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.21"
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



164
165
166
# File 'lib/rubytext.rb', line 164

def self.hide_cursor
  X.curs_set(0)
end

.method_missing(name, *args) ⇒ Object

For passing through arbitrary method calls to the lower level…



151
152
153
154
155
156
157
158
# File 'lib/rubytext.rb', line 151

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

.show_cursorObject



168
169
170
# File 'lib/rubytext.rb', line 168

def self.show_cursor
  X.curs_set(1)
end

.show_cursor!Object



172
173
174
# File 'lib/rubytext.rb', line 172

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

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



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/rubytext.rb', line 122

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

  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)
  fg, bg, cp = fb2cp(fg, bg)
  X.noecho
  X.stdscr.keypad(true)
  X.cbreak   # by default

  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: nil, bg: nil) ⇒ Object



160
161
162
# File 'lib/rubytext.rb', line 160

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