rcurses 2.8 → 2.10

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: c57e93f49709d2dc006240468b49f490abbcff381822edf82eac545de3961ebe
4
- data.tar.gz: 92db5bb428787143a9a6bf63508a3301410ab1f06d69ac4fbb5268d33cce1887
3
+ metadata.gz: 24a1261f7feb08089088cd39e074ce58d7b31db2577c5d172cc702ca91c99341
4
+ data.tar.gz: fe64f92207aad03e6d6b7c0e8cdf61503a0e3c69dc69386f137cb16c1af80956
5
5
  SHA512:
6
- metadata.gz: ffd05a2f1fc8ad273a1e619d0a4ea892c8edd974bcb95dfd42590a969df8eeca7af8f2c675418b8beb90eb751216894539494e208d9eb566aefe2f6a8ef84ea6
7
- data.tar.gz: cdc84b82cb1361a8132c2885905d2029290adbbaa385b53f9a02321c8d1aa84ab54bd38844114bb843c57eaaa4f63fae921fb9f10ba2720c207cc4e928d1af38
6
+ metadata.gz: de7a10ba81e044649267600766fdc49df41969bfdd37db99be7b82883288e3120e51558ad7052cc8d5b766d09c792fc2c8570792e2da2b2f7e6b9de5f5a29cac
7
+ data.tar.gz: 2e8fb40766d423138f6bf4fa29c040285c800ca6c9b68e155fc3106cf31eddb585176d622fda17b1327661e9acc452c15434dd56a977f7b6d4eabe711674ecf2
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # rcurses - An alternative curses library written in pure Ruby
2
2
 
3
3
  ![Ruby](https://img.shields.io/badge/language-Ruby-red) [![Gem Version](https://badge.fury.io/rb/rcurses.svg)](https://badge.fury.io/rb/rcurses) ![Unlicense](https://img.shields.io/badge/license-Unlicense-green) ![Stay Amazing](https://img.shields.io/badge/Stay-Amazing-important)
4
-
4
+
5
5
  <img src="img/rcurses-logo.png" width="150" height="150">
6
6
 
7
7
  Create curses applications for the terminal easier than ever.
@@ -69,6 +69,8 @@ text | The text/content of the Pane
69
69
  ix | "Index" - the line number at the top of the Pane, starts at 0, the first line of text in the Pane
70
70
  align | Text alignment in the Pane: "l" = lefts aligned, "c" = center, "r" = right, with the default "l"
71
71
  prompt | The prompt to print at the beginning of a one-liner Pane used as an input box
72
+ moreup | Set to true when there is more text above what is shown (top scroll bar i showing)
73
+ moredown | Set to true when there is more text below what is shown (bottom scroll bar i showing)
72
74
 
73
75
  The methods for Pane:
74
76
 
@@ -108,6 +110,9 @@ inject("chars",pos) | Inject "chars" at position 'pos' in the pure version of th
108
110
 
109
111
  PS: Blink does not work in conjunction with setting a background color in urxvt. It does work in gnome-terminal. But the overall performance in urxvt as orders of magnitude better than gnome-terminal.
110
112
 
113
+ # Cleaning up upon exit
114
+ End a program with `Rcurses.clear_screen` to clear the screen for any rcurses residues.
115
+
111
116
  # module Cursor
112
117
  To use this module, first do `include Rcurses::Cursor`. Create a new cursor object with `mycursor = Rcurses::Cursor`. Then you can apply the following methods to `mycursor`:
113
118
 
@@ -147,12 +152,16 @@ Key pressed | string returned
147
152
  ----------------|----------------------------------------------------------
148
153
  `esc` | "ESC"
149
154
  `up` | "UP"
155
+ `shift-up` | "S-UP"
150
156
  `ctrl-up` | "C-UP"
151
157
  `down` | "DOWN"
158
+ `shift-down` | "S-DOWN"
152
159
  `ctrl-down` | "C-DOWN"
153
160
  `right` | "RIGHT"
161
+ `shift-right` | "S-RIGHT"
154
162
  `ctrl-right` | "C-RIGHT"
155
163
  `left` | "LEFT"
164
+ `shifth-left` | "S-LEFT"
156
165
  `ctrl-left` | "C-LEFT"
157
166
  `shift-tab` | "S-TAB"
158
167
  `insert` | "INS"
@@ -0,0 +1,6 @@
1
+ module Rcurses
2
+ def self.clear_screen
3
+ # ANSI code \e[2J clears the screen, and \e[H moves the cursor to the top left.
4
+ print "\e[2J\e[H"
5
+ end
6
+ end
data/lib/rcurses/input.rb CHANGED
@@ -21,9 +21,13 @@ module Rcurses
21
21
  third_char = $stdin.getc
22
22
  case third_char
23
23
  when 'A' then chr = "UP"
24
+ when 'a' then chr = "S-UP"
24
25
  when 'B' then chr = "DOWN"
26
+ when 'b' then chr = "S-DOWN"
25
27
  when 'C' then chr = "RIGHT"
28
+ when 'c' then chr = "S-RIGHT"
26
29
  when 'D' then chr = "LEFT"
30
+ when 'd' then chr = "S-LEFT"
27
31
  when 'Z' then chr = "S-TAB"
28
32
  when '1'
29
33
  fourth_char = $stdin.getc
data/lib/rcurses/pane.rb CHANGED
@@ -5,6 +5,7 @@ module Rcurses
5
5
  include Input
6
6
  attr_accessor :x, :y, :w, :h, :fg, :bg
7
7
  attr_accessor :border, :scroll, :text, :ix, :align, :prompt
8
+ attr_accessor :moreup, :moredown
8
9
 
9
10
  def initialize(x = 1, y = 1, w = 1, h = 1, fg = nil, bg = nil)
10
11
  @x = x
@@ -216,12 +217,18 @@ module Rcurses
216
217
 
217
218
  if @ix > 0 and @scroll # Print "more" marker at top
218
219
  col(@x + @w - 1); row(@y)
219
- print "".c(fmt)
220
+ print "".c(fmt)
221
+ @moreup = true
222
+ else
223
+ @moreup = false
220
224
  end
221
225
 
222
226
  if @txt.length - @ix > @h and @scroll # Print bottom "more" marker
223
227
  col(@x + @w - 1); row(@y + @h - 1)
224
- print "".c(fmt)
228
+ print "".c(fmt)
229
+ @moredown = true
230
+ else
231
+ @moredown = false
225
232
  end
226
233
 
227
234
  if @border # Print border if @border is set to true
data/lib/rcurses.rb CHANGED
@@ -5,13 +5,14 @@
5
5
  # Web_site: http://isene.com/
6
6
  # Github: https://github.com/isene/rcurses
7
7
  # License: Public domain
8
- # Version: 2.4.7: Fixed getchr timeout, added panel function 'ask'
8
+ # Version: 2.10: Added key captures for S-UP, S-DOWN, S-LEFT and S-RIGHT. added pane properties 'moreup' and 'moredown'
9
9
 
10
10
  require 'io/console' # Basic gem for rcurses
11
11
  require 'io/wait' # stdin handling
12
12
  require 'timeout'
13
13
 
14
14
  require_relative 'string_extensions'
15
+ require_relative 'rcurses/general'
15
16
  require_relative 'rcurses/cursor'
16
17
  require_relative 'rcurses/input'
17
18
  require_relative 'rcurses/pane'
@@ -11,6 +11,9 @@ class String
11
11
 
12
12
  # Internal function
13
13
  def color(text, sp, ep = "\e[0m")
14
+ # Replace every newline with a newline followed by the start sequence,
15
+ # so that formatting is reestablished on each new line.
16
+ text = text.gsub("\n", "#{ep}\n#{sp}")
14
17
  "#{sp}#{text}#{ep}"
15
18
  end
16
19
 
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.8'
4
+ version: '2.10'
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-27 00:00:00.000000000 Z
11
+ date: 2025-03-30 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.8: Added lineup and linedown
33
- methods to pane and more key captures to Rcurses::Input.'
32
+ in panes. Cursor movement around the terminal. New in 2.10: Added key captures for
33
+ S-UP, S-DOWN, S-LEFT and S-RIGHT. added pane properties ''moreup'' and ''moredown''.'
34
34
  email: g@isene.com
35
35
  executables: []
36
36
  extensions: []
@@ -42,6 +42,7 @@ files:
42
42
  - examples/focus_panes.rb
43
43
  - lib/rcurses.rb
44
44
  - lib/rcurses/cursor.rb
45
+ - lib/rcurses/general.rb
45
46
  - lib/rcurses/input.rb
46
47
  - lib/rcurses/pane.rb
47
48
  - lib/string_extensions.rb