vimamsa 0.1.9 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -7
- data/custom_example.rb +12 -2
- data/demo.txt +2 -2
- data/exe/vimamsa +1 -1
- data/lib/vimamsa/ack.rb +57 -46
- data/lib/vimamsa/actions.rb +1 -1
- data/lib/vimamsa/buffer.rb +287 -55
- data/lib/vimamsa/buffer_list.rb +83 -48
- data/lib/vimamsa/buffer_manager.rb +19 -3
- data/lib/vimamsa/conf.rb +10 -1
- data/lib/vimamsa/debug.rb +15 -11
- data/lib/vimamsa/easy_jump.rb +9 -5
- data/lib/vimamsa/editor.rb +73 -54
- data/lib/vimamsa/encrypt.rb +2 -2
- data/lib/vimamsa/file_finder.rb +70 -72
- data/lib/vimamsa/file_history.rb +2 -3
- data/lib/vimamsa/file_manager.rb +10 -8
- data/lib/vimamsa/form_generator.rb +122 -0
- data/lib/vimamsa/gui.rb +469 -118
- data/lib/vimamsa/gui_image.rb +12 -6
- data/lib/vimamsa/gui_menu.rb +26 -21
- data/lib/vimamsa/gui_select_window.rb +40 -21
- data/lib/vimamsa/gui_sourceview.rb +173 -79
- data/lib/vimamsa/hyper_plain_text.rb +36 -3
- data/lib/vimamsa/key_actions.rb +13 -1
- data/lib/vimamsa/key_binding_tree.rb +32 -20
- data/lib/vimamsa/key_bindings_vimlike.rb +54 -25
- data/lib/vimamsa/langservp.rb +172 -0
- data/lib/vimamsa/macro.rb +9 -8
- data/lib/vimamsa/main.rb +3 -4
- data/lib/vimamsa/rbvma.rb +7 -4
- data/lib/vimamsa/search.rb +3 -2
- data/lib/vimamsa/search_replace.rb +50 -120
- data/lib/vimamsa/text_transforms.rb +1 -1
- data/lib/vimamsa/util.rb +47 -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 +22 -20
@@ -0,0 +1,122 @@
|
|
1
|
+
# PopupFormGenerator.new().run
|
2
|
+
class PopupFormGenerator
|
3
|
+
def submit()
|
4
|
+
for id, entry in @vals
|
5
|
+
@ret[id] = entry.text
|
6
|
+
end
|
7
|
+
if !@callback.nil?
|
8
|
+
@callback.call(@ret)
|
9
|
+
end
|
10
|
+
@window.destroy
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(params = nil)
|
14
|
+
@ret = {}
|
15
|
+
@window = Gtk::Window.new()
|
16
|
+
# @window.screen = main_window.screen
|
17
|
+
# @window.title = title
|
18
|
+
# params = {}
|
19
|
+
# params["inputs"] = {}
|
20
|
+
# params["inputs"]["search"] = { :label => "Search", :type => :entry }
|
21
|
+
# params["inputs"]["replace"] = { :label => "Replace", :type => :entry }
|
22
|
+
# params["inputs"]["btn1"] = { :label => "Replace all", :type => :button }
|
23
|
+
# params[:callback] = proc { |x| puts "====="; puts x.inspect; puts "=====" }
|
24
|
+
|
25
|
+
|
26
|
+
@callback = params[:callback]
|
27
|
+
@window.title = ""
|
28
|
+
|
29
|
+
frame = Gtk::Frame.new()
|
30
|
+
frame.margin_bottom = 8
|
31
|
+
frame.margin_top = 8
|
32
|
+
frame.margin_end = 8
|
33
|
+
frame.margin_start = 8
|
34
|
+
|
35
|
+
@window.set_child(frame)
|
36
|
+
|
37
|
+
# @window.title = params["title"]
|
38
|
+
|
39
|
+
# @callback = params["callback"]
|
40
|
+
|
41
|
+
vbox = Gtk::Box.new(:vertical, 8)
|
42
|
+
vbox.margin_bottom = 8
|
43
|
+
vbox.margin_top = 8
|
44
|
+
vbox.margin_end = 8
|
45
|
+
vbox.margin_start = 8
|
46
|
+
|
47
|
+
frame.set_child(vbox)
|
48
|
+
|
49
|
+
if params.has_key?("title")
|
50
|
+
infolabel = Gtk::Label.new
|
51
|
+
infolabel.markup = params["title"]
|
52
|
+
#TODO:gtk4
|
53
|
+
# vbox.pack_start(infolabel, :expand => false, :fill => false, :padding => 0)
|
54
|
+
vbox.pack_end(infolabel, :expand => false, :fill => false, :padding => 0)
|
55
|
+
end
|
56
|
+
|
57
|
+
hbox = Gtk::Box.new(:horizontal, 8)
|
58
|
+
@vals = {}
|
59
|
+
@default_button = nil
|
60
|
+
|
61
|
+
for id, elem in params["inputs"]
|
62
|
+
if elem[:type] == :button
|
63
|
+
button = Gtk::Button.new(:label => elem[:label])
|
64
|
+
hbox.pack_end(button, :expand => false, :fill => false, :padding => 0)
|
65
|
+
if elem[:default_focus] == true
|
66
|
+
@default_button = button
|
67
|
+
end
|
68
|
+
button.signal_connect "clicked" do
|
69
|
+
@ret[id] = "submit"
|
70
|
+
submit
|
71
|
+
end
|
72
|
+
elsif elem[:type] == :entry
|
73
|
+
label = Gtk::Label.new(elem[:label])
|
74
|
+
entry = Gtk::Entry.new
|
75
|
+
if elem.has_key?(:initial_text)
|
76
|
+
entry.text = elem[:initial_text]
|
77
|
+
end
|
78
|
+
hbox.pack_end(label, :expand => false, :fill => false, :padding => 0)
|
79
|
+
hbox.pack_end(entry, :expand => false, :fill => false, :padding => 0)
|
80
|
+
@vals[id] = entry
|
81
|
+
|
82
|
+
press = Gtk::EventControllerKey.new
|
83
|
+
press.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
|
84
|
+
entry.add_controller(press)
|
85
|
+
press.signal_connect "key-pressed" do |gesture, keyval, keycode, y|
|
86
|
+
if keyval == Gdk::Keyval::KEY_Return
|
87
|
+
submit
|
88
|
+
true
|
89
|
+
elsif keyval == Gdk::Keyval::KEY_Escape
|
90
|
+
@window.destroy
|
91
|
+
true
|
92
|
+
else
|
93
|
+
false
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
vbox.pack_end(hbox, :expand => false, :fill => false, :padding => 0)
|
100
|
+
|
101
|
+
cancel_button = Gtk::Button.new(:label => "Cancel")
|
102
|
+
cancel_button.signal_connect "clicked" do
|
103
|
+
@window.destroy
|
104
|
+
end
|
105
|
+
hbox.pack_end(cancel_button, :expand => false, :fill => false, :padding => 0)
|
106
|
+
@cancel_button = cancel_button
|
107
|
+
return
|
108
|
+
end
|
109
|
+
|
110
|
+
def run
|
111
|
+
if !@window.visible?
|
112
|
+
@window.show
|
113
|
+
else
|
114
|
+
@window.destroy
|
115
|
+
end
|
116
|
+
if !@default_button.nil?
|
117
|
+
@default_button.grab_focus
|
118
|
+
end
|
119
|
+
@window.set_focus_visible(true)
|
120
|
+
@window
|
121
|
+
end
|
122
|
+
end
|