rcurses 1.2 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -3
  3. data/lib/rcurses.rb +0 -0
  4. data/rcurses_example.rb +8 -6
  5. metadata +19 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13819fddc7eb95aa7c4b2efb691448d4d2038bf818f72e4f53a3fd932a4679f6
4
- data.tar.gz: b1029633d1f6149e4572418a6973d5fb6b427632885b38401c17b4548b26b030
3
+ metadata.gz: 81d2dc35832251275d8a1ffb15c8480e5824a19c4643fddf4c74a7ee2fd850d2
4
+ data.tar.gz: a3f96eb853a6a4700037a13623aca7e2d242894da905edc295067475cb7675a7
5
5
  SHA512:
6
- metadata.gz: 60092126289594c0558ccb359ff1bc153ba33294ac067a2575f550fbba079e8885f1ed43e6943d6a1f24e8e998625b2c87d2501dd453de7990146a31bd01b05b
7
- data.tar.gz: a4893f8a61283b33677bf15a8e3837429bdeeaf72bb27bd7358435ffb64fcfa764a0110ba69ce39f31cf619480699ad3a8162f2ca06ed6613efe096cdf1f4200
6
+ metadata.gz: 64971c51e33f0068c2dab3f0e2a3bae2b35e17ec2b6e2d81b5fd5cc35b61a5a8f7561f7af08d3147a043f93237d62dcea31c4860d2ebf5c7be2d08555c979303
7
+ data.tar.gz: aeb2ff504b4dd02822cac01fd25f5ff8423464e5b9f4cf12c08bf3b591d6c2b480e0ea3ab77d1d5ee51db6173913d74fbea528189b826e7139fe661b27141957
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  Having struggled with the venerable curses library and the ruby interface to it for many years, I finally got around to write an alternative - in pure Ruby.
10
10
 
11
11
  # Design principles
12
- Simple. One file. No external requirements.
12
+ Simple. One file. Minimum of external dependencies.
13
13
 
14
14
  # Installation
15
15
  Simply run `gem install rcurses`.
@@ -44,7 +44,15 @@ The format for creating a pane is:
44
44
  ```
45
45
  Rcurses::Pane.new(startx, starty, width, height, foregroundcolor, backgroundcolor)
46
46
  ```
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 "Rcurses::MAXh/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 `Rcurses::MAXh` for terminal height and `Rcurses::MAXw` for terminal width.
47
+ You can drop the last two 256-color codes to create a pane with the defaults for your terminal.
48
+
49
+ You can add anything as `startx`, `starty`, `width` or `height` as those values will be evaluated and stored in readable variables `x`, `y`, `w` and `h` respectively.
50
+
51
+ By adding values for the terminal size in your program:
52
+ ```
53
+ @max_h, @max_w = IO.console.winsize
54
+ ```
55
+ ...you can use these values to create proportinally sized panes. So, a hight value of "@max_h/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 `@max_h` for terminal height and `@max_w` for terminal width.
48
56
 
49
57
  Avaliable properties/variables:
50
58
 
@@ -196,7 +204,8 @@ end
196
204
  Try this in `irb`:
197
205
  ```
198
206
  require 'rcurses'
199
- mypane = Pane.new(Rcurses::MAXw/2, 30, 30, 10, 19, 229)
207
+ @max_h, @max_w = IO.console.winsize
208
+ mypane = Pane.new(@maxw/2, 30, 30, 10, 19, 229)
200
209
  mypane.border = true
201
210
  mypane.text = "Hello".i + " World!".b.i + "\n \n" + "rcurses".r + " " + "is cool".c("16,212")
202
211
  mypane.refresh
data/lib/rcurses.rb CHANGED
Binary file
data/rcurses_example.rb CHANGED
@@ -2,12 +2,14 @@
2
2
 
3
3
  require 'rcurses'
4
4
 
5
+ @max_h, @max_w = IO.console.winsize
6
+
5
7
  # Start by creating the panes; Format:
6
- # pane = Rcurses::Pane.new( startx, starty, width, height, fg, bg)
7
- pane_top = Rcurses::Pane.new( 1, 1, Rcurses::MAXw, 1, 255, 236)
8
- pane_bottom = Rcurses::Pane.new( 1, Rcurses::MAXh, Rcurses::MAXw, 1, 236, 254)
9
- pane_left = Rcurses::Pane.new( 2, 3, Rcurses::MAXw/2 - 2, Rcurses::MAXh - 4, 52, nil)
10
- pane_right = Rcurses::Pane.new(Rcurses::MAXw/2 + 1, 2, Rcurses::MAXw/2, Rcurses::MAXh - 2, 255, 52)
8
+ # pane = Rcurses::Pane.new( startx, starty, width, height, fg, bg)
9
+ pane_top = Rcurses::Pane.new( 1, 1, @max_w, 1, 255, 236)
10
+ pane_bottom = Rcurses::Pane.new( 1, @max_h, @max_w, 1, 236, 254)
11
+ pane_left = Rcurses::Pane.new( 2, 3, @max_w/2 - 2, @max_h - 4, 52, nil)
12
+ pane_right = Rcurses::Pane.new(@max_w/2 + 1, 2, @max_w/2, @max_h - 2, 255, 52)
11
13
 
12
14
  pane_left.border = true # Adding a border to the left pane
13
15
 
@@ -23,7 +25,7 @@ pane_right.refresh # ...and the right pane
23
25
  pane_bottom.editline # Do not use a refresh before editline
24
26
 
25
27
  # Then create a "pop-up" pane in the middle of the screen
26
- pane_mid = Rcurses::Pane.new(Rcurses::MAXw/2 - 10, Rcurses::MAXh/2 - 5, 20, 10, 18, 254)
28
+ pane_mid = Rcurses::Pane.new(@max_w/2 - 10, @max_h/2 - 5, 20, 10, 18, 254)
27
29
  pane_mid.border = true
28
30
  pane_mid.text = "You wrote:" + "\n" + pane_bottom.text.i
29
31
  pane_mid.align = "c"
metadata CHANGED
@@ -1,21 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcurses
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: '2.0'
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-26 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2024-12-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: clipboard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  description: 'Create panes (with the colors and(or border), manipulate the panes and
14
28
  add content. Dress up text (in panes or anywhere in the terminal) in bold, italic,
15
29
  underline, reverse color, blink and in any 256 terminal colors for foreground and
16
30
  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. New in 1.2: Handling
18
- original newlines with ansi carry-over.'
31
+ center align text in panes. Cursor movement around the terminal. New in 2.0: Complete
32
+ code refactoring.'
19
33
  email: g@isene.com
20
34
  executables: []
21
35
  extensions: