Module: RubyText
- Defined in:
- lib/version.rb,
lib/rubytext.rb,
lib/rubytext.rb
Defined Under Namespace
Modules: Keys
Classes: Window
Constant Summary
collapse
- VERSION =
"0.0.18"
- Path =
File.expand_path(File.join(File.dirname(__FILE__)))
- Colors =
%w[black blue cyan green magenta red white yellow]
- ColorPairs =
{}
Class Method Summary
collapse
-
.hide_cursor ⇒ Object
-
.method_missing(name, *args) ⇒ Object
For passing through arbitrary method calls to the lower level…
-
.show_cursor ⇒ Object
-
.show_cursor! ⇒ Object
-
.start(*args, log: nil, fg: nil, bg: nil) ⇒ Object
-
.window(high, wide, r0, c0, border = false, fg = "white", bg = "black") ⇒ Object
Class Method Details
.hide_cursor ⇒ Object
134
135
136
|
# File 'lib/rubytext.rb', line 134
def self.hide_cursor
X.curs_set(0)
end
|
.method_missing(name, *args) ⇒ Object
For passing through arbitrary method calls to the lower level…
90
91
92
93
94
95
96
97
|
# File 'lib/rubytext.rb', line 90
def self.method_missing(name, *args)
debug "method_missing: #{name} #{args.inspect}"
if name[0] == '_'
X.send(name[1..-1], *args)
else
raise "#{name} #{args.inspect}"
end
end
|
.show_cursor ⇒ Object
138
139
140
|
# File 'lib/rubytext.rb', line 138
def self.show_cursor
X.curs_set(1)
end
|
.show_cursor! ⇒ Object
142
143
144
|
# File 'lib/rubytext.rb', line 142
def self.show_cursor!
X.curs_set(2)
end
|
.start(*args, log: nil, fg: nil, bg: nil) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/rubytext.rb', line 103
def self.start(*args, log: nil, fg: nil, bg: nil)
$debug = File.new(log, "w") if log
fg ||= :white
bg ||= :black
debug "fg = #{fg} is not a valid color" unless Colors.include?(fg.to_s)
debug "bg = #{bg} is not a valid color" unless Colors.include?(bg.to_s)
debug "Colors are: #{fg} on #{bg}"
fg = X.const_get("COLOR_#{fg.upcase}")
bg = X.const_get("COLOR_#{bg.upcase}")
debug "Curses colors are: #{fg} on #{bg}"
cp = ColorPairs[[fg, bg]]
debug "cp is: #{cp}"
X.stdscr.bkgd(cp|X::A_NORMAL)
X.noecho
X.stdscr.keypad(true)
X.cbreak
args.each do |arg|
case arg
when :raw
X.raw
when :echo
X.echo
when :noecho
X.noecho
when :color
X.start_color
end
end
end
|
.window(high, wide, r0, c0, border = false, fg = "white", bg = "black") ⇒ Object
99
100
101
|
# File 'lib/rubytext.rb', line 99
def RubyText.window(high, wide, r0, c0, border=false, fg="white", bg="black")
RubyText::Window.new(high, wide, r0, c0, border, fg, bg)
end
|