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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 494b705528b9bb3e5040c9ecf8c1ff31c7cf0db13e04736140f35298d49b48b0
4
- data.tar.gz: 6f74dc4880397c55461c6ff0f5a6371edec67edfdfb3eb3d65d7dafdc5ac6295
3
+ metadata.gz: 240aec267dd4c5e8377ffba6844848463a8d4a0c5291f159f354e9c600e6a264
4
+ data.tar.gz: 3d3534900f41903901758496d0ed0494c400c6ca45dfbd9eb3265b1b924fd108
5
5
  SHA512:
6
- metadata.gz: 0cbed1ef8307fd124d035dce74501d58f648668884ae50190d82460d33b3825557ccd1f07b4c0a64d7b69c81a0c1ef240cf1828adc769e96ffd9bfb47d3e7f08
7
- data.tar.gz: 0f7747ce65c0f8103759b8df5e64bceee0bf7593d137380a08b6002ec6cbaeb3540236f9ebc65b1f28f293ed009b76565fe4e0fd63cdcb2bf597dd32430107cc
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
- Rcurses::Cursor.show
368
+ # Prepare content with visible newline markers
369
369
  content = @text.pure.gsub("\n", "¬\n")
370
- @ix = 0
371
- @line = 0
372
- @pos = 0
373
- @txt = refresh(content)
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 = refresh(content)
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
@@ -1,25 +1,25 @@
1
1
  # string_extensions.rb
2
2
 
3
3
  class String
4
- # 256-color or truecolor RGB foreground
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
- r, g, b = color.scan(/../).map { |c| c.to_i(16) }
8
- ["\e[38;2;#{r};#{g};#{b}m", "\e[0m"]
9
- else
10
- ["\e[38;5;#{color}m", "\e[0m"]
11
- end
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 background
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
- r, g, b = color.scan(/../).map { |c| c.to_i(16) }
19
- ["\e[48;2;#{r};#{g};#{b}m", "\e[0m"]
20
- else
21
- ["\e[48;5;#{color}m", "\e[0m"]
22
- end
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[0m")
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.5'
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-03 00:00:00.000000000 Z
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.5: Full RGB support in addition to 256-colors.'
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: []