rcurses 3.4.1 → 3.4.3
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 +2 -2
- data/lib/rcurses/pane.rb +47 -25
- data/lib/rcurses.rb +1 -1
- 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: be329f6d934aaafb7aab4c2335e9e396ab38e466c4588c65c3a119579a6ff1b8
|
4
|
+
data.tar.gz: 87f5ed878d424e288c1197badc1ccc1f0f906bef1cb8432edba71af4025d3139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14d7539a4c05e7fb0934cd3d2ff2df7df9d54bf825848cdc0bec4a0b0231d5d2518082365d7d126bbcfe9f70b477eb0feb27398546a7541efa30f104646232f2
|
7
|
+
data.tar.gz: 220a5817e7bbf6b517d9f5218cc9e894b969c8116a75f8d6070e86c97002c19d84c770d5c46bf958c46efce2193e40cb4c44c27d3cb077049364892606f03419
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
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">
|
@@ -82,7 +82,7 @@ refresh | Refreshes/redraws the Pane with content
|
|
82
82
|
full_refresh | Refreshes/redraws the Pane with content completely (without diff rendering)
|
83
83
|
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
|
84
84
|
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
|
85
|
-
|
85
|
+
say(text) | Short form for setting panel.text, then doing a refresh of that panel
|
86
86
|
ask(prompt,text) | Short form of setting panel.prompt, then panel.text, doing a panel.editline and then returning panel.text
|
87
87
|
pagedown | Scroll down one page height in the text (minus one line), but not longer than the length of the text
|
88
88
|
pageup | Scroll up one page height in the text (minus one line)
|
data/lib/rcurses/pane.rb
CHANGED
@@ -35,40 +35,50 @@ module Rcurses
|
|
35
35
|
attr_accessor :x, :y, :w, :h, :fg, :bg
|
36
36
|
attr_accessor :border, :scroll, :text, :ix, :align, :prompt
|
37
37
|
attr_accessor :moreup, :moredown
|
38
|
+
attr_accessor :record, :history
|
38
39
|
|
39
40
|
def initialize(x = 1, y = 1, w = 1, h = 1, fg = nil, bg = nil)
|
40
41
|
@max_h, @max_w = IO.console.winsize
|
41
|
-
@x
|
42
|
-
@y
|
43
|
-
@w
|
44
|
-
@h
|
45
|
-
@fg, @bg
|
46
|
-
@text
|
47
|
-
@align
|
48
|
-
@scroll
|
49
|
-
@prompt
|
50
|
-
@ix
|
51
|
-
@prev_frame = nil
|
52
|
-
@line
|
53
|
-
@pos
|
42
|
+
@x = x
|
43
|
+
@y = y
|
44
|
+
@w = w
|
45
|
+
@h = h
|
46
|
+
@fg, @bg = fg, bg
|
47
|
+
@text = "" # Initialize text variable
|
48
|
+
@align = "l" # Default alignment
|
49
|
+
@scroll = true # Enable scroll indicators
|
50
|
+
@prompt = "" # Prompt for editline
|
51
|
+
@ix = 0 # Starting text line index
|
52
|
+
@prev_frame = nil # Holds the previously rendered frame (array of lines)
|
53
|
+
@line = 0 # For cursor tracking during editing:
|
54
|
+
@pos = 0 # For cursor tracking during editing:
|
55
|
+
@record = false # Don't record history unless explicitly set to true
|
56
|
+
@history = [] # History array
|
54
57
|
end
|
55
58
|
|
56
|
-
def
|
57
|
-
@
|
58
|
-
@
|
59
|
-
refresh
|
59
|
+
def text=(new_text)
|
60
|
+
(@history << @text) if @record && @text
|
61
|
+
@text = new_text
|
60
62
|
end
|
61
63
|
|
62
64
|
def ask(prompt, text)
|
63
65
|
@prompt = prompt
|
64
66
|
@text = text
|
65
67
|
editline
|
68
|
+
(@history << @text) if @record && !@text.empty?
|
66
69
|
@text
|
67
|
-
end
|
70
|
+
end
|
68
71
|
|
69
|
-
def
|
72
|
+
def say(text)
|
73
|
+
(@history << text) if @record && !text.empty?
|
70
74
|
@text = text
|
71
75
|
@ix = 0
|
76
|
+
refresh
|
77
|
+
end
|
78
|
+
|
79
|
+
def move(dx, dy)
|
80
|
+
@x += dx
|
81
|
+
@y += dy
|
72
82
|
refresh
|
73
83
|
end
|
74
84
|
|
@@ -250,11 +260,6 @@ module Rcurses
|
|
250
260
|
result
|
251
261
|
end
|
252
262
|
|
253
|
-
def puts(txt)
|
254
|
-
@text = txt
|
255
|
-
refresh
|
256
|
-
end
|
257
|
-
|
258
263
|
def right
|
259
264
|
if @pos < @txt[@ix + @line].length
|
260
265
|
@pos += 1
|
@@ -443,6 +448,7 @@ module Rcurses
|
|
443
448
|
cont = @text.pure.slice(0, content_len)
|
444
449
|
@pos = cont.length
|
445
450
|
chr = ''
|
451
|
+
history_index = @history.size
|
446
452
|
|
447
453
|
while chr != 'ESC'
|
448
454
|
col(@x + prompt_len)
|
@@ -475,8 +481,24 @@ module Rcurses
|
|
475
481
|
cont = ''
|
476
482
|
@pos = 0
|
477
483
|
when 'ENTER'
|
478
|
-
@text =
|
484
|
+
@text = cont
|
479
485
|
chr = 'ESC'
|
486
|
+
when 'UP'
|
487
|
+
if @history.any? && history_index > 0
|
488
|
+
history_index -= 1
|
489
|
+
cont = @history[history_index].pure.slice(0, content_len)
|
490
|
+
@pos = cont.length
|
491
|
+
end
|
492
|
+
when 'DOWN'
|
493
|
+
if history_index < @history.size - 1
|
494
|
+
history_index += 1
|
495
|
+
cont = @history[history_index].pure.slice(0, content_len)
|
496
|
+
@pos = cont.length
|
497
|
+
elsif history_index == @history.size - 1
|
498
|
+
history_index += 1
|
499
|
+
cont = ""
|
500
|
+
@pos = 0
|
501
|
+
end
|
480
502
|
when /^.$/
|
481
503
|
if @pos < content_len
|
482
504
|
cont.insert(@pos, chr)
|
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.3:
|
8
|
+
# Version: 3.4.3: Stopped parsing of bold/italics etc in editline
|
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.
|
4
|
+
version: 3.4.3
|
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-10 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 3.4.
|
33
|
-
|
32
|
+
in panes. Cursor movement around the terminal. New in 3.4.3: Stopped parsing of
|
33
|
+
bold/italics etc in editline.'
|
34
34
|
email: g@isene.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|