rcurses 2.3 → 2.4.1

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: 00434da0ec522a7b5452e13379984e832e5548ac7e070326b74b9e5e19da74a1
4
- data.tar.gz: c49c694b53e4521d3959e76d18117dfc6f40c9a151c28d48d00ebf2688a261ac
3
+ metadata.gz: 7c231359439921bfa6f6da0d36db67cf20daf67054031b64b1362cf17a121f36
4
+ data.tar.gz: 07af990392aca529a25aec404f3a92db948eb64dddd4811c8b9f6f80adca5d55
5
5
  SHA512:
6
- metadata.gz: 3cfd5abe01873f4e5a1b52bbf47e6e9322abe30ecbb366a80ccd97599cec04b02a61c1ed589a4bf60310380e7c0b4f2cde6e64d95cedb1403698e31ae6a63e7a
7
- data.tar.gz: 0e0e13e13de006efe4c42c30e793a6aae63e1d6431748fe6f3aa79e9ef96721d5dae00517fe356b85c0d473ccd1c64bb6618c62a3e9e818681c8e39ea59bf755
6
+ metadata.gz: c3d9d2f610c73f034474376e98aac7c63180e6ad1d224f8a0f57898ede77c37679548845b1d21e68f18aa59d187b64808ea417a3a1821b14a78041f35703c1f8
7
+ data.tar.gz: 006b678e16cd6108fc615cb87e7d7937d88d1e556407e7258a6e6b68a9d0d911652277b8ece6e08f11e6479527b081d994d486dfcd72d9fed592ef6bb5995803
data/README.md CHANGED
@@ -105,7 +105,7 @@ pure | Strip text of any "dressing" (example: with `text = "TEST".b`,
105
105
  PS: Blink does not work in conjunction with setting a background color in urxvt. It does work in gnome-terminal. But the overall performance in urxvt as orders of magnitude better than gnome-terminal.
106
106
 
107
107
  # module Cursor
108
- To use this module, first do `include Rcurses::Cursor`. Create a new cursor object with `mycursor = Cursor`. Then you can apply the following methods to `mycursor`:
108
+ To use this module, first do `include Rcurses::Cursor`. Create a new cursor object with `mycursor = Rcurses::Cursor`. Then you can apply the following methods to `mycursor`:
109
109
 
110
110
  Method | Description
111
111
  ------------------|---------------------------------------------------------------
@@ -114,12 +114,13 @@ 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
124
  next_line) | Move cursor down to beginning of next line
124
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)
@@ -129,8 +130,8 @@ clear_line_after | Erase from the current position (inclusive) to the end of th
129
130
  scroll_up | Scroll display up one line
130
131
  scroll_down | Scroll display down one line
131
132
  clear_screen_down | Clear screen down from current row
132
- hide_cursor | Hide the cursor
133
- show_cursor | Show cursor
133
+ hide | Hide the cursor
134
+ show | Show cursor
134
135
 
135
136
  # The function getchr
136
137
  rcurses provides a vital extension to Ruby in reading characters entered by the user. This is especially needed for curses applications where readline inputs are required.
@@ -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_cursor; print(CSI + '?25l'); end # Scroll display down one line
45
- def show_cursor; 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
@@ -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")
@@ -287,6 +292,7 @@ module Rcurses
287
292
  begin
288
293
  # Switch to raw mode without echoing input
289
294
  STDIN.raw!
295
+ Rcurses::Cursor.show
290
296
  # Prepare content for editing, replacing newlines with a placeholder
291
297
  content = @text.pure.gsub("\n", "¬\n")
292
298
  # Initialize cursor position and indices
@@ -384,12 +390,14 @@ module Rcurses
384
390
  # Restore terminal mode
385
391
  STDIN.cooked!
386
392
  end
393
+ Rcurses::Cursor.hide
387
394
  end
388
395
 
389
396
  def editline
390
397
  begin
391
398
  # Switch to raw mode without echo
392
399
  STDIN.raw!
400
+ Rcurses::Cursor.show
393
401
 
394
402
  # Initialize position and dimensions
395
403
  @x = @startx.call
@@ -468,6 +476,7 @@ module Rcurses
468
476
  # Restore terminal mode
469
477
  STDIN.cooked!
470
478
  end
479
+ Rcurses::Cursor.hide
471
480
  end
472
481
 
473
482
  private
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.3: Updated docs.
8
+ # Version: 2.4: Show cursor on edit. Changed hide_cursor and show_cursor to hide and show.
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.3'
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-07 00:00:00.000000000 Z
11
+ date: 2025-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -29,7 +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.3: Updated docs..'
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. 2.4.1: Minor fixes'
33
34
  email: g@isene.com
34
35
  executables: []
35
36
  extensions: []