vimamsa 0.1.6 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/custom_example.rb +47 -0
- data/demo.txt +25 -0
- data/lang/hyperplaintext.lang +9 -25
- data/lib/vimamsa/ack.rb +90 -7
- data/lib/vimamsa/actions.rb +27 -8
- data/lib/vimamsa/buffer.rb +130 -76
- data/lib/vimamsa/buffer_list.rb +24 -0
- data/lib/vimamsa/buffer_manager.rb +83 -0
- data/lib/vimamsa/conf.rb +21 -0
- data/lib/vimamsa/debug.rb +3 -2
- data/lib/vimamsa/easy_jump.rb +15 -20
- data/lib/vimamsa/editor.rb +93 -73
- data/lib/vimamsa/encrypt.rb +1 -1
- data/lib/vimamsa/file_finder.rb +6 -9
- data/lib/vimamsa/file_history.rb +3 -3
- data/lib/vimamsa/file_manager.rb +9 -8
- data/lib/vimamsa/gui.rb +89 -87
- data/lib/vimamsa/gui_image.rb +43 -0
- data/lib/vimamsa/gui_menu.rb +11 -2
- data/lib/vimamsa/gui_select_window.rb +16 -13
- data/lib/vimamsa/gui_sourceview.rb +64 -37
- data/lib/vimamsa/hyper_plain_text.rb +38 -19
- data/lib/vimamsa/key_actions.rb +40 -13
- data/lib/vimamsa/key_binding_tree.rb +52 -128
- data/lib/vimamsa/key_bindings_vimlike.rb +28 -25
- data/lib/vimamsa/macro.rb +5 -5
- data/lib/vimamsa/rbvma.rb +22 -18
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +11 -8
- data/lib/vimamsa/text_transforms.rb +2 -0
- data/lib/vimamsa/util.rb +34 -0
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +5 -0
- data/sheep.jpg +0 -0
- data/styles/dark.xml +1 -0
- data/styles/molokai_edit.xml +1 -1
- data/vimamsa.gemspec +1 -1
- metadata +13 -8
- data/lib/vimamsa/gui_gtk_sourceview.rb +0 -294
@@ -36,7 +36,7 @@ setcnf :indent_based_on_last_line, true
|
|
36
36
|
setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js"]
|
37
37
|
|
38
38
|
class State
|
39
|
-
attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes
|
39
|
+
attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes, :level
|
40
40
|
|
41
41
|
def initialize(key_name, eval_rule = "")
|
42
42
|
@key_name = key_name
|
@@ -44,6 +44,7 @@ class State
|
|
44
44
|
@children = []
|
45
45
|
@major_modes = []
|
46
46
|
@action = nil
|
47
|
+
@level = 0
|
47
48
|
end
|
48
49
|
|
49
50
|
def to_s()
|
@@ -86,6 +87,7 @@ class KeyBindingTree
|
|
86
87
|
# $kbd.add_mode("I", :insert)
|
87
88
|
def add_mode(id, label)
|
88
89
|
mode = State.new(id)
|
90
|
+
mode.level = 1
|
89
91
|
@modes[label] = mode
|
90
92
|
@root.children << mode
|
91
93
|
if @default_mode == nil
|
@@ -127,22 +129,21 @@ class KeyBindingTree
|
|
127
129
|
@match_state.each { |parent|
|
128
130
|
parent.children.each { |c|
|
129
131
|
# printf(" KEY MATCH: ")
|
130
|
-
#
|
132
|
+
# debug [c.key_name, key_name].inspect
|
131
133
|
if c.key_name == key_name and c.eval_rule == ""
|
132
134
|
new_state << c
|
133
135
|
elsif c.key_name == key_name and c.eval_rule != ""
|
134
|
-
|
136
|
+
debug "CHECK EVAL: #{c.eval_rule}"
|
135
137
|
if eval(c.eval_rule)
|
136
138
|
new_state << c
|
137
|
-
|
139
|
+
debug "EVAL TRUE"
|
138
140
|
else
|
139
|
-
|
141
|
+
debug "EVAL FALSE"
|
140
142
|
end
|
141
143
|
end
|
142
144
|
}
|
143
145
|
}
|
144
146
|
|
145
|
-
|
146
147
|
if new_state.any? # Match found
|
147
148
|
@match_state = new_state
|
148
149
|
return new_state
|
@@ -153,6 +154,11 @@ class KeyBindingTree
|
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
157
|
+
def show_state_trail
|
158
|
+
(st, children) = get_state_trail_str()
|
159
|
+
vma.gui.statnfo.markup = "<span weight='ultrabold'>#{st}</span>"
|
160
|
+
end
|
161
|
+
|
156
162
|
def set_mode(label)
|
157
163
|
@mode_history << @mode_root_state
|
158
164
|
|
@@ -195,7 +201,7 @@ class KeyBindingTree
|
|
195
201
|
end
|
196
202
|
|
197
203
|
@state_trail = [@mode_root_state]
|
198
|
-
#
|
204
|
+
# debug get_state_trail_str()
|
199
205
|
# $next_command_count = nil # TODO: set somewhere else?
|
200
206
|
end
|
201
207
|
|
@@ -205,6 +211,7 @@ class KeyBindingTree
|
|
205
211
|
# @cur_state = @root
|
206
212
|
stack = [[@root, ""]]
|
207
213
|
lines = []
|
214
|
+
|
208
215
|
while stack.any?
|
209
216
|
t, p = *stack.pop # t = current state, p = current path
|
210
217
|
if t.children.any?
|
@@ -212,14 +219,27 @@ class KeyBindingTree
|
|
212
219
|
if c.eval_rule.size > 0
|
213
220
|
new_p = "#{p} #{c.key_name}(#{c.eval_rule})"
|
214
221
|
else
|
215
|
-
|
222
|
+
if c.level == 1
|
223
|
+
new_p = "#{p} [#{c.key_name}]"
|
224
|
+
else
|
225
|
+
new_p = "#{p} #{c.key_name}"
|
226
|
+
end
|
216
227
|
end
|
217
228
|
stack << [c, new_p]
|
218
229
|
}
|
219
230
|
# stack.concat[t.children]
|
220
231
|
else
|
221
|
-
|
222
|
-
|
232
|
+
method_desc = t.action
|
233
|
+
if t.action.class == Symbol
|
234
|
+
if !$actions[t.action].nil?
|
235
|
+
a = $actions[t.action].method_name
|
236
|
+
if !a.nil? and !a.empty?
|
237
|
+
method_desc = a
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
lines << p + " : #{method_desc}"
|
223
243
|
end
|
224
244
|
end
|
225
245
|
s = lines.sort.join("\n")
|
@@ -227,21 +247,26 @@ class KeyBindingTree
|
|
227
247
|
end
|
228
248
|
|
229
249
|
def get_state_trail_str
|
230
|
-
s = ""
|
231
250
|
s_trail = ""
|
232
251
|
last_state = @state_trail.last
|
233
252
|
last_state = last_state[0] if last_state.class == Array
|
253
|
+
first = true
|
234
254
|
for st in @state_trail
|
235
255
|
st = st[0] if st.class == Array
|
236
|
-
|
256
|
+
if first
|
257
|
+
s_trail << "[#{st.to_s}]"
|
258
|
+
else
|
259
|
+
s_trail << " #{st.to_s}"
|
260
|
+
end
|
261
|
+
first = false
|
237
262
|
end
|
238
|
-
|
263
|
+
children = ""
|
239
264
|
for cstate in last_state.children
|
240
265
|
act_s = "..."
|
241
266
|
act_s = cstate.action.to_s if cstate.action != nil
|
242
|
-
|
267
|
+
children << " #{cstate.to_s} #{act_s}\n"
|
243
268
|
end
|
244
|
-
return
|
269
|
+
return [s_trail, children]
|
245
270
|
end
|
246
271
|
|
247
272
|
# Modifies state of key binding tree (move to new state) based on received event
|
@@ -305,20 +330,6 @@ class KeyBindingTree
|
|
305
330
|
|
306
331
|
if new_state != nil
|
307
332
|
@state_trail << new_state
|
308
|
-
puts get_state_trail_str()
|
309
|
-
# # puts "CUR STATE: #{@state_trail.collect{|x| x.to_s}.join}"
|
310
|
-
# s_trail = ""
|
311
|
-
# for st in @state_trail
|
312
|
-
# st = st[0] if st.class == Array
|
313
|
-
# s_trail << " #{st.to_s}"
|
314
|
-
# end
|
315
|
-
# puts "CUR STATE: #{s_trail}"
|
316
|
-
# for cstate in new_state[0].children
|
317
|
-
# act_s = "..."
|
318
|
-
# act_s = cstate.action.to_s if cstate.action != nil
|
319
|
-
# puts " #{cstate.to_s} #{act_s}"
|
320
|
-
# end
|
321
|
-
# new_state[0].children.collect{|x|x.to_s}
|
322
333
|
end
|
323
334
|
|
324
335
|
if new_state == nil
|
@@ -330,7 +341,7 @@ class KeyBindingTree
|
|
330
341
|
end
|
331
342
|
|
332
343
|
if event_type == :key_release and c == "shift!"
|
333
|
-
# Pressing a modifier key (shift)
|
344
|
+
# Pressing a modifier key (shift) sets state back to root
|
334
345
|
# only on key release when no other key has been pressed
|
335
346
|
# after said modifier key (shift).
|
336
347
|
set_state_to_root
|
@@ -346,109 +357,22 @@ class KeyBindingTree
|
|
346
357
|
|
347
358
|
if s_act.any? and !state_with_children.any?
|
348
359
|
eval_s = s_act.first.action if eval_s == nil
|
349
|
-
|
350
|
-
|
360
|
+
debug "FOUND MATCH:#{eval_s}"
|
361
|
+
debug "CHAR: #{c}"
|
351
362
|
c.gsub!("\\", %q{\\\\} * 4) # Escape \ -chars
|
352
363
|
c.gsub!("'", "#{'\\' * 4}'") # Escape ' -chars
|
353
364
|
|
354
365
|
eval_s.gsub!("<char>", "'#{c}'") if eval_s.class == String
|
355
|
-
|
356
|
-
|
366
|
+
debug eval_s
|
367
|
+
debug c
|
357
368
|
handle_key_bindigs_action(eval_s, c)
|
358
369
|
set_state_to_root
|
359
370
|
end
|
360
371
|
end
|
361
372
|
|
362
|
-
|
363
|
-
end
|
364
|
-
|
365
|
-
# Receive keyboard event from Qt
|
366
|
-
def handle_key_event(event)
|
367
|
-
start_profiler
|
368
|
-
# puts "GOT KEY EVENT: #{key.inspect}"
|
369
|
-
debug "GOT KEY EVENT:: #{event} #{event[2]}"
|
370
|
-
debug "|#{event.inspect}|"
|
371
|
-
$debuginfo["cur_event"] = event
|
372
|
-
|
373
|
-
t1 = Time.now
|
374
|
-
|
375
|
-
keycode = event[0]
|
376
|
-
event_type = event[1]
|
377
|
-
modifierinfo = event[4]
|
378
|
-
|
379
|
-
event[3] = event[2]
|
380
|
-
# String representation of received key
|
381
|
-
key_str = event[2]
|
382
|
-
|
383
|
-
@modifiers.delete(Qt::Key_Alt) if event[4] & ALTMODIFIER == 0
|
384
|
-
@modifiers.delete(Qt::Key_Control) if event[4] & CONTROLMODIFIER == 0
|
385
|
-
@modifiers.delete(Qt::Key_Shift) if event[4] & SHIFTMODIFIER == 0
|
386
|
-
|
387
|
-
# Add as modifier if ctrl, alt or shift
|
388
|
-
if modifierinfo & ALTMODIFIER != 0 or modifierinfo & CONTROLMODIFIER != 0 or modifierinfo & SHIFTMODIFIER != 0
|
389
|
-
# And keypress and not already a modifier
|
390
|
-
if event_type == KEY_PRESS and !@modifiers.include?(keycode)
|
391
|
-
@modifiers << keycode
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
# puts "----D------------"
|
396
|
-
# puts @modifiers.inspect
|
397
|
-
# puts event.inspect
|
398
|
-
# puts event[4] & ALTMODIFIER
|
399
|
-
# puts "-----------------"
|
400
|
-
|
401
|
-
@modifiers.delete(keycode) if event_type == KEY_RELEASE
|
402
|
-
|
403
|
-
# uval = keyval_to_unicode(event[0])
|
404
|
-
# event[3] = [uval].pack('c*').force_encoding('UTF-8') #TODO: 32bit?
|
405
|
-
# debug("key_code_to_uval: uval: #{uval} uchar:#{event[3]}")
|
406
|
-
|
407
|
-
if $event_keysym_translate_table.include?(keycode)
|
408
|
-
key_str = $event_keysym_translate_table[keycode]
|
409
|
-
end
|
410
|
-
|
411
|
-
# Prefix string representation with modifiers, e.g. ctrl-shift-a
|
412
|
-
key_prefix = ""
|
413
|
-
@modifiers.each { |pressed_key|
|
414
|
-
if $event_keysym_translate_table[pressed_key]
|
415
|
-
key_prefix += $event_keysym_translate_table[pressed_key] + "-"
|
416
|
-
end
|
417
|
-
}
|
418
|
-
|
419
|
-
# Get char based on keycode
|
420
|
-
# to produce prefixed_key_str "shift-ctrl-a" instead of "shift-ctrl-\x01"
|
421
|
-
key_str2 = key_str
|
422
|
-
if $translate_table.include?(keycode)
|
423
|
-
key_str2 = $translate_table[keycode].downcase
|
424
|
-
end
|
425
|
-
# puts "key_str=|#{key_str}| key_str=|#{key_str.inspect}| key_str2=|#{key_str2}|"
|
426
|
-
prefixed_key_str = key_prefix + key_str2
|
427
|
-
|
428
|
-
# Space is only key in $event_keysym_translate_table
|
429
|
-
# which is representable by single char
|
430
|
-
key_str = " " if key_str == "space" # HACK
|
373
|
+
show_state_trail #TODO: check if changed
|
431
374
|
|
432
|
-
|
433
|
-
# puts "KEY! key_str=|#{key_str}| prefixed_key_str=|#{prefixed_key_str}|"
|
434
|
-
# end
|
435
|
-
|
436
|
-
if key_str != "" or prefixed_key_str != ""
|
437
|
-
if keycode == @last_event[0] and event_type == KEY_RELEASE
|
438
|
-
# If key is released immediately after pressed with no other events between
|
439
|
-
match_key_conf(key_str + "!", prefixed_key_str + "!", event_type)
|
440
|
-
elsif event_type == KEY_PRESS
|
441
|
-
match_key_conf(key_str, prefixed_key_str, event_type)
|
442
|
-
end
|
443
|
-
@last_event = event #TODO: outside if?
|
444
|
-
end
|
445
|
-
|
446
|
-
# gui_refresh_cursor
|
447
|
-
|
448
|
-
event_handle_time = Time.now - t1
|
449
|
-
debug "RB key event handle time: #{event_handle_time}" if event_handle_time > 1 / 40.0
|
450
|
-
render_buffer($buffer)
|
451
|
-
end_profiler
|
375
|
+
return true
|
452
376
|
end
|
453
377
|
|
454
378
|
def bindkey(key, action)
|
@@ -485,7 +409,7 @@ class KeyBindingTree
|
|
485
409
|
m = key.match(/^(\S+)\s(\S.*)$/)
|
486
410
|
if m
|
487
411
|
modetmp = m[1]
|
488
|
-
|
412
|
+
debug [key, modetmp, m].inspect
|
489
413
|
modes = modetmp.split("") if modetmp.match(/^\p{Lu}+$/) # Uppercase
|
490
414
|
modes = [modetmp] if modetmp.match(/^\p{Ll}+$/) # Lowercase
|
491
415
|
keydef = m[2]
|
@@ -568,10 +492,10 @@ class KeyBindingTree
|
|
568
492
|
# debug("NameError with eval cmd #{action}: " + $!.to_s)
|
569
493
|
# raise
|
570
494
|
rescue Exception => e
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
495
|
+
debug "BACKTRACE"
|
496
|
+
debug e.backtrace
|
497
|
+
debug e.inspect
|
498
|
+
debug "BACKTRACE END"
|
575
499
|
if $!.class == SystemExit
|
576
500
|
exit
|
577
501
|
else
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
bindkey ["VCB M","B m"], :run_last_macro
|
1
|
+
bindkey ["VCB M", "B m"], :run_last_macro
|
3
2
|
|
4
3
|
bindkey "VC s", :easy_jump
|
5
|
-
bindkey "VC , m f", [:find_macro_gui, proc{$macro.find_macro_gui}, "Find named macro"]
|
6
|
-
bindkey "C , m n", [:gui_name_macro, proc{$macro.gui_name_macro}, "Name last macro"]
|
4
|
+
bindkey "VC , m f", [:find_macro_gui, proc { $macro.find_macro_gui }, "Find named macro"]
|
5
|
+
bindkey "C , m n", [:gui_name_macro, proc { $macro.gui_name_macro }, "Name last macro"]
|
7
6
|
bindkey "C , j r", :jump_to_random
|
8
7
|
bindkey "I enter", :insert_new_line
|
9
8
|
bindkey "C , ; s k", :show_key_bindings #TODO: better binding
|
@@ -30,13 +29,13 @@ bindkey "C , t 4", :set_line_style_h4
|
|
30
29
|
bindkey "C , t b", :set_line_style_bold
|
31
30
|
bindkey "C , t t", :set_line_style_title
|
32
31
|
bindkey "C , t c", :clear_line_styles
|
33
|
-
bindkey "C , b", :
|
32
|
+
bindkey "C , b", :start_buf_manager
|
34
33
|
# bindkey "C , f o", :open_file_dialog
|
35
34
|
bindkey "CI ctrl-o", :open_file_dialog
|
36
35
|
# bindkey "M enter", :minibuffer_end
|
37
36
|
bindkey "C , a", :ack_search
|
38
|
-
bindkey
|
39
|
-
bindkey
|
37
|
+
bindkey "C d w", :delete_to_word_end
|
38
|
+
bindkey "C d 0", :delete_to_line_start
|
40
39
|
bindkey "C , , f", :file_finder
|
41
40
|
bindkey "VC h", :e_move_backward_char
|
42
41
|
bindkey "C , , .", :backup_all_buffers
|
@@ -62,11 +61,11 @@ bindkey "C , g", :invoke_grep_search
|
|
62
61
|
bindkey "C , v", :auto_indent_buffer
|
63
62
|
bindkey "C , , d", :savedebug
|
64
63
|
bindkey "C , , u", :update_file_index
|
65
|
-
bindkey "C , s a", :buf_save_as
|
66
|
-
bindkey "C d d", [:delete_line, proc{buf.delete_line}, "Delete current line"]
|
67
|
-
bindkey "C enter || C return",
|
68
|
-
bindkey
|
69
|
-
bindkey
|
64
|
+
bindkey "C , s a", :buf_save_as
|
65
|
+
bindkey "C d d", [:delete_line, proc { buf.delete_line }, "Delete current line"]
|
66
|
+
bindkey "C enter || C return", [:line_action, proc { buf.handle_line_action() }, "Line action"]
|
67
|
+
bindkey "C p", [:paste_after, proc { buf.paste(AFTER) }, ""] # TODO: implement as replace for visual mode
|
68
|
+
bindkey "V d", [:delete_selection, proc { buf.delete(SELECTION) }, ""]
|
70
69
|
|
71
70
|
default_keys = {
|
72
71
|
|
@@ -84,7 +83,6 @@ default_keys = {
|
|
84
83
|
# "C , , ." => "backup_all_buffers()",
|
85
84
|
"VC , , s" => :search_actions,
|
86
85
|
|
87
|
-
|
88
86
|
# MOVING
|
89
87
|
# 'VC h' => 'buf.move(BACKWARD_CHAR)',
|
90
88
|
"VC l" => "buf.move(FORWARD_CHAR)",
|
@@ -107,7 +105,7 @@ default_keys = {
|
|
107
105
|
"VC F <char>" => "buf.jump_to_next_instance_of_char(<char>,BACKWARD)",
|
108
106
|
"VC f space" => "buf.jump_to_next_instance_of_char(' ')",
|
109
107
|
"VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
|
110
|
-
|
108
|
+
|
111
109
|
"VC /[1-9]/" => "set_next_command_count(<char>)",
|
112
110
|
# 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
|
113
111
|
# 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
|
@@ -133,6 +131,9 @@ default_keys = {
|
|
133
131
|
"C n" => "$search.jump_to_next()",
|
134
132
|
"C N" => "$search.jump_to_previous()",
|
135
133
|
|
134
|
+
|
135
|
+
"C C" => :content_search,
|
136
|
+
|
136
137
|
# Debug
|
137
138
|
"C , d r p" => "start_ripl",
|
138
139
|
"C , D" => "debug_print_buffer",
|
@@ -189,12 +190,16 @@ default_keys = {
|
|
189
190
|
# Visual mode only:
|
190
191
|
"V esc" => "buf.end_visual_mode",
|
191
192
|
"V ctrl!" => "buf.end_visual_mode",
|
192
|
-
"V y" => "buf.copy_active_selection",
|
193
|
-
"V
|
194
|
-
"V g
|
195
|
-
"V g
|
196
|
-
"V g
|
197
|
-
"V g
|
193
|
+
"V y" => "buf.copy_active_selection()",
|
194
|
+
"V a y" => "buf.copy_active_selection(:append)",
|
195
|
+
"V g U" => :selection_upcase,
|
196
|
+
"V g u" => :selection_downcase,
|
197
|
+
"V g c" => :selection_capitalize,
|
198
|
+
"V g s" => :selection_swapcase,
|
199
|
+
"V g r" => :selection_reverse,
|
200
|
+
|
201
|
+
"VC j" => :forward_line,
|
202
|
+
"VC k" => :backward_line,
|
198
203
|
|
199
204
|
"V x" => "buf.delete(SELECTION)",
|
200
205
|
# "V ctrl-c" => "buf.comment_selection",
|
@@ -214,15 +219,15 @@ default_keys = {
|
|
214
219
|
# Macros
|
215
220
|
# (experimental, may not work correctly)
|
216
221
|
# "C q a" => '$macro.start_recording("a")',
|
217
|
-
"VC q <char>" =>
|
222
|
+
"VC q <char>" => "$macro.start_recording(<char>)",
|
218
223
|
"VC q($macro.is_recording==true) " => "$macro.end_recording", # TODO
|
219
224
|
# 'C q'=> '$macro.end_recording', #TODO
|
220
225
|
"C q v" => "$macro.end_recording",
|
221
226
|
# 'C v'=> '$macro.end_recording',
|
222
227
|
# "C M" => '$macro.run_last_macro',
|
223
|
-
"C @ <char>" =>
|
228
|
+
"C @ <char>" => "$macro.run_macro(<char>)",
|
224
229
|
"C , m S" => '$macro.save_macro("a")',
|
225
|
-
"C , m s" =>
|
230
|
+
"C , m s" => "$macro.save",
|
226
231
|
"C , t r" => "run_tests()",
|
227
232
|
|
228
233
|
# "C ." => "repeat_last_action", # TODO
|
@@ -255,5 +260,3 @@ default_keys = {
|
|
255
260
|
default_keys.each { |key, value|
|
256
261
|
bindkey(key, value)
|
257
262
|
}
|
258
|
-
|
259
|
-
|
data/lib/vimamsa/macro.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
def gui_find_macro_update_callback(search_str = "")
|
3
|
-
|
3
|
+
debug "gui_find_macro_update_callback: #{search_str}"
|
4
4
|
heystack = $macro.named_macros
|
5
5
|
return [] if heystack.empty?
|
6
6
|
$macro_search_list = []
|
@@ -14,10 +14,10 @@ def gui_find_macro_update_callback(search_str = "")
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def gui_find_macro_select_callback(search_str, idx)
|
17
|
-
|
17
|
+
debug "gui_find_macro_select_callback"
|
18
18
|
selected = $macro_search_list[idx]
|
19
19
|
m = $macro.named_macros[selected[0]].clone
|
20
|
-
|
20
|
+
debug "SELECTED MACRO:#{selected}, #{m}"
|
21
21
|
id = $macro.last_macro
|
22
22
|
$macro.recorded_macros[id] = m
|
23
23
|
$macro.run_macro(id)
|
@@ -64,7 +64,7 @@ class Macro
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def name_macro(name, id = nil)
|
67
|
-
|
67
|
+
debug "NAME MACRO #{name}"
|
68
68
|
if id.nil?
|
69
69
|
id = @last_macro
|
70
70
|
end
|
@@ -134,7 +134,7 @@ class Macro
|
|
134
134
|
# Ripl.start :binding => binding
|
135
135
|
for a in acts
|
136
136
|
ret = exec_action(a)
|
137
|
-
|
137
|
+
debug ret
|
138
138
|
if ret == false
|
139
139
|
message("Error while running macro")
|
140
140
|
break
|
data/lib/vimamsa/rbvma.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
require "gtk3"
|
2
|
-
require "gtksourceview3"
|
3
1
|
#require "gtksourceview4"
|
4
|
-
require "ripl"
|
5
|
-
require "fileutils"
|
6
|
-
require "pathname"
|
7
2
|
require "date"
|
8
|
-
require "
|
3
|
+
require "fileutils"
|
4
|
+
require "gtk3"
|
5
|
+
require "gtksourceview4"
|
9
6
|
require "json"
|
10
7
|
require "listen"
|
8
|
+
require "pathname"
|
9
|
+
require "ripl"
|
10
|
+
require "ripl/multi_line"
|
11
|
+
require "shellwords"
|
12
|
+
require "cgi"
|
11
13
|
|
12
14
|
require "vimamsa/util"
|
13
15
|
require "vimamsa/main"
|
@@ -16,27 +18,29 @@ require "vimamsa/actions"
|
|
16
18
|
require "vimamsa/key_binding_tree"
|
17
19
|
require "vimamsa/key_actions"
|
18
20
|
|
19
|
-
|
21
|
+
# Graphical stuff:
|
20
22
|
require "vimamsa/gui"
|
21
23
|
require "vimamsa/gui_menu"
|
22
24
|
require "vimamsa/gui_select_window"
|
23
25
|
require "vimamsa/gui_sourceview"
|
26
|
+
require "vimamsa/gui_image"
|
27
|
+
require "vimamsa/hyper_plain_text"
|
24
28
|
|
25
|
-
require "vimamsa/
|
29
|
+
require "vimamsa/ack"
|
26
30
|
require "vimamsa/buffer"
|
27
|
-
require "vimamsa/
|
31
|
+
require "vimamsa/buffer_list"
|
32
|
+
require "vimamsa/buffer_manager"
|
28
33
|
require "vimamsa/constants"
|
34
|
+
require "vimamsa/debug"
|
29
35
|
require "vimamsa/easy_jump"
|
36
|
+
require "vimamsa/encrypt"
|
37
|
+
require "vimamsa/file_finder"
|
38
|
+
require "vimamsa/file_manager"
|
30
39
|
require "vimamsa/hook"
|
40
|
+
require "vimamsa/macro"
|
31
41
|
require "vimamsa/search"
|
32
42
|
require "vimamsa/search_replace"
|
33
|
-
require "vimamsa/
|
34
|
-
require "vimamsa/file_finder"
|
35
|
-
require "vimamsa/hyper_plain_text"
|
36
|
-
require "vimamsa/ack"
|
37
|
-
require "vimamsa/encrypt"
|
38
|
-
require "vimamsa/file_manager"
|
39
|
-
|
43
|
+
require "vimamsa/conf"
|
40
44
|
# load "vendor/ver/lib/ver/vendor/textpow.rb"
|
41
45
|
# load "vendor/ver/lib/ver/syntax/detector.rb"
|
42
46
|
# load "vendor/ver/config/detect.rb"
|
@@ -48,7 +52,7 @@ def vma()
|
|
48
52
|
end
|
49
53
|
|
50
54
|
def unimplemented
|
51
|
-
|
55
|
+
debug "unimplemented"
|
52
56
|
end
|
53
57
|
|
54
58
|
|
@@ -56,7 +60,7 @@ $debug = false
|
|
56
60
|
|
57
61
|
def scan_indexes(txt, regex)
|
58
62
|
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
59
|
-
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0)
|
63
|
+
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
60
64
|
return indexes
|
61
65
|
end
|
62
66
|
|
data/lib/vimamsa/search.rb
CHANGED
@@ -50,16 +50,15 @@ class FileSelector
|
|
50
50
|
# puts "def select_line"
|
51
51
|
fn = fullp(@buf.get_current_line[0..-2])
|
52
52
|
if File.directory?(fn)
|
53
|
-
|
53
|
+
debug "CHDIR: #{fn}"
|
54
54
|
dir_to_buf(fn)
|
55
|
-
|
55
|
+
# elsif vma.can_open_extension?(fn) #TODO: remove this check?
|
56
56
|
# jump_to_file(fn)
|
57
57
|
elsif file_is_text_file(fn)
|
58
58
|
jump_to_file(fn)
|
59
59
|
else
|
60
60
|
open_with_default_program(fn)
|
61
61
|
end
|
62
|
-
# puts l.inspect
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
@@ -91,7 +90,7 @@ def grep_cur_buffer(search_str, b = nil)
|
|
91
90
|
# @current_buf = buffer_i
|
92
91
|
|
93
92
|
b.line_action_handler = proc { |lineno|
|
94
|
-
|
93
|
+
debug "GREP HANDLER:#{lineno}"
|
95
94
|
jumpto = $grep_matches[lineno]
|
96
95
|
if jumpto.class == Integer
|
97
96
|
$buffers.set_current_buffer($grep_bufid, update_history = true)
|
@@ -104,8 +103,8 @@ def invoke_grep_search()
|
|
104
103
|
start_minibuffer_cmd("", "", :grep_cur_buffer)
|
105
104
|
end
|
106
105
|
|
107
|
-
def gui_one_input_action(title, field_label, button_title, callback)
|
108
|
-
a = OneInputAction.new(nil, title, field_label, button_title, callback)
|
106
|
+
def gui_one_input_action(title, field_label, button_title, callback,opt={})
|
107
|
+
a = OneInputAction.new(nil, title, field_label, button_title, callback,opt)
|
109
108
|
a.run
|
110
109
|
return
|
111
110
|
end
|
@@ -114,7 +113,7 @@ end
|
|
114
113
|
def gui_replace_callback(vals)
|
115
114
|
search_str = vals["search"]
|
116
115
|
replace_str = vals["replace"]
|
117
|
-
|
116
|
+
debug "gui_replace_callback: #{search_str} => #{replace_str}"
|
118
117
|
gui_select_window_close(0)
|
119
118
|
buf_replace(search_str, replace_str)
|
120
119
|
end
|
@@ -263,7 +262,7 @@ class PopupFormGenerator
|
|
263
262
|
end
|
264
263
|
|
265
264
|
class OneInputAction
|
266
|
-
def initialize(main_window, title, field_label, button_title, callback)
|
265
|
+
def initialize(main_window, title, field_label, button_title, callback, opt = {})
|
267
266
|
@window = Gtk::Window.new(:toplevel)
|
268
267
|
# @window.screen = main_window.screen
|
269
268
|
# @window.title = title
|
@@ -292,6 +291,10 @@ class OneInputAction
|
|
292
291
|
|
293
292
|
@entry1 = Gtk::Entry.new
|
294
293
|
|
294
|
+
if opt[:hide]
|
295
|
+
@entry1.visibility = false
|
296
|
+
end
|
297
|
+
|
295
298
|
button.signal_connect "clicked" do
|
296
299
|
callback.call(@entry1.text)
|
297
300
|
@window.destroy
|
data/lib/vimamsa/util.rb
CHANGED
@@ -3,6 +3,40 @@
|
|
3
3
|
# Cross-platform way of finding an executable in the $PATH.
|
4
4
|
#
|
5
5
|
# which('ruby') #=> /usr/bin/ruby
|
6
|
+
|
7
|
+
|
8
|
+
# Execute proc after wait_time seconds after last .run call.
|
9
|
+
# Used for image scaling after window resize
|
10
|
+
class DelayExecutioner
|
11
|
+
def initialize(wait_time, _proc)
|
12
|
+
@wait_time = wait_time
|
13
|
+
@proc = _proc
|
14
|
+
@lastt = Time.now
|
15
|
+
@thread_running = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_thread
|
19
|
+
Thread.new {
|
20
|
+
while true
|
21
|
+
sleep 0.1
|
22
|
+
if Time.now - @lastt > @wait_time
|
23
|
+
@proc.call
|
24
|
+
@thread_running = false
|
25
|
+
break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def run()
|
32
|
+
@lastt = Time.now
|
33
|
+
if @thread_running == false
|
34
|
+
@thread_running = true
|
35
|
+
start_thread
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
6
40
|
def which(cmd)
|
7
41
|
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
8
42
|
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
data/lib/vimamsa/version.rb
CHANGED