rcurses 2.7 → 2.9
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 +8 -1
- data/lib/rcurses/general.rb +6 -0
- data/lib/rcurses/input.rb +66 -7
- data/lib/rcurses/pane.rb +16 -4
- data/lib/rcurses.rb +2 -1
- data/lib/string_extensions.rb +3 -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: 66ea9b80bc6e110518ce62e95aa6f021fdbde64a8ca639c7bb43b33856496372
|
4
|
+
data.tar.gz: 59a2371b4bad8b29ce338385d7d506426c1d02b4d84f56b4421d1ee4b56dc32d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b04179f02c444db27c64ff66f090eda1a2d0176177a32f85c94e867903e1148af47972b50601d6e70e56d2830c5ba8470fc97ce3385963fd685c5c07fa00b155
|
7
|
+
data.tar.gz: 144a1941e04608a19def0450bc93e334d1577388eb798de4423e9720bf3435834786cce1045f3f25969490d5aec6b43010f8da1dca4c69aa1341ec32c827141f
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# rcurses - An alternative curses library written in pure Ruby
|
2
2
|
|
3
3
|
 [](https://badge.fury.io/rb/rcurses)  
|
4
|
-
|
4
|
+
|
5
5
|
<img src="img/rcurses-logo.png" width="150" height="150">
|
6
6
|
|
7
7
|
Create curses applications for the terminal easier than ever.
|
@@ -83,6 +83,8 @@ puts(text) | Short form for setting panel.text, then doing a refresh of that
|
|
83
83
|
ask(prompt,text) | Short form of setting panel.prompt, then panel.text, doing a panel.editline and then returning panel.text
|
84
84
|
pagedown | Scroll down one page height in the text (minus one line), but not longer than the length of the text
|
85
85
|
pageup | Scroll up one page height in the text (minus one line)
|
86
|
+
linedown | Scroll down one line in the text
|
87
|
+
lineup | Scroll up one line in the text
|
86
88
|
bottom | Scroll to the bottom of the text in the pane
|
87
89
|
top | Scroll to the top of the text in the pane
|
88
90
|
|
@@ -106,6 +108,9 @@ inject("chars",pos) | Inject "chars" at position 'pos' in the pure version of th
|
|
106
108
|
|
107
109
|
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.
|
108
110
|
|
111
|
+
# Cleaning up upon exit
|
112
|
+
End a program with `Rcurses.clear_screen` to clear the screen for any rcurses residues.
|
113
|
+
|
109
114
|
# module Cursor
|
110
115
|
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`:
|
111
116
|
|
@@ -166,6 +171,7 @@ Key pressed | string returned
|
|
166
171
|
`end` | "END"
|
167
172
|
`ctrl-end` | "C-END"
|
168
173
|
`backspace` | "BACK"
|
174
|
+
`ctrl- ` | "C-SPACE"
|
169
175
|
`ctrl-h` | "BACK"
|
170
176
|
`ctrl-a` | "C-A"
|
171
177
|
`ctrl-b` | "C-B"
|
@@ -194,6 +200,7 @@ Key pressed | string returned
|
|
194
200
|
`ctrl-z` | "C-Z"
|
195
201
|
`enter` | "ENTER"
|
196
202
|
`tab` | "TAB"
|
203
|
+
`F1` - `F12` | "F1" - "F12"
|
197
204
|
|
198
205
|
Any other character enter will be returned (to `chr` in the example above).
|
199
206
|
|
data/lib/rcurses/input.rb
CHANGED
@@ -25,24 +25,83 @@ module Rcurses
|
|
25
25
|
when 'C' then chr = "RIGHT"
|
26
26
|
when 'D' then chr = "LEFT"
|
27
27
|
when 'Z' then chr = "S-TAB"
|
28
|
+
when '1'
|
29
|
+
fourth_char = $stdin.getc
|
30
|
+
case fourth_char
|
31
|
+
when '1'
|
32
|
+
fifth_char = $stdin.getc
|
33
|
+
chr = fifth_char == '~' ? "F1" : ""
|
34
|
+
when '2'
|
35
|
+
fifth_char = $stdin.getc
|
36
|
+
chr = fifth_char == '~' ? "F2" : ""
|
37
|
+
when '3'
|
38
|
+
fifth_char = $stdin.getc
|
39
|
+
chr = fifth_char == '~' ? "F3" : ""
|
40
|
+
when '4'
|
41
|
+
fifth_char = $stdin.getc
|
42
|
+
chr = fifth_char == '~' ? "F4" : ""
|
43
|
+
when '5'
|
44
|
+
fifth_char = $stdin.getc
|
45
|
+
chr = fifth_char == '~' ? "F5" : ""
|
46
|
+
when '7'
|
47
|
+
fifth_char = $stdin.getc
|
48
|
+
chr = fifth_char == '~' ? "F6" : ""
|
49
|
+
when '8'
|
50
|
+
fifth_char = $stdin.getc
|
51
|
+
chr = fifth_char == '~' ? "F7" : ""
|
52
|
+
when '9'
|
53
|
+
fifth_char = $stdin.getc
|
54
|
+
chr = fifth_char == '~' ? "F8" : ""
|
55
|
+
end
|
28
56
|
when '2'
|
29
57
|
fourth_char = $stdin.getc
|
30
|
-
|
58
|
+
case fourth_char
|
59
|
+
when '~' then chr = "INS"
|
60
|
+
when '0'
|
61
|
+
fifth_char = $stdin.getc
|
62
|
+
chr = fifth_char == '~' ? "F9" : ""
|
63
|
+
when '1'
|
64
|
+
fifth_char = $stdin.getc
|
65
|
+
chr = fifth_char == '~' ? "F10" : ""
|
66
|
+
when '3'
|
67
|
+
fifth_char = $stdin.getc
|
68
|
+
chr = fifth_char == '~' ? "F11" : ""
|
69
|
+
when '4'
|
70
|
+
fifth_char = $stdin.getc
|
71
|
+
chr = fifth_char == '~' ? "F12" : ""
|
72
|
+
else chr = ""
|
73
|
+
end
|
31
74
|
when '3'
|
32
75
|
fourth_char = $stdin.getc
|
33
76
|
chr = fourth_char == '~' ? "DEL" : ""
|
34
77
|
when '5'
|
35
78
|
fourth_char = $stdin.getc
|
36
|
-
|
79
|
+
case fourth_char
|
80
|
+
when '~' then chr = "PgUP"
|
81
|
+
when '^' then chr = "C-PgUP"
|
82
|
+
else chr = ""
|
83
|
+
end
|
37
84
|
when '6'
|
38
85
|
fourth_char = $stdin.getc
|
39
|
-
|
86
|
+
case fourth_char
|
87
|
+
when '~' then chr = "PgDOWN"
|
88
|
+
when '^' then chr = "C-PgDOWN"
|
89
|
+
else chr = ""
|
90
|
+
end
|
40
91
|
when '1', '7'
|
41
92
|
fourth_char = $stdin.getc
|
42
|
-
|
93
|
+
case fourth_char
|
94
|
+
when '~' then chr = "HOME"
|
95
|
+
when '^' then chr = "C-HOME"
|
96
|
+
else chr = ""
|
97
|
+
end
|
43
98
|
when '4', '8'
|
44
99
|
fourth_char = $stdin.getc
|
45
|
-
|
100
|
+
case fourth_char
|
101
|
+
when '~' then chr = "END"
|
102
|
+
when '^' then chr = "C-END"
|
103
|
+
else chr = ""
|
104
|
+
end
|
46
105
|
else
|
47
106
|
chr = ""
|
48
107
|
end
|
@@ -62,6 +121,7 @@ module Rcurses
|
|
62
121
|
when "\r", "\n" then chr = "ENTER"
|
63
122
|
when "\t" then chr = "TAB"
|
64
123
|
when "\u007F", "\b" then chr = "BACK"
|
124
|
+
when "\u0000" then chr = "C-SPACE"
|
65
125
|
when "\u0001" then chr = "C-A"
|
66
126
|
when "\u0002" then chr = "C-B"
|
67
127
|
when "\u0003" then chr = "C-C"
|
@@ -85,7 +145,7 @@ module Rcurses
|
|
85
145
|
when "\u0018" then chr = "C-X"
|
86
146
|
when "\u0019" then chr = "C-Y"
|
87
147
|
when "\u001A" then chr = "C-Z"
|
88
|
-
when "\u0017" then chr = "WBACK"
|
148
|
+
when "\u0017" then chr = "WBACK" # C-W
|
89
149
|
when /[[:print:]]/ then chr = c
|
90
150
|
else chr = ""
|
91
151
|
end
|
@@ -94,4 +154,3 @@ module Rcurses
|
|
94
154
|
end
|
95
155
|
end
|
96
156
|
end
|
97
|
-
|
data/lib/rcurses/pane.rb
CHANGED
@@ -39,8 +39,14 @@ module Rcurses
|
|
39
39
|
refresh
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
43
|
-
@ix
|
42
|
+
def linedown
|
43
|
+
@ix += 1
|
44
|
+
@ix = @text.split("\n").length if @ix > @text.split("\n").length - 1
|
45
|
+
refresh
|
46
|
+
end
|
47
|
+
|
48
|
+
def lineup
|
49
|
+
@ix -= 1
|
44
50
|
@ix = 0 if @ix < 0
|
45
51
|
refresh
|
46
52
|
end
|
@@ -51,8 +57,9 @@ module Rcurses
|
|
51
57
|
refresh
|
52
58
|
end
|
53
59
|
|
54
|
-
def
|
55
|
-
@ix =
|
60
|
+
def pageup
|
61
|
+
@ix = @ix - @h + 1
|
62
|
+
@ix = 0 if @ix < 0
|
56
63
|
refresh
|
57
64
|
end
|
58
65
|
|
@@ -61,6 +68,11 @@ module Rcurses
|
|
61
68
|
refresh
|
62
69
|
end
|
63
70
|
|
71
|
+
def top
|
72
|
+
@ix = 0
|
73
|
+
refresh
|
74
|
+
end
|
75
|
+
|
64
76
|
def refresh(cont = @text)
|
65
77
|
@max_h, @max_w = IO.console.winsize
|
66
78
|
|
data/lib/rcurses.rb
CHANGED
@@ -5,13 +5,14 @@
|
|
5
5
|
# Web_site: http://isene.com/
|
6
6
|
# Github: https://github.com/isene/rcurses
|
7
7
|
# License: Public domain
|
8
|
-
# Version: 2.
|
8
|
+
# Version: 2.9: Added Rcurses.clear_screen
|
9
9
|
|
10
10
|
require 'io/console' # Basic gem for rcurses
|
11
11
|
require 'io/wait' # stdin handling
|
12
12
|
require 'timeout'
|
13
13
|
|
14
14
|
require_relative 'string_extensions'
|
15
|
+
require_relative 'rcurses/general'
|
15
16
|
require_relative 'rcurses/cursor'
|
16
17
|
require_relative 'rcurses/input'
|
17
18
|
require_relative 'rcurses/pane'
|
data/lib/string_extensions.rb
CHANGED
@@ -11,6 +11,9 @@ class String
|
|
11
11
|
|
12
12
|
# Internal function
|
13
13
|
def color(text, sp, ep = "\e[0m")
|
14
|
+
# Replace every newline with a newline followed by the start sequence,
|
15
|
+
# so that formatting is reestablished on each new line.
|
16
|
+
text = text.gsub("\n", "#{ep}\n#{sp}")
|
14
17
|
"#{sp}#{text}#{ep}"
|
15
18
|
end
|
16
19
|
|
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.9'
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -29,8 +29,7 @@ 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
|
-
and ''bottom'' for text scrolling in pane.'
|
32
|
+
in panes. Cursor movement around the terminal. New in 2.9: Added Rcurses.clear_screen.'
|
34
33
|
email: g@isene.com
|
35
34
|
executables: []
|
36
35
|
extensions: []
|
@@ -42,6 +41,7 @@ files:
|
|
42
41
|
- examples/focus_panes.rb
|
43
42
|
- lib/rcurses.rb
|
44
43
|
- lib/rcurses/cursor.rb
|
44
|
+
- lib/rcurses/general.rb
|
45
45
|
- lib/rcurses/input.rb
|
46
46
|
- lib/rcurses/pane.rb
|
47
47
|
- lib/string_extensions.rb
|