rcurses 2.4.7 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3614072a43262fae0361e5fbca943f1e4da81a13a79b4bc2ea9ca7342d935c9
4
- data.tar.gz: 4195f8f7ab5b5183f671487eb9df121a01db6991c4eafb5b5f81c19c0e190b12
3
+ metadata.gz: 45d89af8ee783dbbc7fe8e465de5b5d8915960c0893b5ee809c1b88b2848ce56
4
+ data.tar.gz: 9b31fbc3c918b06070ae7ebca455521c7b2226a0f672d7d04799e6dc3017153e
5
5
  SHA512:
6
- metadata.gz: c1f74c9ae9a72accf1b7cff35f772ca53b61bbc39f56dee8f190ead264fe6dc735e771bcac563832eae17b80452ea5b2098c63be6fbd20e386f18c3727112365
7
- data.tar.gz: 06d521b146ed4962f5bd94d4c359bf8811ff1454ec6ede89e42ec2206fc32090186bf8bc8fc9df1acccdc0642f2cec2a5974656817969c76429d2b59f443b013
6
+ metadata.gz: 5bcc37f94f6a7e24d97027fe78ac821d7398ddc8375c290b885ec6ee7699fd63c675f6a0d103e139081324e4df96b1d382127d94ff1f36aa9a701aa26199a09a
7
+ data.tar.gz: 814630dbef4a3d1afceab3bb0a3395f3075cf73adf48172192dc733cb116a8e430eac9d41be304c675d7180b756eeb4222f35a72e03df569b694a8b9e054256c
data/README.md CHANGED
@@ -85,7 +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
- ask(prompt,text) | Short form of setting panel.prompt, then panel.text and then doing a panel.editline
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
89
90
 
90
91
  # class String extensions
91
92
  Method extensions provided for the class String:
data/lib/rcurses/input.rb CHANGED
@@ -1,21 +1,23 @@
1
1
  module Rcurses
2
2
  module Input
3
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)
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
6
8
  return nil
7
9
  end
8
10
 
9
- c = $stdin.getch
11
+ # Process the character (including escape sequences)
10
12
  case c
11
- when "\e"
12
- # For escape sequences, use a very short timeout to check for extra bytes
13
+ when "\e" # ANSI escape sequences
14
+ # Check quickly for any following bytes
13
15
  unless IO.select([$stdin], nil, nil, 0.001)
14
16
  return "ESC"
15
17
  end
16
18
  second_char = $stdin.getc
17
19
  case second_char
18
- when '['
20
+ when '[' # CSI
19
21
  third_char = $stdin.getc
20
22
  case third_char
21
23
  when 'A' then chr = "UP"
@@ -44,20 +46,20 @@ module Rcurses
44
46
  else
45
47
  chr = ""
46
48
  end
47
- when 'O'
49
+ when 'O' # Function keys
48
50
  third_char = $stdin.getc
49
51
  case third_char
50
52
  when 'a' then chr = "C-UP"
51
53
  when 'b' then chr = "C-DOWN"
52
54
  when 'c' then chr = "C-RIGHT"
53
55
  when 'd' then chr = "C-LEFT"
54
- else
55
- chr = ""
56
+ else chr = ""
56
57
  end
57
58
  else
58
59
  chr = ""
59
60
  end
60
- when "\r" then chr = "ENTER"
61
+ # Treat both "\r" and "\n" as Enter
62
+ when "\r", "\n" then chr = "ENTER"
61
63
  when "\t" then chr = "TAB"
62
64
  when "\u007F", "\b" then chr = "BACK"
63
65
  when "\u0001" then chr = "C-A"
@@ -68,7 +70,6 @@ module Rcurses
68
70
  when "\u0006" then chr = "C-F"
69
71
  when "\u0007" then chr = "C-G"
70
72
  when "\u0008" then chr = "C-H"
71
- when "\u000A" then chr = "C-J"
72
73
  when "\u000B" then chr = "C-K"
73
74
  when "\u000C" then chr = "C-L"
74
75
  when "\u000D" then chr = "C-M"
@@ -88,7 +89,9 @@ module Rcurses
88
89
  when /[[:print:]]/ then chr = c
89
90
  else chr = ""
90
91
  end
92
+
91
93
  chr
92
94
  end
93
95
  end
94
96
  end
97
+
data/lib/rcurses/pane.rb CHANGED
@@ -36,6 +36,12 @@ module Rcurses
36
36
  @prompt = prompt
37
37
  @text = text
38
38
  editline
39
+ @text
40
+ end
41
+
42
+ def puts(text)
43
+ @text = text
44
+ refresh
39
45
  end
40
46
 
41
47
  def refresh(cont = @text)
data/lib/rcurses.rb CHANGED
@@ -9,6 +9,7 @@
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.7
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-22 00:00:00.000000000 Z
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.7: Fixed getchr timeout,
33
- added panel function ''ask''.'
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: []