rcurses 3.7.1 → 3.7.3
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/rcurses/input.rb +109 -97
- data/lib/rcurses/pane.rb +16 -6
- data/lib/rcurses.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: d300db2c5840595d0716539687b0c5d6de38d0d60543373f49edf3bd19b953dd
|
4
|
+
data.tar.gz: 5eed2e21c1912e456640cf54516ffcadece0d7bac70862fd63965299a97c60f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29eac670b3bd278d0b4f3a76ca892278510a94243318ca7f5aa29b05a95b336ec5b4911763c198b73b1028114525d438d7f9da9f323315ef337a8258ba206ebc
|
7
|
+
data.tar.gz: 32dd6bcad30a491872f7e6880e811a6326b5df317bff395e6e6d431d976ebeb252521eb093c5dc7959d6d5303e7c056f39e4f335198888a8cf2533a345a27e7f
|
data/lib/rcurses/input.rb
CHANGED
@@ -1,114 +1,126 @@
|
|
1
1
|
module Rcurses
|
2
2
|
module Input
|
3
|
-
def getchr(t = nil)
|
4
|
-
# 1) Read a byte (with optional timeout)
|
3
|
+
def getchr(t = nil, flush: true)
|
5
4
|
begin
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
# 1) Read a byte (with optional timeout)
|
6
|
+
begin
|
7
|
+
c = t ? Timeout.timeout(t) { $stdin.getch } : $stdin.getch
|
8
|
+
rescue Timeout::Error
|
9
|
+
return nil
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
# 2) If it's ESC, grab any quick trailing bytes
|
13
|
+
seq = c
|
14
|
+
if c == "\e"
|
15
|
+
if IO.select([$stdin], nil, nil, 0.05)
|
16
|
+
begin
|
17
|
+
seq << $stdin.read_nonblock(16)
|
18
|
+
rescue IO::WaitReadable, EOFError
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
|
-
end
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
# 3) Single ESC alone
|
24
|
+
return "ESC" if seq == "\e"
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
# 4) ShiftâTAB
|
27
|
+
return "S-TAB" if seq == "\e[Z"
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
# 5) Legacy singleâchar shiftâarrows (your old working ones)
|
30
|
+
case seq
|
31
|
+
when "\e[a" then return "S-UP"
|
32
|
+
when "\e[b" then return "S-DOWN"
|
33
|
+
when "\e[c" then return "S-RIGHT"
|
34
|
+
when "\e[d" then return "S-LEFT"
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
# 6) CSI style shiftâarrows (e.g. ESC [1;2A )
|
38
|
+
if m = seq.match(/\A\e\[\d+;2([ABCD])\z/)
|
39
|
+
return { 'A' => "S-UP", 'B' => "S-DOWN", 'C' => "S-RIGHT", 'D' => "S-LEFT" }[m[1]]
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
# 7) Plain arrows
|
43
|
+
if m = seq.match(/\A\e\[([ABCD])\z/)
|
44
|
+
return { 'A' => "UP", 'B' => "DOWN", 'C' => "RIGHT", 'D' => "LEFT" }[m[1]]
|
45
|
+
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
47
|
+
# 8) CSI + '~' sequences (Ins, Del, Home, End, PgUp, PgDn, F5-F12)
|
48
|
+
if seq.start_with?("\e[") && seq.end_with?("~")
|
49
|
+
num = seq[/\d+(?=~)/].to_i
|
50
|
+
return case num
|
51
|
+
when 1, 7 then "HOME"
|
52
|
+
when 2 then "INS"
|
53
|
+
when 3 then "DEL"
|
54
|
+
when 4, 8 then "END"
|
55
|
+
when 5 then "PgUP"
|
56
|
+
when 6 then "PgDOWN"
|
57
|
+
when 15 then "F5"
|
58
|
+
when 17 then "F6"
|
59
|
+
when 18 then "F7"
|
60
|
+
when 19 then "F8"
|
61
|
+
when 20 then "F9"
|
62
|
+
when 21 then "F10"
|
63
|
+
when 23 then "F11"
|
64
|
+
when 24 then "F12"
|
65
|
+
else ""
|
66
|
+
end
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
# 9) SS3 function keys F1-F4
|
70
|
+
if seq.start_with?("\eO") && seq.length == 3
|
71
|
+
return case seq[2]
|
72
|
+
when 'P' then "F1"
|
73
|
+
when 'Q' then "F2"
|
74
|
+
when 'R' then "F3"
|
75
|
+
when 'S' then "F4"
|
76
|
+
else ""
|
77
|
+
end
|
78
|
+
end
|
78
79
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
80
|
+
# 10) Single / Ctrl-char mappings
|
81
|
+
return case seq
|
82
|
+
when "\r", "\n" then "ENTER"
|
83
|
+
when "\t" then "TAB"
|
84
|
+
when "\u007F", "\b" then "BACK"
|
85
|
+
when "\u0000" then "C-SPACE"
|
86
|
+
when "\u0001" then "C-A"
|
87
|
+
when "\u0002" then "C-B"
|
88
|
+
when "\u0003" then "C-C"
|
89
|
+
when "\u0004" then "C-D"
|
90
|
+
when "\u0005" then "C-E"
|
91
|
+
when "\u0006" then "C-F"
|
92
|
+
when "\u0007" then "C-G"
|
93
|
+
when "\u0008" then "C-H"
|
94
|
+
when "\u000B" then "C-K"
|
95
|
+
when "\u000C" then "C-L"
|
96
|
+
when "\u000D" then "C-M"
|
97
|
+
when "\u000E" then "C-N"
|
98
|
+
when "\u000F" then "C-O"
|
99
|
+
when "\u0010" then "C-P"
|
100
|
+
when "\u0011" then "C-Q"
|
101
|
+
when "\u0012" then "C-R"
|
102
|
+
when "\u0013" then "C-S"
|
103
|
+
when "\u0014" then "C-T"
|
104
|
+
when "\u0015" then "C-U"
|
105
|
+
when "\u0016" then "C-V"
|
106
|
+
when "\u0018" then "C-X"
|
107
|
+
when "\u0019" then "C-Y"
|
108
|
+
when "\u001A" then "C-Z"
|
109
|
+
when "\u0017" then "WBACK"
|
110
|
+
when /\A[[:print:]]\z/ then seq
|
111
|
+
else ""
|
112
|
+
end
|
113
|
+
ensure
|
114
|
+
if flush
|
115
|
+
while IO.select([$stdin], nil, nil, 0)
|
116
|
+
begin
|
117
|
+
$stdin.read_nonblock(4096)
|
118
|
+
rescue IO::WaitReadable, EOFError
|
119
|
+
break
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
112
124
|
end
|
113
125
|
end
|
114
126
|
end
|
data/lib/rcurses/pane.rb
CHANGED
@@ -342,7 +342,8 @@ module Rcurses
|
|
342
342
|
|
343
343
|
def edit
|
344
344
|
begin
|
345
|
-
STDIN.
|
345
|
+
STDIN.cooked! rescue nil
|
346
|
+
STDIN.echo = true rescue nil
|
346
347
|
Rcurses::Cursor.show
|
347
348
|
content = @text.pure.gsub("\n", "¬\n")
|
348
349
|
@ix = 0
|
@@ -354,7 +355,7 @@ module Rcurses
|
|
354
355
|
while input_char != 'ESC'
|
355
356
|
row(@y + @line)
|
356
357
|
col(@x + @pos)
|
357
|
-
input_char = getchr
|
358
|
+
input_char = getchr(flush: false)
|
358
359
|
case input_char
|
359
360
|
when 'C-L'
|
360
361
|
@align = 'l'
|
@@ -432,14 +433,19 @@ module Rcurses
|
|
432
433
|
@txt = refresh(content)
|
433
434
|
end
|
434
435
|
ensure
|
435
|
-
STDIN.
|
436
|
+
STDIN.raw! rescue nil
|
437
|
+
STDIN.echo = false rescue nil
|
438
|
+
while IO.select([$stdin], nil, nil, 0)
|
439
|
+
$stdin.read_nonblock(4096) rescue break
|
440
|
+
end
|
436
441
|
end
|
437
442
|
Rcurses::Cursor.hide
|
438
443
|
end
|
439
444
|
|
440
445
|
def editline
|
441
446
|
begin
|
442
|
-
STDIN.
|
447
|
+
STDIN.cooked! rescue nil
|
448
|
+
STDIN.echo = true rescue nil
|
443
449
|
Rcurses::Cursor.show
|
444
450
|
@x = [[@x, 1].max, @max_w - @w + 1].min
|
445
451
|
@y = [[@y, 1].max, @max_h - @h + 1].min
|
@@ -461,7 +467,7 @@ module Rcurses
|
|
461
467
|
cont = cont.slice(0, content_len)
|
462
468
|
print cont.ljust(content_len).c(fmt)
|
463
469
|
col(@x + prompt_len + @pos)
|
464
|
-
chr = getchr
|
470
|
+
chr = getchr(flush: false)
|
465
471
|
case chr
|
466
472
|
when 'LEFT'
|
467
473
|
@pos -= 1 if @pos > 0
|
@@ -522,7 +528,11 @@ module Rcurses
|
|
522
528
|
end
|
523
529
|
end
|
524
530
|
ensure
|
525
|
-
STDIN.
|
531
|
+
STDIN.raw! rescue nil
|
532
|
+
STDIN.echo = false rescue nil
|
533
|
+
while IO.select([$stdin], nil, nil, 0)
|
534
|
+
$stdin.read_nonblock(4096) rescue break
|
535
|
+
end
|
526
536
|
end
|
527
537
|
Rcurses::Cursor.hide
|
528
538
|
end
|
data/lib/rcurses.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Web_site: http://isene.com/
|
6
6
|
# Github: https://github.com/isene/rcurses
|
7
7
|
# License: Public domain
|
8
|
-
# Version: 3.7.
|
8
|
+
# Version: 3.7.3: Fixed pasting bug in edit(line)
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcurses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.7.
|
4
|
+
version: 3.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-04-
|
11
|
+
date: 2025-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -29,8 +29,8 @@ description: 'Create curses applications for the terminal easier than ever. Crea
|
|
29
29
|
up text (in panes or anywhere in the terminal) in bold, italic, underline, reverse
|
30
30
|
color, blink and in any 256 terminal colors for foreground and background. Use a
|
31
31
|
simple editor to let users edit text in panes. Left, right or center align text
|
32
|
-
in panes. Cursor movement around the terminal. New in 3.7.
|
33
|
-
|
32
|
+
in panes. Cursor movement around the terminal. New in 3.7.3: Fixed pasting bug in
|
33
|
+
edit(line).'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|