vimamsa 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/custom_example.rb +5 -0
- data/lib/vimamsa/ack.rb +3 -4
- data/lib/vimamsa/audio.rb +25 -1
- data/lib/vimamsa/buffer.rb +43 -566
- data/lib/vimamsa/buffer_changetext.rb +255 -0
- data/lib/vimamsa/buffer_cursor.rb +303 -0
- data/lib/vimamsa/buffer_list.rb +26 -9
- data/lib/vimamsa/buffer_manager.rb +4 -2
- data/lib/vimamsa/clipboard.rb +35 -0
- data/lib/vimamsa/conf.rb +130 -5
- data/lib/vimamsa/debug.rb +4 -8
- data/lib/vimamsa/editor.rb +41 -78
- data/lib/vimamsa/encrypt.rb +6 -11
- data/lib/vimamsa/file_manager.rb +138 -9
- data/lib/vimamsa/gui.rb +3 -32
- data/lib/vimamsa/gui_dialog.rb +113 -0
- data/lib/vimamsa/gui_sourceview.rb +10 -14
- data/lib/vimamsa/gui_text.rb +19 -0
- data/lib/vimamsa/hyper_plain_text.rb +8 -5
- data/lib/vimamsa/key_actions.rb +17 -197
- data/lib/vimamsa/key_binding_tree.rb +49 -31
- data/lib/vimamsa/key_bindings_vimlike.rb +30 -30
- data/lib/vimamsa/macro.rb +35 -25
- data/lib/vimamsa/main.rb +3 -10
- data/lib/vimamsa/rbvma.rb +11 -11
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +89 -151
- data/lib/vimamsa/terminal.rb +22 -0
- data/lib/vimamsa/tests.rb +122 -0
- data/lib/vimamsa/util.rb +33 -3
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +3 -1
- metadata +56 -7
- /data/lib/vimamsa/{form_generator.rb → gui_form_generator.rb} +0 -0
@@ -18,20 +18,6 @@
|
|
18
18
|
# 'I ctrl-a'=> 'vma.buf.jump(BEGINNING_OF_LINE)',
|
19
19
|
#
|
20
20
|
|
21
|
-
$cnf = {} # TODO
|
22
|
-
|
23
|
-
def conf(id)
|
24
|
-
return $cnf[id]
|
25
|
-
end
|
26
|
-
|
27
|
-
def set_conf(id, val)
|
28
|
-
$cnf[id] = val
|
29
|
-
end
|
30
|
-
|
31
|
-
def setcnf(id, val)
|
32
|
-
set_conf(id, val)
|
33
|
-
end
|
34
|
-
|
35
21
|
setcnf :indent_based_on_last_line, true
|
36
22
|
setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js"]
|
37
23
|
|
@@ -55,18 +41,21 @@ class State
|
|
55
41
|
end
|
56
42
|
|
57
43
|
class KeyBindingTree
|
58
|
-
attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action, :modifiers
|
59
|
-
attr_reader :mode_root_state, :state_trail, :act_bindings
|
44
|
+
attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action, :modifiers, :next_command_count, :method_handles_repeat
|
45
|
+
attr_reader :mode_root_state, :state_trail, :act_bindings, :default_mode_stack
|
60
46
|
|
61
47
|
def initialize()
|
48
|
+
@next_command_count = nil
|
62
49
|
@modes = {}
|
63
50
|
@root = State.new("ROOT")
|
64
51
|
@cur_state = @root # used for building the tree
|
65
52
|
@default_mode = nil
|
53
|
+
@default_mode_stack = []
|
66
54
|
@mode_history = []
|
67
55
|
@state_trail = []
|
68
56
|
@last_action = nil
|
69
57
|
@cur_action = nil
|
58
|
+
@method_handles_repeat = false
|
70
59
|
|
71
60
|
@modifiers = { :ctrl => false, :shift => false, :alt => false } # TODO: create a queue
|
72
61
|
@last_event = [nil, nil, nil, nil, nil]
|
@@ -80,10 +69,26 @@ class KeyBindingTree
|
|
80
69
|
@match_state = [@modes[label]] # used for matching input
|
81
70
|
@mode_root_state = @modes[label]
|
82
71
|
@default_mode = label
|
72
|
+
@default_mode_stack << label
|
73
|
+
if !vma.buf.nil?
|
74
|
+
# vma.buf.mode_stack = @default_mode_stack.clone
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def set_mode_stack(ms)
|
79
|
+
@default_mode_stack = ms
|
83
80
|
end
|
84
81
|
|
85
82
|
def set_mode_to_default()
|
86
|
-
set_mode(@default_mode)
|
83
|
+
# set_mode(@default_mode)
|
84
|
+
set_mode(@default_mode_stack[-1])
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_previous_mode()
|
88
|
+
if @default_mode_stack.size > 1
|
89
|
+
@default_mode_stack.pop
|
90
|
+
end
|
91
|
+
set_mode_to_default()
|
87
92
|
end
|
88
93
|
|
89
94
|
def add_mode(id, label, cursortype = :command, name: nil)
|
@@ -180,8 +185,6 @@ class KeyBindingTree
|
|
180
185
|
|
181
186
|
if !vma.gui.view.nil?
|
182
187
|
vma.gui.view.draw_cursor() #TODO: handle outside this class
|
183
|
-
|
184
|
-
# Ripl.start :binding => binding
|
185
188
|
end
|
186
189
|
end
|
187
190
|
|
@@ -220,6 +223,7 @@ class KeyBindingTree
|
|
220
223
|
|
221
224
|
# Print key bindings to show as documentation or for debugging
|
222
225
|
def to_s()
|
226
|
+
# return self.class.to_s
|
223
227
|
s = ""
|
224
228
|
# @cur_state = @root
|
225
229
|
stack = [[@root, ""]]
|
@@ -284,9 +288,21 @@ class KeyBindingTree
|
|
284
288
|
act_s = cstate.action.to_s if cstate.action != nil
|
285
289
|
children << " #{cstate.to_s} #{act_s}\n"
|
286
290
|
end
|
291
|
+
if !@next_command_count.nil?
|
292
|
+
s_trail << " #{@next_command_count}"
|
293
|
+
end
|
287
294
|
return [s_trail, children]
|
288
295
|
end
|
289
296
|
|
297
|
+
def set_next_command_count(num)
|
298
|
+
if @next_command_count != nil
|
299
|
+
@next_command_count = @next_command_count * 10 + num.to_i
|
300
|
+
else
|
301
|
+
@next_command_count = num.to_i
|
302
|
+
end
|
303
|
+
debug("NEXT COMMAND COUNT: #{@next_command_count}")
|
304
|
+
end
|
305
|
+
|
290
306
|
# Modifies state of key binding tree (move to new state) based on received event
|
291
307
|
# Checks child nodes of current state if they match received event
|
292
308
|
# if yes, change state to child
|
@@ -354,7 +370,7 @@ class KeyBindingTree
|
|
354
370
|
if event_type == :key_press and c != "shift"
|
355
371
|
# TODO:include other modifiers in addition to shift?
|
356
372
|
set_state_to_root
|
357
|
-
printf(", BACK TO ROOT") if
|
373
|
+
printf(", BACK TO ROOT") if cnf.debug?
|
358
374
|
end
|
359
375
|
|
360
376
|
if event_type == :key_release and c == "shift!"
|
@@ -362,10 +378,10 @@ class KeyBindingTree
|
|
362
378
|
# only on key release when no other key has been pressed
|
363
379
|
# after said modifier key (shift).
|
364
380
|
set_state_to_root
|
365
|
-
printf(", BACK TO ROOT") if
|
381
|
+
printf(", BACK TO ROOT") if cnf.debug?
|
366
382
|
end
|
367
383
|
|
368
|
-
printf("\n") if
|
384
|
+
printf("\n") if cnf.debug?
|
369
385
|
else
|
370
386
|
|
371
387
|
# Don't execute action if one of the states has children
|
@@ -481,11 +497,10 @@ class KeyBindingTree
|
|
481
497
|
|
482
498
|
def handle_key_bindigs_action(action, c)
|
483
499
|
$acth << action
|
484
|
-
|
500
|
+
@method_handles_repeat = false #TODO:??
|
485
501
|
n = 1
|
486
|
-
if
|
487
|
-
n =
|
488
|
-
# $next_command_count = nil
|
502
|
+
if @next_command_count and !(action.class == String and action.include?("set_next_command_count"))
|
503
|
+
n = @next_command_count
|
489
504
|
debug("COUNT command #{n} times")
|
490
505
|
end
|
491
506
|
|
@@ -493,15 +508,18 @@ class KeyBindingTree
|
|
493
508
|
n.times do
|
494
509
|
ret = exec_action(action)
|
495
510
|
|
496
|
-
if
|
497
|
-
|
511
|
+
if vma.macro.is_recording and ret != false
|
512
|
+
debug "RECORD ACTION:#{action}", 2
|
513
|
+
vma.macro.record_action(action)
|
498
514
|
end
|
499
|
-
break if
|
515
|
+
break if @method_handles_repeat
|
500
516
|
# Some methods have specific implementation for repeat,
|
501
517
|
# like '5yy' => copy next five lines. (copy_line())
|
502
518
|
# By default the same command is just repeated n times
|
503
519
|
# like '20j' => go to next line 20 times.
|
520
|
+
# But methods can also handle the number input themselves if vma.kbd.method_handles_repeat=true is set,
|
504
521
|
end
|
522
|
+
# run_as_idle proc { vma.buf.refresh_cursor; vma.buf.refresh_cursor }, delay: 0.05
|
505
523
|
rescue SyntaxError
|
506
524
|
message("SYNTAX ERROR with eval cmd #{action}: " + $!.to_s)
|
507
525
|
# rescue NoMethodError
|
@@ -521,8 +539,8 @@ class KeyBindingTree
|
|
521
539
|
end
|
522
540
|
end
|
523
541
|
|
524
|
-
if action.class == String and
|
525
|
-
|
542
|
+
if !(action.class == String and action.include?("set_next_command_count"))
|
543
|
+
@next_command_count = nil
|
526
544
|
end
|
527
545
|
end
|
528
546
|
end
|
@@ -3,19 +3,19 @@ vma.kbd.add_mode("I", :insert, :insert)
|
|
3
3
|
vma.kbd.add_mode("V", :visual, :visual)
|
4
4
|
vma.kbd.add_mode("M", :minibuffer) #TODO: needed?
|
5
5
|
vma.kbd.add_mode("R", :readchar)
|
6
|
-
# vma.kbd.add_mode("audio", :audio, :command)
|
7
6
|
vma.kbd.add_minor_mode("audio", :audio, :command)
|
8
7
|
vma.kbd.add_mode("B", :browse, :command)
|
9
8
|
vma.kbd.add_mode("X", :replace, :command, name: "Replace")
|
10
9
|
vma.kbd.set_default_mode(:command)
|
11
10
|
vma.kbd.set_mode(:command)
|
12
|
-
vma.kbd.show_state_trail
|
11
|
+
# vma.kbd.show_state_trail
|
12
|
+
|
13
13
|
|
14
14
|
bindkey ["VCB M", "B m"], :run_last_macro
|
15
15
|
|
16
16
|
bindkey "VC s", :easy_jump
|
17
|
-
bindkey "VC , m f", [:find_macro_gui, proc {
|
18
|
-
bindkey "C , m n", [:gui_name_macro, proc {
|
17
|
+
bindkey "VC , m f", [:find_macro_gui, proc { vma.macro.find_macro_gui }, "Find named macro"]
|
18
|
+
bindkey "C , m n", [:gui_name_macro, proc { vma.macro.gui_name_macro }, "Name last macro"]
|
19
19
|
bindkey "C , j r", :jump_to_random
|
20
20
|
bindkey "I enter", :insert_new_line
|
21
21
|
bindkey "C , ; s k", :show_key_bindings #TODO: better binding
|
@@ -52,14 +52,14 @@ bindkey "C , w", :toggle_active_window
|
|
52
52
|
bindkey "C , , w", :toggle_two_column
|
53
53
|
|
54
54
|
bindkey "C , u s", :audio_stop
|
55
|
-
bindkey "C m a", "vma.kbd.set_mode(:audio)"
|
55
|
+
bindkey "C , m a", "vma.kbd.set_mode(:audio)"
|
56
56
|
bindkey "audio s", :audio_stop
|
57
|
+
bindkey "audio f || audio right", [:audio_forward, proc { Audio.seek_forward }, "Seek forward in audio stream"]
|
58
|
+
bindkey "audio left", [:audio_backward, proc { Audio.seek_forward(-5.0) }, "Seek backward in audio stream"]
|
59
|
+
|
57
60
|
bindkey "audio space", :audio_stop
|
58
61
|
bindkey "audio q || audio esc", "vma.kbd.set_mode_to_default"
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
63
|
# bindkey "C , f o", :open_file_dialog
|
64
64
|
bindkey "CI ctrl-o", :open_file_dialog
|
65
65
|
# bindkey "M enter", :minibuffer_end
|
@@ -72,6 +72,7 @@ bindkey "VC h", :e_move_backward_char
|
|
72
72
|
bindkey "C , , .", :backup_all_buffers
|
73
73
|
bindkey "C z ", :start_browse_mode
|
74
74
|
bindkey "B h", :history_switch_backwards
|
75
|
+
# bindkey "B h", [:browse_file_backwards, proc { vma.kbd.to_previous_mode; call_action(:history_switch_backwards); }, "Browse previous file"]
|
75
76
|
bindkey "B l", :history_switch_forwards
|
76
77
|
#bindkey 'B z', :center_on_current_line
|
77
78
|
bindkey "B z", "center_on_current_line();call_action(:exit_browse_mode)"
|
@@ -87,7 +88,6 @@ bindkey "B ;", "buf.jump_to_last_edit"
|
|
87
88
|
bindkey "B q", :jump_to_last_edit
|
88
89
|
bindkey "B w", :jump_to_next_edit
|
89
90
|
# bindkey "C , d", :diff_buffer
|
90
|
-
bindkey "C , g", :invoke_grep_search
|
91
91
|
#bindkey 'C , g', proc{invoke_grep_search}
|
92
92
|
bindkey "C , v", :auto_indent_buffer
|
93
93
|
bindkey "C , , d", :savedebug
|
@@ -110,7 +110,6 @@ default_keys = {
|
|
110
110
|
# 'C , s'=> 'gui_select_buffer',
|
111
111
|
"C , r v b" => :buf_revert,
|
112
112
|
"C , c b" => "bufs.close_current_buffer",
|
113
|
-
#"C , b" => 'vma.kbd.set_mode("S");gui_select_buffer',
|
114
113
|
"C , n b" => :buf_new,
|
115
114
|
# "C , , ." => "backup_all_buffers()",
|
116
115
|
"VC , , s" => :search_actions,
|
@@ -138,16 +137,16 @@ default_keys = {
|
|
138
137
|
"VC f space" => "buf.jump_to_next_instance_of_char(' ')",
|
139
138
|
"VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
|
140
139
|
|
141
|
-
"VC /[1-9]/" => "set_next_command_count(<char>)",
|
140
|
+
"VC /[1-9]/" => "vma.kbd.set_next_command_count(<char>)",
|
142
141
|
# 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
|
143
142
|
# 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
|
144
|
-
"VC
|
145
|
-
"VC
|
146
|
-
"VC 0(
|
147
|
-
"VC 0($next_command_count==nil)" => "buf.jump(BEGINNING_OF_LINE)",
|
143
|
+
"VC G(vma.kbd.next_command_count!=nil)" => "buf.jump_to_line()",
|
144
|
+
"VC 0(vma.kbd.next_command_count!=nil)" => "set_next_command_count(<char>)",
|
145
|
+
"VC 0(vma.kbd.next_command_count==nil)" => "buf.jump(BEGINNING_OF_LINE)",
|
148
146
|
# 'C 0'=> 'buf.jump(BEGINNING_OF_LINE)',
|
149
147
|
"VC g g" => "buf.jump(START_OF_BUFFER)",
|
150
148
|
"VC g ;" => "buf.jump_to_last_edit",
|
149
|
+
"VC ^" => "buf.jump(BEGINNING_OF_LINE)",
|
151
150
|
"VC G" => "buf.jump(END_OF_BUFFER)",
|
152
151
|
# 'VC z z' => 'center_on_current_line',
|
153
152
|
"VC *" => "buf.jump_to_next_instance_of_word",
|
@@ -186,7 +185,7 @@ default_keys = {
|
|
186
185
|
"C u" => "buf.undo()",
|
187
186
|
|
188
187
|
"C ^" => "buf.jump(BEGINNING_OF_LINE)",
|
189
|
-
"C /[1-9]/" => "set_next_command_count(<char>)",
|
188
|
+
# "C /[1-9]/" => "vma.kbd.set_next_command_count(<char>)",
|
190
189
|
|
191
190
|
# Command mode only:
|
192
191
|
"C ctrl-r" => "buf.redo()", # TODO:???
|
@@ -213,7 +212,7 @@ default_keys = {
|
|
213
212
|
"C r <char>" => "buf.replace_with_char(<char>)", # TODO
|
214
213
|
"C , l b" => "load_buffer_list",
|
215
214
|
"C , l l" => "save_buffer_list",
|
216
|
-
"C , r <char>" => "set_register(<char>)", # TODO
|
215
|
+
"C , r <char>" => "vma.set_register(<char>)", # TODO
|
217
216
|
"C , p <char>" => "buf.paste(BEFORE,<char>)", # TODO
|
218
217
|
|
219
218
|
"C ctrl-c" => "buf.comment_line()",
|
@@ -261,16 +260,16 @@ default_keys = {
|
|
261
260
|
|
262
261
|
# Macros
|
263
262
|
# (experimental, may not work correctly)
|
264
|
-
# "C q a" => '
|
265
|
-
"VC q <char>" => "
|
266
|
-
"VC q(
|
267
|
-
# 'C q'=> '
|
268
|
-
"C q v" => "
|
269
|
-
# 'C v'=> '
|
270
|
-
# "C M" => '
|
271
|
-
"C @ <char>" => "
|
272
|
-
"C , m S" => '
|
273
|
-
"C , m s" => "
|
263
|
+
# "C q a" => 'vma.macro.start_recording("a")',
|
264
|
+
"VC q <char>" => "vma.macro.start_recording(<char>)",
|
265
|
+
"VC q(vma.macro.is_recording==true) " => "$macro.end_recording", # TODO
|
266
|
+
# 'C q'=> 'vma.macro.end_recording', #TODO
|
267
|
+
"C q v" => "vma.macro.end_recording",
|
268
|
+
# 'C v'=> 'vma.macro.end_recording',
|
269
|
+
# "C M" => 'vma.macro.run_last_macro',
|
270
|
+
"C @ <char>" => "vma.macro.run_macro(<char>)",
|
271
|
+
"C , m S" => 'vma.macro.save_macro("a")',
|
272
|
+
"C , m s" => "vma.macro.save",
|
274
273
|
"C , t r" => "run_tests()",
|
275
274
|
|
276
275
|
# "C ." => "repeat_last_action", # TODO
|
@@ -278,10 +277,10 @@ default_keys = {
|
|
278
277
|
# "CV Q" => :quit,
|
279
278
|
"CV ctrl-q" => :quit,
|
280
279
|
"CV , R" => "restart_application",
|
281
|
-
"I ctrl!" => "vma.kbd.
|
280
|
+
# "I ctrl!" => "vma.kbd.to_previous_mode",
|
282
281
|
"C shift!" => "buf.save",
|
283
282
|
"I <char>" => "buf.insert_txt(<char>)",
|
284
|
-
"I esc" => "vma.kbd.
|
283
|
+
"I esc || I ctrl!" => "vma.kbd.set_mode_to_default",
|
285
284
|
|
286
285
|
"I ctrl-d" => "buf.delete2(:to_word_end)",
|
287
286
|
|
@@ -295,7 +294,8 @@ default_keys = {
|
|
295
294
|
"IX alt-f" => "buf.jump_word(FORWARD,WORD_START)",
|
296
295
|
"IX alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
|
297
296
|
|
298
|
-
"I tab" => 'buf.
|
297
|
+
"I tab" => 'buf.insert_tab',
|
298
|
+
"I shift-tab" => 'buf.unindent',
|
299
299
|
"I space" => 'buf.insert_txt(" ")',
|
300
300
|
# "I return" => 'buf.insert_new_line()',
|
301
301
|
}
|
data/lib/vimamsa/macro.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
def gui_find_macro_update_callback(search_str = "")
|
2
2
|
debug "gui_find_macro_update_callback: #{search_str}"
|
3
|
-
heystack =
|
3
|
+
heystack = vma.macro.named_macros
|
4
4
|
return [] if heystack.empty?
|
5
5
|
$macro_search_list = []
|
6
6
|
files = heystack.keys.sort.collect { |x| [x, 0] }
|
@@ -15,11 +15,11 @@ end
|
|
15
15
|
def gui_find_macro_select_callback(search_str, idx)
|
16
16
|
debug "gui_find_macro_select_callback"
|
17
17
|
selected = $macro_search_list[idx]
|
18
|
-
m =
|
18
|
+
m = vma.macro.named_macros[selected[0]].clone
|
19
19
|
debug "SELECTED MACRO:#{selected}, #{m}"
|
20
|
-
id =
|
21
|
-
|
22
|
-
|
20
|
+
id = vma.macro.last_macro
|
21
|
+
vma.macro.recorded_macros[id] = m
|
22
|
+
vma.macro.run_macro(id)
|
23
23
|
end
|
24
24
|
|
25
25
|
class Macro
|
@@ -52,7 +52,7 @@ class Macro
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def find_macro_gui()
|
55
|
-
l =
|
55
|
+
l = vma.macro.named_macros.keys.sort.collect { |x| [x, 0] }
|
56
56
|
$macro_search_list = l
|
57
57
|
$select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
58
58
|
|
@@ -116,36 +116,46 @@ class Macro
|
|
116
116
|
run_macro(@last_macro)
|
117
117
|
end
|
118
118
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
return false
|
123
|
-
end
|
124
|
-
message("Start running macro [#{name}]")
|
125
|
-
if @recorded_macros.has_key?(name)
|
126
|
-
@last_macro = name
|
127
|
-
end
|
128
|
-
acts = @recorded_macros[name]
|
119
|
+
# Run the provided list of actions
|
120
|
+
def run_actions(acts)
|
121
|
+
isok = true
|
129
122
|
if acts.kind_of?(Array) and acts.any?
|
130
123
|
@running_macro = true
|
131
|
-
|
132
|
-
#
|
124
|
+
# TODO:needed?
|
125
|
+
# set_last_command({ method: vma.macro.method("run_macro"), params: [name] })
|
133
126
|
for a in acts
|
134
127
|
ret = exec_action(a)
|
135
|
-
debug ret
|
136
128
|
if ret == false
|
137
|
-
|
138
|
-
|
139
|
-
|
129
|
+
error "Error while running macro"
|
130
|
+
isok=false
|
140
131
|
break
|
141
132
|
end
|
142
133
|
end
|
143
|
-
# eval_str = m.join(";")
|
144
|
-
# debug(eval_str)
|
145
|
-
# eval(eval_str)
|
146
134
|
end
|
147
135
|
@running_macro = false
|
148
136
|
buf.set_pos(buf.pos)
|
137
|
+
# TODO: Should be a better way to trigger this. Sometimes need to wait for GTK to process things before updating the cursor.
|
138
|
+
run_as_idle proc { vma.buf.refresh_cursor; vma.buf.refresh_cursor }, delay: 0.15
|
139
|
+
return isok
|
140
|
+
end
|
141
|
+
|
142
|
+
def run_macro(name)
|
143
|
+
if vma.macro.is_recording == true
|
144
|
+
message("Can't run a macro that runs a macro (recursion risk)")
|
145
|
+
return false
|
146
|
+
end
|
147
|
+
message("Start running macro [#{name}]")
|
148
|
+
if @recorded_macros.has_key?(name)
|
149
|
+
@last_macro = name
|
150
|
+
end
|
151
|
+
acts = @recorded_macros[name]
|
152
|
+
return run_actions(acts)
|
153
|
+
end
|
154
|
+
|
155
|
+
def dump_last_macro()
|
156
|
+
puts "======MACRO START======="
|
157
|
+
puts @recorded_macros[@last_macro].inspect
|
158
|
+
puts "======MACRO END========="
|
149
159
|
end
|
150
160
|
|
151
161
|
def save_macro(name)
|
data/lib/vimamsa/main.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#scriptdir=File.expand_path(File.dirname(__FILE__))
|
2
2
|
$:.unshift File.dirname(__FILE__) + "/lib"
|
3
3
|
|
4
|
-
|
4
|
+
#/home/samsam/Drive/code/vimamsa/git/lib/vimamsa/lib/vimamsa/main.rb require 'benchmark/ips'
|
5
5
|
|
6
6
|
# load "vendor/ver/lib/ver/vendor/textpow.rb"
|
7
7
|
# load "vendor/ver/lib/ver/syntax/detector.rb"
|
@@ -19,20 +19,13 @@ end
|
|
19
19
|
Encoding.default_external = Encoding::UTF_8
|
20
20
|
Encoding.default_internal = Encoding::UTF_8
|
21
21
|
|
22
|
-
# Globals
|
22
|
+
# Globals (TODO:refactor)
|
23
23
|
$command_history = []
|
24
|
-
$clipboard = []
|
25
|
-
$register = Hash.new("")
|
26
|
-
$cnf = {}
|
27
24
|
$errors = []
|
28
25
|
|
29
|
-
$cur_register = "a"
|
30
26
|
$debuginfo = {}
|
31
27
|
|
32
|
-
|
33
|
-
|
34
|
-
$debug = false
|
35
|
-
$experimental = false
|
28
|
+
cnf.debug = false
|
36
29
|
|
37
30
|
# Return currently active buffer
|
38
31
|
def buf()
|
data/lib/vimamsa/rbvma.rb
CHANGED
@@ -12,18 +12,24 @@ require "ripl/multi_line"
|
|
12
12
|
require "shellwords"
|
13
13
|
require "cgi"
|
14
14
|
require "uri"
|
15
|
+
require "vimamsa/conf"
|
15
16
|
require "vimamsa/util"
|
16
17
|
# exit!
|
17
18
|
require "vimamsa/main"
|
18
|
-
require "vimamsa/
|
19
|
+
require "vimamsa/terminal"
|
19
20
|
|
20
21
|
require "vimamsa/actions"
|
21
22
|
require "vimamsa/key_binding_tree"
|
22
23
|
require "vimamsa/key_actions"
|
23
24
|
|
25
|
+
require "vimamsa/clipboard"
|
26
|
+
|
24
27
|
# Graphical stuff:
|
25
28
|
require "vimamsa/gui"
|
29
|
+
require "vimamsa/gui_form_generator"
|
30
|
+
require "vimamsa/gui_text"
|
26
31
|
require "vimamsa/gui_menu"
|
32
|
+
require "vimamsa/gui_dialog"
|
27
33
|
require "vimamsa/gui_select_window"
|
28
34
|
require "vimamsa/gui_sourceview"
|
29
35
|
require "vimamsa/gui_image"
|
@@ -31,10 +37,13 @@ require "vimamsa/hyper_plain_text"
|
|
31
37
|
|
32
38
|
require "vimamsa/ack"
|
33
39
|
require "vimamsa/buffer"
|
40
|
+
require "vimamsa/buffer_cursor"
|
41
|
+
require "vimamsa/buffer_changetext"
|
34
42
|
require "vimamsa/buffer_list"
|
35
43
|
require "vimamsa/buffer_manager"
|
36
44
|
require "vimamsa/constants"
|
37
45
|
require "vimamsa/debug"
|
46
|
+
require "vimamsa/tests"
|
38
47
|
require "vimamsa/easy_jump"
|
39
48
|
require "vimamsa/encrypt"
|
40
49
|
require "vimamsa/file_finder"
|
@@ -43,7 +52,6 @@ require "vimamsa/hook"
|
|
43
52
|
require "vimamsa/macro"
|
44
53
|
require "vimamsa/search"
|
45
54
|
require "vimamsa/search_replace"
|
46
|
-
require "vimamsa/conf"
|
47
55
|
# load "vendor/ver/lib/ver/vendor/textpow.rb"
|
48
56
|
# load "vendor/ver/lib/ver/syntax/detector.rb"
|
49
57
|
# load "vendor/ver/config/detect.rb"
|
@@ -52,15 +60,7 @@ def unimplemented
|
|
52
60
|
debug "unimplemented"
|
53
61
|
end
|
54
62
|
|
55
|
-
|
56
|
-
$debug = false
|
57
|
-
|
58
|
-
def scan_indexes(txt, regex)
|
59
|
-
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
60
|
-
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
61
|
-
return indexes
|
62
|
-
end
|
63
|
-
|
63
|
+
cnf.debug = false
|
64
64
|
$update_cursor = false
|
65
65
|
|
66
66
|
|
data/lib/vimamsa/search.rb
CHANGED