rcurses 4.5 → 4.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.
- checksums.yaml +4 -4
- data/lib/rcurses/pane.rb +15 -10
- data/lib/string_extensions.rb +13 -13
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 240aec267dd4c5e8377ffba6844848463a8d4a0c5291f159f354e9c600e6a264
|
4
|
+
data.tar.gz: 3d3534900f41903901758496d0ed0494c400c6ca45dfbd9eb3265b1b924fd108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92a3f431d49eb85bd4c2a25429acfe87acb2cb1a553c4ebad78614f3e34c3f9bcd23037b725b72a117404fa22397a8d5e8a6ba0d1b6193b227c126bcb4f87e80
|
7
|
+
data.tar.gz: 07e0d869aa2025be468a98d359ef2f1894751b301c5ec37965fe75b6bb97bec452b01bcd67c6ddb3fa6a08fe7f7289d85082eaf0153ac6b487d70d417759e1eb
|
data/lib/rcurses/pane.rb
CHANGED
@@ -186,7 +186,7 @@ module Rcurses
|
|
186
186
|
@raw_txt = cont.split("\n")
|
187
187
|
@lazy_txt = [] # This will hold the processed (wrapped) lines as needed.
|
188
188
|
@lazy_index = 0 # Pointer to the next raw line to process.
|
189
|
-
@cached_text = cont
|
189
|
+
@cached_text = cont.dup
|
190
190
|
@cached_w = @w
|
191
191
|
end
|
192
192
|
|
@@ -365,15 +365,19 @@ module Rcurses
|
|
365
365
|
begin
|
366
366
|
STDIN.cooked! rescue nil
|
367
367
|
STDIN.echo = true rescue nil
|
368
|
-
|
368
|
+
# Prepare content with visible newline markers
|
369
369
|
content = @text.pure.gsub("\n", "¬\n")
|
370
|
-
|
371
|
-
@
|
372
|
-
@
|
373
|
-
@
|
370
|
+
# Reset editing cursor state
|
371
|
+
@ix = 0
|
372
|
+
@line = 0
|
373
|
+
@pos = 0
|
374
|
+
# Initial render sets @txt internally for display and cursor math
|
375
|
+
refresh(content)
|
376
|
+
Rcurses::Cursor.show
|
374
377
|
input_char = ''
|
375
378
|
|
376
379
|
while input_char != 'ESC'
|
380
|
+
# Move the terminal cursor to the logical text cursor
|
377
381
|
row(@y + @line)
|
378
382
|
col(@x + @pos)
|
379
383
|
input_char = getchr(flush: false)
|
@@ -424,9 +428,7 @@ module Rcurses
|
|
424
428
|
current_line_length = @txt[@ix + @line]&.length || 0
|
425
429
|
@pos = current_line_length
|
426
430
|
when 'C-HOME'
|
427
|
-
@ix = 0
|
428
|
-
@line = 0
|
429
|
-
@pos = 0
|
431
|
+
@ix = 0; @line = 0; @pos = 0
|
430
432
|
when 'C-END'
|
431
433
|
total_lines = @txt.length
|
432
434
|
@ix = [total_lines - @h, 0].max
|
@@ -443,6 +445,7 @@ module Rcurses
|
|
443
445
|
right
|
444
446
|
end
|
445
447
|
|
448
|
+
# Handle any buffered input
|
446
449
|
while IO.select([$stdin], nil, nil, 0)
|
447
450
|
input_char = $stdin.read_nonblock(1) rescue nil
|
448
451
|
break unless input_char
|
@@ -451,7 +454,9 @@ module Rcurses
|
|
451
454
|
right
|
452
455
|
end
|
453
456
|
|
454
|
-
@txt
|
457
|
+
# Re-render without overwriting the internal @txt
|
458
|
+
refresh(content)
|
459
|
+
Rcurses::Cursor.show
|
455
460
|
end
|
456
461
|
ensure
|
457
462
|
STDIN.raw! rescue nil
|
data/lib/string_extensions.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# string_extensions.rb
|
2
2
|
|
3
3
|
class String
|
4
|
-
# 256-color or truecolor RGB
|
4
|
+
# 256-color or truecolor RGB foregroundbreset only the fg (SGR 39)
|
5
5
|
def fg(color)
|
6
6
|
sp, ep = if color.to_s =~ /\A[0-9A-Fa-f]{6}\z/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
r, g, b = color.scan(/../).map { |c| c.to_i(16) }
|
8
|
+
["\e[38;2;#{r};#{g};#{b}m", "\e[39m"]
|
9
|
+
else
|
10
|
+
["\e[38;5;#{color}m", "\e[39m"]
|
11
|
+
end
|
12
12
|
color(self, sp, ep)
|
13
13
|
end
|
14
14
|
|
15
|
-
# 256-color or truecolor RGB
|
15
|
+
# 256-color or truecolor RGB backgroundbreset only the bg (SGR 49)
|
16
16
|
def bg(color)
|
17
17
|
sp, ep = if color.to_s =~ /\A[0-9A-Fa-f]{6}\z/
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
r, g, b = color.scan(/../).map { |c| c.to_i(16) }
|
19
|
+
["\e[48;2;#{r};#{g};#{b}m", "\e[49m"]
|
20
|
+
else
|
21
|
+
["\e[48;5;#{color}m", "\e[49m"]
|
22
|
+
end
|
23
23
|
color(self, sp, ep)
|
24
24
|
end
|
25
25
|
|
@@ -41,7 +41,7 @@ class String
|
|
41
41
|
end
|
42
42
|
|
43
43
|
sp = "\e[#{parts.join(';')}m"
|
44
|
-
color(self, sp, "\e[
|
44
|
+
color(self, sp, "\e[39;49m")
|
45
45
|
end
|
46
46
|
|
47
47
|
# bold, italic, underline, blink, reverse
|
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: '4.
|
4
|
+
version: '4.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-05-
|
11
|
+
date: 2025-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clipboard
|
@@ -30,7 +30,8 @@ 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. 4.
|
33
|
+
upon utf-8 characters. 4.6: Fixed a broken pane.edit. Fixed ANSI termination bug
|
34
|
+
in RGB support.'
|
34
35
|
email: g@isene.com
|
35
36
|
executables: []
|
36
37
|
extensions: []
|