vimamsa 0.1.1 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vma_project +0 -0
- data/README.md +110 -16
- data/exe/vimamsa +30 -22
- data/ext/vmaext/vmaext.c +0 -3
- data/lib/vimamsa.rb +1 -31
- data/lib/vimamsa/ack.rb +0 -4
- data/lib/vimamsa/actions.rb +20 -32
- data/lib/vimamsa/buffer.rb +84 -48
- data/lib/vimamsa/buffer_list.rb +4 -4
- data/lib/vimamsa/debug.rb +6 -6
- data/lib/vimamsa/easy_jump.rb +129 -125
- data/lib/vimamsa/editor.rb +51 -28
- data/lib/vimamsa/file_finder.rb +2 -2
- data/lib/vimamsa/file_history.rb +12 -5
- data/lib/vimamsa/gui.rb +561 -0
- data/lib/vimamsa/gui_gtk_sourceview.rb +294 -0
- data/lib/vimamsa/gui_menu.rb +100 -0
- data/lib/vimamsa/gui_select_window.rb +177 -0
- data/lib/vimamsa/gui_sourceview.rb +294 -0
- data/lib/vimamsa/{default_key_bindings.rb → key_actions.rb} +67 -189
- data/lib/vimamsa/key_binding_tree.rb +21 -9
- data/lib/vimamsa/key_bindings_vimlike.rb +259 -0
- data/lib/vimamsa/macro.rb +1 -1
- data/lib/vimamsa/main.rb +1 -2
- data/lib/vimamsa/rbvma.rb +17 -966
- data/lib/vimamsa/search.rb +0 -4
- data/lib/vimamsa/search_replace.rb +1 -2
- data/lib/vimamsa/util.rb +1 -1
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +4 -2
- metadata +43 -10
- data/ext/vimamsa/extconf.rb +0 -11
- data/ext/vimamsa/vimamsa.c +0 -174
data/lib/vimamsa/search.rb
CHANGED
@@ -115,7 +115,7 @@ def gui_replace_callback(vals)
|
|
115
115
|
search_str = vals["search"]
|
116
116
|
replace_str = vals["replace"]
|
117
117
|
puts "gui_replace_callback: #{search_str} => #{replace_str}"
|
118
|
-
|
118
|
+
gui_select_window_close(0)
|
119
119
|
buf_replace(search_str, replace_str)
|
120
120
|
end
|
121
121
|
|
@@ -152,7 +152,6 @@ def buf_replace(search_str, replace_str)
|
|
152
152
|
else
|
153
153
|
$buffer.set_content(repbuf)
|
154
154
|
$buffer.set_pos(tmppos)
|
155
|
-
# $do_center = 1 #TODO
|
156
155
|
message("Replacing #{search_str} with #{replace_str}.")
|
157
156
|
end
|
158
157
|
end
|
data/lib/vimamsa/util.rb
CHANGED
data/lib/vimamsa/version.rb
CHANGED
data/vimamsa.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["sami.sieranoja@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Vimamsa}
|
13
|
-
spec.description = %q{
|
13
|
+
spec.description = %q{Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby and GTK.}
|
14
14
|
spec.homepage = "https://github.com/SamiSieranoja/vimamsa"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib","ext"]
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
-
spec.add_development_dependency "rake", "~>
|
24
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
25
25
|
|
26
26
|
spec.add_runtime_dependency 'rufo', '~> 0.5'
|
27
27
|
|
@@ -29,9 +29,11 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency 'ripl-multi_line', '~> 0.3.1'
|
30
30
|
spec.add_runtime_dependency 'gdk3', '~> 3.4'
|
31
31
|
spec.add_runtime_dependency 'gtk3', '~> 3.4'
|
32
|
+
spec.add_runtime_dependency 'differ', '~> 0.1'
|
32
33
|
spec.add_runtime_dependency 'gtksourceview3', '~> 3.4'
|
33
34
|
# spec.add_runtime_dependency 'gtksourceview4'
|
34
35
|
spec.add_runtime_dependency 'parallel', '~> 1.14'
|
36
|
+
spec.add_runtime_dependency 'listen', '~> 3.4'
|
35
37
|
|
36
38
|
spec.extensions = ["ext/vmaext/extconf.rb"]
|
37
39
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sami Sieranoja
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rufo
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '3.4'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: differ
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.1'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.1'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: gtksourceview3
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +150,22 @@ dependencies:
|
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '1.14'
|
139
|
-
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: listen
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '3.4'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '3.4'
|
167
|
+
description: Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby
|
168
|
+
and GTK.
|
140
169
|
email:
|
141
170
|
- sami.sieranoja@gmail.com
|
142
171
|
executables:
|
@@ -146,14 +175,13 @@ extensions:
|
|
146
175
|
extra_rdoc_files: []
|
147
176
|
files:
|
148
177
|
- ".gitignore"
|
178
|
+
- ".vma_project"
|
149
179
|
- Gemfile
|
150
180
|
- README.md
|
151
181
|
- Rakefile
|
152
182
|
- bin/console
|
153
183
|
- bin/setup
|
154
184
|
- exe/vimamsa
|
155
|
-
- ext/vimamsa/extconf.rb
|
156
|
-
- ext/vimamsa/vimamsa.c
|
157
185
|
- ext/vmaext/extconf.rb
|
158
186
|
- ext/vmaext/vmaext.c
|
159
187
|
- lang/hyperplaintext.lang
|
@@ -164,16 +192,22 @@ files:
|
|
164
192
|
- lib/vimamsa/buffer_list.rb
|
165
193
|
- lib/vimamsa/constants.rb
|
166
194
|
- lib/vimamsa/debug.rb
|
167
|
-
- lib/vimamsa/default_key_bindings.rb
|
168
195
|
- lib/vimamsa/easy_jump.rb
|
169
196
|
- lib/vimamsa/editor.rb
|
170
197
|
- lib/vimamsa/encrypt.rb
|
171
198
|
- lib/vimamsa/file_finder.rb
|
172
199
|
- lib/vimamsa/file_history.rb
|
173
200
|
- lib/vimamsa/file_manager.rb
|
201
|
+
- lib/vimamsa/gui.rb
|
202
|
+
- lib/vimamsa/gui_gtk_sourceview.rb
|
203
|
+
- lib/vimamsa/gui_menu.rb
|
204
|
+
- lib/vimamsa/gui_select_window.rb
|
205
|
+
- lib/vimamsa/gui_sourceview.rb
|
174
206
|
- lib/vimamsa/hook.rb
|
175
207
|
- lib/vimamsa/hyper_plain_text.rb
|
208
|
+
- lib/vimamsa/key_actions.rb
|
176
209
|
- lib/vimamsa/key_binding_tree.rb
|
210
|
+
- lib/vimamsa/key_bindings_vimlike.rb
|
177
211
|
- lib/vimamsa/macro.rb
|
178
212
|
- lib/vimamsa/main.rb
|
179
213
|
- lib/vimamsa/rbvma.rb
|
@@ -206,8 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
240
|
- !ruby/object:Gem::Version
|
207
241
|
version: '0'
|
208
242
|
requirements: []
|
209
|
-
|
210
|
-
rubygems_version: 2.7.6
|
243
|
+
rubygems_version: 3.1.2
|
211
244
|
signing_key:
|
212
245
|
specification_version: 4
|
213
246
|
summary: Vimamsa
|
data/ext/vimamsa/extconf.rb
DELETED
data/ext/vimamsa/vimamsa.c
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
#include <ruby.h>
|
2
|
-
// #include <gtk/gtk.h>
|
3
|
-
#include "ruby/ruby.h"
|
4
|
-
|
5
|
-
#include <stdio.h>
|
6
|
-
#include <string.h>
|
7
|
-
#include <stdlib.h>
|
8
|
-
|
9
|
-
#warning "C Preprocessor got here!"
|
10
|
-
|
11
|
-
typedef struct node {
|
12
|
-
int i;
|
13
|
-
void * next;
|
14
|
-
} node;
|
15
|
-
|
16
|
-
|
17
|
-
void add_to_list(unsigned char c, int i, struct node ** t) {
|
18
|
-
struct node * n;
|
19
|
-
struct node * np;
|
20
|
-
|
21
|
-
n =(struct node*) calloc(1,sizeof(struct node)); //TODO: free
|
22
|
-
n->i = i;
|
23
|
-
if(!t[c]) {
|
24
|
-
t[c] = n;
|
25
|
-
}
|
26
|
-
else {
|
27
|
-
np = t[c];
|
28
|
-
while (np->next) {
|
29
|
-
np = np->next;
|
30
|
-
}
|
31
|
-
np->next = n;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
void dump_list(struct node**t) {
|
36
|
-
for(int i=0;i < 256; i++) {
|
37
|
-
if(t[i]) {
|
38
|
-
printf ("\n%c: ", (char) i);
|
39
|
-
struct node * n = t[i];
|
40
|
-
do {
|
41
|
-
printf ("%d ", n->i);
|
42
|
-
}
|
43
|
-
while (n = n->next);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
}
|
47
|
-
|
48
|
-
float calc_sub_score(unsigned char* s1, unsigned char* s2, int i1, int i2) {
|
49
|
-
|
50
|
-
int s1_len = strlen(s1);
|
51
|
-
int s2_len = strlen(s2);
|
52
|
-
float sub_score = 1;
|
53
|
-
float score_inc = 1;
|
54
|
-
float score_inc_multip = 0.63212;
|
55
|
-
//float score_inc_multip = 0.23212;
|
56
|
-
|
57
|
-
|
58
|
-
// From i2 to zero
|
59
|
-
int i_s1 = i1-1;
|
60
|
-
//printf("{");
|
61
|
-
for (int i_s2=i2-1; i_s2 >= 0 && i_s1 >= 0;) {
|
62
|
-
if(s1[i_s1] == s2[i_s2]) {
|
63
|
-
//printf("%c",s1[i_s1]);
|
64
|
-
i_s1--; i_s2--;
|
65
|
-
sub_score += score_inc;
|
66
|
-
score_inc = 1;
|
67
|
-
}
|
68
|
-
else {i_s2--; score_inc = score_inc*score_inc_multip;}
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
// From i2 to end
|
73
|
-
score_inc = 1;
|
74
|
-
i_s1 = i1+1;
|
75
|
-
//printf("%c",s1[i1]);
|
76
|
-
for (int i_s2=i2+1; i_s2 < s2_len && i_s1 < s1_len;) {
|
77
|
-
if(s1[i_s1] == s2[i_s2]) {
|
78
|
-
//printf("%c",s1[i_s1]);
|
79
|
-
i_s1++; i_s2++;
|
80
|
-
sub_score += score_inc;
|
81
|
-
score_inc = 1;
|
82
|
-
}
|
83
|
-
else {i_s2++;score_inc = score_inc*score_inc_multip;}
|
84
|
-
}
|
85
|
-
|
86
|
-
|
87
|
-
//printf("}");
|
88
|
-
return sub_score;
|
89
|
-
|
90
|
-
}
|
91
|
-
|
92
|
-
float srn_dst(char * s1_sgn, char * s2_sgn) {
|
93
|
-
unsigned char* s1;
|
94
|
-
unsigned char* s2;
|
95
|
-
s1 = (unsigned char *) s1_sgn;
|
96
|
-
s2 = (unsigned char *) s2_sgn;
|
97
|
-
struct node** t;
|
98
|
-
int len_s1 = strlen(s1);
|
99
|
-
int len_s2 = strlen(s2);
|
100
|
-
t = (struct node**) calloc(256,sizeof(struct node*));
|
101
|
-
float score=0;
|
102
|
-
node * nA;
|
103
|
-
node * nB;
|
104
|
-
//printf("l1,2: %d %d\n",len_s1,len_s2);
|
105
|
-
|
106
|
-
for(int i_s2=0;i_s2 < strlen(s2); i_s2++) {
|
107
|
-
add_to_list(s2[i_s2],i_s2,t);
|
108
|
-
}
|
109
|
-
|
110
|
-
for(int i_s1=0;i_s1 < strlen(s1); i_s1++) {
|
111
|
-
struct node * n = t[s1[i_s1]];
|
112
|
-
if (n) {
|
113
|
-
float max_score = 0;
|
114
|
-
unsigned char c = s1[i_s1];
|
115
|
-
do {
|
116
|
-
float sub_score = calc_sub_score(s1,s2,i_s1,n->i);
|
117
|
-
if(sub_score > max_score) {max_score = sub_score;}
|
118
|
-
//printf(" i=%d %c %d [%f] \n",i_s1,c,n->i,sub_score);
|
119
|
-
} while(n = n->next);
|
120
|
-
score += max_score;
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
//dump_list(t);
|
125
|
-
float p =0.01;
|
126
|
-
score = (1-p)*score/(len_s1*len_s1) +p*score/(len_s1*len_s2);
|
127
|
-
|
128
|
-
// Free memory
|
129
|
-
for(int i=0;i<256;i++) {
|
130
|
-
if(t[i]) {
|
131
|
-
// node * nA = t[i];
|
132
|
-
// node * nB;
|
133
|
-
nA = t[i];
|
134
|
-
do {
|
135
|
-
nB = nA->next;
|
136
|
-
free(nA);
|
137
|
-
nA = nB;
|
138
|
-
} while (nA);
|
139
|
-
}
|
140
|
-
}
|
141
|
-
free(t);
|
142
|
-
|
143
|
-
return score;
|
144
|
-
}
|
145
|
-
|
146
|
-
void srn_dst_wrap(void *y) {
|
147
|
-
void **x = (void **)y;
|
148
|
-
char *a = (char *)x[0];
|
149
|
-
char *b = (char *)x[1];
|
150
|
-
float *d = (float *)x[2];
|
151
|
-
*d = srn_dst(a, b);
|
152
|
-
// printf("00000 A:%s B:%s %f\n",a,b,*d);
|
153
|
-
}
|
154
|
-
|
155
|
-
VALUE _srn_dst(VALUE self, VALUE s1, VALUE s2) {
|
156
|
-
VALUE ret;
|
157
|
-
float d;
|
158
|
-
void **ptr = malloc(sizeof(void *) * 3);
|
159
|
-
ptr[0] = (void *)StringValueCStr(s1);
|
160
|
-
ptr[1] = (void *)StringValueCStr(s2);
|
161
|
-
ptr[2] = (void *)&d;
|
162
|
-
rb_thread_call_without_gvl(srn_dst_wrap, ptr, NULL, NULL);
|
163
|
-
// d = srn_dst(StringValueCStr(s1), StringValueCStr(s2));
|
164
|
-
ret = rb_float_new(d);
|
165
|
-
free(ptr);
|
166
|
-
return ret;
|
167
|
-
}
|
168
|
-
|
169
|
-
void Init_vimamsa(void) {
|
170
|
-
printf("Init_vimamsa\n");
|
171
|
-
rb_define_global_function("srn_dst", _srn_dst, 2);
|
172
|
-
}
|
173
|
-
|
174
|
-
|