vimamsa 0.1.7 → 0.1.8
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/lib/vimamsa/actions.rb +6 -6
- data/lib/vimamsa/buffer.rb +69 -39
- data/lib/vimamsa/buffer_list.rb +24 -0
- data/lib/vimamsa/buffer_manager.rb +83 -0
- data/lib/vimamsa/conf.rb +21 -0
- data/lib/vimamsa/debug.rb +3 -2
- data/lib/vimamsa/easy_jump.rb +7 -7
- data/lib/vimamsa/editor.rb +24 -17
- data/lib/vimamsa/file_finder.rb +5 -6
- data/lib/vimamsa/file_history.rb +3 -3
- data/lib/vimamsa/file_manager.rb +9 -8
- data/lib/vimamsa/gui.rb +15 -17
- data/lib/vimamsa/gui_menu.rb +11 -1
- data/lib/vimamsa/gui_select_window.rb +13 -13
- data/lib/vimamsa/gui_sourceview.rb +23 -23
- data/lib/vimamsa/hyper_plain_text.rb +8 -10
- data/lib/vimamsa/key_actions.rb +4 -0
- data/lib/vimamsa/key_binding_tree.rb +27 -27
- data/lib/vimamsa/key_bindings_vimlike.rb +1 -1
- data/lib/vimamsa/macro.rb +5 -5
- data/lib/vimamsa/rbvma.rb +11 -10
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +3 -4
- data/lib/vimamsa/version.rb +1 -1
- metadata +4 -3
- data/lib/vimamsa/gui_gtk_sourceview.rb +0 -294
data/lib/vimamsa/editor.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require "pty"
|
2
2
|
|
3
3
|
def exec_in_terminal(cmd, autoclose = false)
|
4
|
-
#
|
4
|
+
# debug "CMD:#{cmd}"
|
5
5
|
|
6
6
|
# global to prevent garbage collect unlink
|
7
7
|
$initf = Tempfile.new("bashinit")
|
8
|
-
#
|
8
|
+
# debug $initf.path
|
9
9
|
$initf.write(cmd)
|
10
10
|
if autoclose
|
11
11
|
$initf.write("\nsleep 10; exit;\n")
|
@@ -37,7 +37,7 @@ class Editor
|
|
37
37
|
#attr_writer :call_func, :update_highlight
|
38
38
|
|
39
39
|
def initialize()
|
40
|
-
# Thread.new{10000.times{|x|sleep(3);10000.times{|y|y+2};
|
40
|
+
# Thread.new{10000.times{|x|sleep(3);10000.times{|y|y+2};debug "FOOTHREAD #{x}"}}
|
41
41
|
|
42
42
|
# Search for content inside files (e.g. using ack/grep) in:
|
43
43
|
@file_content_search_paths = []
|
@@ -74,7 +74,7 @@ class Editor
|
|
74
74
|
|
75
75
|
# GLib::Idle.add
|
76
76
|
# Ripl.start :binding => binding
|
77
|
-
# GLib::Idle.add(proc{
|
77
|
+
# GLib::Idle.add(proc{ debug "IDLEFUNC"})
|
78
78
|
# GLib::Idle.add(proc { idle_func })
|
79
79
|
|
80
80
|
@gui = $vmag #TODO
|
@@ -106,13 +106,14 @@ class Editor
|
|
106
106
|
sleep(0.03)
|
107
107
|
|
108
108
|
FileManager.init
|
109
|
+
BufferManager.init
|
109
110
|
|
110
111
|
mkdir_if_not_exists("~/.vimamsa")
|
111
112
|
mkdir_if_not_exists("~/.vimamsa/backup")
|
112
113
|
mkdir_if_not_exists("~/.vimamsa/listen")
|
113
114
|
listen_dir = File.expand_path "~/.vimamsa/listen"
|
114
115
|
listener = Listen.to(listen_dir) do |modified, added, removed|
|
115
|
-
|
116
|
+
debug([modified: modified, added: added, removed: removed])
|
116
117
|
open_file_listener(added)
|
117
118
|
end
|
118
119
|
listener.start
|
@@ -188,6 +189,11 @@ class Editor
|
|
188
189
|
def buf()
|
189
190
|
return $buffer
|
190
191
|
end
|
192
|
+
|
193
|
+
def buffers()
|
194
|
+
return $buffers
|
195
|
+
end
|
196
|
+
|
191
197
|
|
192
198
|
def marshal_save(varname, vardata)
|
193
199
|
save_var_to_file(varname, Marshal.dump(vardata))
|
@@ -264,7 +270,7 @@ class Editor
|
|
264
270
|
exts = $cnf[:extensions_to_open]
|
265
271
|
extname = Pathname.new(filepath).extname.downcase
|
266
272
|
can_open = exts.include?(extname)
|
267
|
-
|
273
|
+
debug "CAN OPEN?: #{can_open}"
|
268
274
|
return can_open
|
269
275
|
end
|
270
276
|
end
|
@@ -275,7 +281,7 @@ def _quit()
|
|
275
281
|
end
|
276
282
|
|
277
283
|
def fatal_error(msg)
|
278
|
-
|
284
|
+
debug msg
|
279
285
|
exit!
|
280
286
|
end
|
281
287
|
|
@@ -296,7 +302,7 @@ def system_clipboard_changed(clipboard_contents)
|
|
296
302
|
$paste_lines = false
|
297
303
|
end
|
298
304
|
$clipboard << clipboard_contents
|
299
|
-
#
|
305
|
+
# debug $clipboard[-1]
|
300
306
|
$clipboard = $clipboard[-([$clipboard.size, max_clipboard_items].min)..-1]
|
301
307
|
end
|
302
308
|
|
@@ -306,8 +312,8 @@ end
|
|
306
312
|
|
307
313
|
def set_clipboard(s)
|
308
314
|
if !(s.class <= String) or s.size == 0
|
309
|
-
|
310
|
-
|
315
|
+
debug s.inspect
|
316
|
+
debug [s, s.class, s.size]
|
311
317
|
log_error("s.class != String or s.size == 0")
|
312
318
|
Ripl.start :binding => binding
|
313
319
|
return
|
@@ -378,9 +384,9 @@ def diff_buffer()
|
|
378
384
|
infile.write($buffer.to_s)
|
379
385
|
infile.flush
|
380
386
|
cmd = "diff -w '#{orig_path}' #{infile.path}"
|
381
|
-
#
|
387
|
+
# debug cmd
|
382
388
|
bufstr << run_cmd(cmd)
|
383
|
-
#
|
389
|
+
# debug bufstr
|
384
390
|
infile.close; infile.unlink
|
385
391
|
create_new_file(nil, bufstr)
|
386
392
|
end
|
@@ -434,7 +440,7 @@ end
|
|
434
440
|
|
435
441
|
def message(s)
|
436
442
|
s = "[#{DateTime.now().strftime("%H:%M")}] #{s}"
|
437
|
-
|
443
|
+
debug s
|
438
444
|
|
439
445
|
$vmag.add_to_minibuf(s)
|
440
446
|
# $minibuffer = Buffer.new(s, "")
|
@@ -550,6 +556,7 @@ def hook_draw()
|
|
550
556
|
# easy_jump_draw()
|
551
557
|
end
|
552
558
|
|
559
|
+
#TODO: delete this
|
553
560
|
def render_buffer(buffer = 0, reset = 0)
|
554
561
|
tmpbuf = $buffer.to_s
|
555
562
|
debug "pos:#{$buffer.pos} L:#{$buffer.lpos} C:#{$buffer.cpos}"
|
@@ -604,7 +611,7 @@ end
|
|
604
611
|
def run_cmd(cmd)
|
605
612
|
tmpf = Tempfile.new("vmarun", "/tmp").path
|
606
613
|
cmd = "#{cmd} > #{tmpf}"
|
607
|
-
|
614
|
+
debug "CMD:\n#{cmd}"
|
608
615
|
system("bash", "-c", cmd)
|
609
616
|
res_str = File.read(tmpf)
|
610
617
|
return res_str
|
@@ -633,11 +640,11 @@ def exec_cmd(bin_name, arg1 = nil, arg2 = nil, arg3 = nil, arg4 = nil, arg5 = ni
|
|
633
640
|
end
|
634
641
|
|
635
642
|
def file_is_text_file(fpath)
|
636
|
-
|
643
|
+
debug "file_is_text_file(#{fpath})"
|
637
644
|
fpath = File.expand_path(fpath)
|
638
645
|
return false if !File.exist?(fpath)
|
639
646
|
r = exec_cmd("file", fpath)
|
640
|
-
|
647
|
+
debug "DEBUG:#{r}"
|
641
648
|
return true if r.match(/UTF-8.*text/)
|
642
649
|
return true if r.match(/ASCII.*text/)
|
643
650
|
return false
|
@@ -673,6 +680,6 @@ def find_project_dir_of_cur_buffer()
|
|
673
680
|
if $buffer.fname
|
674
681
|
pdir = find_project_dir_of_fn($buffer.fname)
|
675
682
|
end
|
676
|
-
#
|
683
|
+
# debug "Proj dir of current file: #{pdir}"
|
677
684
|
return pdir
|
678
685
|
end
|
data/lib/vimamsa/file_finder.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "parallel"
|
2
|
-
|
3
2
|
class FileFinder
|
4
3
|
def initialize()
|
5
4
|
$hook.register(:shutdown, self.method("save"))
|
@@ -59,22 +58,22 @@ def filter_files(search_str)
|
|
59
58
|
for s in scores
|
60
59
|
dir_hash[s[0]] = s[1] if s[1] > 0
|
61
60
|
end
|
62
|
-
#
|
61
|
+
# debug scores
|
63
62
|
dir_hash = dir_hash.sort_by { |k, v| -v }
|
64
63
|
dir_hash = dir_hash[0..20]
|
65
64
|
dir_hash.map do |file, d|
|
66
|
-
|
65
|
+
debug "D:#{d} #{file}"
|
67
66
|
end
|
68
67
|
return dir_hash
|
69
68
|
end
|
70
69
|
|
71
70
|
def gui_file_finder_update_callback(search_str = "")
|
72
|
-
|
71
|
+
debug "FILE FINDER UPDATE CALLBACK: #{search_str}"
|
73
72
|
if (search_str.size > 1)
|
74
73
|
files = filter_files(search_str)
|
75
74
|
$file_search_list = files
|
76
75
|
return files
|
77
|
-
#
|
76
|
+
#debug files.inspect
|
78
77
|
#return files.values
|
79
78
|
end
|
80
79
|
return []
|
@@ -88,7 +87,7 @@ def gui_file_finder_select_callback(search_str, idx)
|
|
88
87
|
end
|
89
88
|
|
90
89
|
def gui_file_finder_handle_char(c)
|
91
|
-
|
90
|
+
debug "BUFFER SELECTOR INPUT CHAR: #{c}"
|
92
91
|
buffer_i = $select_keys.index(c)
|
93
92
|
if buffer_i != nil
|
94
93
|
gui_file_finder_callback(buffer_i)
|
data/lib/vimamsa/file_history.rb
CHANGED
@@ -21,7 +21,7 @@ class FileHistory
|
|
21
21
|
# end
|
22
22
|
|
23
23
|
def update(buf)
|
24
|
-
|
24
|
+
debug "FileHistory.update(buf=#{buf.fname})"
|
25
25
|
return if !buf.fname
|
26
26
|
@history[buf.fname] if !@history[buf.fname]
|
27
27
|
if !@history[buf.fname]
|
@@ -29,7 +29,7 @@ class FileHistory
|
|
29
29
|
else
|
30
30
|
@history[buf.fname] += 1
|
31
31
|
end
|
32
|
-
|
32
|
+
debug @history
|
33
33
|
|
34
34
|
# puts "FileHistory.update(buf=#{buf})"
|
35
35
|
end
|
@@ -83,7 +83,7 @@ def fuzzy_filter(search_str, list, maxfinds)
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def gui_file_history_update_callback(search_str = "")
|
86
|
-
|
86
|
+
debug "gui_file_history_update_callback: #{search_str}"
|
87
87
|
return [] if $vma.fh.history.empty?
|
88
88
|
$search_list = []
|
89
89
|
files = $vma.fh.history.keys.sort.collect { |x| [x, 0] }
|
data/lib/vimamsa/file_manager.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
class FileManager
|
2
3
|
@@cur
|
3
4
|
|
@@ -28,11 +29,11 @@ class FileManager
|
|
28
29
|
# bindkey "C o", :delete_state
|
29
30
|
|
30
31
|
$kbd.add_minor_mode("fexp", :file_exp, :command)
|
31
|
-
|
32
|
+
|
32
33
|
bindkey "fexp o m", :fexp_sort_mtime
|
33
|
-
bindkey "fexp o f", :fexp_sort_fname
|
34
|
+
bindkey "fexp o f", :fexp_sort_fname
|
34
35
|
|
35
|
-
# bindkey "fexp l", [:fexp_right, proc {
|
36
|
+
# bindkey "fexp l", [:fexp_right, proc { debug "==fexp_right==" }, ""]
|
36
37
|
bindkey "fexp h", :fexp_chdir_parent
|
37
38
|
bindkey "fexp esc", [:fexp_quit, proc { $kbd.set_mode(:command) }, ""]
|
38
39
|
bindkey "fexp enter", :fexp_select
|
@@ -49,7 +50,7 @@ class FileManager
|
|
49
50
|
@@cur = self
|
50
51
|
ld = buflist.get_last_dir
|
51
52
|
dir_to_buf(ld)
|
52
|
-
#
|
53
|
+
# debug "ld=#{ld}"
|
53
54
|
# dlist = Dir["#{ld}/*"]
|
54
55
|
end
|
55
56
|
|
@@ -83,7 +84,7 @@ class FileManager
|
|
83
84
|
next
|
84
85
|
end
|
85
86
|
next if x[0] == "."
|
86
|
-
if File.directory?(fpath)
|
87
|
+
if File.directory?(fpath)
|
87
88
|
# if f.directory?(fpath)
|
88
89
|
@cdirs << x
|
89
90
|
else
|
@@ -126,10 +127,10 @@ class FileManager
|
|
126
127
|
|
127
128
|
def select_line
|
128
129
|
return if @buf.lpos < @header.size
|
129
|
-
#
|
130
|
+
# debug "def select_line"
|
130
131
|
fn = fullp(@buf.get_current_line[0..-2])
|
131
132
|
if File.directory?(fn)
|
132
|
-
|
133
|
+
debug "CHDIR: #{fn}"
|
133
134
|
dir_to_buf(fn)
|
134
135
|
# elsif vma.can_open_extension?(fn)
|
135
136
|
# jump_to_file(fn)
|
@@ -139,6 +140,6 @@ class FileManager
|
|
139
140
|
else
|
140
141
|
open_with_default_program(fn)
|
141
142
|
end
|
142
|
-
#
|
143
|
+
# debug l.inspect
|
143
144
|
end
|
144
145
|
end
|
data/lib/vimamsa/gui.rb
CHANGED
@@ -10,7 +10,7 @@ def gui_open_file_dialog(dirpath)
|
|
10
10
|
dialog.signal_connect("response") do |dialog, response_id|
|
11
11
|
if response_id == Gtk::ResponseType::ACCEPT
|
12
12
|
open_new_file(dialog.filename)
|
13
|
-
#
|
13
|
+
# debug "uri = #{dialog.uri}"
|
14
14
|
end
|
15
15
|
dialog.destroy
|
16
16
|
end
|
@@ -34,7 +34,7 @@ def gui_file_saveas(dirpath)
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def idle_func
|
37
|
-
#
|
37
|
+
# debug "IDLEFUNC"
|
38
38
|
if $idle_scroll_to_mark
|
39
39
|
# Ripl.start :binding => binding
|
40
40
|
# $view.get_visible_rect
|
@@ -45,7 +45,7 @@ def idle_func
|
|
45
45
|
b = $view.buffer
|
46
46
|
iter = b.get_iter_at(:offset => b.cursor_position)
|
47
47
|
iterxy = $view.get_iter_location(iter)
|
48
|
-
#
|
48
|
+
# debug "ITERXY" + iterxy.inspect
|
49
49
|
# Ripl.start :binding => binding
|
50
50
|
|
51
51
|
intr = iterxy.intersect(vr)
|
@@ -103,7 +103,7 @@ def paste_system_clipboard()
|
|
103
103
|
|
104
104
|
# clipboard.request_contents(target_string) do |_clipboard, selection_data|
|
105
105
|
# received_text = selection_data.text
|
106
|
-
#
|
106
|
+
# debug "received_text=#{received_text}"
|
107
107
|
# end
|
108
108
|
if clipboard.wait_is_text_available?
|
109
109
|
received_text = clipboard.wait_for_text
|
@@ -116,7 +116,7 @@ def paste_system_clipboard()
|
|
116
116
|
$paste_lines = false
|
117
117
|
end
|
118
118
|
$clipboard << received_text
|
119
|
-
#
|
119
|
+
# debug $clipboard[-1]
|
120
120
|
$clipboard = $clipboard[-([$clipboard.size, max_clipboard_items].min)..-1]
|
121
121
|
end
|
122
122
|
return received_text
|
@@ -132,7 +132,7 @@ def set_system_clipboard(arg)
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def gui_create_buffer(id)
|
135
|
-
|
135
|
+
debug "gui_create_buffer(#{id})"
|
136
136
|
buf1 = GtkSource::Buffer.new()
|
137
137
|
view = VSourceView.new()
|
138
138
|
|
@@ -144,7 +144,7 @@ def gui_create_buffer(id)
|
|
144
144
|
ssm.set_search_path(ssm.search_path << ppath("styles/"))
|
145
145
|
# sty = ssm.get_scheme("dark")
|
146
146
|
sty = ssm.get_scheme("molokai_edit")
|
147
|
-
#
|
147
|
+
# debug ssm.scheme_ids
|
148
148
|
|
149
149
|
view.buffer.highlight_matching_brackets = true
|
150
150
|
view.buffer.style_scheme = sty
|
@@ -154,7 +154,8 @@ def gui_create_buffer(id)
|
|
154
154
|
# provider.load(data: "textview { font-family: Arial; font-size: 12pt; }")
|
155
155
|
view.style_context.add_provider(provider)
|
156
156
|
view.wrap_mode = :char
|
157
|
-
view.set_tab_width(
|
157
|
+
view.set_tab_width(conf(:tab_width))
|
158
|
+
|
158
159
|
|
159
160
|
$vmag.buffers[id] = view
|
160
161
|
end
|
@@ -183,7 +184,7 @@ end
|
|
183
184
|
|
184
185
|
def gui_set_buffer_contents(id, txt)
|
185
186
|
# $vbuf.set_text(txt)
|
186
|
-
|
187
|
+
debug "gui_set_buffer_contents(#{id}, txt)"
|
187
188
|
|
188
189
|
$vmag.buffers[id].buffer.set_text(txt)
|
189
190
|
end
|
@@ -195,7 +196,7 @@ end
|
|
195
196
|
|
196
197
|
def gui_set_current_buffer(id)
|
197
198
|
view = $vmag.buffers[id]
|
198
|
-
|
199
|
+
debug "gui_set_current_buffer(#{id}), view=#{view}"
|
199
200
|
buf1 = view.buffer
|
200
201
|
$vmag.view = view
|
201
202
|
$vmag.buf1 = buf1
|
@@ -263,9 +264,9 @@ class VMAgui
|
|
263
264
|
end
|
264
265
|
|
265
266
|
def overlay_draw_text(text, textpos)
|
266
|
-
#
|
267
|
+
# debug "overlay_draw_text #{[x,y]}"
|
267
268
|
(x, y) = @view.pos_to_coord(textpos)
|
268
|
-
#
|
269
|
+
# debug "overlay_draw_text #{[x,y]}"
|
269
270
|
label = Gtk::Label.new("<span background='#00000088' foreground='#ff0000' weight='ultrabold'>#{text}</span>")
|
270
271
|
label.use_markup = true
|
271
272
|
@da.put(label, x, y)
|
@@ -301,7 +302,7 @@ class VMAgui
|
|
301
302
|
# istart = @view.get_iter_at_y(vr.y)
|
302
303
|
# startpos = @view.get_iter_at_position_raw(vr.x,vr.y)[1].offset
|
303
304
|
# endpos = @view.get_iter_at_position_raw(vr.x+vr.width,vr.y+vr.height)[1].offset
|
304
|
-
#
|
305
|
+
# debug "startpos,endpos:#{[startpos, endpos]}"
|
305
306
|
|
306
307
|
da = @da
|
307
308
|
if false
|
@@ -335,7 +336,7 @@ class VMAgui
|
|
335
336
|
da.put(label, x, y)
|
336
337
|
end
|
337
338
|
|
338
|
-
#
|
339
|
+
# debug @view.pos_to_coord(300).inspect
|
339
340
|
|
340
341
|
@da.show_all
|
341
342
|
end
|
@@ -523,7 +524,6 @@ class VMAgui
|
|
523
524
|
|
524
525
|
@menubar = Gtk::MenuBar.new
|
525
526
|
@menubar.expand = false
|
526
|
-
|
527
527
|
|
528
528
|
@sw = Gtk::ScrolledWindow.new
|
529
529
|
@sw.set_policy(:automatic, :automatic)
|
@@ -552,11 +552,9 @@ class VMAgui
|
|
552
552
|
|
553
553
|
init_minibuffer
|
554
554
|
|
555
|
-
|
556
555
|
@window.show_all
|
557
556
|
vma.start
|
558
557
|
Vimamsa::Menu.new(@menubar)
|
559
558
|
@window.show_all
|
560
|
-
|
561
559
|
end
|
562
560
|
end
|
data/lib/vimamsa/gui_menu.rb
CHANGED
@@ -4,7 +4,7 @@ module Vimamsa
|
|
4
4
|
mpath = _mpath.split(".")
|
5
5
|
curnfo = @nfo
|
6
6
|
for y in mpath
|
7
|
-
|
7
|
+
debug(curnfo.inspect)
|
8
8
|
if y.equal?(mpath.last)
|
9
9
|
curnfo[y] = x
|
10
10
|
elsif curnfo[y].nil?
|
@@ -16,12 +16,15 @@ module Vimamsa
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def add_menu_items()
|
19
|
+
|
20
|
+
add_to_menu "File.Example", { :label => "<span foreground='#888888'>Action, [mode] key binding</span>", :action => nil }
|
19
21
|
add_to_menu "File.Save", { :label => "Save", :action => :buf_save }
|
20
22
|
add_to_menu "File.Save as", { :label => "Save As...", :action => :buf_save_as }
|
21
23
|
add_to_menu "File.Open", { :label => "Open", :action => :open_file_dialog }
|
22
24
|
|
23
25
|
add_to_menu "File.New", { :label => "New file", :action => :buf_new }
|
24
26
|
add_to_menu "File.Revert", { :label => "Reload file from disk", :action => :buf_revert }
|
27
|
+
add_to_menu "File.List", { :label => "List open files", :action => :start_buf_manager }
|
25
28
|
|
26
29
|
add_to_menu "File.Quit", { :label => "Quit", :action => :quit }
|
27
30
|
|
@@ -37,8 +40,15 @@ module Vimamsa
|
|
37
40
|
add_to_menu "Actions.FileHistoryFinder", { :label => "Search files in history", :action => :gui_file_history_finder }
|
38
41
|
|
39
42
|
add_to_menu "Actions.experimental.Diff", { :label => "Show Diff of\nunsaved changes", :action => :diff_buffer }
|
43
|
+
|
44
|
+
add_to_menu "Actions.experimental.EnableDebug", { :label => "Enable debug", :action => :enable_debug }
|
45
|
+
add_to_menu "Actions.experimental.DisableDebug", { :label => "Disable debug", :action => :disable_debug }
|
46
|
+
add_to_menu "Actions.experimental.ShowImages", { :label => "Show images ⟦img:path⟧", :action => :show_images }
|
47
|
+
|
40
48
|
|
41
49
|
add_to_menu "Actions.EncryptFile", { :label => "Encrypt file", :action => :encrypt_file }
|
50
|
+
add_to_menu "Help.KeyBindings", { :label => "Show key bindings", :action => :show_key_bindings }
|
51
|
+
|
42
52
|
|
43
53
|
#TODO: :auto_indent_buffer
|
44
54
|
|
@@ -8,7 +8,7 @@ class SelectUpdateWindow
|
|
8
8
|
COLUMN_DESCRIPTION = 1
|
9
9
|
|
10
10
|
def update_item_list(item_list)
|
11
|
-
#
|
11
|
+
# debug item_list.inspect
|
12
12
|
@model.clear
|
13
13
|
for item in item_list
|
14
14
|
iter = @model.append
|
@@ -17,7 +17,7 @@ class SelectUpdateWindow
|
|
17
17
|
else
|
18
18
|
v = ["", item[0]]
|
19
19
|
end
|
20
|
-
|
20
|
+
debug v.inspect
|
21
21
|
iter.set_values(v)
|
22
22
|
end
|
23
23
|
|
@@ -46,10 +46,10 @@ class SelectUpdateWindow
|
|
46
46
|
@selected_row = 0
|
47
47
|
@opt = opt
|
48
48
|
|
49
|
-
|
49
|
+
debug item_list.inspect
|
50
50
|
@update_callback = method(update_callback)
|
51
51
|
@select_callback = method(select_callback)
|
52
|
-
#
|
52
|
+
# debug @update_callback_m.call("").inspect
|
53
53
|
|
54
54
|
vbox = Gtk::Box.new(:vertical, 8)
|
55
55
|
vbox.margin = 8
|
@@ -72,21 +72,21 @@ class SelectUpdateWindow
|
|
72
72
|
update_item_list(item_list)
|
73
73
|
|
74
74
|
@window.signal_connect("key-press-event") do |_widget, event|
|
75
|
-
#
|
75
|
+
# debug "KEYPRESS 1"
|
76
76
|
@entry.handle_event(event)
|
77
77
|
end
|
78
78
|
|
79
79
|
@entry.signal_connect("key_press_event") do |widget, event|
|
80
|
-
#
|
80
|
+
# debug "KEYPRESS 2"
|
81
81
|
if event.keyval == Gdk::Keyval::KEY_Down
|
82
|
-
|
82
|
+
debug "DOWN"
|
83
83
|
set_selected_row(@selected_row + 1)
|
84
84
|
# fixed = iter[COLUMN_FIXED]
|
85
85
|
|
86
86
|
true
|
87
87
|
elsif event.keyval == Gdk::Keyval::KEY_Up
|
88
88
|
set_selected_row(@selected_row - 1)
|
89
|
-
|
89
|
+
debug "UP"
|
90
90
|
true
|
91
91
|
elsif event.keyval == Gdk::Keyval::KEY_Return
|
92
92
|
path = Gtk::TreePath.new(@selected_row.to_s)
|
@@ -94,7 +94,7 @@ class SelectUpdateWindow
|
|
94
94
|
ret = iter[1]
|
95
95
|
@select_callback.call(ret, @selected_row)
|
96
96
|
@window.destroy
|
97
|
-
#
|
97
|
+
# debug iter[1].inspect
|
98
98
|
true
|
99
99
|
elsif event.keyval == Gdk::Keyval::KEY_Escape
|
100
100
|
@window.destroy
|
@@ -105,14 +105,14 @@ class SelectUpdateWindow
|
|
105
105
|
end
|
106
106
|
|
107
107
|
@entry.signal_connect("search-changed") do |widget|
|
108
|
-
|
108
|
+
debug "search changed: #{widget.text || ""}"
|
109
109
|
item_list = @update_callback.call(widget.text)
|
110
110
|
|
111
111
|
update_item_list(item_list)
|
112
112
|
# label.text = widget.text || ""
|
113
113
|
end
|
114
|
-
@entry.signal_connect("changed") {
|
115
|
-
@entry.signal_connect("next-match") {
|
114
|
+
@entry.signal_connect("changed") { debug "[changed] " }
|
115
|
+
@entry.signal_connect("next-match") { debug "[next-match] " }
|
116
116
|
|
117
117
|
if !opt[:desc].nil?
|
118
118
|
descl = Gtk::Label.new(opt[:desc])
|
@@ -160,7 +160,7 @@ class SelectUpdateWindow
|
|
160
160
|
end
|
161
161
|
|
162
162
|
@window.set_default_size(280, 500)
|
163
|
-
|
163
|
+
debug "SelectUpdateWindow"
|
164
164
|
end
|
165
165
|
|
166
166
|
def run
|
@@ -3,16 +3,16 @@ class VSourceView < GtkSource::View
|
|
3
3
|
def initialize(title = nil)
|
4
4
|
# super(:toplevel)
|
5
5
|
super()
|
6
|
-
|
6
|
+
debug "vsource init"
|
7
7
|
@last_keyval = nil
|
8
8
|
@last_event = [nil, nil]
|
9
9
|
|
10
10
|
signal_connect "button-press-event" do |_widget, event|
|
11
11
|
if event.button == Gdk::BUTTON_PRIMARY
|
12
|
-
#
|
12
|
+
# debug "Gdk::BUTTON_PRIMARY"
|
13
13
|
false
|
14
14
|
elsif event.button == Gdk::BUTTON_SECONDARY
|
15
|
-
#
|
15
|
+
# debug "Gdk::BUTTON_SECONDARY"
|
16
16
|
true
|
17
17
|
else
|
18
18
|
true
|
@@ -44,14 +44,14 @@ class VSourceView < GtkSource::View
|
|
44
44
|
def handle_key_event(event, sig)
|
45
45
|
if $update_cursor
|
46
46
|
curpos = buffer.cursor_position
|
47
|
-
|
47
|
+
debug "MOVE CURSOR: #{curpos}"
|
48
48
|
buf.set_pos(curpos)
|
49
49
|
$update_cursor = false
|
50
50
|
end
|
51
|
-
|
51
|
+
debug $view.visible_rect.inspect
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
debug "key event"
|
54
|
+
debug event
|
55
55
|
|
56
56
|
key_name = event.string
|
57
57
|
if event.state.control_mask?
|
@@ -98,9 +98,9 @@ class VSourceView < GtkSource::View
|
|
98
98
|
key_str_parts << key_name
|
99
99
|
key_str = key_str_parts.join("-")
|
100
100
|
keynfo = { :key_str => key_str, :key_name => key_name, :keyval => event.keyval }
|
101
|
-
|
101
|
+
debug keynfo.inspect
|
102
102
|
# $kbd.match_key_conf(key_str, nil, :key_press)
|
103
|
-
#
|
103
|
+
# debug "key_str=#{key_str} key_"
|
104
104
|
|
105
105
|
if key_str != "" # or prefixed_key_str != ""
|
106
106
|
if sig == :key_release_event and event.keyval == @last_keyval
|
@@ -132,7 +132,7 @@ class VSourceView < GtkSource::View
|
|
132
132
|
y = iterxy.y
|
133
133
|
|
134
134
|
# buffer_to_window_coords(Gtk::TextWindowType::TEXT, iterxy.x, iterxy.y).inspect
|
135
|
-
#
|
135
|
+
# debug buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y).inspect
|
136
136
|
(x, y) = buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y)
|
137
137
|
# Ripl.start :binding => binding
|
138
138
|
|
@@ -166,15 +166,15 @@ class VSourceView < GtkSource::View
|
|
166
166
|
def sanity_check()
|
167
167
|
a = buffer.text
|
168
168
|
b = buf.to_s
|
169
|
-
#
|
170
|
-
#
|
171
|
-
#
|
172
|
-
#
|
173
|
-
#
|
169
|
+
# debug "===================="
|
170
|
+
# debug a.lines[0..10].join()
|
171
|
+
# debug "===================="
|
172
|
+
# debug b.lines[0..10].join()
|
173
|
+
# debug "===================="
|
174
174
|
if a == b
|
175
|
-
|
175
|
+
debug "Buffers match"
|
176
176
|
else
|
177
|
-
|
177
|
+
debug "ERROR: Buffer's don't match."
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -210,7 +210,7 @@ class VSourceView < GtkSource::View
|
|
210
210
|
end
|
211
211
|
|
212
212
|
def cursor_visible_idle_func
|
213
|
-
|
213
|
+
debug "cursor_visible_idle_func"
|
214
214
|
# From https://picheta.me/articles/2013/08/gtk-plus--a-method-to-guarantee-scrolling.html
|
215
215
|
# vr = visible_rect
|
216
216
|
|
@@ -247,8 +247,8 @@ class VSourceView < GtkSource::View
|
|
247
247
|
|
248
248
|
intr = iterxy.intersect(vr)
|
249
249
|
if intr.nil?
|
250
|
-
|
251
|
-
|
250
|
+
debug iterxy.inspect
|
251
|
+
debug vr.inspect
|
252
252
|
# Ripl.start :binding => binding
|
253
253
|
|
254
254
|
# exit!
|
@@ -273,16 +273,16 @@ class VSourceView < GtkSource::View
|
|
273
273
|
itr2 = buffer.get_iter_at(:offset => buf.pos + 1)
|
274
274
|
$view.buffer.select_range(itr, itr2)
|
275
275
|
elsif buf.visual_mode?
|
276
|
-
|
276
|
+
debug "VISUAL MODE"
|
277
277
|
(_start, _end) = buf.get_visual_mode_range2
|
278
|
-
|
278
|
+
debug "#{_start}, #{_end}"
|
279
279
|
itr = buffer.get_iter_at(:offset => _start)
|
280
280
|
itr2 = buffer.get_iter_at(:offset => _end + 1)
|
281
281
|
$view.buffer.select_range(itr, itr2)
|
282
282
|
else # Insert mode
|
283
283
|
itr = buffer.get_iter_at(:offset => buf.pos)
|
284
284
|
$view.buffer.select_range(itr, itr)
|
285
|
-
|
285
|
+
debug "INSERT MODE"
|
286
286
|
end
|
287
287
|
end
|
288
288
|
|