rubytext 0.0.51 → 0.0.52

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: 23db0ff4046eddb4b00ed8acc5d6deab26a92cf73e96b275ed786b954c0fdb92
4
- data.tar.gz: d4bc7b61921188e513b6e0fa6c812a1249806a04b56642c1f3d93a27dc59c68b
3
+ metadata.gz: 3c70e2361d174352a8b4bd66080a08636c41afb2e4caffc72dd1583aa1339f70
4
+ data.tar.gz: b84934ee1a6fe52023bfe6c2d80ed2c5265441d021841c1ac0bcd4d2abba3cbf
5
5
  SHA512:
6
- metadata.gz: c55d7d5dfe40eaa98cc94d7210dfe2d0bbf7309270b12921a1779ad932c3cbab42eded5c215bbce3963c00065faaa33d4c86649dd178a072ccbd7a0c86f600aa
7
- data.tar.gz: 7156a6560a54c2e22a037e95eee753d0c3a8859ce3563bdd7e97dabd4987addcf7ae36f664eaec1bac200581efec9f3ffd535a0011d4a6d379a8edae54fc957b
6
+ metadata.gz: 6e0017838a8c4b56f9bba9858438c84b0d72b5343bed1791fb17c5c99db9c8db8578928c00f5496a3c6bbc6730a9c34df24d891aab8cdf1f7dbd76cc2f44bd9d
7
+ data.tar.gz: 3b4ec8017fd0b6fe286d786eaa34f291fb878f2e89ad8b68ce23cfb0d4a815c4872d44bc758534c47e8e19921fe07334989d50a69b8cd3fb0d3f9eb5104936e3
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- RubyText
2
- --------
1
+ # RubyText
3
2
 
4
3
  RubyText is a curses wrapper that is in the early experimental
5
4
  stages. The code has bugs. Running it may cause general bad luck
@@ -17,5 +16,26 @@ or both.
17
16
  There is also `examples/ide.rb` ("world's simplest Ruby IDE").
18
17
  It is _very_ dumb. :)
19
18
 
19
+ ### Getting started
20
+
21
+ Here's the obligatory hello-world program.
22
+
23
+ ```ruby
24
+ require 'rubytext'
25
+
26
+ RubyText.start
27
+
28
+ puts "Hello, world!"
29
+
30
+ getch
31
+ ```
32
+
33
+ You invoke `RubyText.start` to initialize the curses environment with default settings. If you
34
+ then use `puts`, it will write to the standard screen (called `STDSCR` in this library).
35
+
36
+ The `getch` (get character) simply waits for keyboard input before proceeding. Without it, the
37
+ program might terminate too fast for you to see anything.
38
+
39
+
20
40
  *More later...*
21
41
 
data/examples/demo.rb CHANGED
@@ -6,7 +6,7 @@ def delay(sec, speed=1.0)
6
6
  sleep sec/speed
7
7
  end
8
8
 
9
- RubyText.start(log: "mylog.txt", fg: :green, bg: :black)
9
+ RubyText.start(:_cbreak, log: "mylog.txt", fg: :green, bg: :black)
10
10
 
11
11
  print "Here goes... "
12
12
  delay 2
data/examples/prog01.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  win = RubyText.window(6, 25, 2, 34,
2
2
  # 6 rows, 25 cols; upper left at 2,4
3
3
  true, # has a border
4
- fg: :blue, bg: :white) # foreground, background
4
+ fg: Blue, bg: White) # foreground, background
5
5
 
6
6
  win.puts "This is a window..."
data/examples/prog02.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(9, 36, 2, 6, true, fg: :white, bg: :red)
1
+ win = RubyText.window(9, 36, 2, 6, true, fg: White, bg: Red)
2
2
 
3
3
  win.output do
4
4
  puts "Because this code uses #output,"
data/examples/prog03.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(9, 35, 3, 7, false, fg: :black, bg: :green)
1
+ win = RubyText.window(9, 35, 3, 7, false, fg: Black, bg: Green)
2
2
 
3
3
  win.puts "A window doesn't have to"
4
4
  win.puts "have a border."
data/examples/prog04.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(8, 39, 4, 9, true, fg: :black, bg: :blue)
1
+ win = RubyText.window(8, 39, 4, 9, true, fg: Black, bg: Blue)
2
2
 
3
3
  win.puts "If your text is longer than " +
4
4
  "the width of the window, by default it will " +
data/examples/prog05.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(10, 70, 2, 14, true, fg: :yellow, bg: :black)
1
+ win = RubyText.window(10, 70, 2, 14, true, fg: Yellow, bg: Black)
2
2
 
3
3
  win.output do
4
4
  puts "Without scrolling, this is what happens when your window fills up..."
data/examples/prog06.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(10, 60, 2, 14, true, fg: :blue, bg: :black)
1
+ win = RubyText.window(10, 60, 2, 14, true, fg: Blue, bg: Black)
2
2
 
3
3
  win.output do
4
4
  puts "The #print and #p methods also act as you expect."
data/examples/prog07.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(10, 50, 0, 5, true, fg: :yellow, bg: :blue)
1
+ win = RubyText.window(10, 50, 0, 5, true, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.output do
4
4
  puts "Of course, #puts and #print are unaffected \nfor other receivers."
data/examples/prog08.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(11, 50, 0, 5, true, fg: :yellow, bg: :blue)
1
+ win = RubyText.window(11, 50, 0, 5, true, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.puts "We can use the []= method (0-based)"
4
4
  win.puts "to address individual window locations"
data/examples/prog09.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(12, 60, 2, 5, true, fg: :yellow, bg: :blue)
1
+ win = RubyText.window(12, 60, 2, 5, true, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.puts "ABCDE Method [] can retrieve characters "
4
4
  win.puts "FGHIJ from a window."
data/examples/prog10.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(6, 30, 2, 5, true, fg: :yellow, bg: :blue)
1
+ win = RubyText.window(6, 30, 2, 5, true, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.puts "You can write to a window..."
4
4
 
data/examples/prog11.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(6, 30, 2, 5, true, fg: :yellow, bg: :blue)
1
+ win = RubyText.window(6, 30, 2, 5, true, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.puts "We default to cbreak mode, so that characters are "
4
4
  win.puts "accepted instantly, but control-C still works."
data/examples/prog12.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(12, 65, 1, 5, true, fg: :yellow, bg: :blue)
1
+ win = RubyText.window(12, 65, 1, 5, true, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.output do
4
4
  puts "You can detect the size and cursor position of any window."
data/examples/prog13.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(11, 65, 0, 15, true, fg: :blue, bg: :black)
1
+ win = RubyText.window(11, 65, 0, 15, true, fg: Blue, bg: Black)
2
2
 
3
3
  win.puts "The #go method will move the cursor to a specific location."
4
4
  win.go 2, 5
data/examples/prog14.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(13, 65, 0, 6, true, fg: :blue, bg: :white)
1
+ win = RubyText.window(13, 65, 0, 6, true, fg: Blue, bg: White)
2
2
 
3
3
  win.puts "The #rcprint method will print at the specified"
4
4
  win.puts "row/column, like go(r,c) followed by a print,"
data/examples/prog15.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(11, 65, 0, 6, true, fg: :blue, bg: :white)
1
+ win = RubyText.window(11, 65, 0, 6, true, fg: Blue, bg: White)
2
2
 
3
3
  win.go 2,0
4
4
  win.puts " Method #home will home the cursor..."
data/examples/prog16.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(11, 65, 1, 6, true, fg: :blue, bg: :white)
1
+ win = RubyText.window(11, 65, 1, 6, true, fg: Blue, bg: White)
2
2
 
3
3
  win.puts "Methods up/down/left/right can also take an integer..."
4
4
 
data/examples/prog17.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(11, 65, 1, 6, true, fg: :blue, bg: :white)
1
+ win = RubyText.window(11, 65, 1, 6, true, fg: Blue, bg: White)
2
2
 
3
3
  win.go 2,0
4
4
  win.puts "We also have: up!, down!, left!, and right! which can"
data/examples/prog18.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(11, 65, 1, 6, true, fg: :blue, bg: :white)
1
+ win = RubyText.window(11, 65, 1, 6, true, fg: Blue, bg: White)
2
2
 
3
3
  win.go 2,0
4
4
  win.puts "#top and #bottom are the same as #up! and #down!"
data/examples/prog19.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(15, 65, 1, 6, true, fg: :green, bg: :blue)
1
+ win = RubyText.window(15, 65, 1, 6, true, fg: Green, bg: Blue)
2
2
 
3
3
  win.puts "#center will print text centered on the current row"
4
4
  win.puts "and do an implicit CRLF at the end.\n "
data/examples/prog20.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(12, 65, 0, 6, true, fg: :green, bg: :blue)
1
+ win = RubyText.window(12, 65, 0, 6, true, fg: Green, bg: Blue)
2
2
 
3
3
  win.puts "This is EXPERIMENTAL."
4
4
  win.puts "Use a color symbol to change text color temporarily:\n "
data/examples/prog22.rb CHANGED
@@ -7,10 +7,10 @@ w, h = STDSCR.cols, STDSCR.rows - 1
7
7
  threads = []
8
8
 
9
9
  r = RubyText
10
- t1 = -> { r.ticker(text: msg, row: h-8, col: 20, width: w-40, delay: 0.02, fg: :red, bg: :black) }
10
+ t1 = -> { r.ticker(text: msg, row: h-8, col: 20, width: w-40, delay: 0.02, fg: Red, bg: Black) }
11
11
  t2 = -> { r.ticker(text: msg, row: h-6, col: 15, width: w-30, delay: 0.04) }
12
- t3 = -> { r.ticker(text: msg, row: h-4, col: 10, width: w-20, delay: 0.06, fg: :black, bg: :green) }
13
- t4 = -> { r.ticker(text: msg, row: h-2, col: 5, width: w-10, delay: 0.08, bg: :black) }
12
+ t3 = -> { r.ticker(text: msg, row: h-4, col: 10, width: w-20, delay: 0.06, fg: Black, bg: Green) }
13
+ t4 = -> { r.ticker(text: msg, row: h-2, col: 5, width: w-10, delay: 0.08, bg: Black) }
14
14
  t5 = -> { r.ticker(text: msg) } # All defaults -- goes at bottom
15
15
 
16
16
  threads << Thread.new { t1.call } << Thread.new { t2.call } << Thread.new { t3.call } <<
data/lib/rubytext.rb CHANGED
@@ -4,11 +4,11 @@ require 'curses'
4
4
 
5
5
  X = Curses # shorthand
6
6
 
7
- module RubyText
8
- end
7
+ # Colors are 'global' for now
8
+ Black, Blue, Cyan, Green, Magenta, Red, White, Yellow =
9
+ :black, :blue, :cyan, :green, :magenta, :red, :white, :yellow
9
10
 
10
11
  require 'version'
11
-
12
12
  require 'output' # RubyText, RubyText::Window, Kernel
13
13
  require 'keys' # RubyText::Keys
14
14
  require 'menu' # RubyText
data/lib/settings.rb CHANGED
@@ -32,13 +32,14 @@ module RubyText
32
32
  flag.sub!(/^_/, "no")
33
33
  X.send(flag)
34
34
  else
35
- case flag
35
+ case flag.to_sym
36
36
  when :cursor
37
37
  X.curs_set(1)
38
38
  when :_cursor, :nocursor
39
39
  X.curs_set(0)
40
40
  else
41
41
  self.stop
42
+ rest_flags # prevent propagating error in test
42
43
  raise RTError("flag = #{flag.inspect}")
43
44
  end
44
45
  end
data/lib/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module RubyText
3
- VERSION = "0.0.51"
3
+ VERSION = "0.0.52"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
data/lib/window.rb CHANGED
@@ -65,6 +65,11 @@ class RubyText::Window
65
65
  obj
66
66
  end
67
67
 
68
+ def scroll(n=1)
69
+ @win.scrl(n)
70
+ @win.refresh
71
+ end
72
+
68
73
  def screen_text(file = nil)
69
74
  lines = []
70
75
  0.upto(self.rows-1) do |r|
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.51
4
+ version: 0.0.52
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-11-25 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses