rcurses 1.1 → 2.0
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 +12 -3
- data/lib/rcurses.rb +0 -0
- data/rcurses_example.rb +9 -7
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81d2dc35832251275d8a1ffb15c8480e5824a19c4643fddf4c74a7ee2fd850d2
|
4
|
+
data.tar.gz: a3f96eb853a6a4700037a13623aca7e2d242894da905edc295067475cb7675a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64971c51e33f0068c2dab3f0e2a3bae2b35e17ec2b6e2d81b5fd5cc35b61a5a8f7561f7af08d3147a043f93237d62dcea31c4860d2ebf5c7be2d08555c979303
|
7
|
+
data.tar.gz: aeb2ff504b4dd02822cac01fd25f5ff8423464e5b9f4cf12c08bf3b591d6c2b480e0ea3ab77d1d5ee51db6173913d74fbea528189b826e7139fe661b27141957
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
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.
|
10
10
|
|
11
11
|
# Design principles
|
12
|
-
Simple. One file.
|
12
|
+
Simple. One file. Minimum of external dependencies.
|
13
13
|
|
14
14
|
# Installation
|
15
15
|
Simply run `gem install rcurses`.
|
@@ -44,7 +44,15 @@ The format for creating a pane is:
|
|
44
44
|
```
|
45
45
|
Rcurses::Pane.new(startx, starty, width, height, foregroundcolor, backgroundcolor)
|
46
46
|
```
|
47
|
-
You can drop the last two 256-color codes to create a pane with the defaults for your terminal.
|
47
|
+
You can drop the last two 256-color codes to create a pane with the defaults for your terminal.
|
48
|
+
|
49
|
+
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.
|
50
|
+
|
51
|
+
By adding values for the terminal size in your program:
|
52
|
+
```
|
53
|
+
@max_h, @max_w = IO.console.winsize
|
54
|
+
```
|
55
|
+
...you can use these values to create proportinally sized panes. So, a hight value of "@max_h/2" is valid to create a pane with the height of half the terminal height (the integer corresponding to half the terminal height will then be accessible as the variable `h`). Use the variables `@max_h` for terminal height and `@max_w` for terminal width.
|
48
56
|
|
49
57
|
Avaliable properties/variables:
|
50
58
|
|
@@ -196,7 +204,8 @@ end
|
|
196
204
|
Try this in `irb`:
|
197
205
|
```
|
198
206
|
require 'rcurses'
|
199
|
-
|
207
|
+
@max_h, @max_w = IO.console.winsize
|
208
|
+
mypane = Pane.new(@maxw/2, 30, 30, 10, 19, 229)
|
200
209
|
mypane.border = true
|
201
210
|
mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
|
202
211
|
mypane.refresh
|
data/lib/rcurses.rb
CHANGED
Binary file
|
data/rcurses_example.rb
CHANGED
@@ -2,12 +2,14 @@
|
|
2
2
|
|
3
3
|
require 'rcurses'
|
4
4
|
|
5
|
+
@max_h, @max_w = IO.console.winsize
|
6
|
+
|
5
7
|
# Start by creating the panes; Format:
|
6
|
-
# pane = Rcurses::Pane.new(
|
7
|
-
pane_top = Rcurses::Pane.new(
|
8
|
-
pane_bottom = Rcurses::Pane.new(
|
9
|
-
pane_left = Rcurses::Pane.new(
|
10
|
-
pane_right = Rcurses::Pane.new(
|
8
|
+
# pane = Rcurses::Pane.new( startx, starty, width, height, fg, bg)
|
9
|
+
pane_top = Rcurses::Pane.new( 1, 1, @max_w, 1, 255, 236)
|
10
|
+
pane_bottom = Rcurses::Pane.new( 1, @max_h, @max_w, 1, 236, 254)
|
11
|
+
pane_left = Rcurses::Pane.new( 2, 3, @max_w/2 - 2, @max_h - 4, 52, nil)
|
12
|
+
pane_right = Rcurses::Pane.new(@max_w/2 + 1, 2, @max_w/2, @max_h - 2, 255, 52)
|
11
13
|
|
12
14
|
pane_left.border = true # Adding a border to the left pane
|
13
15
|
|
@@ -23,9 +25,9 @@ pane_right.refresh # ...and the right pane
|
|
23
25
|
pane_bottom.editline # Do not use a refresh before editline
|
24
26
|
|
25
27
|
# Then create a "pop-up" pane in the middle of the screen
|
26
|
-
pane_mid = Rcurses::Pane.new(
|
28
|
+
pane_mid = Rcurses::Pane.new(@max_w/2 - 10, @max_h/2 - 5, 20, 10, 18, 254)
|
27
29
|
pane_mid.border = true
|
28
|
-
pane_mid.text = "You wrote:
|
30
|
+
pane_mid.text = "You wrote:" + "\n" + pane_bottom.text.i
|
29
31
|
pane_mid.align = "c"
|
30
32
|
pane_mid.refresh
|
31
33
|
|
metadata
CHANGED
@@ -1,21 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcurses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
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
|
-
dependencies:
|
11
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: clipboard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
13
27
|
description: 'Create panes (with the colors and(or border), manipulate the panes and
|
14
28
|
add content. Dress up text (in panes or anywhere in the terminal) in bold, italic,
|
15
29
|
underline, reverse color, blink and in any 256 terminal colors for foreground and
|
16
30
|
background. Use a simple editor to let users edit text in panes. Left, right or
|
17
|
-
center align text in panes. Cursor movement around the terminal. New in
|
18
|
-
|
31
|
+
center align text in panes. Cursor movement around the terminal. New in 2.0: Complete
|
32
|
+
code refactoring.'
|
19
33
|
email: g@isene.com
|
20
34
|
executables: []
|
21
35
|
extensions:
|