vimamsa 0.1.12 → 0.1.14
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 +5 -0
- data/lib/vimamsa/ack.rb +5 -5
- data/lib/vimamsa/actions.rb +13 -6
- data/lib/vimamsa/audio.rb +82 -0
- data/lib/vimamsa/buffer.rb +73 -566
- data/lib/vimamsa/buffer_changetext.rb +255 -0
- data/lib/vimamsa/buffer_cursor.rb +303 -0
- data/lib/vimamsa/buffer_list.rb +26 -9
- data/lib/vimamsa/buffer_manager.rb +4 -2
- data/lib/vimamsa/clipboard.rb +35 -0
- data/lib/vimamsa/conf.rb +130 -5
- data/lib/vimamsa/debug.rb +4 -8
- data/lib/vimamsa/editor.rb +61 -125
- data/lib/vimamsa/encrypt.rb +6 -11
- data/lib/vimamsa/file_manager.rb +138 -9
- data/lib/vimamsa/gui.rb +11 -59
- data/lib/vimamsa/gui_dialog.rb +113 -0
- data/lib/vimamsa/gui_select_window.rb +9 -8
- data/lib/vimamsa/gui_sourceview.rb +110 -48
- data/lib/vimamsa/gui_text.rb +19 -0
- data/lib/vimamsa/hyper_plain_text.rb +15 -5
- data/lib/vimamsa/key_actions.rb +19 -195
- data/lib/vimamsa/key_binding_tree.rb +57 -33
- data/lib/vimamsa/key_bindings_vimlike.rb +39 -26
- data/lib/vimamsa/macro.rb +35 -25
- data/lib/vimamsa/main.rb +3 -17
- data/lib/vimamsa/rbvma.rb +11 -17
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +93 -131
- data/lib/vimamsa/terminal.rb +22 -0
- data/lib/vimamsa/tests.rb +122 -0
- data/lib/vimamsa/util.rb +87 -2
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +3 -1
- metadata +57 -7
- /data/lib/vimamsa/{form_generator.rb → gui_form_generator.rb} +0 -0
@@ -62,46 +62,104 @@ class FileSelector
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
#
|
68
|
-
gui_one_input_action("Grep", "Search:", "grep", callback)
|
69
|
-
end
|
65
|
+
class Grep
|
66
|
+
attr_reader :buf
|
67
|
+
@@cur = nil # Current object of class
|
70
68
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
r = Regexp.new(Regexp.escape(search_str), Regexp::IGNORECASE)
|
75
|
-
fpath = ""
|
76
|
-
fpath = vma.buf.pathname.expand_path.to_s + ":" if vma.buf.pathname
|
77
|
-
res_str = ""
|
69
|
+
def self.cur()
|
70
|
+
return @@cur
|
71
|
+
end
|
78
72
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
73
|
+
def self.init()
|
74
|
+
vma.kbd.add_minor_mode("grep", :grep, :command)
|
75
|
+
|
76
|
+
if cnf.experimental?
|
77
|
+
bindkey "grep shift!", [:grep_apply_changes, proc {
|
78
|
+
if vma.buf.module.class == Grep
|
79
|
+
vma.buf.module.apply_changes
|
80
|
+
else
|
81
|
+
debug vma.buf.module, 2
|
82
|
+
message("ERROR")
|
83
|
+
end
|
84
|
+
}, "Write changes edited in grep buffer to the underlying file"]
|
85
85
|
end
|
86
|
-
|
87
|
-
|
88
|
-
b = create_new_file(nil, res_str)
|
89
|
-
# set_current_buffer(buffer_i, update_history = true)
|
90
|
-
# @current_buf = buffer_i
|
86
|
+
vma.kbd.add_minor_mode("bmgr", :buf_mgr, :command)
|
87
|
+
reg_act(:grep_buffer, proc { Grep.new.run }, "Grep current buffer")
|
91
88
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
if jumpto.class == Integer
|
96
|
-
vma.buffers.set_current_buffer($grep_bufid, update_history = true)
|
97
|
-
buf.jump_to_line(jumpto)
|
98
|
-
end
|
99
|
-
}
|
100
|
-
end
|
89
|
+
bindkey "C , g", :grep_buffer
|
90
|
+
|
91
|
+
end
|
101
92
|
|
102
|
-
|
103
|
-
|
104
|
-
|
93
|
+
def apply_changes()
|
94
|
+
b = @orig_buf
|
95
|
+
gb = vma.buf
|
96
|
+
changed = 0
|
97
|
+
gb.lines.each { |x|
|
98
|
+
if m = x.match(/(\d+):(.*)/m)
|
99
|
+
lineno = m[1].to_i
|
100
|
+
newl = m[2]
|
101
|
+
r = @orig_buf.line_range(lineno - 1, 1)
|
102
|
+
old = @orig_buf[r.first..r.last]
|
103
|
+
if old != newl
|
104
|
+
@orig_buf.replace_range(r, newl)
|
105
|
+
changed += 1
|
106
|
+
end
|
107
|
+
end
|
108
|
+
}
|
109
|
+
message("GREP: apply changes, #{changed} changed lines")
|
110
|
+
end
|
111
|
+
|
112
|
+
def initialize()
|
113
|
+
@buf = nil
|
114
|
+
@line_to_id = {}
|
115
|
+
end
|
116
|
+
|
117
|
+
def callback(search_str, b = nil)
|
118
|
+
debug "grep_cur_buffer(search_str)"
|
119
|
+
lines = vma.buf.split("\n")
|
120
|
+
r = Regexp.new(Regexp.escape(search_str), Regexp::IGNORECASE)
|
121
|
+
fpath = ""
|
122
|
+
fpath = vma.buf.pathname.expand_path.to_s + ":" if vma.buf.pathname
|
123
|
+
res_str = ""
|
124
|
+
|
125
|
+
hlparts = []
|
126
|
+
@grep_matches = []
|
127
|
+
lines.each_with_index { |l, i|
|
128
|
+
if r.match(l)
|
129
|
+
res_str << "#{i + 1}:"
|
130
|
+
# ind = scan_indexes(l, r)
|
131
|
+
res_str << "#{l}\n"
|
132
|
+
@grep_matches << i + 1 # Lines start from index 1
|
133
|
+
end
|
134
|
+
}
|
135
|
+
$grep_bufid = vma.buffers.current_buf
|
136
|
+
@orig_buf = vma.buf
|
137
|
+
b = create_new_buffer(res_str, "grep")
|
138
|
+
vbuf = vma.gui.view.buffer
|
139
|
+
|
140
|
+
Gui.highlight_match(b, search_str, color: cnf.match.highlight.color!)
|
141
|
+
b.default_mode = :grep
|
142
|
+
b.module = self
|
143
|
+
|
144
|
+
vma.kbd.set_mode(:grep) #TODO: allow to work with other keybindings also
|
145
|
+
vma.kbd.set_default_mode(:grep)
|
146
|
+
b.line_action_handler = proc { |lineno|
|
147
|
+
debug "GREP HANDLER:#{lineno}"
|
148
|
+
jumpto = @grep_matches[lineno]
|
149
|
+
if jumpto.class == Integer
|
150
|
+
# vma.buffers.set_current_buffer($grep_bufid, update_history = true)
|
151
|
+
# buf.jump_to_line(jumpto)
|
152
|
+
vma.buffers.set_current_buffer_by_id(@orig_buf.id)
|
153
|
+
@orig_buf.jump_to_line(jumpto)
|
154
|
+
end
|
155
|
+
}
|
156
|
+
end
|
157
|
+
|
158
|
+
def run()
|
159
|
+
callb = self.method("callback")
|
160
|
+
gui_one_input_action("Grep", "Search:", "grep", callb)
|
161
|
+
end
|
162
|
+
end
|
105
163
|
|
106
164
|
def gui_one_input_action(title, field_label, button_title, callback, opt = {})
|
107
165
|
a = OneInputAction.new(nil, title, field_label, button_title, callback, opt)
|
@@ -167,99 +225,3 @@ def buf_replace_string(instr)
|
|
167
225
|
end
|
168
226
|
buf_replace(a[0], a[1])
|
169
227
|
end
|
170
|
-
|
171
|
-
module Gtk
|
172
|
-
class Frame
|
173
|
-
def margin=(a)
|
174
|
-
self.margin_bottom = a
|
175
|
-
self.margin_top = a
|
176
|
-
self.margin_end = a
|
177
|
-
self.margin_start = a
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
class Box
|
182
|
-
def margin=(a)
|
183
|
-
self.margin_bottom = a
|
184
|
-
self.margin_top = a
|
185
|
-
self.margin_end = a
|
186
|
-
self.margin_start = a
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
class OneInputAction
|
192
|
-
def initialize(main_window, title, field_label, button_title, callback, opt = {})
|
193
|
-
@window = Gtk::Window.new()
|
194
|
-
# @window.screen = main_window.screen
|
195
|
-
# @window.title = title
|
196
|
-
@window.title = ""
|
197
|
-
|
198
|
-
frame = Gtk::Frame.new()
|
199
|
-
# frame.margin = 20
|
200
|
-
@window.set_child(frame)
|
201
|
-
|
202
|
-
infolabel = Gtk::Label.new
|
203
|
-
infolabel.markup = title
|
204
|
-
|
205
|
-
vbox = Gtk::Box.new(:vertical, 8)
|
206
|
-
vbox.margin = 10
|
207
|
-
frame.set_child(vbox)
|
208
|
-
|
209
|
-
hbox = Gtk::Box.new(:horizontal, 8)
|
210
|
-
# @window.add(hbox)
|
211
|
-
vbox.pack_end(infolabel, :expand => false, :fill => false, :padding => 0)
|
212
|
-
vbox.pack_end(hbox, :expand => false, :fill => false, :padding => 0)
|
213
|
-
|
214
|
-
button = Gtk::Button.new(:label => button_title)
|
215
|
-
cancel_button = Gtk::Button.new(:label => "Cancel")
|
216
|
-
|
217
|
-
label = Gtk::Label.new(field_label)
|
218
|
-
|
219
|
-
@entry1 = Gtk::Entry.new
|
220
|
-
|
221
|
-
if opt[:hide]
|
222
|
-
@entry1.visibility = false
|
223
|
-
end
|
224
|
-
|
225
|
-
button.signal_connect "clicked" do
|
226
|
-
callback.call(@entry1.text)
|
227
|
-
@window.destroy
|
228
|
-
end
|
229
|
-
|
230
|
-
cancel_button.signal_connect "clicked" do
|
231
|
-
@window.destroy
|
232
|
-
end
|
233
|
-
|
234
|
-
press = Gtk::EventControllerKey.new
|
235
|
-
press.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
|
236
|
-
@window.add_controller(press)
|
237
|
-
press.signal_connect "key-pressed" do |gesture, keyval, keycode, y|
|
238
|
-
if keyval == Gdk::Keyval::KEY_Return
|
239
|
-
callback.call(@entry1.text)
|
240
|
-
@window.destroy
|
241
|
-
true
|
242
|
-
elsif keyval == Gdk::Keyval::KEY_Escape
|
243
|
-
@window.destroy
|
244
|
-
true
|
245
|
-
else
|
246
|
-
false
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
hbox.pack_end(label, :expand => false, :fill => false, :padding => 0)
|
251
|
-
hbox.pack_end(@entry1, :expand => false, :fill => false, :padding => 0)
|
252
|
-
hbox.pack_end(button, :expand => false, :fill => false, :padding => 0)
|
253
|
-
hbox.pack_end(cancel_button, :expand => false, :fill => false, :padding => 0)
|
254
|
-
return
|
255
|
-
end
|
256
|
-
|
257
|
-
def run
|
258
|
-
if !@window.visible?
|
259
|
-
@window.show
|
260
|
-
else
|
261
|
-
@window.destroy
|
262
|
-
end
|
263
|
-
@window
|
264
|
-
end
|
265
|
-
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
def exec_in_terminal(cmd, autoclose = false)
|
2
|
+
# debug "CMD:#{cmd}"
|
3
|
+
|
4
|
+
# global to prevent garbage collect unlink
|
5
|
+
$initf = Tempfile.new("bashinit")
|
6
|
+
# debug $initf.path
|
7
|
+
$initf.write(cmd)
|
8
|
+
if autoclose
|
9
|
+
$initf.write("\nsleep 10; exit;\n")
|
10
|
+
$initf.write("rm #{$initf.path}\n")
|
11
|
+
else
|
12
|
+
$initf.write("rm #{$initf.path}\n")
|
13
|
+
$initf.write("\nexec bash\n")
|
14
|
+
end
|
15
|
+
$initf.close
|
16
|
+
# PTY.spawn("gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash")
|
17
|
+
# fork { exec "gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash" }
|
18
|
+
# Just another execution
|
19
|
+
fork { exec "gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash" }
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require "digest"
|
2
|
+
|
3
|
+
def run_tests()
|
4
|
+
tests = ["test_paste_0","test_delete_0"]
|
5
|
+
stats = []
|
6
|
+
for t in tests
|
7
|
+
r = eval(t)
|
8
|
+
if r == true
|
9
|
+
stats << "test #{t} OK"
|
10
|
+
else
|
11
|
+
stats << "test #{t} FAILED"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
debug "TEST RESULTS:",2
|
15
|
+
puts stats.join("\n")
|
16
|
+
puts "===================="
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
#
|
22
|
+
|
23
|
+
def test_paste_0(runmacro = true)
|
24
|
+
b = create_new_buffer(file_contents = "\n", prefix = "buf", setcurrent = true)
|
25
|
+
|
26
|
+
b.insert_txt(JABBERWOCKY)
|
27
|
+
b.insert_txt(LOREM_IPSUM)
|
28
|
+
b.insert_txt(LOREM_IPSUM)
|
29
|
+
|
30
|
+
macro = ["buf.jump(START_OF_BUFFER)", "buf.copy_line", :forward_line, :paste_after, :backward_line, :backward_line, "buf.paste(BEFORE)", :forward_line, :forward_line, :forward_line, :forward_line, "buf.jump_word(FORWARD,WORD_START)", "buf.start_visual_mode", "buf.jump_word(FORWARD,WORD_END)", "buf.copy_active_selection()", "buf.move(FORWARD_CHAR)", "buf.paste(BEFORE)", "buf.jump_word(FORWARD,WORD_END)", :paste_after, :forward_line, "buf.jump(BEGINNING_OF_LINE)", "buf.copy_line", :forward_line, :forward_line, :paste_after, :paste_after, :forward_line, "buf.jump_word(FORWARD,WORD_START)", "buf.start_visual_mode", "buf.jump_word(FORWARD,WORD_END)", "buf.jump_word(FORWARD,WORD_END)", "buf.jump_word(FORWARD,WORD_END)", "buf.jump_word(FORWARD,WORD_END)", "buf.jump(END_OF_LINE)", :e_move_backward_char, "buf.copy_active_selection()", :forward_line, "buf.paste(BEFORE)", "buf.paste(BEFORE)", "buf.paste(BEFORE)", "buf.paste(BEFORE)", "buf.jump(END_OF_BUFFER)", "buf.jump(BEGINNING_OF_LINE)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.start_visual_mode", "buf.jump_word(FORWARD,WORD_END)", "buf.jump_word(FORWARD,WORD_END)", "buf.jump_word(FORWARD,WORD_END)", "buf.jump_word(FORWARD,WORD_END)", "buf.copy_active_selection()", "buf.jump(BEGINNING_OF_LINE)", "buf.paste(BEFORE)", "buf.paste(BEFORE)"]
|
31
|
+
|
32
|
+
macro_r = true
|
33
|
+
if runmacro
|
34
|
+
macro_r = vma.macro.run_actions(macro)
|
35
|
+
end
|
36
|
+
|
37
|
+
hex = Digest::SHA2.hexdigest b.to_s
|
38
|
+
conds = [hex == "705061f7bc6370b501b6d09615547530a103e2a659e20fb6915d17ae65f564fa",
|
39
|
+
macro_r == true]
|
40
|
+
# debug conds
|
41
|
+
debug hex
|
42
|
+
|
43
|
+
if conds.include?(false)
|
44
|
+
return false
|
45
|
+
else
|
46
|
+
return true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def macro_test(macro, correct_hex, runmacro=true)
|
51
|
+
b = create_new_buffer(file_contents = "\n", prefix = "buf", setcurrent = true)
|
52
|
+
b.insert_txt(JABBERWOCKY)
|
53
|
+
b.insert_txt(LOREM_IPSUM)
|
54
|
+
b.insert_txt(LOREM_IPSUM)
|
55
|
+
|
56
|
+
macro_r = true
|
57
|
+
if runmacro
|
58
|
+
macro_r = vma.macro.run_actions(macro)
|
59
|
+
end
|
60
|
+
|
61
|
+
hex = Digest::SHA2.hexdigest b.to_s
|
62
|
+
conds = [hex == correct_hex,
|
63
|
+
macro_r == true]
|
64
|
+
# debug conds
|
65
|
+
debug hex
|
66
|
+
|
67
|
+
if conds.include?(false)
|
68
|
+
return false
|
69
|
+
else
|
70
|
+
return true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_delete_0
|
75
|
+
macro = ["buf.jump(START_OF_BUFFER)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", :e_move_backward_char, "buf.delete(BACKWARD_CHAR)", "buf.delete(BACKWARD_CHAR)", "buf.delete(BACKWARD_CHAR)", "buf.delete(BACKWARD_CHAR)", "buf.delete(BACKWARD_CHAR)", "buf.delete(BACKWARD_CHAR)", :forward_line, :e_move_backward_char, "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", "buf.delete(CURRENT_CHAR_FORWARD)", :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, :delete_line, :forward_line, :delete_line, :forward_line, :forward_line, :delete_line, :delete_line, :forward_line, :forward_line, "vma.kbd.set_mode(:audio)", :forward_line, :forward_line, :forward_line, :forward_line, "buf.delete2(:to_mark,'a')", :backward_line, :forward_line, :forward_line, "vma.kbd.set_mode(:audio)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.jump_word(FORWARD,WORD_START)", "buf.delete2(:to_mark,'a')", "buf.mark_current_position('b')", :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, :forward_line, "buf.delete2(:to_mark,'a')", "vma.kbd.set_mode(:audio)", :forward_line, :forward_line, :forward_line, "buf.jump_to_mark('a')", "buf.jump_to_mark('a')", :backward_line, :backward_line, :backward_line, :backward_line, "buf.jump_to_mark('a')", "buf.jump_to_mark('a')", "buf.jump_to_mark('a')", "buf.jump_to_mark('a')"]
|
76
|
+
return macro_test(macro, "71bc0421b47549267b327b69216ad8e042379625f99de1ba4faaa30d5042c22d")
|
77
|
+
end
|
78
|
+
|
79
|
+
LOREM_IPSUM = "
|
80
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
81
|
+
|
82
|
+
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst."
|
83
|
+
|
84
|
+
JABBERWOCKY = "
|
85
|
+
’Twas brillig, and the slithy toves
|
86
|
+
Did gyre and gimble in the wabe:
|
87
|
+
All mimsy were the borogoves,
|
88
|
+
And the mome raths outgrabe.
|
89
|
+
|
90
|
+
“Beware the Jabberwock, my son!
|
91
|
+
The jaws that bite, the claws that catch!
|
92
|
+
Beware the Jubjub bird, and shun
|
93
|
+
The frumious Bandersnatch!”
|
94
|
+
|
95
|
+
He took his vorpal sword in hand;
|
96
|
+
Long time the manxome foe he sought—
|
97
|
+
So rested he by the Tumtum tree
|
98
|
+
And stood awhile in thought.
|
99
|
+
|
100
|
+
And, as in uffish thought he stood,
|
101
|
+
The Jabberwock, with eyes of flame,
|
102
|
+
Came whiffling through the tulgey wood,
|
103
|
+
And burbled as it came!
|
104
|
+
|
105
|
+
One, two! One, two! And through and through
|
106
|
+
The vorpal blade went snicker-snack!
|
107
|
+
He left it dead, and with its head
|
108
|
+
He went galumphing back.
|
109
|
+
|
110
|
+
“And hast thou slain the Jabberwock?
|
111
|
+
Come to my arms, my beamish boy!
|
112
|
+
O frabjous day! Callooh! Callay!”
|
113
|
+
He chortled in his joy.
|
114
|
+
|
115
|
+
’Twas brillig, and the slithy toves
|
116
|
+
Did gyre and gimble in the wabe:
|
117
|
+
All mimsy were the borogoves,
|
118
|
+
And the mome raths outgrabe.
|
119
|
+
"
|
120
|
+
|
121
|
+
|
122
|
+
|
data/lib/vimamsa/util.rb
CHANGED
@@ -1,13 +1,90 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
# Get all indexes for start of matching regexp
|
4
|
+
def scan_indexes(txt, regex)
|
5
|
+
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
6
|
+
indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) }
|
7
|
+
return indexes
|
8
|
+
end
|
9
|
+
|
10
|
+
def file_mime_type(fpath)
|
11
|
+
fpath = File.expand_path(fpath)
|
12
|
+
return false if !File.readable?(fpath)
|
13
|
+
r = exec_cmd("file", "--mime-type", "--mime-encoding", fpath)
|
14
|
+
return false if r.class != String
|
15
|
+
return false if r.size < 2
|
16
|
+
m = r.match(".*:\s*(.*)")
|
17
|
+
mimetype = m[1].match(/(.*);/)
|
18
|
+
charset = m[1].match(/charset=(.*)/)
|
19
|
+
return [mimetype, charset]
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_is_text_file(fpath)
|
23
|
+
debug "file_is_text_file(#{fpath})"
|
24
|
+
fpath = File.expand_path(fpath)
|
25
|
+
return false if !File.exist?(fpath)
|
26
|
+
r = exec_cmd("file", fpath)
|
27
|
+
debug "DEBUG:#{r}"
|
28
|
+
return true if r.match(/UTF-8.*text/)
|
29
|
+
return true if r.match(/ASCII.*text/)
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
# file --mime-type --mime-encoding
|
34
|
+
|
1
35
|
# Run idle proc once
|
2
|
-
# Delay execution of proc until Gtk has fully processed the last calls.
|
3
|
-
def run_as_idle(p)
|
36
|
+
# Delay execution of proc until Gtk has fully processed the last calls.
|
37
|
+
def run_as_idle(p, delay: 0.0)
|
4
38
|
if p.class == Proc
|
5
39
|
Thread.new {
|
40
|
+
sleep delay
|
6
41
|
GLib::Idle.add(proc { p.call; false })
|
7
42
|
}
|
8
43
|
end
|
9
44
|
end
|
10
45
|
|
46
|
+
def open_url(url)
|
47
|
+
system("xdg-open", url)
|
48
|
+
end
|
49
|
+
|
50
|
+
def open_with_default_program(url)
|
51
|
+
system("xdg-open", url)
|
52
|
+
end
|
53
|
+
|
54
|
+
def run_cmd(cmd)
|
55
|
+
tmpf = Tempfile.new("vmarun", "/tmp").path
|
56
|
+
cmd = "#{cmd} > #{tmpf}"
|
57
|
+
debug "CMD:\n#{cmd}"
|
58
|
+
system("bash", "-c", cmd)
|
59
|
+
res_str = File.read(tmpf)
|
60
|
+
return res_str
|
61
|
+
end
|
62
|
+
|
63
|
+
def exec_cmd(bin_name, arg1 = nil, arg2 = nil, arg3 = nil, arg4 = nil, arg5 = nil)
|
64
|
+
assert_binary_exists(bin_name)
|
65
|
+
if !arg5.nil?
|
66
|
+
p = Open3.popen2(bin_name, arg1, arg2, arg3, arg4, arg5)
|
67
|
+
elsif !arg4.nil?
|
68
|
+
p = Open3.popen2(bin_name, arg1, arg2, arg3, arg4)
|
69
|
+
elsif !arg3.nil?
|
70
|
+
p = Open3.popen2(bin_name, arg1, arg2, arg3)
|
71
|
+
elsif !arg2.nil?
|
72
|
+
p = Open3.popen2(bin_name, arg1, arg2)
|
73
|
+
elsif !arg1.nil?
|
74
|
+
p = Open3.popen2(bin_name, arg1)
|
75
|
+
else
|
76
|
+
p = Open3.popen2(bin_name)
|
77
|
+
end
|
78
|
+
|
79
|
+
ret_str = p[1].read
|
80
|
+
return ret_str
|
81
|
+
end
|
82
|
+
|
83
|
+
def mkdir_if_not_exists(_dirpath)
|
84
|
+
dirpath = File.expand_path(_dirpath)
|
85
|
+
Dir.mkdir(dirpath) unless File.exist?(dirpath)
|
86
|
+
end
|
87
|
+
|
11
88
|
class HSafe
|
12
89
|
def initialize(hash)
|
13
90
|
@h = hash
|
@@ -139,6 +216,14 @@ def read_file(text, path)
|
|
139
216
|
return content
|
140
217
|
end
|
141
218
|
|
219
|
+
def sanitize_input(str)
|
220
|
+
if str.encoding != Encoding::UTF_8
|
221
|
+
str = text.encode(Encoding::UTF_8)
|
222
|
+
end
|
223
|
+
str.gsub!(/\r\n/, "\n")
|
224
|
+
return str
|
225
|
+
end
|
226
|
+
|
142
227
|
def is_url(s)
|
143
228
|
return s.match(/(https?|file):\/\/.*/) != nil
|
144
229
|
end
|
data/lib/vimamsa/version.rb
CHANGED
data/vimamsa.gemspec
CHANGED
@@ -29,11 +29,13 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'ripl-multi_line', '~> 0.3.1'
|
30
30
|
spec.add_runtime_dependency 'gdk4', '~> 4.2.0'
|
31
31
|
spec.add_runtime_dependency 'gtk4', '~> 4.2.0'
|
32
|
+
spec.add_runtime_dependency 'rake', '~> 13.1.0'
|
32
33
|
spec.add_runtime_dependency 'differ', '~> 0.1.2'
|
33
34
|
spec.add_runtime_dependency 'gtksourceview5', '~> 4.2.0'
|
34
35
|
spec.add_runtime_dependency 'parallel', '~> 1.14' #TODO: update?
|
35
36
|
spec.add_runtime_dependency 'listen', '~> 3.4' #TODO: update?
|
36
|
-
|
37
|
+
spec.add_runtime_dependency 'language_server-protocol', '~> 3.17.0.3'
|
38
|
+
spec.add_runtime_dependency 'gstreamer', '~> 4.2.0'
|
37
39
|
|
38
40
|
spec.extensions = ["ext/vmaext/extconf.rb"]
|
39
41
|
spec.licenses = ['GPL-3.0+']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimamsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sami Sieranoja
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 4.2.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 13.1.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 13.1.0
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: differ
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +178,34 @@ dependencies:
|
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: '3.4'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: language_server-protocol
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 3.17.0.3
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 3.17.0.3
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: gstreamer
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 4.2.0
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 4.2.0
|
167
209
|
description: Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby
|
168
210
|
and GTK.
|
169
211
|
email:
|
@@ -190,9 +232,13 @@ files:
|
|
190
232
|
- lib/vimamsa.rb
|
191
233
|
- lib/vimamsa/ack.rb
|
192
234
|
- lib/vimamsa/actions.rb
|
235
|
+
- lib/vimamsa/audio.rb
|
193
236
|
- lib/vimamsa/buffer.rb
|
237
|
+
- lib/vimamsa/buffer_changetext.rb
|
238
|
+
- lib/vimamsa/buffer_cursor.rb
|
194
239
|
- lib/vimamsa/buffer_list.rb
|
195
240
|
- lib/vimamsa/buffer_manager.rb
|
241
|
+
- lib/vimamsa/clipboard.rb
|
196
242
|
- lib/vimamsa/conf.rb
|
197
243
|
- lib/vimamsa/constants.rb
|
198
244
|
- lib/vimamsa/debug.rb
|
@@ -202,12 +248,14 @@ files:
|
|
202
248
|
- lib/vimamsa/file_finder.rb
|
203
249
|
- lib/vimamsa/file_history.rb
|
204
250
|
- lib/vimamsa/file_manager.rb
|
205
|
-
- lib/vimamsa/form_generator.rb
|
206
251
|
- lib/vimamsa/gui.rb
|
252
|
+
- lib/vimamsa/gui_dialog.rb
|
253
|
+
- lib/vimamsa/gui_form_generator.rb
|
207
254
|
- lib/vimamsa/gui_image.rb
|
208
255
|
- lib/vimamsa/gui_menu.rb
|
209
256
|
- lib/vimamsa/gui_select_window.rb
|
210
257
|
- lib/vimamsa/gui_sourceview.rb
|
258
|
+
- lib/vimamsa/gui_text.rb
|
211
259
|
- lib/vimamsa/hook.rb
|
212
260
|
- lib/vimamsa/hyper_plain_text.rb
|
213
261
|
- lib/vimamsa/key_actions.rb
|
@@ -219,6 +267,8 @@ files:
|
|
219
267
|
- lib/vimamsa/rbvma.rb
|
220
268
|
- lib/vimamsa/search.rb
|
221
269
|
- lib/vimamsa/search_replace.rb
|
270
|
+
- lib/vimamsa/terminal.rb
|
271
|
+
- lib/vimamsa/tests.rb
|
222
272
|
- lib/vimamsa/text_transforms.rb
|
223
273
|
- lib/vimamsa/util.rb
|
224
274
|
- lib/vimamsa/version.rb
|
@@ -231,7 +281,7 @@ homepage: https://github.com/SamiSieranoja/vimamsa
|
|
231
281
|
licenses:
|
232
282
|
- GPL-3.0+
|
233
283
|
metadata: {}
|
234
|
-
post_install_message:
|
284
|
+
post_install_message:
|
235
285
|
rdoc_options: []
|
236
286
|
require_paths:
|
237
287
|
- lib
|
@@ -247,8 +297,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
297
|
- !ruby/object:Gem::Version
|
248
298
|
version: '0'
|
249
299
|
requirements: []
|
250
|
-
rubygems_version: 3.
|
251
|
-
signing_key:
|
300
|
+
rubygems_version: 3.3.26
|
301
|
+
signing_key:
|
252
302
|
specification_version: 4
|
253
303
|
summary: Vimamsa
|
254
304
|
test_files: []
|
File without changes
|