rcurses 2.4.8 → 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 +7 -13
- data/lib/rcurses/pane.rb +8 -22
- 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,7 +74,7 @@ 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
|
@@ -215,7 +209,7 @@ Try this in `irb`:
|
|
215
209
|
```
|
216
210
|
require 'rcurses'
|
217
211
|
@max_h, @max_w = IO.console.winsize
|
218
|
-
mypane = Pane.new(@
|
212
|
+
mypane = Pane.new(@max_w/2, 30, 30, 10, 19, 229)
|
219
213
|
mypane.border = true
|
220
214
|
mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
|
221
215
|
mypane.refresh
|
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
|
|
@@ -143,10 +137,6 @@ module Rcurses
|
|
143
137
|
|
144
138
|
# Start the actual refresh
|
145
139
|
o_row, o_col = pos
|
146
|
-
@x = @startx.call
|
147
|
-
@y = @starty.call
|
148
|
-
@w = @width.call
|
149
|
-
@h = @height.call
|
150
140
|
|
151
141
|
# Adjust pane dimensions and positions
|
152
142
|
if @border # Keep panes inside screen
|
@@ -416,10 +406,6 @@ module Rcurses
|
|
416
406
|
Rcurses::Cursor.show
|
417
407
|
|
418
408
|
# Initialize position and dimensions
|
419
|
-
@x = @startx.call
|
420
|
-
@y = @starty.call
|
421
|
-
@w = @width.call
|
422
|
-
@h = @height.call
|
423
409
|
# Ensure pane is within screen bounds
|
424
410
|
@x = [[@x, 1].max, @max_w - @w + 1].min
|
425
411
|
@y = [[@y, 1].max, @max_h - @h + 1].min
|
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: []
|