vimamsa 0.1.6 → 0.1.9
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/custom_example.rb +47 -0
- data/demo.txt +25 -0
- data/lang/hyperplaintext.lang +9 -25
- data/lib/vimamsa/ack.rb +90 -7
- data/lib/vimamsa/actions.rb +27 -8
- data/lib/vimamsa/buffer.rb +130 -76
- data/lib/vimamsa/buffer_list.rb +24 -0
- data/lib/vimamsa/buffer_manager.rb +83 -0
- data/lib/vimamsa/conf.rb +21 -0
- data/lib/vimamsa/debug.rb +3 -2
- data/lib/vimamsa/easy_jump.rb +15 -20
- data/lib/vimamsa/editor.rb +93 -73
- data/lib/vimamsa/encrypt.rb +1 -1
- data/lib/vimamsa/file_finder.rb +6 -9
- data/lib/vimamsa/file_history.rb +3 -3
- data/lib/vimamsa/file_manager.rb +9 -8
- data/lib/vimamsa/gui.rb +89 -87
- 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 +64 -37
- data/lib/vimamsa/hyper_plain_text.rb +38 -19
- data/lib/vimamsa/key_actions.rb +40 -13
- data/lib/vimamsa/key_binding_tree.rb +52 -128
- data/lib/vimamsa/key_bindings_vimlike.rb +28 -25
- data/lib/vimamsa/macro.rb +5 -5
- data/lib/vimamsa/rbvma.rb +22 -18
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +11 -8
- data/lib/vimamsa/text_transforms.rb +2 -0
- 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 +1 -1
- metadata +13 -8
- data/lib/vimamsa/gui_gtk_sourceview.rb +0 -294
data/lib/vimamsa/easy_jump.rb
CHANGED
@@ -9,7 +9,6 @@ class EasyJump
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize()
|
12
|
-
# message "EASY JUMP"
|
13
12
|
visible_range = get_visible_area()
|
14
13
|
visible_text = buf[visible_range[0]..visible_range[1]]
|
15
14
|
wsmarks = scan_word_start_marks(visible_text)
|
@@ -17,12 +16,24 @@ class EasyJump
|
|
17
16
|
lsh = Hash[line_starts.collect { |x| [x, true] }]
|
18
17
|
wsmh = Hash[wsmarks.collect { |x| [x, true] }]
|
19
18
|
|
19
|
+
# Exclude work starts that are too close to start of line
|
20
20
|
wsmarks.select! { |x|
|
21
21
|
r = true
|
22
22
|
r = false if lsh[x] or lsh[x - 1] or lsh[x - 2]
|
23
23
|
r
|
24
24
|
}
|
25
25
|
|
26
|
+
# Exclude those word start positions that are too close to each other
|
27
|
+
wsmarks.sort!
|
28
|
+
wsm2 = [wsmarks[0]]
|
29
|
+
for i in 1..(wsmarks.size - 1)
|
30
|
+
if (wsmarks[i] - wsm2[-1]) >= 4 or visible_text[wsm2[-1]..wsmarks[i]].include?("\n")
|
31
|
+
|
32
|
+
wsm2 << wsmarks[i]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
wsmarks = wsm2
|
36
|
+
|
26
37
|
linestart_buf = (line_starts).collect { |x| x + visible_range[0] }
|
27
38
|
wsmarks_buf = (wsmarks).collect { |x| x + visible_range[0] }
|
28
39
|
|
@@ -41,12 +52,12 @@ class EasyJump
|
|
41
52
|
def easy_jump_input_char(c, event_type)
|
42
53
|
return true if event_type != :key_press
|
43
54
|
# vma.paint_stack = []
|
44
|
-
|
55
|
+
debug "EASY JUMP: easy_jump_input_char [#{c}]"
|
45
56
|
@easy_jump_input << c.upcase
|
46
57
|
if @jump_sequence.include?(@easy_jump_input)
|
47
58
|
jshash = Hash[@jump_sequence.map.with_index.to_a]
|
48
59
|
nthword = jshash[@easy_jump_input]
|
49
|
-
|
60
|
+
debug "nthword:#{nthword} #{[@easy_jump_wsmarks[nthword], @jump_sequence[nthword]]}"
|
50
61
|
buf.set_pos(@easy_jump_wsmarks[nthword])
|
51
62
|
# @kbd.set_mode(:command)
|
52
63
|
vma.kbd.remove_keyhandling_override
|
@@ -63,25 +74,11 @@ class EasyJump
|
|
63
74
|
end
|
64
75
|
|
65
76
|
def easy_jump_draw()
|
66
|
-
# puts @jump_sequence.inspect
|
67
|
-
# puts @easy_jump_wsmarks.inspect
|
68
77
|
vma.gui.start_overlay_draw
|
69
78
|
for i in 0..(@easy_jump_wsmarks.size - 1)
|
70
|
-
vma.gui.overlay_draw_text(@jump_sequence[i], @easy_jump_wsmarks[i])
|
79
|
+
vma.gui.overlay_draw_text(@jump_sequence[i], @easy_jump_wsmarks[i])
|
71
80
|
end
|
72
81
|
vma.gui.end_overlay_draw
|
73
|
-
|
74
|
-
return
|
75
|
-
return if @jump_sequence.empty?
|
76
|
-
puts "EASY JUMP DRAW"
|
77
|
-
screen_cord = cpp_function_wrapper(0, [@easy_jump_wsmarks])
|
78
|
-
screen_cord = screen_cord[1..@jump_sequence.size]
|
79
|
-
screen_cord.each_with_index { |point, i|
|
80
|
-
mark_str = @jump_sequence[i]
|
81
|
-
#puts "draw #{point[0]}x#{point[1]}"
|
82
|
-
draw_text(mark_str, point[0] + 3, point[1])
|
83
|
-
#break if m > @cpos
|
84
|
-
}
|
85
82
|
end
|
86
83
|
|
87
84
|
def make_jump_sequence(num_items)
|
@@ -158,8 +155,6 @@ class EasyJump
|
|
158
155
|
}
|
159
156
|
}
|
160
157
|
|
161
|
-
#printf("Size of sequence: %d\n",sequence.size)
|
162
|
-
#puts sequence.inspect
|
163
158
|
return sequence
|
164
159
|
end
|
165
160
|
end
|
data/lib/vimamsa/editor.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
require "pty"
|
2
2
|
|
3
|
-
def exec_in_terminal(cmd)
|
4
|
-
#
|
3
|
+
def exec_in_terminal(cmd, autoclose = false)
|
4
|
+
# debug "CMD:#{cmd}"
|
5
5
|
|
6
6
|
# global to prevent garbage collect unlink
|
7
7
|
$initf = Tempfile.new("bashinit")
|
8
|
-
#
|
8
|
+
# debug $initf.path
|
9
9
|
$initf.write(cmd)
|
10
|
-
|
11
|
-
|
10
|
+
if autoclose
|
11
|
+
$initf.write("\nsleep 10; exit;\n")
|
12
|
+
$initf.write("rm #{$initf.path}\n")
|
13
|
+
else
|
14
|
+
$initf.write("rm #{$initf.path}\n")
|
15
|
+
$initf.write("\nexec bash\n")
|
16
|
+
end
|
12
17
|
$initf.close
|
13
18
|
# PTY.spawn("gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash")
|
19
|
+
# fork { exec "gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash" }
|
20
|
+
# Just another execution
|
14
21
|
fork { exec "gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash" }
|
15
22
|
end
|
16
23
|
|
@@ -26,11 +33,11 @@ end
|
|
26
33
|
|
27
34
|
class Editor
|
28
35
|
attr_reader :file_content_search_paths, :file_name_search_paths, :gui
|
29
|
-
attr_accessor :converters, :fh, :paint_stack, :kbd
|
36
|
+
attr_accessor :converters, :fh, :paint_stack, :kbd
|
30
37
|
#attr_writer :call_func, :update_highlight
|
31
38
|
|
32
39
|
def initialize()
|
33
|
-
# Thread.new{10000.times{|x|sleep(3);10000.times{|y|y+2};
|
40
|
+
# Thread.new{10000.times{|x|sleep(3);10000.times{|y|y+2};debug "FOOTHREAD #{x}"}}
|
34
41
|
|
35
42
|
# Search for content inside files (e.g. using ack/grep) in:
|
36
43
|
@file_content_search_paths = []
|
@@ -42,7 +49,6 @@ class Editor
|
|
42
49
|
@converters = {}
|
43
50
|
@paint_stack = []
|
44
51
|
@_plugins = {}
|
45
|
-
|
46
52
|
end
|
47
53
|
|
48
54
|
def open_file_listener(added)
|
@@ -64,13 +70,6 @@ class Editor
|
|
64
70
|
end
|
65
71
|
|
66
72
|
def start
|
67
|
-
# $highlight = {}
|
68
|
-
|
69
|
-
# GLib::Idle.add
|
70
|
-
# Ripl.start :binding => binding
|
71
|
-
# GLib::Idle.add(proc{ puts "IDLEFUNC"})
|
72
|
-
# GLib::Idle.add(proc { idle_func })
|
73
|
-
|
74
73
|
@gui = $vmag #TODO
|
75
74
|
|
76
75
|
$hook = Hook.new
|
@@ -89,28 +88,39 @@ class Editor
|
|
89
88
|
# build_key_bindings_tree
|
90
89
|
@kbd = KeyBindingTree.new()
|
91
90
|
$kbd = @kbd
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
91
|
+
@kbd.add_mode("C", :command)
|
92
|
+
@kbd.add_mode("I", :insert)
|
93
|
+
@kbd.add_mode("V", :visual)
|
94
|
+
@kbd.add_mode("M", :minibuffer)
|
95
|
+
@kbd.add_mode("R", :readchar)
|
96
|
+
@kbd.add_mode("B", :browse)
|
97
|
+
@kbd.set_default_mode(:command)
|
98
|
+
@kbd.set_mode(:command)
|
99
|
+
@kbd.show_state_trail
|
99
100
|
require "vimamsa/key_bindings_vimlike"
|
100
101
|
sleep(0.03)
|
101
102
|
|
102
103
|
FileManager.init
|
104
|
+
BufferManager.init
|
103
105
|
|
104
106
|
mkdir_if_not_exists("~/.vimamsa")
|
105
107
|
mkdir_if_not_exists("~/.vimamsa/backup")
|
106
108
|
mkdir_if_not_exists("~/.vimamsa/listen")
|
107
109
|
listen_dir = File.expand_path "~/.vimamsa/listen"
|
108
110
|
listener = Listen.to(listen_dir) do |modified, added, removed|
|
109
|
-
|
111
|
+
debug([modified: modified, added: added, removed: removed])
|
110
112
|
open_file_listener(added)
|
111
113
|
end
|
112
114
|
listener.start
|
113
115
|
|
116
|
+
custom_fn = File.expand_path("~/.vimamsa/custom.rb")
|
117
|
+
if !File.exist?(custom_fn)
|
118
|
+
example_custom = IO.read(ppath("custom_example.rb"))
|
119
|
+
IO.write(custom_fn, example_custom)
|
120
|
+
end
|
121
|
+
|
122
|
+
mkdir_if_not_exists("~/.vimamsa/custom.rb")
|
123
|
+
|
114
124
|
$cnf[:theme] = "Twilight_edit"
|
115
125
|
$cnf[:syntax_highlight] = true
|
116
126
|
settings_path = get_dot_path("settings.rb")
|
@@ -125,6 +135,9 @@ class Editor
|
|
125
135
|
|
126
136
|
dotfile = read_file("", "~/.vimamsarc")
|
127
137
|
eval(dotfile) if dotfile
|
138
|
+
|
139
|
+
custom_script = read_file("", custom_fn)
|
140
|
+
eval(custom_script) if custom_script
|
128
141
|
|
129
142
|
# build_options
|
130
143
|
|
@@ -134,6 +147,8 @@ class Editor
|
|
134
147
|
if File.exist?(fname_)
|
135
148
|
fname = fname_
|
136
149
|
end
|
150
|
+
else
|
151
|
+
fname = ppath("demo.txt")
|
137
152
|
end
|
138
153
|
fname = ARGV[0] if ARGV.size >= 1 and File.file?(File.expand_path(ARGV[0]))
|
139
154
|
# vma.add_content_search_path(Dir.pwd)
|
@@ -183,6 +198,10 @@ class Editor
|
|
183
198
|
return $buffer
|
184
199
|
end
|
185
200
|
|
201
|
+
def buffers()
|
202
|
+
return $buffers
|
203
|
+
end
|
204
|
+
|
186
205
|
def marshal_save(varname, vardata)
|
187
206
|
save_var_to_file(varname, Marshal.dump(vardata))
|
188
207
|
end
|
@@ -244,13 +263,18 @@ class Editor
|
|
244
263
|
@converters[converter_id].apply(txt)
|
245
264
|
end
|
246
265
|
|
266
|
+
# Used only by ack module at the moment
|
247
267
|
def get_content_search_paths()
|
248
268
|
r = @file_content_search_paths.clone
|
249
269
|
p = find_project_dir_of_cur_buffer()
|
270
|
+
if p.nil?
|
271
|
+
p = buf.dirname # Search dir of current file by default
|
272
|
+
end
|
250
273
|
|
251
274
|
if p and !@file_content_search_paths.include?(p)
|
252
275
|
r.insert(0, p)
|
253
276
|
end
|
277
|
+
|
254
278
|
return r
|
255
279
|
end
|
256
280
|
|
@@ -258,7 +282,7 @@ class Editor
|
|
258
282
|
exts = $cnf[:extensions_to_open]
|
259
283
|
extname = Pathname.new(filepath).extname.downcase
|
260
284
|
can_open = exts.include?(extname)
|
261
|
-
|
285
|
+
debug "CAN OPEN?: #{can_open}"
|
262
286
|
return can_open
|
263
287
|
end
|
264
288
|
end
|
@@ -269,7 +293,7 @@ def _quit()
|
|
269
293
|
end
|
270
294
|
|
271
295
|
def fatal_error(msg)
|
272
|
-
|
296
|
+
debug msg
|
273
297
|
exit!
|
274
298
|
end
|
275
299
|
|
@@ -290,16 +314,20 @@ def system_clipboard_changed(clipboard_contents)
|
|
290
314
|
$paste_lines = false
|
291
315
|
end
|
292
316
|
$clipboard << clipboard_contents
|
293
|
-
#
|
317
|
+
# debug $clipboard[-1]
|
294
318
|
$clipboard = $clipboard[-([$clipboard.size, max_clipboard_items].min)..-1]
|
295
319
|
end
|
296
320
|
|
321
|
+
def get_clipboard()
|
322
|
+
return $clipboard[-1]
|
323
|
+
end
|
324
|
+
|
297
325
|
def set_clipboard(s)
|
298
326
|
if !(s.class <= String) or s.size == 0
|
299
|
-
|
300
|
-
|
327
|
+
debug s.inspect
|
328
|
+
debug [s, s.class, s.size]
|
301
329
|
log_error("s.class != String or s.size == 0")
|
302
|
-
Ripl.start :binding => binding
|
330
|
+
# Ripl.start :binding => binding
|
303
331
|
return
|
304
332
|
end
|
305
333
|
$clipboard << s
|
@@ -354,10 +382,17 @@ end
|
|
354
382
|
|
355
383
|
def show_key_bindings()
|
356
384
|
kbd_s = "❙Key bindings❙\n"
|
357
|
-
kbd_s << "
|
385
|
+
kbd_s << "\n⦁[Mode] keys : action⦁\n"
|
386
|
+
|
387
|
+
kbd_s << "[B]=Browse, [C]=Command, [I]=Insert, [V]=Visual\n"
|
388
|
+
kbd_s << "key!: Press key once, release before pressing any other keys\n"
|
389
|
+
|
390
|
+
kbd_s << "===============================================\n"
|
358
391
|
kbd_s << $kbd.to_s
|
359
|
-
kbd_s << "
|
360
|
-
create_new_file(nil, kbd_s)
|
392
|
+
kbd_s << "===============================================\n"
|
393
|
+
b = create_new_file(nil, kbd_s)
|
394
|
+
gui_set_file_lang(b.id, "hyperplaintext")
|
395
|
+
#
|
361
396
|
end
|
362
397
|
|
363
398
|
def diff_buffer()
|
@@ -368,9 +403,9 @@ def diff_buffer()
|
|
368
403
|
infile.write($buffer.to_s)
|
369
404
|
infile.flush
|
370
405
|
cmd = "diff -w '#{orig_path}' #{infile.path}"
|
371
|
-
#
|
406
|
+
# debug cmd
|
372
407
|
bufstr << run_cmd(cmd)
|
373
|
-
#
|
408
|
+
# debug bufstr
|
374
409
|
infile.close; infile.unlink
|
375
410
|
create_new_file(nil, bufstr)
|
376
411
|
end
|
@@ -415,7 +450,7 @@ def minibuffer_new_char(c)
|
|
415
450
|
end
|
416
451
|
|
417
452
|
# def readchar_new_char(c)
|
418
|
-
|
453
|
+
# $input_char_call_func.call(c)
|
419
454
|
# end
|
420
455
|
|
421
456
|
def minibuffer_delete()
|
@@ -424,7 +459,7 @@ end
|
|
424
459
|
|
425
460
|
def message(s)
|
426
461
|
s = "[#{DateTime.now().strftime("%H:%M")}] #{s}"
|
427
|
-
|
462
|
+
debug s
|
428
463
|
|
429
464
|
$vmag.add_to_minibuf(s)
|
430
465
|
# $minibuffer = Buffer.new(s, "")
|
@@ -435,6 +470,7 @@ end
|
|
435
470
|
GUESS_ENCODING_ORDER = [
|
436
471
|
Encoding::US_ASCII,
|
437
472
|
Encoding::UTF_8,
|
473
|
+
Encoding::ISO_8859_1,
|
438
474
|
Encoding::Shift_JIS,
|
439
475
|
Encoding::EUC_JP,
|
440
476
|
Encoding::EucJP_ms,
|
@@ -497,11 +533,23 @@ def load_buffer(fname)
|
|
497
533
|
#$buffer_history << $buffers.size - 1
|
498
534
|
end
|
499
535
|
|
500
|
-
def jump_to_file(filename, linenum =
|
536
|
+
def jump_to_file(filename, linenum = nil, charn = nil)
|
501
537
|
open_new_file(filename)
|
502
|
-
|
503
|
-
|
538
|
+
|
539
|
+
# Link to character position
|
540
|
+
if !charn.nil?
|
541
|
+
if charn == "c"
|
542
|
+
buf.jump_to_pos(linenum)
|
543
|
+
center_on_current_line
|
544
|
+
return
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
# Link to line
|
549
|
+
if !linenum.nil?
|
550
|
+
buf.jump_to_line(linenum)
|
504
551
|
center_on_current_line
|
552
|
+
return
|
505
553
|
end
|
506
554
|
end
|
507
555
|
|
@@ -531,39 +579,11 @@ def scan_word_start_marks(search_str)
|
|
531
579
|
return wsmarks
|
532
580
|
end
|
533
581
|
|
534
|
-
def draw_text(str, x, y)
|
535
|
-
vma.paint_stack << [4, x, y, str]
|
536
|
-
end
|
537
|
-
|
538
582
|
def hook_draw()
|
539
583
|
# TODO: as hook.register
|
540
584
|
# easy_jump_draw()
|
541
585
|
end
|
542
586
|
|
543
|
-
def render_buffer(buffer = 0, reset = 0)
|
544
|
-
tmpbuf = $buffer.to_s
|
545
|
-
debug "pos:#{$buffer.pos} L:#{$buffer.lpos} C:#{$buffer.cpos}"
|
546
|
-
pos = $buffer.pos
|
547
|
-
selection_start = $buffer.selection_start
|
548
|
-
|
549
|
-
if $buffer.need_redraw?
|
550
|
-
reset = 1
|
551
|
-
end
|
552
|
-
t1 = Time.now
|
553
|
-
hook_draw()
|
554
|
-
|
555
|
-
if $buffer.need_redraw?
|
556
|
-
hpt_scan_images() if $debug #experimental
|
557
|
-
end
|
558
|
-
|
559
|
-
$buffer.highlight
|
560
|
-
if Time.now - t1 > 1 / 100.0
|
561
|
-
debug "SLOW render"
|
562
|
-
debug "Render time: #{Time.now - t1}"
|
563
|
-
end
|
564
|
-
$buffer.set_redrawed if reset == 1
|
565
|
-
end
|
566
|
-
|
567
587
|
def get_dot_path(sfx)
|
568
588
|
dot_dir = File.expand_path("~/.vimamsa")
|
569
589
|
Dir.mkdir(dot_dir) unless File.exist?(dot_dir)
|
@@ -574,10 +594,10 @@ end
|
|
574
594
|
def get_file_line_pointer(s)
|
575
595
|
#"/code/vimamsa/lib/vimamsa/buffer_select.rb:31:def"
|
576
596
|
# m = s.match(/(~[a-z]*)?\/.*\//)
|
577
|
-
m = s.match(/((~[a-z]*)?\/.*\/\S+):(\d+)/)
|
597
|
+
m = s.match(/((~[a-z]*)?\/.*\/\S+):(c?)(\d+)/)
|
578
598
|
if m != nil
|
579
599
|
if File.exist?(File.expand_path(m[1]))
|
580
|
-
return [m[1], m[
|
600
|
+
return [m[1], m[4].to_i, m[3]]
|
581
601
|
end
|
582
602
|
end
|
583
603
|
return nil
|
@@ -594,7 +614,7 @@ end
|
|
594
614
|
def run_cmd(cmd)
|
595
615
|
tmpf = Tempfile.new("vmarun", "/tmp").path
|
596
616
|
cmd = "#{cmd} > #{tmpf}"
|
597
|
-
|
617
|
+
debug "CMD:\n#{cmd}"
|
598
618
|
system("bash", "-c", cmd)
|
599
619
|
res_str = File.read(tmpf)
|
600
620
|
return res_str
|
@@ -623,11 +643,11 @@ def exec_cmd(bin_name, arg1 = nil, arg2 = nil, arg3 = nil, arg4 = nil, arg5 = ni
|
|
623
643
|
end
|
624
644
|
|
625
645
|
def file_is_text_file(fpath)
|
626
|
-
|
646
|
+
debug "file_is_text_file(#{fpath})"
|
627
647
|
fpath = File.expand_path(fpath)
|
628
648
|
return false if !File.exist?(fpath)
|
629
649
|
r = exec_cmd("file", fpath)
|
630
|
-
|
650
|
+
debug "DEBUG:#{r}"
|
631
651
|
return true if r.match(/UTF-8.*text/)
|
632
652
|
return true if r.match(/ASCII.*text/)
|
633
653
|
return false
|
@@ -663,6 +683,6 @@ def find_project_dir_of_cur_buffer()
|
|
663
683
|
if $buffer.fname
|
664
684
|
pdir = find_project_dir_of_fn($buffer.fname)
|
665
685
|
end
|
666
|
-
#
|
686
|
+
# debug "Proj dir of current file: #{pdir}"
|
667
687
|
return pdir
|
668
688
|
end
|
data/lib/vimamsa/encrypt.rb
CHANGED
@@ -38,7 +38,7 @@ end
|
|
38
38
|
|
39
39
|
def encrypt_cur_buffer()
|
40
40
|
callback = proc{|x|encrypt_cur_buffer_callback(x)}
|
41
|
-
gui_one_input_action("Encrypt", "Password:", "Encrypt", callback)
|
41
|
+
gui_one_input_action("Encrypt", "Password:", "Encrypt", callback,{:hide=>true})
|
42
42
|
end
|
43
43
|
|
44
44
|
def encrypt_cur_buffer_callback(password,b=nil)
|
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
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
class FileManager
|
2
3
|
@@cur
|
3
4
|
|
@@ -28,11 +29,11 @@ class FileManager
|
|
28
29
|
# bindkey "C o", :delete_state
|
29
30
|
|
30
31
|
$kbd.add_minor_mode("fexp", :file_exp, :command)
|
31
|
-
|
32
|
+
|
32
33
|
bindkey "fexp o m", :fexp_sort_mtime
|
33
|
-
bindkey "fexp o f", :fexp_sort_fname
|
34
|
+
bindkey "fexp o f", :fexp_sort_fname
|
34
35
|
|
35
|
-
# bindkey "fexp l", [:fexp_right, proc {
|
36
|
+
# bindkey "fexp l", [:fexp_right, proc { debug "==fexp_right==" }, ""]
|
36
37
|
bindkey "fexp h", :fexp_chdir_parent
|
37
38
|
bindkey "fexp esc", [:fexp_quit, proc { $kbd.set_mode(:command) }, ""]
|
38
39
|
bindkey "fexp enter", :fexp_select
|
@@ -49,7 +50,7 @@ class FileManager
|
|
49
50
|
@@cur = self
|
50
51
|
ld = buflist.get_last_dir
|
51
52
|
dir_to_buf(ld)
|
52
|
-
#
|
53
|
+
# debug "ld=#{ld}"
|
53
54
|
# dlist = Dir["#{ld}/*"]
|
54
55
|
end
|
55
56
|
|
@@ -83,7 +84,7 @@ class FileManager
|
|
83
84
|
next
|
84
85
|
end
|
85
86
|
next if x[0] == "."
|
86
|
-
if File.directory?(fpath)
|
87
|
+
if File.directory?(fpath)
|
87
88
|
# if f.directory?(fpath)
|
88
89
|
@cdirs << x
|
89
90
|
else
|
@@ -126,10 +127,10 @@ class FileManager
|
|
126
127
|
|
127
128
|
def select_line
|
128
129
|
return if @buf.lpos < @header.size
|
129
|
-
#
|
130
|
+
# debug "def select_line"
|
130
131
|
fn = fullp(@buf.get_current_line[0..-2])
|
131
132
|
if File.directory?(fn)
|
132
|
-
|
133
|
+
debug "CHDIR: #{fn}"
|
133
134
|
dir_to_buf(fn)
|
134
135
|
# elsif vma.can_open_extension?(fn)
|
135
136
|
# jump_to_file(fn)
|
@@ -139,6 +140,6 @@ class FileManager
|
|
139
140
|
else
|
140
141
|
open_with_default_program(fn)
|
141
142
|
end
|
142
|
-
#
|
143
|
+
# debug l.inspect
|
143
144
|
end
|
144
145
|
end
|