vimamsa 0.1.18 → 0.1.20
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 +1 -1
- data/demo.txt +1 -1
- data/exe/vimamsa +1 -1
- data/ext/vmaext/extconf.rb +5 -0
- data/lib/vimamsa/ack.rb +7 -16
- data/lib/vimamsa/buffer.rb +10 -5
- data/lib/vimamsa/buffer_changetext.rb +1 -1
- data/lib/vimamsa/buffer_list.rb +44 -10
- data/lib/vimamsa/conf.rb +28 -60
- data/lib/vimamsa/debug.rb +1 -1
- data/lib/vimamsa/editor.rb +22 -27
- data/lib/vimamsa/file_finder.rb +78 -10
- data/lib/vimamsa/gui.rb +119 -153
- data/lib/vimamsa/gui_dialog.rb +11 -8
- data/lib/vimamsa/gui_form_generator.rb +6 -8
- data/lib/vimamsa/gui_menu.rb +12 -10
- data/lib/vimamsa/gui_select_window.rb +3 -1
- data/lib/vimamsa/gui_sourceview.rb +41 -23
- data/lib/vimamsa/key_actions.rb +16 -13
- data/lib/vimamsa/key_binding_tree.rb +0 -2
- data/lib/vimamsa/key_bindings_vimlike.rb +1 -2
- data/lib/vimamsa/langservp.rb +1 -2
- data/lib/vimamsa/macro.rb +1 -1
- data/lib/vimamsa/text_transforms.rb +4 -1
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +3 -0
- data/vimamsa.gemspec +3 -2
- metadata +16 -3
- data/.vma_project +0 -0
data/lib/vimamsa/gui.rb
CHANGED
@@ -142,7 +142,8 @@ def gui_create_buffer(id, bufo)
|
|
142
142
|
provider.load(data: "textview { font-family: #{cnf.font.family!}; font-size: #{cnf.font.size!}pt; }")
|
143
143
|
view.style_context.add_provider(provider)
|
144
144
|
view.wrap_mode = :char
|
145
|
-
|
145
|
+
|
146
|
+
view.set_tab_width(cnf.tab.width!)
|
146
147
|
|
147
148
|
$vmag.buffers[id] = view
|
148
149
|
end
|
@@ -189,8 +190,8 @@ def gui_set_window_title(wtitle, subtitle = "")
|
|
189
190
|
end
|
190
191
|
|
191
192
|
class VMAgui
|
192
|
-
attr_accessor :buffers, :
|
193
|
-
attr_reader :two_column, :windows, :subtitle, :app
|
193
|
+
attr_accessor :buffers, :sw1, :sw2, :view, :buf1, :window, :delex, :statnfo, :overlay, :sws, :two_c
|
194
|
+
attr_reader :two_column, :windows, :subtitle, :app, :active_window
|
194
195
|
|
195
196
|
def initialize()
|
196
197
|
@two_column = false
|
@@ -219,6 +220,7 @@ class VMAgui
|
|
219
220
|
t.exit
|
220
221
|
end
|
221
222
|
end
|
223
|
+
@app.quit
|
222
224
|
end
|
223
225
|
|
224
226
|
def scale_all_images
|
@@ -251,7 +253,7 @@ class VMAgui
|
|
251
253
|
|
252
254
|
def start_overlay_draw()
|
253
255
|
@da = Gtk::Fixed.new
|
254
|
-
@overlay.add_overlay(@da)
|
256
|
+
@active_window[:overlay].add_overlay(@da)
|
255
257
|
|
256
258
|
# @overlay.set_overlay_pass_through(@da, true) #TODO:gtk4
|
257
259
|
end
|
@@ -259,7 +261,7 @@ class VMAgui
|
|
259
261
|
def clear_overlay()
|
260
262
|
if @da != nil
|
261
263
|
# @overlay.remove(@da)
|
262
|
-
@overlay.remove_overlay(@da)
|
264
|
+
@active_window[:overlay].remove_overlay(@da)
|
263
265
|
end
|
264
266
|
end
|
265
267
|
|
@@ -276,20 +278,6 @@ class VMAgui
|
|
276
278
|
@da.show
|
277
279
|
end
|
278
280
|
|
279
|
-
def remove_overlay_cursor()
|
280
|
-
if !@cursorov.nil?
|
281
|
-
@overlay.remove_overlay(@cursorov)
|
282
|
-
@cursorov = nil
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
def overlay_draw_cursor(textpos)
|
287
|
-
# return
|
288
|
-
remove_overlay_cursor
|
289
|
-
GLib::Idle.add(proc { self.overlay_draw_cursor_(textpos) })
|
290
|
-
# overlay_draw_cursor_(textpos)
|
291
|
-
end
|
292
|
-
|
293
281
|
# Run proc after animated scrolling has stopped (e.g. after page down)
|
294
282
|
def run_after_scrolling(p)
|
295
283
|
Thread.new {
|
@@ -306,31 +294,6 @@ class VMAgui
|
|
306
294
|
}
|
307
295
|
end
|
308
296
|
|
309
|
-
# To draw on empty lines and line-ends (where select_range doesn't work)
|
310
|
-
def overlay_draw_cursor_(textpos)
|
311
|
-
# Thread.new {
|
312
|
-
# GLib::Idle.add(proc { p.call; false })
|
313
|
-
# }
|
314
|
-
|
315
|
-
# while Time.now - @last_adj_time < 0.3
|
316
|
-
# return true
|
317
|
-
# end
|
318
|
-
|
319
|
-
remove_overlay_cursor
|
320
|
-
@cursorov = Gtk::Fixed.new
|
321
|
-
@overlay.add_overlay(@cursorov)
|
322
|
-
|
323
|
-
(x, y) = @view.pos_to_coord(textpos)
|
324
|
-
pp [x, y]
|
325
|
-
|
326
|
-
# Trying to draw only background of character "I"
|
327
|
-
label = Gtk::Label.new("<span background='#00ffaaff' foreground='#00ffaaff' weight='ultrabold'>I</span>")
|
328
|
-
label.use_markup = true
|
329
|
-
@cursorov.put(label, x, y)
|
330
|
-
@cursorov.show
|
331
|
-
return false
|
332
|
-
end
|
333
|
-
|
334
297
|
def handle_deltas()
|
335
298
|
view.delete_cursor_char
|
336
299
|
while d = buf.deltas.shift
|
@@ -385,6 +348,7 @@ class VMAgui
|
|
385
348
|
sw.set_child(view)
|
386
349
|
end
|
387
350
|
|
351
|
+
#TODO: implement in gtk4
|
388
352
|
def init_header_bar()
|
389
353
|
header = Gtk::HeaderBar.new
|
390
354
|
@header = header
|
@@ -407,13 +371,13 @@ class VMAgui
|
|
407
371
|
# icon = Gio::ThemedIcon.new("open-menu-symbolic")
|
408
372
|
# image = Gtk::Image.new(:icon => icon, :size => :button)
|
409
373
|
# button.add(image)
|
410
|
-
# header.
|
374
|
+
# header.append(button)
|
411
375
|
|
412
376
|
button = Gtk::Button.new
|
413
377
|
icon = Gio::ThemedIcon.new("document-open-symbolic")
|
414
378
|
image = Gtk::Image.new(:icon => icon, :size => :button)
|
415
379
|
button.add(image)
|
416
|
-
header.
|
380
|
+
header.append(button)
|
417
381
|
|
418
382
|
button.signal_connect "clicked" do |_widget|
|
419
383
|
open_file_dialog
|
@@ -423,7 +387,7 @@ class VMAgui
|
|
423
387
|
icon = Gio::ThemedIcon.new("document-save-symbolic")
|
424
388
|
image = Gtk::Image.new(:icon => icon, :size => :button)
|
425
389
|
button.add(image)
|
426
|
-
header.
|
390
|
+
header.append(button)
|
427
391
|
button.signal_connect "clicked" do |_widget|
|
428
392
|
buf.save
|
429
393
|
end
|
@@ -432,7 +396,7 @@ class VMAgui
|
|
432
396
|
icon = Gio::ThemedIcon.new("document-new-symbolic")
|
433
397
|
image = Gtk::Image.new(:icon => icon, :size => :button)
|
434
398
|
button.add(image)
|
435
|
-
header.
|
399
|
+
header.append(button)
|
436
400
|
button.signal_connect "clicked" do |_widget|
|
437
401
|
create_new_file
|
438
402
|
end
|
@@ -467,7 +431,6 @@ class VMAgui
|
|
467
431
|
|
468
432
|
header.pack_start(box)
|
469
433
|
@window.titlebar = header
|
470
|
-
# @window.add(Gtk::TextView.new)
|
471
434
|
end
|
472
435
|
|
473
436
|
def debug_idle_func
|
@@ -478,7 +441,7 @@ class VMAgui
|
|
478
441
|
# @view.check_controllers
|
479
442
|
end
|
480
443
|
|
481
|
-
ctrl_fn = File.expand_path("
|
444
|
+
ctrl_fn = File.expand_path(get_dot_path("ripl_ctrl"))
|
482
445
|
# Allows to debug in case keyboard handling is lost
|
483
446
|
if File.exist?(ctrl_fn)
|
484
447
|
File.delete(ctrl_fn)
|
@@ -595,6 +558,8 @@ class VMAgui
|
|
595
558
|
|
596
559
|
Gtk::Settings.default.gtk_application_prefer_dark_theme = true
|
597
560
|
Gtk::Settings.default.gtk_theme_name = "Adwaita"
|
561
|
+
Gtk::Settings.default.gtk_cursor_blink = false
|
562
|
+
Gtk::Settings.default.gtk_cursor_blink_time = 4000
|
598
563
|
|
599
564
|
app.signal_connect "activate" do
|
600
565
|
@window = Gtk::ApplicationWindow.new(app)
|
@@ -612,29 +577,22 @@ class VMAgui
|
|
612
577
|
|
613
578
|
reset_controllers
|
614
579
|
|
615
|
-
@
|
616
|
-
@sw.set_policy(:automatic, :automatic)
|
580
|
+
@windows[1] = new_window(1)
|
617
581
|
|
618
582
|
@last_adj_time = Time.now
|
619
|
-
@sw.vadjustment.signal_connect("value-changed") { |x|
|
620
|
-
# pp x.page_increment
|
621
|
-
# pp x.page_size
|
622
|
-
# pp x.step_increment
|
623
|
-
# pp x.upper
|
624
|
-
# pp x.value
|
625
|
-
# pp x
|
626
|
-
@last_adj_time = Time.now
|
627
|
-
}
|
628
583
|
|
629
|
-
@overlay = Gtk::Overlay.new
|
630
|
-
@overlay.add_overlay(@sw)
|
631
584
|
|
585
|
+
# To show keyboard key binding state
|
632
586
|
@statnfo = Gtk::Label.new
|
587
|
+
|
588
|
+
# To show e.g. current folder
|
633
589
|
@subtitle = Gtk::Label.new("")
|
590
|
+
|
634
591
|
@statbox = Gtk::Box.new(:horizontal, 2)
|
635
592
|
@statnfo.set_size_request(150, 10)
|
636
|
-
@statbox.
|
637
|
-
@
|
593
|
+
@statbox.append(@subtitle)
|
594
|
+
@subtitle.hexpand = true
|
595
|
+
@statbox.append(@statnfo)
|
638
596
|
provider = Gtk::CssProvider.new
|
639
597
|
@statnfo.add_css_class("statnfo")
|
640
598
|
provider.load(data: "label.statnfo { background-color:#353535; font-size: 10pt; margin-top:2px; margin-bottom:2px; align:right;}")
|
@@ -643,50 +601,19 @@ class VMAgui
|
|
643
601
|
@statnfo.style_context.add_provider(provider)
|
644
602
|
|
645
603
|
# numbers: left, top, width, height
|
646
|
-
@vbox.attach(@overlay, 0, 2, 2, 1)
|
647
|
-
@sw.vexpand = true
|
648
|
-
@sw.hexpand = true
|
604
|
+
@vbox.attach(@windows[1][:overlay], 0, 2, 2, 1)
|
649
605
|
|
650
606
|
# column, row, width height
|
651
607
|
@vbox.attach(@statbox, 1, 1, 1, 1)
|
652
608
|
|
653
|
-
@overlay.vexpand = true
|
654
|
-
@overlay.hexpand = true
|
655
|
-
|
656
609
|
init_minibuffer
|
657
610
|
|
658
|
-
name = "save"
|
659
|
-
window = @window
|
660
|
-
action = Gio::SimpleAction.new(name)
|
661
|
-
action.signal_connect "activate" do |_simple_action, _parameter|
|
662
|
-
dialog = Gtk::MessageDialog.new(:parent => window,
|
663
|
-
:flags => :destroy_with_parent,
|
664
|
-
:buttons => :close,
|
665
|
-
:message => "Action FOOBAR activated.")
|
666
|
-
dialog.signal_connect(:response) do
|
667
|
-
dialog.destroy
|
668
|
-
end
|
669
|
-
dialog.show
|
670
|
-
end
|
671
|
-
|
672
|
-
@window.add_action(action)
|
673
|
-
doc_actions = Gio::SimpleActionGroup.new
|
674
|
-
doc_actions.add_action(action)
|
675
|
-
|
676
|
-
act_quit = Gio::SimpleAction.new("quit")
|
677
|
-
app.add_action(act_quit)
|
678
|
-
act_quit.signal_connect "activate" do |_simple_action, _parameter|
|
679
|
-
window.destroy
|
680
|
-
exit!
|
681
|
-
end
|
682
|
-
|
683
611
|
menubar = Gio::Menu.new
|
684
612
|
app.menubar = menubar
|
685
613
|
@window.show_menubar = true
|
686
614
|
|
687
615
|
@menubar = menubar
|
688
616
|
|
689
|
-
@windows[1] = { :sw => @sw, :overlay => @overlay, :id => 1 }
|
690
617
|
@active_window = @windows[1]
|
691
618
|
|
692
619
|
@window.show
|
@@ -727,23 +654,20 @@ class VMAgui
|
|
727
654
|
vma.start
|
728
655
|
end
|
729
656
|
|
730
|
-
# Vimamsa::Menu.new(@menubar) #TODO:gtk4
|
731
657
|
GLib::Idle.add(proc { self.monitor })
|
732
658
|
|
733
659
|
app.run
|
734
|
-
|
735
|
-
# @window.show_all
|
736
|
-
# @window.show
|
737
660
|
end
|
738
661
|
|
739
662
|
def monitor
|
663
|
+
swa = @windows[1][:sw]
|
740
664
|
@monitor_time ||= Time.now
|
741
|
-
@sw_width ||=
|
665
|
+
@sw_width ||= swa.width
|
742
666
|
return true if Time.now - @monitor_time < 0.2
|
743
667
|
# Detect element resize
|
744
|
-
if
|
668
|
+
if swa.width != @sw_width
|
745
669
|
# puts "@sw.width=#{@sw.width}"
|
746
|
-
@sw_width =
|
670
|
+
@sw_width = swa.width
|
747
671
|
DelayExecutioner.exec(id: :scale_images, wait: 0.7, callable: proc { vma.gui.scale_all_images })
|
748
672
|
end
|
749
673
|
@monitor_time = Time.now
|
@@ -764,54 +688,86 @@ class VMAgui
|
|
764
688
|
|
765
689
|
def set_one_column
|
766
690
|
return if !@two_column
|
691
|
+
#This always closes the leftmost column/window
|
692
|
+
#TODO: close rightmost column if left active
|
693
|
+
set_active_window(1)
|
694
|
+
|
767
695
|
@windows[2][:sw].set_child(nil)
|
768
696
|
@windows.delete(2)
|
697
|
+
w1 = @windows[1]
|
769
698
|
|
770
699
|
@pane.set_start_child(nil)
|
771
700
|
@pane.set_end_child(nil)
|
772
701
|
|
773
702
|
@vbox.remove(@pane)
|
774
|
-
@vbox.attach(
|
775
|
-
@vbox.attach(@statbox, 1, 1, 1, 1)
|
703
|
+
@vbox.attach(w1[:overlay], 0, 2, 2, 1)
|
704
|
+
# @vbox.attach(@statbox, 1, 1, 1, 1)
|
776
705
|
@two_column = false
|
777
706
|
end
|
778
707
|
|
779
|
-
def
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
# @
|
785
|
-
|
786
|
-
@sw2 = Gtk::ScrolledWindow.new
|
787
|
-
@sw2.set_policy(:automatic, :automatic)
|
788
|
-
@overlay2 = Gtk::Overlay.new
|
789
|
-
@overlay2.add_overlay(@sw2)
|
790
|
-
@pane = Gtk::Paned.new(:horizontal)
|
708
|
+
def new_window(win_id)
|
709
|
+
n_sw = Gtk::ScrolledWindow.new
|
710
|
+
n_sw.set_policy(:automatic, :automatic)
|
711
|
+
n_overlay = Gtk::Overlay.new
|
712
|
+
n_overlay.add_overlay(n_sw)
|
713
|
+
# @pane = Gtk::Paned.new(:horizontal)
|
791
714
|
|
792
|
-
|
715
|
+
win = { :sw => n_sw, :overlay => n_overlay, :id => win_id }
|
716
|
+
# @windows[2] = { :sw => @sw2, :overlay => @overlay2, :id => 2 }
|
793
717
|
|
794
|
-
@vbox.remove(@overlay)
|
718
|
+
# @vbox.remove(@overlay)
|
795
719
|
|
796
|
-
@pane.set_start_child(@overlay2)
|
797
|
-
@pane.set_end_child(@overlay)
|
720
|
+
# @pane.set_start_child(@overlay2)
|
721
|
+
# @pane.set_end_child(@overlay)
|
798
722
|
|
799
723
|
# numbers: left, top, width, height
|
800
|
-
@vbox.attach(@pane, 0, 2, 2, 1)
|
724
|
+
# @vbox.attach(@pane, 0, 2, 2, 1)
|
725
|
+
|
726
|
+
n_sw.vexpand = true
|
727
|
+
n_sw.hexpand = true
|
728
|
+
|
729
|
+
n_overlay.vexpand = true
|
730
|
+
n_overlay.hexpand = true
|
731
|
+
|
732
|
+
# TODO: remove??
|
733
|
+
n_sw.vadjustment.signal_connect("value-changed") { |x|
|
734
|
+
# pp x.page_increment
|
735
|
+
# pp x.page_size
|
736
|
+
# pp x.step_increment
|
737
|
+
# pp x.upper
|
738
|
+
# pp x.value
|
739
|
+
# pp x
|
740
|
+
# @last_adj_time = Time.now
|
741
|
+
}
|
742
|
+
|
743
|
+
# @sw2.show
|
744
|
+
return win
|
745
|
+
end
|
746
|
+
|
747
|
+
def set_two_column
|
748
|
+
return if @two_column
|
749
|
+
@windows[2] = new_window(2)
|
750
|
+
|
751
|
+
w1 = @windows[1]
|
752
|
+
w2 = @windows[2]
|
801
753
|
|
802
|
-
@
|
803
|
-
@
|
754
|
+
# Remove overlay from @vbox and add the Gtk::Paned instead
|
755
|
+
@pane = Gtk::Paned.new(:horizontal)
|
756
|
+
@vbox.remove(w1[:overlay])
|
757
|
+
@pane.set_start_child(w2[:overlay])
|
758
|
+
@pane.set_end_child(w1[:overlay])
|
804
759
|
|
805
|
-
|
806
|
-
@
|
760
|
+
# numbers: left, top, width, height
|
761
|
+
@vbox.attach(@pane, 0, 2, 2, 1)
|
807
762
|
|
808
|
-
|
763
|
+
w2[:sw].show
|
809
764
|
@two_column = true
|
810
765
|
|
811
766
|
last = vma.buffers.get_last_visited_id
|
812
767
|
if !last.nil?
|
813
768
|
set_buffer_to_window(last, 2)
|
814
769
|
else
|
770
|
+
# If there is only one buffer, create a new one and add to the new window/column
|
815
771
|
bf = create_new_buffer "\n\n", "buff", false
|
816
772
|
set_buffer_to_window(bf.id, 2)
|
817
773
|
end
|
@@ -831,11 +787,17 @@ class VMAgui
|
|
831
787
|
end
|
832
788
|
end
|
833
789
|
|
834
|
-
#
|
790
|
+
# Activate that window which has the given view
|
835
791
|
def set_current_view(view)
|
792
|
+
# Window of current view:
|
836
793
|
w = @windows.find { |k, v| v[:sw].child == view }
|
794
|
+
# All other windows:
|
795
|
+
otherw = @windows.find_all { |k, v| v[:sw].child != view }
|
837
796
|
if !w.nil?
|
838
797
|
set_active_window(w[0])
|
798
|
+
for k, x in otherw
|
799
|
+
x[:sw].child.focus_out()
|
800
|
+
end
|
839
801
|
end
|
840
802
|
end
|
841
803
|
|
@@ -850,19 +812,21 @@ class VMAgui
|
|
850
812
|
end
|
851
813
|
|
852
814
|
@active_window = @windows[id]
|
853
|
-
@active_column = id
|
815
|
+
@active_column = id
|
854
816
|
|
855
|
-
@
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
817
|
+
@active_window[:sw].child.focus_in()
|
818
|
+
for k, w in @windows
|
819
|
+
if w != @active_window
|
820
|
+
fochild = w[:sw].child
|
821
|
+
run_as_idle proc { fochild.focus_out() }
|
822
|
+
end
|
823
|
+
end
|
861
824
|
|
825
|
+
vma.buffers.set_current_buffer_by_id(@active_window[:sw].child.bufo.id)
|
862
826
|
end
|
863
827
|
|
864
828
|
def current_view
|
865
|
-
return @sw.child
|
829
|
+
return @active_window[:sw].child
|
866
830
|
end
|
867
831
|
|
868
832
|
def set_buffer_to_window(bufid, winid)
|
@@ -873,9 +837,6 @@ class VMAgui
|
|
873
837
|
@windows[winid][:sw].set_child(view)
|
874
838
|
idle_ensure_cursor_drawn
|
875
839
|
|
876
|
-
# @overlay = Gtk::Overlay.new
|
877
|
-
# @overlay.add_overlay(view)
|
878
|
-
|
879
840
|
#TODO:???
|
880
841
|
# @view = view
|
881
842
|
# @buf1 = buf1
|
@@ -885,10 +846,10 @@ class VMAgui
|
|
885
846
|
end
|
886
847
|
|
887
848
|
def set_current_buffer(id)
|
888
|
-
|
849
|
+
view2 = @buffers[id]
|
889
850
|
debug "vma.gui.set_current_buffer(#{id}), view=#{view}"
|
890
|
-
buf1 =
|
891
|
-
@view =
|
851
|
+
buf1 = view2.buffer
|
852
|
+
@view = view2
|
892
853
|
@buf1 = buf1
|
893
854
|
$view = view
|
894
855
|
$vbuf = buf1
|
@@ -901,14 +862,17 @@ class VMAgui
|
|
901
862
|
toggle_active_window
|
902
863
|
else
|
903
864
|
#TODO: improve
|
904
|
-
@
|
905
|
-
@
|
865
|
+
swa = @active_window[:sw]
|
866
|
+
ol = @active_window[:overlay]
|
867
|
+
ol.remove_overlay(swa)
|
868
|
+
swa.set_child(nil)
|
906
869
|
# Creating a new ScrolledWindow every time to avoid a layout bug
|
907
870
|
# https://gitlab.gnome.org/GNOME/gtk/-/issues/6189
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
@active_window[:
|
871
|
+
swb = new_scrolled_window
|
872
|
+
swb.set_child(view2)
|
873
|
+
ol.add_overlay(swb)
|
874
|
+
@active_window[:view] = view
|
875
|
+
@active_window[:sw] = swb
|
912
876
|
end
|
913
877
|
view.grab_focus
|
914
878
|
|
@@ -927,18 +891,20 @@ class VMAgui
|
|
927
891
|
end
|
928
892
|
|
929
893
|
def page_down(multip: 1.0)
|
930
|
-
|
894
|
+
sw = @active_window[:sw]
|
895
|
+
va = sw.vadjustment
|
931
896
|
newval = va.value + va.page_increment * multip
|
932
897
|
va.value = newval
|
933
|
-
|
898
|
+
sw.child.set_cursor_to_top
|
934
899
|
end
|
935
900
|
|
936
901
|
def page_up(multip: 1.0)
|
937
|
-
|
902
|
+
sw = @active_window[:sw]
|
903
|
+
va = sw.vadjustment
|
938
904
|
newval = va.value - va.page_increment * multip
|
939
905
|
newval = 0 if newval < 0
|
940
906
|
va.value = newval
|
941
|
-
|
907
|
+
sw.child.set_cursor_to_top
|
942
908
|
end
|
943
909
|
|
944
910
|
def idle_ensure_cursor_drawn
|
data/lib/vimamsa/gui_dialog.rb
CHANGED
@@ -40,8 +40,9 @@ class OneInputAction
|
|
40
40
|
def initialize(main_window, title, field_label, button_title, callback, opt = {})
|
41
41
|
@window = Gtk::Window.new()
|
42
42
|
# @window.screen = main_window.screen
|
43
|
-
# @window.title = title
|
44
43
|
@window.title = ""
|
44
|
+
# @window.width_request = 800
|
45
|
+
# @window.hexpand = false
|
45
46
|
|
46
47
|
frame = Gtk::Frame.new()
|
47
48
|
# frame.margin = 20
|
@@ -49,15 +50,17 @@ class OneInputAction
|
|
49
50
|
|
50
51
|
infolabel = Gtk::Label.new
|
51
52
|
infolabel.markup = title
|
53
|
+
infolabel.wrap = true
|
54
|
+
infolabel.max_width_chars = 80
|
55
|
+
|
52
56
|
|
53
57
|
vbox = Gtk::Box.new(:vertical, 8)
|
54
58
|
vbox.margin = 10
|
55
59
|
frame.set_child(vbox)
|
56
60
|
|
57
61
|
hbox = Gtk::Box.new(:horizontal, 8)
|
58
|
-
|
59
|
-
vbox.
|
60
|
-
vbox.pack_end(hbox, :expand => false, :fill => false, :padding => 0)
|
62
|
+
vbox.append(infolabel)
|
63
|
+
vbox.append(hbox)
|
61
64
|
|
62
65
|
button = Gtk::Button.new(:label => button_title)
|
63
66
|
cancel_button = Gtk::Button.new(:label => "Cancel")
|
@@ -95,10 +98,10 @@ class OneInputAction
|
|
95
98
|
end
|
96
99
|
end
|
97
100
|
|
98
|
-
hbox.
|
99
|
-
hbox.
|
100
|
-
hbox.
|
101
|
-
hbox.
|
101
|
+
hbox.append(label)
|
102
|
+
hbox.append(@entry1)
|
103
|
+
hbox.append(button)
|
104
|
+
hbox.append(cancel_button)
|
102
105
|
return
|
103
106
|
end
|
104
107
|
|
@@ -49,9 +49,7 @@ class PopupFormGenerator
|
|
49
49
|
if params.has_key?("title")
|
50
50
|
infolabel = Gtk::Label.new
|
51
51
|
infolabel.markup = params["title"]
|
52
|
-
|
53
|
-
# vbox.pack_start(infolabel, :expand => false, :fill => false, :padding => 0)
|
54
|
-
vbox.pack_end(infolabel, :expand => false, :fill => false, :padding => 0)
|
52
|
+
vbox.append(infolabel)
|
55
53
|
end
|
56
54
|
|
57
55
|
hbox = Gtk::Box.new(:horizontal, 8)
|
@@ -61,7 +59,7 @@ class PopupFormGenerator
|
|
61
59
|
for id, elem in params["inputs"]
|
62
60
|
if elem[:type] == :button
|
63
61
|
button = Gtk::Button.new(:label => elem[:label])
|
64
|
-
hbox.
|
62
|
+
hbox.append(button)
|
65
63
|
if elem[:default_focus] == true
|
66
64
|
@default_button = button
|
67
65
|
end
|
@@ -75,8 +73,8 @@ class PopupFormGenerator
|
|
75
73
|
if elem.has_key?(:initial_text)
|
76
74
|
entry.text = elem[:initial_text]
|
77
75
|
end
|
78
|
-
hbox.
|
79
|
-
hbox.
|
76
|
+
hbox.append(label)
|
77
|
+
hbox.append(entry)
|
80
78
|
@vals[id] = entry
|
81
79
|
|
82
80
|
press = Gtk::EventControllerKey.new
|
@@ -96,13 +94,13 @@ class PopupFormGenerator
|
|
96
94
|
end
|
97
95
|
end
|
98
96
|
|
99
|
-
vbox.
|
97
|
+
vbox.append(hbox)
|
100
98
|
|
101
99
|
cancel_button = Gtk::Button.new(:label => "Cancel")
|
102
100
|
cancel_button.signal_connect "clicked" do
|
103
101
|
@window.destroy
|
104
102
|
end
|
105
|
-
hbox.
|
103
|
+
hbox.append(cancel_button)
|
106
104
|
@cancel_button = cancel_button
|
107
105
|
return
|
108
106
|
end
|
data/lib/vimamsa/gui_menu.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Vimamsa
|
2
2
|
class Menu
|
3
3
|
def add_to_menu(_mpath, x)
|
4
|
+
# If no menu label provided, take from the action definition
|
5
|
+
if !x[:action].nil? and x[:label].nil?
|
6
|
+
x[:label] = vma.actions[x[:action]].method_name
|
7
|
+
end
|
8
|
+
|
4
9
|
mpath = _mpath.split(".")
|
5
10
|
curnfo = @nfo
|
6
11
|
for y in mpath
|
@@ -31,9 +36,10 @@ module Vimamsa
|
|
31
36
|
add_to_menu "Edit.Redo", { :label => "Redo edit", :action => :edit_redo }
|
32
37
|
add_to_menu "Edit.SearchReplace", { :label => "Search and replace", :action => :gui_search_replace }
|
33
38
|
add_to_menu "Edit.Find", { :label => "Find", :action => :find_in_buffer }
|
34
|
-
|
35
|
-
add_to_menu "Edit.StartCompletion", { :label => "StartCompletion", :action => :start_autocomplete }
|
36
|
-
add_to_menu "Edit.ShowCompletion", { :label => "ShowCompletion", :action => :show_autocomplete }
|
39
|
+
|
40
|
+
# add_to_menu "Edit.StartCompletion", { :label => "StartCompletion", :action => :start_autocomplete }
|
41
|
+
# add_to_menu "Edit.ShowCompletion", { :label => "ShowCompletion", :action => :show_autocomplete }
|
42
|
+
add_to_menu "Edit.CustomRb", { :action => :edit_customrb }
|
37
43
|
|
38
44
|
add_to_menu "Actions.SearchForActions", { :label => "Search for Actions", :action => :search_actions }
|
39
45
|
|
@@ -46,13 +52,11 @@ module Vimamsa
|
|
46
52
|
add_to_menu "Actions.experimental.EnableDebug", { :label => "Enable debug", :action => :enable_debug }
|
47
53
|
add_to_menu "Actions.experimental.DisableDebug", { :label => "Disable debug", :action => :disable_debug }
|
48
54
|
add_to_menu "Actions.experimental.ShowImages", { :label => "Show images ⟦img:path⟧", :action => :show_images }
|
49
|
-
|
55
|
+
|
50
56
|
add_to_menu "Actions.debug.dumpkbd", { :label => "Dump kbd state", :action => :kbd_dump_state }
|
51
|
-
|
52
|
-
|
57
|
+
|
53
58
|
add_to_menu "View.BufferManager", { :label => "Show open files", :action => :start_buf_manager }
|
54
59
|
add_to_menu "View.TwoColumn", { :label => "Toggle two column mode", :action => :toggle_two_column }
|
55
|
-
|
56
60
|
|
57
61
|
add_to_menu "Actions.EncryptFile", { :label => "Encrypt file", :action => :encrypt_file }
|
58
62
|
add_to_menu "Help.KeyBindings", { :label => "Show key bindings", :action => :show_key_bindings }
|
@@ -89,7 +93,7 @@ module Vimamsa
|
|
89
93
|
label_str = nfo[:label] + kbd_str
|
90
94
|
actkey = nfo[:action].to_s
|
91
95
|
menuitem = Gio::MenuItem.new(label_str, "app.#{actkey}")
|
92
|
-
|
96
|
+
|
93
97
|
# This worked in GTK3:
|
94
98
|
# But seems there is no way to access the Label object in GTK4
|
95
99
|
# menuitem.children[0].set_markup(label_str)
|
@@ -110,7 +114,6 @@ module Vimamsa
|
|
110
114
|
# menuitem.set_attribute_value("use-markup", true)
|
111
115
|
# This might change in the future(?), but the string version still works in gtk-4.13.0 (gtk/gtkmenutrackeritem.c)
|
112
116
|
|
113
|
-
|
114
117
|
if !nfo[:items].nil? and !nfo[:items].empty?
|
115
118
|
for k2, item in nfo[:items]
|
116
119
|
build_menu(item, menu)
|
@@ -118,7 +121,6 @@ module Vimamsa
|
|
118
121
|
menuitem.submenu = menu
|
119
122
|
end
|
120
123
|
o = parent.append_item(menuitem)
|
121
|
-
|
122
124
|
end
|
123
125
|
end #end class
|
124
126
|
end
|
@@ -154,7 +154,9 @@ class SelectUpdateWindow
|
|
154
154
|
sw = Gtk::ScrolledWindow.new(nil, nil)
|
155
155
|
# sw.shadow_type = :etched_in #TODO:gtk4
|
156
156
|
sw.set_policy(:never, :automatic)
|
157
|
-
vbox.
|
157
|
+
vbox.append(sw)
|
158
|
+
sw.vexpand = true
|
159
|
+
sw.hexpand = true
|
158
160
|
|
159
161
|
# sw.add(treeview) #TODO:gtk4
|
160
162
|
sw.set_child(treeview)
|