diakonos 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. metadata +38 -59
  2. data/CHANGELOG +0 -238
  3. data/LICENCE +0 -21
  4. data/README +0 -75
  5. data/bin/diakonos +0 -6
  6. data/diakonos-256-colour.conf +0 -102
  7. data/diakonos.conf +0 -1233
  8. data/lib/diakonos.rb +0 -618
  9. data/lib/diakonos/array.rb +0 -15
  10. data/lib/diakonos/bignum.rb +0 -9
  11. data/lib/diakonos/bookmark.rb +0 -50
  12. data/lib/diakonos/buffer-hash.rb +0 -60
  13. data/lib/diakonos/buffer-management.rb +0 -73
  14. data/lib/diakonos/buffer.rb +0 -2044
  15. data/lib/diakonos/clipboard.rb +0 -47
  16. data/lib/diakonos/config.rb +0 -304
  17. data/lib/diakonos/ctag.rb +0 -28
  18. data/lib/diakonos/display.rb +0 -288
  19. data/lib/diakonos/enumerable.rb +0 -15
  20. data/lib/diakonos/finding.rb +0 -32
  21. data/lib/diakonos/fixnum.rb +0 -17
  22. data/lib/diakonos/functions.rb +0 -1420
  23. data/lib/diakonos/grep.rb +0 -78
  24. data/lib/diakonos/hash.rb +0 -108
  25. data/lib/diakonos/help.rb +0 -92
  26. data/lib/diakonos/hooks.rb +0 -13
  27. data/lib/diakonos/interaction.rb +0 -139
  28. data/lib/diakonos/keycode.rb +0 -110
  29. data/lib/diakonos/keying.rb +0 -124
  30. data/lib/diakonos/list.rb +0 -55
  31. data/lib/diakonos/logging.rb +0 -24
  32. data/lib/diakonos/object.rb +0 -6
  33. data/lib/diakonos/readline.rb +0 -274
  34. data/lib/diakonos/regexp.rb +0 -6
  35. data/lib/diakonos/sessions.rb +0 -70
  36. data/lib/diakonos/sized-array.rb +0 -48
  37. data/lib/diakonos/string.rb +0 -326
  38. data/lib/diakonos/text-mark.rb +0 -19
  39. data/lib/diakonos/vendor/fuzzy_file_finder.rb +0 -353
  40. data/lib/diakonos/window.rb +0 -32
  41. data/test/buffer-test.rb +0 -53
  42. data/test/clipboard-test.rb +0 -70
  43. data/test/diakonos-test.rb +0 -14
  44. data/test/hash-test.rb +0 -404
  45. data/test/regexp-test.rb +0 -26
  46. data/test/sizedarray-test.rb +0 -113
  47. data/test/string-test.rb +0 -160
@@ -1,6 +0,0 @@
1
- class Regexp
2
- def uses_bos
3
- source[ 0 ] == ?^
4
- end
5
- end
6
-
@@ -1,70 +0,0 @@
1
- module Diakonos
2
- class Diakonos
3
-
4
- def new_session( filepath )
5
- basename = File.basename( filepath )
6
- if not pid_session?( filepath )
7
- name = basename
8
- end
9
- @session = {
10
- 'filename' => File.expand_path( filepath ),
11
- 'settings' => Hash.new,
12
- 'name' => name,
13
- 'files' => [],
14
- 'dir' => Dir.getwd,
15
- }
16
- end
17
-
18
- def load_session_data( filename )
19
- return if not File.exist? filename
20
- File.open( filename ) do |f|
21
- loaded = YAML::load( f )
22
- if loaded
23
- if(
24
- loaded[ 'filename' ] and
25
- loaded[ 'settings' ] and
26
- loaded[ 'settings' ].respond_to?( :values ) and
27
- loaded[ 'name' ] and
28
- loaded[ 'files' ] and
29
- loaded[ 'files' ].respond_to?( :each )
30
- )
31
- @session = loaded
32
- end
33
- end
34
- end
35
- end
36
-
37
- def save_session( session_file = @session[ 'filename' ] )
38
- return if session_file.nil?
39
- @session[ 'files' ] = @buffers.collect { |filepath,buffer|
40
- buffer.name ? filepath : nil
41
- }.compact
42
- File.open( session_file, 'w' ) do |f|
43
- f.puts @session.to_yaml
44
- end
45
- end
46
-
47
- def session_filepath_for( session_id )
48
- if session_id and session_id !~ %r{/}
49
- "#{@session_dir}/#{session_id}"
50
- else
51
- session_id
52
- end
53
- end
54
-
55
- def pid_session?( path = @session[ 'filename' ] )
56
- %r{/\d+$} === path
57
- end
58
-
59
- def increase_grep_context
60
- current = settings[ 'grep.context' ]
61
- @session[ 'settings' ][ 'grep.context' ] = current + 1
62
- end
63
- def decrease_grep_context
64
- current = settings[ 'grep.context' ]
65
- if current > 0
66
- @session[ 'settings' ][ 'grep.context' ] = current - 1
67
- end
68
- end
69
- end
70
- end
@@ -1,48 +0,0 @@
1
- class SizedArray < Array
2
- attr_reader :capacity
3
-
4
- def initialize( capacity = 10, *args )
5
- @capacity = capacity
6
- super( *args )
7
- end
8
-
9
- def resize
10
- if size > @capacity
11
- slice!( (0...-@capacity) )
12
- end
13
- end
14
- private :resize
15
-
16
- def concat( other_array )
17
- super( other_array )
18
- resize
19
- self
20
- end
21
-
22
- def fill( *args )
23
- retval = super( *args )
24
- resize
25
- self
26
- end
27
-
28
- def <<( item )
29
- retval = super( item )
30
- if size > @capacity
31
- retval = shift
32
- end
33
- retval
34
- end
35
-
36
- def push( item )
37
- self << item
38
- end
39
-
40
- def unshift( item )
41
- retval = super( item )
42
- if size > @capacity
43
- retval = pop
44
- end
45
- retval
46
- end
47
- end
48
-
@@ -1,326 +0,0 @@
1
- class String
2
- def subHome
3
- gsub( /~/, ENV[ "HOME" ] )
4
- end
5
-
6
- def keyCode
7
- retval = nil
8
- case downcase
9
- when "down"
10
- retval = Curses::KEY_DOWN
11
- when "up"
12
- retval = Curses::KEY_UP
13
- when "left"
14
- retval = Curses::KEY_LEFT
15
- when "right"
16
- retval = Curses::KEY_RIGHT
17
- when "home"
18
- retval = Curses::KEY_HOME
19
- when "end"
20
- retval = Curses::KEY_END
21
- when "insert", "ins"
22
- retval = Curses::KEY_IC
23
- when "delete", "del"
24
- retval = Curses::KEY_DC
25
- when "backspace"
26
- retval = Diakonos::BACKSPACE
27
- when "tab"
28
- retval = 9
29
- when "pageup", "page-up"
30
- retval = Curses::KEY_PPAGE
31
- when "pagedown", "page-down"
32
- retval = Curses::KEY_NPAGE
33
- when "enter", "return"
34
- retval = Diakonos::ENTER
35
- when "numpad7", "keypad7", "kp-7"
36
- retval = Curses::KEY_A1
37
- when "numpad9", "keypad9", "kp-9"
38
- retval = Curses::KEY_A3
39
- when "numpad5", "keypad5", "kp-5"
40
- retval = Curses::KEY_B2
41
- when "numpad1", "keypad1", "kp-1"
42
- retval = Curses::KEY_C1
43
- when "numpad3", "keypad3", "kp-3"
44
- retval = Curses::KEY_C3
45
- when "escape", "esc"
46
- retval = Diakonos::ESCAPE
47
- when "space"
48
- retval = 32
49
- when "ctrl+space"
50
- retval = 0
51
- when "find"
52
- retval = Curses::KEY_FIND
53
- when "select"
54
- retval = Curses::KEY_SELECT
55
- when "suspend"
56
- retval = Curses::KEY_SUSPEND
57
- when /^f(\d\d?)$/
58
- retval = Curses::KEY_F0 + $1.to_i
59
- when /^ctrl\+[a-gi-z]$/
60
- retval = downcase[ -1 ].ord - 96
61
- when /^ctrl\+h$/
62
- retval = Diakonos::CTRL_H
63
- when /^alt\+(.)$/
64
- retval = [ Diakonos::ESCAPE, $1[ 0 ].ord ]
65
- when /^ctrl\+alt\+(.)$/, /^alt\+ctrl\+(.)$/
66
- retval = [ Diakonos::ESCAPE, downcase[ -1 ].ord - 96 ]
67
- when /^keycode(\d+)$/
68
- retval = $1.to_i
69
- when /^.$/
70
- retval = self[ 0 ].ord
71
- end
72
- if retval.class != Array
73
- retval = [ retval ]
74
- end
75
- retval
76
- end
77
-
78
- def toFormatting
79
- formatting = Curses::A_NORMAL
80
- split( /\s+/ ).each do |format|
81
- case format.downcase
82
- when "normal"
83
- formatting = Curses::A_NORMAL
84
- when "black", "0"
85
- formatting = formatting | Curses::color_pair( Curses::COLOR_BLACK )
86
- when "red", "1"
87
- formatting = formatting | Curses::color_pair( Curses::COLOR_RED )
88
- when "green", "2"
89
- formatting = formatting | Curses::color_pair( Curses::COLOR_GREEN )
90
- when "yellow", "brown", "3"
91
- formatting = formatting | Curses::color_pair( Curses::COLOR_YELLOW )
92
- when "blue", "4"
93
- formatting = formatting | Curses::color_pair( Curses::COLOR_BLUE )
94
- when "magenta", "purple", "5"
95
- formatting = formatting | Curses::color_pair( Curses::COLOR_MAGENTA )
96
- when "cyan", "6"
97
- formatting = formatting | Curses::color_pair( Curses::COLOR_CYAN )
98
- when "white", "7"
99
- formatting = formatting | Curses::color_pair( Curses::COLOR_WHITE )
100
- when "standout", "s", "so"
101
- formatting = formatting | Curses::A_STANDOUT
102
- when "underline", "u", "un", "ul"
103
- formatting = formatting | Curses::A_UNDERLINE
104
- when "reverse", "r", "rev", "inverse", "i", "inv"
105
- formatting = formatting | Curses::A_REVERSE
106
- when "blink", "bl", "blinking"
107
- formatting = formatting | Curses::A_BLINK
108
- when "dim", "d"
109
- formatting = formatting | Curses::A_DIM
110
- when "bold", "b", "bo"
111
- formatting = formatting | Curses::A_BOLD
112
- else
113
- if ( colour_number = format.to_i ) > Curses::COLOR_WHITE
114
- formatting = formatting | Curses::color_pair( colour_number )
115
- end
116
- end
117
- end
118
- formatting
119
- end
120
-
121
- def toColourConstant
122
- case downcase
123
- when "black", "0"
124
- Curses::COLOR_BLACK
125
- when "red", "1"
126
- Curses::COLOR_RED
127
- when "green", "2"
128
- Curses::COLOR_GREEN
129
- when "yellow", "brown", "3"
130
- Curses::COLOR_YELLOW
131
- when "blue", "4"
132
- Curses::COLOR_BLUE
133
- when "magenta", "purple", "5"
134
- Curses::COLOR_MAGENTA
135
- when "cyan", "6"
136
- Curses::COLOR_CYAN
137
- when "white", "7"
138
- Curses::COLOR_WHITE
139
- else
140
- to_i
141
- end
142
- end
143
-
144
- def toDirection( default = :down )
145
- direction = nil
146
- case self
147
- when "up"
148
- direction = :up
149
- when /other/
150
- direction = :opposite
151
- when "down"
152
- direction = :down
153
- when "forward"
154
- direction = :forward
155
- when "backward"
156
- direction = :backward
157
- else
158
- direction = default
159
- end
160
- direction
161
- end
162
-
163
- def to_a
164
- [ self ]
165
- end
166
-
167
- def to_b
168
- case downcase
169
- when "true", "t", "1", "yes", "y", "on", "+"
170
- true
171
- else
172
- false
173
- end
174
- end
175
-
176
- def indentation_level( indent_size, indent_roundup, tab_size = Diakonos::DEFAULT_TAB_SIZE, indent_ignore_charset = nil )
177
- if indent_ignore_charset.nil?
178
- level = 0
179
- if self =~ /^([\s]+)/
180
- #whitespace = $1.gsub( /\t/, ' ' * tab_size )
181
- whitespace = $1.expandTabs( tab_size )
182
- level = whitespace.length / indent_size
183
- if indent_roundup and ( whitespace.length % indent_size > 0 )
184
- level += 1
185
- end
186
- end
187
- else
188
- if self =~ /^[\s#{indent_ignore_charset}]*$/ or self == ""
189
- level = -1
190
- elsif self =~ /^([\s#{indent_ignore_charset}]+)/
191
- #whitespace = $1.gsub( /\t/, ' ' * tab_size )
192
- whitespace = $1.expandTabs( tab_size )
193
- level = whitespace.length / indent_size
194
- if indent_roundup and ( whitespace.length % indent_size > 0 )
195
- level += 1
196
- end
197
- else
198
- level = 0
199
- end
200
- end
201
-
202
- level
203
- end
204
-
205
- def expandTabs( tab_size = Diakonos::DEFAULT_TAB_SIZE )
206
- s = dup
207
- while s.sub!( /\t/ ) { |match_text|
208
- match = Regexp.last_match
209
- index = match.begin( 0 )
210
- # Return value for block:
211
- " " * ( tab_size - ( index % tab_size ) )
212
- }
213
- end
214
- s
215
- end
216
-
217
- def newlineSplit
218
- retval = split( /\\n/ )
219
- if self =~ /\\n$/
220
- retval << ""
221
- end
222
- if retval.length > 1
223
- retval[ 0 ] << "$"
224
- retval[ 1..-2 ].collect do |el|
225
- "^" << el << "$"
226
- end
227
- retval[ -1 ] = "^" << retval[ -1 ]
228
- end
229
- retval
230
- end
231
-
232
- # Works like normal String#index except returns the index
233
- # of the first matching regexp group if one or more groups are specified
234
- # in the regexp. Both the index and the matched text are returned.
235
- def group_index( regexp, offset = 0 )
236
- if regexp.class != Regexp
237
- return index( regexp, offset )
238
- end
239
-
240
- i = nil
241
- match_text = nil
242
- working_offset = 0
243
- loop do
244
- index( regexp, working_offset )
245
- match = Regexp.last_match
246
- if match
247
- i = match.begin( 0 )
248
- match_text = match[ 0 ]
249
- if match.length > 1
250
- # Find first matching group
251
- 1.upto( match.length - 1 ) do |match_item_index|
252
- if match[ match_item_index ]
253
- i = match.begin( match_item_index )
254
- match_text = match[ match_item_index ]
255
- break
256
- end
257
- end
258
- end
259
-
260
- break if i >= offset
261
- else
262
- i = nil
263
- break
264
- end
265
- working_offset += 1
266
- end
267
-
268
- [ i, match_text ]
269
- end
270
-
271
- # Works like normal String#rindex except returns the index
272
- # of the first matching regexp group if one or more groups are specified
273
- # in the regexp. Both the index and the matched text are returned.
274
- def group_rindex( regexp, offset = length )
275
- if regexp.class != Regexp
276
- return rindex( regexp, offset )
277
- end
278
-
279
- i = nil
280
- match_text = nil
281
- working_offset = length
282
- loop do
283
- rindex( regexp, working_offset )
284
- match = Regexp.last_match
285
- if match
286
- i = match.end( 0 ) - 1
287
- match_text = match[ 0 ]
288
- if match.length > 1
289
- # Find first matching group
290
- 1.upto( match.length - 1 ) do |match_item_index|
291
- if match[ match_item_index ]
292
- i = match.end( match_item_index ) - 1
293
- match_text = match[ match_item_index ]
294
- break
295
- end
296
- end
297
- end
298
-
299
- if match_text == ""
300
- # Assume that an empty string means that it matched $
301
- i += 1
302
- end
303
-
304
- break if i <= offset
305
- else
306
- i = nil
307
- break
308
- end
309
- working_offset -= 1
310
- end
311
-
312
- [ i, match_text ]
313
- end
314
-
315
- def movement?
316
- self =~ /^((cursor|page|scroll)(Up|Down|Left|Right)|find)/
317
- end
318
-
319
- # Backport of Ruby 1.9's String#ord into Ruby 1.8
320
- unless method_defined?( :ord )
321
- def ord
322
- self[ 0 ]
323
- end
324
- end
325
- end
326
-