rcurses 2.4 → 2.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6b5f0fbbc0c9c981c1e4d23197008f4a5ea00cff36492938328fe30c52804af
4
- data.tar.gz: d4ee9ba0743c045168d0528534f5cc3f5571b3e968948d8553afdb768aebb1c3
3
+ metadata.gz: '0242225387152024f958dd6d49e9671626e07589c514910258f8bb092c73eb90'
4
+ data.tar.gz: b745692855fcdd6fae65b1fd82126e006737d2923eaf1d4b4cdcea8c19f98734
5
5
  SHA512:
6
- metadata.gz: 53b164b30ccb430b541a6880c51d298c8ddaa38b7d5b97b1714c53ca0c5e100caa1883c1caec210816f03704ff3d1b59715c317bd015c480c83e49227a91e7ed
7
- data.tar.gz: 89ecd3c6021dcfd70bf390723de8a7d75210a85b5e73077dfb7f0167f3faad9c68e422b25ef4ed564fa4fd3341d32ac6c90e70132910e025e278f82ec3b892ec
6
+ metadata.gz: 9bf0a7aac4eeaf767aea8d3f3ec3f529cf633184cb9b771b124dcb9236fcbf9ec6cb458db301e870539c79c3bfba80cd4bb9d5eb8f343265d858d0896ed73c5a
7
+ data.tar.gz: 4f792ed8261eea7b65cc17b95333ccc940843cdb77734f840fdbda3b45e8e671ab221c87e38dd6e38c83bcf6cb9d34674815f13843d998a340f5e100cb7acad4
data/README.md CHANGED
@@ -114,14 +114,15 @@ restore | Restore cursor position
114
114
  pos | Query cursor current position (example: `row,col = mycursor.pos`)
115
115
  colget | Query cursor current cursor col/x position (example: `row = mycursor.rowget`)
116
116
  rowget | Query cursor current cursor row/y position (example: `row = mycursor.rowget`)
117
+ set(c = 1, r = 1) | Set the position of the cursor to row/y,col/x (example: `mycursor.set(row,col)`) (default = top row, first column)
118
+ col(c = 1) | Cursor moves to the nth position horizontally in the current line (default = first column)
119
+ row(r = 1) | Cursor moves to the nth position vertically in the current column (default = first/top row)
117
120
  up(n = 1) | Move cursor up by n (default is 1 character up)
118
121
  down(n = 1) | Move cursor down by n (default is 1 character down)
119
122
  left(n = 1) | Move cursor backward by n (default is one character)
120
123
  right(n = 1) | Move cursor forward by n (default is one character)
121
- col(n = 1) | Cursor moves to the nth position horizontally in the current line (default = first column)
122
- row(n = 1) | Cursor moves to the nth position vertically in the current column (default = first/top row)
123
- next_line) | Move cursor down to beginning of next line
124
- prev_line) | Move cursor up to beginning of previous line
124
+ next_line | Move cursor down to beginning of next line
125
+ prev_line | Move cursor up to beginning of previous line
125
126
  clear_char(n = 1) | Erase n characters from the current cursor position (default is one character)
126
127
  clear_line | Erase the entire current line and return to beginning of the line
127
128
  clear_line_before | Erase from the beginning of the line up to and including the current cursor position
@@ -201,6 +202,8 @@ while $stdin.ready?
201
202
  chr += $stdin.getc
202
203
  end
203
204
  ```
205
+ 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.
206
+
204
207
 
205
208
  # Example
206
209
 
@@ -26,22 +26,23 @@ module Rcurses
26
26
  _row, col = pos
27
27
  col
28
28
  end
29
- def up(n = 1); print(CSI + "#{(n)}A"); end # Move cursor up by n
30
- def down(n = 1); print(CSI + "#{(n)}B"); end # Move the cursor down by n
31
- def left(n = 1); print(CSI + "#{n}D"); end # Move the cursor backward by n
32
- def right(n = 1); print(CSI + "#{n}C"); end # Move the cursor forward by n
33
- def col(n = 1); print(CSI + "#{n}G"); end # Cursor moves to nth position horizontally in the current line
34
- def row(n = 1); print(CSI + "#{n}d"); end # Cursor moves to the nth position vertically in the current column
35
- def next_line; print(CSI + 'E' + CSI + "1G"); end # Move cursor down to beginning of next line
36
- def prev_line; print(CSI + 'A' + CSI + "1G"); end # Move cursor up to beginning of previous line
37
- def clear_char(n = 1); print(CSI + "#{n}X"); end # Erase n characters from the current cursor position
38
- def clear_line; print(CSI + '2K' + CSI + "1G"); end # Erase the entire current line and return to beginning of the line
39
- def clear_line_before; print(CSI + '1K'); end # Erase from the beginning of the line up to and including the current cursor position.
40
- def clear_line_after; print(CSI + '0K'); end # Erase from the current position (inclusive) to the end of the line
41
- def clear_screen_down; print(CSI + 'J'); end # Clear screen down from current row
42
- def scroll_up; print(ESC + 'M'); end # Scroll display up one line
43
- def scroll_down; print(ESC + 'D'); end # Scroll display down one line
44
- def hide; print(CSI + '?25l'); end # Scroll display down one line
45
- def show; print(CSI + '?25h'); end # Scroll display down one line
29
+ def set(r = 1, c = 1); print(CSI + "#{r}d"); print(CSI + "#{c}G"); end # Set cursor position to Row, Col (y,x)
30
+ def up(n = 1); print(CSI + "#{(n)}A"); end # Move cursor up by n
31
+ def down(n = 1); print(CSI + "#{(n)}B"); end # Move the cursor down by n
32
+ def left(n = 1); print(CSI + "#{n}D"); end # Move the cursor backward by n
33
+ def right(n = 1); print(CSI + "#{n}C"); end # Move the cursor forward by n
34
+ def col(c = 1); print(CSI + "#{c}G"); end # Cursor moves to nth position horizontally in the current line
35
+ def row(r = 1); print(CSI + "#{r}d"); end # Cursor moves to the nth position vertically in the current column
36
+ def next_line; print(CSI + 'E' + CSI + "1G"); end # Move cursor down to beginning of next line
37
+ def prev_line; print(CSI + 'A' + CSI + "1G"); end # Move cursor up to beginning of previous line
38
+ def clear_char(n = 1); print(CSI + "#{n}X"); end # Erase n characters from the current cursor position
39
+ def clear_line; print(CSI + '2K' + CSI + "1G"); end # Erase the entire current line and return to beginning of the line
40
+ def clear_line_before; print(CSI + '1K'); end # Erase from the beginning of the line up to and including the current cursor position.
41
+ def clear_line_after; print(CSI + '0K'); end # Erase from the current position (inclusive) to the end of the line
42
+ def clear_screen_down; print(CSI + 'J'); end # Clear screen down from current row
43
+ def scroll_up; print(ESC + 'M'); end # Scroll display up one line
44
+ def scroll_down; print(ESC + 'D'); end # Scroll display down one line
45
+ def hide; print(CSI + '?25l'); end # Scroll display down one line
46
+ def show; print(CSI + '?25h'); end # Scroll display down one line
46
47
  end
47
48
  end
data/lib/rcurses/input.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  module Rcurses
2
2
  module Input
3
- def getchr
3
+ def getchr(m = nil, t = nil)
4
4
  # Function to process key presses
5
- c = $stdin.getch
5
+ c = $stdin.getch(min: m, time: t)
6
6
  case c
7
7
  when "\e" # ANSI escape sequences
8
8
  return "ESC" if !$stdin.ready?
@@ -58,6 +58,8 @@ module Rcurses
58
58
  when "\u0005" then chr = "C-E"
59
59
  when "\u0006" then chr = "C-F"
60
60
  when "\u0007" then chr = "C-G"
61
+ when "\u0008" then chr = "C-H"
62
+ when "\u000A" then chr = "C-J"
61
63
  when "\u000B" then chr = "C-K"
62
64
  when "\u000C" then chr = "C-L"
63
65
  when "\u000D" then chr = "C-M"
@@ -66,6 +68,7 @@ module Rcurses
66
68
  when "\u0010" then chr = "C-P"
67
69
  when "\u0011" then chr = "C-Q"
68
70
  when "\u0012" then chr = "C-R"
71
+ when "\u0013" then chr = "C-S"
69
72
  when "\u0014" then chr = "C-T"
70
73
  when "\u0015" then chr = "C-U"
71
74
  when "\u0016" then chr = "C-V"
@@ -73,7 +76,6 @@ module Rcurses
73
76
  when "\u0019" then chr = "C-Y"
74
77
  when "\u001A" then chr = "C-Z"
75
78
  when "\u0017" then chr = "WBACK"
76
- when "\u0013" then chr = "C-S"
77
79
  when /[[:print:]]/ then chr = c
78
80
  else chr = ""
79
81
  end
data/lib/rcurses/pane.rb CHANGED
@@ -201,6 +201,11 @@ module Rcurses
201
201
  @txt
202
202
  end
203
203
 
204
+ def puts(txt)
205
+ @text = txt
206
+ refresh
207
+ end
208
+
204
209
  def textformat(cont)
205
210
  # Split the content by '\n'
206
211
  lines = cont.split("\n")
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: Show cursor on edit. Changed hide_cursor and show_cursor to hide and show.
8
+ # Version: 2.4.2: Added parameters 'min' and 'time' to getchr
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'
4
+ version: 2.4.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-03-07 00:00:00.000000000 Z
11
+ date: 2025-03-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 2.4: Show cursor on edit.
33
- Changed hide_cursor and show_cursor to hide and show.'
32
+ in panes. Cursor movement around the terminal. New in 2.4.2: Added parameters ''min''
33
+ and ''time'' to getchr'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []