vimamsa 0.1.10 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -3
- data/custom_example.rb +11 -1
- data/demo.txt +2 -2
- data/exe/vimamsa +1 -4
- data/lib/vimamsa/ack.rb +57 -9
- data/lib/vimamsa/actions.rb +1 -1
- data/lib/vimamsa/buffer.rb +270 -45
- data/lib/vimamsa/buffer_list.rb +57 -16
- data/lib/vimamsa/buffer_manager.rb +21 -4
- data/lib/vimamsa/conf.rb +10 -1
- data/lib/vimamsa/debug.rb +7 -3
- data/lib/vimamsa/easy_jump.rb +10 -6
- data/lib/vimamsa/editor.rb +57 -43
- data/lib/vimamsa/file_finder.rb +69 -71
- data/lib/vimamsa/file_history.rb +2 -3
- data/lib/vimamsa/file_manager.rb +1 -1
- data/lib/vimamsa/form_generator.rb +122 -0
- data/lib/vimamsa/gui.rb +518 -180
- data/lib/vimamsa/gui_image.rb +12 -6
- data/lib/vimamsa/gui_menu.rb +29 -20
- data/lib/vimamsa/gui_select_window.rb +40 -21
- data/lib/vimamsa/gui_sourceview.rb +264 -86
- data/lib/vimamsa/hyper_plain_text.rb +34 -1
- data/lib/vimamsa/key_actions.rb +13 -1
- data/lib/vimamsa/key_binding_tree.rb +26 -14
- data/lib/vimamsa/key_bindings_vimlike.rb +56 -26
- data/lib/vimamsa/langservp.rb +172 -0
- data/lib/vimamsa/macro.rb +9 -8
- data/lib/vimamsa/main.rb +0 -1
- data/lib/vimamsa/rbvma.rb +7 -4
- data/lib/vimamsa/search.rb +2 -1
- data/lib/vimamsa/search_replace.rb +36 -106
- data/lib/vimamsa/util.rb +55 -1
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +1 -6
- data/styles/molokai_edit.xml +3 -0
- data/vimamsa.gemspec +10 -10
- metadata +24 -22
@@ -1,73 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
# class VSourceView < Gtk::TextView
|
4
2
|
class VSourceView < GtkSource::View
|
5
|
-
attr_accessor :bufo
|
3
|
+
attr_accessor :bufo
|
6
4
|
# :highlight_matching_brackets
|
7
|
-
|
5
|
+
|
8
6
|
# def set_highlight_current_line(vbool)
|
9
7
|
# end
|
10
|
-
|
8
|
+
|
11
9
|
# def set_show_line_numbers(vbool)
|
12
10
|
# end
|
13
|
-
|
11
|
+
|
14
12
|
# def highlight_matching_brackets=(vbool)
|
15
13
|
# end
|
16
|
-
|
17
14
|
|
18
15
|
# def initialize(title = nil,bufo=nil)
|
19
|
-
def initialize(title,bufo)
|
16
|
+
def initialize(title, bufo)
|
20
17
|
# super(:toplevel)
|
21
18
|
@highlight_matching_brackets = true
|
19
|
+
@idle_func_running = false
|
22
20
|
super()
|
23
21
|
@bufo = bufo #object of Buffer class buffer.rb
|
24
22
|
debug "vsource init"
|
25
23
|
@last_keyval = nil
|
26
24
|
@last_event = [nil, nil]
|
27
|
-
|
28
|
-
self.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
handle_drag_and_drop(fp)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
true
|
54
|
-
end
|
55
|
-
|
56
|
-
signal_connect("key_press_event") do |widget, event|
|
57
|
-
handle_key_event(event, :key_press_event)
|
58
|
-
true
|
59
|
-
end
|
60
|
-
|
61
|
-
signal_connect("key_release_event") do |widget, event|
|
62
|
-
handle_key_event(event, :key_release_event)
|
63
|
-
true
|
64
|
-
end
|
65
|
-
|
25
|
+
@removed_controllers = []
|
26
|
+
self.highlight_current_line = true
|
27
|
+
|
28
|
+
@tt = nil
|
29
|
+
|
30
|
+
# self.drag_dest_add_image_targets #TODO:gtk4
|
31
|
+
# self.drag_dest_add_uri_targets #TODO:gtk4
|
32
|
+
|
33
|
+
# signal_connect("drag-data-received") do |widget, event, x, y, data, info, time| #TODO:gtk4
|
34
|
+
# puts "drag-data-received"
|
35
|
+
# puts
|
36
|
+
# if data.uris.size >= 1
|
37
|
+
# imgpath = CGI.unescape(data.uris[0])
|
38
|
+
# m = imgpath.match(/^file:\/\/(.*)/)
|
39
|
+
# if m
|
40
|
+
# fp = m[1]
|
41
|
+
# handle_drag_and_drop(fp)
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
# true
|
45
|
+
# end
|
46
|
+
|
47
|
+
# Mainly after page-up or page-down
|
66
48
|
signal_connect("move-cursor") do |widget, event|
|
49
|
+
debug("MOVE-CURSOR", 2)
|
67
50
|
$update_cursor = true
|
51
|
+
# handle_scrolling()
|
52
|
+
# curpos = buffer.cursor_position
|
53
|
+
# debug "MOVE CURSOR (sig): #{curpos}"
|
54
|
+
|
55
|
+
# run_as_idle proc {
|
56
|
+
# curpos = buffer.cursor_position
|
57
|
+
# debug "MOVE CURSOR (sig2): #{curpos}"
|
58
|
+
# }
|
59
|
+
|
68
60
|
false
|
69
61
|
end
|
70
62
|
|
63
|
+
return
|
64
|
+
|
65
|
+
#TODO:gtk4
|
71
66
|
signal_connect "button-release-event" do |widget, event|
|
72
67
|
vma.buf.set_pos(buffer.cursor_position)
|
73
68
|
false
|
@@ -75,23 +70,129 @@ class VSourceView < GtkSource::View
|
|
75
70
|
@curpos_mark = nil
|
76
71
|
end
|
77
72
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
73
|
+
def gutter_width()
|
74
|
+
winwidth = width
|
75
|
+
view_width = visible_rect.width
|
76
|
+
gutter_width = winwidth - view_width
|
77
|
+
end
|
78
|
+
|
79
|
+
def show_controllers
|
80
|
+
clist = self.observe_controllers
|
81
|
+
(0..(clist.n_items - 1)).each { |x|
|
82
|
+
ctr = clist.get_item(x)
|
83
|
+
pp ctr
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
def check_controllers
|
88
|
+
clist = self.observe_controllers
|
89
|
+
to_remove = []
|
90
|
+
(0..(clist.n_items - 1)).each { |x|
|
91
|
+
ctr = clist.get_item(x)
|
92
|
+
# Sometimes a GestureClick EventController appears from somewhere
|
93
|
+
# not initiated from this file.
|
94
|
+
|
95
|
+
# if ctr.class == Gtk::EventControllerKey or ctr.class == Gtk::GestureClick
|
96
|
+
if ctr != @click
|
97
|
+
# to_remove << ctr if ctr.class != Gtk::GestureDrag
|
98
|
+
to_remove << ctr
|
99
|
+
end
|
100
|
+
}
|
101
|
+
if to_remove.size > 0
|
102
|
+
debug "Removing controllers:"
|
103
|
+
pp to_remove
|
104
|
+
to_remove.each { |x|
|
105
|
+
# To avoid GC. https://github.com/ruby-gnome/ruby-gnome/issues/15790
|
106
|
+
@removed_controllers << x
|
107
|
+
self.remove_controller(x)
|
108
|
+
}
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def register_signals()
|
113
|
+
|
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
|
119
|
+
|
120
|
+
check_controllers
|
121
|
+
click = Gtk::GestureClick.new
|
122
|
+
click.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
|
123
|
+
self.add_controller(click)
|
124
|
+
# Detect mouse click
|
125
|
+
@click = click
|
126
|
+
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
|
132
|
+
|
133
|
+
xloc = (x - gutter_width).to_i
|
134
|
+
yloc = (y + visible_rect.y).to_i
|
135
|
+
debug "xloc=#{xloc} yloc=#{yloc}"
|
136
|
+
|
137
|
+
# This needs to happen after xloc calculation, otherwise xloc gets a wrong value (around 200 bigger)
|
138
|
+
if vma.gui.current_view != self
|
139
|
+
vma.gui.set_current_view(self)
|
140
|
+
end
|
141
|
+
|
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
|
148
|
+
end
|
149
|
+
|
150
|
+
true
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def handle_scrolling()
|
155
|
+
delete_cursorchar
|
156
|
+
# curpos = buffer.cursor_position
|
157
|
+
# debug "MOVE CURSOR: #{curpos}"
|
158
|
+
return nil if vma.gui.nil?
|
159
|
+
return nil if @bufo.nil?
|
160
|
+
vma.gui.run_after_scrolling proc {
|
161
|
+
delete_cursorchar
|
162
|
+
bc = window_to_buffer_coords(Gtk::TextWindowType::WIDGET, gutter_width + 2, 60)
|
163
|
+
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
|
171
|
+
if !i.nil?
|
172
|
+
@bufo.set_pos(i.offset)
|
173
|
+
end
|
174
|
+
end
|
83
175
|
$update_cursor = false
|
176
|
+
}
|
177
|
+
end
|
178
|
+
|
179
|
+
# def handle_key_event(event, sig)
|
180
|
+
def handle_key_event(keyval, keyname, sig)
|
181
|
+
delete_cursorchar
|
182
|
+
if $update_cursor
|
183
|
+
handle_scrolling
|
84
184
|
end
|
85
185
|
debug $view.visible_rect.inspect
|
86
186
|
|
87
187
|
debug "key event"
|
88
|
-
debug event
|
188
|
+
# debug event
|
89
189
|
|
90
|
-
key_name = event.string
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
190
|
+
# key_name = event.string
|
191
|
+
#TODO:??
|
192
|
+
# if event.state.control_mask?
|
193
|
+
# key_name = Gdk::Keyval.to_name(event.keyval)
|
194
|
+
# Gdk::Keyval.to_name()
|
195
|
+
# end
|
95
196
|
|
96
197
|
keyval_trans = {}
|
97
198
|
keyval_trans[Gdk::Keyval::KEY_Control_L] = "ctrl"
|
@@ -122,29 +223,48 @@ class VSourceView < GtkSource::View
|
|
122
223
|
|
123
224
|
key_trans = {}
|
124
225
|
key_trans["\e"] = "esc"
|
125
|
-
tk = keyval_trans[
|
126
|
-
|
226
|
+
tk = keyval_trans[keyval]
|
227
|
+
keyname = tk if !tk.nil?
|
127
228
|
|
128
229
|
key_str_parts = []
|
129
|
-
key_str_parts << "ctrl" if
|
130
|
-
key_str_parts << "alt" if
|
230
|
+
key_str_parts << "ctrl" if vma.kbd.modifiers[:ctrl]
|
231
|
+
key_str_parts << "alt" if vma.kbd.modifiers[:alt]
|
232
|
+
key_str_parts << "shift" if vma.kbd.modifiers[:shift]
|
233
|
+
key_str_parts << "meta" if vma.kbd.modifiers[:meta]
|
234
|
+
key_str_parts << "super" if vma.kbd.modifiers[:super]
|
235
|
+
key_str_parts << keyname
|
236
|
+
|
237
|
+
if key_str_parts[0] == key_str_parts[1]
|
238
|
+
# We don't want "ctrl-ctrl" or "alt-alt"
|
239
|
+
# TODO:There should be a better way to do this
|
240
|
+
key_str_parts.delete_at(0)
|
241
|
+
end
|
242
|
+
|
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)
|
247
|
+
end
|
131
248
|
|
132
|
-
key_str_parts << key_name
|
133
249
|
key_str = key_str_parts.join("-")
|
134
|
-
|
250
|
+
if key_str == "\u0000"
|
251
|
+
key_str = ""
|
252
|
+
end
|
253
|
+
|
254
|
+
keynfo = { :key_str => key_str, :key_name => keyname, :keyval => keyval }
|
135
255
|
debug keynfo.inspect
|
136
256
|
# $kbd.match_key_conf(key_str, nil, :key_press)
|
137
257
|
# debug "key_str=#{key_str} key_"
|
138
258
|
|
139
259
|
if key_str != "" # or prefixed_key_str != ""
|
140
|
-
if sig == :
|
260
|
+
if sig == :key_release and keyval == @last_keyval
|
141
261
|
$kbd.match_key_conf(key_str + "!", nil, :key_release)
|
142
|
-
@last_event = [
|
143
|
-
elsif sig == :
|
262
|
+
@last_event = [keynfo, :key_release]
|
263
|
+
elsif sig == :key_press
|
144
264
|
$kbd.match_key_conf(key_str, nil, :key_press)
|
145
|
-
@last_event = [
|
265
|
+
@last_event = [keynfo, key_str, :key_press]
|
146
266
|
end
|
147
|
-
@last_keyval =
|
267
|
+
@last_keyval = keyval #TODO: outside if?
|
148
268
|
end
|
149
269
|
|
150
270
|
handle_deltas
|
@@ -152,15 +272,17 @@ class VSourceView < GtkSource::View
|
|
152
272
|
# set_focus(5)
|
153
273
|
# false
|
154
274
|
|
275
|
+
draw_cursor #TODO: only when needed
|
155
276
|
end
|
156
277
|
|
157
278
|
def pos_to_coord(i)
|
158
279
|
b = buffer
|
159
280
|
iter = b.get_iter_at(:offset => i)
|
160
281
|
iterxy = get_iter_location(iter)
|
161
|
-
winw =
|
282
|
+
winw = width #TODO
|
283
|
+
|
162
284
|
view_width = visible_rect.width
|
163
|
-
gutter_width = winw - view_width
|
285
|
+
gutter_width = winw - view_width #TODO
|
164
286
|
|
165
287
|
x = iterxy.x + gutter_width
|
166
288
|
y = iterxy.y
|
@@ -168,12 +290,12 @@ class VSourceView < GtkSource::View
|
|
168
290
|
# buffer_to_window_coords(Gtk::TextWindowType::TEXT, iterxy.x, iterxy.y).inspect
|
169
291
|
# debug buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y).inspect
|
170
292
|
(x, y) = buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y)
|
171
|
-
# Ripl.start :binding => binding
|
172
293
|
|
173
294
|
return [x, y]
|
174
295
|
end
|
175
296
|
|
176
297
|
def handle_deltas()
|
298
|
+
delete_cursorchar
|
177
299
|
any_change = false
|
178
300
|
while d = @bufo.deltas.shift
|
179
301
|
any_change = true
|
@@ -191,7 +313,8 @@ class VSourceView < GtkSource::View
|
|
191
313
|
end
|
192
314
|
end
|
193
315
|
if any_change
|
194
|
-
|
316
|
+
#TODO: only when necessary
|
317
|
+
self.set_cursor_pos(pos)
|
195
318
|
end
|
196
319
|
|
197
320
|
# sanity_check #TODO
|
@@ -213,6 +336,7 @@ class VSourceView < GtkSource::View
|
|
213
336
|
end
|
214
337
|
|
215
338
|
def set_cursor_pos(pos)
|
339
|
+
delete_cursorchar
|
216
340
|
# return
|
217
341
|
itr = buffer.get_iter_at(:offset => pos)
|
218
342
|
itr2 = buffer.get_iter_at(:offset => pos + 1)
|
@@ -237,7 +361,6 @@ class VSourceView < GtkSource::View
|
|
237
361
|
# scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
|
238
362
|
|
239
363
|
# $view.signal_emit("extend-selection", Gtk::TextExtendSelection.new, itr,itr,itr2)
|
240
|
-
# Ripl.start :binding => binding
|
241
364
|
draw_cursor
|
242
365
|
|
243
366
|
return true
|
@@ -252,6 +375,9 @@ class VSourceView < GtkSource::View
|
|
252
375
|
# iter = buffer.get_iter_at(:offset => buffer.cursor_position)
|
253
376
|
# iterxy = get_iter_location(iter)
|
254
377
|
|
378
|
+
# This is not the current buffer
|
379
|
+
return false if vma.gui.view != self
|
380
|
+
|
255
381
|
sleep(0.01)
|
256
382
|
# intr = iterxy.intersect(vr)
|
257
383
|
if is_cursor_visible == false
|
@@ -266,8 +392,9 @@ class VSourceView < GtkSource::View
|
|
266
392
|
|
267
393
|
scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
|
268
394
|
|
269
|
-
|
395
|
+
return true # Call this func again
|
270
396
|
else
|
397
|
+
@idle_func_running = false
|
271
398
|
return false # Don't call this idle func again
|
272
399
|
end
|
273
400
|
end
|
@@ -283,9 +410,6 @@ class VSourceView < GtkSource::View
|
|
283
410
|
if intr.nil?
|
284
411
|
debug iterxy.inspect
|
285
412
|
debug vr.inspect
|
286
|
-
# Ripl.start :binding => binding
|
287
|
-
|
288
|
-
# exit!
|
289
413
|
return false
|
290
414
|
else
|
291
415
|
return true
|
@@ -293,7 +417,12 @@ class VSourceView < GtkSource::View
|
|
293
417
|
end
|
294
418
|
|
295
419
|
def ensure_cursor_visible
|
420
|
+
return #TODO:gtk4
|
421
|
+
debug "@idle_func_running=#{@idle_func_running}"
|
422
|
+
return if @idle_func_running
|
296
423
|
if is_cursor_visible == false
|
424
|
+
@idle_func_running = true
|
425
|
+
debug "Starting idle func"
|
297
426
|
Thread.new {
|
298
427
|
sleep 0.01
|
299
428
|
GLib::Idle.add(proc { cursor_visible_idle_func })
|
@@ -301,22 +430,71 @@ class VSourceView < GtkSource::View
|
|
301
430
|
end
|
302
431
|
end
|
303
432
|
|
433
|
+
# Delete the extra char added to buffer to represent the cursor
|
434
|
+
def delete_cursorchar
|
435
|
+
if !@cursorchar.nil?
|
436
|
+
itr = buffer.get_iter_at(:offset => @cursorchar)
|
437
|
+
itr2 = buffer.get_iter_at(:offset => @cursorchar + 1)
|
438
|
+
buffer.delete(itr, itr2)
|
439
|
+
@cursorchar = nil
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
304
443
|
def draw_cursor
|
305
|
-
if
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
444
|
+
# if @tt.nil?
|
445
|
+
# @tt = buffer.create_tag("font_tag")
|
446
|
+
# @tt.font = "Arial"
|
447
|
+
# end
|
448
|
+
|
449
|
+
mode = vma.kbd.get_mode
|
450
|
+
ctype = vma.kbd.get_cursor_type
|
451
|
+
delete_cursorchar
|
452
|
+
vma.gui.remove_overlay_cursor
|
453
|
+
if ctype == :command
|
454
|
+
if @bufo[@bufo.pos] == "\n"
|
455
|
+
# If we are at end of line, it's not possible to draw the cursor by making a selection. I tried to do this by drawing an overlay, but that generates issues. If moving the cursor causes the ScrolledWindow to be scrolled, these errors randomly appear and the whole view shows blank:
|
456
|
+
# (ruby:21016): Gtk-WARNING **: 19:52:23.181: Trying to snapshot GtkSourceView 0x55a97524c8c0 without a current allocation
|
457
|
+
# (ruby:21016): Gtk-WARNING **: 19:52:23.181: Trying to snapshot GtkGizmo 0x55a9727d2580 without a current allocation
|
458
|
+
# (ruby:21016): Gtk-WARNING **: 19:52:23.243: Trying to snapshot GtkSourceView 0x55a97524c8c0 without a current allocation
|
459
|
+
# vma.gui.overlay_draw_cursor(@bufo.pos)
|
460
|
+
|
461
|
+
# Current workaround is to add an empty space to the place where the cursor is and then remove this whenever we get any kind of event that might cause this class to be accessed.
|
462
|
+
itr = buffer.get_iter_at(:offset => @bufo.pos)
|
463
|
+
buffer.insert(itr, " ") # normal space
|
464
|
+
# buffer.insert(itr, " ") # thin space (U+2009)
|
465
|
+
# buffer.insert(itr, "l")
|
466
|
+
@cursorchar = @bufo.pos
|
467
|
+
|
468
|
+
# Apparently we need to redo this after buffer.insert:
|
469
|
+
itr = buffer.get_iter_at(:offset => @bufo.pos)
|
470
|
+
itr2 = buffer.get_iter_at(:offset => @bufo.pos + 1)
|
471
|
+
# buffer.apply_tag(@tt, itr, itr2)
|
472
|
+
buffer.select_range(itr, itr2)
|
473
|
+
else
|
474
|
+
itr = buffer.get_iter_at(:offset => @bufo.pos)
|
475
|
+
itr2 = buffer.get_iter_at(:offset => @bufo.pos + 1)
|
476
|
+
buffer.select_range(itr, itr2)
|
477
|
+
end
|
478
|
+
# elsif @bufo.visual_mode?
|
479
|
+
elsif ctype == :visual
|
310
480
|
debug "VISUAL MODE"
|
311
481
|
(_start, _end) = @bufo.get_visual_mode_range2
|
312
482
|
debug "#{_start}, #{_end}"
|
313
483
|
itr = buffer.get_iter_at(:offset => _start)
|
314
484
|
itr2 = buffer.get_iter_at(:offset => _end + 1)
|
315
|
-
|
316
|
-
|
485
|
+
# Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed
|
486
|
+
buffer.select_range(itr, itr2)
|
487
|
+
elsif ctype == :insert
|
488
|
+
# Not sure why this is needed
|
317
489
|
itr = buffer.get_iter_at(:offset => @bufo.pos)
|
318
|
-
|
490
|
+
buffer.select_range(itr, itr)
|
491
|
+
|
492
|
+
# Via trial and error, this combination is only thing that seems to work:
|
493
|
+
vma.gui.sw.child.toggle_cursor_visible
|
494
|
+
vma.gui.sw.child.cursor_visible = true
|
495
|
+
|
319
496
|
debug "INSERT MODE"
|
497
|
+
else # TODO
|
320
498
|
end
|
321
499
|
end
|
322
500
|
end
|
@@ -51,6 +51,35 @@ def translate_path(fn, bf)
|
|
51
51
|
return outfn
|
52
52
|
end
|
53
53
|
|
54
|
+
# Scan audio files inserted with ⟦audio:filepath⟧ syntax
|
55
|
+
#TODO: merge code with hpt_scan_images
|
56
|
+
def hpt_scan_audio(bf = nil)
|
57
|
+
bf = buf() if bf.nil?
|
58
|
+
return if bf.nil?
|
59
|
+
return if !bf.fname
|
60
|
+
return if !bf.fname.match(/.*txt$/)
|
61
|
+
imgpos = scan_indexes(bf, /⟦audio:.+?⟧/)
|
62
|
+
imgtags = bf.scan(/(⟦audio:(.+?)⟧)/)
|
63
|
+
c = 0
|
64
|
+
imgpos.each.with_index { |x, i|
|
65
|
+
a = imgpos[i]
|
66
|
+
t = imgtags[i]
|
67
|
+
insert_pos = a + t[0].size + c
|
68
|
+
fn = t[1]
|
69
|
+
imgfn = translate_path(fn, bf)
|
70
|
+
next if !File.exist?(imgfn)
|
71
|
+
# Show as image in gui, handle as empty space in txt file
|
72
|
+
|
73
|
+
if bf[insert_pos..(insert_pos + 2)] != "\n \n"
|
74
|
+
bf.insert_txt_at("\n \n", insert_pos)
|
75
|
+
bf.view.handle_deltas
|
76
|
+
c += 3
|
77
|
+
end
|
78
|
+
bf.add_audio(imgfn, insert_pos + 1)
|
79
|
+
}
|
80
|
+
# vma.gui.delex.run #TODO:gtk4
|
81
|
+
end
|
82
|
+
|
54
83
|
# Scan images inserted with ⟦img:filepath⟧ syntax
|
55
84
|
def hpt_scan_images(bf = nil)
|
56
85
|
bf = buf() if bf.nil?
|
@@ -76,5 +105,9 @@ def hpt_scan_images(bf = nil)
|
|
76
105
|
end
|
77
106
|
bf.add_image(imgfn, insert_pos + 1)
|
78
107
|
}
|
79
|
-
|
108
|
+
|
109
|
+
# Need to scale after buffer loaded
|
110
|
+
GLib::Idle.add(proc { vma.gui.scale_all_images })
|
111
|
+
|
112
|
+
# vma.gui.delex.run #TODO:gtk4
|
80
113
|
end
|
data/lib/vimamsa/key_actions.rb
CHANGED
@@ -28,6 +28,9 @@ def is_visual_mode()
|
|
28
28
|
return 0
|
29
29
|
end
|
30
30
|
|
31
|
+
reg_act(:lsp_debug, proc { vma.buf.lsp_get_def }, "LSP get definition")
|
32
|
+
reg_act(:lsp_jump_to_definition, proc { vma.buf.lsp_jump_to_def }, "LSP jump to definition")
|
33
|
+
|
31
34
|
reg_act(:enable_debug, proc { $debug = true }, "Enable debug")
|
32
35
|
reg_act(:disable_debug, proc { $debug = false }, "Disable debug")
|
33
36
|
|
@@ -48,6 +51,8 @@ reg_act(:jump_to_random, proc { buf.jump_to_random_pos }, "")
|
|
48
51
|
reg_act(:insert_new_line, proc { buf.insert_new_line() }, "")
|
49
52
|
reg_act(:show_key_bindings, proc { show_key_bindings }, "Show key bindings")
|
50
53
|
reg_act(:put_file_path_to_clipboard, proc { buf.put_file_path_to_clipboard }, "Put file path of current file to clipboard")
|
54
|
+
reg_act(:put_file_ref_to_clipboard, proc { buf.put_file_ref_to_clipboard }, "Put file ref of current file to clipboard")
|
55
|
+
|
51
56
|
# reg_act(:encrypt_file, proc{buf.set_encrypted},"Set current file to encrypt on save")
|
52
57
|
reg_act(:encrypt_file, proc { encrypt_cur_buffer }, "Set current file to encrypt on save")
|
53
58
|
reg_act(:set_unencrypted, proc { buf.set_unencrypted }, "Set current file to save unencrypted")
|
@@ -80,8 +85,9 @@ reg_act(:diff_buffer, "diff_buffer", "")
|
|
80
85
|
# reg_act(:invoke_grep_search, proc{invoke_grep_search}, "")
|
81
86
|
reg_act(:invoke_grep_search, proc { gui_grep }, "Grep current buffer")
|
82
87
|
reg_act(:ack_search, proc { gui_ack }, "") #invoke_ack_search
|
83
|
-
reg_act :update_file_index, proc {
|
88
|
+
reg_act :update_file_index, proc { FileFinder.update_index }, "Update file index"
|
84
89
|
reg_act :delete_to_word_end, proc { buf.delete2(:to_word_end) }, "Delete to file end", { :group => [:edit, :basic] }
|
90
|
+
reg_act :delete_to_next_word_start, proc { buf.delete2(:to_next_word) }, "Delete to start of next word", { :group => [:edit, :basic] }
|
85
91
|
reg_act :delete_to_line_start, proc { buf.delete2(:to_line_start) }, "Delete to line start", { :group => [:edit, :basic] }
|
86
92
|
reg_act :start_browse_mode, proc { $kbd.set_mode(:browse); $kbd.set_default_mode(:browse) }, "Start browse mode"
|
87
93
|
reg_act :exit_browse_mode, proc {
|
@@ -146,6 +152,12 @@ act_list = {
|
|
146
152
|
:search_actions => { :proc => proc { search_actions },
|
147
153
|
:desc => "Search actions", :group => :search },
|
148
154
|
|
155
|
+
:toggle_active_window => { :proc => proc { vma.gui.toggle_active_window },
|
156
|
+
:desc => "Toggle active window", :group => :search },
|
157
|
+
|
158
|
+
:toggle_two_column => { :proc => proc { vma.gui.set_two_column },
|
159
|
+
:desc => "Set two column mode", :group => :search },
|
160
|
+
|
149
161
|
:content_search => { :proc => proc { FileContentSearch.start_gui },
|
150
162
|
:desc => "Search content of files", :group => :search },
|
151
163
|
|