rcurses 3.7.1 → 3.7.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rcurses/input.rb +106 -96
  3. data/lib/rcurses.rb +1 -1
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44240d40ec0eed615d785bf0cbd288470b722a1162a6d2e30a1f1045dfed3a01
4
- data.tar.gz: 0316a667c756e3f99b6fe6d0ee1d0956f673058139cbbbb615d48882b0b799b7
3
+ metadata.gz: 6f5f1abba12690ed9ad662a78930994e8a4a8667abafe4508d467f059007951a
4
+ data.tar.gz: fa3a289bbb5f24f77a3417505a9c860a375efc3498860946b938d392ec36c20d
5
5
  SHA512:
6
- metadata.gz: 2a54a18fb906abebebbf5a7066a4448ba25c47a80df7fced9289c86d17caf09d62b2bbb959863470fb2243ead27de62d9278a3843e9c075a16a6885120250f5f
7
- data.tar.gz: 0dd21b911092c501c146ad354ca5dfd58cb84bdff142237ed2b9be677b5f5a18ee8c40283194794affc493097fb9d8a9cc37120a08a787eaa14718920630722a
6
+ metadata.gz: 21fc4e420009b25f19e635ad48cec4124e396ff8a56ae4fc900cf9a1e171f7af9f9126d0a50439632cf0ea4afe6ea5e3a4c531cb66275c8eafef7fd541da69e1
7
+ data.tar.gz: 3c0bb2893b2b561d842665bbac5543cd1e337f8c9ea6ebdd1d3e1d1d942ed62fc18c7c92a1234c319d1c5732b96a814b28c176c594114889d442057b2ccad84a
data/lib/rcurses/input.rb CHANGED
@@ -1,114 +1,124 @@
1
1
  module Rcurses
2
2
  module Input
3
3
  def getchr(t = nil)
4
- # 1) Read a byte (with optional timeout)
5
4
  begin
6
- c = t ? Timeout.timeout(t) { $stdin.getch } : $stdin.getch
7
- rescue Timeout::Error
8
- return nil
9
- end
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
- # 2) If it's ESC, grab any quick trailing bytes
12
- seq = c
13
- if c == "\e"
14
- if IO.select([$stdin], nil, nil, 0.05)
15
- begin
16
- seq << $stdin.read_nonblock(16)
17
- rescue IO::WaitReadable, EOFError
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
- # 3) Single ESC alone
23
- return "ESC" if seq == "\e"
23
+ # 3) Single ESC alone
24
+ return "ESC" if seq == "\e"
24
25
 
25
- # 4) Shift‑TAB
26
- return "S-TAB" if seq == "\e[Z"
26
+ # 4) Shift‑TAB
27
+ return "S-TAB" if seq == "\e[Z"
27
28
 
28
- # 5) Legacy single‑char shift‑arrows (your old working ones)
29
- case seq
30
- when "\e[a" then return "S-UP"
31
- when "\e[b" then return "S-DOWN"
32
- when "\e[c" then return "S-RIGHT"
33
- when "\e[d" then return "S-LEFT"
34
- end
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
- # 6) CSI style shift‑arrows (e.g. ESC [1;2A )
37
- if m = seq.match(/\A\e\[\d+;2([ABCD])\z/)
38
- return { 'A' => "S-UP", 'B' => "S-DOWN", 'C' => "S-RIGHT", 'D' => "S-LEFT" }[m[1]]
39
- end
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
- # 7) Plain arrows
42
- if m = seq.match(/\A\e\[([ABCD])\z/)
43
- return { 'A' => "UP", 'B' => "DOWN", 'C' => "RIGHT", 'D' => "LEFT" }[m[1]]
44
- end
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
- # 8) CSI + '~' sequences (Ins, Del, Home, End, PgUp, PgDn, F5-F12)
47
- if seq.start_with?("\e[") && seq.end_with?("~")
48
- num = seq[/\d+(?=~)/].to_i
49
- return case num
50
- when 1, 7 then "HOME"
51
- when 2 then "INS"
52
- when 3 then "DEL"
53
- when 4, 8 then "END"
54
- when 5 then "PgUP"
55
- when 6 then "PgDOWN"
56
- when 15 then "F5"
57
- when 17 then "F6"
58
- when 18 then "F7"
59
- when 19 then "F8"
60
- when 20 then "F9"
61
- when 21 then "F10"
62
- when 23 then "F11"
63
- when 24 then "F12"
64
- else ""
65
- end
66
- end
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
- # 9) SS3 function keys F1-F4
69
- if seq.start_with?("\eO") && seq.length == 3
70
- return case seq[2]
71
- when 'P' then "F1"
72
- when 'Q' then "F2"
73
- when 'R' then "F3"
74
- when 'S' then "F4"
75
- else ""
76
- end
77
- end
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
- # 10) Single / Ctrl-char mappings
80
- return case seq
81
- when "\r", "\n" then "ENTER"
82
- when "\t" then "TAB"
83
- when "\u007F", "\b" then "BACK"
84
- when "\u0000" then "C-SPACE"
85
- when "\u0001" then "C-A"
86
- when "\u0002" then "C-B"
87
- when "\u0003" then "C-C"
88
- when "\u0004" then "C-D"
89
- when "\u0005" then "C-E"
90
- when "\u0006" then "C-F"
91
- when "\u0007" then "C-G"
92
- when "\u0008" then "C-H"
93
- when "\u000B" then "C-K"
94
- when "\u000C" then "C-L"
95
- when "\u000D" then "C-M"
96
- when "\u000E" then "C-N"
97
- when "\u000F" then "C-O"
98
- when "\u0010" then "C-P"
99
- when "\u0011" then "C-Q"
100
- when "\u0012" then "C-R"
101
- when "\u0013" then "C-S"
102
- when "\u0014" then "C-T"
103
- when "\u0015" then "C-U"
104
- when "\u0016" then "C-V"
105
- when "\u0018" then "C-X"
106
- when "\u0019" then "C-Y"
107
- when "\u001A" then "C-Z"
108
- when "\u0017" then "WBACK"
109
- when /\A[[:print:]]\z/ then seq
110
- else ""
111
- end
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
+ while IO.select([$stdin], nil, nil, 0)
115
+ begin
116
+ $stdin.read_nonblock(4096)
117
+ rescue IO::WaitReadable, EOFError
118
+ break
119
+ end
120
+ end
121
+ end
112
122
  end
113
123
  end
114
124
  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.1: Fixed straggling residue key codes and improved clean_ansi
8
+ # Version: 3.7.2: Better fix for straggling residue key codes
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.1
4
+ version: 3.7.2
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-17 00:00:00.000000000 Z
11
+ date: 2025-04-19 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.1: Fixed straggling residue
33
- key codes and improved clean_ansi.'
32
+ in panes. Cursor movement around the terminal. New in 3.7.2: Better fix for straggling
33
+ residue key codes.'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []