diakonos 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +172 -0
- data/README +75 -0
- data/bin/diakonos +6 -0
- data/diakonos.conf +960 -0
- data/home-on-save.rb +6 -0
- data/lib/diakonos.rb +2397 -0
- data/lib/diakonos/array.rb +10 -0
- data/lib/diakonos/bignum.rb +6 -0
- data/lib/diakonos/bookmark.rb +51 -0
- data/lib/diakonos/buffer-hash.rb +18 -0
- data/lib/diakonos/buffer.rb +1700 -0
- data/lib/diakonos/clipboard.rb +47 -0
- data/lib/diakonos/ctag.rb +28 -0
- data/lib/diakonos/enumerable.rb +15 -0
- data/lib/diakonos/finding.rb +32 -0
- data/lib/diakonos/fixnum.rb +13 -0
- data/lib/diakonos/hash.rb +101 -0
- data/lib/diakonos/keycode.rb +110 -0
- data/lib/diakonos/object.rb +6 -0
- data/lib/diakonos/readline.rb +192 -0
- data/lib/diakonos/regexp.rb +6 -0
- data/lib/diakonos/sized-array.rb +48 -0
- data/lib/diakonos/string.rb +318 -0
- data/lib/diakonos/text-mark.rb +19 -0
- data/lib/diakonos/window.rb +32 -0
- data/test/buffer-test.rb +37 -0
- data/test/clipboard-test.rb +70 -0
- data/test/diakonos-test.rb +14 -0
- data/test/hash-test.rb +404 -0
- data/test/regexp-test.rb +26 -0
- data/test/sizedarray-test.rb +113 -0
- data/test/string-test.rb +160 -0
- metadata +77 -0
data/test/regexp-test.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'diakonos'
|
5
|
+
|
6
|
+
class TC_Regexp < Test::Unit::TestCase
|
7
|
+
def test_uses_bos
|
8
|
+
r = /^test/
|
9
|
+
assert_equal(
|
10
|
+
true, r.uses_bos,
|
11
|
+
"/#{r.source}/.uses_bos should be true"
|
12
|
+
)
|
13
|
+
|
14
|
+
r = /test/
|
15
|
+
assert_equal(
|
16
|
+
false, r.uses_bos,
|
17
|
+
"/#{r.source}/.uses_bos should be false"
|
18
|
+
)
|
19
|
+
|
20
|
+
r = /t^est/
|
21
|
+
assert_equal(
|
22
|
+
false, r.uses_bos,
|
23
|
+
"/#{r.source}/.uses_bos should be false"
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'diakonos'
|
5
|
+
|
6
|
+
class TC_SizedArray < Test::Unit::TestCase
|
7
|
+
def test_initialize
|
8
|
+
a = SizedArray.new( 2 )
|
9
|
+
assert_equal( 2, a.capacity )
|
10
|
+
a = SizedArray.new( 4 )
|
11
|
+
assert_equal( 4, a.capacity )
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_append
|
15
|
+
a = SizedArray.new( 2 )
|
16
|
+
|
17
|
+
assert_equal(
|
18
|
+
[ 1 ],
|
19
|
+
a << 1
|
20
|
+
)
|
21
|
+
assert_equal(
|
22
|
+
[ 1, 2 ],
|
23
|
+
a << 2
|
24
|
+
)
|
25
|
+
assert_equal(
|
26
|
+
1,
|
27
|
+
a << 3
|
28
|
+
)
|
29
|
+
assert_equal(
|
30
|
+
[ 2, 3 ],
|
31
|
+
a
|
32
|
+
)
|
33
|
+
assert_equal(
|
34
|
+
2,
|
35
|
+
a << 1
|
36
|
+
)
|
37
|
+
assert_equal(
|
38
|
+
[ 3, 1 ],
|
39
|
+
a
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_push
|
44
|
+
a = SizedArray.new( 2 )
|
45
|
+
b = SizedArray.new( 2 )
|
46
|
+
|
47
|
+
assert_equal( a, b )
|
48
|
+
|
49
|
+
a << 1
|
50
|
+
b.push 1
|
51
|
+
assert_equal( a, b )
|
52
|
+
a << 2
|
53
|
+
b.push 2
|
54
|
+
assert_equal( a, b )
|
55
|
+
a << 3
|
56
|
+
b.push 3
|
57
|
+
assert_equal( a, b )
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_unshift
|
61
|
+
a = SizedArray.new( 2 )
|
62
|
+
|
63
|
+
assert_equal(
|
64
|
+
[ 1 ],
|
65
|
+
a.unshift( 1 )
|
66
|
+
)
|
67
|
+
assert_equal(
|
68
|
+
[ 2, 1 ],
|
69
|
+
a.unshift( 2 )
|
70
|
+
)
|
71
|
+
assert_equal(
|
72
|
+
1,
|
73
|
+
a.unshift( 3 )
|
74
|
+
)
|
75
|
+
assert_equal(
|
76
|
+
[ 3, 2 ],
|
77
|
+
a
|
78
|
+
)
|
79
|
+
assert_equal(
|
80
|
+
2,
|
81
|
+
a.unshift( 1 )
|
82
|
+
)
|
83
|
+
assert_equal(
|
84
|
+
[ 1, 3 ],
|
85
|
+
a
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_concat
|
90
|
+
a = SizedArray.new( 4 )
|
91
|
+
|
92
|
+
assert_equal(
|
93
|
+
[ 1, 2 ],
|
94
|
+
a.concat( [ 1, 2 ] )
|
95
|
+
)
|
96
|
+
assert_equal(
|
97
|
+
[ 1, 2, 3, 4 ],
|
98
|
+
a.concat( [ 3, 4 ] )
|
99
|
+
)
|
100
|
+
assert_equal(
|
101
|
+
[ 3, 4, 5, 6 ],
|
102
|
+
a.concat( [ 5, 6 ] )
|
103
|
+
)
|
104
|
+
assert_equal(
|
105
|
+
[ 7, 8, 9, 10 ],
|
106
|
+
a.concat( [ 7, 8, 9, 10 ] )
|
107
|
+
)
|
108
|
+
assert_equal(
|
109
|
+
[ 3, 4, 5, 6 ],
|
110
|
+
a.concat( [ 1, 2, 3, 4, 5, 6 ] )
|
111
|
+
)
|
112
|
+
end
|
113
|
+
end
|
data/test/string-test.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'diakonos'
|
5
|
+
|
6
|
+
class TC_String < Test::Unit::TestCase
|
7
|
+
def test_subHome
|
8
|
+
s = "/test"
|
9
|
+
assert_equal(
|
10
|
+
"/test",
|
11
|
+
s.subHome
|
12
|
+
)
|
13
|
+
s = "~/test"
|
14
|
+
assert_equal(
|
15
|
+
"#{ENV[ 'HOME' ]}/test",
|
16
|
+
s.subHome
|
17
|
+
)
|
18
|
+
s = "/this/is/~/test"
|
19
|
+
assert_equal(
|
20
|
+
"/this/is/#{ENV[ 'HOME' ]}/test",
|
21
|
+
s.subHome
|
22
|
+
)
|
23
|
+
s = "~"
|
24
|
+
assert_equal(
|
25
|
+
ENV[ 'HOME' ],
|
26
|
+
s.subHome
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_to_b
|
31
|
+
assert( "true".to_b )
|
32
|
+
assert( "True".to_b )
|
33
|
+
assert( "TRUE".to_b )
|
34
|
+
assert( "tRue".to_b )
|
35
|
+
assert( "t".to_b )
|
36
|
+
assert( "T".to_b )
|
37
|
+
assert( "1".to_b )
|
38
|
+
assert( "yes".to_b )
|
39
|
+
assert( "Yes".to_b )
|
40
|
+
assert( "YES".to_b )
|
41
|
+
assert( "yEs".to_b )
|
42
|
+
assert( "y".to_b )
|
43
|
+
assert( "Y".to_b )
|
44
|
+
assert( "on".to_b )
|
45
|
+
assert( "On".to_b )
|
46
|
+
assert( "ON".to_b )
|
47
|
+
assert( "oN".to_b )
|
48
|
+
assert( "+".to_b )
|
49
|
+
assert_equal( false, "false".to_b )
|
50
|
+
assert_equal( false, "False".to_b )
|
51
|
+
assert_equal( false, "FALSE".to_b )
|
52
|
+
assert_equal( false, "fALse".to_b )
|
53
|
+
assert_equal( false, "f".to_b )
|
54
|
+
assert_equal( false, "F".to_b )
|
55
|
+
assert_equal( false, "n".to_b )
|
56
|
+
assert_equal( false, "N".to_b )
|
57
|
+
assert_equal( false, "x".to_b )
|
58
|
+
assert_equal( false, "X".to_b )
|
59
|
+
assert_equal( false, "0".to_b )
|
60
|
+
assert_equal( false, "2".to_b )
|
61
|
+
assert_equal( false, "no".to_b )
|
62
|
+
assert_equal( false, "No".to_b )
|
63
|
+
assert_equal( false, "NO".to_b )
|
64
|
+
assert_equal( false, "nO".to_b )
|
65
|
+
assert_equal( false, "off".to_b )
|
66
|
+
assert_equal( false, "Off".to_b )
|
67
|
+
assert_equal( false, "OFF".to_b )
|
68
|
+
assert_equal( false, "oFf".to_b )
|
69
|
+
assert_equal( false, "-".to_b )
|
70
|
+
assert_equal( false, "*".to_b )
|
71
|
+
assert_equal( false, "foobar".to_b )
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_indentation_level
|
75
|
+
s = "x"
|
76
|
+
assert_equal( 0, s.indentation_level( 4, true ) )
|
77
|
+
assert_equal( 0, s.indentation_level( 4, false ) )
|
78
|
+
s = " x"
|
79
|
+
assert_equal( 1, s.indentation_level( 4, true ) )
|
80
|
+
assert_equal( 0, s.indentation_level( 4, false ) )
|
81
|
+
s = " x"
|
82
|
+
assert_equal( 1, s.indentation_level( 4, true ) )
|
83
|
+
assert_equal( 1, s.indentation_level( 4, false ) )
|
84
|
+
s = " x"
|
85
|
+
assert_equal( 2, s.indentation_level( 4, true ) )
|
86
|
+
assert_equal( 1, s.indentation_level( 4, false ) )
|
87
|
+
s = " x"
|
88
|
+
assert_equal( 2, s.indentation_level( 4, true ) )
|
89
|
+
assert_equal( 2, s.indentation_level( 4, false ) )
|
90
|
+
s = "\tx"
|
91
|
+
assert_equal( 2, s.indentation_level( 4, true, 8 ) )
|
92
|
+
assert_equal( 2, s.indentation_level( 4, false, 8 ) )
|
93
|
+
s = "\t\tx"
|
94
|
+
assert_equal( 4, s.indentation_level( 4, true, 8 ) )
|
95
|
+
assert_equal( 4, s.indentation_level( 4, false, 8 ) )
|
96
|
+
s = "\t x"
|
97
|
+
assert_equal( 3, s.indentation_level( 4, true, 8 ) )
|
98
|
+
assert_equal( 2, s.indentation_level( 4, false, 8 ) )
|
99
|
+
s = "\t x"
|
100
|
+
assert_equal( 3, s.indentation_level( 4, true, 8 ) )
|
101
|
+
assert_equal( 3, s.indentation_level( 4, false, 8 ) )
|
102
|
+
s = "\t \tx"
|
103
|
+
assert_equal( 4, s.indentation_level( 4, true, 8 ) )
|
104
|
+
assert_equal( 4, s.indentation_level( 4, false, 8 ) )
|
105
|
+
s = "\t \t x"
|
106
|
+
assert_equal( 5, s.indentation_level( 4, true, 8 ) )
|
107
|
+
assert_equal( 4, s.indentation_level( 4, false, 8 ) )
|
108
|
+
s = "\t \t x"
|
109
|
+
assert_equal( 5, s.indentation_level( 4, true, 8 ) )
|
110
|
+
assert_equal( 4, s.indentation_level( 4, false, 8 ) )
|
111
|
+
s = "\t \t x"
|
112
|
+
assert_equal( 5, s.indentation_level( 4, true, 8 ) )
|
113
|
+
assert_equal( 5, s.indentation_level( 4, false, 8 ) )
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_expandTabs
|
117
|
+
s = " "
|
118
|
+
assert_equal( s, s.expandTabs( 8 ) )
|
119
|
+
s = "\t"
|
120
|
+
assert_equal( " " * 8, s.expandTabs( 8 ) )
|
121
|
+
s = "\t\t"
|
122
|
+
assert_equal( " " * 8*2, s.expandTabs( 8 ) )
|
123
|
+
s = "\t \t"
|
124
|
+
assert_equal( " " * 8*2, s.expandTabs( 8 ) )
|
125
|
+
s = "\t \t "
|
126
|
+
assert_equal( " " * (8*2 + 2), s.expandTabs( 8 ) )
|
127
|
+
s = "\t \t"
|
128
|
+
assert_equal( " " * 8*3, s.expandTabs( 8 ) )
|
129
|
+
s = "\t \t"
|
130
|
+
assert_equal( " " * 8*3, s.expandTabs( 8 ) )
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_group_index
|
134
|
+
s = "abc def ghi"
|
135
|
+
assert_equal(
|
136
|
+
[ 0, "abc" ],
|
137
|
+
s.group_index( /abc/ )
|
138
|
+
)
|
139
|
+
assert_equal(
|
140
|
+
[ 4, "def" ],
|
141
|
+
s.group_index( /def/ )
|
142
|
+
)
|
143
|
+
assert_equal(
|
144
|
+
[ 1, "b" ],
|
145
|
+
s.group_index( /a(b)c/ )
|
146
|
+
)
|
147
|
+
assert_equal(
|
148
|
+
[ 1, "b" ],
|
149
|
+
s.group_index( /a(b)c d(e)f/ )
|
150
|
+
)
|
151
|
+
assert_equal(
|
152
|
+
[ nil, nil ],
|
153
|
+
s.group_index( /q/ )
|
154
|
+
)
|
155
|
+
assert_equal(
|
156
|
+
[ 3, '' ],
|
157
|
+
s.group_index( /abc(q?)/ )
|
158
|
+
)
|
159
|
+
end
|
160
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: diakonos
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.8.3
|
7
|
+
date: 2007-02-22 00:00:00 -05:00
|
8
|
+
summary: A usable console-based text editor.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: pistos at purepistos dot net
|
12
|
+
homepage: http://purepistos.net/diakonos
|
13
|
+
rubyforge_project: diakonos
|
14
|
+
description: Diakonos is a customizable, usable console-based text editor.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Pistos
|
31
|
+
files:
|
32
|
+
- CHANGELOG
|
33
|
+
- README
|
34
|
+
- home-on-save.rb
|
35
|
+
- diakonos.conf
|
36
|
+
- bin/diakonos
|
37
|
+
- lib/diakonos.rb
|
38
|
+
- lib/diakonos/finding.rb
|
39
|
+
- lib/diakonos/ctag.rb
|
40
|
+
- lib/diakonos/array.rb
|
41
|
+
- lib/diakonos/enumerable.rb
|
42
|
+
- lib/diakonos/bignum.rb
|
43
|
+
- lib/diakonos/readline.rb
|
44
|
+
- lib/diakonos/keycode.rb
|
45
|
+
- lib/diakonos/hash.rb
|
46
|
+
- lib/diakonos/sized-array.rb
|
47
|
+
- lib/diakonos/regexp.rb
|
48
|
+
- lib/diakonos/buffer-hash.rb
|
49
|
+
- lib/diakonos/clipboard.rb
|
50
|
+
- lib/diakonos/bookmark.rb
|
51
|
+
- lib/diakonos/object.rb
|
52
|
+
- lib/diakonos/fixnum.rb
|
53
|
+
- lib/diakonos/string.rb
|
54
|
+
- lib/diakonos/window.rb
|
55
|
+
- lib/diakonos/buffer.rb
|
56
|
+
- lib/diakonos/text-mark.rb
|
57
|
+
test_files:
|
58
|
+
- test/hash-test.rb
|
59
|
+
- test/string-test.rb
|
60
|
+
- test/diakonos-test.rb
|
61
|
+
- test/buffer-test.rb
|
62
|
+
- test/regexp-test.rb
|
63
|
+
- test/sizedarray-test.rb
|
64
|
+
- test/clipboard-test.rb
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
extra_rdoc_files:
|
68
|
+
- README
|
69
|
+
- CHANGELOG
|
70
|
+
executables:
|
71
|
+
- diakonos
|
72
|
+
extensions: []
|
73
|
+
|
74
|
+
requirements:
|
75
|
+
- curses library for Ruby (not in default Ruby install on Debian or FreeBSD; not sufficiently implemented on Windows)
|
76
|
+
dependencies: []
|
77
|
+
|