vimamsa 0.1.7 → 0.1.10
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 +9 -4
- data/custom_example.rb +47 -0
- data/demo.txt +25 -0
- data/lang/hyperplaintext.lang +9 -25
- data/lib/vimamsa/ack.rb +55 -9
- data/lib/vimamsa/actions.rb +27 -8
- data/lib/vimamsa/buffer.rb +120 -82
- data/lib/vimamsa/buffer_list.rb +48 -30
- data/lib/vimamsa/buffer_manager.rb +83 -0
- data/lib/vimamsa/conf.rb +21 -0
- data/lib/vimamsa/debug.rb +11 -10
- data/lib/vimamsa/easy_jump.rb +15 -20
- data/lib/vimamsa/editor.rb +100 -85
- data/lib/vimamsa/encrypt.rb +3 -3
- data/lib/vimamsa/file_finder.rb +6 -9
- data/lib/vimamsa/file_history.rb +3 -3
- data/lib/vimamsa/file_manager.rb +16 -13
- data/lib/vimamsa/gui.rb +95 -90
- data/lib/vimamsa/gui_image.rb +43 -0
- data/lib/vimamsa/gui_menu.rb +11 -2
- data/lib/vimamsa/gui_select_window.rb +16 -13
- data/lib/vimamsa/gui_sourceview.rb +66 -38
- data/lib/vimamsa/hyper_plain_text.rb +40 -21
- data/lib/vimamsa/key_actions.rb +38 -13
- data/lib/vimamsa/key_binding_tree.rb +50 -126
- data/lib/vimamsa/key_bindings_vimlike.rb +26 -24
- data/lib/vimamsa/macro.rb +5 -5
- data/lib/vimamsa/main.rb +3 -3
- data/lib/vimamsa/rbvma.rb +22 -18
- data/lib/vimamsa/search.rb +2 -2
- data/lib/vimamsa/search_replace.rb +25 -22
- data/lib/vimamsa/text_transforms.rb +3 -1
- 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
- data/vimamsa.gemspec +2 -2
- metadata +16 -11
- data/lib/vimamsa/gui_gtk_sourceview.rb +0 -294
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"))
|
@@ -42,9 +41,7 @@ def recursively_find_files()
|
|
42
41
|
for d in $search_dirs
|
43
42
|
debug("FIND FILEs IN #{d}")
|
44
43
|
dlist = dlist + Dir.glob("#{d}/**/*").select { |e| File.file?(e) and $find_extensions.include?(File.extname(e)) }
|
45
|
-
|
46
|
-
end
|
47
|
-
#$dir_list = Dir.glob('./**/*').select { |e| File.file? e }
|
44
|
+
debug("FIND FILEs IN #{d} END") end #$dir_list = Dir.glob('./**/*').select { |e| File.file? e }
|
48
45
|
debug("END find files2")
|
49
46
|
$dir_list = dlist
|
50
47
|
debug("END find files")
|
@@ -59,22 +56,22 @@ def filter_files(search_str)
|
|
59
56
|
for s in scores
|
60
57
|
dir_hash[s[0]] = s[1] if s[1] > 0
|
61
58
|
end
|
62
|
-
#
|
59
|
+
# debug scores
|
63
60
|
dir_hash = dir_hash.sort_by { |k, v| -v }
|
64
61
|
dir_hash = dir_hash[0..20]
|
65
62
|
dir_hash.map do |file, d|
|
66
|
-
|
63
|
+
debug "D:#{d} #{file}"
|
67
64
|
end
|
68
65
|
return dir_hash
|
69
66
|
end
|
70
67
|
|
71
68
|
def gui_file_finder_update_callback(search_str = "")
|
72
|
-
|
69
|
+
debug "FILE FINDER UPDATE CALLBACK: #{search_str}"
|
73
70
|
if (search_str.size > 1)
|
74
71
|
files = filter_files(search_str)
|
75
72
|
$file_search_list = files
|
76
73
|
return files
|
77
|
-
#
|
74
|
+
#debug files.inspect
|
78
75
|
#return files.values
|
79
76
|
end
|
80
77
|
return []
|
@@ -88,7 +85,7 @@ def gui_file_finder_select_callback(search_str, idx)
|
|
88
85
|
end
|
89
86
|
|
90
87
|
def gui_file_finder_handle_char(c)
|
91
|
-
|
88
|
+
debug "BUFFER SELECTOR INPUT CHAR: #{c}"
|
92
89
|
buffer_i = $select_keys.index(c)
|
93
90
|
if buffer_i != nil
|
94
91
|
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
@@ -27,14 +27,14 @@ class FileManager
|
|
27
27
|
|
28
28
|
# bindkey "C o", :delete_state
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
vma.kbd.add_minor_mode("fexp", :file_exp, :command)
|
31
|
+
|
32
32
|
bindkey "fexp o m", :fexp_sort_mtime
|
33
|
-
bindkey "fexp o f", :fexp_sort_fname
|
33
|
+
bindkey "fexp o f", :fexp_sort_fname
|
34
34
|
|
35
|
-
# bindkey "fexp l", [:fexp_right, proc {
|
35
|
+
# bindkey "fexp l", [:fexp_right, proc { debug "==fexp_right==" }, ""]
|
36
36
|
bindkey "fexp h", :fexp_chdir_parent
|
37
|
-
bindkey "fexp esc", [:fexp_quit, proc {
|
37
|
+
bindkey "fexp esc", [:fexp_quit, proc { FileManager.cur.quit }, ""]
|
38
38
|
bindkey "fexp enter", :fexp_select
|
39
39
|
bindkey "fexp l", :fexp_select
|
40
40
|
|
@@ -49,7 +49,7 @@ class FileManager
|
|
49
49
|
@@cur = self
|
50
50
|
ld = buflist.get_last_dir
|
51
51
|
dir_to_buf(ld)
|
52
|
-
#
|
52
|
+
# debug "ld=#{ld}"
|
53
53
|
# dlist = Dir["#{ld}/*"]
|
54
54
|
end
|
55
55
|
|
@@ -65,6 +65,8 @@ class FileManager
|
|
65
65
|
|
66
66
|
def dir_to_buf(dirpath, b = nil)
|
67
67
|
# File.stat("testfile").mtime
|
68
|
+
|
69
|
+
vma.buffers.last_dir = dirpath
|
68
70
|
dirpath = File.expand_path(dirpath)
|
69
71
|
@header = []
|
70
72
|
@header << "#{dirpath}"
|
@@ -83,7 +85,7 @@ class FileManager
|
|
83
85
|
next
|
84
86
|
end
|
85
87
|
next if x[0] == "."
|
86
|
-
if File.directory?(fpath)
|
88
|
+
if File.directory?(fpath)
|
87
89
|
# if f.directory?(fpath)
|
88
90
|
@cdirs << x
|
89
91
|
else
|
@@ -91,9 +93,7 @@ class FileManager
|
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
94
|
-
|
95
|
-
# sort_by = :name
|
96
|
-
# Ripl.start :binding => binding
|
96
|
+
|
97
97
|
@cfiles.sort_by! { |x| x[1].mtime }.reverse! if @sort_by == :mtime
|
98
98
|
@cfiles.sort_by! { |x| x[1].size }.reverse! if @sort_by == :size
|
99
99
|
@cfiles.sort_by! { |x| x[0] } if @sort_by == :name
|
@@ -126,10 +126,10 @@ class FileManager
|
|
126
126
|
|
127
127
|
def select_line
|
128
128
|
return if @buf.lpos < @header.size
|
129
|
-
#
|
129
|
+
# debug "def select_line"
|
130
130
|
fn = fullp(@buf.get_current_line[0..-2])
|
131
131
|
if File.directory?(fn)
|
132
|
-
|
132
|
+
debug "CHDIR: #{fn}"
|
133
133
|
dir_to_buf(fn)
|
134
134
|
# elsif vma.can_open_extension?(fn)
|
135
135
|
# jump_to_file(fn)
|
@@ -139,6 +139,9 @@ class FileManager
|
|
139
139
|
else
|
140
140
|
open_with_default_program(fn)
|
141
141
|
end
|
142
|
-
|
142
|
+
end
|
143
|
+
|
144
|
+
def quit
|
145
|
+
@buf.close
|
143
146
|
end
|
144
147
|
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
|
@@ -131,30 +131,27 @@ def set_system_clipboard(arg)
|
|
131
131
|
clipboard.text = arg
|
132
132
|
end
|
133
133
|
|
134
|
-
def gui_create_buffer(id)
|
135
|
-
|
134
|
+
def gui_create_buffer(id, bufo)
|
135
|
+
debug "gui_create_buffer(#{id})"
|
136
136
|
buf1 = GtkSource::Buffer.new()
|
137
|
-
view = VSourceView.new()
|
138
|
-
|
139
|
-
view.set_highlight_current_line(true)
|
140
|
-
view.set_show_line_numbers(true)
|
141
|
-
view.set_buffer(buf1)
|
137
|
+
view = VSourceView.new(nil, bufo)
|
142
138
|
|
143
139
|
ssm = GtkSource::StyleSchemeManager.new
|
144
140
|
ssm.set_search_path(ssm.search_path << ppath("styles/"))
|
145
|
-
# sty = ssm.get_scheme("dark")
|
146
141
|
sty = ssm.get_scheme("molokai_edit")
|
147
|
-
# puts ssm.scheme_ids
|
148
142
|
|
149
|
-
|
150
|
-
|
143
|
+
buf1.highlight_matching_brackets = true
|
144
|
+
buf1.style_scheme = sty
|
145
|
+
|
146
|
+
view.set_highlight_current_line(true)
|
147
|
+
view.set_show_line_numbers(true)
|
148
|
+
view.set_buffer(buf1)
|
151
149
|
|
152
150
|
provider = Gtk::CssProvider.new
|
153
151
|
provider.load(data: "textview { font-family: Monospace; font-size: 11pt; }")
|
154
|
-
# provider.load(data: "textview { font-family: Arial; font-size: 12pt; }")
|
155
152
|
view.style_context.add_provider(provider)
|
156
153
|
view.wrap_mode = :char
|
157
|
-
view.set_tab_width(
|
154
|
+
view.set_tab_width(conf(:tab_width))
|
158
155
|
|
159
156
|
$vmag.buffers[id] = view
|
160
157
|
end
|
@@ -177,25 +174,18 @@ end
|
|
177
174
|
def gui_select_window_close(arg = nil)
|
178
175
|
end
|
179
176
|
|
180
|
-
# def set_window_title(str)
|
181
|
-
# unimplemented
|
182
|
-
# end
|
183
|
-
|
184
177
|
def gui_set_buffer_contents(id, txt)
|
185
|
-
#
|
186
|
-
|
187
|
-
|
188
|
-
$vmag.buffers[id].buffer.set_text(txt)
|
178
|
+
debug "gui_set_buffer_contents(#{id}, txt)"
|
179
|
+
vma.gui.buffers[id].buffer.set_text(txt)
|
189
180
|
end
|
190
181
|
|
191
182
|
def gui_set_cursor_pos(id, pos)
|
192
|
-
|
193
|
-
# Ripl.start :binding => binding
|
183
|
+
vma.buf.view.set_cursor_pos(pos)
|
194
184
|
end
|
195
185
|
|
196
186
|
def gui_set_current_buffer(id)
|
197
187
|
view = $vmag.buffers[id]
|
198
|
-
|
188
|
+
debug "gui_set_current_buffer(#{id}), view=#{view}"
|
199
189
|
buf1 = view.buffer
|
200
190
|
$vmag.view = view
|
201
191
|
$vmag.buf1 = buf1
|
@@ -206,17 +196,9 @@ def gui_set_current_buffer(id)
|
|
206
196
|
$vmag.sw.add(view)
|
207
197
|
|
208
198
|
view.grab_focus
|
209
|
-
#view.set_focus(10)
|
210
199
|
view.set_cursor_visible(true)
|
211
|
-
#view.move_cursor(1, 1, false)
|
212
200
|
view.place_cursor_onscreen
|
213
201
|
|
214
|
-
#TODO:
|
215
|
-
# itr = view.buffer.get_iter_at(:offset => 0)
|
216
|
-
# view.buffer.place_cursor(itr)
|
217
|
-
|
218
|
-
# wtitle = ""
|
219
|
-
# wtitle = buf.fname if !buf.fname.nil?
|
220
202
|
$vmag.sw.show_all
|
221
203
|
end
|
222
204
|
|
@@ -226,7 +208,7 @@ def gui_set_window_title(wtitle, subtitle = "")
|
|
226
208
|
end
|
227
209
|
|
228
210
|
class VMAgui
|
229
|
-
attr_accessor :buffers, :sw, :view, :buf1, :window
|
211
|
+
attr_accessor :buffers, :sw, :view, :buf1, :window, :delex, :statnfo
|
230
212
|
|
231
213
|
VERSION = "1.0"
|
232
214
|
|
@@ -242,6 +224,22 @@ class VMAgui
|
|
242
224
|
@buffers = {}
|
243
225
|
@view = nil
|
244
226
|
@buf1 = nil
|
227
|
+
@img_resizer_active = false
|
228
|
+
imgproc = proc {
|
229
|
+
GLib::Idle.add(proc {
|
230
|
+
if !buf.images.empty?
|
231
|
+
vma.gui.scale_all_images
|
232
|
+
|
233
|
+
w = Gtk::Window.new(:toplevel)
|
234
|
+
w.set_default_size(1, 1)
|
235
|
+
w.show_all
|
236
|
+
Thread.new { sleep 0.1; w.destroy }
|
237
|
+
end
|
238
|
+
|
239
|
+
false
|
240
|
+
})
|
241
|
+
}
|
242
|
+
@delex = DelayExecutioner.new(1, imgproc)
|
245
243
|
end
|
246
244
|
|
247
245
|
def run
|
@@ -250,6 +248,38 @@ class VMAgui
|
|
250
248
|
Gtk.main
|
251
249
|
end
|
252
250
|
|
251
|
+
def delay_scale()
|
252
|
+
if Time.now - @dtime > 2.0
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def scale_all_images
|
257
|
+
# puts "scale all"
|
258
|
+
for img in buf.images
|
259
|
+
if !img[:obj].destroyed?
|
260
|
+
img[:obj].scale_image
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def handle_image_resize
|
266
|
+
return if @img_resizer_active == true
|
267
|
+
@dtime = Time.now
|
268
|
+
|
269
|
+
$gcrw = 0
|
270
|
+
vma.gui.window.signal_connect "configure-event" do |widget, cr|
|
271
|
+
# Ripl.start :binding => binding
|
272
|
+
|
273
|
+
if $gcrw != cr.width
|
274
|
+
@delex.run
|
275
|
+
end
|
276
|
+
$gcrw = cr.width
|
277
|
+
false
|
278
|
+
end
|
279
|
+
|
280
|
+
@img_resizer_active = true
|
281
|
+
end
|
282
|
+
|
253
283
|
def start_overlay_draw()
|
254
284
|
@da = Gtk::Fixed.new
|
255
285
|
@overlay.add_overlay(@da)
|
@@ -263,10 +293,10 @@ class VMAgui
|
|
263
293
|
end
|
264
294
|
|
265
295
|
def overlay_draw_text(text, textpos)
|
266
|
-
#
|
296
|
+
# debug "overlay_draw_text #{[x,y]}"
|
267
297
|
(x, y) = @view.pos_to_coord(textpos)
|
268
|
-
#
|
269
|
-
label = Gtk::Label.new("<span background='#
|
298
|
+
# debug "overlay_draw_text #{[x,y]}"
|
299
|
+
label = Gtk::Label.new("<span background='#000000ff' foreground='#ff0000' weight='ultrabold'>#{text}</span>")
|
270
300
|
label.use_markup = true
|
271
301
|
@da.put(label, x, y)
|
272
302
|
end
|
@@ -301,7 +331,7 @@ class VMAgui
|
|
301
331
|
# istart = @view.get_iter_at_y(vr.y)
|
302
332
|
# startpos = @view.get_iter_at_position_raw(vr.x,vr.y)[1].offset
|
303
333
|
# endpos = @view.get_iter_at_position_raw(vr.x+vr.width,vr.y+vr.height)[1].offset
|
304
|
-
#
|
334
|
+
# debug "startpos,endpos:#{[startpos, endpos]}"
|
305
335
|
|
306
336
|
da = @da
|
307
337
|
if false
|
@@ -335,7 +365,7 @@ class VMAgui
|
|
335
365
|
da.put(label, x, y)
|
336
366
|
end
|
337
367
|
|
338
|
-
#
|
368
|
+
# debug @view.pos_to_coord(300).inspect
|
339
369
|
|
340
370
|
@da.show_all
|
341
371
|
end
|
@@ -370,21 +400,21 @@ class VMAgui
|
|
370
400
|
overlay = Gtk::Overlay.new
|
371
401
|
overlay.add(sw)
|
372
402
|
# @vpaned.pack2(overlay, :resize => false)
|
373
|
-
@vbox.attach(overlay, 0, 2,
|
403
|
+
@vbox.attach(overlay, 0, 2, 2, 1)
|
374
404
|
# overlay.set_size_request(-1, 50)
|
375
405
|
# $ovrl = overlay
|
376
406
|
# $ovrl.set_size_request(-1, 30)
|
377
407
|
$sw2 = sw
|
378
408
|
sw.set_size_request(-1, 12)
|
379
409
|
|
380
|
-
view = VSourceView.new()
|
410
|
+
view = VSourceView.new(nil, nil)
|
381
411
|
view.set_highlight_current_line(false)
|
382
412
|
view.set_show_line_numbers(false)
|
383
413
|
# view.set_buffer(buf1)
|
384
414
|
ssm = GtkSource::StyleSchemeManager.new
|
385
415
|
ssm.set_search_path(ssm.search_path << ppath("styles/"))
|
386
416
|
sty = ssm.get_scheme("molokai_edit")
|
387
|
-
view.buffer.highlight_matching_brackets = false
|
417
|
+
view.buffer.highlight_matching_brackets = false #TODO
|
388
418
|
view.buffer.style_scheme = sty
|
389
419
|
provider = Gtk::CssProvider.new
|
390
420
|
# provider.load(data: "textview { font-family: Monospace; font-size: 11pt; }")
|
@@ -405,7 +435,6 @@ class VMAgui
|
|
405
435
|
header.title = ""
|
406
436
|
header.has_subtitle = true
|
407
437
|
header.subtitle = ""
|
408
|
-
# Ripl.start :binding => binding
|
409
438
|
|
410
439
|
# icon = Gio::ThemedIcon.new("mail-send-receive-symbolic")
|
411
440
|
# icon = Gio::ThemedIcon.new("document-open-symbolic")
|
@@ -481,69 +510,46 @@ class VMAgui
|
|
481
510
|
|
482
511
|
header.pack_start(box)
|
483
512
|
@window.titlebar = header
|
484
|
-
@window.add(Gtk::TextView.new)
|
485
|
-
end
|
486
|
-
|
487
|
-
def create_menu_item(label, depth)
|
488
|
-
menuitem = Gtk::MenuItem.new(:label => label)
|
489
|
-
menuitem.submenu = create_menu(depth)
|
490
|
-
@menubar.append(menuitem)
|
491
|
-
end
|
492
|
-
|
493
|
-
def create_menu(depth)
|
494
|
-
return nil if depth < 1
|
495
|
-
|
496
|
-
menu = Gtk::Menu.new
|
497
|
-
last_item = nil
|
498
|
-
(0..5).each do |i|
|
499
|
-
j = i + 1
|
500
|
-
label = "item #{depth} - #{j}"
|
501
|
-
menu_item = Gtk::RadioMenuItem.new(nil, label)
|
502
|
-
menu_item.join_group(last_item) if last_item
|
503
|
-
last_item = menu_item
|
504
|
-
menu.append(menu_item)
|
505
|
-
menu_item.sensitive = false if i == 3
|
506
|
-
menu_item.submenu = create_menu(depth - 1)
|
507
|
-
end
|
508
|
-
|
509
|
-
menu
|
513
|
+
# @window.add(Gtk::TextView.new)
|
510
514
|
end
|
511
515
|
|
512
516
|
def init_window
|
513
517
|
@window = Gtk::Window.new(:toplevel)
|
514
|
-
@window.
|
518
|
+
sh = @window.screen.height
|
519
|
+
sw = @window.screen.width
|
520
|
+
# TODO:Maximise vertically
|
521
|
+
@window.set_default_size((sw * 0.45).to_i, sh - 20)
|
522
|
+
|
515
523
|
@window.title = "Multiple Views"
|
516
524
|
@window.show_all
|
517
|
-
# vpaned = Gtk::Paned.new(:horizontal)
|
518
525
|
@vpaned = Gtk::Paned.new(:vertical)
|
519
|
-
|
520
|
-
# @vbox = Gtk::Box.new(:vertical, 0)
|
526
|
+
|
521
527
|
@vbox = Gtk::Grid.new()
|
522
528
|
@window.add(@vbox)
|
523
529
|
|
524
530
|
@menubar = Gtk::MenuBar.new
|
525
531
|
@menubar.expand = false
|
526
|
-
|
527
532
|
|
528
533
|
@sw = Gtk::ScrolledWindow.new
|
529
534
|
@sw.set_policy(:automatic, :automatic)
|
530
535
|
@overlay = Gtk::Overlay.new
|
531
536
|
@overlay.add(@sw)
|
532
537
|
|
533
|
-
# @vpaned.pack1(@overlay, :resize => true)
|
534
|
-
# @vpaned.pack2(@menubar, :resize => false)
|
535
|
-
# @vbox.add(@menubar, :resize => false)
|
536
|
-
|
537
538
|
init_header_bar
|
538
539
|
|
539
|
-
|
540
|
+
@statnfo = Gtk::Label.new
|
541
|
+
provider = Gtk::CssProvider.new
|
542
|
+
provider.load(data: "textview { background-color:#353535; font-family: Monospace; font-size: 10pt; margin-top:4px;}")
|
543
|
+
@statnfo.style_context.add_provider(provider)
|
544
|
+
|
545
|
+
# Deprecated, but found no other way to do it. css doesn't work.
|
546
|
+
# TODO: should select color automatically from theme
|
547
|
+
@statnfo.override_background_color(Gtk::StateFlags::NORMAL, "#353535")
|
540
548
|
|
541
|
-
#
|
542
|
-
# @vbox.pack_start(@menubar)
|
543
|
-
# @vbox.pack_start(@overlay, :expand => true, :fill => true, :padding => 0 )
|
544
|
-
# @vbox.pack_start(@overlay, :expand => true, :fill => true, :padding => 0 )
|
549
|
+
# column, row, width height
|
545
550
|
@vbox.attach(@menubar, 0, 0, 1, 1)
|
546
|
-
@vbox.attach(@
|
551
|
+
@vbox.attach(@statnfo, 1, 0, 1, 1)
|
552
|
+
@vbox.attach(@overlay, 0, 1, 2, 1)
|
547
553
|
@overlay.vexpand = true
|
548
554
|
@overlay.hexpand = true
|
549
555
|
|
@@ -552,11 +558,10 @@ class VMAgui
|
|
552
558
|
|
553
559
|
init_minibuffer
|
554
560
|
|
555
|
-
|
556
561
|
@window.show_all
|
557
562
|
vma.start
|
558
563
|
Vimamsa::Menu.new(@menubar)
|
564
|
+
|
559
565
|
@window.show_all
|
560
|
-
|
561
566
|
end
|
562
567
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
# Following this example:
|
3
|
+
# https://gabmus.org/posts/create_an_auto-resizing_image_widget_with_gtk3_and_python/
|
4
|
+
class ResizableImage < Gtk::DrawingArea
|
5
|
+
attr_accessor :fpath, :pixbuf, :oldimg, :draw_image, :view
|
6
|
+
|
7
|
+
def initialize(fpath, view)
|
8
|
+
@fpath = fpath
|
9
|
+
@pixbuf = GdkPixbuf::Pixbuf.new(:file => fpath)
|
10
|
+
@oldimg = @pixbuf
|
11
|
+
@draw_image = @pixbuf
|
12
|
+
@view = view
|
13
|
+
|
14
|
+
super()
|
15
|
+
end
|
16
|
+
|
17
|
+
# Scale to fit window width
|
18
|
+
def scale_image()
|
19
|
+
pb = @pixbuf
|
20
|
+
view = @view
|
21
|
+
imglimit = view.visible_rect.width - 10
|
22
|
+
|
23
|
+
if @oldimg.width > imglimit or @oldimg.width < imglimit - 10
|
24
|
+
nwidth = imglimit
|
25
|
+
nwidth = pb.width if pb.width < imglimit
|
26
|
+
nheight = (pb.height * (nwidth.to_f / pb.width)).to_i
|
27
|
+
pb = pb.scale_simple(nwidth, nheight, GdkPixbuf::InterpType::HYPER)
|
28
|
+
else
|
29
|
+
pb = @oldimg
|
30
|
+
end
|
31
|
+
@draw_image = pb
|
32
|
+
@oldimg = pb
|
33
|
+
self.set_size_request(pb.width, pb.height)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def do_draw(da, cr)
|
38
|
+
# puts @fpath
|
39
|
+
cr.set_source_pixbuf(@draw_image, 0, 0)
|
40
|
+
cr.paint
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
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,14 @@ 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 }
|
40
|
-
|
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
|
+
|
41
48
|
add_to_menu "Actions.EncryptFile", { :label => "Encrypt file", :action => :encrypt_file }
|
49
|
+
add_to_menu "Help.KeyBindings", { :label => "Show key bindings", :action => :show_key_bindings }
|
50
|
+
|
42
51
|
|
43
52
|
#TODO: :auto_indent_buffer
|
44
53
|
|