rcurses 2.4.6 → 2.4.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f120b89280037a3485515b1cc75f7a08f122fde4faff32b2234b602bb37dbecf
4
- data.tar.gz: 71aa736312930bf945f8af1e021430e4ff9ce23be9a12402a3ec046c272f5055
3
+ metadata.gz: c3614072a43262fae0361e5fbca943f1e4da81a13a79b4bc2ea9ca7342d935c9
4
+ data.tar.gz: 4195f8f7ab5b5183f671487eb9df121a01db6991c4eafb5b5f81c19c0e190b12
5
5
  SHA512:
6
- metadata.gz: fa2b26d81b024bd82cdeab5fc643072f4c4b1120cd96720a41926e5bafcc49c535b9df25242f534c99448a501000d3c30fd8331777f2eff03720472c3747182f
7
- data.tar.gz: 2153244b482b08beb7234df2dd91fc542f438b6a814016ccdec68c32bd818e92744165bf10b87fa6a4d5167d30106a9bc7bcd4b259ab05eecb581112cbe8b2ab
6
+ metadata.gz: c1f74c9ae9a72accf1b7cff35f772ca53b61bbc39f56dee8f190ead264fe6dc735e771bcac563832eae17b80452ea5b2098c63be6fbd20e386f18c3727112365
7
+ data.tar.gz: 06d521b146ed4962f5bd94d4c359bf8811ff1454ec6ede89e42ec2206fc32090186bf8bc8fc9df1acccdc0642f2cec2a5974656817969c76429d2b59f443b013
data/README.md CHANGED
@@ -85,6 +85,7 @@ 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
+ ask(prompt,text) | Short form of setting panel.prompt, then panel.text and then doing a panel.editline
88
89
 
89
90
  # class String extensions
90
91
  Method extensions provided for the class String:
@@ -204,7 +205,7 @@ while $stdin.ready?
204
205
  chr += $stdin.getc
205
206
  end
206
207
  ```
207
- You can also pass two parameters to `getchr` with `getchr(min, time)` where `min` instructs getchr to wait for the minimum number of characters to return (not very useful) - and `time` is the timeout for waiting (can be very useful). You can happily call `getchr` without these parameters.
208
+ 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
209
 
209
210
 
210
211
  # Example
data/lib/rcurses/input.rb CHANGED
@@ -1,14 +1,21 @@
1
1
  module Rcurses
2
2
  module Input
3
- def getchr(m = nil, t = nil)
4
- # Function to process key presses
5
- c = $stdin.getch(min: m, time: t)
3
+ def getchr(t = nil)
4
+ # Wait for input up to t seconds; if none, return nil (or a timeout indicator)
5
+ if t && !IO.select([$stdin], nil, nil, t)
6
+ return nil
7
+ end
8
+
9
+ c = $stdin.getch
6
10
  case c
7
- when "\e" # ANSI escape sequences
8
- return "ESC" if !$stdin.ready?
11
+ when "\e"
12
+ # For escape sequences, use a very short timeout to check for extra bytes
13
+ unless IO.select([$stdin], nil, nil, 0.001)
14
+ return "ESC"
15
+ end
9
16
  second_char = $stdin.getc
10
17
  case second_char
11
- when '[' # CSI
18
+ when '['
12
19
  third_char = $stdin.getc
13
20
  case third_char
14
21
  when 'A' then chr = "UP"
@@ -34,16 +41,18 @@ module Rcurses
34
41
  when '4', '8'
35
42
  fourth_char = $stdin.getc
36
43
  chr = fourth_char == '~' ? "END" : ""
37
- else chr = ""
44
+ else
45
+ chr = ""
38
46
  end
39
- when 'O' # Function keys
47
+ when 'O'
40
48
  third_char = $stdin.getc
41
49
  case third_char
42
50
  when 'a' then chr = "C-UP"
43
51
  when 'b' then chr = "C-DOWN"
44
52
  when 'c' then chr = "C-RIGHT"
45
53
  when 'd' then chr = "C-LEFT"
46
- else chr = ""
54
+ else
55
+ chr = ""
47
56
  end
48
57
  else
49
58
  chr = ""
data/lib/rcurses/pane.rb CHANGED
@@ -32,6 +32,12 @@ module Rcurses
32
32
  refresh
33
33
  end
34
34
 
35
+ def ask(prompt, text)
36
+ @prompt = prompt
37
+ @text = text
38
+ editline
39
+ end
40
+
35
41
  def refresh(cont = @text)
36
42
  @max_h, @max_w = IO.console.winsize
37
43
 
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: 2.4.6: Added x,y,w,h at panel creation, not just on refresh
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
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.6
4
+ version: 2.4.7
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-21 00:00:00.000000000 Z
11
+ date: 2025-03-22 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.6: Added x,y,w,h at panel
33
- creation, not just on refresh.'
32
+ in panes. Cursor movement around the terminal. New in 2.4.7: Fixed getchr timeout,
33
+ added panel function ''ask''.'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []