rcurses 2.4.8 → 2.6

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -13
  3. data/lib/rcurses/pane.rb +20 -22
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45d89af8ee783dbbc7fe8e465de5b5d8915960c0893b5ee809c1b88b2848ce56
4
- data.tar.gz: 9b31fbc3c918b06070ae7ebca455521c7b2226a0f672d7d04799e6dc3017153e
3
+ metadata.gz: 85c679d06754d9afd2c33e55e44d700d37333f197ffb1d753ef3ff8bbdf15e1b
4
+ data.tar.gz: 5f2c74a5a789c93c6406bb761fffc769d13ab8e0723b743f408e264cfd61614a
5
5
  SHA512:
6
- metadata.gz: 5bcc37f94f6a7e24d97027fe78ac821d7398ddc8375c290b885ec6ee7699fd63c675f6a0d103e139081324e4df96b1d382127d94ff1f36aa9a701aa26199a09a
7
- data.tar.gz: 814630dbef4a3d1afceab3bb0a3395f3075cf73adf48172192dc733cb116a8e430eac9d41be304c675d7180b756eeb4222f35a72e03df569b694a8b9e054256c
6
+ metadata.gz: 19854a5865cfe09fcdcad1c8e9540ac5eb29a704f1b8e0b9626e6c69e8b51f5991411ea5f60bf8f9eb6a67725b89f3c3debfe2fc0af0857e3a770e103603ffae
7
+ data.tar.gz: 22f2e416110f65bdedad83a967464d6072affa79b45facf5c38abf3ae80cbe22ec1a0d2041c57f295082e98a0529994f4b8c352443e578853a27792009a02f18
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(startx, starty, width, height, foregroundcolor, backgroundcolor)
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
- startx | The `x` value to be "Eval-ed"
63
- x | The readable x-value for the Pane
64
- starty | The `y` value to be "Eval-ed"
65
- y | The readable y-value for the Pane
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,13 +74,15 @@ The methods for Pane:
80
74
 
81
75
  Method | Description
82
76
  ---------------|---------------------------------------------------------------
83
- new/init | Initializes a Pane with optional arguments startx, starty, width, height, foregroundcolor and backgroundcolor
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
89
83
  ask(prompt,text) | Short form of setting panel.prompt, then panel.text, doing a panel.editline and then returning panel.text
84
+ pagedown | Go down one page height in the text (minus one line), but not longer than the length of the text
85
+ pageup | Go up one page height in the text (minus one line)
90
86
 
91
87
  # class String extensions
92
88
  Method extensions provided for the class String:
@@ -215,7 +211,7 @@ Try this in `irb`:
215
211
  ```
216
212
  require 'rcurses'
217
213
  @max_h, @max_w = IO.console.winsize
218
- mypane = Pane.new(@maxw/2, 30, 30, 10, 19, 229)
214
+ mypane = Pane.new(@max_w/2, 30, 30, 10, 19, 229)
219
215
  mypane.border = true
220
216
  mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
221
217
  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 :startx, :starty, :width, :height, :fg, :bg
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(startx = 1, starty = 1, width = 1, height = 1, fg = nil, bg = nil)
11
- # Using Procs or Lambdas instead of eval
12
- @startx = startx.is_a?(Proc) ? startx : -> { startx }
13
- @starty = starty.is_a?(Proc) ? starty : -> { starty }
14
- @width = width.is_a?(Proc) ? width : -> { width }
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
- @startx = -> { @x + x }
31
- @starty = -> { @y + y }
24
+ @x += x
25
+ @y += y
32
26
  refresh
33
27
  end
34
28
 
@@ -44,6 +38,18 @@ module Rcurses
44
38
  refresh
45
39
  end
46
40
 
41
+ def pageup
42
+ @ix = @ix - @h + 1
43
+ @ix = 0 if @ix < 0
44
+ refresh
45
+ end
46
+
47
+ def pagedown
48
+ @ix = @ix + @h - 1
49
+ @ix = @text.length - 1 if @ix > @text.length - 1
50
+ refresh
51
+ end
52
+
47
53
  def refresh(cont = @text)
48
54
  @max_h, @max_w = IO.console.winsize
49
55
 
@@ -143,10 +149,6 @@ module Rcurses
143
149
 
144
150
  # Start the actual refresh
145
151
  o_row, o_col = pos
146
- @x = @startx.call
147
- @y = @starty.call
148
- @w = @width.call
149
- @h = @height.call
150
152
 
151
153
  # Adjust pane dimensions and positions
152
154
  if @border # Keep panes inside screen
@@ -416,10 +418,6 @@ module Rcurses
416
418
  Rcurses::Cursor.show
417
419
 
418
420
  # Initialize position and dimensions
419
- @x = @startx.call
420
- @y = @starty.call
421
- @w = @width.call
422
- @h = @height.call
423
421
  # Ensure pane is within screen bounds
424
422
  @x = [[@x, 1].max, @max_w - @w + 1].min
425
423
  @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.8
4
+ version: '2.6'
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-24 00:00:00.000000000 Z
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.4.8: Fixed getchr timeout
33
- bug, ''ask'' now returns panel.text, added panel function ''puts''.'
32
+ in panes. Cursor movement around the terminal. New in 2.6: Added methods ''pagedown''
33
+ and ''pageup'' to panes enabling text scrolling.'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []