editor_core 0.2.0 → 0.3.0
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/README.md +5 -1
- data/lib/editor_core/core.rb +34 -14
- data/lib/editor_core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bbf8d36bb4ce04088ab0a8343dffd83be278692e585c0d4e31999a3480d2e3a
|
4
|
+
data.tar.gz: 280aa2304b7495ff16202d2c49de3c72d6b9d509f93fa8d2f1a2ffca2402eecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 796e196320ad8607cce128794403a764d277085461b40c24b4c61177e376816e886d52f8b66ec5b7cf2163ae9eeede6057ef3f36ad14b34af72bb262caebe6e2
|
7
|
+
data.tar.gz: c905cc8eb1acb375947adc5b9d36187c8c6522d489ae97b71ae8a989fd3dfcd7093a0ed1e0759a3c351e6374404d9c0f2bc592ae7774677c3896e27ccc9da1d7
|
data/README.md
CHANGED
@@ -28,7 +28,11 @@ TODO: Write usage instructions here
|
|
28
28
|
|
29
29
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
30
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake
|
32
|
+
install`. To release a new version, update the version number in
|
33
|
+
`version.rb`, and then run `bundle exec rake release`, which will create
|
34
|
+
a git tag for the version, push git commits and tags, and push the `.gem`
|
35
|
+
file to [rubygems.org](https://rubygems.org).
|
32
36
|
|
33
37
|
## Contributing
|
34
38
|
|
data/lib/editor_core/core.rb
CHANGED
@@ -58,7 +58,7 @@ module EditorCore
|
|
58
58
|
|
59
59
|
def page_down
|
60
60
|
lines = view_down(view.height-1)
|
61
|
-
|
61
|
+
#@cursor = cursor.down(buffer, lines)
|
62
62
|
end
|
63
63
|
|
64
64
|
def page_up
|
@@ -70,6 +70,7 @@ module EditorCore
|
|
70
70
|
oldtop = view.top
|
71
71
|
view.top -= offset
|
72
72
|
view.top = 0 if view.top < 0
|
73
|
+
up(offset)
|
73
74
|
oldtop - view.top
|
74
75
|
end
|
75
76
|
|
@@ -79,6 +80,7 @@ module EditorCore
|
|
79
80
|
if view.top > buffer.lines_count
|
80
81
|
view.top = buffer.lines_count
|
81
82
|
end
|
83
|
+
down(offset)
|
82
84
|
view.top - oldtop
|
83
85
|
end
|
84
86
|
|
@@ -91,6 +93,8 @@ module EditorCore
|
|
91
93
|
end
|
92
94
|
|
93
95
|
# ## Complex navigation ##
|
96
|
+
|
97
|
+
# FIXME: Rewrite like prev_word
|
94
98
|
def next_word
|
95
99
|
line = current_line
|
96
100
|
c = cursor.col
|
@@ -115,24 +119,40 @@ module EditorCore
|
|
115
119
|
end
|
116
120
|
|
117
121
|
|
118
|
-
def
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
122
|
+
def beginning_of_file?
|
123
|
+
cursor&.beginning_of_file?
|
124
|
+
end
|
125
|
+
|
126
|
+
def current_char
|
127
|
+
current_line[cursor.col]
|
128
|
+
end
|
129
|
+
|
130
|
+
def left_until_match(r)
|
131
|
+
off = -1
|
132
|
+
loop do
|
133
|
+
left
|
134
|
+
off +=1
|
135
|
+
break if beginning_of_file? || current_char&.match(r)
|
127
136
|
end
|
128
|
-
|
129
|
-
|
137
|
+
off
|
138
|
+
end
|
139
|
+
|
140
|
+
def left_while_match(r)
|
141
|
+
off = 0
|
142
|
+
while !beginning_of_file? && current_char&.match(r)
|
143
|
+
left
|
144
|
+
off +=1
|
130
145
|
end
|
131
|
-
|
132
|
-
|
146
|
+
# Because we'll advance once too far left
|
147
|
+
right if !current_char&.match(r)
|
133
148
|
off
|
134
149
|
end
|
135
150
|
|
151
|
+
def prev_word
|
152
|
+
word = /[A-Za-z]/
|
153
|
+
left_until_match(word) + left_while_match(word)
|
154
|
+
end
|
155
|
+
|
136
156
|
# ## Mutation ##
|
137
157
|
|
138
158
|
def delete_before
|
data/lib/editor_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: editor_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vidar Hokstad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|