rcurses 3.4 → 3.4.1

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rcurses/pane.rb +11 -8
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '089c7b974ce66ffc1afdc8c70d6b5d354f11926894329367c4ac304fc56e7af4'
4
- data.tar.gz: 23e9d5853f8977ecc914a4cdbfce0a26570d9e3076415709a150c59b5ddc61df
3
+ metadata.gz: b639396f6e9ac9ac7fe77f5fcce3346abcbe6e54f0662a7655a684ff1fd65f54
4
+ data.tar.gz: 40d11e4c27a34f1e289f1e098e30110b176db829918cecbe310483f9c68b47cb
5
5
  SHA512:
6
- metadata.gz: 31a9cf284d90a1ead46acfc3f3f77c0777e6e879481e01203e2bb7219579b6d694d50c08d9af7beedcd7a355244bee5975b4f3d9b037827081430abf08363721
7
- data.tar.gz: d0f9ed3cdf1a29c10e1a732f61e62c2054ad549edb04398ea5a273c49730c7bdb567e16e59ee67ebdcc9d420499e1823f2c11b087b558bb7e3bfb71b1293b6b0
6
+ metadata.gz: 4a3e1b37d0067eaff67d6e84f0496f122774246d9a2497bc56d36cd169ea05748757fc7f62ea7e38b3321ad73fca8e7316daa91e4b1f097e3f0fb6f4567ceda8
7
+ data.tar.gz: b3fc5442eec96aae8eb82840bb751282983c2ef53fac8b814e3f103a8a1dc9dcbc4f1ef5768d8cc23fce686c43f51d47225fe536fb41bdd64bfee86420f49d23
data/lib/rcurses/pane.rb CHANGED
@@ -130,7 +130,9 @@ module Rcurses
130
130
  end
131
131
 
132
132
  o_row, o_col = pos
133
- STDOUT.print "\e[?25l" # Hide cursor
133
+
134
+ # Hide cursor and disable auto-wrap (minimal fix)
135
+ STDOUT.print "\e[?25l\e[?7l"
134
136
 
135
137
  fmt = [@fg, @bg].compact.join(',')
136
138
 
@@ -149,7 +151,7 @@ module Rcurses
149
151
  while @lazy_txt.size < required_lines && @lazy_index < @raw_txt.size
150
152
  raw_line = @raw_txt[@lazy_index]
151
153
  # If the raw line is short, no wrapping is needed.
152
- if raw_line.respond_to?(:pure) && raw_line.pure.length < @w
154
+ if raw_line.respond_to?(:pure) && Rcurses.display_width(raw_line.pure) < @w
153
155
  processed = [raw_line]
154
156
  else
155
157
  processed = split_line_with_ansi(raw_line, @w)
@@ -172,7 +174,7 @@ module Rcurses
172
174
  line_str = ""
173
175
  l = @ix + i
174
176
  if @txt[l].to_s != ""
175
- pl = @w - @txt[l].pure.length
177
+ pl = @w - Rcurses.display_width(@txt[l].pure)
176
178
  pl = 0 if pl < 0
177
179
  hl = pl / 2
178
180
  case @align
@@ -209,7 +211,8 @@ module Rcurses
209
211
  end
210
212
  end
211
213
 
212
- diff_buf << "\e[#{o_row};#{o_col}H"
214
+ # Re-enable wrap just before printing the final buffer
215
+ diff_buf << "\e[#{o_row};#{o_col}H\e[?7h"
213
216
  print diff_buf
214
217
  @prev_frame = new_frame
215
218
 
@@ -511,7 +514,7 @@ module Rcurses
511
514
  def calculate_posx
512
515
  total_length = 0
513
516
  (@ix + @line).times do |i|
514
- total_length += @txt[i].pure.length + 1 # +1 for newline
517
+ total_length += Rcurses.display_width(@txt[i].pure) + 1 # +1 for newline
515
518
  end
516
519
  total_length += @pos
517
520
  total_length
@@ -520,7 +523,7 @@ module Rcurses
520
523
  def calculate_line_start_pos
521
524
  total_length = 0
522
525
  (@ix + @line).times do |i|
523
- total_length += @txt[i].pure.length + 1
526
+ total_length += Rcurses.display_width(@txt[i].pure) + 1
524
527
  end
525
528
  total_length
526
529
  end
@@ -556,7 +559,7 @@ module Rcurses
556
559
  else
557
560
  words = token.scan(/\s+|\S+/)
558
561
  words.each do |word|
559
- word_length = word.gsub(ansi_regex, '').length
562
+ word_length = Rcurses.display_width(word.gsub(ansi_regex, ''))
560
563
  if current_line_length + word_length <= w
561
564
  current_line << word
562
565
  current_line_length += word_length
@@ -571,7 +574,7 @@ module Rcurses
571
574
  current_line << part
572
575
  result << current_line
573
576
  word = word[w..-1]
574
- word_length = word.gsub(ansi_regex, '').length
577
+ word_length = Rcurses.display_width(word.gsub(ansi_regex, ''))
575
578
  current_line = active_sequences.join
576
579
  current_line_length = 0
577
580
  end
metadata CHANGED
@@ -1,7 +1,7 @@
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
@@ -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: Added ansi_clean and
33
- full_refresh methods.'
32
+ in panes. Cursor movement around the terminal. New in 3.4.1: Fixed bug on handling
33
+ utf-8 characters.'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []