rcurses 4.6 → 4.7

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -14
  3. data/lib/rcurses/pane.rb +1 -1
  4. data/lib/rcurses.rb +42 -1
  5. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 240aec267dd4c5e8377ffba6844848463a8d4a0c5291f159f354e9c600e6a264
4
- data.tar.gz: 3d3534900f41903901758496d0ed0494c400c6ca45dfbd9eb3265b1b924fd108
3
+ metadata.gz: 5bd13b6d8edf4884599788ea2ab4ee0cd74e19c76dd5d8816fee9a8c39af2ed7
4
+ data.tar.gz: 710c11b21962f2c833b109dd1991a4e61994db67609ffa41f85ceca7d8f08aaf
5
5
  SHA512:
6
- metadata.gz: 92a3f431d49eb85bd4c2a25429acfe87acb2cb1a553c4ebad78614f3e34c3f9bcd23037b725b72a117404fa22397a8d5e8a6ba0d1b6193b227c126bcb4f87e80
7
- data.tar.gz: 07e0d869aa2025be468a98d359ef2f1894751b301c5ec37965fe75b6bb97bec452b01bcd67c6ddb3fa6a08fe7f7289d85082eaf0153ac6b487d70d417759e1eb
6
+ metadata.gz: 6ba8e09362dd518bf485d0e5d725fe421fe1fa70d03827878581d75c9296645b7edef9450881ae4403fd9fe9fa64208c58d3b196b194d27dd8021bf990bb5e13
7
+ data.tar.gz: b1bd57631466afd0da235ee5c4e34e9124c6fd15a40bb2db44bb4ddcf9c8a54d8809c593ed580d64200fab02a4bed315723bb5ad48731f165ed9867453810a3e
data/README.md CHANGED
@@ -73,7 +73,8 @@ bg | Background color for the Pane
73
73
  border | Draw border around the Pane (=true) or not (=false), default being false
74
74
  scroll | Whether to indicate more text to be shown above/below the Pane, default is true
75
75
  text | The text/content of the Pane
76
- ix | "Index" - the line number at the top of the Pane, starts at 0, the first line of text in the Pane
76
+ ix | The line number at the top of the Pane, starts at 0, the first line of text in the Pane
77
+ index | An attribute that can be used to track the selected line/element in the pane
77
78
  align | Text alignment in the Pane: "l" = lefts aligned, "c" = center, "r" = right, with the default "l"
78
79
  prompt | The prompt to print at the beginning of a one-liner Pane used as an input box
79
80
  moreup | Set to true when there is more text above what is shown (top scroll bar i showing)
@@ -88,7 +89,7 @@ move(x,y) | Move the pane by `x`and `y` (`mypane.move(-4,5)` will move the
88
89
  refresh | Refreshes/redraws the Pane with content
89
90
  border_refresh | Refresh the Pane border only
90
91
  full_refresh | Refreshes/redraws the Pane with content completely (without diff rendering)
91
- edit | An editor for the Pane. When this is invoked, all existing font dressing is stripped and the user gets to edit the raw text. The user can add font effects similar to Markdown; Use an asterisk before and after text to be drawn in bold, text between forward-slashes become italic, and underline before and after text means the text will be underlined, a hash-sign before and after text makes the text reverse colored. You can also combine a whole set of dressings in this format: `<23,245,biurl|Hello World!>` - this will make "Hello World!" print in the color 23 with the background color 245 (regardless of the Pane's fg/bg setting) in bold, italic, underlined, reversed colored and blinking. Hitting `ESC` while in edit mode will disregard the edits, while `Ctrl-S` will save the edits
92
+ edit | An editor for the Pane. When this is invoked, all existing font dressing is stripped and the user gets to edit the raw text. The user can add font effects similar to Markdown; Use an asterisk before and after text to be drawn in bold, text between forward-slashes become italic, and underline before and after text means the text will be underlined, a hash-sign before and after text makes the text reverse colored. You can also combine a whole set of dressings in this format: `<23,245,biurl\|Hello World!>` - this will make "Hello World!" print in the color 23 with the background color 245 (regardless of the Pane's fg/bg setting) in bold, italic, underlined, reversed colored and blinking. Hitting `ESC` while in edit mode will disregard the edits, while `Ctrl-S` will save the edits
92
93
  editline | Used for one-line Panes. It will print the content of the property `prompt` and then the property `text` that can then be edited by the user. Hitting `ESC` will disregard the edits, while `ENTER` will save the edited text
93
94
  clear | Clears the pane
94
95
  say(text) | Short form for setting panel.text, then doing a refresh of that panel
@@ -115,7 +116,7 @@ i | Set text to be printed in italic (example: `"TEST".i`)
115
116
  u | Set text to be printed underlined (example: `"TEST".u`)
116
117
  l | Set text to be printed blinking (example: `"TEST".l`)
117
118
  r | Set text to be printed in reverse colors (example: `"TEST".r`)
118
- c(code) | Use coded format like "TEST".c("204,45,bui") to print "TEST" in bold, underline italic, fg=204 and bg=45 (the format is `.c("fg,bg,biulr"))
119
+ c(code) | Use coded format like "TEST".c("204,45,bui") to print "TEST" in bold, underline italic, fg=204 and bg=45 (the format is `.c("fg,bg,biulr")`)
119
120
  pure | Strip text of any "dressing" (example: with `text = "TEST".b`, you will have bold text in the variable `text`, then with `text.pure` it will show "uncoded" or pure text)
120
121
  ansi_clean | Strip seemingly uncolored strings of ansi code (those that are enclosed in "\e[0m"
121
122
  shorten(n) | Shorten the pure version of the string to 'n' characters, preserving any ANSI coding
@@ -249,17 +250,6 @@ mypane.edit
249
250
 
250
251
  And - try running the example file `rcurses_example.rb`.
251
252
 
252
- # Clean exit for your application
253
- To restore the terminal fully after you exit your application, add this:
254
- ```
255
- at_exit do # Always restore terminal state on quit (or fatal)
256
- $stdin.cooked!
257
- $stdin.echo = true
258
- Rcurses.clear_screen
259
- Cursor.show
260
- end
261
- ```
262
-
263
253
  # Not yet implemented
264
254
  Let me know what other features you like to see.
265
255
 
data/lib/rcurses/pane.rb CHANGED
@@ -33,7 +33,7 @@ module Rcurses
33
33
  include Cursor
34
34
  include Input
35
35
  attr_accessor :x, :y, :w, :h, :fg, :bg
36
- attr_accessor :border, :scroll, :text, :ix, :align, :prompt
36
+ attr_accessor :border, :scroll, :text, :ix, :index, :align, :prompt
37
37
  attr_accessor :moreup, :moredown
38
38
  attr_accessor :record, :history
39
39
 
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: 4.5: Full RGB support in addition to 256-colors
8
+ # Version: 4.7: Removed the need for user templates on startup/exit. Added attr 'index' to pane
9
9
 
10
10
  require 'io/console' # Basic gem for rcurses
11
11
  require 'io/wait' # stdin handling
@@ -17,4 +17,45 @@ require_relative 'rcurses/cursor'
17
17
  require_relative 'rcurses/input'
18
18
  require_relative 'rcurses/pane'
19
19
 
20
+ module Rcurses
21
+ class << self
22
+ # Public: Initialize Rcurses. Switches terminal into raw/no-echo
23
+ # and registers cleanup handlers. Idempotent.
24
+ def init!
25
+ return if @initialized
26
+ return unless $stdin.tty?
27
+
28
+ # enter raw mode, disable echo
29
+ $stdin.raw!
30
+ $stdin.echo = false
31
+
32
+ # ensure cleanup on normal exit
33
+ at_exit { cleanup! }
34
+
35
+ # ensure cleanup on signals
36
+ %w[INT TERM].each do |sig|
37
+ trap(sig) { cleanup!; exit }
38
+ end
39
+
40
+ @initialized = true
41
+ end
42
+
43
+ # Public: Restore terminal to normal mode, clear screen, show cursor.
44
+ # Idempotent: subsequent calls do nothing.
45
+ def cleanup!
46
+ return if @cleaned_up
47
+
48
+ $stdin.cooked!
49
+ $stdin.echo = true
50
+ Rcurses.clear_screen
51
+ Cursor.show
52
+
53
+ @cleaned_up = true
54
+ end
55
+ end
56
+
57
+ # Kick off initialization as soon as the library is required.
58
+ init!
59
+ end
60
+
20
61
  # vim: set sw=2 sts=2 et filetype=ruby fdn=2 fcs=fold\:\ :
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.6'
4
+ version: '4.7'
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-06 00:00:00.000000000 Z
11
+ date: 2025-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -30,8 +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.6: Fixed a broken pane.edit. Fixed ANSI termination bug
34
- in RGB support.'
33
+ upon utf-8 characters. 4.7: Removed the need for user templates on startup/exit.
34
+ Added attr ''index'' to pane.'
35
35
  email: g@isene.com
36
36
  executables: []
37
37
  extensions: []