diakonos 0.8.11 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +433 -0
- data/LICENCE.md +675 -0
- data/bin/diakonos +6 -0
- data/diakonos-256-colour.conf +220 -0
- data/diakonos.conf +1802 -0
- data/help/about-help.dhf +31 -0
- data/help/clipboard.dhf +45 -0
- data/help/close-file.dhf +6 -0
- data/help/code-block-navigation.dhf +16 -0
- data/help/column-markers.dhf +15 -0
- data/help/config.dhf +69 -0
- data/help/cursor-stack.dhf +19 -0
- data/help/delete.dhf +41 -0
- data/help/extensions.dhf +125 -0
- data/help/file-type.dhf +24 -0
- data/help/key-mapping.dhf +127 -0
- data/help/line-numbers.dhf +22 -0
- data/help/macros.dhf +27 -0
- data/help/new-file.dhf +6 -0
- data/help/open-file.dhf +21 -0
- data/help/quit.dhf +7 -0
- data/help/resizing.dhf +19 -0
- data/help/ruby.dhf +17 -0
- data/help/save-file.dhf +10 -0
- data/help/scripting.dhf +92 -0
- data/help/search.dhf +103 -0
- data/help/shell.dhf +60 -0
- data/help/speed.dhf +23 -0
- data/help/support.dhf +15 -0
- data/help/switch-buffers.dhf +15 -0
- data/help/tabs.dhf +36 -0
- data/help/undo.dhf +9 -0
- data/help/uninstall.dhf +18 -0
- data/help/welcome.dhf +32 -0
- data/help/word-wrap.dhf +17 -0
- data/lib/diakonos/about.rb +69 -0
- data/lib/diakonos/bookmark.rb +46 -0
- data/lib/diakonos/buffer/bookmarking.rb +47 -0
- data/lib/diakonos/buffer/cursor.rb +335 -0
- data/lib/diakonos/buffer/delete.rb +170 -0
- data/lib/diakonos/buffer/display.rb +356 -0
- data/lib/diakonos/buffer/file.rb +157 -0
- data/lib/diakonos/buffer/indentation.rb +175 -0
- data/lib/diakonos/buffer/searching.rb +552 -0
- data/lib/diakonos/buffer/selection.rb +360 -0
- data/lib/diakonos/buffer/undo.rb +73 -0
- data/lib/diakonos/buffer-hash.rb +60 -0
- data/lib/diakonos/buffer-management.rb +59 -0
- data/lib/diakonos/buffer.rb +698 -0
- data/lib/diakonos/clipboard-klipper-dbus.rb +62 -0
- data/lib/diakonos/clipboard-klipper.rb +62 -0
- data/lib/diakonos/clipboard-osx.rb +59 -0
- data/lib/diakonos/clipboard-xclip.rb +60 -0
- data/lib/diakonos/clipboard.rb +47 -0
- data/lib/diakonos/config-file.rb +67 -0
- data/lib/diakonos/config.rb +381 -0
- data/lib/diakonos/core-ext/enumerable.rb +15 -0
- data/lib/diakonos/core-ext/hash.rb +60 -0
- data/lib/diakonos/core-ext/object.rb +6 -0
- data/lib/diakonos/core-ext/regexp.rb +6 -0
- data/lib/diakonos/core-ext/string.rb +122 -0
- data/lib/diakonos/ctag.rb +28 -0
- data/lib/diakonos/cursor.rb +27 -0
- data/lib/diakonos/display/format.rb +75 -0
- data/lib/diakonos/display.rb +336 -0
- data/lib/diakonos/extension-set.rb +49 -0
- data/lib/diakonos/extension.rb +34 -0
- data/lib/diakonos/finding.rb +40 -0
- data/lib/diakonos/functions/basics.rb +34 -0
- data/lib/diakonos/functions/bookmarking.rb +61 -0
- data/lib/diakonos/functions/buffers.rb +489 -0
- data/lib/diakonos/functions/clipboard.rb +70 -0
- data/lib/diakonos/functions/cursor.rb +264 -0
- data/lib/diakonos/functions/grepping.rb +83 -0
- data/lib/diakonos/functions/indentation.rb +71 -0
- data/lib/diakonos/functions/readline.rb +93 -0
- data/lib/diakonos/functions/search.rb +179 -0
- data/lib/diakonos/functions/selection.rb +98 -0
- data/lib/diakonos/functions/sessions.rb +78 -0
- data/lib/diakonos/functions/shell.rb +250 -0
- data/lib/diakonos/functions/tags.rb +65 -0
- data/lib/diakonos/functions/text-manipulation.rb +196 -0
- data/lib/diakonos/functions-deprecated.rb +77 -0
- data/lib/diakonos/functions.rb +292 -0
- data/lib/diakonos/grep.rb +98 -0
- data/lib/diakonos/help.rb +47 -0
- data/lib/diakonos/hooks.rb +13 -0
- data/lib/diakonos/installation.rb +19 -0
- data/lib/diakonos/interaction-handler.rb +216 -0
- data/lib/diakonos/interaction.rb +52 -0
- data/lib/diakonos/key-map.rb +62 -0
- data/lib/diakonos/keying.rb +442 -0
- data/lib/diakonos/line-mover.rb +42 -0
- data/lib/diakonos/list.rb +59 -0
- data/lib/diakonos/logging.rb +27 -0
- data/lib/diakonos/mode.rb +17 -0
- data/lib/diakonos/mouse.rb +18 -0
- data/lib/diakonos/number-fitter.rb +11 -0
- data/lib/diakonos/range.rb +31 -0
- data/lib/diakonos/readline/functions.rb +82 -0
- data/lib/diakonos/readline.rb +222 -0
- data/lib/diakonos/search.rb +58 -0
- data/lib/diakonos/sessions.rb +257 -0
- data/lib/diakonos/sized-array.rb +48 -0
- data/lib/diakonos/text-mark.rb +19 -0
- data/lib/diakonos/vendor/fuzzy_file_finder.rb +365 -0
- data/lib/diakonos/version.rb +25 -0
- data/lib/diakonos/window.rb +43 -0
- data/lib/diakonos.rb +592 -0
- metadata +160 -68
@@ -0,0 +1,335 @@
|
|
1
|
+
module Diakonos
|
2
|
+
|
3
|
+
class Buffer
|
4
|
+
|
5
|
+
attr_reader :last_col, :last_row, :last_screen_x, :last_screen_y, :last_screen_col
|
6
|
+
|
7
|
+
# Returns true iff the cursor changed positions in the buffer.
|
8
|
+
def cursor_to( row, col, do_display = DONT_DISPLAY, stopped_typing = STOPPED_TYPING, adjust_row = ADJUST_ROW )
|
9
|
+
old_last_row = @last_row
|
10
|
+
old_last_col = @last_col
|
11
|
+
|
12
|
+
row = NumberFitter.fit(
|
13
|
+
number: row,
|
14
|
+
min: 0,
|
15
|
+
max: @lines.length - 1,
|
16
|
+
)
|
17
|
+
|
18
|
+
if col < 0
|
19
|
+
if adjust_row
|
20
|
+
if row > 0
|
21
|
+
row = row - 1
|
22
|
+
col = @lines[ row ].length
|
23
|
+
else
|
24
|
+
col = 0
|
25
|
+
end
|
26
|
+
else
|
27
|
+
col = 0
|
28
|
+
end
|
29
|
+
elsif col > @lines[ row ].length
|
30
|
+
if adjust_row
|
31
|
+
if row < @lines.length - 1
|
32
|
+
row = row + 1
|
33
|
+
col = 0
|
34
|
+
else
|
35
|
+
col = @lines[ row ].length
|
36
|
+
end
|
37
|
+
else
|
38
|
+
col = @lines[ row ].length
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if adjust_row
|
43
|
+
@desired_column = col
|
44
|
+
else
|
45
|
+
goto_col = [ @desired_column, @lines[ row ].length ].min
|
46
|
+
if col < goto_col
|
47
|
+
col = goto_col
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
new_col = tab_expanded_column( col, row )
|
52
|
+
view_changed = show_character( row, new_col )
|
53
|
+
@last_screen_y = row - @top_line
|
54
|
+
@last_screen_x = new_col - @left_column
|
55
|
+
|
56
|
+
@typing = false if stopped_typing
|
57
|
+
@last_row = row
|
58
|
+
@last_col = col
|
59
|
+
@last_screen_col = new_col
|
60
|
+
|
61
|
+
record_mark_start_and_end
|
62
|
+
|
63
|
+
selection_removed = false
|
64
|
+
if ! @auto_anchored && ! @changing_selection && selecting?
|
65
|
+
remove_selection( DONT_DISPLAY )
|
66
|
+
selection_removed = true
|
67
|
+
end
|
68
|
+
@auto_anchored = false
|
69
|
+
|
70
|
+
old_pair = @text_marks[ :pair ]
|
71
|
+
if @settings[ 'view.pairs.highlight' ]
|
72
|
+
highlight_pair
|
73
|
+
elsif old_pair
|
74
|
+
clear_pair_highlight
|
75
|
+
end
|
76
|
+
highlight_changed = old_pair != @text_marks[ :pair ]
|
77
|
+
|
78
|
+
if selection_removed || ( do_display && ( selecting? || view_changed || highlight_changed ) )
|
79
|
+
display
|
80
|
+
else
|
81
|
+
$diakonos.display_mutex.synchronize do
|
82
|
+
@win_main.setpos( @last_screen_y, @last_screen_x )
|
83
|
+
end
|
84
|
+
end
|
85
|
+
$diakonos.update_status_line
|
86
|
+
$diakonos.update_context_line
|
87
|
+
|
88
|
+
( @last_row != old_last_row || @last_col != old_last_col )
|
89
|
+
end
|
90
|
+
|
91
|
+
def cursor_to_eof
|
92
|
+
cursor_to( @lines.length - 1, @lines[ -1 ].length, DO_DISPLAY )
|
93
|
+
end
|
94
|
+
|
95
|
+
def cursor_to_bol
|
96
|
+
row = @last_row
|
97
|
+
case @settings[ "bol_behaviour" ]
|
98
|
+
when BOL_ZERO
|
99
|
+
col = 0
|
100
|
+
when BOL_FIRST_CHAR
|
101
|
+
col = ( ( @lines[ row ] =~ /\S/ ) || 0 )
|
102
|
+
when BOL_ALT_ZERO
|
103
|
+
if @last_col == 0
|
104
|
+
col = ( @lines[ row ] =~ /\S/ )
|
105
|
+
else
|
106
|
+
col = 0
|
107
|
+
end
|
108
|
+
#when BOL_ALT_FIRST_CHAR
|
109
|
+
else
|
110
|
+
first_char_col = ( ( @lines[ row ] =~ /\S/ ) || 0 )
|
111
|
+
if @last_col == first_char_col
|
112
|
+
col = 0
|
113
|
+
else
|
114
|
+
col = first_char_col
|
115
|
+
end
|
116
|
+
end
|
117
|
+
cursor_to( row, col, DO_DISPLAY )
|
118
|
+
end
|
119
|
+
|
120
|
+
def cursor_to_eol
|
121
|
+
y = @win_main.cury
|
122
|
+
end_col = line_at( y ).length
|
123
|
+
last_char_col = line_at( y ).rstrip.length
|
124
|
+
case @settings[ 'eol_behaviour' ]
|
125
|
+
when EOL_END
|
126
|
+
col = end_col
|
127
|
+
when EOL_LAST_CHAR
|
128
|
+
col = last_char_col
|
129
|
+
when EOL_ALT_LAST_CHAR
|
130
|
+
if @last_col == last_char_col
|
131
|
+
col = end_col
|
132
|
+
else
|
133
|
+
col = last_char_col
|
134
|
+
end
|
135
|
+
else
|
136
|
+
if @last_col == end_col
|
137
|
+
col = last_char_col
|
138
|
+
else
|
139
|
+
col = end_col
|
140
|
+
end
|
141
|
+
end
|
142
|
+
cursor_to( @last_row, col, DO_DISPLAY )
|
143
|
+
end
|
144
|
+
|
145
|
+
# Top of view
|
146
|
+
def cursor_to_tov
|
147
|
+
cursor_to( row_of( 0 ), @last_col, DO_DISPLAY )
|
148
|
+
end
|
149
|
+
# Bottom of view
|
150
|
+
def cursor_to_bov
|
151
|
+
cursor_to( row_of( 0 + $diakonos.main_window_height - 1 ), @last_col, DO_DISPLAY )
|
152
|
+
end
|
153
|
+
|
154
|
+
# col and row are given relative to the buffer, not any window or screen.
|
155
|
+
# Returns true if the view changed positions.
|
156
|
+
def show_character( row, col )
|
157
|
+
old_top_line = @top_line
|
158
|
+
old_left_column = @left_column
|
159
|
+
|
160
|
+
while row < @top_line + @settings[ "view.margin.y" ]
|
161
|
+
amount = (-1) * @settings[ "view.jump.y" ]
|
162
|
+
break if( pitch_view( amount, DONT_PITCH_CURSOR, DONT_DISPLAY ) != amount )
|
163
|
+
end
|
164
|
+
while row > @top_line + $diakonos.main_window_height - 1 - @settings[ "view.margin.y" ]
|
165
|
+
amount = @settings[ "view.jump.y" ]
|
166
|
+
break if( pitch_view( amount, DONT_PITCH_CURSOR, DONT_DISPLAY ) != amount )
|
167
|
+
end
|
168
|
+
|
169
|
+
while col < @left_column + @settings[ "view.margin.x" ]
|
170
|
+
amount = (-1) * @settings[ "view.jump.x" ]
|
171
|
+
break if( pan_view( amount, DONT_DISPLAY ) != amount )
|
172
|
+
end
|
173
|
+
while col > @left_column + $diakonos.main_window_width - @settings[ "view.margin.x" ] - 2
|
174
|
+
amount = @settings[ "view.jump.x" ]
|
175
|
+
break if( pan_view( amount, DONT_DISPLAY ) != amount )
|
176
|
+
end
|
177
|
+
|
178
|
+
@top_line != old_top_line || @left_column != old_left_column
|
179
|
+
end
|
180
|
+
|
181
|
+
def go_to_line( line = nil, column = nil, do_display = DO_DISPLAY )
|
182
|
+
cursor_to( line || @last_row, column || 0, do_display )
|
183
|
+
end
|
184
|
+
|
185
|
+
def go_block_outer
|
186
|
+
initial_level = indentation_level( @last_row )
|
187
|
+
new_row = @last_row
|
188
|
+
passed = false
|
189
|
+
new_level = initial_level
|
190
|
+
( 0...@last_row ).reverse_each do |row|
|
191
|
+
next if @lines[ row ].strip.empty?
|
192
|
+
level = indentation_level( row )
|
193
|
+
if ! passed
|
194
|
+
passed = ( level < initial_level )
|
195
|
+
new_level = level
|
196
|
+
else
|
197
|
+
if level < new_level
|
198
|
+
new_row = ( row+1..@last_row ).find { |r|
|
199
|
+
! @lines[ r ].strip.empty?
|
200
|
+
}
|
201
|
+
break
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
go_to_line( new_row, @lines[ new_row ].index( /\S/ ) )
|
206
|
+
end
|
207
|
+
|
208
|
+
def go_block_inner
|
209
|
+
initial_level = indentation_level( @last_row )
|
210
|
+
new_row = @lines.length
|
211
|
+
( @last_row...@lines.length ).each do |row|
|
212
|
+
next if @lines[ row ].strip.empty?
|
213
|
+
level = indentation_level( row )
|
214
|
+
if level > initial_level
|
215
|
+
new_row = row
|
216
|
+
break
|
217
|
+
elsif level < initial_level
|
218
|
+
new_row = @last_row
|
219
|
+
break
|
220
|
+
end
|
221
|
+
end
|
222
|
+
go_to_line( new_row, @lines[ new_row ].index( /\S/ ) )
|
223
|
+
end
|
224
|
+
|
225
|
+
def go_block_next
|
226
|
+
initial_level = indentation_level( @last_row )
|
227
|
+
new_row = @last_row
|
228
|
+
passed = false
|
229
|
+
( @last_row+1...@lines.length ).each do |row|
|
230
|
+
next if @lines[ row ].strip.empty?
|
231
|
+
level = indentation_level( row )
|
232
|
+
if ! passed
|
233
|
+
if level < initial_level
|
234
|
+
passed = true
|
235
|
+
end
|
236
|
+
else
|
237
|
+
if level == initial_level
|
238
|
+
new_row = row
|
239
|
+
break
|
240
|
+
elsif level < initial_level - 1
|
241
|
+
break
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
go_to_line( new_row, @lines[ new_row ].index( /\S/ ) )
|
246
|
+
end
|
247
|
+
|
248
|
+
def go_block_previous
|
249
|
+
initial_level = indentation_level( @last_row )
|
250
|
+
new_row = @last_row
|
251
|
+
passed = false # search for unindent
|
252
|
+
passed2 = false # search for reindent
|
253
|
+
( 0...@last_row ).reverse_each do |row|
|
254
|
+
next if @lines[ row ].strip.empty?
|
255
|
+
level = indentation_level( row )
|
256
|
+
if ! passed
|
257
|
+
if level < initial_level
|
258
|
+
passed = true
|
259
|
+
end
|
260
|
+
else
|
261
|
+
if ! passed2
|
262
|
+
if level >= initial_level
|
263
|
+
new_row = row
|
264
|
+
passed2 = true
|
265
|
+
elsif level <= initial_level - 2
|
266
|
+
# No previous block
|
267
|
+
break
|
268
|
+
end
|
269
|
+
else
|
270
|
+
if level < initial_level
|
271
|
+
new_row = ( row+1..@last_row ).find { |r|
|
272
|
+
! @lines[ r ].strip.empty?
|
273
|
+
}
|
274
|
+
break
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
go_to_line( new_row, @lines[ new_row ].index( /\S/ ) )
|
280
|
+
end
|
281
|
+
|
282
|
+
def go_to_char( char, after = ON_CHAR )
|
283
|
+
r = @last_row
|
284
|
+
i = @lines[ r ].index( char, @last_col + 1 )
|
285
|
+
if i
|
286
|
+
if after
|
287
|
+
i += 1
|
288
|
+
end
|
289
|
+
return cursor_to r, i, DO_DISPLAY
|
290
|
+
end
|
291
|
+
|
292
|
+
loop do
|
293
|
+
r += 1
|
294
|
+
break if r >= @lines.size
|
295
|
+
|
296
|
+
i = @lines[ r ].index( char )
|
297
|
+
if i
|
298
|
+
if after
|
299
|
+
i += 1
|
300
|
+
end
|
301
|
+
return cursor_to r, i, DO_DISPLAY
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
def go_to_char_previous( char, after = ON_CHAR )
|
307
|
+
r = @last_row
|
308
|
+
search_from = @last_col - 1
|
309
|
+
if search_from >= 0
|
310
|
+
i = @lines[ r ].rindex( char, search_from )
|
311
|
+
if i
|
312
|
+
if after
|
313
|
+
i += 1
|
314
|
+
end
|
315
|
+
return cursor_to r, i, DO_DISPLAY
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
loop do
|
320
|
+
r -= 1
|
321
|
+
break if r < 0
|
322
|
+
|
323
|
+
i = @lines[ r ].rindex( char )
|
324
|
+
if i
|
325
|
+
if after
|
326
|
+
i += 1
|
327
|
+
end
|
328
|
+
return cursor_to r, i, DO_DISPLAY
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
334
|
+
|
335
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
module Diakonos
|
2
|
+
|
3
|
+
class Buffer
|
4
|
+
|
5
|
+
# x and y are given window-relative, not buffer-relative.
|
6
|
+
def delete
|
7
|
+
if selection_mark
|
8
|
+
delete_selection
|
9
|
+
else
|
10
|
+
row = @last_row
|
11
|
+
col = @last_col
|
12
|
+
if ( row >= 0 ) && ( col >= 0 )
|
13
|
+
line = @lines[ row ]
|
14
|
+
if col == line.length
|
15
|
+
if row < @lines.length - 1
|
16
|
+
# Delete newline, and concat next line
|
17
|
+
join_lines( row )
|
18
|
+
cursor_to( @last_row, @last_col )
|
19
|
+
end
|
20
|
+
else
|
21
|
+
take_snapshot( TYPING )
|
22
|
+
@lines[ row ] = line[ 0...col ] + line[ (col + 1)..-1 ]
|
23
|
+
set_modified
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def delete_line
|
30
|
+
remove_selection( DONT_DISPLAY ) if selection_mark
|
31
|
+
|
32
|
+
row = @last_row
|
33
|
+
take_snapshot
|
34
|
+
retval = nil
|
35
|
+
if @lines.length == 1
|
36
|
+
retval = @lines[ 0 ]
|
37
|
+
@lines[ 0 ] = ""
|
38
|
+
else
|
39
|
+
retval = @lines[ row ]
|
40
|
+
@lines.delete_at row
|
41
|
+
end
|
42
|
+
cursor_to( row, 0 )
|
43
|
+
set_modified
|
44
|
+
|
45
|
+
retval
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete_to_eol
|
49
|
+
remove_selection( DONT_DISPLAY ) if selection_mark
|
50
|
+
|
51
|
+
row = @last_row
|
52
|
+
col = @last_col
|
53
|
+
|
54
|
+
take_snapshot
|
55
|
+
if @settings[ 'delete_newline_on_delete_to_eol' ] && col == @lines[ row ].size
|
56
|
+
next_line = @lines.delete_at( row + 1 )
|
57
|
+
@lines[ row ] << next_line
|
58
|
+
retval = [ "\n" ]
|
59
|
+
else
|
60
|
+
retval = [ @lines[ row ][ col..-1 ] ]
|
61
|
+
@lines[ row ] = @lines[ row ][ 0...col ]
|
62
|
+
end
|
63
|
+
set_modified
|
64
|
+
|
65
|
+
retval
|
66
|
+
end
|
67
|
+
|
68
|
+
def delete_from_to( row_from, col_from, row_to, col_to )
|
69
|
+
take_snapshot
|
70
|
+
if row_to == row_from
|
71
|
+
retval = [ @lines[ row_to ].slice!( col_from, col_to - col_from ) ]
|
72
|
+
else
|
73
|
+
pre_head = @lines[ row_from ][ 0...col_from ]
|
74
|
+
post_tail = @lines[ row_to ][ col_to..-1 ]
|
75
|
+
head = @lines[ row_from ].slice!( col_from..-1 )
|
76
|
+
tail = @lines[ row_to ].slice!( 0...col_to )
|
77
|
+
retval = [ head ] + @lines.slice!( row_from + 1, row_to - row_from ) + [ tail ]
|
78
|
+
@lines[ row_from ] = pre_head + post_tail
|
79
|
+
end
|
80
|
+
set_modified
|
81
|
+
retval
|
82
|
+
end
|
83
|
+
|
84
|
+
def delete_to( char )
|
85
|
+
remove_selection( DONT_DISPLAY ) if selection_mark
|
86
|
+
|
87
|
+
first_row = row = @last_row
|
88
|
+
index = @lines[ @last_row ].index( char, @last_col+1 )
|
89
|
+
|
90
|
+
while row < @lines.length - 1 && index.nil?
|
91
|
+
row += 1
|
92
|
+
index = @lines[ row ].index( char )
|
93
|
+
end
|
94
|
+
|
95
|
+
if index
|
96
|
+
delete_from_to( first_row, @last_col, row, index )
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def delete_from( char )
|
101
|
+
remove_selection( DONT_DISPLAY ) if selection_mark
|
102
|
+
|
103
|
+
first_row = row = @last_row
|
104
|
+
index = @lines[ @last_row ].rindex( char, @last_col-1 )
|
105
|
+
|
106
|
+
while row > 0 && index.nil?
|
107
|
+
row -= 1
|
108
|
+
index = @lines[ row ].rindex( char )
|
109
|
+
end
|
110
|
+
|
111
|
+
if index
|
112
|
+
deleted_text = delete_from_to( row, index+1, first_row, @last_col )
|
113
|
+
cursor_to( row, index+1 )
|
114
|
+
deleted_text
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def delete_to_and_from( char, inclusive = NOT_INCLUSIVE )
|
119
|
+
remove_selection( DONT_DISPLAY ) if selection_mark
|
120
|
+
|
121
|
+
start_char = end_char = char
|
122
|
+
case char
|
123
|
+
when '('
|
124
|
+
end_char = ')'
|
125
|
+
when '{'
|
126
|
+
end_char = '}'
|
127
|
+
when '['
|
128
|
+
end_char = ']'
|
129
|
+
when '<'
|
130
|
+
end_char = '>'
|
131
|
+
when ')'
|
132
|
+
end_char = '('
|
133
|
+
when '}'
|
134
|
+
end_char = '{'
|
135
|
+
when ']'
|
136
|
+
end_char = '['
|
137
|
+
when '>'
|
138
|
+
end_char = '<'
|
139
|
+
end
|
140
|
+
|
141
|
+
row = @last_row
|
142
|
+
start_index = @lines[ @last_row ].rindex( start_char, @last_col )
|
143
|
+
while row > 0 && start_index.nil?
|
144
|
+
row -= 1
|
145
|
+
start_index = @lines[ row ].rindex( start_char )
|
146
|
+
end
|
147
|
+
start_row = row
|
148
|
+
|
149
|
+
row = @last_row
|
150
|
+
end_index = @lines[ row ].index( end_char, @last_col+1 )
|
151
|
+
while row < @lines.length - 1 && end_index.nil?
|
152
|
+
row += 1
|
153
|
+
end_index = @lines[ row ].index( end_char )
|
154
|
+
end
|
155
|
+
end_row = row
|
156
|
+
|
157
|
+
if start_index && end_index
|
158
|
+
if inclusive
|
159
|
+
end_index += 1
|
160
|
+
else
|
161
|
+
start_index += 1
|
162
|
+
end
|
163
|
+
cursor_to( start_row, start_index )
|
164
|
+
delete_from_to( start_row, start_index, end_row, end_index )
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|