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.
@@ -34,6 +34,7 @@ class VSourceView < GtkSource::View
34
34
  # puts "drag-data-received"
35
35
  # puts
36
36
  # if data.uris.size >= 1
37
+
37
38
  # imgpath = CGI.unescape(data.uris[0])
38
39
  # m = imgpath.match(/^file:\/\/(.*)/)
39
40
  # if m
@@ -46,8 +47,14 @@ class VSourceView < GtkSource::View
46
47
 
47
48
  # Mainly after page-up or page-down
48
49
  signal_connect("move-cursor") do |widget, event|
49
- debug("MOVE-CURSOR", 2)
50
- $update_cursor = true
50
+ if event.name == "GTK_MOVEMENT_PAGES" and (last_action == "page_up" or last_action == "page_down")
51
+ # Ripl.start :binding => binding
52
+
53
+ debug("MOVE-CURSOR", 2)
54
+ # $update_cursor = true
55
+ handle_scrolling()
56
+ end
57
+
51
58
  # handle_scrolling()
52
59
  # curpos = buffer.cursor_position
53
60
  # debug "MOVE CURSOR (sig): #{curpos}"
@@ -110,47 +117,116 @@ class VSourceView < GtkSource::View
110
117
  end
111
118
 
112
119
  def register_signals()
120
+ check_controllers
113
121
 
114
- #TODO: Doesn't seem to catch "move-cursor" signal since upgrade to gtk4
115
- # self.signal_connect("move-cursor") do |widget, event|
116
- # $update_cursor = true
117
- # false
118
- # end
122
+ # Implement mouse selections using @cnt_mo and @cnt_drag
123
+ @cnt_mo = Gtk::EventControllerMotion.new
124
+ self.add_controller(@cnt_mo)
125
+ @cnt_mo.signal_connect "motion" do |gesture, x, y|
126
+ if !@range_start.nil? and !x.nil? and !y.nil? and buf.visual_mode?
127
+ i = coord_to_iter(x, y, true)
128
+ @bufo.set_pos(i) if !i.nil? and @last_iter != i
129
+ @last_iter = i
130
+ end
131
+ end
132
+
133
+ @last_coord = nil
134
+ @cnt_drag = Gtk::GestureDrag.new
135
+ self.add_controller(@cnt_drag)
136
+ @cnt_drag.signal_connect "drag-begin" do |gesture, x, y|
137
+ debug "drag-begin", 2
138
+ i = coord_to_iter(x, y, true)
139
+ pp i
140
+ @range_start = i
141
+ if !buf.visual_mode?
142
+ buf.start_visual_mode
143
+ end
144
+ end
145
+
146
+ @cnt_drag.signal_connect "drag-end" do |gesture, offsetx, offsety|
147
+ debug "drag-end", 2
148
+
149
+ # Not enough drag
150
+ if offsetx.abs < 5 and offsety.abs < 5
151
+ buf.end_visual_mode
152
+ end
153
+ @range_start = nil
154
+ end
119
155
 
120
- check_controllers
121
156
  click = Gtk::GestureClick.new
122
157
  click.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
123
158
  self.add_controller(click)
124
159
  # Detect mouse click
125
160
  @click = click
161
+
162
+ @range_start = nil
126
163
  click.signal_connect "pressed" do |gesture, n_press, x, y, z|
127
- debug "SourceView, GestureClick x=#{x} y=#{y}"
128
- pp visible_rect
129
- winw = width
130
- view_width = visible_rect.width
131
- gutter_width = winw - view_width
164
+ debug "SourceView, GestureClick released x=#{x} y=#{y}"
165
+
166
+ if buf.visual_mode?
167
+ buf.end_visual_mode
168
+ end
132
169
 
133
170
  xloc = (x - gutter_width).to_i
134
171
  yloc = (y + visible_rect.y).to_i
135
172
  debug "xloc=#{xloc} yloc=#{yloc}"
136
173
 
174
+ i = coord_to_iter(xloc, yloc)
175
+ # @range_start = i
176
+
137
177
  # This needs to happen after xloc calculation, otherwise xloc gets a wrong value (around 200 bigger)
138
178
  if vma.gui.current_view != self
139
179
  vma.gui.set_current_view(self)
140
180
  end
141
181
 
142
- i = get_iter_at_location(xloc, yloc)
143
- if !i.nil?
144
- @bufo.set_pos(i.offset)
145
- else
146
- debug "iter nil"
147
- #TODO: find correct line position some other way
182
+ @bufo.set_pos(i) if !i.nil?
183
+ true
184
+ end
185
+
186
+ click.signal_connect "released" do |gesture, n_press, x, y, z|
187
+ debug "SourceView, GestureClick released x=#{x} y=#{y}"
188
+
189
+ xloc = (x - gutter_width).to_i
190
+ yloc = (y + visible_rect.y).to_i
191
+ debug "xloc=#{xloc} yloc=#{yloc}"
192
+
193
+ # This needs to happen after xloc calculation, otherwise xloc gets a wrong value (around 200 bigger)
194
+ if vma.gui.current_view != self
195
+ vma.gui.set_current_view(self)
148
196
  end
149
197
 
198
+ i = coord_to_iter(xloc, yloc)
199
+
200
+ # if i != @range_start
201
+ # debug "RANGE #{[@range_start, i]}", 2
202
+ # end
203
+
204
+ @bufo.set_pos(i) if !i.nil?
205
+ # @range_start = nil
150
206
  true
151
207
  end
152
208
  end
153
209
 
210
+ def coord_to_iter(xloc, yloc, transform_coord = false)
211
+ if transform_coord
212
+ xloc = (xloc - gutter_width).to_i
213
+ yloc = (yloc + visible_rect.y).to_i
214
+ end
215
+
216
+ # Try to get exact character position
217
+ i = get_iter_at_location(xloc, yloc)
218
+
219
+ # If doesn't work, at least get the start of correct line
220
+ # TODO: sometimes end of line is better choice
221
+ if i.nil?
222
+ r = get_line_at_y(yloc)
223
+ i = r[0] if !r.nil?
224
+ end
225
+
226
+ return i.offset if !i.nil?
227
+ return nil
228
+ end
229
+
154
230
  def handle_scrolling()
155
231
  delete_cursorchar
156
232
  # curpos = buffer.cursor_position
@@ -158,18 +234,13 @@ class VSourceView < GtkSource::View
158
234
  return nil if vma.gui.nil?
159
235
  return nil if @bufo.nil?
160
236
  vma.gui.run_after_scrolling proc {
237
+ debug "START UPDATE POS AFTER SCROLLING", 2
161
238
  delete_cursorchar
162
239
  bc = window_to_buffer_coords(Gtk::TextWindowType::WIDGET, gutter_width + 2, 60)
163
240
  if !bc.nil?
164
- # Try to get exact character position
165
- i = get_iter_at_location(bc[0], bc[1])
166
- if i.nil?
167
- # If doesn't work, at least get the start of correct line
168
- i = get_line_at_y(bc[1])
169
- i = i[0]
170
- end
241
+ i = coord_to_iter(bc[0], bc[1])
171
242
  if !i.nil?
172
- @bufo.set_pos(i.offset)
243
+ @bufo.set_pos(i)
173
244
  end
174
245
  end
175
246
  $update_cursor = false
@@ -220,6 +291,7 @@ class VSourceView < GtkSource::View
220
291
  keyval_trans[Gdk::Keyval::KEY_Shift_L] = "shift"
221
292
  keyval_trans[Gdk::Keyval::KEY_Shift_R] = "shift"
222
293
  keyval_trans[Gdk::Keyval::KEY_Tab] = "tab"
294
+ keyval_trans[Gdk::Keyval::GDK_KEY_ISO_Left_Tab] = "tab"
223
295
 
224
296
  key_trans = {}
225
297
  key_trans["\e"] = "esc"
@@ -240,10 +312,12 @@ class VSourceView < GtkSource::View
240
312
  key_str_parts.delete_at(0)
241
313
  end
242
314
 
243
- if key_str_parts[0] == "shift" and key_str_parts[1].class == String
244
- #"shift-P" to just "P"
245
- # key_str_parts.delete_at(0) if key_str_parts[1].match(/^[[:upper:]]$/)
246
- 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
247
321
  end
248
322
 
249
323
  key_str = key_str_parts.join("-")
@@ -342,8 +416,6 @@ class VSourceView < GtkSource::View
342
416
  itr2 = buffer.get_iter_at(:offset => pos + 1)
343
417
  buffer.place_cursor(itr)
344
418
 
345
- # $view.signal_emit("extend-selection", Gtk::MovementStep.new(:PAGES), -1, false)
346
-
347
419
  within_margin = 0.075 #margin as a [0.0,0.5) fraction of screen size
348
420
  use_align = false
349
421
  xalign = 0.5 #0.0=top 1.0=bottom, 0.5=center
@@ -358,22 +430,15 @@ class VSourceView < GtkSource::View
358
430
  $idle_scroll_to_mark = true
359
431
  ensure_cursor_visible
360
432
 
361
- # scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
362
-
363
- # $view.signal_emit("extend-selection", Gtk::TextExtendSelection.new, itr,itr,itr2)
364
433
  draw_cursor
365
434
 
366
435
  return true
367
436
  end
368
437
 
369
438
  def cursor_visible_idle_func
439
+ return false
370
440
  debug "cursor_visible_idle_func"
371
441
  # From https://picheta.me/articles/2013/08/gtk-plus--a-method-to-guarantee-scrolling.html
372
- # vr = visible_rect
373
-
374
- # b = $view.buffer
375
- # iter = buffer.get_iter_at(:offset => buffer.cursor_position)
376
- # iterxy = get_iter_location(iter)
377
442
 
378
443
  # This is not the current buffer
379
444
  return false if vma.gui.view != self
@@ -417,16 +482,13 @@ class VSourceView < GtkSource::View
417
482
  end
418
483
 
419
484
  def ensure_cursor_visible
420
- return #TODO:gtk4
485
+ # return
421
486
  debug "@idle_func_running=#{@idle_func_running}"
422
487
  return if @idle_func_running
423
488
  if is_cursor_visible == false
424
489
  @idle_func_running = true
425
490
  debug "Starting idle func"
426
- Thread.new {
427
- sleep 0.01
428
- GLib::Idle.add(proc { cursor_visible_idle_func })
429
- }
491
+ GLib::Idle.add(proc { cursor_visible_idle_func })
430
492
  end
431
493
  end
432
494
 
@@ -477,9 +539,9 @@ class VSourceView < GtkSource::View
477
539
  end
478
540
  # elsif @bufo.visual_mode?
479
541
  elsif ctype == :visual
480
- debug "VISUAL MODE"
542
+ # debug "VISUAL MODE"
481
543
  (_start, _end) = @bufo.get_visual_mode_range2
482
- debug "#{_start}, #{_end}"
544
+ # debug "#{_start}, #{_end}"
483
545
  itr = buffer.get_iter_at(:offset => _start)
484
546
  itr2 = buffer.get_iter_at(:offset => _end + 1)
485
547
  # Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
@@ -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,8 +1,8 @@
1
1
  def hpt_check_cur_word(w)
2
2
  debug "check_cur_word(w)"
3
- m = w.match(/⟦(.*)⟧/)
3
+ m = w.match(/⟦((audio|img):)?(.*)⟧/)
4
4
  if m
5
- fpfx = m[1]
5
+ fpfx = m[3]
6
6
  if vma.buf.fname
7
7
  dn = File.dirname(vma.buf.fname)
8
8
 
@@ -15,16 +15,26 @@ def hpt_check_cur_word(w)
15
15
  fcands << File.expand_path("#{fpfx}.txt")
16
16
 
17
17
  fn = nil
18
+
18
19
  for fc in fcands
19
- if File.exists?(fc)
20
+ if File.exist?(fc)
20
21
  fn = fc
21
22
  break
22
23
  end
23
24
  end
24
25
 
25
26
  if fn
26
- message "HPT opening file #{fn}"
27
- return fn
27
+ if m[2] == "audio"
28
+ # Thread.new { Audio.play(fn) }
29
+ Audio.play(fn)
30
+ else
31
+ if !file_is_text_file(fn)
32
+ message "Not text file #{fn}"
33
+ return nil
34
+ end
35
+ message "HPT opening file #{fn}"
36
+ return fn
37
+ end
28
38
  # open_existing_file(fn)
29
39
  # return true
30
40
  else
@@ -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,6 +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
 
114
+ reg_act(:audio_stop, proc { Audio.stop }, "Stop audio playback")
115
+
107
116
  act_list = {
108
117
  # File handling
109
118
  :buf_save => { :proc => proc { buf.save },
@@ -164,199 +173,14 @@ act_list = {
164
173
  :quit => { :proc => proc { _quit },
165
174
  :desc => "Quit", :group => :app },
166
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
+
167
182
  }
168
183
 
169
184
  for k, v in act_list
170
185
  reg_act(k, v[:proc], v[:desc])
171
186
  end
172
-
173
- act_list_todo = {
174
-
175
- # Buffer handling
176
- # : => {proc => proc {bufs.switch}, :desc => "", :group => :},
177
- :buf_switch_to_last => { :proc => proc { bufs.switch_to_last_buf },
178
- :desc => "", :group => :file },
179
- # 'C , s'=> 'gui_select_buffer',
180
- :buf_revert => { :proc => proc { buf.revert },
181
- :desc => "Reload/revert file from disk", :group => :file },
182
- :buf_close => { :proc => proc { bufs.close_current_buffer },
183
- :desc => "Close current file", :group => :file },
184
- #"C , b" => '$kbd.set_mode("S");gui_select_buffer',
185
-
186
- # MOVING
187
- # 'VC h' => 'buf.move(BACKWARD_CHAR)',
188
- :m_forward_char => { :proc => proc { buf.move(FORWARD_CHAR) },
189
- :desc => "Move cursor one char forward",
190
- :group => :move },
191
- # "VC j" => "buf.move(FORWARD_LINE)",
192
- # "VC k" => "buf.move(BACKWARD_LINE)",
193
-
194
- "VC pagedown" => "page_down",
195
- "VC pageup" => "page_up",
196
-
197
- "VCI left" => "buf.move(BACKWARD_CHAR)",
198
- "VCI right" => "buf.move(FORWARD_CHAR)",
199
- "VCI down" => "buf.move(FORWARD_LINE)",
200
- "VCI up" => "buf.move(BACKWARD_LINE)",
201
-
202
- "VC w" => "buf.jump_word(FORWARD,WORD_START)",
203
- "VC b" => "buf.jump_word(BACKWARD,WORD_START)",
204
- "VC e" => "buf.jump_word(FORWARD,WORD_END)",
205
- # 'C '=> 'buf.jump_word(BACKWARD,END)',#TODO
206
- "VC f <char>" => "buf.jump_to_next_instance_of_char(<char>)",
207
- "VC F <char>" => "buf.jump_to_next_instance_of_char(<char>,BACKWARD)",
208
- "VC f space" => "buf.jump_to_next_instance_of_char(' ')",
209
- "VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
210
-
211
- "VC /[1-9]/" => "set_next_command_count(<char>)",
212
- # 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
213
- # 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
214
- "VC ^" => "buf.jump(BEGINNING_OF_LINE)",
215
- "VC G($next_command_count!=nil)" => "buf.jump_to_line()",
216
- "VC 0($next_command_count!=nil)" => "set_next_command_count(<char>)",
217
- "VC 0($next_command_count==nil)" => "buf.jump(BEGINNING_OF_LINE)",
218
- # 'C 0'=> 'buf.jump(BEGINNING_OF_LINE)',
219
- "VC g g" => "buf.jump(START_OF_BUFFER)",
220
- "VC g ;" => "buf.jump_to_last_edit",
221
- "VC G" => "buf.jump(END_OF_BUFFER)",
222
- # 'VC z z' => 'center_on_current_line',
223
- "VC *" => "buf.jump_to_next_instance_of_word",
224
-
225
- # MINIBUFFER bindings
226
- "VC /" => "invoke_search",
227
- # 'VC :' => 'invoke_command', #TODO
228
- "C , e" => "invoke_command", # Currently eval
229
- "M enter" => "minibuffer_end()",
230
- # "M return" => "minibuffer_end()",
231
- "M esc" => "minibuffer_cancel()",
232
- "M backspace" => "minibuffer_delete()",
233
- "M <char>" => "minibuffer_new_char(<char>)",
234
- "M ctrl-v" => "$minibuffer.paste(BEFORE)",
235
-
236
- # READCHAR bindings
237
-
238
- "R <char>" => "readchar_new_char(<char>)",
239
-
240
- "C n" => "$search.jump_to_next()",
241
- "C N" => "$search.jump_to_previous()",
242
-
243
- # Debug
244
- "C , d r p" => "start_ripl",
245
- "C , D" => "debug_print_buffer",
246
- "C , c s" => "bufs.close_scrap_buffers",
247
- "C , d b" => "debug_print_buffer",
248
- "C , d c" => "debug_dump_clipboard",
249
- "C , d d" => "debug_dump_deltas",
250
- "VC O" => "buf.jump(END_OF_LINE)",
251
- "VC $" => "buf.jump(END_OF_LINE)",
252
-
253
- "C o" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");$kbd.set_mode(:insert)',
254
- "C X" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");',
255
- "C A" => "buf.jump(END_OF_LINE);$kbd.set_mode(:insert)",
256
- "C I" => "buf.jump(FIRST_NON_WHITESPACE);$kbd.set_mode(:insert)",
257
- "C a" => "buf.move(FORWARD_CHAR);$kbd.set_mode(:insert)",
258
- "C J" => "buf.join_lines()",
259
- "C u" => "buf.undo()",
260
-
261
- "C ^" => "buf.jump(BEGINNING_OF_LINE)",
262
- "C /[1-9]/" => "set_next_command_count(<char>)",
263
-
264
- # Command mode only:
265
- "C R" => "buf.redo()",
266
- "C v" => "buf.start_visual_mode",
267
- "C P" => "buf.paste(BEFORE)", # TODO: implement as replace for visual mode
268
- "C space <char>" => "buf.insert_txt(<char>)",
269
- "C space space" => "buf.insert_txt(' ')",
270
- "C y y" => "buf.copy_line",
271
- "C y O" => "buf.copy(:to_line_end)",
272
- "C y 0" => "buf.copy(:to_line_start)",
273
- "C y e" => "buf.copy(:to_word_end)", # TODO
274
- #### Deleting
275
- "C x" => "buf.delete(CURRENT_CHAR_FORWARD)",
276
- # 'C d k'=> 'delete_line(BACKWARD)', #TODO
277
- # 'C d j'=> 'delete_line(FORWARD)', #TODO
278
- # 'C d d'=> 'buf.delete_cur_line',
279
- "C d e" => "buf.delete2(:to_word_end)",
280
- "C d O" => "buf.delete2(:to_line_end)",
281
- "C d $" => "buf.delete2(:to_line_end)",
282
- # 'C d e'=> 'buf.delete_to_next_word_end',
283
- "C d <num> e" => "delete_next_word",
284
- "C r <char>" => "buf.replace_with_char(<char>)", # TODO
285
- "C , l b" => "load_buffer_list",
286
- "C , l l" => "save_buffer_list",
287
- "C , r <char>" => "set_register(<char>)", # TODO
288
- "C , p <char>" => "buf.paste(BEFORE,<char>)", # TODO
289
-
290
- "C ctrl-c" => "buf.comment_line()",
291
- "C ctrl-x" => "buf.comment_line(:uncomment)",
292
-
293
- # 'C 0($next_command_count==nil)'=> 'jump_to_beginning_of_line',
294
-
295
- # Visual mode only:
296
- "V esc" => "buf.end_visual_mode",
297
- "V ctrl!" => "buf.end_visual_mode",
298
- "V y" => "buf.copy_active_selection(:foo)",
299
- "V g U" => "buf.transform_selection(:upcase)",
300
- "V g u" => "buf.transform_selection(:downcase)",
301
- "V g c" => "buf.transform_selection(:capitalize)",
302
- "V g s" => "buf.transform_selection(:swapcase)",
303
- "V g r" => "buf.transform_selection(:reverse)",
304
-
305
- "V x" => "buf.delete(SELECTION)",
306
- # "V ctrl-c" => "buf.comment_selection",
307
- "V ctrl-x" => "buf.comment_selection(:uncomment)",
308
-
309
- "CI ctrl-v" => "buf.paste(BEFORE)",
310
- "CI backspace" => "buf.delete(BACKWARD_CHAR)",
311
-
312
- # Marks
313
- "CV m <char>" => "buf.mark_current_position(<char>)",
314
- 'CV \' <char>' => "buf.jump_to_mark(<char>)",
315
- # "CV ''" =>'jump_to_mark(NEXT_MARK)', #TODO
316
-
317
- "C i" => "$kbd.set_mode(:insert)",
318
- "C ctrl!" => "$kbd.set_mode(:insert)",
319
-
320
- # Macros
321
- # (experimental, may not work correctly)
322
- # "C q a" => '$macro.start_recording("a")',
323
- "VC q <char>" => "$macro.start_recording(<char>)",
324
- "VC q($macro.is_recording==true) " => "$macro.end_recording", # TODO
325
- # 'C q'=> '$macro.end_recording', #TODO
326
- "C q v" => "$macro.end_recording",
327
- # 'C v'=> '$macro.end_recording',
328
- # "C M" => '$macro.run_last_macro',
329
- "C @ <char>" => "$macro.run_macro(<char>)",
330
- "C , m S" => '$macro.save_macro("a")',
331
- "C , m s" => "$macro.save",
332
- "C , t r" => "run_tests()",
333
-
334
- "C ." => "repeat_last_action", # TODO
335
- "VC ;" => "repeat_last_find",
336
- "CV ctrl-q" => "_quit",
337
- "CV , R" => "restart_application",
338
- "I ctrl!" => "$kbd.set_mode(:command)",
339
- "C shift!" => "buf.save",
340
- "I <char>" => "buf.insert_txt(<char>)",
341
- "I esc" => "$kbd.set_mode(:command)",
342
-
343
- "I ctrl-d" => "buf.delete2(:to_word_end)",
344
-
345
- # INSERT MODE: Moving
346
- "I ctrl-a" => "buf.jump(BEGINNING_OF_LINE)",
347
- "I ctrl-b" => "buf.move(BACKWARD_CHAR)",
348
- "I ctrl-f" => "buf.move(FORWARD_CHAR)",
349
- "I ctrl-n" => "buf.move(FORWARD_LINE)",
350
- "I ctrl-p" => "buf.move(BACKWARD_LINE)",
351
- "I ctrl-e" => "buf.jump(END_OF_LINE)", # context: mode:I, buttons down: {C}
352
- "I alt-f" => "buf.jump_word(FORWARD,WORD_START)",
353
- "I alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
354
-
355
- "I tab" => 'buf.insert_txt(" ")',
356
- "I space" => 'buf.insert_txt(" ")',
357
- # "I return" => 'buf.insert_new_line()',
358
- }
359
-
360
- # default_keys.each { |key, value|
361
- # bindkey(key, value)
362
- # }