rcurses 2.4.5 → 2.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: 72fa40a32c3bd2d5b8d9b877570cef06ac7717923e5ceb00beb25ff604042d6f
4
- data.tar.gz: 4d98c839744b9715286ab94fe4d3f0e71c9c6ac2b755d9642b7ba2957c943200
3
+ metadata.gz: f120b89280037a3485515b1cc75f7a08f122fde4faff32b2234b602bb37dbecf
4
+ data.tar.gz: 71aa736312930bf945f8af1e021430e4ff9ce23be9a12402a3ec046c272f5055
5
5
  SHA512:
6
- metadata.gz: 530c8e9aa1f37ff1fabf89b70c03a6e572afddf6905d3a79d8c5a2f1e9f0ae582499e37168a9585b7e3ff0da1a49c6426e281fbc56d54884dd3cc610bd3575e9
7
- data.tar.gz: b9d7694f652427485d65317c931da8399139fdc25436e2526c91ef37b835bda2ed9ef7fe1a4652f9ba1dd6fe50ca3fdf42b7990b578617a3ebed0426868aa016
6
+ metadata.gz: fa2b26d81b024bd82cdeab5fc643072f4c4b1120cd96720a41926e5bafcc49c535b9df25242f534c99448a501000d3c30fd8331777f2eff03720472c3747182f
7
+ data.tar.gz: 2153244b482b08beb7234df2dd91fc542f438b6a814016ccdec68c32bd818e92744165bf10b87fa6a4d5167d30106a9bc7bcd4b259ab05eecb581112cbe8b2ab
data/lib/rcurses/pane.rb CHANGED
@@ -13,6 +13,10 @@ module Rcurses
13
13
  @starty = starty.is_a?(Proc) ? starty : -> { starty }
14
14
  @width = width.is_a?(Proc) ? width : -> { width }
15
15
  @height = height.is_a?(Proc) ? height : -> { height }
16
+ @x = @startx.call
17
+ @y = @starty.call
18
+ @w = @width.call
19
+ @h = @height.call
16
20
  @fg, @bg = fg, bg
17
21
  @text = "" # Initialize text variable
18
22
  @align = "l" # Default alignment
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: 2.4.2: Added parameters 'min' and 'time' to getchr
8
+ # Version: 2.4.6: Added x,y,w,h at panel creation, not just on refresh
9
9
 
10
10
  require 'io/console' # Basic gem for rcurses
11
11
  require 'io/wait' # stdin handling
@@ -60,10 +60,11 @@ class String
60
60
  result
61
61
  end
62
62
 
63
- # Injects the given string at the given visible character position.
64
- # A negative position is treated as an insertion at the end.
63
+ # Inserts the given substring at the provided visible character position.
64
+ # A negative position means insertion at the end.
65
+ # When inserting at the end and the string ends with an ANSI escape sequence,
66
+ # the insertion is placed before that trailing ANSI sequence.
65
67
  def inject(insertion, pos)
66
- # Work on visible text; if pos is negative, set it to the length (i.e. end).
67
68
  pure_text = self.pure
68
69
  visible_length = pure_text.length
69
70
  pos = visible_length if pos < 0
@@ -74,7 +75,7 @@ class String
74
75
  injected = false
75
76
 
76
77
  while i < self.length
77
- if self[i] == "\e" # ANSI escape sequence copy whole sequence without counting
78
+ if self[i] == "\e" # Start of an ANSI sequence.
78
79
  if m = self[i..-1].match(/\A(\e\[\d+(?:;\d+)*m)/)
79
80
  result << m[1]
80
81
  i += m[1].length
@@ -83,7 +84,6 @@ class String
83
84
  i += 1
84
85
  end
85
86
  else
86
- # At the point when we've output exactly pos visible characters, do the injection.
87
87
  if count == pos && !injected
88
88
  result << insertion
89
89
  injected = true
@@ -93,10 +93,18 @@ class String
93
93
  i += 1
94
94
  end
95
95
  end
96
- # In case pos equals the total visible length (i.e. insertion at the end) and
97
- # no injection has occurred inside the loop, append now.
98
- result << insertion unless injected
96
+
97
+ # If we haven't injected (i.e. pos equals visible_length),
98
+ # check for a trailing ANSI sequence and insert before it.
99
+ unless injected
100
+ if result =~ /(\e\[\d+(?:;\d+)*m)\z/
101
+ trailing = $1
102
+ result = result[0...-trailing.length] + insertion + trailing
103
+ else
104
+ result << insertion
105
+ end
106
+ end
107
+
99
108
  result
100
109
  end
101
110
  end
102
-
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: 2.4.5
4
+ version: 2.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-03-20 00:00:00.000000000 Z
11
+ date: 2025-03-21 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 2.4.5: Added functions ''shorten''
33
- and ''inject'' to the string class.'
32
+ in panes. Cursor movement around the terminal. New in 2.4.6: Added x,y,w,h at panel
33
+ creation, not just on refresh.'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []