rcurses 3.8.1 → 3.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 +4 -0
- data/examples/basic_panes.rb +6 -0
- data/examples/focus_panes.rb +14 -11
- data/lib/rcurses/pane.rb +2 -2
- data/lib/rcurses.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b86d406d96a0e08b0cf5b1d5e6ddc0a0e3a8908293405e59dcedf230276bde95
|
4
|
+
data.tar.gz: 91a3ac14bc426f1d864baee262b3b070aa1b5c7fdd94397f82b10ddd405b91b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfef56d215b5906f531c23b81756cba928ee25249893ad3464c9c64c42b121c8e5a1de3cf5110511dbb4b1b538ef09e1e1cdcf629724109c9c081c9371109135
|
7
|
+
data.tar.gz: 6c422acb468b451f959399161c8483d9812d99dc88c0afd1aa76335635a31ab2d81e247c98fca69f0242b7fd92e0e35e3f39338a09d2a1dd52e55374d8f51537
|
data/README.md
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
|
7
7
|
Create curses applications for the terminal easier than ever.
|
8
8
|
|
9
|
+
Here's a somewhat simple example of a TUI program using rcurses: The [T-REX](https://github.com/isene/T-REX) calculator.
|
10
|
+
|
11
|
+
And here's a much more involved example: The [RTFM](https://github.com/isene/RTFM) terminal file manager.
|
12
|
+
|
9
13
|
# Why?
|
10
14
|
Having struggled with the venerable curses library and the ruby interface to it for many years, I finally got around to write an alternative - in pure Ruby.
|
11
15
|
|
data/examples/basic_panes.rb
CHANGED
data/examples/focus_panes.rb
CHANGED
@@ -7,11 +7,11 @@ include Rcurses::Cursor
|
|
7
7
|
@max_h, @max_w = IO.console.winsize
|
8
8
|
@pane = []
|
9
9
|
@focused = 3 # Start with pane 3 so that the first keypress focuses back to Pane 0
|
10
|
-
|
10
|
+
Rcurses::Cursor.hide
|
11
11
|
|
12
12
|
# Start by creating the panes; Format:
|
13
13
|
# pane = Rcurses::Pane.new( startx, starty, width, height, fg, bg)
|
14
|
-
pane_back = Rcurses::Pane.new( 1, 1, @max_w, @max_h,
|
14
|
+
pane_back = Rcurses::Pane.new( 1, 1, @max_w, @max_h, nil, 236)
|
15
15
|
@pane[0] = Rcurses::Pane.new( 4, 4, 20, 10, 236, 254)
|
16
16
|
@pane[1] = Rcurses::Pane.new( 30, 10, 16, 12, 232, 132)
|
17
17
|
@pane[2] = Rcurses::Pane.new( 8, 20, 30, 20, 136, 54)
|
@@ -19,21 +19,24 @@ pane_back = Rcurses::Pane.new( 1, 1, @max_w, @max_h, 255, 236)
|
|
19
19
|
|
20
20
|
pane_back.text = "PRESS ANY KEY TO SHIFT FOCUS. PRESS 'ESC' TO QUIT."
|
21
21
|
@pane.each_index { |i| @pane[i].text = "This is pane " + i.to_s }
|
22
|
-
pane_back.
|
22
|
+
pane_back.full_refresh
|
23
23
|
@pane.each_index { |i| @pane[i].refresh }
|
24
24
|
|
25
25
|
input = ''
|
26
26
|
while input != 'ESC'
|
27
27
|
input = getchr
|
28
|
-
|
28
|
+
pane_back.full_refresh
|
29
29
|
@focused += 1
|
30
30
|
@focused = 0 if @focused == @pane.size
|
31
|
+
@pane.each_index {|i| @pane[i].border = false}
|
32
|
+
@pane.each_index {|i| @pane[i].full_refresh}
|
31
33
|
@pane[@focused].border = true
|
32
|
-
|
33
|
-
@pane.each_index { |i| @pane[i].refresh }
|
34
|
-
@pane[@focused].refresh
|
34
|
+
@pane[@focused].full_refresh
|
35
35
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
|
37
|
+
# Always end an application with these lines:
|
38
|
+
$stdin.cooked!
|
39
|
+
$stdin.echo = true
|
40
|
+
Rcurses.clear_screen
|
41
|
+
Rcurses::Cursor.show
|
42
|
+
|
data/lib/rcurses/pane.rb
CHANGED
@@ -150,7 +150,7 @@ module Rcurses
|
|
150
150
|
# Hide cursor and disable auto-wrap (minimal fix)
|
151
151
|
STDOUT.print "\e[?25l\e[?7l"
|
152
152
|
|
153
|
-
fmt = [@fg, @bg].
|
153
|
+
fmt = [@fg.to_s, @bg.to_s].join(',')
|
154
154
|
|
155
155
|
# Lazy evaluation: If the content or pane width has changed, reinitialize the lazy cache.
|
156
156
|
if !defined?(@cached_text) || @cached_text != cont || @cached_w != @w
|
@@ -444,7 +444,7 @@ module Rcurses
|
|
444
444
|
@scroll = false
|
445
445
|
@ix = 0
|
446
446
|
row(@y)
|
447
|
-
fmt = [@fg, @bg].
|
447
|
+
fmt = [@fg.to_s, @bg.to_s].join(',')
|
448
448
|
col(@x)
|
449
449
|
print @prompt.c(fmt)
|
450
450
|
prompt_len = @prompt.pure.length
|
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: 3.
|
8
|
+
# Version: 3.9: Fixed bug on pane parameters passed as nil. Better examples.
|
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: 3.
|
4
|
+
version: '3.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-04-
|
11
|
+
date: 2025-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -30,7 +30,7 @@ description: 'Create curses applications for the terminal easier than ever. Crea
|
|
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
32
|
in panes. Cursor movement around the terminal. New in 3.8: Fixed border fragments
|
33
|
-
upon utf-8 characters. 3.
|
33
|
+
upon utf-8 characters. 3.9: Fixed bug on pane parameters passed as nil. Better examples.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|