vimamsa 0.1.21 → 0.1.23
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/README.md +14 -8
- data/custom_example.rb +4 -1
- data/img/screenshot1.png +0 -0
- data/img/screenshot2.png +0 -0
- data/install.sh +4 -0
- data/lib/vimamsa/buffer.rb +129 -8
- data/lib/vimamsa/buffer_changetext.rb +19 -2
- data/lib/vimamsa/buffer_cursor.rb +10 -4
- data/lib/vimamsa/buffer_list.rb +13 -1
- data/lib/vimamsa/buffer_manager.rb +1 -1
- data/lib/vimamsa/conf.rb +3 -1
- data/lib/vimamsa/diff_buffer.rb +137 -0
- data/lib/vimamsa/editor.rb +104 -34
- data/lib/vimamsa/file_manager.rb +10 -3
- data/lib/vimamsa/gui.rb +123 -87
- data/lib/vimamsa/gui_dialog.rb +2 -0
- data/lib/vimamsa/gui_file_panel.rb +93 -0
- data/lib/vimamsa/gui_form_generator.rb +4 -2
- data/lib/vimamsa/gui_image.rb +2 -4
- data/lib/vimamsa/gui_menu.rb +12 -1
- data/lib/vimamsa/gui_select_window.rb +1 -0
- data/lib/vimamsa/gui_settings.rb +155 -0
- data/lib/vimamsa/gui_sourceview.rb +86 -47
- data/lib/vimamsa/key_actions.rb +58 -13
- data/lib/vimamsa/key_binding_tree.rb +228 -28
- data/lib/vimamsa/key_bindings_vimlike.rb +174 -148
- data/lib/vimamsa/main.rb +1 -0
- data/lib/vimamsa/rbvma.rb +3 -0
- data/lib/vimamsa/string_util.rb +56 -0
- data/lib/vimamsa/util.rb +27 -36
- data/lib/vimamsa/version.rb +1 -1
- metadata +9 -2
|
@@ -4,6 +4,7 @@ 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
6
|
vma.kbd.add_minor_mode("audio", :audio, :command)
|
|
7
|
+
vma.kbd.add_minor_mode("macro", :macro, :command)
|
|
7
8
|
vma.kbd.add_mode("B", :browse, :browse, scope: :editor)
|
|
8
9
|
vma.kbd.add_mode("X", :replace, :replace, name: "Replace")
|
|
9
10
|
vma.kbd.set_default_mode(:command)
|
|
@@ -40,114 +41,80 @@ def insert_move(op)
|
|
|
40
41
|
_insert_move(op)
|
|
41
42
|
end
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
44
|
+
add_keys "intro", {
|
|
45
|
+
"VCX up" => "buf.move(BACKWARD_LINE)",
|
|
46
|
+
"VCX down" => "buf.move(FORWARD_LINE)",
|
|
47
|
+
"VCX right" => "buf.move(FORWARD_CHAR)",
|
|
48
|
+
"VCX left" => "buf.move(BACKWARD_CHAR)",
|
|
49
|
+
"C , b" => :start_buf_manager,
|
|
50
|
+
"VC l" => "buf.move(FORWARD_CHAR)",
|
|
51
|
+
"VC , , s" => :search_actions,
|
|
52
|
+
"C , n b" => :buf_new,
|
|
53
|
+
"C y y" => :copy_cur_line,
|
|
54
|
+
"C P" => :paste_before_cursor,
|
|
55
|
+
"C p" => :paste_after_cursor,
|
|
56
|
+
"C v" => :start_visual_mode,
|
|
57
|
+
"C ctrl-r" => :redo,
|
|
58
|
+
"C u" => :undo,
|
|
59
|
+
"VC O" => :jump_end_of_line,
|
|
60
|
+
# NOTE: "G(condition)" need to be defined before "G"
|
|
61
|
+
"VC G(vma.kbd.next_command_count!=nil)" => "buf.jump_to_line()",
|
|
62
|
+
"VC G" => :jump_end_of_buffer,
|
|
63
|
+
"VC g ;" => :jump_last_edit,
|
|
64
|
+
"VC g g" => :jump_start_of_buffer,
|
|
65
|
+
"VC e" => :jump_next_word_end,
|
|
66
|
+
"VC b" => :jump_prev_word_start,
|
|
67
|
+
"VC w" => :jump_next_word_start,
|
|
68
|
+
"V esc" => "buf.end_visual_mode",
|
|
69
|
+
"V ctrl!" => "buf.end_visual_mode",
|
|
70
|
+
|
|
71
|
+
"C ctrl!" => :insert_mode,
|
|
72
|
+
"C i" => :insert_mode,
|
|
73
|
+
"I esc || I ctrl!" => :prev_mode,
|
|
74
|
+
"IX alt-b" => :jump_prev_word_start,
|
|
75
|
+
"IX alt-f" => :jump_next_word_start,
|
|
76
|
+
"IX ctrl-e" => :jump_end_of_line,
|
|
77
|
+
"IX ctrl-p" => :move_prev_line,
|
|
78
|
+
"IX ctrl-n" => :move_next_line,
|
|
79
|
+
"IX ctrl-b" => :move_backward_char,
|
|
80
|
+
"IX ctrl-a" => :jump_beginning_of_line,
|
|
81
|
+
|
|
82
|
+
"CI ctrl-v" => :paste_before_cursor,
|
|
83
|
+
"I ctrl-c" => :copy_selection, #TODO: in control mode also?
|
|
84
|
+
"CI ctrl-x" => :cut_selection,
|
|
85
|
+
"CI ctrl-z" => :undo,
|
|
86
|
+
"CI ctrl-w" => :close_current_buffer,
|
|
87
|
+
"I ctrl-y" => :redo,
|
|
88
|
+
"CI backspace" => :insert_backspace,
|
|
89
|
+
"CI ctrl-o" => :open_file_dialog,
|
|
90
|
+
"I ctrl-l" => :find_in_buffer,
|
|
91
|
+
"I ctrl-g" => :find_next,
|
|
92
|
+
|
|
93
|
+
"I shift-up" => :insert_select_up,
|
|
94
|
+
"I shift-down" => :insert_select_down,
|
|
95
|
+
}
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
bindkey "C d w", :delete_to_next_word_start
|
|
97
|
-
|
|
98
|
-
bindkey "C d 0", :delete_to_line_start
|
|
99
|
-
bindkey "C , , f", :file_finder
|
|
100
|
-
bindkey "VC h", :e_move_backward_char
|
|
101
|
-
bindkey "C , , .", :backup_all_buffers
|
|
102
|
-
bindkey "C z ", :start_browse_mode
|
|
103
|
-
bindkey "B h", :history_switch_backwards
|
|
104
|
-
bindkey "B l", :history_switch_forwards
|
|
105
|
-
bindkey "B z", "center_on_current_line();call_action(:exit_browse_mode)"
|
|
106
|
-
bindkey "B enter || B return || B esc || B j || B ctrl!", :exit_browse_mode
|
|
107
|
-
bindkey "B s", :page_up
|
|
108
|
-
bindkey "B d", :page_down
|
|
109
|
-
bindkey "B r", proc { vma.gui.page_down(multip: 0.25) }
|
|
110
|
-
bindkey "B e", proc { vma.gui.page_up(multip: 0.25) }
|
|
111
|
-
|
|
112
|
-
bindkey "B i", :jump_to_start_of_buffer
|
|
113
|
-
bindkey "B o", :jump_to_end_of_buffer
|
|
114
|
-
bindkey "B c", :close_current_buffer
|
|
115
|
-
bindkey "B ;", "buf.jump_to_last_edit"
|
|
116
|
-
bindkey "B q", :jump_to_last_edit
|
|
117
|
-
bindkey "B w", :jump_to_next_edit
|
|
118
|
-
# bindkey "C , d", :diff_buffer
|
|
119
|
-
#bindkey 'C , g', proc{invoke_grep_search}
|
|
120
|
-
bindkey "C , v", :auto_indent_buffer
|
|
121
|
-
bindkey "C , , d", :savedebug
|
|
122
|
-
bindkey "C , , u", :update_file_index
|
|
123
|
-
bindkey "C , s a", :buf_save_as
|
|
124
|
-
bindkey "C d d", [:delete_line, proc { buf.delete_line }, "Delete current line"]
|
|
125
|
-
bindkey "C enter || C return", [:line_action, proc { buf.handle_line_action() }, "Line action"]
|
|
126
|
-
bindkey "C p", [:paste_after, proc { buf.paste(AFTER) }, ""] # TODO: implement as replace for visual mode
|
|
127
|
-
bindkey "V d", [:delete_selection, proc { buf.delete(SELECTION) }, ""]
|
|
128
|
-
bindkey "V a d", [:delete_append_selection, proc { buf.delete(SELECTION, :append) }, "Delete and append selection"]
|
|
97
|
+
add_keys "intro delete", {
|
|
98
|
+
"C x" => :delete_char_forward,
|
|
99
|
+
"C d d" => [:delete_line, proc { buf.delete_line }, "Delete current line"]
|
|
100
|
+
}
|
|
129
101
|
|
|
130
102
|
|
|
131
|
-
|
|
103
|
+
add_keys "core", {
|
|
132
104
|
|
|
133
105
|
# File handling
|
|
134
106
|
"C ctrl-s" => :buf_save,
|
|
135
107
|
|
|
108
|
+
"V J" => :V_join_lines,
|
|
136
109
|
# Buffer handling
|
|
137
110
|
# "C B" => "bufs.switch",
|
|
138
111
|
"C tab" => "bufs.switch_to_last_buf",
|
|
139
112
|
# 'C , s'=> 'gui_select_buffer',
|
|
140
113
|
"C , r v b" => :buf_revert,
|
|
141
114
|
"C , c b" => "bufs.close_current_buffer",
|
|
142
|
-
"C , n b" => :buf_new,
|
|
143
115
|
# "C , , ." => "backup_all_buffers()",
|
|
144
|
-
"VC , , s" => :search_actions,
|
|
145
116
|
|
|
146
117
|
# MOVING
|
|
147
|
-
# 'VC h' => 'buf.move(BACKWARD_CHAR)',
|
|
148
|
-
"VC l" => "buf.move(FORWARD_CHAR)",
|
|
149
|
-
# "VC j" => "buf.move(FORWARD_LINE)",
|
|
150
|
-
# "VC k" => "buf.move(BACKWARD_LINE)",
|
|
151
118
|
|
|
152
119
|
"VCI pagedown" => :page_down,
|
|
153
120
|
"VCI pageup" => :page_up,
|
|
@@ -163,10 +130,9 @@ default_keys = {
|
|
|
163
130
|
|
|
164
131
|
"I enter" => :insert_new_line,
|
|
165
132
|
|
|
166
|
-
|
|
133
|
+
|
|
167
134
|
"I shift-right" => "insert_select_move(FORWARD_CHAR)",
|
|
168
135
|
"I shift-down" => "insert_select_move(FORWARD_LINE)",
|
|
169
|
-
"I shift-up" => "insert_select_move(BACKWARD_LINE)",
|
|
170
136
|
"I shift-pagedown" => "insert_select_move(:pagedown)",
|
|
171
137
|
"I shift-pageup" => "insert_select_move(:pageup)",
|
|
172
138
|
|
|
@@ -177,17 +143,6 @@ default_keys = {
|
|
|
177
143
|
"I pagedown" => "insert_move(:pagedown)",
|
|
178
144
|
"I pageup" => "insert_move(:pageup)",
|
|
179
145
|
|
|
180
|
-
#TODO:
|
|
181
|
-
"I @shift-click" => "insert_mode_shift_click(charpos)",
|
|
182
|
-
|
|
183
|
-
"VCX left" => "buf.move(BACKWARD_CHAR)",
|
|
184
|
-
"VCX right" => "buf.move(FORWARD_CHAR)",
|
|
185
|
-
"VCX down" => "buf.move(FORWARD_LINE)",
|
|
186
|
-
"VCX up" => "buf.move(BACKWARD_LINE)",
|
|
187
|
-
|
|
188
|
-
"VC w" => "buf.jump_word(FORWARD,WORD_START)",
|
|
189
|
-
"VC b" => "buf.jump_word(BACKWARD,WORD_START)",
|
|
190
|
-
"VC e" => "buf.jump_word(FORWARD,WORD_END)",
|
|
191
146
|
# 'C '=> 'buf.jump_word(BACKWARD,END)',#TODO
|
|
192
147
|
"VC f <char>" => "buf.jump_to_next_instance_of_char(<char>)",
|
|
193
148
|
"VC F <char>" => "buf.jump_to_next_instance_of_char(<char>,BACKWARD)",
|
|
@@ -197,14 +152,10 @@ default_keys = {
|
|
|
197
152
|
"VC /[1-9]/" => "vma.kbd.set_next_command_count(<char>)",
|
|
198
153
|
# 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
|
|
199
154
|
# 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
|
|
200
|
-
"VC G(vma.kbd.next_command_count!=nil)" => "buf.jump_to_line()",
|
|
201
155
|
"VC 0(vma.kbd.next_command_count!=nil)" => "set_next_command_count(<char>)",
|
|
202
156
|
"VC 0(vma.kbd.next_command_count==nil)" => "buf.jump(BEGINNING_OF_LINE)",
|
|
203
157
|
# 'C 0'=> 'buf.jump(BEGINNING_OF_LINE)',
|
|
204
|
-
"VC g g" => "buf.jump(START_OF_BUFFER)",
|
|
205
|
-
"VC g ;" => "buf.jump_to_last_edit",
|
|
206
158
|
"VC ^" => "buf.jump(BEGINNING_OF_LINE)",
|
|
207
|
-
"VC G" => "buf.jump(END_OF_BUFFER)",
|
|
208
159
|
# 'VC z z' => 'center_on_current_line',
|
|
209
160
|
"VC *" => "buf.jump_to_next_instance_of_word",
|
|
210
161
|
|
|
@@ -216,22 +167,13 @@ default_keys = {
|
|
|
216
167
|
|
|
217
168
|
"R <char>" => "readchar_new_char(<char>)",
|
|
218
169
|
|
|
219
|
-
"C n" =>
|
|
170
|
+
"C n" => :find_next,
|
|
220
171
|
"C N" => "$search.jump_to_previous()",
|
|
221
172
|
|
|
222
173
|
"C C" => :content_search,
|
|
223
174
|
|
|
224
|
-
# Debug
|
|
225
|
-
"C , d r p" => "start_ripl",
|
|
226
|
-
"C , d o" => "vma.gui.clear_overlay",
|
|
227
|
-
"C , D" => "debug_print_buffer",
|
|
228
175
|
"C , c s" => "bufs.close_scrap_buffers",
|
|
229
|
-
"C , d b" => "debug_print_buffer",
|
|
230
|
-
"C , d c" => "debug_dump_clipboard",
|
|
231
|
-
"C , d d" => "debug_dump_deltas",
|
|
232
|
-
"C , d m" => :kbd_dump_state,
|
|
233
176
|
|
|
234
|
-
"VC O" => "buf.jump(END_OF_LINE)",
|
|
235
177
|
"VC $" => "buf.jump(END_OF_LINE)",
|
|
236
178
|
|
|
237
179
|
"C o" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");vma.kbd.set_mode(:insert)',
|
|
@@ -240,23 +182,18 @@ default_keys = {
|
|
|
240
182
|
"C I" => "buf.jump(FIRST_NON_WHITESPACE);vma.kbd.set_mode(:insert)",
|
|
241
183
|
"C a" => "buf.move(FORWARD_CHAR);vma.kbd.set_mode(:insert)",
|
|
242
184
|
"C J" => "buf.join_lines()",
|
|
243
|
-
"C u" => "buf.undo()",
|
|
244
185
|
|
|
245
186
|
"C ^" => "buf.jump(BEGINNING_OF_LINE)",
|
|
246
187
|
# "C /[1-9]/" => "vma.kbd.set_next_command_count(<char>)",
|
|
247
188
|
|
|
248
189
|
# Command mode only:
|
|
249
|
-
"C ctrl-r" => "buf.redo()", # TODO:???
|
|
250
|
-
"C v" => "buf.start_selection;vma.kbd.set_mode(:visual)",
|
|
251
|
-
"C P" => "buf.paste(BEFORE)", # TODO: implement as replace for visual mode
|
|
252
190
|
"C space <char>" => "buf.insert_txt(<char>)",
|
|
253
191
|
"C space space" => "buf.insert_txt(' ')",
|
|
254
|
-
"C y y" => "buf.copy_line",
|
|
255
192
|
"C y O" => "buf.copy(:to_line_end)",
|
|
256
193
|
"C y 0" => "buf.copy(:to_line_start)",
|
|
257
194
|
"C y e" => "buf.copy(:to_word_end)", # TODO
|
|
258
195
|
#### Deleting
|
|
259
|
-
"C x" => "buf.delete(CURRENT_CHAR_FORWARD)",
|
|
196
|
+
# "C x" => "buf.delete(CURRENT_CHAR_FORWARD)",
|
|
260
197
|
# 'C d k'=> 'delete_line(BACKWARD)', #TODO
|
|
261
198
|
# 'C d j'=> 'delete_line(FORWARD)', #TODO
|
|
262
199
|
# 'C d d'=> 'buf.delete_cur_line',
|
|
@@ -279,8 +216,7 @@ default_keys = {
|
|
|
279
216
|
# 'C 0($next_command_count==nil)'=> 'jump_to_beginning_of_line',
|
|
280
217
|
|
|
281
218
|
# Visual mode only:
|
|
282
|
-
|
|
283
|
-
"V ctrl!" => "buf.end_visual_mode",
|
|
219
|
+
|
|
284
220
|
"V y" => "buf.copy_active_selection()",
|
|
285
221
|
"V a y" => "buf.copy_active_selection(:append)",
|
|
286
222
|
"V g U" => :selection_upcase,
|
|
@@ -296,8 +232,6 @@ default_keys = {
|
|
|
296
232
|
# "V ctrl-c" => "buf.comment_selection",
|
|
297
233
|
"V ctrl-x" => "buf.comment_selection(:uncomment)",
|
|
298
234
|
|
|
299
|
-
"CI ctrl-v" => "buf.paste(BEFORE)",
|
|
300
|
-
"CI backspace" => "buf.delete(BACKWARD_CHAR)",
|
|
301
235
|
|
|
302
236
|
# Marks
|
|
303
237
|
"CV m <char>" => "buf.mark_current_position(<char>)",
|
|
@@ -305,9 +239,7 @@ default_keys = {
|
|
|
305
239
|
# "CV ''" =>'jump_to_mark(NEXT_MARK)', #TODO
|
|
306
240
|
|
|
307
241
|
# Switch to another mode
|
|
308
|
-
"C i" => "vma.kbd.set_mode(:insert)",
|
|
309
242
|
"C R" => "vma.kbd.set_mode(:replace)",
|
|
310
|
-
"C ctrl!" => "vma.kbd.set_mode(:insert)",
|
|
311
243
|
|
|
312
244
|
# Replace mode
|
|
313
245
|
"X esc || X ctrl!" => "vma.kbd.to_previous_mode",
|
|
@@ -316,49 +248,143 @@ default_keys = {
|
|
|
316
248
|
# Macros
|
|
317
249
|
# (experimental, may not work correctly)
|
|
318
250
|
# "C q a" => 'vma.macro.start_recording("a")',
|
|
319
|
-
|
|
320
|
-
"
|
|
251
|
+
|
|
252
|
+
"macro q" => "vma.kbd.to_previous_mode; vma.macro.end_recording",
|
|
253
|
+
# "macro q z" => "vma.kbd.to_previous_mode; vma.macro.end_recording",
|
|
254
|
+
|
|
255
|
+
# "VC q(vma.macro.is_recording==true)" => "vma.macro.end_recording", # TODO: does not work
|
|
256
|
+
# "VC o(vma.macro.is_recording==true)" => "vma.macro.end_recording", # TODO: does not work
|
|
257
|
+
# "VC q q(vma.macro.is_recording==true)" => "vma.macro.end_recording",
|
|
258
|
+
"VC q <char>" => "vma.kbd.set_mode(:macro);vma.macro.start_recording(<char>)",
|
|
321
259
|
# 'C q'=> 'vma.macro.end_recording', #TODO
|
|
322
|
-
|
|
260
|
+
|
|
261
|
+
# "C q v" => "vma.kbd.to_previous_mode; vma.macro.end_recording", #TODO
|
|
262
|
+
|
|
323
263
|
# 'C v'=> 'vma.macro.end_recording',
|
|
324
264
|
# "C M" => 'vma.macro.run_last_macro',
|
|
325
265
|
"C @ <char>" => "vma.macro.run_macro(<char>)",
|
|
326
266
|
"C , m S" => 'vma.macro.save_macro("a")',
|
|
327
267
|
"C , m s" => "vma.macro.save",
|
|
328
|
-
"C , t r" => "run_tests()",
|
|
329
268
|
|
|
330
269
|
# "C ." => "repeat_last_action", # TODO
|
|
331
270
|
"VC ;" => "repeat_last_find",
|
|
332
271
|
# "CV Q" => :quit,
|
|
333
272
|
"CV ctrl-q" => :quit,
|
|
334
|
-
"CV , R" => "restart_application",
|
|
335
273
|
# "I ctrl!" => "vma.kbd.to_previous_mode",
|
|
336
274
|
"C shift! s" => "buf.save",
|
|
337
275
|
"I ctrl-s" => "buf.save",
|
|
338
276
|
"I <char>" => "buf.insert_txt(<char>)",
|
|
339
|
-
"I esc || I ctrl!" => "vma.kbd.to_previous_mode",
|
|
340
277
|
|
|
341
278
|
"I ctrl-d" => "buf.delete2(:to_word_end)",
|
|
342
279
|
|
|
343
280
|
# Insert and Replace modes: Moving
|
|
344
|
-
"IX ctrl-a" => "buf.jump(BEGINNING_OF_LINE)",
|
|
345
|
-
"IX ctrl-b" => "buf.move(BACKWARD_CHAR)",
|
|
346
281
|
"IX ctrl-f" => "buf.move(FORWARD_CHAR)",
|
|
347
|
-
"IX ctrl-n" => "buf.move(FORWARD_LINE)",
|
|
348
|
-
"IX ctrl-p" => "buf.move(BACKWARD_LINE)",
|
|
349
|
-
"IX ctrl-e" => "buf.jump(END_OF_LINE)", # context: mode:I, buttons down: {C}
|
|
350
|
-
"IX alt-f" => "buf.jump_word(FORWARD,WORD_START)",
|
|
351
|
-
"IX alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
|
|
352
282
|
|
|
353
|
-
"I ctrl-h" => :show_autocomplete,
|
|
354
283
|
"I ctrl-j" => "vma.buf.view.hide_completions",
|
|
355
284
|
|
|
356
285
|
"I space" => 'buf.insert_txt(" ")',
|
|
357
286
|
# "I return" => 'buf.insert_new_line()',
|
|
287
|
+
|
|
288
|
+
"C , a" => :ack_search,
|
|
289
|
+
"C d w" => :delete_to_next_word_start,
|
|
290
|
+
|
|
291
|
+
"C d 0" => :delete_to_line_start,
|
|
292
|
+
"C , , f" => :file_finder,
|
|
293
|
+
"VC h" => :e_move_backward_char,
|
|
294
|
+
"C , , ." => :backup_all_buffers,
|
|
295
|
+
"C z " => :start_browse_mode,
|
|
296
|
+
"B h" => :history_switch_backwards,
|
|
297
|
+
"B l" => :history_switch_forwards,
|
|
298
|
+
"B z" => "center_on_current_line();call_action(:exit_browse_mode)",
|
|
299
|
+
"B enter || B return || B esc || B j || B ctrl!" => :exit_browse_mode,
|
|
300
|
+
"B s" => :page_up,
|
|
301
|
+
"B d" => :page_down,
|
|
302
|
+
"B r" => proc { vma.gui.page_down(multip: 0.25) },
|
|
303
|
+
"B e" => proc { vma.gui.page_up(multip: 0.25) },
|
|
304
|
+
|
|
305
|
+
"B i" => :jump_to_start_of_buffer,
|
|
306
|
+
"B o" => :jump_to_end_of_buffer,
|
|
307
|
+
"B c" => :close_current_buffer,
|
|
308
|
+
"B ;" => :jump_last_edit,
|
|
309
|
+
"B q" => :jump_to_last_edit,
|
|
310
|
+
"B w" => :jump_to_next_edit,
|
|
311
|
+
"C , v" => :auto_indent_buffer,
|
|
312
|
+
"C , , u" => :update_file_index,
|
|
313
|
+
"C , s a" => :buf_save_as,
|
|
314
|
+
"VC , r r" => :gui_search_replace,
|
|
315
|
+
"C , w" => :toggle_active_window,
|
|
316
|
+
"C , , w" => :toggle_two_column,
|
|
317
|
+
|
|
318
|
+
"VC s" => :easy_jump,
|
|
319
|
+
"I alt-s" => :easy_jump,
|
|
320
|
+
"VC , m f" => [:find_macro_gui, proc { vma.macro.find_macro_gui }, "Find named macro"],
|
|
321
|
+
"C , m n" => [:gui_name_macro, proc { vma.macro.gui_name_macro }, "Name last macro"],
|
|
322
|
+
"C , j r" => :jump_to_random,
|
|
323
|
+
"C , ; s k" => :show_key_bindings, #TODO: better binding,
|
|
324
|
+
"C , , c b" => :put_file_path_to_clipboard, #TODO: better binding or remove?,
|
|
325
|
+
"C , , e" => :encrypt_file, #TODO: better binding,
|
|
326
|
+
"C , ; u" => :set_unencrypted, #TODO: better binding,
|
|
327
|
+
"C , c b" => :close_current_buffer,
|
|
328
|
+
"V ctrl-c" => :comment_selection,
|
|
329
|
+
"C , f" => :gui_file_finder,
|
|
330
|
+
"C , h" => :gui_file_history_finder,
|
|
331
|
+
"C , z" => :gui_file_finder,
|
|
332
|
+
|
|
333
|
+
"C enter || C return" => [:line_action, proc { buf.handle_line_action() }, "Line action"],
|
|
334
|
+
"V d" => [:delete_selection, proc { buf.delete(SELECTION) }, ""],
|
|
335
|
+
"V a d" => [:delete_append_selection, proc { buf.delete(SELECTION, :append) }, "Delete and append selection"]
|
|
358
336
|
}
|
|
359
337
|
|
|
360
|
-
|
|
338
|
+
add_keys "hyperplaintext", {
|
|
339
|
+
"V , t b" => :set_style_bold,
|
|
340
|
+
"V , t l" => :set_style_link,
|
|
341
|
+
"V , t c" => :clear_formats,
|
|
342
|
+
"C , t h" => :set_line_style_heading,
|
|
343
|
+
"C , t 1" => :set_line_style_h1,
|
|
344
|
+
"C , t 2" => :set_line_style_h2,
|
|
345
|
+
"C , t 3" => :set_line_style_h3,
|
|
346
|
+
"C , t 4" => :set_line_style_h4,
|
|
347
|
+
"C , t b" => :set_line_style_bold,
|
|
348
|
+
"C , t t" => :set_line_style_title,
|
|
349
|
+
"C , t c" => :clear_line_styles,
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
bindkey ["VCB M", "B m"], :run_last_macro
|
|
353
|
+
|
|
354
|
+
add_keys "experimental", {
|
|
355
|
+
"C ` k" => :lsp_debug,
|
|
356
|
+
"C ` j" => :lsp_jump_to_definition,
|
|
357
|
+
"C , u s" => :audio_stop,
|
|
361
358
|
|
|
362
|
-
|
|
363
|
-
|
|
359
|
+
"C , t r" => "run_tests()",
|
|
360
|
+
# "CV , R" => "restart_application", #TODO: does not work
|
|
361
|
+
"I ctrl-h" => :show_autocomplete, #TODO: does not work
|
|
362
|
+
"C , d m" => :kbd_dump_state,
|
|
363
|
+
"C , ; ." => :increment_word,
|
|
364
|
+
"C , d d" => "debug_dump_deltas",
|
|
365
|
+
"C , d c" => "debug_dump_clipboard",
|
|
366
|
+
"C , d b" => "debug_print_buffer",
|
|
367
|
+
"C , D" => "debug_print_buffer",
|
|
368
|
+
"C , d o" => "vma.gui.clear_overlay",
|
|
369
|
+
# Debug
|
|
370
|
+
"C , d r p" => 'require "pry"; binding.pry', #TODO
|
|
371
|
+
#bindkey 'C , g', proc{invoke_grep_search}
|
|
372
|
+
# bindkey "C , d", :diff_buffer
|
|
373
|
+
"C , , d" => :savedebug,
|
|
374
|
+
"C , m a" => "vma.kbd.set_mode(:audio)",
|
|
375
|
+
"audio s" => :audio_stop,
|
|
364
376
|
}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
bindkey "audio f || audio right", [:audio_forward, proc { Audio.seek_forward }, "Seek forward in audio stream"]
|
|
380
|
+
bindkey "audio left", [:audio_backward, proc { Audio.seek_forward(-5.0) }, "Seek backward in audio stream"]
|
|
381
|
+
|
|
382
|
+
bindkey "audio space", :audio_stop
|
|
383
|
+
bindkey "audio q || audio esc", "vma.kbd.to_previous_mode"
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
bindkey "C , i p", "generate_password_to_buf(15)"
|
|
387
|
+
|
|
388
|
+
# default_keys.each { |key, value|
|
|
389
|
+
# bindkey(key, value)
|
|
390
|
+
# }
|
data/lib/vimamsa/main.rb
CHANGED
data/lib/vimamsa/rbvma.rb
CHANGED
|
@@ -16,6 +16,7 @@ require "cgi"
|
|
|
16
16
|
require "uri"
|
|
17
17
|
require "vimamsa/conf"
|
|
18
18
|
require "vimamsa/util"
|
|
19
|
+
require "vimamsa/string_util"
|
|
19
20
|
# exit!
|
|
20
21
|
require "vimamsa/main"
|
|
21
22
|
require "vimamsa/terminal"
|
|
@@ -30,6 +31,8 @@ require "vimamsa/gui_form_generator"
|
|
|
30
31
|
require "vimamsa/gui_text"
|
|
31
32
|
require "vimamsa/gui_menu"
|
|
32
33
|
require "vimamsa/gui_dialog"
|
|
34
|
+
require "vimamsa/gui_settings"
|
|
35
|
+
require "vimamsa/gui_file_panel"
|
|
33
36
|
require "vimamsa/gui_select_window"
|
|
34
37
|
require "vimamsa/gui_sourceview"
|
|
35
38
|
require "vimamsa/gui_sourceview_autocomplete"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
def flip_true_false(str)
|
|
2
|
+
str.gsub(/\b(true|false)\b/i) do |match|
|
|
3
|
+
if match.match?(/\Atrue\z/i)
|
|
4
|
+
replacement = "false"
|
|
5
|
+
else
|
|
6
|
+
replacement = "true"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# preserve casing style
|
|
10
|
+
if match == match.upcase
|
|
11
|
+
replacement.upcase
|
|
12
|
+
elsif match[0] == match[0].upcase
|
|
13
|
+
replacement.capitalize
|
|
14
|
+
else
|
|
15
|
+
replacement.downcase
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def to_camel_case(str)
|
|
21
|
+
words = str.split(/\W+/) # Split the input string into words
|
|
22
|
+
camel_case_words = words.map.with_index do |word, index|
|
|
23
|
+
index == 0 ? word.downcase : word.capitalize
|
|
24
|
+
end
|
|
25
|
+
camel_case_words.join
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Get all indexes for start of matching regexp
|
|
29
|
+
def scan_indexes(txt, regex)
|
|
30
|
+
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
|
31
|
+
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
|
32
|
+
return indexes
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def is_path(s)
|
|
36
|
+
m = s.match(/(~[a-z]*)?\/.*\//)
|
|
37
|
+
if m != nil
|
|
38
|
+
return true
|
|
39
|
+
end
|
|
40
|
+
return false
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def sanitize_input(str)
|
|
45
|
+
if str.encoding != Encoding::UTF_8
|
|
46
|
+
str = text.encode(Encoding::UTF_8)
|
|
47
|
+
end
|
|
48
|
+
str.gsub!(/\r\n/, "\n")
|
|
49
|
+
return str
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def is_url(s)
|
|
53
|
+
return s.match(/(https?|file):\/\/.*/) != nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
data/lib/vimamsa/util.rb
CHANGED
|
@@ -3,6 +3,12 @@ require "open3"
|
|
|
3
3
|
VOWELS = %w(a e i o u)
|
|
4
4
|
CONSONANTS = %w(b c d f g h j k l m n p q r s t v w x y z)
|
|
5
5
|
|
|
6
|
+
def draw_cursor_bug_workaround()
|
|
7
|
+
if !vma.gui.nil?
|
|
8
|
+
DelayExecutioner.exec(id: :bug_workaround_draw_cursor, wait: 1.0, callable: proc { vma.gui.view.draw_cursor(); debug ":bug_workaround_draw_cursor"; false })
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
6
12
|
def running_wayland?
|
|
7
13
|
sess = ENV["DESKTOP_SESSION"]
|
|
8
14
|
sess ||= ENV["XDG_SESSION_DESKTOP"]
|
|
@@ -20,14 +26,6 @@ def tilde_path(abspath)
|
|
|
20
26
|
abspath.sub(/^#{Regexp.escape(userhome)}\//, "~/")
|
|
21
27
|
end
|
|
22
28
|
|
|
23
|
-
def to_camel_case(str)
|
|
24
|
-
words = str.split(/\W+/) # Split the input string into words
|
|
25
|
-
camel_case_words = words.map.with_index do |word, index|
|
|
26
|
-
index == 0 ? word.downcase : word.capitalize
|
|
27
|
-
end
|
|
28
|
-
camel_case_words.join
|
|
29
|
-
end
|
|
30
|
-
|
|
31
29
|
def generate_password(length)
|
|
32
30
|
password = ""
|
|
33
31
|
while password.size < length
|
|
@@ -49,13 +47,6 @@ def generate_password_to_buf(length)
|
|
|
49
47
|
vma.buf.insert_txt(passw)
|
|
50
48
|
end
|
|
51
49
|
|
|
52
|
-
# Get all indexes for start of matching regexp
|
|
53
|
-
def scan_indexes(txt, regex)
|
|
54
|
-
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
|
55
|
-
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
|
56
|
-
return indexes
|
|
57
|
-
end
|
|
58
|
-
|
|
59
50
|
def file_mime_type(fpath)
|
|
60
51
|
fpath = File.expand_path(fpath)
|
|
61
52
|
return nil if !File.readable?(fpath)
|
|
@@ -218,7 +209,7 @@ end
|
|
|
218
209
|
# Used for image scaling after window resize
|
|
219
210
|
|
|
220
211
|
class DelayExecutioner
|
|
221
|
-
|
|
212
|
+
attr_accessor :last_run, :wait_before_next
|
|
222
213
|
# Run 'callable.call' if 'wait' time elapsed from last exec call for this id
|
|
223
214
|
def self.exec(id:, wait:, callable:)
|
|
224
215
|
@@h ||= {}
|
|
@@ -226,6 +217,12 @@ class DelayExecutioner
|
|
|
226
217
|
if h[id].nil?
|
|
227
218
|
h[id] = DelayExecutioner.new(wait, callable)
|
|
228
219
|
end
|
|
220
|
+
o = h[id]
|
|
221
|
+
if !o.last_run.nil?
|
|
222
|
+
# if Time.now - o.last_run < o.wait_before_next
|
|
223
|
+
# return
|
|
224
|
+
# end
|
|
225
|
+
end
|
|
229
226
|
h[id].run
|
|
230
227
|
end
|
|
231
228
|
|
|
@@ -234,6 +231,8 @@ class DelayExecutioner
|
|
|
234
231
|
@proc = _proc
|
|
235
232
|
@lastt = Time.now
|
|
236
233
|
@thread_running = false
|
|
234
|
+
@last_run = nil
|
|
235
|
+
@wait_before_next = 0
|
|
237
236
|
end
|
|
238
237
|
|
|
239
238
|
def start_thread
|
|
@@ -242,6 +241,7 @@ class DelayExecutioner
|
|
|
242
241
|
sleep 0.1
|
|
243
242
|
if Time.now - @lastt > @wait_time
|
|
244
243
|
@proc.call
|
|
244
|
+
@last_run = Time.now
|
|
245
245
|
@thread_running = false
|
|
246
246
|
break
|
|
247
247
|
end
|
|
@@ -309,18 +309,6 @@ def read_file(text, path)
|
|
|
309
309
|
return content
|
|
310
310
|
end
|
|
311
311
|
|
|
312
|
-
def sanitize_input(str)
|
|
313
|
-
if str.encoding != Encoding::UTF_8
|
|
314
|
-
str = text.encode(Encoding::UTF_8)
|
|
315
|
-
end
|
|
316
|
-
str.gsub!(/\r\n/, "\n")
|
|
317
|
-
return str
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
def is_url(s)
|
|
321
|
-
return s.match(/(https?|file):\/\/.*/) != nil
|
|
322
|
-
end
|
|
323
|
-
|
|
324
312
|
def expand_if_existing(fpath)
|
|
325
313
|
return nil if fpath.class != String
|
|
326
314
|
fpath = File.expand_path(fpath)
|
|
@@ -344,6 +332,17 @@ def is_existing_file(s)
|
|
|
344
332
|
return false
|
|
345
333
|
end
|
|
346
334
|
|
|
335
|
+
def uri_to_path(uri)
|
|
336
|
+
fp = nil
|
|
337
|
+
begin
|
|
338
|
+
x = URI::DEFAULT_PARSER.unescape(URI(uri).path)
|
|
339
|
+
rescue URI::InvalidURIError
|
|
340
|
+
else
|
|
341
|
+
fp = x # only if no exception
|
|
342
|
+
end
|
|
343
|
+
return fp
|
|
344
|
+
end
|
|
345
|
+
|
|
347
346
|
def is_image_file(fpath)
|
|
348
347
|
return false if !File.exist?(fpath)
|
|
349
348
|
# return false if !fpath.match(/.(jpg|jpeg|png)$/i)
|
|
@@ -362,11 +361,3 @@ end
|
|
|
362
361
|
# #TODO: check contents of file
|
|
363
362
|
# return true
|
|
364
363
|
# end
|
|
365
|
-
|
|
366
|
-
def is_path(s)
|
|
367
|
-
m = s.match(/(~[a-z]*)?\/.*\//)
|
|
368
|
-
if m != nil
|
|
369
|
-
return true
|
|
370
|
-
end
|
|
371
|
-
return false
|
|
372
|
-
end
|