rcurses 0.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -9
  3. data/lib/rcurses.rb +0 -0
  4. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c653bbbd37d3eb63b73b4b31610e5c3aa38026fbefab2fe286037597af3edaa
4
- data.tar.gz: 3b8114bd0899f50dae09e1deeb107b45293b5fe55c24ff92f07cb9b536288cb1
3
+ metadata.gz: a0411fe63ee57de3eec47170eb8367708f18ea848fd88ecbe14cca62ae11e40e
4
+ data.tar.gz: 9b500a1a7df79b63cb7ef0d8a8775ff9ea32dce7354842c6ccbed0623c9566ee
5
5
  SHA512:
6
- metadata.gz: 75d19d87bdd770831b22f1c507ead604231cf0607ac51932d485411d84e9ff0b02405541c23ccb370e88534384fd67c1220461fd00dfe9179b5266cbbe91118d
7
- data.tar.gz: 14872c98ff9edcc649998066d0f817ec306b5caa06e59329ecfad84b0a42c970fa0f2061dfbe5259ed5be9e8d35027b97b0ebf14a1cdb98af00494eb25e318b4
6
+ metadata.gz: a56c0c656ca11e0e6b5fc4823c6ad427a28bf75b1fc51df12d29ea0cd60b214d2581b8df3354a4d034f0af56b2c0a3ed6c7ba00a914e9aab3bef4645912a4fbf
7
+ data.tar.gz: 62467880b4c9b8e56ed68070e6d5bc8bd8e0cc3d2050a51f225c22ad6a64aacb3a2e5d64835b377d7269ee428ae612e17e358e1789a343d0d5be80f482e07c24
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # rcurses - An alternative curses library written in pure Ruby
2
2
 
3
- ![Ruby](https://img.shields.io/badge/language-Ruby-red) ![Unlicense](https://img.shields.io/badge/license-Unlicense-green) ![Stay Amazing](https://img.shields.io/badge/Stay-Amazing-important)
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
 
@@ -12,9 +12,7 @@ Having struggled with the venerable curses library and the ruby interface to it
12
12
  Simple. One file. No external requirements.
13
13
 
14
14
  # Installation
15
- Clone this repo and drop `lib/rcurses.rb` into `/usr/lib/ruby/vendor_ruby/`
16
-
17
- Or simply run `gem install rcurses`.
15
+ Simply run `gem install rcurses`.
18
16
 
19
17
  To use this library do:
20
18
  ```
@@ -33,18 +31,18 @@ require 'rcurses'
33
31
  * The class `Pane` to create and manilpulate panes/boxes
34
32
  * Extensions to the class String to print text in various degrees of fancy and also strip any fanciness
35
33
  * A module `Cursor` to give you cursor movements around the terminal
36
- * A top level function `getchr` to capture a single character input from the user (much better than any Ruby built-ins)
34
+ * A module `Rinput` providing the function `getchr` to capture a single character input from the user (much better than any Ruby built-ins)
37
35
 
38
36
  # class Pane
39
37
  To create a pane do something like this:
40
38
  ```
41
- mypane = Pane.new(80, 30, 30, 10, 19, 229)
39
+ mypane = Rcurses::Pane.new(80, 30, 30, 10, 19, 229)
42
40
  ```
43
41
  This will create a pane/box starting at terminal column/x 80 and row/y 30 with the width of 30 characters and a hight of 10 characters and with the foreground color 19 and background color 229 (from the 256 choices available)
44
42
 
45
43
  The format for creating a pane is:
46
44
  ```
47
- Pane.new(startx, starty, width, height, foregroundcolor, backgroundcolor)
45
+ Rcurses::Pane.new(startx, starty, width, height, foregroundcolor, backgroundcolor)
48
46
  ```
49
47
  You can drop the last two 256-color codes to create a pane with the defaults for your terminal. Also, you can add anything as `startx`, `starty`, `width` or `height` as those values will be run through a Ruby eval and stored in readable variables `x`, `y`, `w` and `h` respectively. So, a hight value of "@maxrow/2" is valid to create a pane with the height of half the terminal height (the integer corresponding to half the terminal height will then be accessible as the variable `h`). Use the variables @maxrow for terminal height and @maxcol for terminal width.
50
48
 
@@ -95,6 +93,8 @@ r | Set text to be printed in reverse colors (example: `"TEST".r`)
95
93
  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"))
96
94
  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)
97
95
 
96
+ 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.
97
+
98
98
  # module Cursor
99
99
  Create a new cursor object with `mycursor = Cursor`. Then you can apply the following methods to `mycursor`:
100
100
 
@@ -121,10 +121,14 @@ scroll_up | Scroll display up one line
121
121
  scroll_down | Scroll display down one line
122
122
  clear_screen_down | Clear screen down from current row
123
123
 
124
- # function getchr
124
+ # Rinput::getchr
125
125
  rcurses provides a vital extension to Ruby in reading characters entered by the user. This is especially needed for curses applications where readline inputs are required.
126
126
 
127
- Simply use `chr = getchr` in a program to read any character input by the user. The returning code (the content of `chr` in this example could be any of the following:
127
+ To include this into your curses program, first:
128
+ ```
129
+ include Rinput
130
+ ```
131
+ Then simply use `chr = getchr` in a program to read any character input by the user. The returning code (the content of `chr` in this example could be any of the following:
128
132
 
129
133
  Key pressed | string returned
130
134
  ----------------|----------------------------------------------------------
@@ -190,6 +194,19 @@ while $stdin.ready?
190
194
  end
191
195
  ```
192
196
 
197
+ # Example
198
+
199
+ Try this in `irb`:
200
+ ```
201
+ require 'rcurses'
202
+ mypane = Pane.new("@maxcol/2", 30, 30, 10, 19, 229)
203
+ mypane.border = true
204
+ mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
205
+ mypane.refresh
206
+ mypane.edit
207
+ ```
208
+ ... and then try to add some bold text by enclosing it in '*' and italics by enclosing text in '/'. Then press 'ctrl-s' to save your edited text - and then type `mypane.refresh` to see the result.
209
+
193
210
  # Not yet implemented
194
211
  Let me know what other features you like to see.
195
212
 
data/lib/rcurses.rb CHANGED
Binary file
metadata CHANGED
@@ -1,20 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcurses
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-16 00:00:00.000000000 Z
11
+ date: 2024-11-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Create panes (with the colors and(or border), manipulate the panes and
13
+ description: 'Create panes (with the colors and(or border), manipulate the panes and
14
14
  add content. Dress up text (in panes or anywhere in the terminal) in bold, italic,
15
15
  underline, reverse color, blink and in any 256 terminal colors for foreground and
16
16
  background. Use a simple editor to let users edit text in panes. Left, right or
17
- center align text in panes. Cursor movement around the terminal.
17
+ center align text in panes. Cursor movement around the terminal. New in 0.4: Code-reorganization
18
+ and bugfix.'
18
19
  email: g@isene.com
19
20
  executables: []
20
21
  extensions: