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
data/lib/vimamsa/gui_image.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# Following this example:
|
3
2
|
# https://gabmus.org/posts/create_an_auto-resizing_image_widget_with_gtk3_and_python/
|
4
3
|
class ResizableImage < Gtk::DrawingArea
|
@@ -18,26 +17,33 @@ class ResizableImage < Gtk::DrawingArea
|
|
18
17
|
def scale_image()
|
19
18
|
pb = @pixbuf
|
20
19
|
view = @view
|
21
|
-
|
20
|
+
if view.visible_rect.width > 0
|
21
|
+
imglimit = view.visible_rect.width - 50
|
22
|
+
else
|
23
|
+
imglimit = 500
|
24
|
+
end
|
22
25
|
|
23
26
|
if @oldimg.width > imglimit or @oldimg.width < imglimit - 10
|
24
27
|
nwidth = imglimit
|
25
28
|
nwidth = pb.width if pb.width < imglimit
|
26
29
|
nheight = (pb.height * (nwidth.to_f / pb.width)).to_i
|
30
|
+
# Ripl.start :binding => binding
|
31
|
+
|
27
32
|
pb = pb.scale_simple(nwidth, nheight, GdkPixbuf::InterpType::HYPER)
|
28
33
|
else
|
29
34
|
pb = @oldimg
|
30
35
|
end
|
31
36
|
@draw_image = pb
|
32
37
|
@oldimg = pb
|
33
|
-
|
34
|
-
|
38
|
+
#TODO: Should be better way to compensate for the gutter
|
39
|
+
self.set_size_request(pb.width+@view.gutter_width, pb.height)
|
35
40
|
end
|
36
41
|
|
37
42
|
def do_draw(da, cr)
|
38
43
|
# puts @fpath
|
39
|
-
|
44
|
+
# Ripl.start :binding => binding
|
45
|
+
|
46
|
+
cr.set_source_pixbuf(@draw_image, @view.gutter_width, 0)
|
40
47
|
cr.paint
|
41
48
|
end
|
42
49
|
end
|
43
|
-
|
data/lib/vimamsa/gui_menu.rb
CHANGED
@@ -16,7 +16,6 @@ module Vimamsa
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def add_menu_items()
|
19
|
-
|
20
19
|
add_to_menu "File.Example", { :label => "<span foreground='#888888'>Action, [mode] key binding</span>", :action => nil }
|
21
20
|
add_to_menu "File.Save", { :label => "Save", :action => :buf_save }
|
22
21
|
add_to_menu "File.Save as", { :label => "Save As...", :action => :buf_save_as }
|
@@ -40,14 +39,17 @@ module Vimamsa
|
|
40
39
|
add_to_menu "Actions.FileHistoryFinder", { :label => "Search files in history", :action => :gui_file_history_finder }
|
41
40
|
|
42
41
|
add_to_menu "Actions.experimental.Diff", { :label => "Show Diff of\nunsaved changes", :action => :diff_buffer }
|
43
|
-
|
42
|
+
|
44
43
|
add_to_menu "Actions.experimental.EnableDebug", { :label => "Enable debug", :action => :enable_debug }
|
45
44
|
add_to_menu "Actions.experimental.DisableDebug", { :label => "Disable debug", :action => :disable_debug }
|
46
45
|
add_to_menu "Actions.experimental.ShowImages", { :label => "Show images ⟦img:path⟧", :action => :show_images }
|
47
46
|
|
47
|
+
|
48
|
+
add_to_menu "View.TwoColumn", { :label => "Start two column mode", :action => :toggle_two_column }
|
49
|
+
|
50
|
+
|
48
51
|
add_to_menu "Actions.EncryptFile", { :label => "Encrypt file", :action => :encrypt_file }
|
49
52
|
add_to_menu "Help.KeyBindings", { :label => "Show key bindings", :action => :show_key_bindings }
|
50
|
-
|
51
53
|
|
52
54
|
#TODO: :auto_indent_buffer
|
53
55
|
|
@@ -55,26 +57,19 @@ module Vimamsa
|
|
55
57
|
|
56
58
|
end
|
57
59
|
|
58
|
-
def initialize(menubar)
|
59
|
-
|
60
|
-
# nfo["actions"] = { :items => {}, :label => "Actions" }
|
61
|
-
# nfo["help"] = { :items => {}, :label => "Help" }
|
62
|
-
|
60
|
+
def initialize(menubar, _app)
|
61
|
+
@app = _app
|
63
62
|
@nfo = {}
|
64
63
|
|
65
64
|
add_menu_items
|
66
65
|
|
67
|
-
# add_to_menu("help.extra.keybindings", { :label => "Show keybindings" })
|
68
|
-
# add_to_menu("help.extra.nfo.keybindings", { :label => "Show keybindings" })
|
69
|
-
# add_to_menu("help.keybindings", { :label => "Show keybindings <span foreground='#888888' >C ? k</span>" }) #font='12' weight='ultrabold'
|
70
|
-
|
71
66
|
for k, v in @nfo
|
72
67
|
build_menu(v, menubar)
|
73
68
|
end
|
74
69
|
end
|
75
70
|
|
76
71
|
def build_menu(nfo, parent)
|
77
|
-
menu =
|
72
|
+
menu = Gio::Menu.new
|
78
73
|
if nfo[:action]
|
79
74
|
kbd_str = ""
|
80
75
|
for mode_str in ["C", "V"]
|
@@ -86,24 +81,38 @@ module Vimamsa
|
|
86
81
|
end
|
87
82
|
|
88
83
|
label_str = nfo[:label] + kbd_str
|
89
|
-
|
90
|
-
menuitem.
|
91
|
-
|
92
|
-
|
84
|
+
actkey = nfo[:action].to_s
|
85
|
+
menuitem = Gio::MenuItem.new(label_str, "app.#{actkey}")
|
86
|
+
|
87
|
+
# This worked in GTK3:
|
88
|
+
# But seems there is no way to access the Label object in GTK4
|
89
|
+
# menuitem.children[0].set_markup(label_str)
|
90
|
+
|
91
|
+
act = Gio::SimpleAction.new(actkey)
|
92
|
+
@app.add_action(act)
|
93
|
+
act.signal_connect "activate" do |_simple_action, _parameter|
|
93
94
|
call_action(nfo[:action])
|
94
95
|
end
|
95
96
|
else
|
96
|
-
menuitem =
|
97
|
-
menuitem.children[0].set_markup(nfo[:label])
|
97
|
+
menuitem = Gio::MenuItem.new(nfo[:label], nil)
|
98
98
|
end
|
99
99
|
|
100
|
+
# Apparently requires Gtk 4.6 to work.
|
101
|
+
# According to instructions in: https://discourse.gnome.org/t/gtk4-and-pango-markup-in-menu-items/16082
|
102
|
+
# Boolean true here should work but doesn't yet in GTK 4.6. The string version does work.
|
103
|
+
menuitem.set_attribute_value("use-markup", "true")
|
104
|
+
# menuitem.set_attribute_value("use-markup", true)
|
105
|
+
# This might change in the future(?), but the string version still works in gtk-4.13.0 (gtk/gtkmenutrackeritem.c)
|
106
|
+
|
107
|
+
|
100
108
|
if !nfo[:items].nil? and !nfo[:items].empty?
|
101
109
|
for k2, item in nfo[:items]
|
102
110
|
build_menu(item, menu)
|
103
111
|
end
|
104
112
|
menuitem.submenu = menu
|
105
113
|
end
|
106
|
-
parent.
|
114
|
+
o = parent.append_item(menuitem)
|
115
|
+
|
107
116
|
end
|
108
117
|
end #end class
|
109
118
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
def gui_select_update_window(item_list, jump_keys, select_callback, update_callback, opt={})
|
1
|
+
def gui_select_update_window(item_list, jump_keys, select_callback, update_callback, opt = {})
|
2
2
|
$selup = SelectUpdateWindow.new(nil, item_list, jump_keys, select_callback, update_callback, opt)
|
3
3
|
$selup.run
|
4
4
|
# opt fields:
|
@@ -39,7 +39,7 @@ class SelectUpdateWindow
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def initialize(main_window, item_list, jump_keys, select_callback, update_callback, opt = {})
|
42
|
-
@window = Gtk::Window.new(
|
42
|
+
@window = Gtk::Window.new()
|
43
43
|
# @window.screen = main_window.screen
|
44
44
|
@window.title = ""
|
45
45
|
if !opt[:title].nil?
|
@@ -50,12 +50,23 @@ class SelectUpdateWindow
|
|
50
50
|
@opt = opt
|
51
51
|
|
52
52
|
debug item_list.inspect
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
if select_callback.class == Method
|
55
|
+
@select_callback = select_callback
|
56
|
+
else
|
57
|
+
@select_callback = method(select_callback)
|
58
|
+
end
|
59
|
+
if update_callback.class == Method
|
60
|
+
@update_callback = update_callback
|
61
|
+
else
|
62
|
+
@update_callback = method(update_callback)
|
63
|
+
end
|
55
64
|
# debug @update_callback_m.call("").inspect
|
56
65
|
|
57
66
|
vbox = Gtk::Box.new(:vertical, 8)
|
58
|
-
vbox.
|
67
|
+
vbox.margin_bottom = 8
|
68
|
+
vbox.margin_top = 8
|
69
|
+
|
59
70
|
@window.add(vbox)
|
60
71
|
|
61
72
|
@entry = Gtk::SearchEntry.new
|
@@ -74,24 +85,31 @@ class SelectUpdateWindow
|
|
74
85
|
# item_list = @update_callback.call("")
|
75
86
|
update_item_list(item_list)
|
76
87
|
|
77
|
-
@window.signal_connect("key-press-event") do |_widget, event|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
88
|
+
# @window.signal_connect("key-press-event") do |_widget, event| #TODO:gtk4
|
89
|
+
# debug "KEYPRESS 1"
|
90
|
+
# @entry.handle_event(event)
|
91
|
+
# end
|
92
|
+
|
93
|
+
press = Gtk::EventControllerKey.new
|
94
|
+
press.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
|
81
95
|
|
82
|
-
@entry.
|
83
|
-
|
84
|
-
|
96
|
+
@entry.add_controller(press)
|
97
|
+
# @window.add_controller(press)
|
98
|
+
press.signal_connect "key-pressed" do |gesture, keyval, keycode, y|
|
99
|
+
name = Gdk::Keyval.to_name(keyval)
|
100
|
+
uki = Gdk::Keyval.to_unicode(keyval)
|
101
|
+
keystr = uki.chr("UTF-8")
|
102
|
+
debug "keyval=#{keyval}"
|
103
|
+
|
104
|
+
if keyval == Gdk::Keyval::KEY_Down
|
85
105
|
debug "DOWN"
|
86
106
|
set_selected_row(@selected_row + 1)
|
87
|
-
# fixed = iter[COLUMN_FIXED]
|
88
|
-
|
89
107
|
true
|
90
|
-
elsif
|
108
|
+
elsif keyval == Gdk::Keyval::KEY_Up
|
91
109
|
set_selected_row(@selected_row - 1)
|
92
110
|
debug "UP"
|
93
111
|
true
|
94
|
-
elsif
|
112
|
+
elsif keyval == Gdk::Keyval::KEY_Return
|
95
113
|
path = Gtk::TreePath.new(@selected_row.to_s)
|
96
114
|
iter = @model.get_iter(path)
|
97
115
|
ret = iter[1]
|
@@ -99,7 +117,7 @@ class SelectUpdateWindow
|
|
99
117
|
@window.destroy
|
100
118
|
# debug iter[1].inspect
|
101
119
|
true
|
102
|
-
elsif
|
120
|
+
elsif keyval == Gdk::Keyval::KEY_Escape
|
103
121
|
@window.destroy
|
104
122
|
true
|
105
123
|
else
|
@@ -131,11 +149,12 @@ class SelectUpdateWindow
|
|
131
149
|
|
132
150
|
vbox.pack_start(container, :expand => false, :fill => false, :padding => 0)
|
133
151
|
sw = Gtk::ScrolledWindow.new(nil, nil)
|
134
|
-
sw.shadow_type = :etched_in
|
152
|
+
# sw.shadow_type = :etched_in #TODO:gtk4
|
135
153
|
sw.set_policy(:never, :automatic)
|
136
|
-
vbox.
|
154
|
+
vbox.pack_end(sw, :expand => true, :fill => true, :padding => 0)
|
137
155
|
|
138
|
-
sw.add(treeview)
|
156
|
+
# sw.add(treeview) #TODO:gtk4
|
157
|
+
sw.set_child(treeview)
|
139
158
|
|
140
159
|
if !opt[:columns].nil?
|
141
160
|
for col in opt[:columns]
|
@@ -168,7 +187,7 @@ class SelectUpdateWindow
|
|
168
187
|
|
169
188
|
def run
|
170
189
|
if !@window.visible?
|
171
|
-
@window.
|
190
|
+
@window.show
|
172
191
|
# add_spinner
|
173
192
|
else
|
174
193
|
@window.destroy
|