vimamsa 0.1.16 → 0.1.18
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 +1 -1
- data/lib/vimamsa/ack.rb +91 -13
- data/lib/vimamsa/actions.rb +99 -84
- data/lib/vimamsa/buffer.rb +34 -44
- data/lib/vimamsa/buffer_changetext.rb +20 -5
- data/lib/vimamsa/buffer_list.rb +7 -0
- data/lib/vimamsa/buffer_manager.rb +1 -1
- data/lib/vimamsa/conf.rb +3 -0
- data/lib/vimamsa/editor.rb +26 -13
- data/lib/vimamsa/encrypt.rb +38 -1
- data/lib/vimamsa/file_history.rb +3 -3
- data/lib/vimamsa/file_manager.rb +1 -1
- data/lib/vimamsa/gui.rb +75 -30
- data/lib/vimamsa/gui_select_window.rb +2 -0
- data/lib/vimamsa/gui_sourceview.rb +91 -57
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +3 -1
- data/lib/vimamsa/hyper_plain_text.rb +4 -3
- data/lib/vimamsa/key_actions.rb +1 -1
- data/lib/vimamsa/key_binding_tree.rb +5 -6
- data/lib/vimamsa/key_bindings_vimlike.rb +55 -18
- data/lib/vimamsa/langservp.rb +3 -1
- data/lib/vimamsa/macro.rb +4 -1
- data/lib/vimamsa/rbvma.rb +2 -2
- data/lib/vimamsa/tests.rb +6 -9
- data/lib/vimamsa/util.rb +56 -14
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +4 -4
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d45a54c1e25d490c27465b9649d09fa3b0e5db85e91324fb8c70201de9ff5a1
|
4
|
+
data.tar.gz: f7393daa458da9e7c3b1e769049f7205e96e4ba157c162f9dacbdae700b6731d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d8be7daf217add0cef74e246bebf114d886f60739bc700d532035067f9a3c26dabde5ffbec7ef662278a6f7829f0513210a961e4b9c661b0f9c52ea839971a
|
7
|
+
data.tar.gz: 33315be557aaf4f294005e80a1c8b9be61da65b9d0d21cc90b8e03bddb0c4cf34df332217e11787d5e2dd3da1a0de459065c342b44f8a37f1aec5cd34f7ed4c1
|
data/README.md
CHANGED
data/lib/vimamsa/ack.rb
CHANGED
@@ -13,7 +13,6 @@ Will search all .txt files in the following directories:
|
|
13
13
|
</span>"
|
14
14
|
|
15
15
|
callback = proc { |x| FileContentSearch.search_buffer(x) }
|
16
|
-
# gui_one_input_action(nfo, "Search:", "search", callback)
|
17
16
|
|
18
17
|
params = {}
|
19
18
|
params["inputs"] = {}
|
@@ -21,7 +20,6 @@ Will search all .txt files in the following directories:
|
|
21
20
|
params["inputs"]["extensions"] = { :label => "Limit to file extensions:", :type => :entry }
|
22
21
|
params["inputs"]["extensions"][:initial_text] = conf(:default_search_extensions).join(",")
|
23
22
|
params["inputs"]["btn1"] = { :label => "Search", :type => :button }
|
24
|
-
# callback = proc { |x| gui_replace_callback(x) }
|
25
23
|
|
26
24
|
params[:callback] = callback
|
27
25
|
PopupFormGenerator.new(params).run
|
@@ -106,20 +104,100 @@ Will search the following directories:
|
|
106
104
|
If .vma_project exists in parent directory of current file, searches within that directory.
|
107
105
|
</span>"
|
108
106
|
|
109
|
-
callback = proc { |x| ack_buffer(x) }
|
107
|
+
callback = proc { |x| Ack.new.ack_buffer(x) }
|
110
108
|
gui_one_input_action(nfo, "Search:", "search", callback)
|
111
109
|
end
|
112
110
|
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
def group_by_folder(list)
|
112
|
+
bh = {}
|
113
|
+
for b in list
|
114
|
+
fpath = b[:fpath]
|
115
|
+
if !fpath.nil?
|
116
|
+
bname = File.basename(b[:fpath])
|
117
|
+
dname = File.dirname(b[:fpath])
|
118
|
+
else
|
119
|
+
#TODO
|
120
|
+
end
|
121
|
+
bh[dname] ||= {}
|
122
|
+
bh[dname][:files] ||= []
|
123
|
+
bh[dname][:files] << { bname: bname, nfo: b }
|
124
|
+
end
|
125
|
+
arr = []
|
126
|
+
|
127
|
+
for k in bh.keys.sort
|
128
|
+
tp = tilde_path(k)
|
129
|
+
arr << { type: :dir, path: tp }
|
130
|
+
for f in bh[k][:files].sort_by { |x| x[:bname] }
|
131
|
+
arr << { type: :file, bname: f[:bname], nfo: f[:nfo] }
|
132
|
+
end
|
118
133
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
134
|
+
return arr
|
135
|
+
end
|
136
|
+
|
137
|
+
class Ack
|
138
|
+
attr_reader :buf
|
139
|
+
@@cur = nil # Current object of class
|
140
|
+
|
141
|
+
def self.cur()
|
142
|
+
return @@cur
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.init()
|
146
|
+
end
|
147
|
+
|
148
|
+
def initialize()
|
149
|
+
@buf = nil
|
150
|
+
@line_to_id = {}
|
151
|
+
end
|
152
|
+
|
153
|
+
def ack_buffer(_instr, b = nil)
|
154
|
+
instr = Shellwords.escape(_instr)
|
155
|
+
bufstr = ""
|
156
|
+
for path in vma.get_content_search_paths
|
157
|
+
bufstr += run_cmd("ack -Q --type-add=gd=.gd -ki --nohtml --nojs --nojson #{instr} #{path}")
|
158
|
+
end
|
159
|
+
|
160
|
+
b = ""
|
161
|
+
list = []
|
162
|
+
for x in bufstr.lines
|
163
|
+
if x.match(/(.*?):(\d+):(.+)/) # non greedy: *?
|
164
|
+
fn = $1
|
165
|
+
lineno = $2
|
166
|
+
matchpart = $3
|
167
|
+
pp [fn, lineno, matchpart]
|
168
|
+
b << "[#{fn},#{lineno},#{matchpart}]\n"
|
169
|
+
list << { fpath: fn, lineno: lineno, matchpart: matchpart }
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
gb = group_by_folder(list)
|
174
|
+
s = ""
|
175
|
+
@line_to_nfo = {}
|
176
|
+
i = 0
|
177
|
+
for x in gb
|
178
|
+
if x[:type] == :file
|
179
|
+
s << "╰─#{x[:bname]}:#{x[:nfo][:lineno]}:#{x[:nfo][:matchpart]}\n"
|
180
|
+
@line_to_nfo[i] = x
|
181
|
+
end
|
182
|
+
if x[:type] == :dir
|
183
|
+
s << "📂#{x[:path]}:\n"
|
184
|
+
end
|
185
|
+
i += 1
|
186
|
+
end
|
187
|
+
|
188
|
+
if s.size > 5
|
189
|
+
@buf = create_new_buffer(s, "ack")
|
190
|
+
@buf.module = self
|
191
|
+
@buf.line_action_handler = self.method("select_line")
|
192
|
+
Gui.highlight_match(@buf, _instr, color: cnf.match.highlight.color!)
|
193
|
+
else
|
194
|
+
message("No results for input:#{instr}")
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def select_line(lineno)
|
199
|
+
debug "def select_line #{lineno}", 2
|
200
|
+
nfo = @line_to_nfo[lineno][:nfo]
|
201
|
+
jump_to_file(nfo[:fpath], nfo[:lineno].to_i)
|
124
202
|
end
|
125
203
|
end
|
data/lib/vimamsa/actions.rb
CHANGED
@@ -6,13 +6,10 @@ class Action
|
|
6
6
|
@id = id
|
7
7
|
@method = method
|
8
8
|
@opt = opt
|
9
|
-
|
10
|
-
$actions[id] = self
|
9
|
+
vma.actions.register(id, self) # TODO: handle this in Editor class
|
11
10
|
end
|
12
11
|
end
|
13
12
|
|
14
|
-
$actions = {}
|
15
|
-
|
16
13
|
def reg_act(id, callfunc, name = "", opt = {})
|
17
14
|
if callfunc.class == Proc
|
18
15
|
a = Action.new(id, name, callfunc, opt)
|
@@ -31,108 +28,126 @@ def missing_callfunc
|
|
31
28
|
debug "missing_callfunc"
|
32
29
|
end
|
33
30
|
|
34
|
-
#TODO: remove
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
#TODO: remove?
|
32
|
+
def call_action(id)
|
33
|
+
vma.actions.call(id)
|
34
|
+
end
|
38
35
|
|
39
|
-
|
36
|
+
class ActionList
|
37
|
+
def initialize
|
38
|
+
@acth = []
|
39
|
+
@actions = {}
|
40
|
+
end
|
40
41
|
|
41
|
-
def
|
42
|
-
|
43
|
-
a = $actions[id]
|
44
|
-
if a
|
45
|
-
a.method.call()
|
46
|
-
else
|
47
|
-
message("Unknown action: " + id.inspect)
|
42
|
+
def register(id, obj)
|
43
|
+
@actions[id] = obj
|
48
44
|
end
|
49
|
-
end
|
50
45
|
|
51
|
-
def
|
52
|
-
|
53
|
-
end
|
46
|
+
def include?(act)
|
47
|
+
return @actions.has_key?(act)
|
48
|
+
end
|
54
49
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
$select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
50
|
+
def [](id)
|
51
|
+
@actions[id]
|
52
|
+
end
|
59
53
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
54
|
+
def call(id)
|
55
|
+
@acth << id
|
56
|
+
a = @actions[id]
|
57
|
+
if a
|
58
|
+
a.method.call()
|
59
|
+
else
|
60
|
+
message("Unknown action: " + id.inspect)
|
61
|
+
end
|
62
|
+
end
|
65
63
|
|
66
|
-
|
64
|
+
def last_action
|
65
|
+
return @acth[-1]
|
66
|
+
end
|
67
67
|
|
68
|
-
def
|
69
|
-
|
68
|
+
def gui_search()
|
69
|
+
l = []
|
70
|
+
opt = { :title => "Search for actions", :desc => "Fuzzy search for actions. <up> or <down> to change selcted. <enter> to select current.",
|
71
|
+
:columns => [{ :title => "Shortcut", :id => 0 }, { :title => "Action", :id => 1 }] }
|
70
72
|
|
71
|
-
|
72
|
-
for act_id in $actions.keys
|
73
|
-
act = $actions[act_id]
|
74
|
-
item = {}
|
75
|
-
item[:key] = ""
|
73
|
+
@select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
76
74
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
break
|
82
|
-
end
|
83
|
-
end
|
84
|
-
# c_kbd = vma.kbd.act_bindings[mode_str][nfo[:action]]
|
85
|
-
item[:action] = act_id
|
86
|
-
item[:str] = act_id.to_s
|
87
|
-
if $actions[act_id].method_name != ""
|
88
|
-
item[:str] = $actions[act_id].method_name
|
89
|
-
end
|
90
|
-
item_list2 << item
|
75
|
+
gui_select_update_window(l, @select_keys.collect { |x| x.upcase },
|
76
|
+
self.method("search_actions_select_callback"),
|
77
|
+
self.method("search_actions_update_callback"),
|
78
|
+
opt)
|
91
79
|
end
|
92
80
|
|
93
|
-
item_list =
|
81
|
+
@item_list = []
|
94
82
|
|
95
|
-
|
96
|
-
|
83
|
+
def search_actions_update_callback(search_str = "")
|
84
|
+
return [] if search_str == ""
|
97
85
|
|
98
|
-
|
99
|
-
|
100
|
-
|
86
|
+
item_list2 = []
|
87
|
+
for act_id in @actions.keys
|
88
|
+
act = @actions[act_id]
|
89
|
+
item = {}
|
90
|
+
item[:key] = ""
|
101
91
|
|
102
|
-
|
92
|
+
for mode_str in ["C", "V"]
|
93
|
+
c_kbd = vma.kbd.act_bindings[mode_str][act_id]
|
94
|
+
if c_kbd.class == String
|
95
|
+
item[:key] = "[#{mode_str}] #{c_kbd} "
|
96
|
+
item[:key] = "" if item[:key].size > 15
|
97
|
+
break
|
98
|
+
end
|
99
|
+
end
|
100
|
+
# c_kbd = vma.kbd.act_bindings[mode_str][nfo[:action]]
|
101
|
+
item[:action] = act_id
|
102
|
+
item[:str] = act_id.to_s
|
103
|
+
if @actions[act_id].method_name != ""
|
104
|
+
item[:str] = @actions[act_id].method_name
|
105
|
+
end
|
106
|
+
item_list2 << item
|
107
|
+
end
|
103
108
|
|
104
|
-
|
105
|
-
return r
|
106
|
-
end
|
109
|
+
item_list = item_list2
|
107
110
|
|
108
|
-
|
109
|
-
|
110
|
-
acc = item[0][:action]
|
111
|
+
a = filter_items(item_list, 0, search_str)
|
112
|
+
debug a.inspect
|
111
113
|
|
112
|
-
|
113
|
-
|
114
|
+
r = a.collect { |x| [x[0][0], 0, x] }
|
115
|
+
debug r.inspect
|
116
|
+
@item_list = r
|
114
117
|
|
115
|
-
|
116
|
-
|
117
|
-
elsif acc.class == Symbol
|
118
|
-
debug "Symbol"
|
119
|
-
call_action(acc)
|
118
|
+
r = a.collect { |x| [x[0][:key], x[0][:str]] }
|
119
|
+
return r
|
120
120
|
end
|
121
|
-
end
|
122
121
|
|
123
|
-
def
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
122
|
+
def search_actions_select_callback(search_str, idx)
|
123
|
+
item = @item_list[idx][2]
|
124
|
+
acc = item[0][:action]
|
125
|
+
|
126
|
+
debug "Selected:" + acc.to_s
|
127
|
+
gui_select_window_close(0)
|
128
|
+
|
129
|
+
if acc.class == String
|
130
|
+
eval(acc)
|
131
|
+
elsif acc.class == Symbol
|
132
|
+
debug "Symbol"
|
133
|
+
call(acc)
|
130
134
|
end
|
131
|
-
[item, srn_dst(search_str, item[:str])]
|
132
135
|
end
|
133
|
-
scores.sort_by! { |x| -x[1] }
|
134
|
-
debug scores.inspect
|
135
|
-
scores = scores[0..30]
|
136
136
|
|
137
|
-
|
137
|
+
def filter_items(item_list, item_key, search_str)
|
138
|
+
item_hash = {}
|
139
|
+
# debug item_list.inspect
|
140
|
+
scores = Parallel.map(item_list, in_threads: 8) do |item|
|
141
|
+
if item[:str].class != String
|
142
|
+
puts item.inspect
|
143
|
+
exit!
|
144
|
+
end
|
145
|
+
[item, srn_dst(search_str, item[:str])]
|
146
|
+
end
|
147
|
+
scores.sort_by! { |x| -x[1] }
|
148
|
+
debug scores.inspect
|
149
|
+
scores = scores[0..30]
|
150
|
+
|
151
|
+
return scores
|
152
|
+
end
|
138
153
|
end
|
data/lib/vimamsa/buffer.rb
CHANGED
@@ -12,7 +12,7 @@ $update_highlight = false
|
|
12
12
|
$ifuncon = false
|
13
13
|
|
14
14
|
class Buffer < String
|
15
|
-
attr_reader :pos, :lpos, :cpos, :deltas, :edit_history, :fname, :call_func, :pathname, :basename, :dirname, :update_highlight, :marks, :is_highlighted, :syntax_detect_failed, :id, :lang, :images, :last_save, :access_time
|
15
|
+
attr_reader :pos, :lpos, :cpos, :deltas, :edit_history, :fname, :call_func, :pathname, :basename, :dirname, :update_highlight, :marks, :is_highlighted, :syntax_detect_failed, :id, :lang, :images, :last_save, :access_time, :selection_active
|
16
16
|
attr_writer :call_func, :update_highlight
|
17
17
|
attr_accessor :gui_update_highlight, :update_hl_startpos, :update_hl_endpos, :hl_queue, :syntax_parser, :highlights, :gui_reset_highlight, :is_parsing_syntax, :line_ends, :bt, :line_action_handler, :module, :active_kbd_mode, :title, :subtitle, :paste_lines, :mode_stack, :default_mode
|
18
18
|
|
@@ -24,6 +24,7 @@ class Buffer < String
|
|
24
24
|
|
25
25
|
update_access_time
|
26
26
|
@images = []
|
27
|
+
@prefix = prefix
|
27
28
|
@audiofiles = []
|
28
29
|
@lang = nil
|
29
30
|
@id = @@num_buffers
|
@@ -47,27 +48,10 @@ class Buffer < String
|
|
47
48
|
@is_parsing_syntax = false
|
48
49
|
@last_update = Time.now - 100
|
49
50
|
@highlights = {}
|
50
|
-
|
51
|
-
|
52
|
-
detect_file_language()
|
53
|
-
else
|
54
|
-
@fname = fname
|
55
|
-
end
|
51
|
+
|
52
|
+
set_filename(fname)
|
56
53
|
@hl_queue = []
|
57
54
|
@line_action_handler = nil
|
58
|
-
|
59
|
-
@dirname = nil
|
60
|
-
@title = "*#{prefix}-#{@id}*"
|
61
|
-
@subtitle = ""
|
62
|
-
|
63
|
-
if @fname
|
64
|
-
@title = File.basename(@fname)
|
65
|
-
@dirname = File.dirname(@fname)
|
66
|
-
userhome = File.expand_path("~")
|
67
|
-
# @subtitle = @dirname.gsub(/^#{userhome}/, "~")
|
68
|
-
@subtitle = @fname.gsub(/^#{userhome}/, "~")
|
69
|
-
end
|
70
|
-
|
71
55
|
t1 = Time.now
|
72
56
|
|
73
57
|
set_content(str)
|
@@ -304,7 +288,7 @@ class Buffer < String
|
|
304
288
|
if is_image_file(fname)
|
305
289
|
debug "Dropped image file"
|
306
290
|
insert_image_after_current_line(fname)
|
307
|
-
elsif
|
291
|
+
elsif file_is_text_file(fname)
|
308
292
|
debug "Dropped text file"
|
309
293
|
open_new_file(fname)
|
310
294
|
else
|
@@ -325,15 +309,10 @@ class Buffer < String
|
|
325
309
|
self.set_content(str)
|
326
310
|
end
|
327
311
|
|
328
|
-
def
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
str = @crypt.decrypt(@encrypted_str)
|
333
|
-
rescue OpenSSL::Cipher::CipherError => e
|
334
|
-
str = "incorrect password"
|
335
|
-
end
|
336
|
-
self.set_content(str)
|
312
|
+
def init_encrypted(crypt:, filename:, encrypted:)
|
313
|
+
@crypt = crypt
|
314
|
+
@encrypted_str = encrypted
|
315
|
+
set_filename(filename)
|
337
316
|
end
|
338
317
|
|
339
318
|
def sanitycheck_btree()
|
@@ -365,12 +344,6 @@ class Buffer < String
|
|
365
344
|
@encrypted_str = nil
|
366
345
|
@gui_update_highlight = true
|
367
346
|
@ftype = nil
|
368
|
-
if str[0..10] == "VMACRYPT001"
|
369
|
-
@encrypted_str = str[11..-1]
|
370
|
-
callback = proc { |x| self.decrypt(x) }
|
371
|
-
gui_one_input_action("Decrypt file \n #{@fname}", "Password:", "decrypt", callback, { :hide => true })
|
372
|
-
str = "ENCRYPTED"
|
373
|
-
end
|
374
347
|
|
375
348
|
if (str[-1] != "\n")
|
376
349
|
str << "\n"
|
@@ -424,7 +397,10 @@ class Buffer < String
|
|
424
397
|
end
|
425
398
|
|
426
399
|
def set_filename(filename)
|
400
|
+
debug "set_filename(filename) #{filename}"
|
427
401
|
@fname = filename
|
402
|
+
@title = "*#{@prefix}-#{@id}*"
|
403
|
+
return if @fname.nil?
|
428
404
|
@pathname = Pathname.new(fname) if @fname
|
429
405
|
@basename = @pathname.basename if @fname
|
430
406
|
|
@@ -435,6 +411,7 @@ class Buffer < String
|
|
435
411
|
vma.buffers.last_dir = @dirname
|
436
412
|
|
437
413
|
detect_file_language
|
414
|
+
gui_set_window_title(@title, @subtitle)
|
438
415
|
end
|
439
416
|
|
440
417
|
def get_short_path()
|
@@ -1051,7 +1028,7 @@ class Buffer < String
|
|
1051
1028
|
|
1052
1029
|
# Activated when enter/return pressed
|
1053
1030
|
def handle_line_action()
|
1054
|
-
if line_action_handler.class == Proc
|
1031
|
+
if line_action_handler.class == Proc or line_action_handler.class == Method
|
1055
1032
|
# Custom handler
|
1056
1033
|
line_action_handler.call(lpos)
|
1057
1034
|
else
|
@@ -1098,6 +1075,7 @@ class Buffer < String
|
|
1098
1075
|
else
|
1099
1076
|
wtype = :file
|
1100
1077
|
end
|
1078
|
+
word = path
|
1101
1079
|
# elsif hpt_check_cur_word(word) #TODO: check only
|
1102
1080
|
# debug word
|
1103
1081
|
elsif linep != nil
|
@@ -1111,6 +1089,7 @@ class Buffer < String
|
|
1111
1089
|
return [fn, :hpt_link]
|
1112
1090
|
end
|
1113
1091
|
end
|
1092
|
+
|
1114
1093
|
return [word, wtype]
|
1115
1094
|
end
|
1116
1095
|
|
@@ -1258,17 +1237,26 @@ class Buffer < String
|
|
1258
1237
|
@need_redraw = false
|
1259
1238
|
end
|
1260
1239
|
|
1261
|
-
def
|
1262
|
-
@
|
1263
|
-
|
1264
|
-
|
1240
|
+
def selection_active?
|
1241
|
+
@selection_active
|
1242
|
+
end
|
1243
|
+
|
1244
|
+
def end_selection()
|
1245
|
+
@selection_start = nil
|
1246
|
+
@selection_active = false
|
1247
|
+
@visual_mode = false
|
1248
|
+
#TODO: remove @visual_mode
|
1265
1249
|
end
|
1266
1250
|
|
1267
1251
|
def start_selection()
|
1268
|
-
@visual_mode = true
|
1269
1252
|
@selection_start = @pos
|
1270
|
-
|
1271
|
-
|
1253
|
+
@selection_active = true
|
1254
|
+
@visual_mode = true
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
# Start selection if not already started
|
1258
|
+
def continue_selection()
|
1259
|
+
start_selection if !@selection_active
|
1272
1260
|
end
|
1273
1261
|
|
1274
1262
|
def copy_active_selection(x = nil)
|
@@ -1297,6 +1285,7 @@ class Buffer < String
|
|
1297
1285
|
txt.gsub!(/\w+/, &:capitalize) if op == :capitalize
|
1298
1286
|
txt.swapcase! if op == :swapcase
|
1299
1287
|
txt.reverse! if op == :reverse
|
1288
|
+
txt = to_camel_case(txt) if op == :camelcase
|
1300
1289
|
|
1301
1290
|
replace_range(r, txt)
|
1302
1291
|
end_visual_mode
|
@@ -1380,6 +1369,7 @@ class Buffer < String
|
|
1380
1369
|
# TODO: should not happen
|
1381
1370
|
end
|
1382
1371
|
debug "End visual mode"
|
1372
|
+
end_selection
|
1383
1373
|
vma.kbd.to_previous_mode
|
1384
1374
|
@visual_mode = false
|
1385
1375
|
return true
|
@@ -74,20 +74,35 @@ class Buffer < String
|
|
74
74
|
set_pos(l.end + 1)
|
75
75
|
end
|
76
76
|
|
77
|
+
# Workaround for https://github.com/ruby-gnome/ruby-gnome/issues/1609
|
78
|
+
def paste_start_xclip(at, register)
|
79
|
+
@clipboard_paste_running = true
|
80
|
+
Thread.new {
|
81
|
+
text = `xclip -selection c -o`
|
82
|
+
paste_finish(text, at, register)
|
83
|
+
}
|
84
|
+
return nil
|
85
|
+
end
|
86
|
+
|
77
87
|
# Start asynchronous read of system clipboard
|
78
88
|
def paste_start(at, register)
|
79
89
|
@clipboard_paste_running = true
|
90
|
+
|
91
|
+
if true or running_wayland? and !GLib::Version::or_later?(2, 79, 0)
|
92
|
+
return paste_start_xclip(at, register)
|
93
|
+
end
|
94
|
+
|
80
95
|
clipboard = vma.gui.window.display.clipboard
|
81
96
|
clipboard.read_text_async do |_clipboard, result|
|
82
97
|
begin
|
83
98
|
text = clipboard.read_text_finish(result)
|
84
99
|
rescue Gio::IOError::NotSupported
|
85
|
-
# Happens when pasting from KeePassX and clipboard cleared
|
86
100
|
debug Gio::IOError::NotSupported
|
87
101
|
else
|
88
102
|
paste_finish(text, at, register)
|
89
103
|
end
|
90
104
|
end
|
105
|
+
return nil
|
91
106
|
end
|
92
107
|
|
93
108
|
def paste_finish(text, at, register)
|
@@ -141,7 +156,7 @@ class Buffer < String
|
|
141
156
|
return if !is_legal_pos(p)
|
142
157
|
(word, range) = get_word_in_pos(p, boundary: :word)
|
143
158
|
debug [word, range].to_s, 2
|
144
|
-
endpos = range.begin+rep.size
|
159
|
+
endpos = range.begin + rep.size
|
145
160
|
replace_range(range, rep)
|
146
161
|
set_pos(endpos)
|
147
162
|
end
|
@@ -246,9 +261,9 @@ class Buffer < String
|
|
246
261
|
end
|
247
262
|
|
248
263
|
def insert_tab
|
249
|
-
convert =
|
250
|
-
convert = true if
|
251
|
-
convert = false if
|
264
|
+
convert = cnf.tab.to_spaces_default?
|
265
|
+
convert = true if cnf.tab.to_spaces_languages?.include?(@lang)
|
266
|
+
convert = false if cnf.tab.to_spaces_not_languages?.include?(@lang)
|
252
267
|
tw = conf(:tab_width)
|
253
268
|
if convert
|
254
269
|
indent_to = (@cpos / tw) * tw + tw
|
data/lib/vimamsa/buffer_list.rb
CHANGED
@@ -65,6 +65,12 @@ class BufferList
|
|
65
65
|
# TODO: implement using heap/priorityque
|
66
66
|
@list.sort_by! { |x| x.access_time }
|
67
67
|
end
|
68
|
+
|
69
|
+
def each(&block)
|
70
|
+
for x in slist
|
71
|
+
block.call(x)
|
72
|
+
end
|
73
|
+
end
|
68
74
|
|
69
75
|
def get_last_visited_id
|
70
76
|
last_buf = nil
|
@@ -155,6 +161,7 @@ class BufferList
|
|
155
161
|
end
|
156
162
|
|
157
163
|
# hpt_scan_images() if cnf.debug? # experimental
|
164
|
+
return bu
|
158
165
|
end
|
159
166
|
|
160
167
|
def to_s
|