rcurses 2.4.7 → 2.5
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 +9 -14
- data/lib/rcurses/input.rb +14 -11
- data/lib/rcurses/pane.rb +14 -22
- data/lib/rcurses.rb +1 -0
- 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: d761408b4f05dc23d8ce7bbccee6e205f197a7121755ecda26a12f07cf1c3270
|
4
|
+
data.tar.gz: 0abd1a9a7b67cb96a9a00c537d17c414f8ceb78e78747627cd49305bf22bf57f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641587c5622dee1f388f027a3bbec71f5072a74cdbe0ed7dc26fcc33e17fc112a22422d81785f32ca3d46398130809d44cd6f6f3f831819fd005bee791735b77
|
7
|
+
data.tar.gz: e6b7d6ccb2024490326d3a2452a361b8886b5518f0c9a2d8015f79345911cbc7898b64ecf228333dd6099631c9214aa09a56ea9a8d089fa30d02494f802a85fa
|
data/README.md
CHANGED
@@ -43,12 +43,10 @@ This will create a pane/box starting at terminal column/x 80 and row/y 30 with t
|
|
43
43
|
|
44
44
|
The format for creating a pane is:
|
45
45
|
```
|
46
|
-
Rcurses::Pane.new(
|
46
|
+
Rcurses::Pane.new(x, y, w, h, fg, bg)
|
47
47
|
```
|
48
48
|
You can drop the last two 256-color codes to create a pane with the defaults for your terminal.
|
49
49
|
|
50
|
-
You can add anything as `startx`, `starty`, `width` or `height` as those values will be evaluated and stored in readable variables `x`, `y`, `w` and `h` respectively.
|
51
|
-
|
52
50
|
By adding values for the terminal size in your program:
|
53
51
|
```
|
54
52
|
@max_h, @max_w = IO.console.winsize
|
@@ -59,14 +57,10 @@ Avaliable properties/variables:
|
|
59
57
|
|
60
58
|
Property | Description
|
61
59
|
---------------|---------------------------------------------------------------
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
width | The Pane width to be "Eval-ed"
|
67
|
-
w | The readable w-value for the Pane
|
68
|
-
height | The Pane height to be "Eval-ed"
|
69
|
-
h | The readable h-value for the Pane
|
60
|
+
x | The x (column) position of the Pane
|
61
|
+
y | The y (row) position of the Pane
|
62
|
+
w | The width of the Pane
|
63
|
+
h | The heigth of the Pane
|
70
64
|
fg | Foreground color for the Pane
|
71
65
|
bg | Background color for the Pane
|
72
66
|
border | Draw border around the Pane (=true) or not (=false), default being false
|
@@ -80,12 +74,13 @@ The methods for Pane:
|
|
80
74
|
|
81
75
|
Method | Description
|
82
76
|
---------------|---------------------------------------------------------------
|
83
|
-
new/init | Initializes a Pane with optional arguments
|
77
|
+
new/init | Initializes a Pane with optional arguments `x, y, w, h, fg and bg`
|
84
78
|
move(x,y) | Move the pane by `x`and `y` (`mypane.move(-4,5)` will move the pane left four characters and five characters down)
|
85
79
|
refresh | Refreshes/redraws the Pane with content
|
86
80
|
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
81
|
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
|
-
|
82
|
+
puts(text) | Short form for setting panel.text, then doing a refresh of that panel
|
83
|
+
ask(prompt,text) | Short form of setting panel.prompt, then panel.text, doing a panel.editline and then returning panel.text
|
89
84
|
|
90
85
|
# class String extensions
|
91
86
|
Method extensions provided for the class String:
|
@@ -214,7 +209,7 @@ Try this in `irb`:
|
|
214
209
|
```
|
215
210
|
require 'rcurses'
|
216
211
|
@max_h, @max_w = IO.console.winsize
|
217
|
-
mypane = Pane.new(@
|
212
|
+
mypane = Pane.new(@max_w/2, 30, 30, 10, 19, 229)
|
218
213
|
mypane.border = true
|
219
214
|
mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
|
220
215
|
mypane.refresh
|
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
|
-
|
5
|
-
|
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
|
-
|
11
|
+
# Process the character (including escape sequences)
|
10
12
|
case c
|
11
|
-
when "\e"
|
12
|
-
#
|
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
|
-
|
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
@@ -3,20 +3,14 @@ module Rcurses
|
|
3
3
|
require 'clipboard' # Ensure the 'clipboard' gem is installed
|
4
4
|
include Cursor
|
5
5
|
include Input
|
6
|
-
attr_accessor :
|
7
|
-
attr_accessor :x, :y, :w, :h
|
6
|
+
attr_accessor :x, :y, :w, :h, :fg, :bg
|
8
7
|
attr_accessor :border, :scroll, :text, :ix, :align, :prompt
|
9
8
|
|
10
|
-
def initialize(
|
11
|
-
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@height = height.is_a?(Proc) ? height : -> { height }
|
16
|
-
@x = @startx.call
|
17
|
-
@y = @starty.call
|
18
|
-
@w = @width.call
|
19
|
-
@h = @height.call
|
9
|
+
def initialize(x = 1, y = 1, w = 1, h = 1, fg = nil, bg = nil)
|
10
|
+
@x = x
|
11
|
+
@y = y
|
12
|
+
@w = w
|
13
|
+
@h = h
|
20
14
|
@fg, @bg = fg, bg
|
21
15
|
@text = "" # Initialize text variable
|
22
16
|
@align = "l" # Default alignment
|
@@ -27,8 +21,8 @@ module Rcurses
|
|
27
21
|
end
|
28
22
|
|
29
23
|
def move(x, y)
|
30
|
-
@
|
31
|
-
@
|
24
|
+
@x += x
|
25
|
+
@y += y
|
32
26
|
refresh
|
33
27
|
end
|
34
28
|
|
@@ -36,6 +30,12 @@ module Rcurses
|
|
36
30
|
@prompt = prompt
|
37
31
|
@text = text
|
38
32
|
editline
|
33
|
+
@text
|
34
|
+
end
|
35
|
+
|
36
|
+
def puts(text)
|
37
|
+
@text = text
|
38
|
+
refresh
|
39
39
|
end
|
40
40
|
|
41
41
|
def refresh(cont = @text)
|
@@ -137,10 +137,6 @@ module Rcurses
|
|
137
137
|
|
138
138
|
# Start the actual refresh
|
139
139
|
o_row, o_col = pos
|
140
|
-
@x = @startx.call
|
141
|
-
@y = @starty.call
|
142
|
-
@w = @width.call
|
143
|
-
@h = @height.call
|
144
140
|
|
145
141
|
# Adjust pane dimensions and positions
|
146
142
|
if @border # Keep panes inside screen
|
@@ -410,10 +406,6 @@ module Rcurses
|
|
410
406
|
Rcurses::Cursor.show
|
411
407
|
|
412
408
|
# Initialize position and dimensions
|
413
|
-
@x = @startx.call
|
414
|
-
@y = @starty.call
|
415
|
-
@w = @width.call
|
416
|
-
@h = @height.call
|
417
409
|
# Ensure pane is within screen bounds
|
418
410
|
@x = [[@x, 1].max, @max_w - @w + 1].min
|
419
411
|
@y = [[@y, 1].max, @max_h - @h + 1].min
|
data/lib/rcurses.rb
CHANGED
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
|
+
version: '2.5'
|
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-26 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.
|
33
|
-
|
32
|
+
in panes. Cursor movement around the terminal. New in 2.5: Simplified the over-engineering,
|
33
|
+
removing startx, starty, width and height of pane creation.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|