pryline 0.0.5 → 0.0.6
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/lib/pryline.rb +104 -6
- data/lib/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76de10badae29d39145da9e24ac05d879ebd6c37b96f12f3c2e1b54cfa7c7277
|
4
|
+
data.tar.gz: ee668e5a3cb247047b065ce25424506baddc8ff299b1e568f95e81bce76499db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0e79e8e8749165cf63c7b32e913571160a1f5b5a807d9089b6d38a2b9573b260a3d1582fec404c1c45faf09747c192fa2bcac3687c160ccd09cdd16dbf87c3
|
7
|
+
data.tar.gz: 75708cf6fed8e892ecb2d5f1c6817b3eb4f7b496bfd79e3e84d19fac4ad268e70a6dee446273574e4338bc40e241b4c477a7f80c529a2dee2d52f8fcc47e7492
|
data/lib/pryline.rb
CHANGED
@@ -122,6 +122,31 @@ module Pryline
|
|
122
122
|
where_history.call(nil)
|
123
123
|
end
|
124
124
|
|
125
|
+
# set mark
|
126
|
+
set_mark = Fiddle::Function.new(
|
127
|
+
libreadline['_rl_set_mark_at_pos'],
|
128
|
+
[Fiddle::TYPE_INT], Fiddle::TYPE_INT
|
129
|
+
)
|
130
|
+
Pryline.define_singleton_method(:set_mark) do |pos|
|
131
|
+
set_mark.call(pos)
|
132
|
+
end
|
133
|
+
|
134
|
+
# activate mark
|
135
|
+
activate_mark = Fiddle::Function.new(
|
136
|
+
libreadline['rl_activate_mark'],
|
137
|
+
[Fiddle::TYPE_VOID],
|
138
|
+
Fiddle::TYPE_INT
|
139
|
+
)
|
140
|
+
Pryline.define_singleton_method(:activate_mark) { activate_mark.call(nil) }
|
141
|
+
|
142
|
+
# deactivate mark
|
143
|
+
deactivate_mark = Fiddle::Function.new(
|
144
|
+
libreadline['rl_deactivate_mark'],
|
145
|
+
[Fiddle::TYPE_VOID],
|
146
|
+
Fiddle::TYPE_INT
|
147
|
+
)
|
148
|
+
Pryline.define_singleton_method(:deactivate_mark) { deactivate_mark.call(nil) }
|
149
|
+
|
125
150
|
# null function
|
126
151
|
null_function = Fiddle::Function.new(
|
127
152
|
libreadline['_rl_null_function'],
|
@@ -150,8 +175,8 @@ module Pryline
|
|
150
175
|
Pryline.define_singleton_method(:bind_key) do |key, &block|
|
151
176
|
unbind_key.call(key.ord)
|
152
177
|
BLOCK_CALLERS[key] = Fiddle::Closure::BlockCaller.new(
|
153
|
-
Fiddle::
|
154
|
-
[Fiddle::
|
178
|
+
Fiddle::TYPE_INT,
|
179
|
+
[Fiddle::TYPE_INT, Fiddle::TYPE_INT],
|
155
180
|
&block
|
156
181
|
)
|
157
182
|
bind_key.call(
|
@@ -176,8 +201,8 @@ module Pryline
|
|
176
201
|
Pryline.define_singleton_method(:bind_keyseq) do |keyseq, &block|
|
177
202
|
unbind_keyseq(keyseq)
|
178
203
|
BLOCK_CALLERS[keyseq] = Fiddle::Closure::BlockCaller.new(
|
179
|
-
Fiddle::
|
180
|
-
[Fiddle::
|
204
|
+
Fiddle::TYPE_INT,
|
205
|
+
[Fiddle::TYPE_INT, Fiddle::TYPE_INT],
|
181
206
|
&block
|
182
207
|
)
|
183
208
|
bind_keyseq.call(
|
@@ -193,7 +218,7 @@ module Pryline
|
|
193
218
|
save_prompt.call(nil)
|
194
219
|
end
|
195
220
|
set_message = Fiddle::Function.new(libreadline['rl_message'], [Fiddle::TYPE_UINTPTR_T], Fiddle::TYPE_INT)
|
196
|
-
Pryline.define_singleton_method(:
|
221
|
+
Pryline.define_singleton_method(:set_message_with_save) do |message|
|
197
222
|
buffer, point = Pryline.line_buffer, Pryline.point
|
198
223
|
Pryline.delete_text
|
199
224
|
Pryline.point = 0
|
@@ -205,16 +230,30 @@ module Pryline
|
|
205
230
|
Fiddle::Pointer[message]
|
206
231
|
)
|
207
232
|
end
|
233
|
+
Pryline.define_singleton_method(:set_message) do |message|
|
234
|
+
buffer, point = Pryline.line_buffer, Pryline.point
|
235
|
+
Pryline.delete_text
|
236
|
+
Pryline.point = 0
|
237
|
+
Pryline.redisplay
|
238
|
+
Pryline.insert_text buffer
|
239
|
+
Pryline.point = point
|
240
|
+
set_message.call(
|
241
|
+
Fiddle::Pointer[message]
|
242
|
+
)
|
243
|
+
end
|
208
244
|
|
209
245
|
restore_prompt = Fiddle::Function.new(libreadline['rl_restore_prompt'], [Fiddle::TYPE_VOID], Fiddle::TYPE_INT)
|
210
246
|
Pryline.define_singleton_method(:restore_prompt) do
|
211
247
|
restore_prompt.call(nil)
|
212
248
|
end
|
213
249
|
clear_message = Fiddle::Function.new(libreadline['rl_clear_message'], [Fiddle::TYPE_VOID], Fiddle::TYPE_INT)
|
214
|
-
Pryline.define_singleton_method(:
|
250
|
+
Pryline.define_singleton_method(:clear_message_with_restore) do
|
215
251
|
Pryline.restore_prompt
|
216
252
|
clear_message.call(nil)
|
217
253
|
end
|
254
|
+
Pryline.define_singleton_method(:clear_message) do
|
255
|
+
clear_message.call(nil)
|
256
|
+
end
|
218
257
|
|
219
258
|
move_vert = Fiddle::Function.new(libreadline['_rl_move_vert'], [Fiddle::TYPE_INT], Fiddle::TYPE_VOID)
|
220
259
|
Pryline.define_singleton_method(:move_vert) do |dest|
|
@@ -250,6 +289,65 @@ module Pryline
|
|
250
289
|
ApplicationName.rl_readline_name = Fiddle::Pointer[name]
|
251
290
|
end
|
252
291
|
|
292
|
+
Pryline.define_singleton_method(:slice_buffer_at_cursor) do
|
293
|
+
left_of_cursor = Pryline.line_buffer[0...Pryline.point]
|
294
|
+
right_of_cursor = Pryline.line_buffer[(Pryline.point)..-1] || ''
|
295
|
+
Pryline.delete_text
|
296
|
+
Pryline.point = 0
|
297
|
+
Pryline.redisplay
|
298
|
+
[left_of_cursor, right_of_cursor]
|
299
|
+
end
|
300
|
+
|
301
|
+
Pryline.define_singleton_method(:reformat_buffer) do
|
302
|
+
left_of_cursor, right_of_cursor = Pryline.slice_buffer_at_cursor
|
303
|
+
left_ended_with_newline = left_of_cursor.end_with?("\n")
|
304
|
+
left_ended_with_whitespace = left_of_cursor.match?(/\s+\z/) && !left_ended_with_newline
|
305
|
+
left = left_of_cursor.lines.map(&:strip).join("\n")
|
306
|
+
left = "#{left}\n" if left_ended_with_newline
|
307
|
+
left = "#{left} " if left_ended_with_whitespace
|
308
|
+
indent = Pry::Indent.new
|
309
|
+
left = indent.indent(left)
|
310
|
+
Pryline.insert_text(left)
|
311
|
+
if right_of_cursor.strip != ''
|
312
|
+
point = Pryline.point
|
313
|
+
Pryline.delete_text
|
314
|
+
Pryline.point = 0
|
315
|
+
new_buffer = Pry::Indent.new.indent("#{left}#{right_of_cursor}")
|
316
|
+
Pryline.insert_text(new_buffer)
|
317
|
+
Pryline.point = point
|
318
|
+
Pryline.redisplay
|
319
|
+
elsif left_ended_with_newline
|
320
|
+
Pryline.insert_text indent.current_prefix
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
# reset line state
|
325
|
+
reset_line_state = Fiddle::Function.new(libreadline['rl_reset_line_state'], [Fiddle::TYPE_VOID], Fiddle::TYPE_INT)
|
326
|
+
Pryline.define_singleton_method(:reset_line_state) do
|
327
|
+
reset_line_state.call(nil)
|
328
|
+
end
|
329
|
+
|
330
|
+
# DICEY!!
|
331
|
+
# add descriptive function name, so as to make
|
332
|
+
# it bindable from inputrc
|
333
|
+
add_defun = Fiddle::Function.new(
|
334
|
+
libreadline['rl_add_defun'],
|
335
|
+
[Fiddle::TYPE_UINTPTR_T, Fiddle::TYPE_UINTPTR_T, Fiddle::TYPE_INT],
|
336
|
+
Fiddle::TYPE_INT
|
337
|
+
)
|
338
|
+
Pryline.define_singleton_method(:add_defun) do |name, key = -1, &block|
|
339
|
+
BLOCK_CALLERS[name] = Fiddle::Closure::BlockCaller.new(
|
340
|
+
Fiddle::TYPE_VOID,
|
341
|
+
[Fiddle::TYPE_VOID],
|
342
|
+
&block
|
343
|
+
)
|
344
|
+
add_defun.call(
|
345
|
+
Fiddle::Pointer[name],
|
346
|
+
BLOCK_CALLERS[name].to_i,
|
347
|
+
key
|
348
|
+
)
|
349
|
+
end
|
350
|
+
|
253
351
|
# helpers
|
254
352
|
Pryline.define_singleton_method(:replace_buffer) do |new_contents|
|
255
353
|
Pryline.delete_text
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pryline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Adds rl_bind_key, rl_bind_keyseq, rl_newline, rl_unbind_key, rl_unbind_keyseq.
|
14
14
|
email: bcgraham+github@gmail.com
|
@@ -30,7 +30,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.7.0
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
requirements:
|
40
40
|
- Readline 8.1
|
41
|
-
rubygems_version: 3.
|
41
|
+
rubygems_version: 3.5.3
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Extend Readline interface to more functions.
|