rubytext 0.0.68 → 0.0.69

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: e0f3ff5611efd4871e31da6cbf2fc7131f5fdd546e651362449e4be0f91e4a5a
4
- data.tar.gz: ae5fae35dca133795f63db64798ea6afb379feb18d3672c90f088ea55900b89b
3
+ metadata.gz: 05ecb544b4d51313454758aa89eeb5997ced7b0cc8c8dc5e5609c842957d9aea
4
+ data.tar.gz: 943e529d5da7f1eba8826e4702e6dd9c12fe644664012af610796805f419b21b
5
5
  SHA512:
6
- metadata.gz: 108d7bb54f633c16b0c3d66e6d13d8ce8bee681a81fdba7567d5c26a2e98e25cd9b8b49aa54aba0def9c9b29f4e7312af7c00076fd0d71dcf2b8bc789eb85f21
7
- data.tar.gz: 102b62ce8a5ba35cdced7c93ff52ff9b15d41e9b6f854055255747c7300e79b75198327cd6d069c8df1a296e60ab267550b88528db9ae34a50826ca5541cbfc4
6
+ metadata.gz: 06273a824f50b4248fdddda9e72d2c967a42e56a04edbece55af9a0c9a4e80cc45e8c96ad5dc588a277f8d7619e4b2a3b2386f5f6ff9a8844138f1bbd1198c0c
7
+ data.tar.gz: 3360acf134a66130a6e9aaa373b6ac951af363ff01dcffdea667aa931c2e7d2cf5767b42b626b51370de30d9ab9de1b5d6285803b0193960c293fe7b443ff552
data/examples/prog01.rb CHANGED
@@ -1,5 +1,4 @@
1
- win = RubyText.window(6, 25, 2, 34,
2
- # 6 rows, 25 cols; upper left at 2,4
3
- fg: Blue, bg: White) # foreground, background
1
+ win = RubyText.window(6, 25, 10, 34, # 6 rows, 25 cols; corner @ 10,34
2
+ fg: Blue, bg: White) # foreground, background colors
4
3
 
5
4
  win.puts "This is a window..."
data/examples/prog02.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(9, 36, 2, 6, fg: White, bg: Red)
1
+ win = RubyText.window(9, 36, 5, 11, 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, border: false, fg: Black, bg: Green)
1
+ win = RubyText.window(9, 35, 6, 12, border: 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, fg: Black, bg: Blue)
1
+ win = RubyText.window(8, 39, 7, 14, 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, fg: Yellow, bg: Black)
1
+ win = RubyText.window(10, 70, 4, 14, 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, fg: Blue, bg: Black)
1
+ win = RubyText.window(10, 60, 3, 14, 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, fg: Yellow, bg: Blue)
1
+ win = RubyText.window(10, 50, 2, 15, 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, fg: Yellow, bg: Blue)
1
+ win = RubyText.window(11, 50, 2, 15, 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, fg: Yellow, bg: Blue)
1
+ win = RubyText.window(12, 60, 3, 10, 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, fg: Yellow, bg: Blue)
1
+ win = RubyText.window(6, 30, 4, 13, fg: Yellow, bg: Blue)
2
2
 
3
3
  win.puts "You can write to a window..."
4
4
 
data/examples/prog12.rb CHANGED
@@ -1,4 +1,4 @@
1
- win = RubyText.window(12, 65, 1, 5, fg: Yellow, bg: Blue)
1
+ win = RubyText.window(12, 65, 2, 11, 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, fg: Blue, bg: Black)
1
+ win = RubyText.window(11, 65, 2, 15, 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, fg: Blue, bg: White)
1
+ win = RubyText.window(13, 65, 2, 14, 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, fg: Blue, bg: White)
1
+ win = RubyText.window(11, 65, 2, 14, 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, fg: Blue, bg: White)
1
+ win = RubyText.window(11, 65, 4, 14, 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, fg: Blue, bg: White)
1
+ win = RubyText.window(11, 65, 3, 14, 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, fg: Blue, bg: White)
1
+ win = RubyText.window(11, 65, 4, 14, 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, fg: Green, bg: Blue)
1
+ win = RubyText.window(15, 65, 2, 14, 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,13 +1,15 @@
1
- win = RubyText.window(12, 65, 0, 6, fg: Green, bg: Blue)
1
+ def fx(*args) # find better way
2
+ RubyText::Effects.new(*args)
3
+ end
2
4
 
3
- win.puts "This is EXPERIMENTAL."
4
- win.puts "Use a color symbol to change text color temporarily:\n "
5
-
6
- win.puts "This is", :yellow, " another color", :white, " and yet another."
7
- win.puts "And this is normal again.\n "
5
+ win = RubyText.window(9, 65, 2, 26, fg: Green, bg: Blue)
6
+ fg, bg = Green, Blue
8
7
 
9
- win.puts "This does mean that you can't print a symbol that is"
10
- win.puts "also a color name... you'd need a workaround.\n "
8
+ win.puts "This is EXPERIMENTAL."
9
+ win.puts "Use an \"effect\" to change the color or \"look\""
10
+ win.puts "of the text (temporarily):\n "
11
11
 
12
- sym = :red
13
- win.puts "The symbol is ", sym.inspect, " which works", sym, " just fine."
12
+ win.puts "This is", fx(win, Yellow), " another color ",
13
+ fx(win, White), "and yet another."
14
+ win.puts "This is ", fx(win, :bold, Red), "bold red ",
15
+ fx(win, :normal, fg), "and this is normal again.\n "
data/lib/color.rb CHANGED
@@ -1,13 +1,4 @@
1
1
 
2
- def fb2cp(fg, bg)
3
- fg ||= Blue
4
- bg ||= White
5
- f2 = X.const_get("COLOR_#{fg.upcase}")
6
- b2 = X.const_get("COLOR_#{bg.upcase}")
7
- cp = $ColorPairs[[fg, bg]]
8
- [f2, b2, cp]
9
- end
10
-
11
2
  # Colors are 'global' for now
12
3
  Black, Blue, Cyan, Green, Magenta, Red, White, Yellow =
13
4
  :black, :blue, :cyan, :green, :magenta, :red, :white, :yellow
@@ -26,7 +17,15 @@ class RubyText::Color
26
17
  end
27
18
 
28
19
  def self.pair(fg, bg)
29
- num = 8*index(fg) + index(bg)
20
+ nf = index(fg)
21
+ nb = index(bg)
22
+ File.open("/tmp/pair.out", "w") do |f|
23
+ f.puts "fg, bg = #{[fg, bg].inspect}"
24
+ f.puts "Colors = #{Colors.inspect}"
25
+ f.puts "index fg = #{nf.inspect}"
26
+ f.puts "index bg = #{nb.inspect}"
27
+ end
28
+ num = 8*nf + nb
30
29
  X.init_pair(num, sym2const(fg), sym2const(bg))
31
30
  num
32
31
  end
@@ -34,6 +33,9 @@ end
34
33
 
35
34
  class RubyText::Window
36
35
  def self.colorize!(win, fg, bg)
36
+ File.open("/tmp/cize.out", "w") do |f|
37
+ f.puts "colorize: fg, bg = #{[fg, bg].inspect}"
38
+ end
37
39
  cp = RubyText::Color.pair(fg, bg)
38
40
  win.color_set(cp)
39
41
  num = win.maxx * win.maxy
@@ -41,6 +43,11 @@ class RubyText::Window
41
43
  win.addstr(' '*num)
42
44
  win.setpos 0,0
43
45
  win.refresh
46
+ rescue => err
47
+ File.open("/tmp/#{__method__}.out", "w") do |f|
48
+ f.puts err
49
+ f.puts err.backtrace
50
+ end
44
51
  end
45
52
 
46
53
  def set_colors(fg, bg)
@@ -57,11 +64,11 @@ class RubyText::Window
57
64
  end
58
65
 
59
66
  def fg=(sym)
60
- set_colors(fg, @bg)
67
+ set_colors(sym, @bg)
61
68
  end
62
69
 
63
70
  def bg=(sym)
64
- set_colors(@fg, bg)
71
+ set_colors(@fg, sym)
65
72
  end
66
73
  end
67
74
 
data/lib/effects.rb CHANGED
@@ -1,17 +1,21 @@
1
1
  class RubyText::Effects # dumb name?
2
- Modes = %w[A_BOLD A_NORMAL A_PROTECT A_REVERSE A_STANDOUT A_UNDERLINE]
2
+ Modes = {bold: X::A_BOLD,
3
+ normal: X:: A_NORMAL,
4
+ reverse: X:: A_REVERSE,
5
+ under: X:: A_UNDERLINE}
3
6
 
4
- attr_reader :value
7
+ Others = %[:show, :hide] # show/hide cursor; more later??
8
+
9
+ attr_reader :value, :fg
5
10
 
6
- def initialize(bg, *args)
11
+ def initialize(win, *args)
7
12
  bits = 0
8
13
  args.each do |arg|
9
- if Modes.include?(arg)
10
- val = eval("X::A_#{arg.to_s.upcase}")
11
- bits ||= val
12
- elsif RubyText::Colors.include?(arg)
13
- val = eval("X::COLOR_#{arg.to_s.upcase}")
14
+ if Modes.keys.include?(arg)
15
+ val = Modes[arg]
14
16
  bits ||= val
17
+ elsif ::Colors.include?(arg)
18
+ @fg = arg # symbol
15
19
  end
16
20
  end
17
21
  @value = bits
data/lib/menu.rb CHANGED
@@ -30,11 +30,13 @@ module RubyText
30
30
  RubyText.hide_cursor
31
31
  sel = curr
32
32
  max = items.size - 1
33
+ norm = RubyText::Effects.new(win, :normal, White)
34
+ bold = RubyText::Effects.new(win, :bold, Yellow)
33
35
  loop do
34
36
  items.each.with_index do |item, row|
35
37
  win.go row, 0
36
- color = sel == row ? Yellow : White
37
- win.puts color, " #{item} "
38
+ style = (sel == row) ? bold : norm
39
+ win.print style, " #{item} "
38
40
  end
39
41
  ch = getch
40
42
  case ch
@@ -69,8 +71,10 @@ module RubyText
69
71
  loop do
70
72
  items.each.with_index do |item, row|
71
73
  menu_win.go row, 0
72
- color = sel == row ? Yellow : White
73
- menu_win.puts color, " #{item} "
74
+ norm = RubyText::Effects.new(:normal, White)
75
+ rev = RubyText::Effects.new(:reverse, White)
76
+ style = sel == row ? Yellow : White
77
+ menu_win.puts style, " #{item} "
74
78
  end
75
79
  ch = getch
76
80
  case ch
data/lib/output.rb CHANGED
@@ -15,9 +15,8 @@ class RubyText::Window
15
15
 
16
16
  # FIXME Please refactor the Hal out of this.
17
17
 
18
- def special?(arg)
19
- RubyText::Color::Colors.include?(arg) ||
20
- arg.is_a?(RubyText::Effects)
18
+ def effect?(arg)
19
+ arg.is_a?(RubyText::Effects)
21
20
  end
22
21
 
23
22
  def delegate_output(sym, *args)
@@ -27,14 +26,13 @@ class RubyText::Window
27
26
  if sym == :p
28
27
  args.map!(&:inspect)
29
28
  else
30
- args.map! {|x| special?(x) ? x : x.to_s }
29
+ args.map! {|x| effect?(x) ? x : x.to_s }
31
30
  end
32
31
  args.each do |arg|
33
32
  case
34
- when arg.is_a?(Symbol) # must be a color
35
- set_colors(arg, @bg) # FIXME?
36
33
  when arg.is_a?(RubyText::Effects)
37
34
  X.attrset(arg.value)
35
+ self.set_colors(arg.fg, @bg) if arg.fg
38
36
  else
39
37
  arg.each_char {|ch| ch == "\n" ? crlf : @cwin.addch(ch) }
40
38
  end
@@ -129,6 +127,7 @@ end
129
127
 
130
128
  # into top level...
131
129
 
130
+ module WindowIO
132
131
  def puts(*args) # Doesn't affect STDOUT.puts, etc.
133
132
  $stdscr.puts(*args)
134
133
  end
@@ -148,4 +147,5 @@ end
148
147
  def getch
149
148
  X.getch
150
149
  end
150
+ end
151
151
 
data/lib/rubytext.rb CHANGED
@@ -7,8 +7,6 @@ X = Curses # shorthand
7
7
  module RubyText
8
8
  end
9
9
 
10
- $debug = File.new("wtf.out", "w")
11
-
12
10
  require 'version'
13
11
  require 'output' # RubyText, RubyText::Window, Kernel
14
12
  require 'keys' # RubyText::Keys
@@ -46,7 +44,8 @@ def make_exception(sym, str)
46
44
  Object.const_set(sym, StandardError.dup)
47
45
  define_method(sym) do |*args|
48
46
  msg = str
49
- args.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
47
+ list = (args + [nil]*2)[0..2]
48
+ list.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
50
49
  Object.class_eval(sym.to_s).new(msg)
51
50
  end
52
51
  end
@@ -54,7 +53,7 @@ end
54
53
  make_exception(:RTError, "General error: $1 $2 $3")
55
54
 
56
55
  def debug(*args)
57
- return unless $debug
58
56
  $debug.puts *args
57
+ $debug.flush
59
58
  end
60
59
 
data/lib/settings.rb CHANGED
@@ -40,7 +40,7 @@ module RubyText
40
40
  when :_cursor, :nocursor
41
41
  X.curs_set(0)
42
42
  else
43
- self.stop
43
+ # self.stop
44
44
  rest_flags # prevent propagating error in test
45
45
  raise RTError("flag = #{flag.inspect}")
46
46
  end
@@ -70,18 +70,18 @@ module RubyText
70
70
  @flags = @defaults
71
71
  end
72
72
 
73
- def self.start(*args, log: nil, fg: nil, bg: nil, scroll: false)
73
+ def self.start(*args, log: nil, fg: White, bg: Blue, scroll: false)
74
74
  $debug ||= File.new(log, "w") if log
75
75
  main = RubyText::Window.main(fg: fg, bg: bg, scroll: scroll)
76
- Object.const_set(:STDSCR, main)
76
+ Object.const_set(:STDSCR, main) unless defined? STDSCR
77
77
  $stdscr = STDSCR
78
- fg, bg, cp = fb2cp(fg, bg)
78
+ Object.include(WindowIO)
79
79
  self.set(:_echo, :cbreak) # defaults
80
80
  self.set(*args) # override defaults
81
81
  rescue => err
82
82
  debug(err.inspect)
83
83
  debug(err.backtrace)
84
- # raise RTError("#{err}")
84
+ raise RTError("#{err}")
85
85
  end
86
86
 
87
87
  def self.stop
@@ -100,7 +100,7 @@ module RubyText
100
100
  end
101
101
  end
102
102
 
103
- def self.window(high, wide, r0, c0, border: true, fg: nil, bg: nil, scroll: false)
103
+ def self.window(high, wide, r0, c0, border: true, fg: White, bg: Blue, scroll: false)
104
104
  RubyText::Window.new(high, wide, r0, c0, border, fg, bg, scroll)
105
105
  end
106
106
 
data/lib/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module RubyText
3
- VERSION = "0.0.68"
3
+ VERSION = "0.0.69"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
data/lib/window.rb CHANGED
@@ -6,7 +6,7 @@ class RubyText::Window
6
6
 
7
7
  # Better to use Window.window IRL
8
8
 
9
- def initialize(high=nil, wide=nil, r0=1, c0=1, border=false, fg=nil, bg=nil, scroll=false)
9
+ def initialize(high=nil, wide=nil, r0=1, c0=1, border=false, fg=White, bg=Blue, scroll=false)
10
10
  @wide, @high, @r0, @c0 = wide, high, r0, c0
11
11
  @border, @fg, @bg = border, fg, bg
12
12
  @cwin = X::Window.new(high, wide, r0, c0)
@@ -27,7 +27,7 @@ class RubyText::Window
27
27
  @cwin.refresh
28
28
  end
29
29
 
30
- def self.main(fg: nil, bg: nil, scroll: false)
30
+ def self.main(fg: White, bg: Blue, scroll: false)
31
31
  main_win = X.init_screen
32
32
  X.start_color
33
33
  self.colorize!(main_win, fg, bg)
@@ -91,4 +91,12 @@ class RubyText::Window
91
91
  File.open(file, "w") {|f| f.puts lines } if file
92
92
  lines
93
93
  end
94
+
95
+ def fg=(sym)
96
+ set_colors(fg, @bg)
97
+ end
98
+
99
+ def bg=(sym)
100
+ set_colors(@fg, bg)
101
+ end
94
102
  end
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.68
4
+ version: 0.0.69
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-30 00:00:00.000000000 Z
11
+ date: 2018-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -69,7 +69,6 @@ files:
69
69
  - examples/prog22.rb
70
70
  - examples/showme.rb
71
71
  - examples/slides
72
- - lib/_window.rb
73
72
  - lib/color.rb
74
73
  - lib/effects.rb
75
74
  - lib/keys.rb
data/lib/_window.rb DELETED
@@ -1,92 +0,0 @@
1
- class RubyText::Window
2
- Vert, Horiz = X::A_VERTICAL, X::A_HORIZONTAL
3
-
4
- attr_reader :cwin, :rows, :cols, :width, :height, :scrolling
5
- attr_writer :fg, :bg
6
-
7
- # Better to use Window.window IRL
8
-
9
- def initialize(high=nil, wide=nil, r0=1, c0=1, border=false, fg=nil, bg=nil, scroll=false)
10
- @wide, @high, @r0, @c0 = wide, high, r0, c0
11
- @border, @fg, @bg = border, fg, bg
12
- @cwin = X::Window.new(high, wide, r0, c0)
13
- RubyText::Window.colorize!(@cwin, fg, bg)
14
- if @border
15
- @cwin.box(Vert, Horiz)
16
- @outer = @cwin
17
- @outer.refresh
18
- @cwin = X::Window.new(high-2, wide-2, r0+1, c0+1)
19
- RubyText::Window.colorize!(@cwin, fg, bg)
20
- else
21
- @outer = @cwin
22
- end
23
- @rows, @cols = @cwin.maxy, @cwin.maxx # unnecessary really...
24
- @width, @height = @cols + 2, @rows + 2 if @border
25
- @scrolling = scroll
26
- @cwin.scrollok(scroll)
27
- @cwin.refresh
28
- end
29
-
30
- def self.main(fg: nil, bg: nil, scroll: false)
31
- main_win = X.init_screen
32
- X.start_color
33
- colorize!(main_win, fg, bg)
34
- rows, cols = main_win.maxy, main_win.maxx
35
- self.make(main_win, rows, cols, 0, 0, border: false,
36
- fg: fg, bg: bg, scroll: scroll)
37
- end
38
-
39
- def self.make(cwin, high, wide, r0, c0, border: true, fg: White, bg: Black, scroll: false)
40
- obj = self.allocate
41
- obj.instance_eval do
42
- @outer = @cwin = cwin
43
- @wide, @high, @r0, @c0 = wide, high, r0, c0
44
- @fg, @bg = fg, bg
45
- @border = border
46
- @rows, @cols = high, wide
47
- @width, @height = @cols + 2, @rows + 2 if @border
48
- end
49
- obj.scrolling(scroll)
50
- obj
51
- end
52
-
53
- # FIXME refactor bad code
54
-
55
- def scrolling(flag=true)
56
- @scrolling = flag
57
- @cwin.scrollok(flag)
58
- end
59
-
60
- def noscroll
61
- @scrolling = false
62
- @cwin.scrollok(false)
63
- end
64
-
65
- def scroll(n=1)
66
- if n < 0
67
- @cwin.scrl(n)
68
- (-n).times {|i| rcprint i, 0, (' '*@cols) }
69
- else
70
- n.times do |i|
71
- @cwin.scroll
72
- scrolling(false)
73
- rcprint @rows-1, 0, (' '*@cols)
74
- scrolling
75
- end
76
- end
77
- @cwin.refresh
78
- end
79
-
80
- def screen_text(file = nil)
81
- lines = []
82
- 0.upto(self.rows-1) do |r|
83
- line = ""
84
- 0.upto(self.cols-1) do |c|
85
- line << self[r, c]
86
- end
87
- lines << line
88
- end
89
- File.open(file, "w") {|f| f.puts lines } if file
90
- lines
91
- end
92
- end