vimamsa 0.1.8 → 0.1.9
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 +47 -0
- data/demo.txt +25 -0
- data/lang/hyperplaintext.lang +9 -25
- data/lib/vimamsa/ack.rb +90 -7
- data/lib/vimamsa/actions.rb +21 -2
- data/lib/vimamsa/buffer.rb +53 -49
- data/lib/vimamsa/debug.rb +1 -1
- data/lib/vimamsa/easy_jump.rb +13 -18
- data/lib/vimamsa/editor.rb +57 -54
- data/lib/vimamsa/encrypt.rb +1 -1
- data/lib/vimamsa/file_finder.rb +1 -3
- data/lib/vimamsa/gui.rb +76 -73
- data/lib/vimamsa/gui_image.rb +43 -0
- data/lib/vimamsa/gui_menu.rb +0 -1
- data/lib/vimamsa/gui_select_window.rb +3 -0
- data/lib/vimamsa/gui_sourceview.rb +41 -14
- data/lib/vimamsa/hyper_plain_text.rb +31 -10
- data/lib/vimamsa/key_actions.rb +37 -16
- data/lib/vimamsa/key_binding_tree.rb +37 -113
- data/lib/vimamsa/key_bindings_vimlike.rb +25 -23
- data/lib/vimamsa/rbvma.rb +12 -9
- data/lib/vimamsa/search_replace.rb +8 -4
- data/lib/vimamsa/text_transforms.rb +2 -0
- data/lib/vimamsa/util.rb +34 -0
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +5 -0
- data/sheep.jpg +0 -0
- data/styles/dark.xml +1 -0
- data/styles/molokai_edit.xml +1 -1
- metadata +9 -5
@@ -35,25 +35,46 @@ def hpt_check_cur_word(w)
|
|
35
35
|
return nil
|
36
36
|
end
|
37
37
|
|
38
|
+
def translate_path(fn, bf)
|
39
|
+
if File.exist?(fn)
|
40
|
+
outfn = fn
|
41
|
+
elsif fn[0] == "$"
|
42
|
+
outfn = ppath(fn[1..-1]) # Path to source location
|
43
|
+
elsif fn[0] == "~"
|
44
|
+
outfn = File.expand_path(fn)
|
45
|
+
elsif !bf.fname.nil?
|
46
|
+
pd = File.dirname(bf.fname)
|
47
|
+
outfn = "#{pd}/#{fn}"
|
48
|
+
else
|
49
|
+
outfn = File.expand_path(fn)
|
50
|
+
end
|
51
|
+
return outfn
|
52
|
+
end
|
53
|
+
|
38
54
|
# Scan images inserted with ⟦img:filepath⟧ syntax
|
39
|
-
def hpt_scan_images()
|
40
|
-
|
41
|
-
return if
|
42
|
-
|
43
|
-
|
55
|
+
def hpt_scan_images(bf = nil)
|
56
|
+
bf = buf() if bf.nil?
|
57
|
+
return if bf.nil?
|
58
|
+
return if !bf.fname
|
59
|
+
return if !bf.fname.match(/.*txt$/)
|
60
|
+
imgpos = scan_indexes(bf, /⟦img:.+?⟧/)
|
61
|
+
imgtags = bf.scan(/(⟦img:(.+?)⟧)/)
|
44
62
|
c = 0
|
45
63
|
imgpos.each.with_index { |x, i|
|
46
64
|
a = imgpos[i]
|
47
65
|
t = imgtags[i]
|
48
66
|
insert_pos = a + t[0].size + c
|
49
|
-
|
67
|
+
fn = t[1]
|
68
|
+
imgfn = translate_path(fn, bf)
|
50
69
|
next if !File.exist?(imgfn)
|
51
70
|
# Show as image in gui, handle as empty space in txt file
|
52
|
-
|
53
|
-
|
54
|
-
|
71
|
+
|
72
|
+
if bf[insert_pos..(insert_pos + 2)] != "\n \n"
|
73
|
+
bf.insert_txt_at("\n \n", insert_pos)
|
74
|
+
bf.view.handle_deltas
|
55
75
|
c += 3
|
56
76
|
end
|
57
|
-
|
77
|
+
bf.add_image(imgfn, insert_pos + 1)
|
58
78
|
}
|
79
|
+
vma.gui.delex.run
|
59
80
|
end
|
data/lib/vimamsa/key_actions.rb
CHANGED
@@ -28,17 +28,16 @@ def is_visual_mode()
|
|
28
28
|
return 0
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
reg_act(:
|
33
|
-
reg_act(:disable_debug, proc {$debug=false }, "Disable debug")
|
31
|
+
reg_act(:enable_debug, proc { $debug = true }, "Enable debug")
|
32
|
+
reg_act(:disable_debug, proc { $debug = false }, "Disable debug")
|
34
33
|
|
35
34
|
reg_act(:easy_jump, proc { EasyJump.start }, "Easy jump")
|
36
35
|
reg_act(:savedebug, "savedebug", "Save debug info", { :group => :debug })
|
37
36
|
reg_act(:open_file_dialog, "open_file_dialog", "Open file", { :group => :file })
|
38
37
|
reg_act(:create_new_file, "create_new_file", "Create new file", { :group => :file })
|
39
|
-
reg_act(:backup_all_buffers, proc{backup_all_buffers}, "Backup all buffers", { :group => :file })
|
40
|
-
reg_act(:e_move_forward_char, "e_move_forward_char", "", { :group => :move })
|
41
|
-
reg_act(:e_move_backward_char, "e_move_backward_char", "", { :group => :move })
|
38
|
+
reg_act(:backup_all_buffers, proc { backup_all_buffers }, "Backup all buffers", { :group => :file })
|
39
|
+
reg_act(:e_move_forward_char, "e_move_forward_char", "", { :group => [:move, :basic] })
|
40
|
+
reg_act(:e_move_backward_char, "e_move_backward_char", "", { :group => [:move, :basic] })
|
42
41
|
reg_act(:history_switch_backwards, "history_switch_backwards", "", { :group => :file })
|
43
42
|
reg_act(:history_switch_forwards, "history_switch_forwards", "", { :group => :file })
|
44
43
|
reg_act(:center_on_current_line, "center_on_current_line", "", { :group => :view })
|
@@ -56,7 +55,7 @@ reg_act(:set_executable, proc { buf.set_executable }, "Set current file permissi
|
|
56
55
|
reg_act(:close_all_buffers, proc { bufs.close_all_buffers() }, "Close all buffers")
|
57
56
|
reg_act(:close_current_buffer, proc { bufs.close_current_buffer(true) }, "Close current buffer")
|
58
57
|
reg_act(:comment_selection, proc { buf.comment_selection }, "")
|
59
|
-
reg_act(:delete_char_forward, proc { buf.delete(CURRENT_CHAR_FORWARD) }, "Delete char forward")
|
58
|
+
reg_act(:delete_char_forward, proc { buf.delete(CURRENT_CHAR_FORWARD) }, "Delete char forward", { :group => [:edit, :basic] })
|
60
59
|
reg_act(:load_theme, proc { load_theme }, "Load theme")
|
61
60
|
reg_act(:gui_file_finder, proc { vma.FileFinder.start_gui }, "Fuzzy file finder")
|
62
61
|
reg_act(:gui_file_history_finder, proc { vma.FileHistory.start_gui }, "Fuzzy file history finder")
|
@@ -82,19 +81,19 @@ reg_act(:diff_buffer, "diff_buffer", "")
|
|
82
81
|
reg_act(:invoke_grep_search, proc { gui_grep }, "Grep current buffer")
|
83
82
|
reg_act(:ack_search, proc { gui_ack }, "") #invoke_ack_search
|
84
83
|
reg_act :update_file_index, proc { update_file_index }, "Update file index"
|
85
|
-
reg_act :delete_to_word_end, proc { buf.delete2(:to_word_end) }, "Delete to file end"
|
86
|
-
reg_act :delete_to_line_start, proc { buf.delete2(:to_line_start) }, "Delete to line start"
|
84
|
+
reg_act :delete_to_word_end, proc { buf.delete2(:to_word_end) }, "Delete to file end", { :group => [:edit, :basic] }
|
85
|
+
reg_act :delete_to_line_start, proc { buf.delete2(:to_line_start) }, "Delete to line start", { :group => [:edit, :basic] }
|
87
86
|
reg_act :start_browse_mode, proc { $kbd.set_mode(:browse); $kbd.set_default_mode(:browse) }, "Start browse mode"
|
88
87
|
reg_act :exit_browse_mode, proc {
|
89
88
|
bufs.add_current_buf_to_history(); $kbd.set_mode(:command); $kbd.set_default_mode(:command)
|
90
89
|
}, "Exit browse mode"
|
91
90
|
|
92
|
-
reg_act :page_down, proc { page_down }
|
93
|
-
reg_act :page_up, proc { page_up }
|
91
|
+
reg_act :page_down, proc { page_down }, "Page down", :group => [:move, :basic]
|
92
|
+
reg_act :page_up, proc { page_up }, "Page up", :group => [:move, :basic]
|
94
93
|
reg_act :jump_to_start_of_buffer, proc { buf.jump(START_OF_BUFFER) }, "Jump to start of buffer"
|
95
94
|
reg_act :jump_to_end_of_buffer, proc { buf.jump(END_OF_BUFFER) }, "Jump to end of buffer"
|
96
95
|
reg_act(:auto_indent_buffer, proc { buf.indent }, "Auto format buffer")
|
97
|
-
reg_act(:execute_current_line_in_terminal, proc { buf.execute_current_line_in_terminal }, "Execute current line in
|
96
|
+
reg_act(:execute_current_line_in_terminal, proc { buf.execute_current_line_in_terminal }, "Execute current line in terminal")
|
98
97
|
reg_act(:execute_current_line_in_terminal_autoclose, proc { buf.execute_current_line_in_terminal(true) }, "Execute current line in terminal. Close after execution.")
|
99
98
|
reg_act(:show_images, proc { hpt_scan_images() }, "Show images inserted with ⟦img:file.png⟧ syntax")
|
100
99
|
reg_act(:delete_current_file, proc { bufs.delete_current_buffer() }, "Delete current file")
|
@@ -118,8 +117,28 @@ act_list = {
|
|
118
117
|
:desc => "Undo edit", :group => :edit },
|
119
118
|
|
120
119
|
:find_in_buffer => { :proc => proc { invoke_search },
|
121
|
-
|
120
|
+
:desc => "Find", :group => :edit },
|
121
|
+
|
122
|
+
:selection_upcase => { :proc => proc { buf.transform_selection(:upcase) },
|
123
|
+
:desc => "Transform text: upcase", :group => :edit },
|
124
|
+
|
125
|
+
:selection_downcase => { :proc => proc { buf.transform_selection(:downcase) },
|
126
|
+
:desc => "Transform text: downcase", :group => :edit },
|
127
|
+
|
128
|
+
:selection_capitalize => { :proc => proc { buf.transform_selection(:capitalize) },
|
129
|
+
:desc => "Transform text: capitalize", :group => :edit },
|
130
|
+
|
131
|
+
:selection_swapcase => { :proc => proc { buf.transform_selection(:swapcase) },
|
132
|
+
:desc => "Transform text: swapcase", :group => :edit },
|
122
133
|
|
134
|
+
:selection_reverse => { :proc => proc { buf.transform_selection(:reverse) },
|
135
|
+
:desc => "Transform text: reverse", :group => :edit },
|
136
|
+
|
137
|
+
:forward_line => { :proc => proc { buf.move(FORWARD_LINE) },
|
138
|
+
:desc => "Move one line forward", :group => [:move, :basic] },
|
139
|
+
|
140
|
+
:backward_line => { :proc => proc { buf.move(BACKWARD_LINE) },
|
141
|
+
:desc => "Move one line backward", :group => [:move, :basic] },
|
123
142
|
|
124
143
|
# { :proc => proc { },
|
125
144
|
# :desc => "", :group => : },
|
@@ -127,6 +146,9 @@ act_list = {
|
|
127
146
|
:search_actions => { :proc => proc { search_actions },
|
128
147
|
:desc => "Search actions", :group => :search },
|
129
148
|
|
149
|
+
:content_search => { :proc => proc { FileContentSearch.start_gui },
|
150
|
+
:desc => "Search content of files", :group => :search },
|
151
|
+
|
130
152
|
:quit => { :proc => proc { _quit },
|
131
153
|
:desc => "Quit", :group => :app },
|
132
154
|
|
@@ -149,14 +171,13 @@ act_list_todo = {
|
|
149
171
|
:desc => "Close current file", :group => :file },
|
150
172
|
#"C , b" => '$kbd.set_mode("S");gui_select_buffer',
|
151
173
|
|
152
|
-
|
153
174
|
# MOVING
|
154
175
|
# 'VC h' => 'buf.move(BACKWARD_CHAR)',
|
155
176
|
:m_forward_char => { :proc => proc { buf.move(FORWARD_CHAR) },
|
156
177
|
:desc => "Move cursor one char forward",
|
157
178
|
:group => :move },
|
158
|
-
"VC j" => "buf.move(FORWARD_LINE)",
|
159
|
-
"VC k" => "buf.move(BACKWARD_LINE)",
|
179
|
+
# "VC j" => "buf.move(FORWARD_LINE)",
|
180
|
+
# "VC k" => "buf.move(BACKWARD_LINE)",
|
160
181
|
|
161
182
|
"VC pagedown" => "page_down",
|
162
183
|
"VC pageup" => "page_up",
|
@@ -36,7 +36,7 @@ setcnf :indent_based_on_last_line, true
|
|
36
36
|
setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js"]
|
37
37
|
|
38
38
|
class State
|
39
|
-
attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes
|
39
|
+
attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes, :level
|
40
40
|
|
41
41
|
def initialize(key_name, eval_rule = "")
|
42
42
|
@key_name = key_name
|
@@ -44,6 +44,7 @@ class State
|
|
44
44
|
@children = []
|
45
45
|
@major_modes = []
|
46
46
|
@action = nil
|
47
|
+
@level = 0
|
47
48
|
end
|
48
49
|
|
49
50
|
def to_s()
|
@@ -86,6 +87,7 @@ class KeyBindingTree
|
|
86
87
|
# $kbd.add_mode("I", :insert)
|
87
88
|
def add_mode(id, label)
|
88
89
|
mode = State.new(id)
|
90
|
+
mode.level = 1
|
89
91
|
@modes[label] = mode
|
90
92
|
@root.children << mode
|
91
93
|
if @default_mode == nil
|
@@ -142,7 +144,6 @@ class KeyBindingTree
|
|
142
144
|
}
|
143
145
|
}
|
144
146
|
|
145
|
-
|
146
147
|
if new_state.any? # Match found
|
147
148
|
@match_state = new_state
|
148
149
|
return new_state
|
@@ -153,6 +154,11 @@ class KeyBindingTree
|
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
157
|
+
def show_state_trail
|
158
|
+
(st, children) = get_state_trail_str()
|
159
|
+
vma.gui.statnfo.markup = "<span weight='ultrabold'>#{st}</span>"
|
160
|
+
end
|
161
|
+
|
156
162
|
def set_mode(label)
|
157
163
|
@mode_history << @mode_root_state
|
158
164
|
|
@@ -205,6 +211,7 @@ class KeyBindingTree
|
|
205
211
|
# @cur_state = @root
|
206
212
|
stack = [[@root, ""]]
|
207
213
|
lines = []
|
214
|
+
|
208
215
|
while stack.any?
|
209
216
|
t, p = *stack.pop # t = current state, p = current path
|
210
217
|
if t.children.any?
|
@@ -212,14 +219,27 @@ class KeyBindingTree
|
|
212
219
|
if c.eval_rule.size > 0
|
213
220
|
new_p = "#{p} #{c.key_name}(#{c.eval_rule})"
|
214
221
|
else
|
215
|
-
|
222
|
+
if c.level == 1
|
223
|
+
new_p = "#{p} [#{c.key_name}]"
|
224
|
+
else
|
225
|
+
new_p = "#{p} #{c.key_name}"
|
226
|
+
end
|
216
227
|
end
|
217
228
|
stack << [c, new_p]
|
218
229
|
}
|
219
230
|
# stack.concat[t.children]
|
220
231
|
else
|
221
|
-
|
222
|
-
|
232
|
+
method_desc = t.action
|
233
|
+
if t.action.class == Symbol
|
234
|
+
if !$actions[t.action].nil?
|
235
|
+
a = $actions[t.action].method_name
|
236
|
+
if !a.nil? and !a.empty?
|
237
|
+
method_desc = a
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
lines << p + " : #{method_desc}"
|
223
243
|
end
|
224
244
|
end
|
225
245
|
s = lines.sort.join("\n")
|
@@ -227,21 +247,26 @@ class KeyBindingTree
|
|
227
247
|
end
|
228
248
|
|
229
249
|
def get_state_trail_str
|
230
|
-
s = ""
|
231
250
|
s_trail = ""
|
232
251
|
last_state = @state_trail.last
|
233
252
|
last_state = last_state[0] if last_state.class == Array
|
253
|
+
first = true
|
234
254
|
for st in @state_trail
|
235
255
|
st = st[0] if st.class == Array
|
236
|
-
|
256
|
+
if first
|
257
|
+
s_trail << "[#{st.to_s}]"
|
258
|
+
else
|
259
|
+
s_trail << " #{st.to_s}"
|
260
|
+
end
|
261
|
+
first = false
|
237
262
|
end
|
238
|
-
|
263
|
+
children = ""
|
239
264
|
for cstate in last_state.children
|
240
265
|
act_s = "..."
|
241
266
|
act_s = cstate.action.to_s if cstate.action != nil
|
242
|
-
|
267
|
+
children << " #{cstate.to_s} #{act_s}\n"
|
243
268
|
end
|
244
|
-
return
|
269
|
+
return [s_trail, children]
|
245
270
|
end
|
246
271
|
|
247
272
|
# Modifies state of key binding tree (move to new state) based on received event
|
@@ -305,20 +330,6 @@ class KeyBindingTree
|
|
305
330
|
|
306
331
|
if new_state != nil
|
307
332
|
@state_trail << new_state
|
308
|
-
debug get_state_trail_str()
|
309
|
-
# # debug "CUR STATE: #{@state_trail.collect{|x| x.to_s}.join}"
|
310
|
-
# s_trail = ""
|
311
|
-
# for st in @state_trail
|
312
|
-
# st = st[0] if st.class == Array
|
313
|
-
# s_trail << " #{st.to_s}"
|
314
|
-
# end
|
315
|
-
# debug "CUR STATE: #{s_trail}"
|
316
|
-
# for cstate in new_state[0].children
|
317
|
-
# act_s = "..."
|
318
|
-
# act_s = cstate.action.to_s if cstate.action != nil
|
319
|
-
# debug " #{cstate.to_s} #{act_s}"
|
320
|
-
# end
|
321
|
-
# new_state[0].children.collect{|x|x.to_s}
|
322
333
|
end
|
323
334
|
|
324
335
|
if new_state == nil
|
@@ -359,96 +370,9 @@ class KeyBindingTree
|
|
359
370
|
end
|
360
371
|
end
|
361
372
|
|
362
|
-
|
363
|
-
end
|
364
|
-
|
365
|
-
# Receive keyboard event from Qt
|
366
|
-
def handle_key_event(event)
|
367
|
-
start_profiler
|
368
|
-
# debug "GOT KEY EVENT: #{key.inspect}"
|
369
|
-
debug "GOT KEY EVENT:: #{event} #{event[2]}"
|
370
|
-
debug "|#{event.inspect}|"
|
371
|
-
$debuginfo["cur_event"] = event
|
372
|
-
|
373
|
-
t1 = Time.now
|
374
|
-
|
375
|
-
keycode = event[0]
|
376
|
-
event_type = event[1]
|
377
|
-
modifierinfo = event[4]
|
378
|
-
|
379
|
-
event[3] = event[2]
|
380
|
-
# String representation of received key
|
381
|
-
key_str = event[2]
|
382
|
-
|
383
|
-
@modifiers.delete(Qt::Key_Alt) if event[4] & ALTMODIFIER == 0
|
384
|
-
@modifiers.delete(Qt::Key_Control) if event[4] & CONTROLMODIFIER == 0
|
385
|
-
@modifiers.delete(Qt::Key_Shift) if event[4] & SHIFTMODIFIER == 0
|
386
|
-
|
387
|
-
# Add as modifier if ctrl, alt or shift
|
388
|
-
if modifierinfo & ALTMODIFIER != 0 or modifierinfo & CONTROLMODIFIER != 0 or modifierinfo & SHIFTMODIFIER != 0
|
389
|
-
# And keypress and not already a modifier
|
390
|
-
if event_type == KEY_PRESS and !@modifiers.include?(keycode)
|
391
|
-
@modifiers << keycode
|
392
|
-
end
|
393
|
-
end
|
394
|
-
|
395
|
-
# debug "----D------------"
|
396
|
-
# debug @modifiers.inspect
|
397
|
-
# debug event.inspect
|
398
|
-
# debug event[4] & ALTMODIFIER
|
399
|
-
# debug "-----------------"
|
400
|
-
|
401
|
-
@modifiers.delete(keycode) if event_type == KEY_RELEASE
|
402
|
-
|
403
|
-
# uval = keyval_to_unicode(event[0])
|
404
|
-
# event[3] = [uval].pack('c*').force_encoding('UTF-8') #TODO: 32bit?
|
405
|
-
# debug("key_code_to_uval: uval: #{uval} uchar:#{event[3]}")
|
406
|
-
|
407
|
-
if $event_keysym_translate_table.include?(keycode)
|
408
|
-
key_str = $event_keysym_translate_table[keycode]
|
409
|
-
end
|
410
|
-
|
411
|
-
# Prefix string representation with modifiers, e.g. ctrl-shift-a
|
412
|
-
key_prefix = ""
|
413
|
-
@modifiers.each { |pressed_key|
|
414
|
-
if $event_keysym_translate_table[pressed_key]
|
415
|
-
key_prefix += $event_keysym_translate_table[pressed_key] + "-"
|
416
|
-
end
|
417
|
-
}
|
418
|
-
|
419
|
-
# Get char based on keycode
|
420
|
-
# to produce prefixed_key_str "shift-ctrl-a" instead of "shift-ctrl-\x01"
|
421
|
-
key_str2 = key_str
|
422
|
-
if $translate_table.include?(keycode)
|
423
|
-
key_str2 = $translate_table[keycode].downcase
|
424
|
-
end
|
425
|
-
# debug "key_str=|#{key_str}| key_str=|#{key_str.inspect}| key_str2=|#{key_str2}|"
|
426
|
-
prefixed_key_str = key_prefix + key_str2
|
427
|
-
|
428
|
-
# Space is only key in $event_keysym_translate_table
|
429
|
-
# which is representable by single char
|
430
|
-
key_str = " " if key_str == "space" # HACK
|
373
|
+
show_state_trail #TODO: check if changed
|
431
374
|
|
432
|
-
|
433
|
-
# debug "KEY! key_str=|#{key_str}| prefixed_key_str=|#{prefixed_key_str}|"
|
434
|
-
# end
|
435
|
-
|
436
|
-
if key_str != "" or prefixed_key_str != ""
|
437
|
-
if keycode == @last_event[0] and event_type == KEY_RELEASE
|
438
|
-
# If key is released immediately after pressed with no other events between
|
439
|
-
match_key_conf(key_str + "!", prefixed_key_str + "!", event_type)
|
440
|
-
elsif event_type == KEY_PRESS
|
441
|
-
match_key_conf(key_str, prefixed_key_str, event_type)
|
442
|
-
end
|
443
|
-
@last_event = event #TODO: outside if?
|
444
|
-
end
|
445
|
-
|
446
|
-
# gui_refresh_cursor
|
447
|
-
|
448
|
-
event_handle_time = Time.now - t1
|
449
|
-
debug "RB key event handle time: #{event_handle_time}" if event_handle_time > 1 / 40.0
|
450
|
-
render_buffer($buffer)
|
451
|
-
end_profiler
|
375
|
+
return true
|
452
376
|
end
|
453
377
|
|
454
378
|
def bindkey(key, action)
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
bindkey ["VCB M","B m"], :run_last_macro
|
1
|
+
bindkey ["VCB M", "B m"], :run_last_macro
|
3
2
|
|
4
3
|
bindkey "VC s", :easy_jump
|
5
|
-
bindkey "VC , m f", [:find_macro_gui, proc{$macro.find_macro_gui}, "Find named macro"]
|
6
|
-
bindkey "C , m n", [:gui_name_macro, proc{$macro.gui_name_macro}, "Name last macro"]
|
4
|
+
bindkey "VC , m f", [:find_macro_gui, proc { $macro.find_macro_gui }, "Find named macro"]
|
5
|
+
bindkey "C , m n", [:gui_name_macro, proc { $macro.gui_name_macro }, "Name last macro"]
|
7
6
|
bindkey "C , j r", :jump_to_random
|
8
7
|
bindkey "I enter", :insert_new_line
|
9
8
|
bindkey "C , ; s k", :show_key_bindings #TODO: better binding
|
@@ -35,8 +34,8 @@ bindkey "C , b", :start_buf_manager
|
|
35
34
|
bindkey "CI ctrl-o", :open_file_dialog
|
36
35
|
# bindkey "M enter", :minibuffer_end
|
37
36
|
bindkey "C , a", :ack_search
|
38
|
-
bindkey
|
39
|
-
bindkey
|
37
|
+
bindkey "C d w", :delete_to_word_end
|
38
|
+
bindkey "C d 0", :delete_to_line_start
|
40
39
|
bindkey "C , , f", :file_finder
|
41
40
|
bindkey "VC h", :e_move_backward_char
|
42
41
|
bindkey "C , , .", :backup_all_buffers
|
@@ -62,11 +61,11 @@ bindkey "C , g", :invoke_grep_search
|
|
62
61
|
bindkey "C , v", :auto_indent_buffer
|
63
62
|
bindkey "C , , d", :savedebug
|
64
63
|
bindkey "C , , u", :update_file_index
|
65
|
-
bindkey "C , s a", :buf_save_as
|
66
|
-
bindkey "C d d", [:delete_line, proc{buf.delete_line}, "Delete current line"]
|
67
|
-
bindkey "C enter || C return",
|
68
|
-
bindkey
|
69
|
-
bindkey
|
64
|
+
bindkey "C , s a", :buf_save_as
|
65
|
+
bindkey "C d d", [:delete_line, proc { buf.delete_line }, "Delete current line"]
|
66
|
+
bindkey "C enter || C return", [:line_action, proc { buf.handle_line_action() }, "Line action"]
|
67
|
+
bindkey "C p", [:paste_after, proc { buf.paste(AFTER) }, ""] # TODO: implement as replace for visual mode
|
68
|
+
bindkey "V d", [:delete_selection, proc { buf.delete(SELECTION) }, ""]
|
70
69
|
|
71
70
|
default_keys = {
|
72
71
|
|
@@ -84,7 +83,6 @@ default_keys = {
|
|
84
83
|
# "C , , ." => "backup_all_buffers()",
|
85
84
|
"VC , , s" => :search_actions,
|
86
85
|
|
87
|
-
|
88
86
|
# MOVING
|
89
87
|
# 'VC h' => 'buf.move(BACKWARD_CHAR)',
|
90
88
|
"VC l" => "buf.move(FORWARD_CHAR)",
|
@@ -107,7 +105,7 @@ default_keys = {
|
|
107
105
|
"VC F <char>" => "buf.jump_to_next_instance_of_char(<char>,BACKWARD)",
|
108
106
|
"VC f space" => "buf.jump_to_next_instance_of_char(' ')",
|
109
107
|
"VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
|
110
|
-
|
108
|
+
|
111
109
|
"VC /[1-9]/" => "set_next_command_count(<char>)",
|
112
110
|
# 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
|
113
111
|
# 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
|
@@ -133,6 +131,9 @@ default_keys = {
|
|
133
131
|
"C n" => "$search.jump_to_next()",
|
134
132
|
"C N" => "$search.jump_to_previous()",
|
135
133
|
|
134
|
+
|
135
|
+
"C C" => :content_search,
|
136
|
+
|
136
137
|
# Debug
|
137
138
|
"C , d r p" => "start_ripl",
|
138
139
|
"C , D" => "debug_print_buffer",
|
@@ -191,11 +192,14 @@ default_keys = {
|
|
191
192
|
"V ctrl!" => "buf.end_visual_mode",
|
192
193
|
"V y" => "buf.copy_active_selection()",
|
193
194
|
"V a y" => "buf.copy_active_selection(:append)",
|
194
|
-
"V g U" =>
|
195
|
-
"V g u" =>
|
196
|
-
"V g c" =>
|
197
|
-
"V g s" =>
|
198
|
-
"V g r" =>
|
195
|
+
"V g U" => :selection_upcase,
|
196
|
+
"V g u" => :selection_downcase,
|
197
|
+
"V g c" => :selection_capitalize,
|
198
|
+
"V g s" => :selection_swapcase,
|
199
|
+
"V g r" => :selection_reverse,
|
200
|
+
|
201
|
+
"VC j" => :forward_line,
|
202
|
+
"VC k" => :backward_line,
|
199
203
|
|
200
204
|
"V x" => "buf.delete(SELECTION)",
|
201
205
|
# "V ctrl-c" => "buf.comment_selection",
|
@@ -215,15 +219,15 @@ default_keys = {
|
|
215
219
|
# Macros
|
216
220
|
# (experimental, may not work correctly)
|
217
221
|
# "C q a" => '$macro.start_recording("a")',
|
218
|
-
"VC q <char>" =>
|
222
|
+
"VC q <char>" => "$macro.start_recording(<char>)",
|
219
223
|
"VC q($macro.is_recording==true) " => "$macro.end_recording", # TODO
|
220
224
|
# 'C q'=> '$macro.end_recording', #TODO
|
221
225
|
"C q v" => "$macro.end_recording",
|
222
226
|
# 'C v'=> '$macro.end_recording',
|
223
227
|
# "C M" => '$macro.run_last_macro',
|
224
|
-
"C @ <char>" =>
|
228
|
+
"C @ <char>" => "$macro.run_macro(<char>)",
|
225
229
|
"C , m S" => '$macro.save_macro("a")',
|
226
|
-
"C , m s" =>
|
230
|
+
"C , m s" => "$macro.save",
|
227
231
|
"C , t r" => "run_tests()",
|
228
232
|
|
229
233
|
# "C ." => "repeat_last_action", # TODO
|
@@ -256,5 +260,3 @@ default_keys = {
|
|
256
260
|
default_keys.each { |key, value|
|
257
261
|
bindkey(key, value)
|
258
262
|
}
|
259
|
-
|
260
|
-
|
data/lib/vimamsa/rbvma.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
require "gtk3"
|
2
|
-
require "gtksourceview3"
|
3
1
|
#require "gtksourceview4"
|
4
|
-
require "ripl"
|
5
|
-
require "fileutils"
|
6
|
-
require "pathname"
|
7
2
|
require "date"
|
8
|
-
require "
|
3
|
+
require "fileutils"
|
4
|
+
require "gtk3"
|
5
|
+
require "gtksourceview4"
|
9
6
|
require "json"
|
10
7
|
require "listen"
|
8
|
+
require "pathname"
|
9
|
+
require "ripl"
|
10
|
+
require "ripl/multi_line"
|
11
|
+
require "shellwords"
|
12
|
+
require "cgi"
|
11
13
|
|
12
14
|
require "vimamsa/util"
|
13
15
|
require "vimamsa/main"
|
@@ -16,11 +18,13 @@ require "vimamsa/actions"
|
|
16
18
|
require "vimamsa/key_binding_tree"
|
17
19
|
require "vimamsa/key_actions"
|
18
20
|
|
19
|
-
|
21
|
+
# Graphical stuff:
|
20
22
|
require "vimamsa/gui"
|
21
23
|
require "vimamsa/gui_menu"
|
22
24
|
require "vimamsa/gui_select_window"
|
23
25
|
require "vimamsa/gui_sourceview"
|
26
|
+
require "vimamsa/gui_image"
|
27
|
+
require "vimamsa/hyper_plain_text"
|
24
28
|
|
25
29
|
require "vimamsa/ack"
|
26
30
|
require "vimamsa/buffer"
|
@@ -33,7 +37,6 @@ require "vimamsa/encrypt"
|
|
33
37
|
require "vimamsa/file_finder"
|
34
38
|
require "vimamsa/file_manager"
|
35
39
|
require "vimamsa/hook"
|
36
|
-
require "vimamsa/hyper_plain_text"
|
37
40
|
require "vimamsa/macro"
|
38
41
|
require "vimamsa/search"
|
39
42
|
require "vimamsa/search_replace"
|
@@ -57,7 +60,7 @@ $debug = false
|
|
57
60
|
|
58
61
|
def scan_indexes(txt, regex)
|
59
62
|
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
60
|
-
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0)
|
63
|
+
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
61
64
|
return indexes
|
62
65
|
end
|
63
66
|
|
@@ -52,7 +52,7 @@ class FileSelector
|
|
52
52
|
if File.directory?(fn)
|
53
53
|
debug "CHDIR: #{fn}"
|
54
54
|
dir_to_buf(fn)
|
55
|
-
|
55
|
+
# elsif vma.can_open_extension?(fn) #TODO: remove this check?
|
56
56
|
# jump_to_file(fn)
|
57
57
|
elsif file_is_text_file(fn)
|
58
58
|
jump_to_file(fn)
|
@@ -103,8 +103,8 @@ def invoke_grep_search()
|
|
103
103
|
start_minibuffer_cmd("", "", :grep_cur_buffer)
|
104
104
|
end
|
105
105
|
|
106
|
-
def gui_one_input_action(title, field_label, button_title, callback)
|
107
|
-
a = OneInputAction.new(nil, title, field_label, button_title, callback)
|
106
|
+
def gui_one_input_action(title, field_label, button_title, callback,opt={})
|
107
|
+
a = OneInputAction.new(nil, title, field_label, button_title, callback,opt)
|
108
108
|
a.run
|
109
109
|
return
|
110
110
|
end
|
@@ -262,7 +262,7 @@ class PopupFormGenerator
|
|
262
262
|
end
|
263
263
|
|
264
264
|
class OneInputAction
|
265
|
-
def initialize(main_window, title, field_label, button_title, callback)
|
265
|
+
def initialize(main_window, title, field_label, button_title, callback, opt = {})
|
266
266
|
@window = Gtk::Window.new(:toplevel)
|
267
267
|
# @window.screen = main_window.screen
|
268
268
|
# @window.title = title
|
@@ -291,6 +291,10 @@ class OneInputAction
|
|
291
291
|
|
292
292
|
@entry1 = Gtk::Entry.new
|
293
293
|
|
294
|
+
if opt[:hide]
|
295
|
+
@entry1.visibility = false
|
296
|
+
end
|
297
|
+
|
294
298
|
button.signal_connect "clicked" do
|
295
299
|
callback.call(@entry1.text)
|
296
300
|
@window.destroy
|
data/lib/vimamsa/util.rb
CHANGED
@@ -3,6 +3,40 @@
|
|
3
3
|
# Cross-platform way of finding an executable in the $PATH.
|
4
4
|
#
|
5
5
|
# which('ruby') #=> /usr/bin/ruby
|
6
|
+
|
7
|
+
|
8
|
+
# Execute proc after wait_time seconds after last .run call.
|
9
|
+
# Used for image scaling after window resize
|
10
|
+
class DelayExecutioner
|
11
|
+
def initialize(wait_time, _proc)
|
12
|
+
@wait_time = wait_time
|
13
|
+
@proc = _proc
|
14
|
+
@lastt = Time.now
|
15
|
+
@thread_running = false
|
16
|
+
end
|
17
|
+
|
18
|
+
def start_thread
|
19
|
+
Thread.new {
|
20
|
+
while true
|
21
|
+
sleep 0.1
|
22
|
+
if Time.now - @lastt > @wait_time
|
23
|
+
@proc.call
|
24
|
+
@thread_running = false
|
25
|
+
break
|
26
|
+
end
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def run()
|
32
|
+
@lastt = Time.now
|
33
|
+
if @thread_running == false
|
34
|
+
@thread_running = true
|
35
|
+
start_thread
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
6
40
|
def which(cmd)
|
7
41
|
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
8
42
|
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
data/lib/vimamsa/version.rb
CHANGED
data/lib/vimamsa.rb
CHANGED
data/sheep.jpg
ADDED
Binary file
|