vimamsa 0.1.3 → 0.1.4
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/.vma_project +0 -0
- data/README.md +110 -16
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +2 -2
- metadata +7 -8
- data/ext/vimamsa/extconf.rb +0 -11
- data/ext/vimamsa/vimamsa.c +0 -174
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e99c11af9802815672e7b3cc220668fe9a0d6837760ff1cd5ca8b029ca04bc
|
4
|
+
data.tar.gz: b61f32cdaebc0cce856e832567787da9a9d041ed46000463d226959aee492373
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d26574ac402e3f2de520d84db614c26a8760bbbae75fa422dd44d0af2145df2ffcfea8fd8c5f8d45735c0367f36ab85d895660822d7f471a6ba7db2bd5e3513a
|
7
|
+
data.tar.gz: 3e95a3a334284bf3143e67283354c064e23afe2b3332cb5c2f4fc98fe4f80adeee2c4ee39b3759f95b72ff543269e8705d54162e8b04acc5448e41e522360600
|
data/.vma_project
ADDED
File without changes
|
data/README.md
CHANGED
@@ -1,35 +1,129 @@
|
|
1
1
|
# Vimamsa
|
2
2
|
|
3
|
-
|
3
|
+
Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby and GTK.
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
## Requirements
|
7
|
+
- Ruby 2.0+
|
8
|
+
- GTK 3
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
On Ubuntu:
|
14
|
+
```
|
15
|
+
sudo apt install ruby-dev
|
16
|
+
sudo gem install vimamsa
|
13
17
|
```
|
14
18
|
|
15
|
-
|
19
|
+
Run:
|
20
|
+
```
|
21
|
+
vimamsa
|
22
|
+
```
|
16
23
|
|
17
|
-
|
24
|
+
Packages for optional features:
|
25
|
+
```
|
26
|
+
sudo apt install ack-grep clang-format
|
27
|
+
```
|
18
28
|
|
19
|
-
|
29
|
+
For customization, edit dot_vimamsarc.rb and copy to ~/.vimamsarc
|
20
30
|
|
21
|
-
|
31
|
+
## Key bindings
|
22
32
|
|
23
|
-
|
33
|
+
Key bindings are very much like in VIm. For details, see file lib/vimamsa/key_bindings.rb and lib/vimamsa/default_bindings.rb
|
24
34
|
|
25
|
-
|
35
|
+
Keys that work somewhat similarly as in Vim:
|
26
36
|
|
27
|
-
|
37
|
+
In Command mode:
|
38
|
+
```
|
39
|
+
j k l h w b p P G f F ; 0 $ v i o J * / a A I u ctrl-r x
|
40
|
+
zz dd dw gg <linenum>G r<char>
|
41
|
+
```
|
42
|
+
|
43
|
+
In Visual mode:
|
44
|
+
```
|
45
|
+
d y gU gu
|
46
|
+
```
|
28
47
|
|
29
|
-
|
48
|
+
Keys that work differently to Vim are documented in the tables below
|
49
|
+
|
50
|
+
Syntax:
|
51
|
+
ctrl! means press and immediate release of ctrl key. Triggered by key up event.
|
52
|
+
ctrl-x means press and hold ctrl key, press x
|
53
|
+
|
54
|
+
<table>
|
55
|
+
<colgroup>
|
56
|
+
<col style="text-align:center;"/>
|
57
|
+
<col style="text-align:left;"/>
|
58
|
+
</colgroup>
|
59
|
+
|
60
|
+
<thead> <tr> <th style="text-align:center;" colspan="4">Command mode keys</th> </tr> </thead>
|
61
|
+
|
62
|
+
<tbody>
|
63
|
+
<tr><th>Key</th><th>Action</th></tr>
|
64
|
+
<tr><td style="text-align:center;">ctrl!</td> <td style="text-align:left;">switch between command and insert modes</td> </tr>
|
65
|
+
<tr> <td style="text-align:center;">z</td> <td style="text-align:left;"> enter into BROWSE mode</td></tr>
|
66
|
+
<tr> <td style="text-align:center;">shift!</td> <td style="text-align:left;">save file</td> </tr>
|
67
|
+
<tr> <td style="text-align:center;">s</td> <td style="text-align:left;">Easy jump (Similar to Vim EasyMotion https://github.com/easymotion/vim-easymotion ) </td> </tr>
|
68
|
+
<tr> <td style="text-align:center;">tab</td> <td style="text-align:left;">switch betwen current and previous buffer/file</td></tr>
|
69
|
+
<tr> <td style="text-align:center;">enter</td> <td style="text-align:left;"> (when cursor on link) open url in browser </td></tr>
|
70
|
+
<tr> <td style="text-align:center;">enter</td> <td style="text-align:left;">(when cursor on /path/to/file.txt:linenum ) open file in editor, jump to linenum </td></tr>
|
71
|
+
<tr> <td style="text-align:center;">,a</td> <td style="text-align:left;">Search for string using ack
|
72
|
+
</td></tr>
|
73
|
+
<tr> <td style="text-align:center;">,b</td> <td style="text-align:left;"> Switch buffer (jump to other open file)</td></tr>
|
74
|
+
<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;">Fuzzy filename search</td></tr>
|
76
|
+
<tr> <td style="text-align:center;">space c</td> <td style="text-align:left;">insert character "c"</td></tr>
|
77
|
+
</tbody>
|
78
|
+
</table>
|
79
|
+
|
80
|
+
<table>
|
81
|
+
<colgroup>
|
82
|
+
<col style="text-align:center;"/>
|
83
|
+
<col style="text-align:left;"/>
|
84
|
+
</colgroup>
|
85
|
+
|
86
|
+
<thead> <tr> <th style="text-align:center;" colspan="4">Insert mode keys (similar to bash or emacs)</th> </tr> </thead>
|
87
|
+
|
88
|
+
<tbody>
|
89
|
+
<tr> <td style="text-align:center;">ctrl! OR esc</td> <td style="text-align:left;">Switch to command mode</td></tr>
|
90
|
+
<tr> <td style="text-align:center;">ctrl-n</td> <td style="text-align:left;">Move to next line</td></tr>
|
91
|
+
<tr> <td style="text-align:center;">ctrl-p</td> <td style="text-align:left;">Move to previous line</td></tr>
|
92
|
+
<tr> <td style="text-align:center;">ctrl-a</td> <td style="text-align:left;">Move beginning of line</td></tr>
|
93
|
+
<tr> <td style="text-align:center;">ctrl-e</td> <td style="text-align:left;">Move to end of line</td></tr>
|
94
|
+
<tr> <td style="text-align:center;">ctrl-b</td> <td style="text-align:left;">Move backward one char</td></tr>
|
95
|
+
<tr> <td style="text-align:center;">ctrl-f</td> <td style="text-align:left;">Move forward one char</td></tr>
|
96
|
+
<tr> <td style="text-align:center;">alt-f</td> <td style="text-align:left;">Move forward one word</td></tr>
|
97
|
+
<tr> <td style="text-align:center;">alt-b</td> <td style="text-align:left;">Move backward one word</td></tr>
|
98
|
+
</tbody>
|
99
|
+
</table>
|
100
|
+
|
101
|
+
|
102
|
+
<table>
|
103
|
+
<colgroup>
|
104
|
+
<col style="text-align:center;"/>
|
105
|
+
<col style="text-align:left;"/>
|
106
|
+
</colgroup>
|
107
|
+
|
108
|
+
<thead> <tr> <th style="text-align:center;" colspan="4">Browse mode keys</th> </tr> </thead>
|
109
|
+
|
110
|
+
<tbody>
|
111
|
+
<tr> <td style="text-align:center;">h</td> <td style="text-align:left;">jump to previous buffer in history</td></tr>
|
112
|
+
<tr> <td style="text-align:center;">l</td> <td style="text-align:left;">jump to next buffer in history</td></tr>
|
113
|
+
<tr> <td style="text-align:center;">q</td> <td style="text-align:left;">jump to previous edited position</td></tr>
|
114
|
+
<tr> <td style="text-align:center;">w</td> <td style="text-align:left;">jump to next edited position</td></tr>
|
115
|
+
<tr> <td style="text-align:center;">j OR esc</td> <td style="text-align:left;">switch from browse to command mode</td></tr>
|
116
|
+
</tbody>
|
117
|
+
</table>
|
118
|
+
|
119
|
+
Bindings can be customized in ~/.vimamsarc
|
120
|
+
For example, to bind ctrl-n to action "create new file":
|
121
|
+
```
|
122
|
+
bindkey 'C ctrl-n', 'create_new_file()'
|
123
|
+
```
|
30
124
|
|
31
|
-
|
125
|
+
## Current limitations
|
126
|
+
- UTF8 only
|
127
|
+
- Line endings with "\n"
|
32
128
|
|
33
|
-
## Contributing
|
34
129
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vimamsa.
|
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
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sami Sieranoja
|
@@ -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
|
@@ -150,7 +150,8 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '1.14'
|
153
|
-
description:
|
153
|
+
description: Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby
|
154
|
+
and GTK.
|
154
155
|
email:
|
155
156
|
- sami.sieranoja@gmail.com
|
156
157
|
executables:
|
@@ -160,14 +161,13 @@ extensions:
|
|
160
161
|
extra_rdoc_files: []
|
161
162
|
files:
|
162
163
|
- ".gitignore"
|
164
|
+
- ".vma_project"
|
163
165
|
- Gemfile
|
164
166
|
- README.md
|
165
167
|
- Rakefile
|
166
168
|
- bin/console
|
167
169
|
- bin/setup
|
168
170
|
- exe/vimamsa
|
169
|
-
- ext/vimamsa/extconf.rb
|
170
|
-
- ext/vimamsa/vimamsa.c
|
171
171
|
- ext/vmaext/extconf.rb
|
172
172
|
- ext/vmaext/vmaext.c
|
173
173
|
- lang/hyperplaintext.lang
|
@@ -220,8 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
220
|
- !ruby/object:Gem::Version
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
|
-
|
224
|
-
rubygems_version: 2.7.6
|
223
|
+
rubygems_version: 3.1.2
|
225
224
|
signing_key:
|
226
225
|
specification_version: 4
|
227
226
|
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
|
-
|