rcurses 5.1.2 → 5.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/rcurses/pane.rb +28 -5
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67b18a3ec884ebcbb7d0a55f6953bad3a55feba14163ea64ed538fbc2b00131f
4
- data.tar.gz: 721fa5b171684ade0adf15d146afcbb7344b3ac26a01cf6e817f0568ed8d193e
3
+ metadata.gz: c4d7bebb69ba43f7cc3d5bcb19898b554d06ca7d238c826f2222822ab699e5a0
4
+ data.tar.gz: 2e96402c39a1005574b32014a42e20088d900ca79734938b45586bc45826b299
5
5
  SHA512:
6
- metadata.gz: a32d358968c1dae62f7a6448661d00341cb9aa2914d26cb012d0b5a3e12cfbf4f98d86ebba647d177fbdc93ff8a98e66bc857e61575e0d814b395fcdd74c34e2
7
- data.tar.gz: 0257001adf843da5f38afebee39bce279eb2ae873455faf61764b02f883fd6ecd91746d8980943bb51503104ffb1fad7511d6220ecd237bc2197758575682431
6
+ metadata.gz: de02f1b55081905e4a34ac88ee15e39f3ca7c0d08e57e01f7513cd5100647c38f8db25ddfcb56797bf31311d5e0e51c26bede41a0c74a1d72811b678c7492396
7
+ data.tar.gz: 66f9f70ac65f4e481dafa257cb7bea926e22f7fbc4a107abacfd0c21cf9fc2bed8d63bac413ac395be68855a00deb1bf5dc39f2a4658ca3f501a08d46b8c2e8c
data/README.md CHANGED
@@ -248,7 +248,7 @@ Try this in `irb`:
248
248
  ```
249
249
  require 'rcurses'
250
250
  @max_h, @max_w = IO.console.winsize
251
- mypane = Pane.new(@max_w/2, 30, 30, 10, 19, 229)
251
+ mypane = Rcurses::Pane.new(@max_w/2, 30, 30, 10, 19, 229)
252
252
  mypane.border = true
253
253
  mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
254
254
  mypane.refresh
data/lib/rcurses/pane.rb CHANGED
@@ -255,9 +255,12 @@ module Rcurses
255
255
  pl = @w - Rcurses.display_width(@txt[l].pure)
256
256
  pl = 0 if pl < 0
257
257
  hl = pl / 2
258
- # Skip color application if pane has no colors set or text has ANY ANSI codes
259
- if @skip_colors || @txt[l].include?("\e[")
260
- # Don't apply pane colors - text already has ANSI sequences
258
+
259
+ # Check if text has ANSI background colors (48 or 4x codes)
260
+ has_bg_color = @txt[l] =~ /\e\[(?:\d+;)*4[0-9](?:;\d+)*m/ || @txt[l] =~ /\e\[(?:\d+;)*48(?:;\d+)*m/
261
+
262
+ if @skip_colors || (@txt[l].include?("\e[") && !@bg)
263
+ # No pane colors to apply, or text has ANSI but pane has no bg
261
264
  case @align
262
265
  when "l"
263
266
  line_str = @txt[l] + " " * pl
@@ -266,8 +269,28 @@ module Rcurses
266
269
  when "c"
267
270
  line_str = " " * hl + @txt[l] + " " * (pl - hl)
268
271
  end
272
+ elsif @txt[l].include?("\e[") && @bg && !has_bg_color
273
+ # Text has ANSI codes but no bg color - apply pane fg and bg to text and padding
274
+ case @align
275
+ when "l"
276
+ line_str = @txt[l].c(fmt) + " ".c(fmt) * pl
277
+ when "r"
278
+ line_str = " ".c(fmt) * pl + @txt[l].c(fmt)
279
+ when "c"
280
+ line_str = " ".c(fmt) * hl + @txt[l].c(fmt) + " ".c(fmt) * (pl - hl)
281
+ end
282
+ elsif @txt[l].include?("\e[") && has_bg_color
283
+ # Text has its own bg color - preserve it, only apply pane bg to padding
284
+ case @align
285
+ when "l"
286
+ line_str = @txt[l] + " ".c(fmt) * pl
287
+ when "r"
288
+ line_str = " ".c(fmt) * pl + @txt[l]
289
+ when "c"
290
+ line_str = " ".c(fmt) * hl + @txt[l] + " ".c(fmt) * (pl - hl)
291
+ end
269
292
  else
270
- # Apply pane colors normally
293
+ # No ANSI codes - apply pane colors normally
271
294
  case @align
272
295
  when "l"
273
296
  line_str = @txt[l].c(fmt) + " ".c(fmt) * pl
@@ -278,7 +301,7 @@ module Rcurses
278
301
  end
279
302
  end
280
303
  else
281
- # Empty line - only apply colors if pane has them
304
+ # Empty line
282
305
  line_str = @skip_colors ? " " * @w : " ".c(fmt) * @w
283
306
  end
284
307
 
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: 5.1.2
4
+ version: 5.1.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-08-13 00:00:00.000000000 Z
11
+ date: 2025-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard