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.
data/lib/vimamsa/gui.rb CHANGED
@@ -6,7 +6,6 @@ def gui_open_file_dialog(dirpath)
6
6
  :buttons => [["Open", :accept],
7
7
  ["Cancel", :cancel]])
8
8
  dialog.set_current_folder(Gio::File.new_for_path(dirpath))
9
- # dialog.set_current_folder(Gio::File.new_for_path("/tmp"))
10
9
 
11
10
  dialog.signal_connect("response") do |dialog, response_id|
12
11
  if response_id == Gtk::ResponseType::ACCEPT
@@ -24,7 +23,7 @@ def gui_file_saveas(dirpath)
24
23
  :action => :save,
25
24
  :buttons => [["Save", :accept],
26
25
  ["Cancel", :cancel]])
27
- # dialog.set_current_folder(dirpath) #TODO:gtk4
26
+ dialog.set_current_folder(Gio::File.new_for_path(dirpath))
28
27
  dialog.signal_connect("response") do |dialog, response_id|
29
28
  if response_id == Gtk::ResponseType::ACCEPT
30
29
  file_saveas(dialog.file.parse_name)
@@ -36,32 +35,6 @@ def gui_file_saveas(dirpath)
36
35
  dialog.show
37
36
  end
38
37
 
39
- def idle_func
40
- # debug "IDLEFUNC"
41
- if $idle_scroll_to_mark
42
- # $view.get_visible_rect
43
- vr = $view.visible_rect
44
-
45
- # iter = b.get_iter_at(:offset => i)
46
-
47
- b = $view.buffer
48
- iter = b.get_iter_at(:offset => b.cursor_position)
49
- iterxy = $view.get_iter_location(iter)
50
- # debug "ITERXY" + iterxy.inspect
51
-
52
- intr = iterxy.intersect(vr)
53
- if intr.nil?
54
- $view.set_cursor_pos($view.buffer.cursor_position)
55
- else
56
- $idle_scroll_to_mark = false
57
- end
58
-
59
- sleep(0.1)
60
- end
61
- sleep(0.01)
62
- return true
63
- end
64
-
65
38
  def center_on_current_line()
66
39
  b = $view.buffer
67
40
  iter = b.get_iter_at(:offset => b.cursor_position)
@@ -91,9 +64,6 @@ def page_down
91
64
  end
92
65
 
93
66
 
94
- def set_system_clipboard(arg)
95
- vma.gui.window.display.clipboard.set(arg)
96
- end
97
67
 
98
68
  def gui_create_buffer(id, bufo)
99
69
  debug "gui_create_buffer(#{id})"
@@ -101,7 +71,7 @@ def gui_create_buffer(id, bufo)
101
71
  view = VSourceView.new(nil, bufo)
102
72
 
103
73
  view.register_signals()
104
- $debug = true
74
+ cnf.debug = true
105
75
 
106
76
  ssm = GtkSource::StyleSchemeManager.new
107
77
  ssm.set_search_path(ssm.search_path << ppath("styles/"))
@@ -118,6 +88,7 @@ def gui_create_buffer(id, bufo)
118
88
  provider.load(data: "textview { font-family: Monospace; font-size: 11pt; }")
119
89
  view.style_context.add_provider(provider)
120
90
  view.wrap_mode = :char
91
+ pp $cnf
121
92
  view.set_tab_width(conf(:tab_width))
122
93
 
123
94
  $vmag.buffers[id] = view
@@ -0,0 +1,113 @@
1
+ module Gui
2
+ def self.confirm(title, callback)
3
+ params = {}
4
+ params["title"] = title
5
+ params["inputs"] = {}
6
+ params["inputs"]["yes_btn"] = { :label => "Yes", :type => :button, :default_focus => true }
7
+ params[:callback] = callback
8
+ PopupFormGenerator.new(params).run
9
+ end
10
+ end
11
+
12
+ module Gtk
13
+ class Frame
14
+ def margin=(a)
15
+ self.margin_bottom = a
16
+ self.margin_top = a
17
+ self.margin_end = a
18
+ self.margin_start = a
19
+ end
20
+ end
21
+
22
+ class Box
23
+ def margin=(a)
24
+ self.margin_bottom = a
25
+ self.margin_top = a
26
+ self.margin_end = a
27
+ self.margin_start = a
28
+ end
29
+ end
30
+ end
31
+
32
+ def set_margin_all(widget, m)
33
+ widget.margin_bottom = m
34
+ widget.margin_top = m
35
+ widget.margin_end = m
36
+ widget.margin_start = m
37
+ end
38
+
39
+ class OneInputAction
40
+ def initialize(main_window, title, field_label, button_title, callback, opt = {})
41
+ @window = Gtk::Window.new()
42
+ # @window.screen = main_window.screen
43
+ # @window.title = title
44
+ @window.title = ""
45
+
46
+ frame = Gtk::Frame.new()
47
+ # frame.margin = 20
48
+ @window.set_child(frame)
49
+
50
+ infolabel = Gtk::Label.new
51
+ infolabel.markup = title
52
+
53
+ vbox = Gtk::Box.new(:vertical, 8)
54
+ vbox.margin = 10
55
+ frame.set_child(vbox)
56
+
57
+ hbox = Gtk::Box.new(:horizontal, 8)
58
+ # @window.add(hbox)
59
+ vbox.pack_end(infolabel, :expand => false, :fill => false, :padding => 0)
60
+ vbox.pack_end(hbox, :expand => false, :fill => false, :padding => 0)
61
+
62
+ button = Gtk::Button.new(:label => button_title)
63
+ cancel_button = Gtk::Button.new(:label => "Cancel")
64
+
65
+ label = Gtk::Label.new(field_label)
66
+
67
+ @entry1 = Gtk::Entry.new
68
+
69
+ if opt[:hide]
70
+ @entry1.visibility = false
71
+ end
72
+
73
+ button.signal_connect "clicked" do
74
+ callback.call(@entry1.text)
75
+ @window.destroy
76
+ end
77
+
78
+ cancel_button.signal_connect "clicked" do
79
+ @window.destroy
80
+ end
81
+
82
+ press = Gtk::EventControllerKey.new
83
+ press.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
84
+ @window.add_controller(press)
85
+ press.signal_connect "key-pressed" do |gesture, keyval, keycode, y|
86
+ if keyval == Gdk::Keyval::KEY_Return
87
+ callback.call(@entry1.text)
88
+ @window.destroy
89
+ true
90
+ elsif keyval == Gdk::Keyval::KEY_Escape
91
+ @window.destroy
92
+ true
93
+ else
94
+ false
95
+ end
96
+ end
97
+
98
+ hbox.pack_end(label, :expand => false, :fill => false, :padding => 0)
99
+ hbox.pack_end(@entry1, :expand => false, :fill => false, :padding => 0)
100
+ hbox.pack_end(button, :expand => false, :fill => false, :padding => 0)
101
+ hbox.pack_end(cancel_button, :expand => false, :fill => false, :padding => 0)
102
+ return
103
+ end
104
+
105
+ def run
106
+ if !@window.visible?
107
+ @window.show
108
+ else
109
+ @window.destroy
110
+ end
111
+ @window
112
+ end
113
+ end
@@ -291,6 +291,7 @@ class VSourceView < GtkSource::View
291
291
  keyval_trans[Gdk::Keyval::KEY_Shift_L] = "shift"
292
292
  keyval_trans[Gdk::Keyval::KEY_Shift_R] = "shift"
293
293
  keyval_trans[Gdk::Keyval::KEY_Tab] = "tab"
294
+ keyval_trans[Gdk::Keyval::GDK_KEY_ISO_Left_Tab] = "tab"
294
295
 
295
296
  key_trans = {}
296
297
  key_trans["\e"] = "esc"
@@ -311,10 +312,12 @@ class VSourceView < GtkSource::View
311
312
  key_str_parts.delete_at(0)
312
313
  end
313
314
 
314
- if key_str_parts[0] == "shift" and key_str_parts[1].class == String
315
- #"shift-P" to just "P"
316
- # key_str_parts.delete_at(0) if key_str_parts[1].match(/^[[:upper:]]$/)
317
- key_str_parts.delete_at(0)
315
+ if key_str_parts[0] == "shift" and key_str_parts.size == 2
316
+ if key_str_parts[1].size == 1 # and key_str_parts[1].match(/^[[:upper:]]$/)
317
+ #"shift-P" to just "P" etc.
318
+ # but keep shift-tab as is
319
+ key_str_parts.delete_at(0)
320
+ end
318
321
  end
319
322
 
320
323
  key_str = key_str_parts.join("-")
@@ -433,13 +436,9 @@ class VSourceView < GtkSource::View
433
436
  end
434
437
 
435
438
  def cursor_visible_idle_func
439
+ return false
436
440
  debug "cursor_visible_idle_func"
437
441
  # From https://picheta.me/articles/2013/08/gtk-plus--a-method-to-guarantee-scrolling.html
438
- # vr = visible_rect
439
-
440
- # b = $view.buffer
441
- # iter = buffer.get_iter_at(:offset => buffer.cursor_position)
442
- # iterxy = get_iter_location(iter)
443
442
 
444
443
  # This is not the current buffer
445
444
  return false if vma.gui.view != self
@@ -483,16 +482,13 @@ class VSourceView < GtkSource::View
483
482
  end
484
483
 
485
484
  def ensure_cursor_visible
486
- return #TODO:gtk4
485
+ # return
487
486
  debug "@idle_func_running=#{@idle_func_running}"
488
487
  return if @idle_func_running
489
488
  if is_cursor_visible == false
490
489
  @idle_func_running = true
491
490
  debug "Starting idle func"
492
- Thread.new {
493
- sleep 0.01
494
- GLib::Idle.add(proc { cursor_visible_idle_func })
495
- }
491
+ GLib::Idle.add(proc { cursor_visible_idle_func })
496
492
  end
497
493
  end
498
494
 
@@ -0,0 +1,19 @@
1
+ module Gui
2
+ def self.highlight_match(bf, str, color: "#aa0000ff")
3
+ vbuf = bf.view.buffer
4
+ r = Regexp.new(Regexp.escape(str), Regexp::IGNORECASE)
5
+
6
+ hlparts = []
7
+
8
+ tt = vma.gui.view.buffer.create_tag("highlight_match_tag")
9
+ tt.weight = 650
10
+ tt.foreground = color
11
+
12
+ ind = scan_indexes(bf, r)
13
+ ind.each { |x|
14
+ itr = vbuf.get_iter_at(:offset => x)
15
+ itr2 = vbuf.get_iter_at(:offset => x + str.size)
16
+ vbuf.apply_tag(tt, itr, itr2)
17
+ }
18
+ end
19
+ end
@@ -1,9 +1,7 @@
1
1
  def hpt_check_cur_word(w)
2
2
  debug "check_cur_word(w)"
3
- m = w.match(/⟦((audio|img):)(.*)⟧/)
3
+ m = w.match(/⟦((audio|img):)?(.*)⟧/)
4
4
  if m
5
- # Ripl.start :binding => binding
6
-
7
5
  fpfx = m[3]
8
6
  if vma.buf.fname
9
7
  dn = File.dirname(vma.buf.fname)
@@ -17,8 +15,9 @@ def hpt_check_cur_word(w)
17
15
  fcands << File.expand_path("#{fpfx}.txt")
18
16
 
19
17
  fn = nil
18
+
20
19
  for fc in fcands
21
- if File.exists?(fc)
20
+ if File.exist?(fc)
22
21
  fn = fc
23
22
  break
24
23
  end
@@ -27,8 +26,12 @@ def hpt_check_cur_word(w)
27
26
  if fn
28
27
  if m[2] == "audio"
29
28
  # Thread.new { Audio.play(fn) }
30
- Audio.play(fn)
29
+ Audio.play(fn)
31
30
  else
31
+ if !file_is_text_file(fn)
32
+ message "Not text file #{fn}"
33
+ return nil
34
+ end
32
35
  message "HPT opening file #{fn}"
33
36
  return fn
34
37
  end
@@ -31,10 +31,15 @@ end
31
31
  reg_act(:lsp_debug, proc { vma.buf.lsp_get_def }, "LSP get definition")
32
32
  reg_act(:lsp_jump_to_definition, proc { vma.buf.lsp_jump_to_def }, "LSP jump to definition")
33
33
 
34
- reg_act(:enable_debug, proc { $debug = true }, "Enable debug")
35
- reg_act(:disable_debug, proc { $debug = false }, "Disable debug")
34
+ reg_act(:enable_debug, proc { cnf.debug = true }, "Enable debug")
35
+ reg_act(:disable_debug, proc { cnf.debug = false }, "Disable debug")
36
36
 
37
37
  reg_act(:easy_jump, proc { EasyJump.start }, "Easy jump")
38
+ reg_act(:gui_ensure_cursor_visible, proc { vma.gui.view.ensure_cursor_visible }, "Scroll to current cursor position")
39
+ reg_act(:gui_refresh_cursor, proc { vma.buf.refresh_cursor }, "Refresh cursor")
40
+
41
+
42
+
38
43
  reg_act(:savedebug, "savedebug", "Save debug info", { :group => :debug })
39
44
  reg_act(:open_file_dialog, "open_file_dialog", "Open file", { :group => :file })
40
45
  reg_act(:create_new_file, "create_new_file", "Create new file", { :group => :file })
@@ -44,7 +49,7 @@ reg_act(:e_move_backward_char, "e_move_backward_char", "", { :group => [:move, :
44
49
  reg_act(:history_switch_backwards, "history_switch_backwards", "", { :group => :file })
45
50
  reg_act(:history_switch_forwards, "history_switch_forwards", "", { :group => :file })
46
51
  reg_act(:center_on_current_line, "center_on_current_line", "", { :group => :view })
47
- reg_act(:run_last_macro, proc { $macro.run_last_macro }, "Run last recorded or executed macro", { :group => :macro })
52
+ reg_act(:run_last_macro, proc { vma.macro.run_last_macro }, "Run last recorded or executed macro", { :group => :macro })
48
53
  reg_act(:jump_to_next_edit, "jump_to_next_edit", "")
49
54
  reg_act(:jump_to_last_edit, proc { buf.jump_to_last_edit }, "")
50
55
  reg_act(:jump_to_random, proc { buf.jump_to_random_pos }, "")
@@ -91,7 +96,9 @@ reg_act :delete_to_next_word_start, proc { buf.delete2(:to_next_word) }, "Delete
91
96
  reg_act :delete_to_line_start, proc { buf.delete2(:to_line_start) }, "Delete to line start", { :group => [:edit, :basic] }
92
97
  reg_act :start_browse_mode, proc { $kbd.set_mode(:browse); $kbd.set_default_mode(:browse) }, "Start browse mode"
93
98
  reg_act :exit_browse_mode, proc {
94
- bufs.add_current_buf_to_history(); $kbd.set_mode(:command); $kbd.set_default_mode(:command)
99
+ bufs.add_current_buf_to_history;
100
+ vma.kbd.set_mode_stack([vma.buf.default_mode])
101
+ vma.kbd.set_mode_to_default
95
102
  }, "Exit browse mode"
96
103
 
97
104
  reg_act :page_down, proc { page_down }, "Page down", :group => [:move, :basic]
@@ -104,10 +111,8 @@ reg_act(:execute_current_line_in_terminal_autoclose, proc { buf.execute_current_
104
111
  reg_act(:show_images, proc { hpt_scan_images() }, "Show images inserted with ⟦img:file.png⟧ syntax")
105
112
  reg_act(:delete_current_file, proc { bufs.delete_current_buffer() }, "Delete current file")
106
113
 
107
-
108
114
  reg_act(:audio_stop, proc { Audio.stop }, "Stop audio playback")
109
115
 
110
-
111
116
  act_list = {
112
117
  # File handling
113
118
  :buf_save => { :proc => proc { buf.save },
@@ -168,199 +173,14 @@ act_list = {
168
173
  :quit => { :proc => proc { _quit },
169
174
  :desc => "Quit", :group => :app },
170
175
 
176
+ :run_tests => { :proc => proc { run_tests },
177
+ :desc => "Run tests" },
178
+
179
+ :debug_buf_hex => { :proc => proc { puts "SHA256: " + (Digest::SHA2.hexdigest vma.buf.to_s) },
180
+ :desc => "Output SHA256 hex digest of curent buffer" },
181
+
171
182
  }
172
183
 
173
184
  for k, v in act_list
174
185
  reg_act(k, v[:proc], v[:desc])
175
186
  end
176
-
177
- act_list_todo = {
178
-
179
- # Buffer handling
180
- # : => {proc => proc {bufs.switch}, :desc => "", :group => :},
181
- :buf_switch_to_last => { :proc => proc { bufs.switch_to_last_buf },
182
- :desc => "", :group => :file },
183
- # 'C , s'=> 'gui_select_buffer',
184
- :buf_revert => { :proc => proc { buf.revert },
185
- :desc => "Reload/revert file from disk", :group => :file },
186
- :buf_close => { :proc => proc { bufs.close_current_buffer },
187
- :desc => "Close current file", :group => :file },
188
- #"C , b" => '$kbd.set_mode("S");gui_select_buffer',
189
-
190
- # MOVING
191
- # 'VC h' => 'buf.move(BACKWARD_CHAR)',
192
- :m_forward_char => { :proc => proc { buf.move(FORWARD_CHAR) },
193
- :desc => "Move cursor one char forward",
194
- :group => :move },
195
- # "VC j" => "buf.move(FORWARD_LINE)",
196
- # "VC k" => "buf.move(BACKWARD_LINE)",
197
-
198
- "VC pagedown" => "page_down",
199
- "VC pageup" => "page_up",
200
-
201
- "VCI left" => "buf.move(BACKWARD_CHAR)",
202
- "VCI right" => "buf.move(FORWARD_CHAR)",
203
- "VCI down" => "buf.move(FORWARD_LINE)",
204
- "VCI up" => "buf.move(BACKWARD_LINE)",
205
-
206
- "VC w" => "buf.jump_word(FORWARD,WORD_START)",
207
- "VC b" => "buf.jump_word(BACKWARD,WORD_START)",
208
- "VC e" => "buf.jump_word(FORWARD,WORD_END)",
209
- # 'C '=> 'buf.jump_word(BACKWARD,END)',#TODO
210
- "VC f <char>" => "buf.jump_to_next_instance_of_char(<char>)",
211
- "VC F <char>" => "buf.jump_to_next_instance_of_char(<char>,BACKWARD)",
212
- "VC f space" => "buf.jump_to_next_instance_of_char(' ')",
213
- "VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
214
-
215
- "VC /[1-9]/" => "set_next_command_count(<char>)",
216
- # 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
217
- # 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
218
- "VC ^" => "buf.jump(BEGINNING_OF_LINE)",
219
- "VC G($next_command_count!=nil)" => "buf.jump_to_line()",
220
- "VC 0($next_command_count!=nil)" => "set_next_command_count(<char>)",
221
- "VC 0($next_command_count==nil)" => "buf.jump(BEGINNING_OF_LINE)",
222
- # 'C 0'=> 'buf.jump(BEGINNING_OF_LINE)',
223
- "VC g g" => "buf.jump(START_OF_BUFFER)",
224
- "VC g ;" => "buf.jump_to_last_edit",
225
- "VC G" => "buf.jump(END_OF_BUFFER)",
226
- # 'VC z z' => 'center_on_current_line',
227
- "VC *" => "buf.jump_to_next_instance_of_word",
228
-
229
- # MINIBUFFER bindings
230
- "VC /" => "invoke_search",
231
- # 'VC :' => 'invoke_command', #TODO
232
- "C , e" => "invoke_command", # Currently eval
233
- "M enter" => "minibuffer_end()",
234
- # "M return" => "minibuffer_end()",
235
- "M esc" => "minibuffer_cancel()",
236
- "M backspace" => "minibuffer_delete()",
237
- "M <char>" => "minibuffer_new_char(<char>)",
238
- "M ctrl-v" => "$minibuffer.paste(BEFORE)",
239
-
240
- # READCHAR bindings
241
-
242
- "R <char>" => "readchar_new_char(<char>)",
243
-
244
- "C n" => "$search.jump_to_next()",
245
- "C N" => "$search.jump_to_previous()",
246
-
247
- # Debug
248
- "C , d r p" => "start_ripl",
249
- "C , D" => "debug_print_buffer",
250
- "C , c s" => "bufs.close_scrap_buffers",
251
- "C , d b" => "debug_print_buffer",
252
- "C , d c" => "debug_dump_clipboard",
253
- "C , d d" => "debug_dump_deltas",
254
- "VC O" => "buf.jump(END_OF_LINE)",
255
- "VC $" => "buf.jump(END_OF_LINE)",
256
-
257
- "C o" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");$kbd.set_mode(:insert)',
258
- "C X" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");',
259
- "C A" => "buf.jump(END_OF_LINE);$kbd.set_mode(:insert)",
260
- "C I" => "buf.jump(FIRST_NON_WHITESPACE);$kbd.set_mode(:insert)",
261
- "C a" => "buf.move(FORWARD_CHAR);$kbd.set_mode(:insert)",
262
- "C J" => "buf.join_lines()",
263
- "C u" => "buf.undo()",
264
-
265
- "C ^" => "buf.jump(BEGINNING_OF_LINE)",
266
- "C /[1-9]/" => "set_next_command_count(<char>)",
267
-
268
- # Command mode only:
269
- "C R" => "buf.redo()",
270
- "C v" => "buf.start_visual_mode",
271
- "C P" => "buf.paste(BEFORE)", # TODO: implement as replace for visual mode
272
- "C space <char>" => "buf.insert_txt(<char>)",
273
- "C space space" => "buf.insert_txt(' ')",
274
- "C y y" => "buf.copy_line",
275
- "C y O" => "buf.copy(:to_line_end)",
276
- "C y 0" => "buf.copy(:to_line_start)",
277
- "C y e" => "buf.copy(:to_word_end)", # TODO
278
- #### Deleting
279
- "C x" => "buf.delete(CURRENT_CHAR_FORWARD)",
280
- # 'C d k'=> 'delete_line(BACKWARD)', #TODO
281
- # 'C d j'=> 'delete_line(FORWARD)', #TODO
282
- # 'C d d'=> 'buf.delete_cur_line',
283
- "C d e" => "buf.delete2(:to_word_end)",
284
- "C d O" => "buf.delete2(:to_line_end)",
285
- "C d $" => "buf.delete2(:to_line_end)",
286
- # 'C d e'=> 'buf.delete_to_next_word_end',
287
- "C d <num> e" => "delete_next_word",
288
- "C r <char>" => "buf.replace_with_char(<char>)", # TODO
289
- "C , l b" => "load_buffer_list",
290
- "C , l l" => "save_buffer_list",
291
- "C , r <char>" => "set_register(<char>)", # TODO
292
- "C , p <char>" => "buf.paste(BEFORE,<char>)", # TODO
293
-
294
- "C ctrl-c" => "buf.comment_line()",
295
- "C ctrl-x" => "buf.comment_line(:uncomment)",
296
-
297
- # 'C 0($next_command_count==nil)'=> 'jump_to_beginning_of_line',
298
-
299
- # Visual mode only:
300
- "V esc" => "buf.end_visual_mode",
301
- "V ctrl!" => "buf.end_visual_mode",
302
- "V y" => "buf.copy_active_selection(:foo)",
303
- "V g U" => "buf.transform_selection(:upcase)",
304
- "V g u" => "buf.transform_selection(:downcase)",
305
- "V g c" => "buf.transform_selection(:capitalize)",
306
- "V g s" => "buf.transform_selection(:swapcase)",
307
- "V g r" => "buf.transform_selection(:reverse)",
308
-
309
- "V x" => "buf.delete(SELECTION)",
310
- # "V ctrl-c" => "buf.comment_selection",
311
- "V ctrl-x" => "buf.comment_selection(:uncomment)",
312
-
313
- "CI ctrl-v" => "buf.paste(BEFORE)",
314
- "CI backspace" => "buf.delete(BACKWARD_CHAR)",
315
-
316
- # Marks
317
- "CV m <char>" => "buf.mark_current_position(<char>)",
318
- 'CV \' <char>' => "buf.jump_to_mark(<char>)",
319
- # "CV ''" =>'jump_to_mark(NEXT_MARK)', #TODO
320
-
321
- "C i" => "$kbd.set_mode(:insert)",
322
- "C ctrl!" => "$kbd.set_mode(:insert)",
323
-
324
- # Macros
325
- # (experimental, may not work correctly)
326
- # "C q a" => '$macro.start_recording("a")',
327
- "VC q <char>" => "$macro.start_recording(<char>)",
328
- "VC q($macro.is_recording==true) " => "$macro.end_recording", # TODO
329
- # 'C q'=> '$macro.end_recording', #TODO
330
- "C q v" => "$macro.end_recording",
331
- # 'C v'=> '$macro.end_recording',
332
- # "C M" => '$macro.run_last_macro',
333
- "C @ <char>" => "$macro.run_macro(<char>)",
334
- "C , m S" => '$macro.save_macro("a")',
335
- "C , m s" => "$macro.save",
336
- "C , t r" => "run_tests()",
337
-
338
- "C ." => "repeat_last_action", # TODO
339
- "VC ;" => "repeat_last_find",
340
- "CV ctrl-q" => "_quit",
341
- "CV , R" => "restart_application",
342
- "I ctrl!" => "$kbd.set_mode(:command)",
343
- "C shift!" => "buf.save",
344
- "I <char>" => "buf.insert_txt(<char>)",
345
- "I esc" => "$kbd.set_mode(:command)",
346
-
347
- "I ctrl-d" => "buf.delete2(:to_word_end)",
348
-
349
- # INSERT MODE: Moving
350
- "I ctrl-a" => "buf.jump(BEGINNING_OF_LINE)",
351
- "I ctrl-b" => "buf.move(BACKWARD_CHAR)",
352
- "I ctrl-f" => "buf.move(FORWARD_CHAR)",
353
- "I ctrl-n" => "buf.move(FORWARD_LINE)",
354
- "I ctrl-p" => "buf.move(BACKWARD_LINE)",
355
- "I ctrl-e" => "buf.jump(END_OF_LINE)", # context: mode:I, buttons down: {C}
356
- "I alt-f" => "buf.jump_word(FORWARD,WORD_START)",
357
- "I alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
358
-
359
- "I tab" => 'buf.insert_txt(" ")',
360
- "I space" => 'buf.insert_txt(" ")',
361
- # "I return" => 'buf.insert_new_line()',
362
- }
363
-
364
- # default_keys.each { |key, value|
365
- # bindkey(key, value)
366
- # }