Top Level Namespace

Defined Under Namespace

Modules: RubyText

Constant Summary collapse

Colors =
[Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]
X =

shorthand

Curses

Instance Method Summary collapse

Instance Method Details

#debug(*args) ⇒ Object



56
57
58
59
# File 'lib/rubytext.rb', line 56

def debug(*args)
  return unless $debug
  $debug.puts *args
end

#fb2cp(fg, bg) ⇒ Object



2
3
4
5
6
7
8
9
# File 'lib/color.rb', line 2

def fb2cp(fg, bg)
  fg ||= Blue
  bg ||= White
  f2 = X.const_get("COLOR_#{fg.upcase}")
  b2 = X.const_get("COLOR_#{bg.upcase}")
  cp = $ColorPairs[[fg, bg]]
  [f2, b2, cp]
end

#getch ⇒ Object



148
149
150
# File 'lib/output.rb', line 148

def getch
  X.getch
end

#import(meth, recv) ⇒ Object



38
39
40
41
42
# File 'lib/rubytext.rb', line 38

def import(meth, recv)
  Kernel.module_eval do
    define_method(meth) {|*args| recv.send(meth, *args) }
  end
end

#make_exception(sym, str) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/rubytext.rb', line 44

def make_exception(sym, str)
  return if Object.constants.include?(sym)
  Object.const_set(sym, StandardError.dup)
  define_method(sym) do |*args|
    msg = str
    args.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
    Object.class_eval(sym.to_s).new(msg)
  end
end

#p(*args) ⇒ Object



140
141
142
# File 'lib/output.rb', line 140

def p(*args)
  $stdscr.p(*args)
end


136
137
138
# File 'lib/output.rb', line 136

def print(*args)
  $stdscr.print(*args)
end

#puts(*args) ⇒ Object

into top level...



132
133
134
# File 'lib/output.rb', line 132

def puts(*args)       # Doesn't affect STDOUT.puts, etc.
  $stdscr.puts(*args)
end

#rcprint(r, c, *args) ⇒ Object



144
145
146
# File 'lib/output.rb', line 144

def rcprint(r, c, *args)
  $stdscr.rcprint r, c, *args
end