diakonos 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- metadata +38 -59
- data/CHANGELOG +0 -238
- data/LICENCE +0 -21
- data/README +0 -75
- data/bin/diakonos +0 -6
- data/diakonos-256-colour.conf +0 -102
- data/diakonos.conf +0 -1233
- data/lib/diakonos.rb +0 -618
- data/lib/diakonos/array.rb +0 -15
- data/lib/diakonos/bignum.rb +0 -9
- data/lib/diakonos/bookmark.rb +0 -50
- data/lib/diakonos/buffer-hash.rb +0 -60
- data/lib/diakonos/buffer-management.rb +0 -73
- data/lib/diakonos/buffer.rb +0 -2044
- data/lib/diakonos/clipboard.rb +0 -47
- data/lib/diakonos/config.rb +0 -304
- data/lib/diakonos/ctag.rb +0 -28
- data/lib/diakonos/display.rb +0 -288
- data/lib/diakonos/enumerable.rb +0 -15
- data/lib/diakonos/finding.rb +0 -32
- data/lib/diakonos/fixnum.rb +0 -17
- data/lib/diakonos/functions.rb +0 -1420
- data/lib/diakonos/grep.rb +0 -78
- data/lib/diakonos/hash.rb +0 -108
- data/lib/diakonos/help.rb +0 -92
- data/lib/diakonos/hooks.rb +0 -13
- data/lib/diakonos/interaction.rb +0 -139
- data/lib/diakonos/keycode.rb +0 -110
- data/lib/diakonos/keying.rb +0 -124
- data/lib/diakonos/list.rb +0 -55
- data/lib/diakonos/logging.rb +0 -24
- data/lib/diakonos/object.rb +0 -6
- data/lib/diakonos/readline.rb +0 -274
- data/lib/diakonos/regexp.rb +0 -6
- data/lib/diakonos/sessions.rb +0 -70
- data/lib/diakonos/sized-array.rb +0 -48
- data/lib/diakonos/string.rb +0 -326
- data/lib/diakonos/text-mark.rb +0 -19
- data/lib/diakonos/vendor/fuzzy_file_finder.rb +0 -353
- data/lib/diakonos/window.rb +0 -32
- data/test/buffer-test.rb +0 -53
- data/test/clipboard-test.rb +0 -70
- data/test/diakonos-test.rb +0 -14
- data/test/hash-test.rb +0 -404
- data/test/regexp-test.rb +0 -26
- data/test/sizedarray-test.rb +0 -113
- data/test/string-test.rb +0 -160
data/lib/diakonos/keying.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
module Diakonos
|
2
|
-
class Diakonos
|
3
|
-
def capture_keychain( c, context )
|
4
|
-
if c == ENTER
|
5
|
-
@capturing_keychain = false
|
6
|
-
@current_buffer.deleteSelection
|
7
|
-
str = context.to_keychain_s.strip
|
8
|
-
@current_buffer.insertString str
|
9
|
-
cursorRight( Buffer::STILL_TYPING, str.length )
|
10
|
-
else
|
11
|
-
keychain_pressed = context.concat [ c ]
|
12
|
-
|
13
|
-
function_and_args = @keychains.getLeaf( keychain_pressed )
|
14
|
-
|
15
|
-
if function_and_args
|
16
|
-
function, args = function_and_args
|
17
|
-
end
|
18
|
-
|
19
|
-
partial_keychain = @keychains.getNode( keychain_pressed )
|
20
|
-
if partial_keychain
|
21
|
-
setILine( "Part of existing keychain: " + keychain_pressed.to_keychain_s + "..." )
|
22
|
-
else
|
23
|
-
setILine keychain_pressed.to_keychain_s + "..."
|
24
|
-
end
|
25
|
-
processKeystroke( keychain_pressed )
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def capture_mapping( c, context )
|
30
|
-
if c == ENTER
|
31
|
-
@capturing_mapping = false
|
32
|
-
@current_buffer.deleteSelection
|
33
|
-
setILine
|
34
|
-
else
|
35
|
-
keychain_pressed = context.concat [ c ]
|
36
|
-
|
37
|
-
function_and_args = @keychains.getLeaf( keychain_pressed )
|
38
|
-
|
39
|
-
if function_and_args
|
40
|
-
function, args = function_and_args
|
41
|
-
setILine "#{keychain_pressed.to_keychain_s.strip} -> #{function}( #{args} )"
|
42
|
-
else
|
43
|
-
partial_keychain = @keychains.getNode( keychain_pressed )
|
44
|
-
if partial_keychain
|
45
|
-
setILine( "Several mappings start with: " + keychain_pressed.to_keychain_s + "..." )
|
46
|
-
processKeystroke( keychain_pressed )
|
47
|
-
else
|
48
|
-
setILine "There is no mapping for " + keychain_pressed.to_keychain_s
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# context is an array of characters (bytes) which are keystrokes previously
|
55
|
-
# typed (in a chain of keystrokes)
|
56
|
-
def processKeystroke( context = [] )
|
57
|
-
c = @win_main.getch.ord
|
58
|
-
|
59
|
-
if @capturing_keychain
|
60
|
-
capture_keychain c, context
|
61
|
-
elsif @capturing_mapping
|
62
|
-
capture_mapping c, context
|
63
|
-
else
|
64
|
-
|
65
|
-
if context.empty?
|
66
|
-
if c > 31 and c < 255 and c != BACKSPACE
|
67
|
-
if @macro_history
|
68
|
-
@macro_history.push "typeCharacter #{c}"
|
69
|
-
end
|
70
|
-
@there_was_non_movement = true
|
71
|
-
typeCharacter c
|
72
|
-
return
|
73
|
-
end
|
74
|
-
end
|
75
|
-
keychain_pressed = context.concat [ c ]
|
76
|
-
|
77
|
-
function_and_args = @keychains.getLeaf( keychain_pressed )
|
78
|
-
|
79
|
-
if function_and_args
|
80
|
-
function, args = function_and_args
|
81
|
-
setILine if not @settings[ "context.combined" ]
|
82
|
-
|
83
|
-
if args
|
84
|
-
to_eval = "#{function}( #{args} )"
|
85
|
-
else
|
86
|
-
to_eval = function
|
87
|
-
end
|
88
|
-
|
89
|
-
if @macro_history
|
90
|
-
@macro_history.push to_eval
|
91
|
-
end
|
92
|
-
|
93
|
-
begin
|
94
|
-
eval to_eval, nil, "eval"
|
95
|
-
@last_commands << to_eval unless to_eval == "repeatLast"
|
96
|
-
if not @there_was_non_movement
|
97
|
-
@there_was_non_movement = ( not to_eval.movement? )
|
98
|
-
end
|
99
|
-
rescue Exception => e
|
100
|
-
debugLog e.message
|
101
|
-
debugLog e.backtrace.join( "\n\t" )
|
102
|
-
showException e
|
103
|
-
end
|
104
|
-
else
|
105
|
-
partial_keychain = @keychains.getNode( keychain_pressed )
|
106
|
-
if partial_keychain
|
107
|
-
setILine( keychain_pressed.to_keychain_s + "..." )
|
108
|
-
processKeystroke( keychain_pressed )
|
109
|
-
else
|
110
|
-
setILine "Nothing assigned to #{keychain_pressed.to_keychain_s}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
protected :processKeystroke
|
116
|
-
|
117
|
-
def typeCharacter( c )
|
118
|
-
@current_buffer.deleteSelection( Buffer::DONT_DISPLAY )
|
119
|
-
@current_buffer.insertChar c
|
120
|
-
cursorRight( Buffer::STILL_TYPING )
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
124
|
-
end
|
data/lib/diakonos/list.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module Diakonos
|
2
|
-
class Diakonos
|
3
|
-
def openListBuffer
|
4
|
-
@list_buffer = openFile( @list_filename )
|
5
|
-
end
|
6
|
-
|
7
|
-
def closeListBuffer
|
8
|
-
closeFile( @list_buffer )
|
9
|
-
@list_buffer = nil
|
10
|
-
end
|
11
|
-
|
12
|
-
def showing_list?
|
13
|
-
@list_buffer
|
14
|
-
end
|
15
|
-
|
16
|
-
def list_item_selected?
|
17
|
-
@list_buffer and @list_buffer.selecting?
|
18
|
-
end
|
19
|
-
|
20
|
-
def current_list_item
|
21
|
-
if @list_buffer
|
22
|
-
@list_buffer.select_current_line
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def select_list_item
|
27
|
-
if @list_buffer
|
28
|
-
line = @list_buffer.select_current_line
|
29
|
-
@list_buffer.display
|
30
|
-
line
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def previous_list_item
|
35
|
-
if @list_buffer
|
36
|
-
cursorUp
|
37
|
-
@list_buffer[ @list_buffer.currentRow ]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def next_list_item
|
42
|
-
if @list_buffer
|
43
|
-
cursorDown
|
44
|
-
@list_buffer[ @list_buffer.currentRow ]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def with_list_file
|
49
|
-
File.open( @list_filename, "w" ) do |f|
|
50
|
-
yield f
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
data/lib/diakonos/logging.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Diakonos
|
2
|
-
class Diakonos
|
3
|
-
def log( string )
|
4
|
-
@log.puts string
|
5
|
-
@log.flush
|
6
|
-
end
|
7
|
-
|
8
|
-
def debugLog( string )
|
9
|
-
@debug.puts( Time.now.strftime( "[%a %H:%M:%S] #{string}" ) )
|
10
|
-
@debug.flush
|
11
|
-
end
|
12
|
-
|
13
|
-
def logBacktrace
|
14
|
-
begin
|
15
|
-
raise Exception
|
16
|
-
rescue Exception => e
|
17
|
-
e.backtrace[ 1..-1 ].each do |x|
|
18
|
-
debugLog x
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
data/lib/diakonos/object.rb
DELETED
data/lib/diakonos/readline.rb
DELETED
@@ -1,274 +0,0 @@
|
|
1
|
-
module Diakonos
|
2
|
-
|
3
|
-
class Readline
|
4
|
-
|
5
|
-
# completion_array is the array of strings that tab completion can use
|
6
|
-
# The block returns true if a refresh is needed?
|
7
|
-
def initialize( diakonos, window, prompt, initial_text = "", completion_array = nil, history = [], do_complete = Diakonos::DONT_COMPLETE, on_dirs = :go_into_dirs, &block )
|
8
|
-
@diakonos = diakonos
|
9
|
-
@window = window
|
10
|
-
@prompt = prompt
|
11
|
-
pos = redraw_prompt
|
12
|
-
@window.setpos( 0, pos )
|
13
|
-
@initial_text = initial_text
|
14
|
-
@completion_array = completion_array
|
15
|
-
@list_filename = @diakonos.list_filename
|
16
|
-
|
17
|
-
@history = history
|
18
|
-
@history << initial_text
|
19
|
-
@history_index = @history.length - 1
|
20
|
-
|
21
|
-
@do_complete = do_complete
|
22
|
-
@on_dirs = on_dirs
|
23
|
-
|
24
|
-
@block = block
|
25
|
-
end
|
26
|
-
|
27
|
-
def redraw_prompt
|
28
|
-
@diakonos.setILine @prompt
|
29
|
-
end
|
30
|
-
|
31
|
-
def call_block
|
32
|
-
if @block
|
33
|
-
@block.call( @input )
|
34
|
-
@window.refresh
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Returns nil on cancel.
|
39
|
-
def readline
|
40
|
-
@input = @initial_text
|
41
|
-
if not @input.empty?
|
42
|
-
call_block
|
43
|
-
end
|
44
|
-
|
45
|
-
@icurx = @window.curx
|
46
|
-
@icury = @window.cury
|
47
|
-
@window.addstr @initial_text
|
48
|
-
@input_cursor = @initial_text.length
|
49
|
-
@opened_list_file = false
|
50
|
-
|
51
|
-
if @do_complete
|
52
|
-
completeInput
|
53
|
-
end
|
54
|
-
|
55
|
-
loop do
|
56
|
-
c = @window.getch.ord
|
57
|
-
|
58
|
-
case c
|
59
|
-
when Curses::KEY_DC
|
60
|
-
if @input_cursor < @input.length
|
61
|
-
@window.delch
|
62
|
-
@input = @input[ 0...@input_cursor ] + @input[ (@input_cursor + 1)..-1 ]
|
63
|
-
call_block
|
64
|
-
end
|
65
|
-
when BACKSPACE, CTRL_H
|
66
|
-
# Curses::KEY_LEFT
|
67
|
-
if @input_cursor > 0
|
68
|
-
@input_cursor += -1
|
69
|
-
@window.setpos( @window.cury, @window.curx - 1 )
|
70
|
-
|
71
|
-
# Curses::KEY_DC
|
72
|
-
if @input_cursor < @input.length
|
73
|
-
@window.delch
|
74
|
-
@input = @input[ 0...@input_cursor ] + @input[ (@input_cursor + 1)..-1 ]
|
75
|
-
call_block
|
76
|
-
end
|
77
|
-
end
|
78
|
-
when ENTER, Curses::KEY_F3
|
79
|
-
item = @diakonos.current_list_item
|
80
|
-
if @on_dirs == :go_into_dirs and item and File.directory? item
|
81
|
-
completeInput
|
82
|
-
else
|
83
|
-
break
|
84
|
-
end
|
85
|
-
when ESCAPE, CTRL_C, CTRL_D, CTRL_Q
|
86
|
-
@input = nil
|
87
|
-
break
|
88
|
-
when Curses::KEY_LEFT
|
89
|
-
if @input_cursor > 0
|
90
|
-
@input_cursor += -1
|
91
|
-
@window.setpos( @window.cury, @window.curx - 1 )
|
92
|
-
end
|
93
|
-
when Curses::KEY_RIGHT
|
94
|
-
if @input_cursor < @input.length
|
95
|
-
@input_cursor += 1
|
96
|
-
@window.setpos( @window.cury, @window.curx + 1 )
|
97
|
-
end
|
98
|
-
when Curses::KEY_HOME
|
99
|
-
@input_cursor = 0
|
100
|
-
@window.setpos( @icury, @icurx )
|
101
|
-
when Curses::KEY_END
|
102
|
-
@input_cursor = @input.length
|
103
|
-
@window.setpos( @window.cury, @icurx + @input.length )
|
104
|
-
when TAB
|
105
|
-
completeInput
|
106
|
-
when Curses::KEY_NPAGE
|
107
|
-
@diakonos.pageDown
|
108
|
-
line = @diakonos.select_list_item
|
109
|
-
if line
|
110
|
-
@input = line
|
111
|
-
cursorWriteInput
|
112
|
-
end
|
113
|
-
when Curses::KEY_PPAGE
|
114
|
-
@diakonos.pageUp
|
115
|
-
line = @diakonos.select_list_item
|
116
|
-
if line
|
117
|
-
@input = line
|
118
|
-
cursorWriteInput
|
119
|
-
end
|
120
|
-
when Curses::KEY_UP
|
121
|
-
if @diakonos.showing_list?
|
122
|
-
if @diakonos.list_item_selected?
|
123
|
-
@diakonos.previous_list_item
|
124
|
-
end
|
125
|
-
@input = @diakonos.select_list_item
|
126
|
-
elsif @history_index > 0
|
127
|
-
@history[ @history_index ] = @input
|
128
|
-
@history_index -= 1
|
129
|
-
@input = @history[ @history_index ]
|
130
|
-
end
|
131
|
-
cursorWriteInput
|
132
|
-
when Curses::KEY_DOWN
|
133
|
-
if @diakonos.showing_list?
|
134
|
-
if @diakonos.list_item_selected?
|
135
|
-
@diakonos.next_list_item
|
136
|
-
end
|
137
|
-
@input = @diakonos.select_list_item
|
138
|
-
elsif @history_index < @history.length - 1
|
139
|
-
@history[ @history_index ] = @input
|
140
|
-
@history_index += 1
|
141
|
-
@input = @history[ @history_index ]
|
142
|
-
end
|
143
|
-
cursorWriteInput
|
144
|
-
when CTRL_K
|
145
|
-
@input = ""
|
146
|
-
if @block
|
147
|
-
@block.call @input
|
148
|
-
end
|
149
|
-
cursorWriteInput
|
150
|
-
when Curses::KEY_F5
|
151
|
-
@diakonos.decrease_grep_context
|
152
|
-
call_block
|
153
|
-
when Curses::KEY_F6
|
154
|
-
@diakonos.increase_grep_context
|
155
|
-
call_block
|
156
|
-
else
|
157
|
-
if c > 31 and c < 255 and c != BACKSPACE
|
158
|
-
if @input_cursor == @input.length
|
159
|
-
@input << c
|
160
|
-
@window.addch c
|
161
|
-
else
|
162
|
-
@input = @input[ 0...@input_cursor ] + c.chr + @input[ @input_cursor..-1 ]
|
163
|
-
@window.setpos( @window.cury, @window.curx + 1 )
|
164
|
-
redrawInput
|
165
|
-
end
|
166
|
-
@input_cursor += 1
|
167
|
-
call_block
|
168
|
-
else
|
169
|
-
@diakonos.log "Other input: #{c}"
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
@diakonos.closeListBuffer
|
175
|
-
|
176
|
-
@history[ -1 ] = @input
|
177
|
-
end
|
178
|
-
|
179
|
-
def redrawInput
|
180
|
-
input = @input[ 0...Curses::cols ]
|
181
|
-
|
182
|
-
curx = @window.curx
|
183
|
-
cury = @window.cury
|
184
|
-
@window.setpos( @icury, @icurx )
|
185
|
-
@window.addstr "%-#{ Curses::cols - curx }s%s" % [ input, " " * ( Curses::cols - input.length ) ]
|
186
|
-
@window.setpos( cury, curx )
|
187
|
-
@window.refresh
|
188
|
-
end
|
189
|
-
|
190
|
-
# Redisplays the input text starting at the start of the user input area,
|
191
|
-
# positioning the cursor at the end of the text.
|
192
|
-
def cursorWriteInput
|
193
|
-
if @input
|
194
|
-
@input_cursor = @input.length
|
195
|
-
@window.setpos( @window.cury, @icurx + @input.length )
|
196
|
-
redrawInput
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def completeInput
|
201
|
-
if @completion_array and @input.length > 0
|
202
|
-
len = @input.length
|
203
|
-
matches = @completion_array.find_all { |el| el[ 0...len ] == @input and len <= el.length }
|
204
|
-
else
|
205
|
-
matches = Dir.glob( ( @input.subHome() + "*" ).gsub( /\*\*/, "*" ) )
|
206
|
-
if @on_dirs == :accept_dirs
|
207
|
-
matches = matches.select { |m| File.directory? m }
|
208
|
-
end
|
209
|
-
end
|
210
|
-
matches.sort!
|
211
|
-
|
212
|
-
if matches.length == 1
|
213
|
-
@input = matches[ 0 ]
|
214
|
-
cursorWriteInput
|
215
|
-
File.open( @list_filename, "w" ) do |f|
|
216
|
-
if @completion_array.nil?
|
217
|
-
f.puts "(unique)"
|
218
|
-
else
|
219
|
-
f.puts @input
|
220
|
-
end
|
221
|
-
end
|
222
|
-
if @completion_array.nil? and FileTest.directory?( @input )
|
223
|
-
@input << "/"
|
224
|
-
cursorWriteInput
|
225
|
-
if @on_dirs != :accept_dirs
|
226
|
-
completeInput
|
227
|
-
end
|
228
|
-
end
|
229
|
-
elsif matches.length > 1
|
230
|
-
common = matches[ 0 ]
|
231
|
-
File.open( @list_filename, "w" ) do |f|
|
232
|
-
i = nil
|
233
|
-
matches.each do |match|
|
234
|
-
f.print match
|
235
|
-
if FileTest.directory?( match )
|
236
|
-
f.print '/'
|
237
|
-
else
|
238
|
-
@diakonos.log "'#{match}' is not a directory"
|
239
|
-
end
|
240
|
-
f.puts
|
241
|
-
|
242
|
-
if match[ 0 ] != common[ 0 ]
|
243
|
-
common = nil
|
244
|
-
break
|
245
|
-
end
|
246
|
-
|
247
|
-
up_to = [ common.length - 1, match.length - 1 ].min
|
248
|
-
i = 1
|
249
|
-
while ( i <= up_to ) and ( match[ 0..i ] == common[ 0..i ] )
|
250
|
-
i += 1
|
251
|
-
end
|
252
|
-
common = common[ 0...i ]
|
253
|
-
end
|
254
|
-
end
|
255
|
-
if common.nil?
|
256
|
-
File.open( @list_filename, "w" ) do |f|
|
257
|
-
f.puts "(no matches)"
|
258
|
-
end
|
259
|
-
else
|
260
|
-
@input = common
|
261
|
-
cursorWriteInput
|
262
|
-
end
|
263
|
-
else
|
264
|
-
File.open( @list_filename, "w" ) do |f|
|
265
|
-
f.puts "(no matches)"
|
266
|
-
end
|
267
|
-
end
|
268
|
-
@diakonos.openListBuffer
|
269
|
-
@window.setpos( @window.cury, @window.curx )
|
270
|
-
end
|
271
|
-
|
272
|
-
end
|
273
|
-
|
274
|
-
end
|