vimamsa 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/custom_example.rb +1 -1
- data/lib/vimamsa/ack.rb +3 -40
- data/lib/vimamsa/buffer.rb +16 -12
- data/lib/vimamsa/buffer_list.rb +31 -37
- data/lib/vimamsa/debug.rb +8 -8
- data/lib/vimamsa/editor.rb +24 -19
- data/lib/vimamsa/encrypt.rb +2 -2
- data/lib/vimamsa/file_manager.rb +9 -7
- data/lib/vimamsa/gui.rb +6 -2
- data/lib/vimamsa/gui_sourceview.rb +3 -2
- data/lib/vimamsa/hyper_plain_text.rb +2 -2
- data/lib/vimamsa/key_binding_tree.rb +6 -6
- data/lib/vimamsa/main.rb +3 -3
- data/lib/vimamsa/search.rb +1 -1
- data/lib/vimamsa/search_replace.rb +14 -14
- data/lib/vimamsa/text_transforms.rb +1 -1
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfc14cb231bc93909b4866e08cbd4503b4f4444527c0b65b4a9edb11d863faa0
|
4
|
+
data.tar.gz: 7b63cdbff33cdcdbf7d6f5d025d8ec13a6f39a3ee937f716ec990bba743f3239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2176d7aaa01be873deb8687cf2b8d75044edba4ccfc3685cf334cae973c93e15ba6dc47d9667a9848209329b043f2ba8daf049f4340ddb130538584e17b5a5de
|
7
|
+
data.tar.gz: afcdd6c30018dc971fc165d8ed6f63f5b2ccf109a167d0ec39cf03c150ac03d7765c4c0d83e3a6ceabaae74cf44f759144dbe5e2d9aee1b191182ca7fb622035
|
data/README.md
CHANGED
@@ -26,11 +26,16 @@ Packages for optional features:
|
|
26
26
|
sudo apt install ack-grep clang-format
|
27
27
|
```
|
28
28
|
|
29
|
-
For customization, edit
|
29
|
+
For customization, edit ~/.vimamsa/custom.rb
|
30
|
+
|
31
|
+
## Screenshots
|
32
|
+
|
33
|
+
<a href="https://samiddhi.net/vimamsa/screenshot1.png" target="_blank"><img src="https://samiddhi.net/vimamsa/screenshot1.png" width="400"/></a>
|
34
|
+
<a href="https://samiddhi.net/vimamsa/screenshot2.png" target="_blank"><img src="https://samiddhi.net/vimamsa/screenshot2.png" width="400"/></a>
|
30
35
|
|
31
36
|
## Key bindings
|
32
37
|
|
33
|
-
Key bindings are very much like in VIm. For details, see file lib/vimamsa/key_bindings.rb and lib/vimamsa/
|
38
|
+
Key bindings are very much like in VIm. For details, see file lib/vimamsa/key_bindings.rb and lib/vimamsa/key_bindings_vimlike.rb
|
34
39
|
|
35
40
|
Keys that work somewhat similarly as in Vim:
|
36
41
|
|
@@ -72,7 +77,7 @@ ctrl-x means press and hold ctrl key, press x
|
|
72
77
|
</td></tr>
|
73
78
|
<tr> <td style="text-align:center;">,b</td> <td style="text-align:left;"> Switch buffer (jump to other open file)</td></tr>
|
74
79
|
<tr> <td style="text-align:center;">,g</td> <td style="text-align:left;">search for input string inside current buffer</td></tr>
|
75
|
-
<tr> <td style="text-align:center;">,f</td> <td style="text-align:left;">
|
80
|
+
<tr> <td style="text-align:center;">,f</td> <td style="text-align:left;">File finder</td></tr>
|
76
81
|
<tr> <td style="text-align:center;">space c</td> <td style="text-align:left;">insert character "c"</td></tr>
|
77
82
|
</tbody>
|
78
83
|
</table>
|
@@ -116,7 +121,7 @@ ctrl-x means press and hold ctrl key, press x
|
|
116
121
|
</tbody>
|
117
122
|
</table>
|
118
123
|
|
119
|
-
Bindings can be customized in ~/.
|
124
|
+
Bindings can be customized in ~/.vimamsa/custom.rb
|
120
125
|
For example, to bind ctrl-n to action "create new file":
|
121
126
|
```
|
122
127
|
bindkey 'C ctrl-n', 'create_new_file()'
|
data/custom_example.rb
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
# setcnf :tab_width, 4
|
14
14
|
|
15
15
|
# Open this file every time the program starts
|
16
|
-
# setcnf :startup_file, "~/Documents/
|
16
|
+
# setcnf :startup_file, "~/Documents/startup.txt"
|
17
17
|
|
18
18
|
def insert_date()
|
19
19
|
# $buffer.insert_txt("#{DateTime.now().strftime("==========\n%Y-%m-%d")}\n")
|
data/lib/vimamsa/ack.rb
CHANGED
@@ -4,12 +4,8 @@ class FileContentSearch
|
|
4
4
|
def self.start_gui()
|
5
5
|
search_paths = vma.get_content_search_paths.join("<br/>")
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
<p>Hint: add empty file named .vma_project to dirs you want to search.</p>\n<p>If .vma_project exists in parent dir of current file, searches within that dir</p></div></html>"
|
10
|
-
|
11
|
-
nfo = "<span size='x-large'>Search contents of all files using ack</span>
|
12
|
-
Will search the following directories:
|
7
|
+
nfo = "<span size='x-large'>Search contents of text files</span>
|
8
|
+
Will search all .txt files in the following directories:
|
13
9
|
#{search_paths}
|
14
10
|
|
15
11
|
<span>Hint: add empty file named .vma_project to directories you want to search in.
|
@@ -25,6 +21,7 @@ Will search the following directories:
|
|
25
21
|
fext = Set[".txt"]
|
26
22
|
dlist = []
|
27
23
|
for d in vma.get_content_search_paths
|
24
|
+
# Search for files with extension .txt and size < 200k
|
28
25
|
dlist = dlist + Dir.glob("#{d}/**/*").select { |e| File.file?(e) and fext.include?(File.extname(e)) and File.size(e) < 200e3 }
|
29
26
|
end
|
30
27
|
bufstr = "Results:\n\n"
|
@@ -33,8 +30,6 @@ Will search the following directories:
|
|
33
30
|
ind = scan_indexes(txt, /#{instr}/i)
|
34
31
|
if !ind.empty?
|
35
32
|
for x in ind
|
36
|
-
# Ripl.start :binding => binding
|
37
|
-
|
38
33
|
starti = x - 30
|
39
34
|
endi = x + 30
|
40
35
|
starti = 0 if starti < 0
|
@@ -68,38 +63,6 @@ Will search the following directories:
|
|
68
63
|
gui_one_input_action(nfo, "Search:", "search", callback)
|
69
64
|
end
|
70
65
|
|
71
|
-
def ack_buffer(instr, b = nil)
|
72
|
-
instr = Shellwords.escape(instr)
|
73
|
-
bufstr = ""
|
74
|
-
for path in vma.get_content_search_paths
|
75
|
-
bufstr += run_cmd("ack -Q --type-add=gd=.gd -k --nohtml --nojs --nojson '#{instr}' #{path}")
|
76
|
-
end
|
77
|
-
if bufstr.size > 5
|
78
|
-
create_new_file(nil, bufstr)
|
79
|
-
else
|
80
|
-
message("No results for input:#{instr}")
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def gui_ack()
|
85
|
-
search_paths = vma.get_content_search_paths.join("<br/>")
|
86
|
-
|
87
|
-
nfo = "<html><h2>Search contents of all files using ack</h2>
|
88
|
-
<div style='width:300px'>
|
89
|
-
<p>Hint: add empty file named .vma_project to dirs you want to search.</p>\n<p>If .vma_project exists in parent dir of current file, searches within that dir</p></div></html>"
|
90
|
-
|
91
|
-
nfo = "<span size='x-large'>Search contents of all files using ack</span>
|
92
|
-
Will search the following directories:
|
93
|
-
#{search_paths}
|
94
|
-
|
95
|
-
<span>Hint: add empty file named .vma_project to directories you want to search in.
|
96
|
-
If .vma_project exists in parent directory of current file, searches within that directory.
|
97
|
-
</span>"
|
98
|
-
|
99
|
-
callback = proc { |x| ack_buffer(x) }
|
100
|
-
gui_one_input_action(nfo, "Search:", "search", callback)
|
101
|
-
end
|
102
|
-
|
103
66
|
def ack_buffer(instr, b = nil)
|
104
67
|
instr = Shellwords.escape(instr)
|
105
68
|
bufstr = ""
|
data/lib/vimamsa/buffer.rb
CHANGED
@@ -320,6 +320,7 @@ class Buffer < String
|
|
320
320
|
@dirname = File.dirname(@fname)
|
321
321
|
userhome = File.expand_path("~")
|
322
322
|
@subtitle = @dirname.gsub(/^#{userhome}/, "~")
|
323
|
+
vma.buffers.last_dir = @dirname
|
323
324
|
|
324
325
|
detect_file_language
|
325
326
|
end
|
@@ -574,8 +575,7 @@ class Buffer < String
|
|
574
575
|
|
575
576
|
def comment_linerange(r)
|
576
577
|
com_str = get_com_str()
|
577
|
-
|
578
|
-
lines = $buffer[r].lines
|
578
|
+
lines = self[r].lines
|
579
579
|
mod = ""
|
580
580
|
lines.each { |line|
|
581
581
|
m = line.match(/^(\s*)(\S.*)/)
|
@@ -637,14 +637,14 @@ class Buffer < String
|
|
637
637
|
elsif op == :uncomment
|
638
638
|
uncomment_linerange(first..last)
|
639
639
|
end
|
640
|
-
|
640
|
+
self.end_visual_mode
|
641
641
|
end
|
642
642
|
end
|
643
643
|
|
644
644
|
def uncomment_linerange(r)
|
645
645
|
com_str = get_com_str()
|
646
|
-
#r
|
647
|
-
lines =
|
646
|
+
#r=self.line_range(self.lpos, 2)
|
647
|
+
lines = self[r].split(/(\n)/).each_slice(2).map { |x| x[0] }
|
648
648
|
mod = lines.collect { |x| x.sub(/^(\s*)(#{com_str}\s?)/, '\1') + "\n" }.join()
|
649
649
|
replace_range(r, mod)
|
650
650
|
end
|
@@ -1356,7 +1356,7 @@ class Buffer < String
|
|
1356
1356
|
d2 = [@pos, INSERT, 1, char]
|
1357
1357
|
add_delta(d1, true)
|
1358
1358
|
add_delta(d2, true)
|
1359
|
-
debug "DELTAS:#{
|
1359
|
+
debug "DELTAS:#{self.deltas.inspect} "
|
1360
1360
|
end
|
1361
1361
|
|
1362
1362
|
def insert_txt_at(c, pos)
|
@@ -1449,7 +1449,6 @@ class Buffer < String
|
|
1449
1449
|
for d in deltas
|
1450
1450
|
add_delta(d, true, true)
|
1451
1451
|
end
|
1452
|
-
# $buffer.update_content(IO.read('test.txt'))
|
1453
1452
|
end
|
1454
1453
|
|
1455
1454
|
def need_redraw!
|
@@ -1685,7 +1684,7 @@ class Buffer < String
|
|
1685
1684
|
# If current file has fname, save to that fname
|
1686
1685
|
# Else search for previously open files and save to the directory of
|
1687
1686
|
# the last viewed file that has a filename
|
1688
|
-
#
|
1687
|
+
# selffers[$buffer_history.reverse[1]].fname
|
1689
1688
|
|
1690
1689
|
if @fname
|
1691
1690
|
savepath = File.dirname(@fname)
|
@@ -1747,7 +1746,7 @@ class Buffer < String
|
|
1747
1746
|
def indent()
|
1748
1747
|
file = Tempfile.new("out")
|
1749
1748
|
infile = Tempfile.new("in")
|
1750
|
-
file.write(
|
1749
|
+
file.write(self.to_s)
|
1751
1750
|
file.flush
|
1752
1751
|
bufc = "FOO"
|
1753
1752
|
|
@@ -1773,12 +1772,17 @@ class Buffer < String
|
|
1773
1772
|
else
|
1774
1773
|
return
|
1775
1774
|
end
|
1776
|
-
|
1775
|
+
self.update_content(bufc)
|
1777
1776
|
center_on_current_line #TODO: needed?
|
1778
1777
|
file.close; file.unlink
|
1779
1778
|
infile.close; infile.unlink
|
1780
1779
|
end
|
1781
1780
|
|
1781
|
+
def close()
|
1782
|
+
idx = vma.buffers.get_buffer_by_id(@id)
|
1783
|
+
vma.buffers.close_buffer(idx)
|
1784
|
+
end
|
1785
|
+
|
1782
1786
|
def backup()
|
1783
1787
|
fname = @fname
|
1784
1788
|
return if !@fname
|
@@ -1799,7 +1803,7 @@ end
|
|
1799
1803
|
#TODO
|
1800
1804
|
def write_to_file(savepath, s)
|
1801
1805
|
if is_path_writable(savepath)
|
1802
|
-
IO.write(savepath,
|
1806
|
+
IO.write(savepath, self.to_s)
|
1803
1807
|
else
|
1804
1808
|
message("PATH NOT WRITABLE: #{savepath}")
|
1805
1809
|
end
|
@@ -1814,7 +1818,7 @@ def is_path_writable(fpath)
|
|
1814
1818
|
end
|
1815
1819
|
|
1816
1820
|
def backup_all_buffers()
|
1817
|
-
for buf in
|
1821
|
+
for buf in selffers
|
1818
1822
|
buf.backup
|
1819
1823
|
end
|
1820
1824
|
message("Backup all buffers")
|
data/lib/vimamsa/buffer_list.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
1
|
def save_buffer_list()
|
3
2
|
message("Save buffer list")
|
4
3
|
buffn = get_dot_path("buffers.txt")
|
5
4
|
f = File.open(buffn, "w")
|
6
|
-
bufstr =
|
5
|
+
bufstr = vma.buffers.collect { |buf| buf.fname }.inspect
|
7
6
|
f.write(bufstr)
|
8
7
|
f.close()
|
9
8
|
end
|
@@ -21,18 +20,23 @@ def load_buffer_list()
|
|
21
20
|
end
|
22
21
|
|
23
22
|
class BufferList < Array
|
24
|
-
attr_reader :current_buf
|
23
|
+
attr_reader :current_buf, :last_dir
|
25
24
|
|
25
|
+
def initialize()
|
26
|
+
@last_dir = File.expand_path(".")
|
27
|
+
super
|
28
|
+
end
|
26
29
|
|
30
|
+
# lastdir = File.expand_path(".") if lastdir.nil?
|
27
31
|
def <<(_buf)
|
28
32
|
super
|
29
|
-
|
33
|
+
vma.buf = _buf
|
30
34
|
@current_buf = self.size - 1
|
31
35
|
$buffer_history << @current_buf
|
32
36
|
@recent_ind = 0
|
33
|
-
$hook.call(:change_buffer,
|
34
|
-
gui_set_current_buffer(
|
35
|
-
gui_set_cursor_pos(
|
37
|
+
$hook.call(:change_buffer, vma.buf)
|
38
|
+
gui_set_current_buffer(vma.buf.id)
|
39
|
+
gui_set_cursor_pos(vma.buf.id, vma.buf.pos)
|
36
40
|
end
|
37
41
|
|
38
42
|
def switch()
|
@@ -58,12 +62,11 @@ class BufferList < Array
|
|
58
62
|
buf_idx = self.index { |b| b.fname == fname }
|
59
63
|
return buf_idx
|
60
64
|
end
|
61
|
-
|
62
|
-
|
65
|
+
|
66
|
+
def get_buffer_by_id(id)
|
63
67
|
buf_idx = self.index { |b| b.id == id }
|
64
68
|
return buf_idx
|
65
69
|
end
|
66
|
-
|
67
70
|
|
68
71
|
def add_current_buf_to_history()
|
69
72
|
@recent_ind = 0
|
@@ -74,11 +77,11 @@ class BufferList < Array
|
|
74
77
|
def set_current_buffer(buffer_i, update_history = true)
|
75
78
|
buffer_i = self.size -1 if buffer_i > self.size
|
76
79
|
buffer_i = 0 if buffer_i < 0
|
77
|
-
|
78
|
-
return if
|
80
|
+
vma.buf = self[buffer_i]
|
81
|
+
return if !vma.buf
|
79
82
|
@current_buf = buffer_i
|
80
83
|
debug "SWITCH BUF2. bufsize:#{self.size}, curbuf: #{@current_buf}"
|
81
|
-
fpath =
|
84
|
+
fpath = vma.buf.fname
|
82
85
|
if fpath and fpath.size > 50
|
83
86
|
fpath = fpath[-50..-1]
|
84
87
|
end
|
@@ -87,31 +90,25 @@ class BufferList < Array
|
|
87
90
|
add_current_buf_to_history
|
88
91
|
end
|
89
92
|
|
90
|
-
$hook.call(:change_buffer,
|
91
|
-
|
93
|
+
$hook.call(:change_buffer, vma.buf)
|
94
|
+
vma.buf.set_active
|
92
95
|
|
93
|
-
gui_set_current_buffer(
|
94
|
-
gui_set_window_title(
|
96
|
+
gui_set_current_buffer(vma.buf.id)
|
97
|
+
gui_set_window_title(vma.buf.title, vma.buf.subtitle)
|
98
|
+
|
99
|
+
if vma.buf.fname
|
100
|
+
@last_dir = File.dirname(vma.buf.fname)
|
101
|
+
end
|
95
102
|
|
96
103
|
# hpt_scan_images() if $debug # experimental
|
97
104
|
end
|
98
105
|
|
106
|
+
def last_dir=(d)
|
107
|
+
@last_dir = d
|
108
|
+
end
|
109
|
+
|
99
110
|
def get_last_dir
|
100
|
-
|
101
|
-
if $buffer.fname
|
102
|
-
lastdir = File.dirname($buffer.fname)
|
103
|
-
else
|
104
|
-
for bufid in $buffer_history.reverse[1..-1]
|
105
|
-
bf = $buffers[bufid]
|
106
|
-
debug "FNAME:#{bf.fname}"
|
107
|
-
if bf.fname
|
108
|
-
lastdir = File.dirname(bf.fname)
|
109
|
-
break
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
lastdir = File.expand_path(".") if lastdir.nil?
|
114
|
-
return lastdir
|
111
|
+
return @last_dir
|
115
112
|
end
|
116
113
|
|
117
114
|
def get_recent_buffers()
|
@@ -145,26 +142,23 @@ class BufferList < Array
|
|
145
142
|
$buffer_history = bh.reverse
|
146
143
|
end
|
147
144
|
|
148
|
-
|
149
145
|
# Close buffer in the background
|
150
146
|
# TODO: if open in another widget
|
151
147
|
def close_other_buffer(buffer_i)
|
152
148
|
return if self.size <= buffer_i
|
153
149
|
return if @current_buf == buffer_i
|
154
|
-
|
150
|
+
|
155
151
|
bufname = self[buffer_i].basename
|
156
152
|
message("Closed buffer #{bufname}")
|
157
153
|
|
158
154
|
self.slice!(buffer_i)
|
159
155
|
$buffer_history = $buffer_history.collect { |x| r = x; r = x - 1 if x > buffer_i; r = nil if x == buffer_i; r }.compact
|
160
|
-
|
161
156
|
end
|
162
157
|
|
163
|
-
|
164
158
|
def close_buffer(buffer_i, from_recent = false)
|
165
159
|
return if buffer_i.nil?
|
166
160
|
return if self.size <= buffer_i
|
167
|
-
|
161
|
+
|
168
162
|
bufname = self[buffer_i].basename
|
169
163
|
message("Closed buffer #{bufname}")
|
170
164
|
recent = get_recent_buffers
|
data/lib/vimamsa/debug.rb
CHANGED
@@ -81,19 +81,19 @@ end
|
|
81
81
|
|
82
82
|
def run_test(test_id)
|
83
83
|
target_results = read_file("", "tests/test_#{test_id}_output.txt")
|
84
|
-
old_buffer =
|
85
|
-
|
84
|
+
old_buffer = vma.buf
|
85
|
+
vma.buf = Buffer.new("", "")
|
86
86
|
load "tests/test_#{test_id}.rb"
|
87
|
-
test_ok =
|
87
|
+
test_ok = vma.buf.to_s.strip == target_results.strip
|
88
88
|
puts "##################"
|
89
89
|
puts target_results
|
90
90
|
puts "##################"
|
91
|
-
puts
|
91
|
+
puts vma.buf.to_s
|
92
92
|
puts "##################"
|
93
93
|
puts "TEST OK" if test_ok
|
94
94
|
puts "TEST FAILED" if !test_ok
|
95
95
|
puts "##################"
|
96
|
-
|
96
|
+
vma.buf = old_buffer
|
97
97
|
end
|
98
98
|
|
99
99
|
#TODO: remove?
|
@@ -121,7 +121,7 @@ def run_random_jump_test__tmpl(test_time = 60 * 60 * 10)
|
|
121
121
|
# puts buf.current_line()
|
122
122
|
# puts "======================"
|
123
123
|
|
124
|
-
render_buffer(
|
124
|
+
render_buffer(vma.buf)
|
125
125
|
|
126
126
|
gui_sleep(rand() / 2)
|
127
127
|
if rand() < (1 / 40.0)
|
@@ -130,9 +130,9 @@ def run_random_jump_test__tmpl(test_time = 60 * 60 * 10)
|
|
130
130
|
|
131
131
|
gui_trigger_event
|
132
132
|
buf.insert_txt("X") if rand() > 0.25
|
133
|
-
render_buffer(
|
133
|
+
render_buffer(vma.buf)
|
134
134
|
|
135
|
-
|
135
|
+
vma.buffers.set_current_buffer(rand(vma.buffers.size)) if rand > 0.25
|
136
136
|
step += 1
|
137
137
|
end
|
138
138
|
end
|
data/lib/vimamsa/editor.rb
CHANGED
@@ -165,11 +165,11 @@ class Editor
|
|
165
165
|
else
|
166
166
|
buffer = Buffer.new(" \n")
|
167
167
|
end
|
168
|
-
|
168
|
+
vma.buffers << buffer
|
169
169
|
|
170
170
|
# load_theme($cnf[:theme])
|
171
171
|
|
172
|
-
# render_buffer(
|
172
|
+
# render_buffer(vma.buf, 1) #TODO
|
173
173
|
|
174
174
|
# gui_select_buffer_init #TODO
|
175
175
|
# gui_file_finder_init #TODO
|
@@ -197,6 +197,10 @@ class Editor
|
|
197
197
|
def buf()
|
198
198
|
return $buffer
|
199
199
|
end
|
200
|
+
def buf=(aa)
|
201
|
+
$buffer=aa
|
202
|
+
end
|
203
|
+
|
200
204
|
|
201
205
|
def buffers()
|
202
206
|
return $buffers
|
@@ -256,7 +260,7 @@ class Editor
|
|
256
260
|
# Register converter
|
257
261
|
def reg_conv(converter, converter_id)
|
258
262
|
@converters[converter_id] = converter
|
259
|
-
reg_act(converter_id, proc {
|
263
|
+
reg_act(converter_id, proc { vma.buf.convert_selected_text(converter_id) }, "Converter #{converter_id}", { :scope => [:selection] })
|
260
264
|
end
|
261
265
|
|
262
266
|
def apply_conv(converter_id, txt)
|
@@ -268,7 +272,7 @@ class Editor
|
|
268
272
|
r = @file_content_search_paths.clone
|
269
273
|
p = find_project_dir_of_cur_buffer()
|
270
274
|
if p.nil?
|
271
|
-
p =
|
275
|
+
p = vma.buffers.last_dir
|
272
276
|
end
|
273
277
|
|
274
278
|
if p and !@file_content_search_paths.include?(p)
|
@@ -303,7 +307,7 @@ end
|
|
303
307
|
|
304
308
|
def open_file_dialog()
|
305
309
|
path = ""
|
306
|
-
path =
|
310
|
+
path = vma.buf.fname if vma.buf.fname
|
307
311
|
gui_open_file_dialog(File.dirname(path))
|
308
312
|
end
|
309
313
|
|
@@ -339,8 +343,8 @@ end
|
|
339
343
|
|
340
344
|
def set_cursor_pos(new_pos)
|
341
345
|
buf.set_pos(new_pos)
|
342
|
-
#render_buffer(
|
343
|
-
debug "New pos: #{new_pos}lpos:#{
|
346
|
+
#render_buffer(vma.buf)
|
347
|
+
debug "New pos: #{new_pos}lpos:#{vma.buf.lpos} cpos:#{vma.buf.cpos}"
|
344
348
|
end
|
345
349
|
|
346
350
|
def set_last_command(cmd)
|
@@ -361,7 +365,7 @@ end
|
|
361
365
|
|
362
366
|
def repeat_last_find()
|
363
367
|
return if !defined? $last_find_command
|
364
|
-
|
368
|
+
vma.buf.jump_to_next_instance_of_char($last_find_command[:char],
|
365
369
|
$last_find_command[:direction])
|
366
370
|
end
|
367
371
|
|
@@ -397,10 +401,10 @@ end
|
|
397
401
|
|
398
402
|
def diff_buffer()
|
399
403
|
bufstr = ""
|
400
|
-
orig_path =
|
404
|
+
orig_path = vma.buf.fname
|
401
405
|
infile = Tempfile.new("out")
|
402
406
|
infile = Tempfile.new("in")
|
403
|
-
infile.write(
|
407
|
+
infile.write(vma.buf.to_s)
|
404
408
|
infile.flush
|
405
409
|
cmd = "diff -w '#{orig_path}' #{infile.path}"
|
406
410
|
# debug cmd
|
@@ -446,7 +450,7 @@ def minibuffer_new_char(c)
|
|
446
450
|
$minibuffer.insert_txt(c)
|
447
451
|
debug "MINIBUFFER: #{c}"
|
448
452
|
end
|
449
|
-
|
453
|
+
#vma.buf = $minibuffer
|
450
454
|
end
|
451
455
|
|
452
456
|
# def readchar_new_char(c)
|
@@ -499,7 +503,8 @@ def create_new_file(filename = nil, file_contents = "\n")
|
|
499
503
|
debug "NEW FILE CREATED"
|
500
504
|
buffer = Buffer.new(file_contents)
|
501
505
|
# gui_set_current_buffer(buffer.id) #TODO: remove?
|
502
|
-
|
506
|
+
vma.buffers << buffer
|
507
|
+
vma.kbd.set_mode_to_default
|
503
508
|
return buffer
|
504
509
|
end
|
505
510
|
|
@@ -517,7 +522,7 @@ end
|
|
517
522
|
|
518
523
|
def load_buffer(fname)
|
519
524
|
return if !File.exist?(fname)
|
520
|
-
existing_buffer =
|
525
|
+
existing_buffer = vma.buffers.get_buffer_by_filename(fname)
|
521
526
|
if existing_buffer != nil
|
522
527
|
$buffer_history << existing_buffer
|
523
528
|
return
|
@@ -529,8 +534,8 @@ def load_buffer(fname)
|
|
529
534
|
debug("DONE LOAD: #{fname}")
|
530
535
|
#buf = filter_buffer(buffer)
|
531
536
|
# debug("END FILTER: #{fname}")
|
532
|
-
|
533
|
-
#$buffer_history <<
|
537
|
+
vma.buffers << buffer
|
538
|
+
#$buffer_history << vma.buffers.size - 1
|
534
539
|
end
|
535
540
|
|
536
541
|
def jump_to_file(filename, linenum = nil, charn = nil)
|
@@ -561,11 +566,11 @@ end
|
|
561
566
|
def open_new_file(filename, file_contents = "")
|
562
567
|
#TODO: expand path
|
563
568
|
filename = File.expand_path(filename)
|
564
|
-
b =
|
569
|
+
b = vma.buffers.get_buffer_by_filename(filename)
|
565
570
|
# File is already opened to existing buffer
|
566
571
|
if b != nil
|
567
572
|
message "Switching to: #{filename}"
|
568
|
-
|
573
|
+
vma.buffers.set_current_buffer(b)
|
569
574
|
else
|
570
575
|
message "New file opened: #{filename}"
|
571
576
|
fname = filename
|
@@ -680,8 +685,8 @@ end
|
|
680
685
|
def find_project_dir_of_cur_buffer()
|
681
686
|
# Find "project dir" of current file. If currently editing file in path "/foo/bar/baz/fn.txt" and file named "/foo/bar/.vma_project" exists, then dir /foo/bar is treated as project dir and subject to e.g. ack search.
|
682
687
|
pdir = nil
|
683
|
-
if
|
684
|
-
pdir = find_project_dir_of_fn(
|
688
|
+
if vma.buf.fname
|
689
|
+
pdir = find_project_dir_of_fn(vma.buf.fname)
|
685
690
|
end
|
686
691
|
# debug "Proj dir of current file: #{pdir}"
|
687
692
|
return pdir
|
data/lib/vimamsa/encrypt.rb
CHANGED
@@ -33,7 +33,7 @@ class Encrypt
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def decrypt_cur_buffer(password, b = nil)
|
36
|
-
|
36
|
+
vma.buf.decrypt(password)
|
37
37
|
end
|
38
38
|
|
39
39
|
def encrypt_cur_buffer()
|
@@ -42,6 +42,6 @@ def encrypt_cur_buffer()
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def encrypt_cur_buffer_callback(password,b=nil)
|
45
|
-
|
45
|
+
vma.buf.set_encrypted(password)
|
46
46
|
end
|
47
47
|
|
data/lib/vimamsa/file_manager.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
class FileManager
|
3
2
|
@@cur
|
4
3
|
|
@@ -28,14 +27,14 @@ class FileManager
|
|
28
27
|
|
29
28
|
# bindkey "C o", :delete_state
|
30
29
|
|
31
|
-
|
30
|
+
vma.kbd.add_minor_mode("fexp", :file_exp, :command)
|
32
31
|
|
33
32
|
bindkey "fexp o m", :fexp_sort_mtime
|
34
33
|
bindkey "fexp o f", :fexp_sort_fname
|
35
34
|
|
36
35
|
# bindkey "fexp l", [:fexp_right, proc { debug "==fexp_right==" }, ""]
|
37
36
|
bindkey "fexp h", :fexp_chdir_parent
|
38
|
-
bindkey "fexp esc", [:fexp_quit, proc {
|
37
|
+
bindkey "fexp esc", [:fexp_quit, proc { FileManager.cur.quit }, ""]
|
39
38
|
bindkey "fexp enter", :fexp_select
|
40
39
|
bindkey "fexp l", :fexp_select
|
41
40
|
|
@@ -66,6 +65,8 @@ class FileManager
|
|
66
65
|
|
67
66
|
def dir_to_buf(dirpath, b = nil)
|
68
67
|
# File.stat("testfile").mtime
|
68
|
+
|
69
|
+
vma.buffers.last_dir = dirpath
|
69
70
|
dirpath = File.expand_path(dirpath)
|
70
71
|
@header = []
|
71
72
|
@header << "#{dirpath}"
|
@@ -92,9 +93,7 @@ class FileManager
|
|
92
93
|
end
|
93
94
|
end
|
94
95
|
|
95
|
-
|
96
|
-
# sort_by = :name
|
97
|
-
# Ripl.start :binding => binding
|
96
|
+
|
98
97
|
@cfiles.sort_by! { |x| x[1].mtime }.reverse! if @sort_by == :mtime
|
99
98
|
@cfiles.sort_by! { |x| x[1].size }.reverse! if @sort_by == :size
|
100
99
|
@cfiles.sort_by! { |x| x[0] } if @sort_by == :name
|
@@ -140,6 +139,9 @@ class FileManager
|
|
140
139
|
else
|
141
140
|
open_with_default_program(fn)
|
142
141
|
end
|
143
|
-
|
142
|
+
end
|
143
|
+
|
144
|
+
def quit
|
145
|
+
@buf.close
|
144
146
|
end
|
145
147
|
end
|
data/lib/vimamsa/gui.rb
CHANGED
@@ -407,7 +407,7 @@ class VMAgui
|
|
407
407
|
$sw2 = sw
|
408
408
|
sw.set_size_request(-1, 12)
|
409
409
|
|
410
|
-
view = VSourceView.new()
|
410
|
+
view = VSourceView.new(nil, nil)
|
411
411
|
view.set_highlight_current_line(false)
|
412
412
|
view.set_show_line_numbers(false)
|
413
413
|
# view.set_buffer(buf1)
|
@@ -515,7 +515,11 @@ class VMAgui
|
|
515
515
|
|
516
516
|
def init_window
|
517
517
|
@window = Gtk::Window.new(:toplevel)
|
518
|
-
@window.
|
518
|
+
sh = @window.screen.height
|
519
|
+
sw = @window.screen.width
|
520
|
+
# TODO:Maximise vertically
|
521
|
+
@window.set_default_size((sw * 0.45).to_i, sh - 20)
|
522
|
+
|
519
523
|
@window.title = "Multiple Views"
|
520
524
|
@window.show_all
|
521
525
|
@vpaned = Gtk::Paned.new(:vertical)
|
@@ -15,7 +15,8 @@ class VSourceView < GtkSource::View
|
|
15
15
|
# end
|
16
16
|
|
17
17
|
|
18
|
-
def initialize(title = nil,bufo=nil)
|
18
|
+
# def initialize(title = nil,bufo=nil)
|
19
|
+
def initialize(title,bufo)
|
19
20
|
# super(:toplevel)
|
20
21
|
@highlight_matching_brackets = true
|
21
22
|
super()
|
@@ -68,7 +69,7 @@ class VSourceView < GtkSource::View
|
|
68
69
|
end
|
69
70
|
|
70
71
|
signal_connect "button-release-event" do |widget, event|
|
71
|
-
|
72
|
+
vma.buf.set_pos(buffer.cursor_position)
|
72
73
|
false
|
73
74
|
end
|
74
75
|
@curpos_mark = nil
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# 'C , r v b'=> 'revert_buffer',
|
16
16
|
#
|
17
17
|
# In insert mode: press and hold ctrl, press "a"
|
18
|
-
# 'I ctrl-a'=> '
|
18
|
+
# 'I ctrl-a'=> 'vma.buf.jump(BEGINNING_OF_LINE)',
|
19
19
|
#
|
20
20
|
|
21
21
|
$cnf = {} # TODO
|
@@ -485,17 +485,17 @@ class KeyBindingTree
|
|
485
485
|
# like '20j' => go to next line 20 times.
|
486
486
|
end
|
487
487
|
rescue SyntaxError
|
488
|
-
|
488
|
+
message("SYNTAX ERROR with eval cmd #{action}: " + $!.to_s)
|
489
489
|
# rescue NoMethodError
|
490
490
|
# debug("NoMethodError with eval cmd #{action}: " + $!.to_s)
|
491
491
|
# rescue NameError
|
492
492
|
# debug("NameError with eval cmd #{action}: " + $!.to_s)
|
493
493
|
# raise
|
494
494
|
rescue Exception => e
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
495
|
+
puts "BACKTRACE"
|
496
|
+
puts e.backtrace
|
497
|
+
puts e.inspect
|
498
|
+
puts "BACKTRACE END"
|
499
499
|
if $!.class == SystemExit
|
500
500
|
exit
|
501
501
|
else
|
data/lib/vimamsa/main.rb
CHANGED
@@ -37,15 +37,15 @@ $experimental = false
|
|
37
37
|
|
38
38
|
# Return currently active buffer
|
39
39
|
def buf()
|
40
|
-
return
|
40
|
+
return vma.buf
|
41
41
|
end
|
42
42
|
|
43
43
|
def bufs()
|
44
|
-
return
|
44
|
+
return vma.buffers
|
45
45
|
end
|
46
46
|
|
47
47
|
def buflist()
|
48
|
-
return
|
48
|
+
return vma.buffers
|
49
49
|
end
|
50
50
|
|
51
51
|
require "vimamsa/editor.rb"
|
data/lib/vimamsa/search.rb
CHANGED
@@ -3,7 +3,7 @@ def execute_search(input_str)
|
|
3
3
|
$search = Search.new
|
4
4
|
eval_str="execute_search(#{input_str.dump})"
|
5
5
|
$macro.overwrite_current_action(eval_str)
|
6
|
-
return $search.set(input_str, "simple",
|
6
|
+
return $search.set(input_str, "simple", vma.buf)
|
7
7
|
end
|
8
8
|
|
9
9
|
def invoke_search()
|
@@ -70,10 +70,10 @@ end
|
|
70
70
|
|
71
71
|
def grep_cur_buffer(search_str, b = nil)
|
72
72
|
debug "grep_cur_buffer(search_str)"
|
73
|
-
lines =
|
73
|
+
lines = vma.buf.split("\n")
|
74
74
|
r = Regexp.new(Regexp.escape(search_str), Regexp::IGNORECASE)
|
75
75
|
fpath = ""
|
76
|
-
fpath =
|
76
|
+
fpath = vma.buf.pathname.expand_path.to_s + ":" if vma.buf.pathname
|
77
77
|
res_str = ""
|
78
78
|
|
79
79
|
$grep_matches = []
|
@@ -84,7 +84,7 @@ def grep_cur_buffer(search_str, b = nil)
|
|
84
84
|
$grep_matches << i + 1 # Lines start from index 1
|
85
85
|
end
|
86
86
|
}
|
87
|
-
$grep_bufid =
|
87
|
+
$grep_bufid = vma.buffers.current_buf
|
88
88
|
b = create_new_file(nil, res_str)
|
89
89
|
# set_current_buffer(buffer_i, update_history = true)
|
90
90
|
# @current_buf = buffer_i
|
@@ -93,7 +93,7 @@ def grep_cur_buffer(search_str, b = nil)
|
|
93
93
|
debug "GREP HANDLER:#{lineno}"
|
94
94
|
jumpto = $grep_matches[lineno]
|
95
95
|
if jumpto.class == Integer
|
96
|
-
|
96
|
+
vma.buffers.set_current_buffer($grep_bufid, update_history = true)
|
97
97
|
buf.jump_to_line(jumpto)
|
98
98
|
end
|
99
99
|
}
|
@@ -136,21 +136,21 @@ def invoke_replace()
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def buf_replace(search_str, replace_str)
|
139
|
-
if
|
140
|
-
r =
|
141
|
-
txt =
|
139
|
+
if vma.buf.visual_mode?
|
140
|
+
r = vma.buf.get_visual_mode_range
|
141
|
+
txt = vma.buf[r]
|
142
142
|
txt.gsub!(search_str, replace_str)
|
143
|
-
|
144
|
-
|
143
|
+
vma.buf.replace_range(r, txt)
|
144
|
+
vma.buf.end_visual_mode
|
145
145
|
else
|
146
|
-
repbuf =
|
146
|
+
repbuf = vma.buf.to_s.clone
|
147
147
|
repbuf.gsub!(search_str, replace_str)
|
148
|
-
tmppos =
|
149
|
-
if repbuf ==
|
148
|
+
tmppos = vma.buf.pos
|
149
|
+
if repbuf == vma.buf.to_s.clone
|
150
150
|
message("NO CHANGE. Replacing #{search_str} with #{replace_str}.")
|
151
151
|
else
|
152
|
-
|
153
|
-
|
152
|
+
vma.buf.set_content(repbuf)
|
153
|
+
vma.buf.set_pos(tmppos)
|
154
154
|
message("Replacing #{search_str} with #{replace_str}.")
|
155
155
|
end
|
156
156
|
end
|
data/lib/vimamsa/version.rb
CHANGED
data/vimamsa.gemspec
CHANGED
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_runtime_dependency 'gdk3', '~> 3.4'
|
31
31
|
spec.add_runtime_dependency 'gtk3', '~> 3.4'
|
32
32
|
spec.add_runtime_dependency 'differ', '~> 0.1'
|
33
|
-
spec.add_runtime_dependency 'gtksourceview3', '~> 3.4'
|
34
|
-
|
33
|
+
# spec.add_runtime_dependency 'gtksourceview3', '~> 3.4'
|
34
|
+
spec.add_runtime_dependency 'gtksourceview4'
|
35
35
|
spec.add_runtime_dependency 'parallel', '~> 1.14'
|
36
36
|
spec.add_runtime_dependency 'listen', '~> 3.4'
|
37
37
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sami Sieranoja
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,19 +123,19 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.1'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: gtksourceview4
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - "
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - "
|
136
|
+
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: parallel
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|