vimamsa 0.1.9 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -7
- data/custom_example.rb +12 -2
- data/demo.txt +2 -2
- data/exe/vimamsa +1 -1
- data/lib/vimamsa/ack.rb +57 -46
- data/lib/vimamsa/actions.rb +1 -1
- data/lib/vimamsa/buffer.rb +287 -55
- data/lib/vimamsa/buffer_list.rb +83 -48
- data/lib/vimamsa/buffer_manager.rb +19 -3
- data/lib/vimamsa/conf.rb +10 -1
- data/lib/vimamsa/debug.rb +15 -11
- data/lib/vimamsa/easy_jump.rb +9 -5
- data/lib/vimamsa/editor.rb +73 -54
- data/lib/vimamsa/encrypt.rb +2 -2
- data/lib/vimamsa/file_finder.rb +70 -72
- data/lib/vimamsa/file_history.rb +2 -3
- data/lib/vimamsa/file_manager.rb +10 -8
- data/lib/vimamsa/form_generator.rb +122 -0
- data/lib/vimamsa/gui.rb +469 -118
- data/lib/vimamsa/gui_image.rb +12 -6
- data/lib/vimamsa/gui_menu.rb +26 -21
- data/lib/vimamsa/gui_select_window.rb +40 -21
- data/lib/vimamsa/gui_sourceview.rb +173 -79
- data/lib/vimamsa/hyper_plain_text.rb +36 -3
- data/lib/vimamsa/key_actions.rb +13 -1
- data/lib/vimamsa/key_binding_tree.rb +32 -20
- data/lib/vimamsa/key_bindings_vimlike.rb +54 -25
- data/lib/vimamsa/langservp.rb +172 -0
- data/lib/vimamsa/macro.rb +9 -8
- data/lib/vimamsa/main.rb +3 -4
- data/lib/vimamsa/rbvma.rb +7 -4
- data/lib/vimamsa/search.rb +3 -2
- data/lib/vimamsa/search_replace.rb +50 -120
- data/lib/vimamsa/text_transforms.rb +1 -1
- data/lib/vimamsa/util.rb +47 -1
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +1 -6
- data/styles/molokai_edit.xml +3 -0
- data/vimamsa.gemspec +10 -10
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97397b2b0eb7e2d07c23e67d4c9cebeec0df6925f43a70b2d42ad87d2f5383fb
|
4
|
+
data.tar.gz: fe0040694d69b1b860d942fb7cf3bea5fc671ba482b72a991f4d8f6d0031524c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749aa7833a6db40dc85620884f2e7be97c3d54b4e681f96255f54aa1a76148d80640f78e194f3b688e80f770c4afedbba9c096ac58a56da455102fc2ece4bcec
|
7
|
+
data.tar.gz: 74df362a22e70517ababecf5a61d29cc5655147f3c163764d264febfb83fa8b65182cb0f2cfc92e26e157ed3e2618c03c53f06c0d73ba5c06a18a4aa4b162201
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby and GTK
|
|
5
5
|
|
6
6
|
## Requirements
|
7
7
|
- Ruby 2.0+
|
8
|
-
- GTK
|
8
|
+
- GTK 4
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -16,21 +16,43 @@ sudo apt install ruby-dev
|
|
16
16
|
sudo gem install vimamsa
|
17
17
|
```
|
18
18
|
|
19
|
-
|
19
|
+
### Other install options
|
20
|
+
|
21
|
+
Install from sources:
|
22
|
+
|
23
|
+
```
|
24
|
+
git clone https://github.com/SamiSieranoja/vimamsa.git
|
25
|
+
cd vimamsa
|
26
|
+
gem build vimamsa.gemspec
|
27
|
+
sudo gem install --local vimamsa-0.1.*.gem
|
28
|
+
|
29
|
+
```
|
30
|
+
|
31
|
+
Older version for GTK3:
|
32
|
+
|
33
|
+
sudo gem install vimamsa -v 0.1.10
|
34
|
+
|
35
|
+
## Run
|
20
36
|
```
|
21
37
|
vimamsa
|
22
38
|
```
|
23
39
|
|
24
|
-
|
40
|
+
Install packages for optional features:
|
25
41
|
```
|
26
42
|
sudo apt install ack-grep clang-format
|
43
|
+
gem install ripl ripl-multi_line differ parallel listen rufo language_server-protocol
|
27
44
|
```
|
28
45
|
|
29
|
-
For customization, edit
|
46
|
+
For customization, edit ~/.vimamsa/custom.rb
|
47
|
+
|
48
|
+
## Screenshots
|
49
|
+
|
50
|
+
<a href="https://samiddhi.net/vimamsa/screenshot1.png" target="_blank"><img src="https://samiddhi.net/vimamsa/screenshot1.png" width="400"/></a>
|
51
|
+
<a href="https://samiddhi.net/vimamsa/screenshot2.png" target="_blank"><img src="https://samiddhi.net/vimamsa/screenshot2.png" width="400"/></a>
|
30
52
|
|
31
53
|
## Key bindings
|
32
54
|
|
33
|
-
Key bindings are very much like in VIm. For details, see file lib/vimamsa/key_bindings.rb and lib/vimamsa/
|
55
|
+
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
56
|
|
35
57
|
Keys that work somewhat similarly as in Vim:
|
36
58
|
|
@@ -72,7 +94,7 @@ ctrl-x means press and hold ctrl key, press x
|
|
72
94
|
</td></tr>
|
73
95
|
<tr> <td style="text-align:center;">,b</td> <td style="text-align:left;"> Switch buffer (jump to other open file)</td></tr>
|
74
96
|
<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;">
|
97
|
+
<tr> <td style="text-align:center;">,f</td> <td style="text-align:left;">File finder</td></tr>
|
76
98
|
<tr> <td style="text-align:center;">space c</td> <td style="text-align:left;">insert character "c"</td></tr>
|
77
99
|
</tbody>
|
78
100
|
</table>
|
@@ -116,7 +138,7 @@ ctrl-x means press and hold ctrl key, press x
|
|
116
138
|
</tbody>
|
117
139
|
</table>
|
118
140
|
|
119
|
-
Bindings can be customized in ~/.
|
141
|
+
Bindings can be customized in ~/.vimamsa/custom.rb
|
120
142
|
For example, to bind ctrl-n to action "create new file":
|
121
143
|
```
|
122
144
|
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")
|
@@ -23,9 +23,18 @@ end
|
|
23
23
|
def collect_c_header()
|
24
24
|
# Matches e.g.:
|
25
25
|
# static void funcname(parameters)
|
26
|
-
s = buf.scan(/^(
|
26
|
+
s = buf.scan(/^(
|
27
|
+
([\w\*\:&]+\s*){1,3}
|
28
|
+
[\*?\w\:&]+
|
29
|
+
\(
|
30
|
+
([^\)]|\n)*?
|
31
|
+
\)
|
32
|
+
)
|
33
|
+
/x
|
34
|
+
).collect { |x| x[0] + ";" }.join("\n")
|
27
35
|
buf.insert_txt(s)
|
28
36
|
end
|
37
|
+
|
29
38
|
reg_act(:collect_c_header, proc { collect_c_header }, "Collect function definitions for c header file")
|
30
39
|
|
31
40
|
# Extract all numbers from txt selection
|
@@ -38,6 +47,7 @@ def insert_lorem_ipsum()
|
|
38
47
|
|
39
48
|
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."
|
40
49
|
|
50
|
+
# Insert to current position
|
41
51
|
vma.buf.insert_txt(lorem_ipsum)
|
42
52
|
end
|
43
53
|
|
data/demo.txt
CHANGED
data/exe/vimamsa
CHANGED
@@ -5,12 +5,12 @@ require "tempfile"
|
|
5
5
|
require "pathname"
|
6
6
|
|
7
7
|
ENV["GTK_THEME"] = "Adwaita:dark"
|
8
|
+
# ENV["GTK_THEME"] = "Adwaita:light"
|
8
9
|
|
9
10
|
selfpath = __FILE__
|
10
11
|
selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
|
11
12
|
scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
|
12
13
|
|
13
|
-
|
14
14
|
# If process is already running, open the parameter file in the running process and exit.
|
15
15
|
listen_dir = File.expand_path("~/.vimamsa/listen")
|
16
16
|
if File.exist?(listen_dir) and !ARGV[0].nil?
|
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
|
-
nfo = "<
|
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.
|
@@ -17,67 +13,82 @@ Will search the following directories:
|
|
17
13
|
</span>"
|
18
14
|
|
19
15
|
callback = proc { |x| FileContentSearch.search_buffer(x) }
|
20
|
-
gui_one_input_action(nfo, "Search:", "search", callback)
|
16
|
+
# gui_one_input_action(nfo, "Search:", "search", callback)
|
17
|
+
|
18
|
+
params = {}
|
19
|
+
params["inputs"] = {}
|
20
|
+
params["inputs"]["search"] = { :label => "Search:", :type => :entry }
|
21
|
+
params["inputs"]["extensions"] = { :label => "Limit to file extensions:", :type => :entry }
|
22
|
+
params["inputs"]["extensions"][:initial_text] = conf(:default_search_extensions).join(",")
|
23
|
+
params["inputs"]["btn1"] = { :label => "Search", :type => :button }
|
24
|
+
# callback = proc { |x| gui_replace_callback(x) }
|
25
|
+
|
26
|
+
params[:callback] = callback
|
27
|
+
PopupFormGenerator.new(params).run
|
21
28
|
end
|
22
29
|
|
23
|
-
def self.search_buffer(
|
30
|
+
def self.search_buffer(formdata, b = nil)
|
24
31
|
# instr = Shellwords.escape(instr)
|
32
|
+
|
25
33
|
fext = Set[".txt"]
|
34
|
+
# Include only word characters and dot
|
35
|
+
extstmp = formdata["extensions"].split(",").collect { |x| "." + x.gsub(/[^\w\.]/, "") }
|
36
|
+
fext = extstmp.to_set
|
37
|
+
if fext.empty?
|
38
|
+
return
|
39
|
+
end
|
40
|
+
instr = formdata["search"]
|
41
|
+
|
26
42
|
dlist = []
|
27
43
|
for d in vma.get_content_search_paths
|
44
|
+
# Search for files with extension .txt and size < 200k
|
28
45
|
dlist = dlist + Dir.glob("#{d}/**/*").select { |e| File.file?(e) and fext.include?(File.extname(e)) and File.size(e) < 200e3 }
|
29
46
|
end
|
30
47
|
bufstr = "Results:\n\n"
|
48
|
+
b = create_new_buffer(bufstr,"contentsearch")
|
49
|
+
lno = 1
|
50
|
+
@linep = {}
|
31
51
|
for fp in dlist
|
32
|
-
txt = read_file("",fp)
|
52
|
+
txt = read_file("", fp)
|
33
53
|
ind = scan_indexes(txt, /#{instr}/i)
|
34
54
|
if !ind.empty?
|
35
|
-
|
36
|
-
#
|
55
|
+
# bufstr << "#{fp}\n"
|
56
|
+
# buf.insert_txt("#{fp}\n", AFTER)
|
57
|
+
b.append("#{fp}\n")
|
58
|
+
lno += 1
|
37
59
|
|
60
|
+
for x in ind
|
38
61
|
starti = x - 30
|
39
62
|
endi = x + 30
|
40
63
|
starti = 0 if starti < 0
|
41
64
|
endi = txt.size - 1 if endi >= txt.size
|
42
|
-
|
43
|
-
|
44
|
-
|
65
|
+
b.append " "
|
66
|
+
b.append txt[starti..endi].gsub("\n", " ")
|
67
|
+
b.append "\n"
|
68
|
+
@linep[lno] = { :fname => fp, :ind => x }
|
69
|
+
lno += 1
|
45
70
|
end
|
46
71
|
end
|
47
72
|
end
|
48
|
-
create_new_file(nil, bufstr)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def gui_ack()
|
53
|
-
search_paths = vma.get_content_search_paths.join("<br/>")
|
54
|
-
|
55
|
-
nfo = "<html><h2>Search contents of all files using ack</h2>
|
56
|
-
<div style='width:300px'>
|
57
|
-
<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>"
|
58
73
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
gui_one_input_action(nfo, "Search:", "search", callback)
|
69
|
-
end
|
74
|
+
b.line_action_handler = proc { |lineno|
|
75
|
+
puts "SEARCH HANDLER:#{lineno}"
|
76
|
+
puts @linep[lineno]
|
77
|
+
lp = @linep[lineno]
|
78
|
+
if !lp.nil?
|
79
|
+
if lp.has_key?(:ind) and lp.has_key?(:fname)
|
80
|
+
jump_to_file(lp[:fname], lp[:ind], "c")
|
81
|
+
end
|
82
|
+
end
|
70
83
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
create_new_file(nil, bufstr)
|
79
|
-
else
|
80
|
-
message("No results for input:#{instr}")
|
84
|
+
# jumpto = $grep_matches[lineno]
|
85
|
+
# if jumpto.class == Integer
|
86
|
+
# vma.buffers.set_current_buffer($grep_bufid, update_history = true)
|
87
|
+
# buf.jump_to_line(jumpto)
|
88
|
+
# end
|
89
|
+
}
|
90
|
+
# buf.insert_txt("\n")
|
91
|
+
# create_new_file(nil, bufstr)
|
81
92
|
end
|
82
93
|
end
|
83
94
|
|
@@ -107,7 +118,7 @@ def ack_buffer(instr, b = nil)
|
|
107
118
|
bufstr += run_cmd("ack -Q --type-add=gd=.gd -ki --nohtml --nojs --nojson #{instr} #{path}")
|
108
119
|
end
|
109
120
|
if bufstr.size > 5
|
110
|
-
|
121
|
+
create_new_buffer(bufstr,"ack")
|
111
122
|
else
|
112
123
|
message("No results for input:#{instr}")
|
113
124
|
end
|
data/lib/vimamsa/actions.rb
CHANGED
@@ -49,6 +49,7 @@ def search_actions()
|
|
49
49
|
l = []
|
50
50
|
opt = { :title => "Search actions.", :desc => "Fuzzy search for actions. <up> or <down> to change selcted. <enter> to select current." }
|
51
51
|
$select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
52
|
+
|
52
53
|
gui_select_update_window(l, $select_keys.collect { |x| x.upcase },
|
53
54
|
"search_actions_select_callback",
|
54
55
|
"search_actions_update_callback",
|
@@ -74,7 +75,6 @@ def search_actions_update_callback(search_str = "")
|
|
74
75
|
end
|
75
76
|
end
|
76
77
|
# c_kbd = vma.kbd.act_bindings[mode_str][nfo[:action]]
|
77
|
-
# Ripl.start :binding => binding
|
78
78
|
item[:action] = act_id
|
79
79
|
item[:str] = act_id.to_s
|
80
80
|
if $actions[act_id].method_name != ""
|