rcurses 2.4.6 → 2.4.8
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 +3 -1
- data/lib/rcurses/input.rb +19 -7
- data/lib/rcurses/pane.rb +12 -0
- data/lib/rcurses.rb +2 -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: 45d89af8ee783dbbc7fe8e465de5b5d8915960c0893b5ee809c1b88b2848ce56
|
4
|
+
data.tar.gz: 9b31fbc3c918b06070ae7ebca455521c7b2226a0f672d7d04799e6dc3017153e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bcc37f94f6a7e24d97027fe78ac821d7398ddc8375c290b885ec6ee7699fd63c675f6a0d103e139081324e4df96b1d382127d94ff1f36aa9a701aa26199a09a
|
7
|
+
data.tar.gz: 814630dbef4a3d1afceab3bb0a3395f3075cf73adf48172192dc733cb116a8e430eac9d41be304c675d7180b756eeb4222f35a72e03df569b694a8b9e054256c
|
data/README.md
CHANGED
@@ -85,6 +85,8 @@ move(x,y) | Move the pane by `x`and `y` (`mypane.move(-4,5)` will move the
|
|
85
85
|
refresh | Refreshes/redraws the Pane with content
|
86
86
|
edit | An editor for the Pane. When this is invoked, all existing font dressing is stripped and the user gets to edit the raw text. The user can add font effects similar to Markdown; Use an asterisk before and after text to be drawn in bold, text between forward-slashes become italic, and underline before and after text means the text will be underlined, a hash-sign before and after text makes the text reverse colored. You can also combine a whole set of dressings in this format: `<23,245,biurl|Hello World!>` - this will make "Hello World!" print in the color 23 with the background color 245 (regardless of the Pane's fg/bg setting) in bold, italic, underlined, reversed colored and blinking. Hitting `ESC` while in edit mode will disregard the edits, while `Ctrl-S` will save the edits
|
87
87
|
editline | Used for one-line Panes. It will print the content of the property `prompt` and then the property `text` that can then be edited by the user. Hitting `ESC` will disregard the edits, while `ENTER` will save the edited text
|
88
|
+
puts(text) | Short form for setting panel.text, then doing a refresh of that panel
|
89
|
+
ask(prompt,text) | Short form of setting panel.prompt, then panel.text, doing a panel.editline and then returning panel.text
|
88
90
|
|
89
91
|
# class String extensions
|
90
92
|
Method extensions provided for the class String:
|
@@ -204,7 +206,7 @@ while $stdin.ready?
|
|
204
206
|
chr += $stdin.getc
|
205
207
|
end
|
206
208
|
```
|
207
|
-
You can also pass
|
209
|
+
You can also pass a timeout to `getchr` with `getchr(time)` to wait for `time` number of seconds and returning `nil` if the user does not press a key.
|
208
210
|
|
209
211
|
|
210
212
|
# Example
|
data/lib/rcurses/input.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
module Rcurses
|
2
2
|
module Input
|
3
|
-
def getchr(
|
4
|
-
|
5
|
-
|
3
|
+
def getchr(t = nil)
|
4
|
+
begin
|
5
|
+
# If a timeout is provided, wrap the blocking getch call in Timeout.timeout.
|
6
|
+
c = t ? Timeout.timeout(t) { $stdin.getch } : $stdin.getch
|
7
|
+
rescue Timeout::Error
|
8
|
+
return nil
|
9
|
+
end
|
10
|
+
|
11
|
+
# Process the character (including escape sequences)
|
6
12
|
case c
|
7
13
|
when "\e" # ANSI escape sequences
|
8
|
-
|
14
|
+
# Check quickly for any following bytes
|
15
|
+
unless IO.select([$stdin], nil, nil, 0.001)
|
16
|
+
return "ESC"
|
17
|
+
end
|
9
18
|
second_char = $stdin.getc
|
10
19
|
case second_char
|
11
20
|
when '[' # CSI
|
@@ -34,7 +43,8 @@ module Rcurses
|
|
34
43
|
when '4', '8'
|
35
44
|
fourth_char = $stdin.getc
|
36
45
|
chr = fourth_char == '~' ? "END" : ""
|
37
|
-
else
|
46
|
+
else
|
47
|
+
chr = ""
|
38
48
|
end
|
39
49
|
when 'O' # Function keys
|
40
50
|
third_char = $stdin.getc
|
@@ -48,7 +58,8 @@ module Rcurses
|
|
48
58
|
else
|
49
59
|
chr = ""
|
50
60
|
end
|
51
|
-
|
61
|
+
# Treat both "\r" and "\n" as Enter
|
62
|
+
when "\r", "\n" then chr = "ENTER"
|
52
63
|
when "\t" then chr = "TAB"
|
53
64
|
when "\u007F", "\b" then chr = "BACK"
|
54
65
|
when "\u0001" then chr = "C-A"
|
@@ -59,7 +70,6 @@ module Rcurses
|
|
59
70
|
when "\u0006" then chr = "C-F"
|
60
71
|
when "\u0007" then chr = "C-G"
|
61
72
|
when "\u0008" then chr = "C-H"
|
62
|
-
when "\u000A" then chr = "C-J"
|
63
73
|
when "\u000B" then chr = "C-K"
|
64
74
|
when "\u000C" then chr = "C-L"
|
65
75
|
when "\u000D" then chr = "C-M"
|
@@ -79,7 +89,9 @@ module Rcurses
|
|
79
89
|
when /[[:print:]]/ then chr = c
|
80
90
|
else chr = ""
|
81
91
|
end
|
92
|
+
|
82
93
|
chr
|
83
94
|
end
|
84
95
|
end
|
85
96
|
end
|
97
|
+
|
data/lib/rcurses/pane.rb
CHANGED
@@ -32,6 +32,18 @@ module Rcurses
|
|
32
32
|
refresh
|
33
33
|
end
|
34
34
|
|
35
|
+
def ask(prompt, text)
|
36
|
+
@prompt = prompt
|
37
|
+
@text = text
|
38
|
+
editline
|
39
|
+
@text
|
40
|
+
end
|
41
|
+
|
42
|
+
def puts(text)
|
43
|
+
@text = text
|
44
|
+
refresh
|
45
|
+
end
|
46
|
+
|
35
47
|
def refresh(cont = @text)
|
36
48
|
@max_h, @max_w = IO.console.winsize
|
37
49
|
|
data/lib/rcurses.rb
CHANGED
@@ -5,10 +5,11 @@
|
|
5
5
|
# Web_site: http://isene.com/
|
6
6
|
# Github: https://github.com/isene/rcurses
|
7
7
|
# License: Public domain
|
8
|
-
# Version: 2.4.
|
8
|
+
# Version: 2.4.7: Fixed getchr timeout, added panel function 'ask'
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
12
|
+
require 'timeout'
|
12
13
|
|
13
14
|
require_relative 'string_extensions'
|
14
15
|
require_relative 'rcurses/cursor'
|
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: 2.4.
|
4
|
+
version: 2.4.8
|
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-03-
|
11
|
+
date: 2025-03-24 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 2.4.
|
33
|
-
|
32
|
+
in panes. Cursor movement around the terminal. New in 2.4.8: Fixed getchr timeout
|
33
|
+
bug, ''ask'' now returns panel.text, added panel function ''puts''.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|