rubytext 0.0.61 → 0.0.62
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 +4 -4
- data/lib/navigation.rb +4 -4
- data/lib/output.rb +24 -15
- data/lib/rubytext.rb +5 -0
- data/lib/version.rb +1 -1
- data/lib/window.rb +18 -34
- 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: 67a616d1aeab9989c5b6c06c427b34867ee1d9f37d9d555f2a576158aee9da92
|
4
|
+
data.tar.gz: 5b611824f529a56c5e768df667c377cb01f695d4baa12912c9cff9440a711376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00129ff170a92b6c62c4c39674ec56ab3cd1c51a164c696755d72386178e8ea03c1c7037d88d6da4a0f6ef3e51acd13de0cabd300d147563510da6d6648370fe'
|
7
|
+
data.tar.gz: cc26dad3e9f198b51196d28baac80b229b8a816b588a1e98c3f8baf47a05fd2662a322a4ceb63728484388c2401b749cf645957f95049f1bcb9850cef43dbeda
|
data/lib/navigation.rb
CHANGED
data/lib/output.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
$LOAD_PATH << "lib"
|
2
2
|
|
3
|
-
require 'global' # FIXME later
|
4
|
-
|
5
|
-
def debug(*args)
|
6
|
-
return unless $debug
|
7
|
-
$debug.puts *args
|
8
|
-
end
|
3
|
+
# require 'global' # FIXME later
|
9
4
|
|
10
5
|
class RubyText::Window
|
11
6
|
def center(str)
|
@@ -25,6 +20,8 @@ class RubyText::Window
|
|
25
20
|
args[-1][-1] != "\n" # last char is a literal linefeed
|
26
21
|
end
|
27
22
|
|
23
|
+
# FIXME Please refactor the Hal out of this.
|
24
|
+
|
28
25
|
def delegate_output(sym, *args)
|
29
26
|
args = [""] if args.empty?
|
30
27
|
RubyText::Window.colors(@cwin, @fg, @bg) # FIXME?
|
@@ -39,16 +36,20 @@ class RubyText::Window
|
|
39
36
|
end
|
40
37
|
end
|
41
38
|
end
|
42
|
-
#
|
43
|
-
flag = need_crlf?(sym, args)
|
44
|
-
# Limitation: Can't print color symbols!
|
39
|
+
flag = need_crlf?(sym, args) # Limitation: Can't print color symbols!
|
45
40
|
args.each do |arg|
|
46
41
|
if arg.is_a? Symbol # must be a color
|
47
42
|
RubyText::Window.colors(@cwin, arg, @bg) # FIXME?
|
48
43
|
elsif arg.is_a? RubyText::Effects
|
49
44
|
X.attrset(arg.value)
|
50
45
|
else
|
51
|
-
arg.each_char
|
46
|
+
arg.each_char do |ch|
|
47
|
+
if ch == "\n"
|
48
|
+
crlf
|
49
|
+
else
|
50
|
+
@cwin.addch(ch)
|
51
|
+
end
|
52
|
+
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
crlf if flag
|
@@ -77,13 +78,21 @@ class RubyText::Window
|
|
77
78
|
self.print *args
|
78
79
|
end
|
79
80
|
|
80
|
-
def crlf
|
81
|
-
# Technically not output...
|
81
|
+
def crlf # Technically not output...
|
82
82
|
r, c = rc
|
83
|
-
if
|
84
|
-
|
83
|
+
if @scrolling
|
84
|
+
if r == @rows - 1 # bottom row
|
85
|
+
scroll
|
86
|
+
left!
|
87
|
+
else
|
88
|
+
go r+1, 0
|
89
|
+
end
|
85
90
|
else
|
86
|
-
|
91
|
+
if r == @rows - 1 # bottom row
|
92
|
+
left!
|
93
|
+
else
|
94
|
+
go r+1, 0
|
95
|
+
end
|
87
96
|
end
|
88
97
|
end
|
89
98
|
|
data/lib/rubytext.rb
CHANGED
data/lib/version.rb
CHANGED
data/lib/window.rb
CHANGED
@@ -1,25 +1,20 @@
|
|
1
1
|
class RubyText::Window
|
2
2
|
Vert, Horiz = X::A_VERTICAL, X::A_HORIZONTAL
|
3
3
|
|
4
|
-
attr_reader :cwin, :rows, :cols, :width, :height
|
4
|
+
attr_reader :cwin, :rows, :cols, :width, :height, :scrolling
|
5
5
|
attr_writer :fg, :bg
|
6
6
|
|
7
7
|
# Better to use Window.window IRL
|
8
8
|
|
9
9
|
def initialize(high=nil, wide=nil, r0=1, c0=1, border=false, fg=nil, bg=nil, scroll=false)
|
10
|
-
debug "RT::Win.init: #{[high, wide, r0, c0, border]}"
|
11
10
|
@wide, @high, @r0, @c0 = wide, high, r0, c0
|
12
11
|
@border, @fg, @bg = border, fg, bg
|
13
12
|
@cwin = X::Window.new(high, wide, r0, c0)
|
14
|
-
debug "outer = #{@cwin.inspect}"
|
15
|
-
debug "@border = #@border"
|
16
|
-
debug "Calling 'colors': #{[@cwin, fg, bg]}"
|
17
13
|
RubyText::Window.colors!(@cwin, fg, bg)
|
18
14
|
if @border
|
19
15
|
@cwin.box(Vert, Horiz)
|
20
16
|
@outer = @cwin
|
21
17
|
@outer.refresh
|
22
|
-
debug "About to call again: params = #{[high-2, wide-2, r0+1, c0+1]}"
|
23
18
|
@cwin = X::Window.new(high-2, wide-2, r0+1, c0+1)
|
24
19
|
RubyText::Window.colors!(@cwin, fg, bg)
|
25
20
|
else
|
@@ -33,33 +28,17 @@ class RubyText::Window
|
|
33
28
|
end
|
34
29
|
|
35
30
|
def self.main(fg: nil, bg: nil, scroll: false)
|
36
|
-
|
31
|
+
main_win = X.init_screen
|
37
32
|
X.start_color
|
38
|
-
colors!(
|
39
|
-
|
40
|
-
rows, cols
|
41
|
-
|
42
|
-
fg: fg, bg: bg, scroll: scroll)
|
43
|
-
# FIXME Why is this hard to inline?
|
44
|
-
## Must be params...?
|
45
|
-
## def self.make(cwin, high, wide, r0, c0, border, fg: White, bg: Black, scroll: false)
|
46
|
-
# obj = self.allocate
|
47
|
-
# obj.instance_eval do
|
48
|
-
# @outer = @cwin = @main_win
|
49
|
-
# @wide, @high, @r0, @c0 = cols, rows, 0, 0
|
50
|
-
# @fg, @bg = fg, bg
|
51
|
-
# @border = false
|
52
|
-
# @rows, @cols = @high, @wide
|
53
|
-
# @width, @height = @cols + 2, @rows + 2 if @border
|
54
|
-
# end
|
55
|
-
# obj.scrolling(scroll)
|
56
|
-
# obj
|
33
|
+
colors!(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)
|
57
37
|
end
|
58
38
|
|
59
39
|
def self.make(cwin, high, wide, r0, c0, border: true, fg: White, bg: Black, scroll: false)
|
60
40
|
obj = self.allocate
|
61
41
|
obj.instance_eval do
|
62
|
-
# debug " Inside instance_eval..."
|
63
42
|
@outer = @cwin = cwin
|
64
43
|
@wide, @high, @r0, @c0 = wide, high, r0, c0
|
65
44
|
@fg, @bg = fg, bg
|
@@ -74,21 +53,26 @@ class RubyText::Window
|
|
74
53
|
# FIXME refactor bad code
|
75
54
|
|
76
55
|
def scrolling(flag=true)
|
56
|
+
@scrolling = flag
|
77
57
|
@cwin.scrollok(flag)
|
78
58
|
end
|
79
59
|
|
80
60
|
def noscroll
|
61
|
+
@scrolling = false
|
81
62
|
@cwin.scrollok(false)
|
82
63
|
end
|
83
64
|
|
84
65
|
def scroll(n=1)
|
85
|
-
n
|
86
|
-
@cwin.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
92
76
|
end
|
93
77
|
@cwin.refresh
|
94
78
|
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.
|
4
|
+
version: 0.0.62
|
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-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|