vimamsa 0.1.13 → 0.1.15
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 +12 -0
- data/lib/vimamsa/ack.rb +3 -4
- data/lib/vimamsa/actions.rb +1 -2
- data/lib/vimamsa/audio.rb +25 -1
- data/lib/vimamsa/buffer.rb +116 -591
- data/lib/vimamsa/buffer_changetext.rb +272 -0
- data/lib/vimamsa/buffer_cursor.rb +303 -0
- data/lib/vimamsa/buffer_list.rb +137 -133
- data/lib/vimamsa/buffer_manager.rb +15 -15
- data/lib/vimamsa/clipboard.rb +36 -0
- data/lib/vimamsa/conf.rb +136 -5
- data/lib/vimamsa/constants.rb +0 -10
- data/lib/vimamsa/debug.rb +9 -8
- data/lib/vimamsa/editor.rb +57 -84
- data/lib/vimamsa/encrypt.rb +6 -11
- data/lib/vimamsa/file_history.rb +0 -8
- data/lib/vimamsa/file_manager.rb +142 -10
- data/lib/vimamsa/gui.rb +106 -85
- data/lib/vimamsa/gui_dialog.rb +113 -0
- data/lib/vimamsa/gui_menu.rb +5 -1
- data/lib/vimamsa/gui_sourceview.rb +46 -29
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +141 -0
- data/lib/vimamsa/gui_text.rb +49 -0
- data/lib/vimamsa/hyper_plain_text.rb +19 -5
- data/lib/vimamsa/key_actions.rb +41 -202
- data/lib/vimamsa/key_binding_tree.rb +129 -41
- data/lib/vimamsa/key_bindings_vimlike.rb +58 -48
- data/lib/vimamsa/langservp.rb +23 -3
- data/lib/vimamsa/macro.rb +35 -25
- data/lib/vimamsa/main.rb +7 -10
- data/lib/vimamsa/rbvma.rb +13 -11
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +106 -160
- data/lib/vimamsa/terminal.rb +34 -0
- data/lib/vimamsa/tests.rb +122 -0
- data/lib/vimamsa/util.rb +43 -4
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +5 -2
- metadata +59 -9
- /data/lib/vimamsa/{form_generator.rb → gui_form_generator.rb} +0 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
# require "trie"
|
2
|
+
require "rambling-trie"
|
3
|
+
|
4
|
+
class Autocomplete
|
5
|
+
@@trie = Rambling::Trie.create
|
6
|
+
|
7
|
+
def self.init
|
8
|
+
vma.hook.register(:file_saved, self.method("update_index"))
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.update_index(bu)
|
12
|
+
debug "self.update_index", 2
|
13
|
+
add_words bu.scan_all_words
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.update_dict
|
17
|
+
for bu in vma.buffers.list
|
18
|
+
for w in bu.scan_all_words
|
19
|
+
trie << w
|
20
|
+
end
|
21
|
+
end
|
22
|
+
@@trie = trie
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.add_words(words)
|
26
|
+
for w in words
|
27
|
+
@@trie << w
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.word_list
|
32
|
+
return @@dict.keys
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.matching_words(beginning)
|
36
|
+
return @@trie.scan(beginning)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class VSourceView < GtkSource::View
|
41
|
+
def hide_completions
|
42
|
+
if @acwin.class == Gtk::Popover
|
43
|
+
@acwin.hide
|
44
|
+
end
|
45
|
+
@autocp_active = false
|
46
|
+
end
|
47
|
+
|
48
|
+
def autocp_select
|
49
|
+
return if !@autocp_active
|
50
|
+
bufo.complete_current_word(@cpl_list[@autocp_selected])
|
51
|
+
autocp_exit
|
52
|
+
end
|
53
|
+
|
54
|
+
def autocp_select_previous
|
55
|
+
return if @autocp_selected <= 0
|
56
|
+
autocp_hilight(@autocp_selected)
|
57
|
+
autocp_unhilight(@autocp_selected)
|
58
|
+
@autocp_selected -= 1
|
59
|
+
autocp_hilight(@autocp_selected)
|
60
|
+
end
|
61
|
+
|
62
|
+
def autocp_hilight(id)
|
63
|
+
l = @autocp_items[id]
|
64
|
+
l.set_text("<span foreground='#00ff00' weight='ultrabold'>#{cpl_list[id]}</span>")
|
65
|
+
l.use_markup = true
|
66
|
+
end
|
67
|
+
|
68
|
+
def autocp_unhilight(id)
|
69
|
+
l = @autocp_items[id]
|
70
|
+
l.set_text("<span>#{cpl_list[id]}</span>")
|
71
|
+
l.use_markup = true
|
72
|
+
end
|
73
|
+
|
74
|
+
def autocp_select_next
|
75
|
+
return if @autocp_selected >= cpl_list.size - 1
|
76
|
+
debug "autocp_select_next", 2
|
77
|
+
autocp_unhilight(@autocp_selected)
|
78
|
+
@autocp_selected += 1
|
79
|
+
autocp_hilight(@autocp_selected)
|
80
|
+
end
|
81
|
+
|
82
|
+
def autocp_exit
|
83
|
+
@autocp_items = []
|
84
|
+
@autocp_active = true
|
85
|
+
hide_completions
|
86
|
+
end
|
87
|
+
|
88
|
+
def try_autocomplete
|
89
|
+
end
|
90
|
+
|
91
|
+
def show_completions
|
92
|
+
hide_completions
|
93
|
+
bu = vma.buf
|
94
|
+
(w, range) = bu.get_word_in_pos(bu.pos - 1, boundary: :word)
|
95
|
+
debug [w, range].to_s, 2
|
96
|
+
matches = Autocomplete.matching_words w
|
97
|
+
return if matches.empty?
|
98
|
+
@autocp_active = true
|
99
|
+
@cpl_list = cpl_list = matches
|
100
|
+
win = Gtk::Popover.new()
|
101
|
+
win.parent = self
|
102
|
+
vbox = Gtk::Grid.new()
|
103
|
+
win.set_child(vbox)
|
104
|
+
|
105
|
+
i = 0
|
106
|
+
@autocp_items = []
|
107
|
+
@autocp_selected = 0
|
108
|
+
for x in cpl_list
|
109
|
+
l = Gtk::Label.new(x)
|
110
|
+
@autocp_items << l
|
111
|
+
# numbers: left, top, width, height
|
112
|
+
vbox.attach(l, 0, i, 1, 1)
|
113
|
+
i += 1
|
114
|
+
end
|
115
|
+
autocp_hilight(0)
|
116
|
+
(x, y) = cur_pos_xy
|
117
|
+
rec = Gdk::Rectangle.new(x, y + 8, 10, 10)
|
118
|
+
win.has_arrow = false
|
119
|
+
win.set_pointing_to(rec)
|
120
|
+
win.autohide = false
|
121
|
+
win.popup
|
122
|
+
gui_remove_controllers(win)
|
123
|
+
@acwin = win
|
124
|
+
end
|
125
|
+
|
126
|
+
def start_autocomplete
|
127
|
+
return
|
128
|
+
# Roughly following these examples:
|
129
|
+
# https://stackoverflow.com/questions/52359721/howto-maintain-gtksourcecompletion-when-changing-buffers-in-a-gtksourceview
|
130
|
+
# and gedit-plugins-41.0/plugins/wordcompletion/gedit-word-completion-plugin.c
|
131
|
+
# .. but it doesn't work. So implementing using Popover.
|
132
|
+
# Keeping this for reference
|
133
|
+
|
134
|
+
cp = self.completion
|
135
|
+
prov = GtkSource::CompletionWords.new("Autocomplete") # (name,icon)
|
136
|
+
prov.register(self.buffer)
|
137
|
+
cp.add_provider(prov)
|
138
|
+
pp prov
|
139
|
+
self.show_completion
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Gui
|
2
|
+
def self.hilight_range(bf, r, color: "#aa0000ff", weight: nil, tag: nil)
|
3
|
+
vbuf = bf.view.buffer
|
4
|
+
|
5
|
+
if tag.nil?
|
6
|
+
tag = vma.gui.view.buffer.create_tag
|
7
|
+
tag.weight = weight if !weight.nil?
|
8
|
+
tag.foreground = color
|
9
|
+
end
|
10
|
+
|
11
|
+
itr = vbuf.get_iter_at(:offset => r.begin)
|
12
|
+
itr2 = vbuf.get_iter_at(:offset => r.last)
|
13
|
+
vbuf.apply_tag(tag, itr, itr2)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.highlight_match(bf, str, color: "#aa0000ff", weight: 650)
|
17
|
+
r = Regexp.new(Regexp.escape(str), Regexp::IGNORECASE)
|
18
|
+
tag = vma.gui.view.buffer.create_tag
|
19
|
+
tag.weight = weight
|
20
|
+
tag.foreground = color
|
21
|
+
ind = scan_indexes(bf, r)
|
22
|
+
ind.each { |x|
|
23
|
+
r = x..(x + str.size)
|
24
|
+
self.hilight_range(bf, r, tag: tag)
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.highlight_match_old(bf, str, color: "#aa0000ff")
|
29
|
+
vbuf = bf.view.buffer
|
30
|
+
r = Regexp.new(Regexp.escape(str), Regexp::IGNORECASE)
|
31
|
+
|
32
|
+
hlparts = []
|
33
|
+
|
34
|
+
tt = vma.gui.view.buffer.tag_table.lookup("highlight_match_tag")
|
35
|
+
if tt.nil?
|
36
|
+
tt = vma.gui.view.buffer.create_tag("highlight_match_tag")
|
37
|
+
end
|
38
|
+
|
39
|
+
tt.weight = 650
|
40
|
+
tt.foreground = color
|
41
|
+
|
42
|
+
ind = scan_indexes(bf, r)
|
43
|
+
ind.each { |x|
|
44
|
+
itr = vbuf.get_iter_at(:offset => x)
|
45
|
+
itr2 = vbuf.get_iter_at(:offset => x + str.size)
|
46
|
+
vbuf.apply_tag(tt, itr, itr2)
|
47
|
+
}
|
48
|
+
end
|
49
|
+
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.
|
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
|
@@ -36,12 +39,23 @@ def hpt_check_cur_word(w)
|
|
36
39
|
# return true
|
37
40
|
else
|
38
41
|
message "File not found: #{fpfx}"
|
42
|
+
newfn = fcands[0]
|
43
|
+
if File.extname(newfn) == ""
|
44
|
+
newfn = fcands[1]
|
45
|
+
end
|
46
|
+
Gui.confirm("File does not exist. Create a new file? \r #{newfn}",
|
47
|
+
proc{hpt_create_new_file(newfn)})
|
48
|
+
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|
42
52
|
return nil
|
43
53
|
end
|
44
54
|
|
55
|
+
def hpt_create_new_file(fn)
|
56
|
+
create_new_file(fn)
|
57
|
+
end
|
58
|
+
|
45
59
|
def translate_path(fn, bf)
|
46
60
|
if File.exist?(fn)
|
47
61
|
outfn = fn
|
data/lib/vimamsa/key_actions.rb
CHANGED
@@ -28,13 +28,18 @@ def is_visual_mode()
|
|
28
28
|
return 0
|
29
29
|
end
|
30
30
|
|
31
|
+
reg_act(:command_to_buf, proc { command_to_buf }, "Execute command, output to buffer")
|
32
|
+
|
31
33
|
reg_act(:lsp_debug, proc { vma.buf.lsp_get_def }, "LSP get definition")
|
32
34
|
reg_act(:lsp_jump_to_definition, proc { vma.buf.lsp_jump_to_def }, "LSP jump to definition")
|
33
35
|
|
34
|
-
reg_act(:enable_debug, proc {
|
35
|
-
reg_act(:disable_debug, proc {
|
36
|
+
reg_act(:enable_debug, proc { cnf.debug = true }, "Enable debug")
|
37
|
+
reg_act(:disable_debug, proc { cnf.debug = false }, "Disable debug")
|
36
38
|
|
37
39
|
reg_act(:easy_jump, proc { EasyJump.start }, "Easy jump")
|
40
|
+
reg_act(:gui_ensure_cursor_visible, proc { vma.gui.view.ensure_cursor_visible }, "Scroll to current cursor position")
|
41
|
+
reg_act(:gui_refresh_cursor, proc { vma.buf.refresh_cursor }, "Refresh cursor")
|
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 {
|
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 }, "")
|
@@ -57,7 +62,7 @@ reg_act(:put_file_ref_to_clipboard, proc { buf.put_file_ref_to_clipboard }, "Put
|
|
57
62
|
reg_act(:encrypt_file, proc { encrypt_cur_buffer }, "Set current file to encrypt on save")
|
58
63
|
reg_act(:set_unencrypted, proc { buf.set_unencrypted }, "Set current file to save unencrypted")
|
59
64
|
reg_act(:set_executable, proc { buf.set_executable }, "Set current file permissions to executable")
|
60
|
-
reg_act(:close_all_buffers, proc { bufs.close_all_buffers() }, "Close all buffers")
|
65
|
+
# reg_act(:close_all_buffers, proc { bufs.close_all_buffers() }, "Close all buffers")
|
61
66
|
reg_act(:close_current_buffer, proc { bufs.close_current_buffer(true) }, "Close current buffer")
|
62
67
|
reg_act(:comment_selection, proc { buf.comment_selection }, "")
|
63
68
|
reg_act(:delete_char_forward, proc { buf.delete(CURRENT_CHAR_FORWARD) }, "Delete char forward", { :group => [:edit, :basic] })
|
@@ -89,13 +94,23 @@ reg_act :update_file_index, proc { FileFinder.update_index }, "Update file index
|
|
89
94
|
reg_act :delete_to_word_end, proc { buf.delete2(:to_word_end) }, "Delete to file end", { :group => [:edit, :basic] }
|
90
95
|
reg_act :delete_to_next_word_start, proc { buf.delete2(:to_next_word) }, "Delete to start of next word", { :group => [:edit, :basic] }
|
91
96
|
reg_act :delete_to_line_start, proc { buf.delete2(:to_line_start) }, "Delete to line start", { :group => [:edit, :basic] }
|
92
|
-
|
97
|
+
|
98
|
+
reg_act :start_browse_mode, proc {
|
99
|
+
vma.kbd.set_mode(:browse)
|
100
|
+
bufs.reset_navigation
|
101
|
+
}, "Start browse mode"
|
102
|
+
reg_act :kbd_dump_state, proc { vma.kbd.dump_state }, "Dump keyboard tree state"
|
103
|
+
|
93
104
|
reg_act :exit_browse_mode, proc {
|
94
|
-
bufs.add_current_buf_to_history
|
105
|
+
bufs.add_current_buf_to_history
|
106
|
+
# Load previously saved buffer specific mode stack
|
107
|
+
buf.restore_kbd_mode
|
95
108
|
}, "Exit browse mode"
|
96
109
|
|
97
|
-
reg_act :page_down, proc { page_down }, "Page down", :group => [:move, :basic]
|
98
|
-
reg_act :
|
110
|
+
# reg_act :page_down, proc { page_down }, "Page down", :group => [:move, :basic]
|
111
|
+
reg_act :page_down, proc { vma.gui.page_down }, "Page down", :group => [:move, :basic]
|
112
|
+
|
113
|
+
reg_act :page_up, proc { vma.gui.page_up }, "Page up", :group => [:move, :basic]
|
99
114
|
reg_act :jump_to_start_of_buffer, proc { buf.jump(START_OF_BUFFER) }, "Jump to start of buffer"
|
100
115
|
reg_act :jump_to_end_of_buffer, proc { buf.jump(END_OF_BUFFER) }, "Jump to end of buffer"
|
101
116
|
reg_act(:auto_indent_buffer, proc { buf.indent }, "Auto format buffer")
|
@@ -104,10 +119,8 @@ reg_act(:execute_current_line_in_terminal_autoclose, proc { buf.execute_current_
|
|
104
119
|
reg_act(:show_images, proc { hpt_scan_images() }, "Show images inserted with ⟦img:file.png⟧ syntax")
|
105
120
|
reg_act(:delete_current_file, proc { bufs.delete_current_buffer() }, "Delete current file")
|
106
121
|
|
107
|
-
|
108
122
|
reg_act(:audio_stop, proc { Audio.stop }, "Stop audio playback")
|
109
123
|
|
110
|
-
|
111
124
|
act_list = {
|
112
125
|
# File handling
|
113
126
|
:buf_save => { :proc => proc { buf.save },
|
@@ -159,7 +172,7 @@ act_list = {
|
|
159
172
|
:toggle_active_window => { :proc => proc { vma.gui.toggle_active_window },
|
160
173
|
:desc => "Toggle active window", :group => :search },
|
161
174
|
|
162
|
-
:toggle_two_column => { :proc => proc { vma.gui.
|
175
|
+
:toggle_two_column => { :proc => proc { vma.gui.toggle_two_column },
|
163
176
|
:desc => "Set two column mode", :group => :search },
|
164
177
|
|
165
178
|
:content_search => { :proc => proc { FileContentSearch.start_gui },
|
@@ -168,199 +181,25 @@ act_list = {
|
|
168
181
|
:quit => { :proc => proc { _quit },
|
169
182
|
:desc => "Quit", :group => :app },
|
170
183
|
|
171
|
-
}
|
184
|
+
:run_tests => { :proc => proc { run_tests },
|
185
|
+
:desc => "Run tests" },
|
172
186
|
|
173
|
-
|
174
|
-
|
175
|
-
end
|
187
|
+
:debug_buf_hex => { :proc => proc { puts "SHA256: " + (Digest::SHA2.hexdigest vma.buf.to_s) },
|
188
|
+
:desc => "Output SHA256 hex digest of curent buffer" },
|
176
189
|
|
177
|
-
|
190
|
+
:start_autocomplete => { :proc => proc { vma.buf.view.start_autocomplete },
|
191
|
+
:desc => "Start autocomplete" },
|
192
|
+
|
193
|
+
:show_autocomplete => { :proc => proc {
|
194
|
+
# vma.buf.view.signal_emit("show-completion")
|
195
|
+
# vma.buf.view.show_completion
|
196
|
+
vma.buf.view.show_completions
|
197
|
+
},
|
198
|
+
:desc => "Show autocomplete" },
|
199
|
+
|
178
200
|
|
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
201
|
}
|
363
202
|
|
364
|
-
|
365
|
-
|
366
|
-
|
203
|
+
for k, v in act_list
|
204
|
+
reg_act(k, v[:proc], v[:desc])
|
205
|
+
end
|