rubytext 0.0.84 → 0.0.85
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -19
- data/examples/demo.rb +1 -1
- data/examples/multitest.rb +1 -1
- data/examples/prog01.rb +1 -1
- data/examples/prog02.rb +1 -1
- data/examples/prog03.rb +1 -1
- data/examples/prog04.rb +1 -1
- data/examples/prog05.rb +1 -1
- data/examples/prog06.rb +1 -1
- data/examples/prog07.rb +1 -1
- data/examples/prog08.rb +1 -1
- data/examples/prog09.rb +1 -1
- data/examples/prog10.rb +1 -1
- data/examples/prog11.rb +1 -1
- data/examples/prog12.rb +1 -1
- data/examples/prog13.rb +1 -1
- data/examples/prog14.rb +1 -1
- data/examples/prog15.rb +1 -1
- data/examples/prog16.rb +1 -1
- data/examples/prog17.rb +1 -1
- data/examples/prog18.rb +1 -1
- data/examples/prog19.rb +1 -1
- data/examples/prog20.rb +1 -1
- data/examples/prog20a.rb +1 -1
- data/examples/prog21.rb +1 -1
- data/examples/prog23.rb +1 -1
- data/examples/showme.rb +1 -1
- data/lib/menu.rb +2 -2
- data/lib/settings.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/widgets.rb +1 -1
- data/tutorial/colortest.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da6c7f728561feb7074a8736b19eba3f9d5a1a01b41ebdd5c479762393a37dac
|
4
|
+
data.tar.gz: '01181ad2cee1b8a24e9084074c8a27d28c8230288e45d249daa47ddac067be8c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f1f5637c3c0d05ed11a879180077eaa144d37de4125622a8d6f39163d3103e7acb774d5c8a91ff25d45760048bf056b64a0da623e35b9546b79e8d30a9ffbd6
|
7
|
+
data.tar.gz: d7ad8cdc8d86231dc34029085e085a25328480f31df2a10be7c82c44f73ec0d818dbbef629735143f9b489e437acb6089207fcb38aa8ffd1e86fe42a95932a15
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ directory and the `showme.rb` script.
|
|
46
46
|
A simple window:
|
47
47
|
```ruby
|
48
48
|
require 'rubytext'
|
49
|
-
win = RubyText.window(6, 25, 2, 34,
|
49
|
+
win = RubyText.window(6, 25, r: 2, c: 34,
|
50
50
|
# 6 rows, 25 cols; upper left at 2,4
|
51
51
|
fg: Blue, bg: White) # foreground, background
|
52
52
|
|
@@ -59,7 +59,7 @@ win.puts "This is a window..."
|
|
59
59
|
How `output` works. This name may change.
|
60
60
|
```ruby
|
61
61
|
require 'rubytext'
|
62
|
-
win = RubyText.window(9, 36, 2, 6, fg: White, bg: Red)
|
62
|
+
win = RubyText.window(9, 36, r: 2, c: 6, fg: White, bg: Red)
|
63
63
|
|
64
64
|
win.output do
|
65
65
|
puts "Because this code uses #output,"
|
@@ -71,7 +71,7 @@ end
|
|
71
71
|
Windows are bordered by default.
|
72
72
|
```ruby
|
73
73
|
require 'rubytext'
|
74
|
-
win = RubyText.window(9, 35, 3, 7, border: false, fg: Black, bg: Green)
|
74
|
+
win = RubyText.window(9, 35, r: 3, c: 7, border: false, fg: Black, bg: Green)
|
75
75
|
|
76
76
|
win.puts "A window doesn't have to"
|
77
77
|
win.puts "have a border."
|
@@ -80,7 +80,7 @@ win.puts "have a border."
|
|
80
80
|
Using `puts` will wrap around the window automagically.
|
81
81
|
```ruby
|
82
82
|
require 'rubytext'
|
83
|
-
win = RubyText.window(8, 39, 4, 9, fg: Black, bg: Blue)
|
83
|
+
win = RubyText.window(8, 39, r: 4, c: 9, fg: Black, bg: Blue)
|
84
84
|
|
85
85
|
win.puts "If your text is longer than " +
|
86
86
|
"the width of the window, by default it will " +
|
@@ -92,7 +92,7 @@ win.puts "Scrolling is not yet supported."
|
|
92
92
|
Scrolling is not yet implemented.
|
93
93
|
```ruby
|
94
94
|
require 'rubytext'
|
95
|
-
win = RubyText.window(10, 70, 2, 14, fg: Yellow, bg: Black)
|
95
|
+
win = RubyText.window(10, 70, r: 2, c: 14, fg: Yellow, bg: Black)
|
96
96
|
|
97
97
|
win.output do
|
98
98
|
puts "Without scrolling, this is what happens when your window fills up..."
|
@@ -109,7 +109,7 @@ end
|
|
109
109
|
You can use `print` and `p` as well as `puts`.
|
110
110
|
```ruby
|
111
111
|
require 'rubytext'
|
112
|
-
win = RubyText.window(10, 60, 2, 14, fg: Blue, bg: Black)
|
112
|
+
win = RubyText.window(10, 60, r: 2, c: 14, fg: Blue, bg: Black)
|
113
113
|
|
114
114
|
win.output do
|
115
115
|
puts "The #print and #p methods also act as you expect."
|
@@ -127,7 +127,7 @@ end
|
|
127
127
|
You can still use `puts` (etc.) with files, but watch for `STDOUT` and `STDERR`.
|
128
128
|
```ruby
|
129
129
|
require 'rubytext'
|
130
|
-
win = RubyText.window(10, 50, 0, 5, fg: Yellow, bg: Blue)
|
130
|
+
win = RubyText.window(10, 50, r: 0, c: 5, fg: Yellow, bg: Blue)
|
131
131
|
|
132
132
|
win.output do
|
133
133
|
puts "Of course, #puts and #print are unaffected \nfor other receivers."
|
@@ -147,7 +147,7 @@ end
|
|
147
147
|
Use `[]=` to stuff single characters into a window (like an array).
|
148
148
|
```ruby
|
149
149
|
require 'rubytext'
|
150
|
-
win = RubyText.window(11, 50, 0, 5, fg: Yellow, bg: Blue)
|
150
|
+
win = RubyText.window(11, 50, r: 0, c: 5, fg: Yellow, bg: Blue)
|
151
151
|
|
152
152
|
win.puts "We can use the []= method (0-based)"
|
153
153
|
win.puts "to address individual window locations"
|
@@ -166,7 +166,7 @@ win[6,38] = "Z"; win.refresh
|
|
166
166
|
Likewise use `[]` to retrieve characters from a window.
|
167
167
|
```ruby
|
168
168
|
require 'rubytext'
|
169
|
-
win = RubyText.window(12, 60, 2, 5, fg: Yellow, bg: Blue)
|
169
|
+
win = RubyText.window(12, 60, r: 2, c: 5, fg: Yellow, bg: Blue)
|
170
170
|
|
171
171
|
win.puts "ABCDE Method [] can retrieve characters "
|
172
172
|
win.puts "FGHIJ from a window."
|
@@ -181,7 +181,7 @@ win.puts "(6,7) => '#{win[6,7]}' (0,15) => '#{win[0,15]}'"
|
|
181
181
|
You can write to `STDSCR` or to a subwindow.
|
182
182
|
```ruby
|
183
183
|
require 'rubytext'
|
184
|
-
win = RubyText.window(6, 30, 2, 5, fg: Yellow, bg: Blue)
|
184
|
+
win = RubyText.window(6, 30, r: 2, c: 5, fg: Yellow, bg: Blue)
|
185
185
|
|
186
186
|
win.puts "You can write to a window..."
|
187
187
|
|
@@ -201,7 +201,7 @@ puts "Nothing stops you from overwriting a window."
|
|
201
201
|
You can retrieve cursor position and window size.
|
202
202
|
```ruby
|
203
203
|
require 'rubytext'
|
204
|
-
win = RubyText.window(12, 65, 1, 5, fg: Yellow, bg: Blue)
|
204
|
+
win = RubyText.window(12, 65, r: 1, c: 5, fg: Yellow, bg: Blue)
|
205
205
|
|
206
206
|
win.output do
|
207
207
|
puts "You can detect the size and cursor position of any window."
|
@@ -218,7 +218,7 @@ end
|
|
218
218
|
Move the cursor with `go` (and use a block to jump/return).
|
219
219
|
```ruby
|
220
220
|
require 'rubytext'
|
221
|
-
win = RubyText.window(11, 65, 0, 15, fg: Blue, bg: Black)
|
221
|
+
win = RubyText.window(11, 65, r: 0, c: 15, fg: Blue, bg: Black)
|
222
222
|
|
223
223
|
win.puts "The #go method will move the cursor to a specific location."
|
224
224
|
win.go 2, 5
|
@@ -237,7 +237,7 @@ win.print "DEF"
|
|
237
237
|
Use `rcprint` to print at specific coordinates.
|
238
238
|
```ruby
|
239
239
|
require 'rubytext'
|
240
|
-
win = RubyText.window(13, 65, 0, 6, fg: Blue, bg: White)
|
240
|
+
win = RubyText.window(13, 65, r: 0, c: 6, fg: Blue, bg: White)
|
241
241
|
|
242
242
|
win.puts "The #rcprint method will print at the specified"
|
243
243
|
win.puts "row/column, like go(r,c) followed by a print,"
|
@@ -253,7 +253,7 @@ win.rcprint 10,0, "Later there will be other ways to do this kind of thing."
|
|
253
253
|
Window navigation: `home`, `up`, `down`, `left`, `right`
|
254
254
|
```ruby
|
255
255
|
require 'rubytext'
|
256
|
-
win = RubyText.window(11, 65, 0, 6, fg: Blue, bg: White)
|
256
|
+
win = RubyText.window(11, 65, r: 0, c: 6, fg: Blue, bg: White)
|
257
257
|
|
258
258
|
win.go 2,0
|
259
259
|
win.puts " Method #home will home the cursor..."
|
@@ -272,7 +272,7 @@ win.go 7, 29; win.right; win.putch("R"); sleep 1
|
|
272
272
|
More navigation: `up`, `down`, `left`, `right` with a parameter.
|
273
273
|
```ruby
|
274
274
|
require 'rubytext'
|
275
|
-
win = RubyText.window(11, 65, 1, 6, fg: Blue, bg: White)
|
275
|
+
win = RubyText.window(11, 65, r: 1, c: 6, fg: Blue, bg: White)
|
276
276
|
|
277
277
|
win.puts "Methods up/down/left/right can also take an integer..."
|
278
278
|
|
@@ -286,7 +286,7 @@ win.go 4, 29; win.right(5); win.putch("5"); sleep 1
|
|
286
286
|
Still more navigation: `up!`, `down!`, `left!`, `right!`
|
287
287
|
```ruby
|
288
288
|
require 'rubytext'
|
289
|
-
win = RubyText.window(11, 65, 1, 6, fg: Blue, bg: White)
|
289
|
+
win = RubyText.window(11, 65, r: 1, c: 6, fg: Blue, bg: White)
|
290
290
|
|
291
291
|
win.go 2,0
|
292
292
|
win.puts "We also have: up!, down!, left!, and right! which can"
|
@@ -302,7 +302,7 @@ win.go 5, 21; win.right!; win.putch("R"); sleep 1
|
|
302
302
|
And finally, `top` and `bottom`.
|
303
303
|
```ruby
|
304
304
|
require 'rubytext'
|
305
|
-
win = RubyText.window(11, 65, 1, 6, fg: Blue, bg: White)
|
305
|
+
win = RubyText.window(11, 65, r: 1, c: 6, fg: Blue, bg: White)
|
306
306
|
|
307
307
|
win.go 2,0
|
308
308
|
win.puts "#top and #bottom are the same as #up! and #down!"
|
@@ -315,7 +315,7 @@ win.go 5, 21; win.bottom; win.putch("B"); sleep 1
|
|
315
315
|
Somewhat useless, but there is a `center` method.
|
316
316
|
```ruby
|
317
317
|
require 'rubytext'
|
318
|
-
win = RubyText.window(15, 65, 1, 6, fg: Green, bg: Blue)
|
318
|
+
win = RubyText.window(15, 65, r: 1, c: 6, fg: Green, bg: Blue)
|
319
319
|
|
320
320
|
win.puts "#center will print text centered on the current row"
|
321
321
|
win.puts "and do an implicit CRLF at the end.\n "
|
@@ -330,7 +330,7 @@ stuff.each {|str| win.center(str) }
|
|
330
330
|
Changing colors during printing. This syntax will change.
|
331
331
|
```ruby
|
332
332
|
require 'rubytext'
|
333
|
-
win = RubyText.window(12, 65, 0, 6, fg: Green, bg: Blue)
|
333
|
+
win = RubyText.window(12, 65, r: 0, c: 6, fg: Green, bg: Blue)
|
334
334
|
|
335
335
|
win.puts "This is EXPERIMENTAL."
|
336
336
|
win.puts "Use a color symbol to change text color temporarily:\n "
|
data/examples/demo.rb
CHANGED
data/examples/multitest.rb
CHANGED
@@ -14,7 +14,7 @@ r0 = 3
|
|
14
14
|
Colors.each do |fg|
|
15
15
|
c0 = 0
|
16
16
|
Colors.each do |bg|
|
17
|
-
win = RubyText.window(2, 12, r0, c0, border: false, fg: fg, bg: bg)
|
17
|
+
win = RubyText.window(2, 12, r: r0, c: c0, border: false, fg: fg, bg: bg)
|
18
18
|
win.puts " #{fg} on\n #{bg}"
|
19
19
|
c0 += 14
|
20
20
|
end
|
data/examples/prog01.rb
CHANGED
data/examples/prog02.rb
CHANGED
data/examples/prog03.rb
CHANGED
data/examples/prog04.rb
CHANGED
data/examples/prog05.rb
CHANGED
data/examples/prog06.rb
CHANGED
data/examples/prog07.rb
CHANGED
data/examples/prog08.rb
CHANGED
data/examples/prog09.rb
CHANGED
data/examples/prog10.rb
CHANGED
data/examples/prog11.rb
CHANGED
data/examples/prog12.rb
CHANGED
data/examples/prog13.rb
CHANGED
data/examples/prog14.rb
CHANGED
data/examples/prog15.rb
CHANGED
data/examples/prog16.rb
CHANGED
data/examples/prog17.rb
CHANGED
data/examples/prog18.rb
CHANGED
data/examples/prog19.rb
CHANGED
data/examples/prog20.rb
CHANGED
@@ -3,7 +3,7 @@ def effect(*args) # find better way
|
|
3
3
|
end
|
4
4
|
|
5
5
|
fg, bg = White, Blue
|
6
|
-
win = RubyText.window(9, 65, 2, 26, fg: fg, bg: bg)
|
6
|
+
win = RubyText.window(9, 65, r: 2, c: 26, fg: fg, bg: bg)
|
7
7
|
|
8
8
|
win.puts "This is EXPERIMENTAL (and BUGGY)."
|
9
9
|
win.puts "Use an \"effect\" to change the text color or \"look\":"
|
data/examples/prog20a.rb
CHANGED
@@ -3,7 +3,7 @@ def effect(*args) # find better way
|
|
3
3
|
end
|
4
4
|
|
5
5
|
fg, bg = White, Blue
|
6
|
-
win = RubyText.window(9, 65, 2, 26, fg: fg, bg: bg)
|
6
|
+
win = RubyText.window(9, 65, r: 2, c: 26, fg: fg, bg: bg)
|
7
7
|
|
8
8
|
win.puts "This is EXPERIMENTAL (and BUGGY)."
|
9
9
|
win.puts "Use an \"effect\" to change the text color or \"look\":"
|
data/examples/prog21.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
win = RubyText.window(10, 45, 1, 20, fg: Black, bg: Red)
|
1
|
+
win = RubyText.window(10, 45, r: 1, c: 20, fg: Black, bg: Red)
|
2
2
|
win.puts "This very crude menu is also EXPERIMENTAL."
|
3
3
|
win.puts "It knows up, down, Enter, and Escape.\n "
|
4
4
|
win.puts "Press any key to display the menu..."
|
data/examples/prog23.rb
CHANGED
@@ -2,7 +2,7 @@ puts "\n Methods such as go, rcprint, and putch \n can accept symbols such as"
|
|
2
2
|
puts " :top :bottom :left :right :center"
|
3
3
|
puts "\n Of course, printing starting at the far right \n can be problematic."
|
4
4
|
|
5
|
-
win = RubyText.window(7, 29, 1, 60, fg: Red, bg: Black)
|
5
|
+
win = RubyText.window(7, 29, r: 1, c: 60, fg: Red, bg: Black)
|
6
6
|
|
7
7
|
win.putch "1", r: :bottom, c: :left; sleep 0.4
|
8
8
|
win.go :center, :left; win.puts "abc"; sleep 0.4
|
data/examples/showme.rb
CHANGED
@@ -17,7 +17,7 @@ def show_code(prog, upward=0)
|
|
17
17
|
nlines = text.split("\n").size
|
18
18
|
|
19
19
|
prog_top = @rmax-nlines-3 - upward.to_i
|
20
|
-
code = RubyText.window(nlines+2, @cmax-2, prog_top, 1,
|
20
|
+
code = RubyText.window(nlines+2, @cmax-2, r: prog_top, c: 1,
|
21
21
|
fg: Green, bg: Black)
|
22
22
|
code.puts text
|
23
23
|
|
data/lib/menu.rb
CHANGED
@@ -6,7 +6,7 @@ module RubyText
|
|
6
6
|
high = items.size + 2
|
7
7
|
wide = items.map(&:length).max + 4
|
8
8
|
win.saveback(high, wide, r, c)
|
9
|
-
mwin = RubyText.window(high, wide, r+win.r0+1, c+win.c0+1,
|
9
|
+
mwin = RubyText.window(high, wide, r: r+win.r0+1, c: c+win.c0+1,
|
10
10
|
fg: fg, bg: bg)
|
11
11
|
X.stdscr.keypad(true)
|
12
12
|
sel = curr
|
@@ -43,7 +43,7 @@ module RubyText
|
|
43
43
|
win2:, callback:, enter: nil, quit: "q")
|
44
44
|
high = rows
|
45
45
|
wide = cols
|
46
|
-
mwin = RubyText.
|
46
|
+
mwin = RubyText.indow(high, wide, r: r, c: c, fg: fg, bg: bg)
|
47
47
|
handler = callback
|
48
48
|
X.stdscr.keypad(true)
|
49
49
|
RubyText.hide_cursor
|
data/lib/settings.rb
CHANGED
@@ -121,8 +121,8 @@ module RubyText
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
def self.window(high, wide,
|
125
|
-
RubyText::Window.new(high, wide,
|
124
|
+
def self.window(high, wide, r:, c:, border: true, fg: White, bg: Blue, scroll: false)
|
125
|
+
RubyText::Window.new(high, wide, r, c, border, fg, bg, scroll)
|
126
126
|
end
|
127
127
|
|
128
128
|
def self.hide_cursor
|
data/lib/version.rb
CHANGED
data/lib/widgets.rb
CHANGED
@@ -2,7 +2,7 @@ module RubyText
|
|
2
2
|
def self.ticker(row: STDSCR.rows-1, col: 0, width: STDSCR.cols,
|
3
3
|
fg: White, bg: Blue, text:, delay: 0.1)
|
4
4
|
text = text.gsub("\n", " ") + " "
|
5
|
-
win = RubyText.window(1, width, row, col, border: false, fg: fg, bg: bg)
|
5
|
+
win = RubyText.window(1, width, r: row, c: col, border: false, fg: fg, bg: bg)
|
6
6
|
leader = " "*width + text
|
7
7
|
leader = text.chars.cycle.each_cons(width)
|
8
8
|
width.times { win.rcprint 0, 0, leader.next.join }
|
data/tutorial/colortest.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubytext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.85
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|