vimamsa 0.1.12 → 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 +5 -5
- data/lib/vimamsa/actions.rb +13 -6
- data/lib/vimamsa/audio.rb +82 -0
- data/lib/vimamsa/buffer.rb +73 -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 +61 -125
- data/lib/vimamsa/encrypt.rb +6 -11
- data/lib/vimamsa/file_manager.rb +138 -9
- data/lib/vimamsa/gui.rb +11 -59
- data/lib/vimamsa/gui_dialog.rb +113 -0
- data/lib/vimamsa/gui_select_window.rb +9 -8
- data/lib/vimamsa/gui_sourceview.rb +110 -48
- data/lib/vimamsa/gui_text.rb +19 -0
- data/lib/vimamsa/hyper_plain_text.rb +15 -5
- data/lib/vimamsa/key_actions.rb +19 -195
- data/lib/vimamsa/key_binding_tree.rb +57 -33
- data/lib/vimamsa/key_bindings_vimlike.rb +39 -26
- data/lib/vimamsa/macro.rb +35 -25
- data/lib/vimamsa/main.rb +3 -17
- data/lib/vimamsa/rbvma.rb +11 -17
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +93 -131
- data/lib/vimamsa/terminal.rb +22 -0
- data/lib/vimamsa/tests.rb +122 -0
- data/lib/vimamsa/util.rb +87 -2
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +3 -1
- metadata +57 -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, ""]]
|
@@ -267,7 +271,12 @@ class KeyBindingTree
|
|
267
271
|
for st in @state_trail
|
268
272
|
st = st[0] if st.class == Array
|
269
273
|
if first
|
270
|
-
|
274
|
+
trailpfx = ""
|
275
|
+
if !st.major_modes.empty?
|
276
|
+
mmid = st.major_modes.first
|
277
|
+
trailpfx = "#{@modes[mmid].to_s}>"
|
278
|
+
end
|
279
|
+
s_trail << "[#{trailpfx}#{st.to_s}]"
|
271
280
|
else
|
272
281
|
s_trail << " #{st.to_s}"
|
273
282
|
end
|
@@ -279,9 +288,21 @@ class KeyBindingTree
|
|
279
288
|
act_s = cstate.action.to_s if cstate.action != nil
|
280
289
|
children << " #{cstate.to_s} #{act_s}\n"
|
281
290
|
end
|
291
|
+
if !@next_command_count.nil?
|
292
|
+
s_trail << " #{@next_command_count}"
|
293
|
+
end
|
282
294
|
return [s_trail, children]
|
283
295
|
end
|
284
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
|
+
|
285
306
|
# Modifies state of key binding tree (move to new state) based on received event
|
286
307
|
# Checks child nodes of current state if they match received event
|
287
308
|
# if yes, change state to child
|
@@ -349,7 +370,7 @@ class KeyBindingTree
|
|
349
370
|
if event_type == :key_press and c != "shift"
|
350
371
|
# TODO:include other modifiers in addition to shift?
|
351
372
|
set_state_to_root
|
352
|
-
printf(", BACK TO ROOT") if
|
373
|
+
printf(", BACK TO ROOT") if cnf.debug?
|
353
374
|
end
|
354
375
|
|
355
376
|
if event_type == :key_release and c == "shift!"
|
@@ -357,10 +378,10 @@ class KeyBindingTree
|
|
357
378
|
# only on key release when no other key has been pressed
|
358
379
|
# after said modifier key (shift).
|
359
380
|
set_state_to_root
|
360
|
-
printf(", BACK TO ROOT") if
|
381
|
+
printf(", BACK TO ROOT") if cnf.debug?
|
361
382
|
end
|
362
383
|
|
363
|
-
printf("\n") if
|
384
|
+
printf("\n") if cnf.debug?
|
364
385
|
else
|
365
386
|
|
366
387
|
# Don't execute action if one of the states has children
|
@@ -475,11 +496,11 @@ class KeyBindingTree
|
|
475
496
|
end
|
476
497
|
|
477
498
|
def handle_key_bindigs_action(action, c)
|
478
|
-
$
|
499
|
+
$acth << action
|
500
|
+
@method_handles_repeat = false #TODO:??
|
479
501
|
n = 1
|
480
|
-
if
|
481
|
-
n =
|
482
|
-
# $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
|
483
504
|
debug("COUNT command #{n} times")
|
484
505
|
end
|
485
506
|
|
@@ -487,15 +508,18 @@ class KeyBindingTree
|
|
487
508
|
n.times do
|
488
509
|
ret = exec_action(action)
|
489
510
|
|
490
|
-
if
|
491
|
-
|
511
|
+
if vma.macro.is_recording and ret != false
|
512
|
+
debug "RECORD ACTION:#{action}", 2
|
513
|
+
vma.macro.record_action(action)
|
492
514
|
end
|
493
|
-
break if
|
515
|
+
break if @method_handles_repeat
|
494
516
|
# Some methods have specific implementation for repeat,
|
495
517
|
# like '5yy' => copy next five lines. (copy_line())
|
496
518
|
# By default the same command is just repeated n times
|
497
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,
|
498
521
|
end
|
522
|
+
# run_as_idle proc { vma.buf.refresh_cursor; vma.buf.refresh_cursor }, delay: 0.05
|
499
523
|
rescue SyntaxError
|
500
524
|
message("SYNTAX ERROR with eval cmd #{action}: " + $!.to_s)
|
501
525
|
# rescue NoMethodError
|
@@ -515,8 +539,8 @@ class KeyBindingTree
|
|
515
539
|
end
|
516
540
|
end
|
517
541
|
|
518
|
-
if action.class == String and
|
519
|
-
|
542
|
+
if !(action.class == String and action.include?("set_next_command_count"))
|
543
|
+
@next_command_count = nil
|
520
544
|
end
|
521
545
|
end
|
522
546
|
end
|
@@ -531,7 +555,7 @@ def exec_action(action)
|
|
531
555
|
$kbd.last_action = $kbd.cur_action
|
532
556
|
$kbd.cur_action = action
|
533
557
|
if action.class == Symbol
|
534
|
-
return
|
558
|
+
return call_action(action)
|
535
559
|
elsif action.class == Proc
|
536
560
|
return action.call
|
537
561
|
else
|
@@ -3,17 +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_minor_mode("audio", :audio, :command)
|
6
7
|
vma.kbd.add_mode("B", :browse, :command)
|
7
8
|
vma.kbd.add_mode("X", :replace, :command, name: "Replace")
|
8
9
|
vma.kbd.set_default_mode(:command)
|
9
10
|
vma.kbd.set_mode(:command)
|
10
|
-
vma.kbd.show_state_trail
|
11
|
+
# vma.kbd.show_state_trail
|
12
|
+
|
11
13
|
|
12
14
|
bindkey ["VCB M", "B m"], :run_last_macro
|
13
15
|
|
14
16
|
bindkey "VC s", :easy_jump
|
15
|
-
bindkey "VC , m f", [:find_macro_gui, proc {
|
16
|
-
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"]
|
17
19
|
bindkey "C , j r", :jump_to_random
|
18
20
|
bindkey "I enter", :insert_new_line
|
19
21
|
bindkey "C , ; s k", :show_key_bindings #TODO: better binding
|
@@ -49,6 +51,15 @@ bindkey "C , b", :start_buf_manager
|
|
49
51
|
bindkey "C , w", :toggle_active_window
|
50
52
|
bindkey "C , , w", :toggle_two_column
|
51
53
|
|
54
|
+
bindkey "C , u s", :audio_stop
|
55
|
+
bindkey "C , m a", "vma.kbd.set_mode(:audio)"
|
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
|
+
|
60
|
+
bindkey "audio space", :audio_stop
|
61
|
+
bindkey "audio q || audio esc", "vma.kbd.set_mode_to_default"
|
62
|
+
|
52
63
|
# bindkey "C , f o", :open_file_dialog
|
53
64
|
bindkey "CI ctrl-o", :open_file_dialog
|
54
65
|
# bindkey "M enter", :minibuffer_end
|
@@ -61,9 +72,10 @@ bindkey "VC h", :e_move_backward_char
|
|
61
72
|
bindkey "C , , .", :backup_all_buffers
|
62
73
|
bindkey "C z ", :start_browse_mode
|
63
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"]
|
64
76
|
bindkey "B l", :history_switch_forwards
|
65
77
|
#bindkey 'B z', :center_on_current_line
|
66
|
-
bindkey "B z", "center_on_current_line();
|
78
|
+
bindkey "B z", "center_on_current_line();call_action(:exit_browse_mode)"
|
67
79
|
bindkey "B enter || B return || B esc || B j || B ctrl!", :exit_browse_mode
|
68
80
|
bindkey "B s", :page_up
|
69
81
|
bindkey "B d", :page_down
|
@@ -76,7 +88,6 @@ bindkey "B ;", "buf.jump_to_last_edit"
|
|
76
88
|
bindkey "B q", :jump_to_last_edit
|
77
89
|
bindkey "B w", :jump_to_next_edit
|
78
90
|
# bindkey "C , d", :diff_buffer
|
79
|
-
bindkey "C , g", :invoke_grep_search
|
80
91
|
#bindkey 'C , g', proc{invoke_grep_search}
|
81
92
|
bindkey "C , v", :auto_indent_buffer
|
82
93
|
bindkey "C , , d", :savedebug
|
@@ -99,7 +110,6 @@ default_keys = {
|
|
99
110
|
# 'C , s'=> 'gui_select_buffer',
|
100
111
|
"C , r v b" => :buf_revert,
|
101
112
|
"C , c b" => "bufs.close_current_buffer",
|
102
|
-
#"C , b" => 'vma.kbd.set_mode("S");gui_select_buffer',
|
103
113
|
"C , n b" => :buf_new,
|
104
114
|
# "C , , ." => "backup_all_buffers()",
|
105
115
|
"VC , , s" => :search_actions,
|
@@ -127,16 +137,16 @@ default_keys = {
|
|
127
137
|
"VC f space" => "buf.jump_to_next_instance_of_char(' ')",
|
128
138
|
"VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
|
129
139
|
|
130
|
-
"VC /[1-9]/" => "set_next_command_count(<char>)",
|
140
|
+
"VC /[1-9]/" => "vma.kbd.set_next_command_count(<char>)",
|
131
141
|
# 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
|
132
142
|
# 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
|
133
|
-
"VC
|
134
|
-
"VC
|
135
|
-
"VC 0(
|
136
|
-
"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)",
|
137
146
|
# 'C 0'=> 'buf.jump(BEGINNING_OF_LINE)',
|
138
147
|
"VC g g" => "buf.jump(START_OF_BUFFER)",
|
139
148
|
"VC g ;" => "buf.jump_to_last_edit",
|
149
|
+
"VC ^" => "buf.jump(BEGINNING_OF_LINE)",
|
140
150
|
"VC G" => "buf.jump(END_OF_BUFFER)",
|
141
151
|
# 'VC z z' => 'center_on_current_line',
|
142
152
|
"VC *" => "buf.jump_to_next_instance_of_word",
|
@@ -162,6 +172,7 @@ default_keys = {
|
|
162
172
|
"C , d b" => "debug_print_buffer",
|
163
173
|
"C , d c" => "debug_dump_clipboard",
|
164
174
|
"C , d d" => "debug_dump_deltas",
|
175
|
+
|
165
176
|
"VC O" => "buf.jump(END_OF_LINE)",
|
166
177
|
"VC $" => "buf.jump(END_OF_LINE)",
|
167
178
|
|
@@ -174,7 +185,7 @@ default_keys = {
|
|
174
185
|
"C u" => "buf.undo()",
|
175
186
|
|
176
187
|
"C ^" => "buf.jump(BEGINNING_OF_LINE)",
|
177
|
-
"C /[1-9]/" => "set_next_command_count(<char>)",
|
188
|
+
# "C /[1-9]/" => "vma.kbd.set_next_command_count(<char>)",
|
178
189
|
|
179
190
|
# Command mode only:
|
180
191
|
"C ctrl-r" => "buf.redo()", # TODO:???
|
@@ -197,10 +208,11 @@ default_keys = {
|
|
197
208
|
"C d $" => "buf.delete2(:to_line_end)",
|
198
209
|
# 'C d e'=> 'buf.delete_to_next_word_end',
|
199
210
|
"C d <num> e" => "delete_next_word",
|
211
|
+
"C d ' <char>" => "buf.delete2(:to_mark,<char>)",
|
200
212
|
"C r <char>" => "buf.replace_with_char(<char>)", # TODO
|
201
213
|
"C , l b" => "load_buffer_list",
|
202
214
|
"C , l l" => "save_buffer_list",
|
203
|
-
"C , r <char>" => "set_register(<char>)", # TODO
|
215
|
+
"C , r <char>" => "vma.set_register(<char>)", # TODO
|
204
216
|
"C , p <char>" => "buf.paste(BEFORE,<char>)", # TODO
|
205
217
|
|
206
218
|
"C ctrl-c" => "buf.comment_line()",
|
@@ -248,16 +260,16 @@ default_keys = {
|
|
248
260
|
|
249
261
|
# Macros
|
250
262
|
# (experimental, may not work correctly)
|
251
|
-
# "C q a" => '
|
252
|
-
"VC q <char>" => "
|
253
|
-
"VC q(
|
254
|
-
# 'C q'=> '
|
255
|
-
"C q v" => "
|
256
|
-
# 'C v'=> '
|
257
|
-
# "C M" => '
|
258
|
-
"C @ <char>" => "
|
259
|
-
"C , m S" => '
|
260
|
-
"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",
|
261
273
|
"C , t r" => "run_tests()",
|
262
274
|
|
263
275
|
# "C ." => "repeat_last_action", # TODO
|
@@ -265,10 +277,10 @@ default_keys = {
|
|
265
277
|
# "CV Q" => :quit,
|
266
278
|
"CV ctrl-q" => :quit,
|
267
279
|
"CV , R" => "restart_application",
|
268
|
-
"I ctrl!" => "vma.kbd.
|
280
|
+
# "I ctrl!" => "vma.kbd.to_previous_mode",
|
269
281
|
"C shift!" => "buf.save",
|
270
282
|
"I <char>" => "buf.insert_txt(<char>)",
|
271
|
-
"I esc" => "vma.kbd.
|
283
|
+
"I esc || I ctrl!" => "vma.kbd.set_mode_to_default",
|
272
284
|
|
273
285
|
"I ctrl-d" => "buf.delete2(:to_word_end)",
|
274
286
|
|
@@ -282,7 +294,8 @@ default_keys = {
|
|
282
294
|
"IX alt-f" => "buf.jump_word(FORWARD,WORD_START)",
|
283
295
|
"IX alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
|
284
296
|
|
285
|
-
"I tab" => 'buf.
|
297
|
+
"I tab" => 'buf.insert_tab',
|
298
|
+
"I shift-tab" => 'buf.unindent',
|
286
299
|
"I space" => 'buf.insert_txt(" ")',
|
287
300
|
# "I return" => 'buf.insert_new_line()',
|
288
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()
|
@@ -49,18 +42,11 @@ end
|
|
49
42
|
|
50
43
|
require "vimamsa/editor.rb"
|
51
44
|
|
52
|
-
# load "gui_funcs.rb"
|
53
|
-
|
54
45
|
$vma = Editor.new
|
55
46
|
def vma()
|
56
47
|
return $vma
|
57
48
|
end
|
58
49
|
|
59
|
-
# c_startup
|
60
|
-
# run_random_jump_test
|
61
|
-
# main_loop
|
62
|
-
|
63
|
-
# debug("END")
|
64
50
|
|
65
51
|
|
66
52
|
|
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,30 +52,15 @@ 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"
|
50
58
|
|
51
|
-
$vma = Editor.new
|
52
|
-
|
53
|
-
def vma()
|
54
|
-
return $vma
|
55
|
-
end
|
56
|
-
|
57
59
|
def unimplemented
|
58
60
|
debug "unimplemented"
|
59
61
|
end
|
60
62
|
|
61
|
-
|
62
|
-
$debug = false
|
63
|
-
|
64
|
-
def scan_indexes(txt, regex)
|
65
|
-
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
66
|
-
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
67
|
-
return indexes
|
68
|
-
end
|
69
|
-
|
63
|
+
cnf.debug = false
|
70
64
|
$update_cursor = false
|
71
65
|
|
72
66
|
|
data/lib/vimamsa/search.rb
CHANGED