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.33"
Path =
File.expand_path(File.join(File.dirname(__FILE__)))
Colors =
%w[black blue cyan green magenta red white yellow]

Class Method Summary collapse

Class Method Details

.hide_cursorObject



150
151
152
# File 'lib/rubytext.rb', line 150

def self.hide_cursor
  X.curs_set(0)
end

.method_missing(name, *args) ⇒ Object

For passing through arbitrary method calls to the lower level…



137
138
139
140
141
142
143
144
# File 'lib/rubytext.rb', line 137

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}" # NoMethodError
  end
end

.set(*args) ⇒ Object



116
117
118
119
120
121
122
# File 'lib/rubytext.rb', line 116

def self.set(*args)
  args.each do |arg|
    flag = arg.to_s
    flag.sub!(/_/, "no")
    X.send(flag)
  end
end

.show_cursorObject



154
155
156
# File 'lib/rubytext.rb', line 154

def self.show_cursor
  X.curs_set(1)
end

.show_cursor!Object



158
159
160
# File 'lib/rubytext.rb', line 158

def self.show_cursor!
  X.curs_set(2)  # Doesn't work?
end

.start(*args, log: nil, fg: nil, bg: nil) ⇒ Object



124
125
126
127
128
129
130
131
132
# File 'lib/rubytext.rb', line 124

def self.start(*args, log: nil, fg: nil, bg: nil)
  $debug = File.new(log, "w") if log
  Object.const_set(:STDSCR, RubyText::Window.main(fg: fg, bg: bg))
  $stdscr = STDSCR
  fg, bg, cp = fb2cp(fg, bg)
  self.set(:_echo, :cbreak, :raw)  # defaults
#   X.stdscr.keypad(true)
  self.set(*args)  # override defaults
end

.window(high, wide, r0, c0, border = false, fg: nil, bg: nil) ⇒ Object



146
147
148
# File 'lib/rubytext.rb', line 146

def RubyText.window(high, wide, r0, c0, border=false, fg: nil, bg: nil)
  RubyText::Window.new(high, wide, r0, c0, border, fg, bg)
end