{: rooto:"YARD::CodeObjects::RootObject:@childrenIC:&YARD::CodeObjects::CodeObjectList[ o:&YARD::CodeObjects::ConstantObject: @files[[I" color.rb:ETi :@current_file_has_commentsF: @name: Colors:@source_type: ruby:@visibility: public: @tags[:@docstrings{:@docstringIC:YARD::Docstring" ; T;[:@ref_tags[: @allI"; T:@unresolved_reference0: @object@:@namespace@: @pathI" Colors; F: @sourceI"EColors = [Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]; T: @valueI"<[Black, Blue, Cyan, Green, Magenta, Red, White, Yellow]; To:$YARD::CodeObjects::MethodObject:@module_functionF: @scope: instance;;;I"#fx; T:@parameters[[I"str; T0[I" *args; T0[I"bg:; TI"nil; T; [[I"effects.rb; Ti ; T; :fx;;;[;{;IC;"6Helper method: insert text effects while printing; T;[;[;I"6Helper method: insert text effects while printing; T;0;@:@ref_tag_recurse_counti:@hash_flagF:@line_rangeo: Range: exclF: begini:endi;@:@explicitT;I"def fx(str, *args, bg: nil) eff = RubyText::Effects.new(*args, bg: bg) str.define_singleton_method(:effect) { eff } str # must return str end; T:@signatureI" def fx(str, *args, bg: nil); To:$YARD::CodeObjects::ModuleObject;IC;[o:#YARD::CodeObjects::ClassObject;IC;[Ho;; F;!;";;;I"RubyText::Window#topmenu; F;#[ [I" items:; T0[I" curr:; TI"0; T[I"fg:; TI" Green; T[I"bg:; TI" Black; T; [[I" menu.rb; Ti; T; : topmenu;;;[;{;IC;"#One-line menu at top of window; T;[;[;I"#One-line menu at top of window; T;0;@/;%i;&F;'o;(;)F;*i;+i;@-;,T;I"def topmenu(items:, curr: 0, fg: Green, bg: Black) r, c = 0, 0 high = 1 RubyText.hide_cursor if items.is_a?(Hash) results = items.values items = items.keys hash_flag = true else results = items end width = 0 # total width cols = [] # start-column of each item items.each do |item| cols << width iwide = item.to_s.length + 2 width += iwide end r, c = self.coords(r, c) self.saveback(high, width, r, c) mr, mc = r+self.r0, c+self.c0 mwin = RubyText.window(high, width, r: mr, c: mc, fg: fg, bg: bg, border: false, title: nil) Curses.stdscr.keypad(true) sel = curr max = items.size - 1 loop do items.each.with_index do |item, num| item = " #{item} " mwin.go 0, cols[num] style = (sel == num) ? :reverse : :normal mwin.print fx(item, style) end ch = getch case ch when Left sel -= 1 if sel > 0 when Right sel += 1 if sel < max when Esc, " " # spacebar also quits self.restback(high, width, r, c) RubyText.show_cursor return [nil, nil] when Down, Enter self.restback(high, width, r, c) RubyText.show_cursor choice = results[sel] return [sel, choice] if choice.is_a? String result = choice.call next if result.nil? next if result.empty? return result else Curses.beep end RubyText.show_cursor end end; T;-I"7def topmenu(items:, curr: 0, fg: Green, bg: Black); T: @dynamicTo;; F;!;";;;I"RubyText::Window#menu; F;#[ [I"r:; TI" :center; T[I"c:; TI" :center; T[I" items:; T0[I" curr:; TI"0; T[I" border:; TI" true; T[I" title:; TI"nil; T[I"fg:; TI" Green; T[I"bg:; TI" Black; T; [[@?iN; T; : menu;;;[;{;IC;"%Simple menu with rows of strings; T;[;[;I"%Simple menu with rows of strings; T;0;@I;%i;&F;'o;(;)F;*iL;+iL;@-;,T;I"def menu(r: :center, c: :center, items:, curr: 0, border: true, title: nil, fg: Green, bg: Black) RubyText.hide_cursor if items.is_a?(Hash) results = items.values items = items.keys hash_flag = true else results = items end high = items.size wide = items.map(&:length).max + 3 high += 2 if border wide += 2 if border tlen = title.length + 8 rescue 0 wide = [wide, tlen].max row, col = self.coords(r, c) row = row - high/2 if r == :center col = col - wide/2 if c == :center r, c = row, col self.saveback(high, wide, r, c) mr, mc = r+self.r0, c+self.c0 title = nil unless border mwin = RubyText.window(high, wide, r: mr, c: mc, border: border, fg: fg, bg: bg, title: title) Curses.stdscr.keypad(true) sel = curr max = items.size - 1 loop do RubyText.hide_cursor # FIXME should be unnecessary items.each.with_index do |item, row| mwin.go row, 0 style = (sel == row) ? :reverse : :normal label = (" "*2 + item.to_s + " "*8)[0..wide-1] mwin.print fx(label, style) end ch = getch case ch when Up sel -= 1 if sel > 0 when Down sel += 1 if sel < max when Esc self.restback(high, wide, r, c) RubyText.show_cursor return [nil, nil] when Enter self.restback(high, wide, r, c) RubyText.show_cursor choice = results[sel] return [sel, choice] if choice.is_a? String result = choice.call return [nil, nil] if result.nil? || result.empty? return result else Curses.beep end RubyText.show_cursor end end; T;-I"fdef menu(r: :center, c: :center, items:, curr: 0, border: true, title: nil, fg: Green, bg: Black); T;1To;; F;!;";;;I"RubyText::Window#multimenu; F;#[[I"r:; TI" :center; T[I"c:; TI" :center; T[I" items:; T0[I" curr:; TI"0; T[I"selected:; TI"[]; T[I" title:; TI"nil; T[I" sel_fg:; TI" Yellow; T[I"fg:; TI" White; T[I"bg:; TI" Blue; T; [[@?i; T; :multimenu;;;[;{;IC;"1Menu for multiple selections (buggy/unused?); T;[;[;I"1Menu for multiple selections (buggy/unused?); T;0;@n;%i;&F;'o;(;)F;*i;+i;@-;,T;I"def multimenu(r: :center, c: :center, items:, curr: 0, selected: [], title: nil, sel_fg: Yellow, fg: White, bg: Blue) RubyText.hide_cursor high = items.size + 2 wide = items.map(&:length).max + 5 tlen = title.length + 8 rescue 0 wide = [wide, tlen].max row, col = self.coords(r, c) row = row - high/2 if r == :center col = col - wide/2 if c == :center r, c = row, col self.saveback(high, wide, r, c) mr, mc = r+self.r0, c+self.c0 mwin = RubyText.window(high, wide, r: mr, c: mc, fg: fg, bg: bg, title: title) Curses.stdscr.keypad(true) sel = curr max = items.size - 1 loop do RubyText.hide_cursor # FIXME should be unnecessary items.each.with_index do |item, row| mwin.go row, 0 style = (sel == row) ? :reverse : :normal color = selected.include?(row) ? sel_fg : fg label = (" "*2 + item + " "*8)[0..wide-1] mwin.print fx(label, color, style) end ch = getch case ch when Up sel -= 1 if sel > 0 when Down sel += 1 if sel < max when Esc self.restback(high, wide, r, c) RubyText.show_cursor return [] when Enter self.restback(high, wide, r, c) RubyText.show_cursor return selected.map {|i| items[i] } when " " selected << sel sel += 1 if sel < max else Curses.beep end RubyText.show_cursor end end; T;-I"zdef multimenu(r: :center, c: :center, items:, curr: 0, selected: [], title: nil, sel_fg: Yellow, fg: White, bg: Blue); T;1To;; F;!;";;;I"RubyText::Window#yesno; F;#[; [[@?i; T; : yesno;;;[;{;IC;"Simple yes/no decision; T;[;[;I"Simple yes/no decision; T;0;@;%i;&F;'o;(;)F;*i;+i;@-;,T;I"~def yesno # TODO: Accept YyNn r, c = STDSCR.rc num, str = STDSCR.menu(r: r, c: c+6, items: ["yes", "no"]) num == 0 end; T;-I"def yesno; T;1To;; F;!;";;;I" RubyText::Window#radio_menu; F;#[ [I"r:; TI" :center; T[I"c:; TI" :center; T[I" items:; T0[I" curr:; TI"0; T[I" border:; TI" true; T[I" title:; TI"nil; T[I"fg:; TI" Green; T[I"bg:; TI" Black; T; [[@?i; T; :radio_menu;;;[;{;IC;"2Menu to choose a single setting and retain it; T;[;[;I"2Menu to choose a single setting and retain it; T;0;@;%i;&F;'o;(;)F;*i;+i;@-;,T;I""def radio_menu(r: :center, c: :center, items:, curr: 0, # Handle current value better? border: true, title: nil, fg: Green, bg: Black) RubyText.hide_cursor if items.is_a?(Hash) results = items.values items = items.keys hash_flag = true else results = items end high = items.size wide = items.map(&:length).max + 3 high += 2 if border wide += 2 if border tlen = title.length + 8 rescue 0 wide = [wide, tlen].max row, col = self.coords(r, c) row = row - high/2 if r == :center col = col - wide/2 if c == :center r, c = row, col self.saveback(high, wide, r, c) mr, mc = r+self.r0, c+self.c0 title = nil unless border mwin = RubyText.window(high, wide, r: mr, c: mc, border: border, fg: fg, bg: bg, title: title) Curses.stdscr.keypad(true) sel = curr max = items.size - 1 loop do RubyText.hide_cursor # FIXME should be unnecessary items.each.with_index do |item, row| mark = row == curr ? ">" : " " mwin.go row, 0 style = (sel == row) ? :reverse : :normal label = "#{mark} #{item}" mwin.print fx(label, style) end ch = getch case ch when Up sel -= 1 if sel > 0 when Down sel += 1 if sel < max when Esc self.restback(high, wide, r, c) RubyText.show_cursor return [nil, nil] when " " mwin[curr, 0] = " " mwin[sel, 0] = ">" curr = sel when Enter self.restback(high, wide, r, c) RubyText.show_cursor choice = results[sel] return [sel, choice] if choice.is_a? String result = choice.call return [nil, nil] if result.nil? || result.empty? return result else Curses.beep end RubyText.show_cursor end end; T;-I"def radio_menu(r: :center, c: :center, items:, curr: 0, # Handle current value better? border: true, title: nil, fg: Green, bg: Black); T;1To;; F;!;";;;I"RubyText::Window#coords; F;#[[I"r; T0[I"c; T0; [[I"navigation.rb; Ti ; T; : coords;;;[;{;IC;".Handle special coordinate names (symbols); T;[;[;I".Handle special coordinate names (symbols); T;0;@;%i;&F;'o;(;)F;*i ;+i ;@-;,T;I"def coords(r, c) r = case when r == :center self.rows / 2 when r == :top 0 when r == :bottom self.rows - 1 else r end c = case when c == :center self.cols / 2 when c == :left 0 when c == :right self.cols - 1 else c end [r, c] end; T;-I"def coords(r, c); T;1To;; F;!;";;;I"RubyText::Window#goto; F;#[[I"r; T0[I"c; T0; [[@i&; T; : goto;;;[;{;IC;"1Go to specified row/column in current window; T;[;[;I"1Go to specified row/column in current window; T;0;@;%i;&F;'o;(;)F;*i$;+i$;@-;,T;I"Edef goto(r, c) # only accepts numbers! @cwin.setpos(r, c) end; T;-I"def goto(r, c); T;1To;; F;!;";;;I"RubyText::Window#go; F;#[[I"r0; T0[I"c0; T0; [[@i.; T; :go;;;[;{;IC;"UGo to specified row/column in current window, execute block, and return cursor; T;[;[;I"UGo to specified row/column in current window, execute block, and return cursor; T;0;@;%i;&F;'o;(;)F;*i+;+i,;@-;,T;I"def go(r0, c0) r, c = coords(r0, c0) save = self.rc goto r, c if block_given? yield goto *save end end; T;-I"def go(r0, c0); T;1To;; F;!;";;;I"RubyText::Window#up; F;#[[I"n; TI"1; T; [[@i:; T; :up;;;[;{;IC;"Move cursor up; T;[;[;I"Move cursor up; T;0;@;%i;&F;'o;(;)F;*i8;+i8;@-;,T;I",def up(n=1) r, c = rc go r-n, c end; T;-I"def up(n=1); T;1To;; F;!;";;;I"RubyText::Window#down; F;#[[I"n; TI"1; T; [[@iA; T; : down;;;[;{;IC;"Move cursor down; T;[;[;I"Move cursor down; T;0;@ ;%i;&F;'o;(;)F;*i?;+i?;@-;,T;I".def down(n=1) r, c = rc go r+n, c end; T;-I"def down(n=1); T;1To;; F;!;";;;I"RubyText::Window#left; F;#[[I"n; TI"1; T; [[@iH; T; : left;;;[;{;IC;"Move cursor left; T;[;[;I"Move cursor left; T;0;@;%i;&F;'o;(;)F;*iF;+iF;@-;,T;I".def left(n=1) r, c = rc go r, c-n end; T;-I"def left(n=1); T;1To;; F;!;";;;I"RubyText::Window#right; F;#[[I"n; TI"1; T; [[@iO; T; : right;;;[;{;IC;"Move cursor right; T;[;[;I"Move cursor right; T;0;@.;%i;&F;'o;(;)F;*iM;+iM;@-;,T;I"/def right(n=1) r, c = rc go r, c+n end; T;-I"def right(n=1); T;1To;; F;!;";;;I"RubyText::Window#top; F;#[; [[@iV; T; :top;;;[;{;IC;"!Move cursor to top of window; T;[;[;I"!Move cursor to top of window; T;0;@?;%i;&F;'o;(;)F;*iT;+iT;@-;,T;I"&def top r, c = rc go 0, c end; T;-I" def top; T;1To;; F;!;";;;I"RubyText::Window#bottom; F;#[; [[@i]; T; : bottom;;;[;{;IC;"$Move cursor to bottom of window; T;[;[;I"$Move cursor to bottom of window; T;0;@M;%i;&F;'o;(;)F;*i[;+i[;@-;,T;I"Ddef bottom r, c = rc rmax = self.rows - 1 go rmax, c end; T;-I"def bottom; T;1To;; F;!;";;;I"RubyText::Window#up!; F;#[; [[@ie; T; :up!;;;[;{;IC;"!Move cursor to top of window; T;[;[;I"!Move cursor to top of window; T;0;@[;%i;&F;'o;(;)F;*ic;+ic;@-;,T;I"def up! top end; T;-I" def up!; T;1To;; F;!;";;;I"RubyText::Window#down!; F;#[; [[@ik; T; : down!;;;[;{;IC;"$Move cursor to bottom of window; T;[;[;I"$Move cursor to bottom of window; T;0;@i;%i;&F;'o;(;)F;*ii;+ii;@-;,T;I"def down! bottom end; T;-I"def down!; T;1To;; F;!;";;;I"RubyText::Window#left!; F;#[; [[@iq; T; : left!;;;[;{;IC;"&Move cursor to far left of window; T;[;[;I"&Move cursor to far left of window; T;0;@w;%i;&F;'o;(;)F;*io;+io;@-;,T;I"(def left! r, c = rc go r, 0 end; T;-I"def left!; T;1To;; F;!;";;;I"RubyText::Window#right!; F;#[; [[@ix; T; : right!;;;[;{;IC;"&Move cursor to far left of window; T;[;[;I"&Move cursor to far left of window; T;0;@;%i;&F;'o;(;)F;*iv;+iv;@-;,T;I"Cdef right! r, c = rc cmax = self.cols - 1 go r, cmax end; T;-I"def right!; T;1To;; F;!;";;;I"RubyText::Window#home; F;#[; [[@i{; T; : home;;;[;{;IC;"%Move cursor to home (upper left); T;[;[;I"%Move cursor to home (upper left); T;0;@;%i;&F;'o;(;)F;*i~;+i~;@-;,T;I"def home go 0, 0 end; T;-I" def home; T;1To;; F;!;";;;I"RubyText::Window#rc; F;#[; [[@i; T; :rc;;;[;{;IC;"Return current row/column; T;[;[;I"Return current row/column; T;0;@;%i;&F;'o;(;)F;*i;+i;@-;,T;I"*def rc [@cwin.cury, @cwin.curx] end; T;-I" def rc; T;1To;; F;!;";;;I"RubyText::Window#center; F;#[[I"str; T0; [[I"output.rb; Ti ; F; : center;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"cdef center(str) r, c = self.rc n = @cwin.maxx - str.length go r, n/2 self.puts str end; T;-I"def center(str); T;1To;; F;!;";;;I"RubyText::Window#effect?; F;#[[I"arg; T0; [[@i; T; : effect?;;;[;{;IC;"/FIXME Please refactor the Hal out of this.; T;[o:YARD::Tags::Tag :@tag_nameI" return; F: @text@; 0: @types[I" Boolean; T;@;[;I"/FIXME Please refactor the Hal out of this.; T;0;@;%i;&F;'o;(;)F;*i;+i;@-;,T;I"8def effect?(arg) arg.is_a?(RubyText::Effects) end; T;-I"def effect?(arg); T;1To;; F;!;";;;I"%RubyText::Window#delegate_output; F;#[[I"sym; T0[I" *args; T0; [[@i; F; :delegate_output;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I")def delegate_output(sym, *args) self.cwin.attrset(0) args = [""] if args.empty? args += ["\n"] if sym == :puts set_colors(@fg, @bg) meth = sym == :p ? :inspect : :to_s args.map! {|x| effect?(x) ? x : x.send(meth) } args.each do |arg| if arg.is_a?(RubyText::Effects) arg.set(self) else arg.effect.set(self) if arg.respond_to? :effect arg.each_char {|ch| ch == "\n" ? crlf : @cwin.addch(ch) } @cwin.refresh end end crlf if sym == :p # no implicit newline set_colors(@fg, @bg) @cwin.refresh end; T;-I"$def delegate_output(sym, *args); T;1To;; F;!;";;;I"RubyText::Window#puts; F;#[[I" *args; T0; [[@i/; F; : puts;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"8def puts(*args) delegate_output(:puts, *args) end; T;-I"def puts(*args); T;1To;; F;!;";;;I"RubyText::Window#print; F;#[[I" *args; T0; [[@i3; F; : print;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I":def print(*args) delegate_output(:print, *args) end; T;-I"def print(*args); T;1To;; F;!;";;;I"RubyText::Window#p; F;#[[I" *args; T0; [[@i7; F; :p;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"2def p(*args) delegate_output(:p, *args) end; T;-I"def p(*args); T;1To;; F;!;";;;I"RubyText::Window#rcprint; F;#[[I"r; T0[I"c; T0[I" *args; T0; [[@i;; F; : rcprint;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@-;,T;I"Fdef rcprint(r, c, *args) self.go(r, c) { self.print *args } end; T;-I"def rcprint(r, c, *args); T;1To;; F;!;";;;I"RubyText::Window#rcprint!; F;#[[I"r; T0[I"c; T0[I" *args; T0; [[@i?; F; : rcprint!;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"^def rcprint!(r, c, *args) self.go(r, c) # Cursor isn't restored self.print *args end; T;-I"def rcprint!(r, c, *args); T;1To;; F;!;";;;I"RubyText::Window#_putch; F;#[[I"ch; T0; [[@iD; F; : _putch;;;[;{;IC;" ; T;[;[;@;0;@0;%i;@-;,T;I")def _putch(ch) @cwin.addch(ch) end; T;-I"def _putch(ch); T;1To;; F;!;";;;I"RubyText::Window#putch; F;#[ [I"ch; T0[I"r:; TI"nil; T[I"c:; TI"nil; T[I"fx:; TI"nil; T; [[@iH; F; : putch;;;[;{;IC;" ; T;[;[;@;0;@>;%i;@-;,T;I"Ydef putch(ch, r: nil, c: nil, fx: nil) debug("putch: #{[ch, r, c, fx].inspect}") if r.nil? && c.nil? && fx.nil? _putch(ch) else r0, c0 = self.rc r ||= r0 c ||= c0 go(r, c) do fx.set(self) if fx val = fx.value rescue 0 @cwin.addch(ch.ord|val) end fx.reset(self) if fx end @cwin.refresh end; T;-I"+def putch(ch, r: nil, c: nil, fx: nil); T;1To;; F;!;";;;I"RubyText::Window#crlf; F;#[; [[@iZ; T; : crlf;;;[;{;IC;"Technically not output...; T;[;[;I"Technically not output...; T;0;@U;%i;&F;'o;(;)F;*iZ;+iZ;@-;,T;I"def crlf # Technically not output... r, c = rc if @scrolling if r == @rows - 1 # bottom row scroll left! else go r+1, 0 end else if r == @rows - 1 # bottom row left! else go r+1, 0 end end end; T;-I" def crlf; T;1To;; F;!: class;;;I"RubyText::Window.clear; F;#[[I"win; T0; [[@il; T; : clear;;;[;{;IC;"delete this?; T;[;[;I"delete this?; T;0;@c;%i;&F;'o;(;)F;*il;+il;@-;,T;I"def self.clear(win) # delete this? num = win.maxx * win.maxy - 1 win.setpos(0, 0) win.addstr(' '*num) win.setpos(0, 0) win.refresh end; T;-I"def clear(win); T;1To;; F;!;";;;I"RubyText::Window#clear; F;#[; [[@it; F; ;U;;;[;{;IC;" ; T;[;[;@;0;@s;%i;@-;,T;I"def clear cwin.setpos(cwin.maxx, cwin.maxy) cwin.addstr(' ') num = cwin.maxx * cwin.maxy - 1 cwin.addstr(' '*num) cwin.setpos(0, 0) cwin.refresh end; T;-I"def clear; T;1To;; F;!;";;;I"RubyText::Window#output; F;#[[I" &block; T0; [[@i}; F; : output;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"Ldef output(&block) $stdscr = self block.call $stdscr = STDSCR end; T;-I"def output(&block); T;1To;; F;!;";;;I"RubyText::Window#[]; F;#[[I"r; T0[I"c; T0; [[@i~; F; :[];;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"qdef [](r, c) ch = nil go(r, c) { ch = @cwin.inch } debug "ch = #{ch} ch.chr = #{ch.chr}" ch.chr end; T;-I"def [](r, c); T;1To;; F;!;";;;I"RubyText::Window#[]=; F;#[[I"r; T0[I"c; T0[I" char; T0; [[@i; F; :[]=;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"}def []=(r, c, char) @cwin.setpos(r, c) @cwin.addch(char[0].ord|Curses::A_NORMAL) @cwin.setpos(r, c) @cwin.refresh end; T;-I"def []=(r, c, char); T;1To;; F;!;";;;I"RubyText::Window#boxme; F;#[; [[@i; F; : boxme;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"=def boxme @outer.box(Vert, Horiz) @outer.refresh end; T;-I"def boxme; T;1To;; F;!;";;;I"RubyText::Window#refresh; F;#[; [[@i; F; : refresh;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"$def refresh @cwin.refresh end; T;-I"def refresh; T;1To;/;IC;[o;; F;!;";;;I"+RubyText::Window::GetString#initialize; F;#[ [I"win; TI" STDSCR; T[I"str; TI"""; T[I"i; TI"0; T[I" history:; TI"[]; T[I" limit:; TI"nil; T[I" tab:; TI"[]; T[I" capture:; TI"[]; T; [[@i; F; :initialize;;;[;{;IC;" ; T;[o;G ;HI" return; F;II" a new instance of GetString; T; 0;J[I"GetString; F;@o;G ;HI" raise; F;I@; 0;J[I"ArgumentError; T;@;[;@;0;@;%i;@;,T;I"def initialize(win = STDSCR, str = "", i = 0, history: [], limit: nil, tab: [], capture: []) @win = win @r0, @c0 = @win.rc @limit = limit || (@win.cols - @r0 - 1) raise ArgumentError unless @limit.is_a?(Numeric) @str, @i = str[0..(@limit-1)], i @str ||= "" @win.print @str @win.left @str.length @history = history @h = @history.length - 1 @maxlen = 0 # longest string in history list @tabcom = tab end; T;-I"adef initialize(win = STDSCR, str = "", i = 0, history: [], limit: nil, tab: [], capture: []); T;1To;; F;!;";;;I"&RubyText::Window::GetString#enter; F;#[; [[@i; F; : enter;;;[;{;IC;" ; T;[;[;@;0;@;%i;@;,T;I"Ldef enter @win.crlf @history << @str @h = @history.length - 1 end; T;-I"def enter; T;1To;; F;!;";;;I"+RubyText::Window::GetString#left_arrow; F;#[; [[@i; F; :left_arrow;;;[;{;IC;" ; T;[;[;@;0;@;%i;@;,T;I"Cdef left_arrow if @i > 0 @i -= 1 @win.left end end; T;-I"def left_arrow; T;1To;; F;!;";;;I",RubyText::Window::GetString#right_arrow; F;#[; [[@i; F; :right_arrow;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@;,T;I"Odef right_arrow if @i < @str.length @i += 1 @win.right end end; T;-I"def right_arrow; T;1To;; F;!;";;;I"*RubyText::Window::GetString#backspace; F;#[; [[@i; F; :backspace;;;[;{;IC;" ; T;[;[;@;0;@;%i;@;,T;I"def backspace # remember: may be in middle of string return if @i == 0 @i -= 1 @str[@i] = "" @win.left @win.rcprint @r0, @c0, @str + " " end; T;-I"def backspace; T;1To;; F;!;";;;I"-RubyText::Window::GetString#history_prev; F;#[; [[@i; F; :history_prev;;;[;{;IC;" ; T;[;[;@;0;@#;%i;@;,T;I"def history_prev return if @history.empty? @win.go @r0, @c0 @maxlen = @history.map(&:length).max @win.print(" "*@maxlen) @h = (@h - 1) % @history.length @str = @history[@h] @i = @str.length @win.go @r0, @c0 @win.print @str end; T;-I"def history_prev; T;1To;; F;!;";;;I"-RubyText::Window::GetString#history_next; F;#[; [[@i; F; :history_next;;;[;{;IC;" ; T;[;[;@;0;@/;%i;@;,T;I"def history_next return if @history.empty? @h = (@h + 1) % @history.length @win.go @r0, @c0 @maxlen = @history.map(&:length).max @win.print(" "*@maxlen) @str = @history[@h] @i = @str.length @win.go @r0, @c0 @win.print @str end; T;-I"def history_next; T;1To;; F;!;";;;I")RubyText::Window::GetString#complete; F;#[; [[@i; F; : complete;;;[;{;IC;" ; T;[;[;@;0;@;;%i;@;,T;I"[def complete targets = @tabcom.find_all {|x| x.start_with?(@str) } if targets.nil? # Curses.beep @win.print "???" return end if targets.size > 1 num, target = @win.menu(items: targets) else target = targets.first end @str = target.nil? ? "" : target.dup @i = @str.length @win.go @r0, @c0 @win.print @str end; T;-I"def complete; T;1To;; F;!;";;;I"$RubyText::Window::GetString#add; F;#[[I"ch; T0; [[@i; F; :add;;;[;{;IC;" ; T;[;[;@;0;@G;%i;@;,T;I"def add(ch) if @str.length >= @limit Curses.beep return end @str.insert(@i, ch) @win.right @win.go(@r0, @c0) { @win.print @str } @i += 1 end; T;-I"def add(ch); T;1To;; F;!;";;;I"&RubyText::Window::GetString#value; F;#[; [[@i; F; : value;;;[;{;IC;" ; T;[;[;@;0;@U;%i;@;,T;I"def value @str end; T;-I"def value; T;1T: @owner@:@class_mixinsIC;[;e@:@instance_mixinsIC;[;e@:@attributesIC:SymbolHash{;TIC;i{:@symbolize_valueT;"IC;i{;jT;jT: @aliases{: @groups[; [[@i; F; :GetString;;;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;I" RubyText::Window::GetString; F:@superclasso:YARD::CodeObjects::Proxy :@orignamespace0:@origname0: @imethod0; : Object;@: @obj0: @type;T;1To;; F;!;";;;I"RubyText::Window#gets; F;#[ [I" history:; TI"[]; T[I" limit:; TI"nil; T[I" tab:; TI"[]; T[I" default:; TI"""; T[I" capture:; TI"[]; T; [[@i; F; : gets;;;[;{;IC;" ; T;[;[;@;0;@q;%i;@-;,T;I"def gets(history: [], limit: nil, tab: [], default: "", capture: []) # needs improvement # echo assumed to be OFF, keypad ON @history = history gs = GetString.new(self, default, history: history, limit: limit, tab: tab, capture: capture) count = 0 loop do count += 1 # Escape and 'capture' chars have special meaning if first char ch = self.getch case ch when *capture return ch if count == 1 gs.add(ch) when Escape return Escape if count == 1 gs.enter break when CtlD return CtlD if count == 1 gs.enter break when Enter gs.enter break when BS, DEL, 63 # backspace, del, ^H (huh?) gs.backspace when Tab gs.complete when Left gs.left_arrow when Right gs.right_arrow when Up next if @history.nil? # move this? gs.history_prev when Down next if @history.nil? # move this? gs.history_next when Integer Curses.beep else gs.add(ch) end end gs.value rescue => err str = err.to_s + "\n" + err.backtrace.join("\n") raise str end; T;-I"Idef gets(history: [], limit: nil, tab: [], default: "", capture: []); T;1To; ; [[I"window.rb; Ti; F; :ScreenStack;;;;;[;{;IC;" ; T;[;[;@;0;@;@-;I""RubyText::Window::ScreenStack; F;I"ScreenStack = []; T;I"[]; T;1To;; F;!;";;;I"RubyText::Window#cwin; F;#[; [[@i; F; : cwin;;;[;{;IC;")Returns the value of attribute cwin. ; T;[;[;I")Returns the value of attribute cwin.; T;0;@;&F: @summary0;@-;I"def cwin @cwin end; T;-I" def cwin; T;1To;; F;!;";;;I"RubyText::Window#rows; F;#[; [[@i; F; : rows;;;[;{;IC;")Returns the value of attribute rows. ; T;[;[;I")Returns the value of attribute rows.; T;0;@;&F;y0;@-;I"def rows @rows end; T;-I" def rows; T;1To;; F;!;";;;I"RubyText::Window#cols; F;#[; [[@i; F; : cols;;;[;{;IC;")Returns the value of attribute cols. ; T;[;[;I")Returns the value of attribute cols.; T;0;@;&F;y0;@-;I"def cols @cols end; T;-I" def cols; T;1To;; F;!;";;;I"RubyText::Window#width; F;#[; [[@i; F; : width;;;[;{;IC;"*Returns the value of attribute width. ; T;[;[;I"*Returns the value of attribute width.; T;0;@;&F;y0;@-;I"def width @width end; T;-I"def width; T;1To;; F;!;";;;I"RubyText::Window#height; F;#[; [[@i; F; : height;;;[;{;IC;"+Returns the value of attribute height. ; T;[;[;I"+Returns the value of attribute height.; T;0;@;&F;y0;@-;I"def height @height end; T;-I"def height; T;1To;; F;!;";;;I"RubyText::Window#scrolling; F;#[[I" flag; TI" true; T; [[@i_[@i; T; :scrolling;;;[;{;IC;"FIXME refactor bad code; T;[;[;I"FIXME refactor bad code; T;0;@;%i;&F;'o;(;)F;*i];+i];@-;,T;I"#def scrolling @scrolling end; T;-I"def scrolling; T;1To;; F;!;";;;I"RubyText::Window#r0; F;#[; [[@i; F; :r0;;;[;{;IC;"'Returns the value of attribute r0. ; T;[;[;I"'Returns the value of attribute r0.; T;0;@;&F;y0;@-;I"def r0 @r0 end; T;-I" def r0; T;1To;; F;!;";;;I"RubyText::Window#c0; F;#[; [[@i; F; :c0;;;[;{;IC;"'Returns the value of attribute c0. ; T;[;[;I"'Returns the value of attribute c0.; T;0;@;&F;y0;@-;I"def c0 @c0 end; T;-I" def c0; T;1To;; F;!;";;;I"RubyText::Window#fg; F;#[; [[@i; F; :fg;;;[;{;IC;"'Returns the value of attribute fg. ; T;[;[;I"'Returns the value of attribute fg.; T;0;@;&F;y0;@-;I"def fg @fg end; T;-I" def fg; T;1To;; F;!;";;;I"RubyText::Window#fg=; F;#[[I"sym; T0; [[@ iT[@i[@i; T; :fg=;;;[;{;IC;"Set foreground color; T;[;[;I"Set foreground color; T;0;@;%i;&F;'o;(;)F;*iR;+iR;@-;,T;I"%def fg=(value) @fg = value end; T;-I"def fg=(value); T;1To;; F;!;";;;I"RubyText::Window#bg; F;#[; [[@i; F; :bg;;;[;{;IC;"'Returns the value of attribute bg. ; T;[;[;I"'Returns the value of attribute bg.; T;0;@$;&F;y0;@-;I"def bg @bg end; T;-I" def bg; T;1To;; F;!;";;;I"RubyText::Window#bg=; F;#[[I"sym; T0; [[@ iZ[@i[@i; T; :bg=;;;[;{;IC;"Set background color; T;[;[;I"Set background color; T;0;@1;%i;&F;'o;(;)F;*iX;+iX;@-;,T;I"%def bg=(value) @bg = value end; T;-I"def bg=(value); T;1To;; F;!;";;;I" RubyText::Window#initialize; F;#[ [I" high; TI"nil; T[I" wide; TI"nil; T[I"r0; TI"0; T[I"c0; TI"0; T[I" border; TI" false; T[I"fg; TI" White; T[I"bg; TI" Blue; T[I" scroll; TI" false; T; [[@i; T; ;[;;;[;{;IC;"$Better to use Window.window IRL; T;[o;G ;HI" return; F;II"a new instance of Window; T; 0;J[I" Window; F;@C;[;I"%Better to use Window.window IRL ; T;0;@C;%i;&F;'o;(;)F;*i;+i;@-;,T;I"def initialize(high=nil, wide=nil, r0=0, c0=0, border=false, fg=White, bg=Blue, scroll=false) @wide, @high, @r0, @c0 = wide, high, r0, c0 @border, @fg, @bg = border, fg, bg @cwin = Curses::Window.new(high, wide, r0, c0) colorize!(fg, bg) if @border @cwin.box(Vert, Horiz) @outer = @cwin @outer.refresh @cwin = Curses::Window.new(high-2, wide-2, r0+1, c0+1) colorize!(fg, bg) else @outer = @cwin end @rows, @cols = @cwin.maxy, @cwin.maxx # unnecessary really... @width, @height = @cols + 2, @rows + 2 if @border @scrolling = scroll @cwin.scrollok(scroll) @cwin.refresh end; T;-I"bdef initialize(high=nil, wide=nil, r0=0, c0=0, border=false, fg=White, bg=Blue, scroll=false); T;1To;; F;!;T;;;I"RubyText::Window.main; F;#[[I"fg:; TI" White; T[I"bg:; TI" Blue; T[I" scroll:; TI" false; T; [[@i2; F; : main;;;[;{;IC;" ; T;[;[;@;0;@n;%i;@-;,T;I"def self.main(fg: White, bg: Blue, scroll: false) debug "Starting #main..." main_win = Curses.init_screen Curses.start_color self.colorize!(main_win, fg, bg) rows, cols = main_win.maxy, main_win.maxx win = self.make(main_win, rows, cols, 0, 0, border: false, fg: fg, bg: bg, scroll: scroll) debug "...started #main" win rescue => err File.open("/tmp/main.out", "w") {|f| f.puts err.inspect; f.puts err.backtrace } end; T;-I"1def main(fg: White, bg: Blue, scroll: false); T;1To;; F;!;T;;;I"RubyText::Window.make; F;#[[I" cwin; T0[I" high; T0[I" wide; T0[I"r0; T0[I"c0; T0[I" border:; TI" true; T[I"fg:; TI" White; T[I"bg:; TI" Black; T[I" scroll:; TI" false; T; [[@iB; T; : make;;;[;{;IC;"#FIXME try again to inline this; T;[;[;I"#FIXME try again to inline this; T;0;@;%i;&F;'o;(;)F;*i@;+i@;@-;,T;I"ydef self.make(cwin, high, wide, r0, c0, border: true, fg: White, bg: Black, scroll: false) obj = self.allocate obj.instance_eval do @outer = @cwin = cwin @wide, @high, @r0, @c0 = wide, high, r0, c0 @fg, @bg = fg, bg @border = border @rows, @cols = high, wide @width, @height = @cols + 2, @rows + 2 if @border end obj.scrolling(scroll) obj end; T;-I"Zdef make(cwin, high, wide, r0, c0, border: true, fg: White, bg: Black, scroll: false); T;1To;; F;!;";;;I"RubyText::Window#add_title; F;#[[I"str; T0[I" align; TI" :center; T; [[@iP; F; :add_title;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"Tdef add_title(str, align = :center) raise "No border" unless @border len = str.length # What if it's too long? start = case align when :left; 1 when :center; (@outer.maxx - len)/2 when :right; @outer.maxx - len - 1 end @outer.setpos 0, start @outer.addstr str @outer.refresh end; T;-I"(def add_title(str, align = :center); T;1To;; F;!;";;;I"RubyText::Window#scroll; F;#[[I"n; TI"1; T; [[@id; F; : scroll;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"def scroll(n=1) if n < 0 @cwin.scrl(n) (-n).times {|i| rcprint i, 0, (' '*@cols) } else n.times do |i| @cwin.scroll scrolling(false) rcprint @rows-1, 0, (' '*@cols) scrolling end end @cwin.refresh end; T;-I"def scroll(n=1); T;1To;; F;!;";;;I"!RubyText::Window#screen_text; F;#[[I" file; TI"nil; T; [[@is; T; :screen_text;;;[;{;IC;" rename?; T;[;[;I" rename?; T;0;@;%i;&F;'o;(;)F;*is;+is;@-;,T;I"def screen_text(file = nil) # rename? lines = [] 0.upto(self.rows-1) do |r| line = "" 0.upto(self.cols-1) do |c| line << self[r, c] end lines << line end File.open(file, "w") {|f| f.puts lines } if file lines end; T;-I" def screen_text(file = nil); T;1To;; F;!;";;;I" RubyText::Window#background; F;#[ [I" high; TI"STDSCR.rows; T[I" wide; TI"STDSCR.cols; T[I"r; TI"0; T[I"c; TI"0; T; [[@i{; F; :background;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"def background(high=STDSCR.rows, wide=STDSCR.cols, r=0, c=0) saveback(high, wide, r, c) yield restback(high, wide, r, c) end; T;-I"Adef background(high=STDSCR.rows, wide=STDSCR.cols, r=0, c=0); T;1To;; F;!;";;;I"RubyText::Window#saveback; F;#[ [I" high; TI"STDSCR.rows; T[I" wide; TI"STDSCR.cols; T[I"r; TI"0; T[I"c; TI"0; T; [[@i; F; : saveback;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"adef saveback(high=STDSCR.rows, wide=STDSCR.cols, r=0, c=0) debug "saveback: #{[high, wide, r, c].inspect}" save = [self.rc] 0.upto(high-1) do |h| 0.upto(wide-1) do |w| row, col = h+r-1, w+c-1 row += 1 if self == STDSCR # wtf? col += 1 if self == STDSCR save << self[row, col] end end ScreenStack.push save end; T;-I"?def saveback(high=STDSCR.rows, wide=STDSCR.cols, r=0, c=0); T;1To;; F;!;";;;I"RubyText::Window#restback; F;#[ [I" high; TI"STDSCR.rows; T[I" wide; TI"STDSCR.cols; T[I"r; TI"0; T[I"c; TI"0; T; [[@i; F; : restback;;;[;{;IC;" ; T;[;[;@;0;@;%i;@-;,T;I"def restback(high=STDSCR.rows, wide=STDSCR.cols, r=0, c=0) save = ScreenStack.pop pos = save.shift 0.upto(high-1) do |h| line = "" 0.upto(wide-1) {|w| line << save.shift } row, col = h+r-1, c-1 row += 1 if self == STDSCR # wtf? col += 1 if self == STDSCR self.go row, col self.print line end self.go *pos @cwin.refresh rescue => err puts "Error!" puts err puts err.backtrace.join("\n") sleep 8 end; T;-I"?def restback(high=STDSCR.rows, wide=STDSCR.cols, r=0, c=0); T;1To;; F;!;";;;I"RubyText::Window#beep; F;#[; [[@i; F; : beep;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@-;,T;I"def beep Curses.beep end; T;-I" def beep; T;1To;; F;!;";;;I"RubyText::Window#flash; F;#[; [[@i; F; : flash;;;[;{;IC;" ; T;[;[;@;0;@,;%i;@-;,T;I"!def flash Curses.flash end; T;-I"def flash; T;1To;; F;!;T;;;I"RubyText::Window.colorize!; F;#[[I" cwin; T0[I"fg; T0[I"bg; T0; [[@ i2; T; :colorize!;;;[;{;IC;"Set up a window with fg/bg; T;[;[;I"Set up a window with fg/bg; T;0;@8;%i;&F;'o;(;)F;*i0;+i0;@-;,T;I"3def self.colorize!(cwin, fg, bg) cp = RubyText::Color.pair(fg, bg) cwin.color_set(cp) num = cwin.maxx * cwin.maxy cwin.setpos 0,0 cwin.addstr(' '*num) cwin.setpos 0,0 cwin.refresh rescue => err File.open("/tmp/#{__method__}.out", "w") do |f| f.puts err f.puts err.backtrace end end; T;-I" def colorize!(cwin, fg, bg); T;1To;; F;!;";;;I" RubyText::Window#set_colors; F;#[[I"fg; T0[I"bg; T0; [[@ iC; T; :set_colors;;;[;{;IC;"'Assign color pair to curses window; T;[;[;I"'Assign color pair to curses window; T;0;@L;%i;&F;'o;(;)F;*iA;+iA;@-;,T;I"Ydef set_colors(fg, bg) cp = RubyText::Color.pair(fg, bg) @cwin.color_set(cp) end; T;-I"def set_colors(fg, bg); T;1To;; F;!;";;;I"RubyText::Window#colorize!; F;#[[I"fg; T0[I"bg; T0; [[@ iJ; T; ;;;;[;{;IC;"Set up a window with fg/bg; T;[;[;I"Set up a window with fg/bg; T;0;@^;%i;&F;'o;(;)F;*iH;+iH;@-;,T;I"def colorize!(fg, bg) set_colors(fg, bg) num = @cwin.maxx * @cwin.maxy self.home self.go(0, 0) { @cwin.addstr(' '*num) } @cwin.refresh end; T;-I"def colorize!(fg, bg); T;1T;e@-;fIC;[;e@-;gIC;[o;o ;p@;qI"RubyText::Keys; T;r0; : Keys;o;o ;p0;q0;r0; : RubyText;@;t@+;u0;to;.;IC;[$o; ; [[I" keys.rb; Ti ; F; : Down;;;;;[;{;IC;" ; T;[;[;@;0;@w;@u;I"RubyText::Keys::Down; T;I"Down = 258; T;I"258; T;1To; ; [[@zi ; F; :Up;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::Up; T;I"Up = 259; T;I"259; T;1To; ; [[@zi ; F; : Left;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::Left; T;I"Left = 260; T;I"260; T;1To; ; [[@zi ; F; : Right;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::Right; T;I"Right = 261; T;I"261; T;1To; ; [[@zi; F; : Enter;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::Enter; T;I"Enter = 10; T;I"10; T;1To; ; [[@zi; F; :NL;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::NL; T;I"NL = 10; T;I"10; T;1To; ; [[@zi; F; :LF;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::LF; T;I"LF = 10; T;I"10; T;1To; ; [[@zi; F; :EOF;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::EOF; T;I"EOF = 4; T;I"4; T;1To; ; [[@zi; F; : CtlD;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::CtlD; T;I"CtlD = 4; T;I"4; T;1To; ; [[@zi; T; : Back;;;;;[;{;IC;"backspace ; T;[;[;I"backspace; T;0;@;&F;'o;(;)F;*i;+i;@u;I"RubyText::Keys::Back; T;I"Back = 8; T;I"8; T;1To; ; [[@zi; F; :BS;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::BS; T;I"BS = 8; T;I"8; T;1To; ; [[@zi; F; :Tab;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::Tab; T;I"Tab = 9; T;I"9; T;1To; ; [[@zi; F; :TAB;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::TAB; T;I"TAB = 9; T;I"9; T;1To; ; [[@zi; F; : Escape;;;;;[;{;IC;" ; T;[;[;@;0;@ ;@u;I"RubyText::Keys::Escape; T;I"Escape = 27; T;I"27; T;1To; ; [[@zi; F; :ESC;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::ESC; T;I"ESC = 27; T;I"27; T;1To; ; [[@zi; F; :Esc;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::Esc; T;I"Esc = 27; T;I"27; T;1To; ; [[@zi ; F; : Delete;;;;;[;{;IC;" ; T;[;[;@;0;@*;@u;I"RubyText::Keys::Delete; T;I"Delete = 127; T;I"127; T;1To; ; [[@zi!; F; :DEL;;;;;[;{;IC;" ; T;[;[;@;0;@5;@u;I"RubyText::Keys::DEL; T;I"DEL = 127; T;I"127; T;1To; ; [[@zi"; F; :Del;;;;;[;{;IC;" ; T;[;[;@;0;@@;@u;I"RubyText::Keys::Del; T;I"Del = 127; T;I"127; T;1To; ; [[@zi$; F; :F1;;;;;[;{;IC;" ; T;[;[;@;0;@K;@u;I"RubyText::Keys::F1; T;I"F1 = 265; T;I"265; T;1To; ; [[@zi%; F; :F2;;;;;[;{;IC;" ; T;[;[;@;0;@V;@u;I"RubyText::Keys::F2; T;I"F2 = 266; T;I"266; T;1To; ; [[@zi&; F; :F3;;;;;[;{;IC;" ; T;[;[;@;0;@a;@u;I"RubyText::Keys::F3; T;I"F3 = 267; T;I"267; T;1To; ; [[@zi'; F; :F4;;;;;[;{;IC;" ; T;[;[;@;0;@l;@u;I"RubyText::Keys::F4; T;I"F4 = 268; T;I"268; T;1To; ; [[@zi(; F; :F5;;;;;[;{;IC;" ; T;[;[;@;0;@w;@u;I"RubyText::Keys::F5; T;I"F5 = 269; T;I"269; T;1To; ; [[@zi); F; :F6;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F6; T;I"F6 = 270; T;I"270; T;1To; ; [[@zi*; F; :F7;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F7; T;I"F7 = 271; T;I"271; T;1To; ; [[@zi+; F; :F8;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F8; T;I"F8 = 272; T;I"272; T;1To; ; [[@zi,; F; :F9;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F9; T;I"F9 = 273; T;I"273; T;1To; ; [[@zi-; F; :F10;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F10; T;I"F10 = 274; T;I"274; T;1To; ; [[@zi.; F; :F11;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F11; T;I"F11 = 275; T;I"275; T;1To; ; [[@zi/; F; :F12;;;;;[;{;IC;" ; T;[;[;@;0;@;@u;I"RubyText::Keys::F12; T;I"F12 = 276; T;I"276; T;1T;e@u;fIC;[;e@u;gIC;[;e@u;hIC;i{;TIC;i{;jT;"IC;i{;jT;jT;k{;l[; [[@zi[I"rubytext.rb; Ti; T; ;;;;;;[;{;IC;".Ruby constants for curses key definitions; T;[;[;I".Ruby constants for curses key definitions; T;0;@u;%i;&F;'o;(;)F;*i;+i;@t;I"RubyText::Keys; T;1T;u: module;e@-;hIC;i{;TIC;i{;jT;"IC;i{;xIC;i{: read@: write0;jT;zIC;i{;@;0;jT;{IC;i{;@;0;jT;|IC;i{;@;0;jT;}IC;i{;@;0;jT;~IC;i{;@;0;jT;IC;i{;@;0;jT;{IC;i{;@;0;jT;|IC;i{;@;@;jT;~IC;i{;@$;@1;jT;jT;jT;k{;l[; [ [@?i [@i[@i [@i[@i[@ i.; T; : Window;;;;;[;{;IC;"*Reopening: Wrapper for curses windows; T;[;[;I"*Reopening: Wrapper for curses windows; T;0;@-;%i;&F;'o;(;)F;*i,;+i,;@+;I"RubyText::Window; F;no;o ;p0;q0;r0; ;s;@;t0;u;T;1To;; F;!;T;;;I"RubyText.selector; F;#[[I" win:; TI" STDSCR; T[I"r:; TI"0; T[I"c:; TI"0; T[I" rows:; TI"10; T[I" cols:; TI"20; T[I" items:; T0[I"fg:; TI" White; T[I"bg:; TI" Blue; T[I" win2:; T0[I"callback:; T0[I" enter:; TI"nil; T[I" quit:; TI""q"; T; [[@?i; T; : selector;;;[;{;IC;"CTwo-paned widget with menu on left, informtional area on right; T;[;[;I"CTwo-paned widget with menu on left, informtional area on right; T;0;@;%i;&F;'o;(;)F;*i;+i;@+;,T;I"def self.selector(win: STDSCR, r: 0, c: 0, rows: 10, cols: 20, items:, fg: White, bg: Blue, win2:, callback:, enter: nil, quit: "q") high = rows wide = cols mwin = RubyText.window(high, wide, r: r, c: c, fg: fg, bg: bg) handler = callback Curses.stdscr.keypad(true) RubyText.hide_cursor sel = 0 max = items.size - 1 handler.call(sel, items[sel], win2) loop do mwin.home items.each.with_index do |item, row| mwin.crlf style = (sel == row) ? :reverse : :normal mwin.print fx(" #{item}", style) end ch = getch case ch when Up if sel > 0 sel -= 1 handler.call(sel, items[sel], win2) end when Down if sel < max sel += 1 handler.call(sel, items[sel], win2) end when Enter if enter del = enter.call(sel, items[sel], win2) if del items -= [items[sel]] raise end end when Tab Curses.flash when quit # parameter exit else Curses.beep # all else is trash end end rescue retry end; T;-I"def selector(win: STDSCR, r: 0, c: 0, rows: 10, cols: 20, items:, fg: White, bg: Blue, win2:, callback:, enter: nil, quit: "q"); T;1T@uo; ; [[I"rubytext_version.rb; Ti; F; : VERSION;;;;;[;{;IC;" ; T;[;[;@;0;@0;@+;I"RubyText::VERSION; F;I"VERSION = "0.1.22"; T;I" "0.1.22"; T;1To; ; [[@3i ; F; : Path;;;;;[;{;IC;" ; T;[;[;@;0;@<;@+;I"RubyText::Path; F;I"@Path = File.expand_path(File.join(File.dirname(__FILE__))); T;I"8File.expand_path(File.join(File.dirname(__FILE__))); T;1To;/;IC;[ o; ; [[I"settings.rb; Ti ; F; :ValidArgs;;;;;[;{;IC;" ; T;[;[;@;0;@I;@G;I""RubyText::Settings::ValidArgs; F;I"gValidArgs = [:raw, :_raw, :echo, :_echo, :cbreak, :_cbreak, :keypad, :_keypad, :cursor, :_cursor]; T;I"[[:raw, :_raw, :echo, :_echo, :cbreak, :_cbreak, :keypad, :_keypad, :cursor, :_cursor]; T;1To;; F;!;";;;I""RubyText::Settings#initialize; F;#[; [[@Li ; F; ;[;;;[;{;IC;" ; T;[o;G ;HI" return; F;II"a new instance of Settings; T; 0;J[I" Settings; F;@U;[;@;0;@U;%i;@G;,T;I"def initialize @defaults = {raw: false, echo: false, cbreak: true, keypad: true, cursor: true} @current = @defaults.dup @stack = [] @stack.push @current # Note: Never let stack be empty set_curses(@current) # Set them for real # FIXME To be continued... end; T;-I"def initialize; T;1To;; F;!;";;;I""RubyText::Settings#set_curses; F;#[[I" **hash; T0; [[@Li; F; :set_curses;;;[;{;IC;" ; T;[;[;@;0;@f;%i;@G;,T;I"Hdef set_curses(**hash) # Later: check for bad keys hash.each_pair do |sym, val| case [sym, val] when [:cbreak, true]; Curses.cbreak when [:cbreak, false]; Curses.nocbreak when [:raw, true]; Curses.raw when [:raw, false]; Curses.noraw when [:echo, true]; Curses.echo when [:echo, false]; Curses.noecho when [:keypad, true]; Curses.stdscr.keypad(true) when [:keypad, false]; Curses.stdscr.keypad(false) when [:cursor, true]; Curses.curs_set(1) when [:cursor, false]; Curses.curs_set(0) end end end; T;-I"def set_curses(**hash); T;1To;; F;!;";;;I"#RubyText::Settings#set_boolean; F;#[ [I" raw:; TI"nil; T[I" echo:; TI"nil; T[I" cbreak:; TI"nil; T[I" keypad:; TI"nil; T[I" cursor:; TI"nil; T; [[@Li'; F; :set_boolean;;;[;{;IC;" ; T;[;[;@;0;@t;%i;@G;,T;I"gdef set_boolean(raw: nil, echo: nil, cbreak: nil, keypad: nil, cursor: nil) raw ||= @current[:raw] echo ||= @current[:echo] cbreak ||= @current[:cbreak] keypad ||= @current[:keypad] cursor ||= @current[:cursor] @stack.push @current @current = {raw: raw, echo: echo, cbreak: cbreak, keypad: keypad, cursor: cursor} set_curses(@current) end; T;-I"Pdef set_boolean(raw: nil, echo: nil, cbreak: nil, keypad: nil, cursor: nil); T;1To;; F;!;";;;I"%RubyText::Settings#reset_boolean; F;#[; [[@Li2; F; :reset_boolean;;;[;{;IC;" ; T;[;[;@;0;@;%i;@G;,T;I"Zdef reset_boolean @current = @stack.pop rescue @stack[0] set_curses(@current) end; T;-I"def reset_boolean; T;1To;; F;!;";;;I"RubyText::Settings#set; F;#[[I" *syms; T0; [[@Li7; F; :set;;;[;{;IC;" ; T;[o;G ;HI" raise; F;I@; 0;J[I"ArgumentError; T;@;[;@;0;@;%i;@G;,T;I"def set(*syms) raise ArgumentError unless syms - ValidArgs == [] # FIXME - call set_boolean list = {} syms.each do |sym| str = sym.to_s val = str[0] != "_" sym0 = val ? sym : str[1..-1].to_sym list[sym0] = val end set_boolean(list) # allow a block here? end; T;-I"def set(*syms); T;1To;; F;!;";;;I"RubyText::Settings#reset; F;#[; [[@LiE; F; : reset;;;[;{;IC;" ; T;[;[;@;0;@;%i;@G;,T;I"1def reset # FIXME - call reset_boolean end; T;-I"def reset; T;1T;e@G;fIC;[;e@G;gIC;[;e@G;hIC;i{;TIC;i{;jT;"IC;i{;jT;jT;k{;l[; [[@Li ; T; : Settings;;;;;[;{;IC;"(Hmm, all these are module-level...?; T;[;[;I"(Hmm, all these are module-level...?; T;0;@G;%i;&F;'o;(;)F;*i;+i;@+;I"RubyText::Settings; F;no;o ;p0;q0;r0; ;s;@;t0;u;T;1To;; F;!;T;;;I"RubyText.started; F;#[; [[@LiJ; T; : started;;;[;{;IC;"remove later; T;[;[;I"remove later; T;0;@;%i;&F;'o;(;)F;*iJ;+iJ;@+;,T;I"5def self.started # remove later @started end; T;-I"def started; T;1To;; F;!;T;;;I"RubyText.started?; F;#[; [[@LiN; F; : started?;;;[;{;IC;" ; T;[o;G ;HI" return; F;I@; 0;J[@;@;[;@;0;@;%i;@+;,T;I"%def self.started? @started end; T;-I"def started?; T;1To;; F;!;T;;;I"RubyText.beep; F;#[; [[@LiR; F; ;;;;[;{;IC;" ; T;[;[;@;0;@;%i;@+;,T;I"$def self.beep Curses.beep end; T;-I" def beep; T;1To;; F;!;T;;;I"RubyText.flash; F;#[; [[@LiV; F; ;;;;[;{;IC;" ; T;[;[;@;0;@;%i;@+;,T;I"&def self.flash Curses.flash end; T;-I"def flash; T;1To;; F;!;T;;;I"RubyText.start; F;#[ [I" *args; T0[I" log:; TI""/tmp/rubytext.log"; T[I"fg:; TI" White; T[I"bg:; TI" Blue; T[I" scroll:; TI" false; T; [[@Li^; T; : start;;;[;{;IC;"?FIXME refactor save/restore, etc. - rep as binary vector?; T;[;[;I"?FIXME refactor save/restore, etc. - rep as binary vector?; T;0;@;%i;&F;'o;(;)F;*i\;+i\;@+;,T;I"def self.start(*args, log: "/tmp/rubytext.log", fg: White, bg: Blue, scroll: false) $debug ||= File.new(log, "w") if log # FIXME remove global args.each {|arg| raise "#{arg} is not valid" unless Settings::ValidArgs.include?(arg) } raise RTError("#{fg} is not a color") unless ::Colors.include? fg raise RTError("#{bg} is not a color") unless ::Colors.include? bg @settings = Settings.new @settings.set(*args) # override defaults main = RubyText::Window.main(fg: fg, bg: bg, scroll: scroll) Object.const_set(:STDSCR, main) unless defined? STDSCR $stdscr = STDSCR # FIXME global needed? Object.include(WindowIO) Curses.ESCDELAY = 10 @started = true # rescue => err # puts(err.inspect) # puts(err.backtrace) # raise RTError("#{err}") end; T;-I"Sdef start(*args, log: "/tmp/rubytext.log", fg: White, bg: Blue, scroll: false); T;1To;; F;!;T;;;I"RubyText.stop; F;#[; [[@Liu; F; : stop;;;[;{;IC;" ; T;[;[;@;0;@;%i;@+;,T;I"?def self.stop @started = false Curses.close_screen end; T;-I" def stop; T;1To;; F;!;";;;I"RubyText#set; F;#[[I" *args; T0; [[@Liz; F; ;;;;[;{;IC;" ; T;[;[;@;0;@(;%i;@+;,T;I".def set(*args) @settings.set(*args) end; T;-I"def set(*args); T;1To;; F;!;";;;I"RubyText#reset; F;#[; [[@Li~; F; ;;;;[;{;IC;" ; T;[;[;@;0;@6;%i;@+;,T;I"$def reset @settings.reset end; T;-I"def reset; T;1To;; F;!;T;;;I"RubyText.method_missing; F;#[[I" name; T0[I" *args; T0; [[@Li; T; :method_missing;;;[;{;IC;"EFor passing through arbitrary method calls to the lower level...; T;[;[;I"EFor passing through arbitrary method calls to the lower level...; T;0;@B;%i;&F;'o;(;)F;*i};+i~;@+;,T;I"def self.method_missing(name, *args) debug "method_missing: #{name} #{args.inspect}" if name[0] == '_' Curses.send(name[1..-1], *args) else raise "#{name} #{args.inspect}" # NoMethodError end end; T;-I"$def method_missing(name, *args); T;1To;; F;!;T;;;I"RubyText.hide_cursor; F;#[; [[@Li; T; :hide_cursor;;;[;{;IC;"remove later?; T;[;[;I"remove later?; T;0;@T;%i;&F;'o;(;)F;*i;+i;@+;,T;I"Edef self.hide_cursor # remove later? Curses.curs_set(0) end; T;-I"def hide_cursor; T;1To;; F;!;T;;;I"RubyText.show_cursor; F;#[; [[@Li; T; :show_cursor;;;[;{;IC;"remove later?; T;[;[;I"remove later?; T;0;@b;%i;&F;'o;(;)F;*i;+i;@+;,T;I"Edef self.show_cursor # remove later? Curses.curs_set(1) end; T;-I"def show_cursor; T;1To;; F;!;T;;;I"RubyText.show_cursor!; F;#[; [[@Li; F; :show_cursor!;;;[;{;IC;" ; T;[;[;@;0;@p;%i;@+;,T;I"Vdef self.show_cursor! Curses.curs_set(2) # Doesn't work? Device-dependent? end; T;-I"def show_cursor!; T;1To;; F;!;T;;;I"RubyText.ticker; F;#[ [I" row:; TI"STDSCR.rows-1; T[I" col:; TI"0; T[I" width:; TI"STDSCR.cols; T[I"fg:; TI" White; T[I"bg:; TI" Blue; T[I" text:; T0[I" delay:; TI"0.1; T; [[I"widgets.rb; Ti; F; : ticker;;;[;{;IC;" ; T;[;[;@;0;@|;%i;@+;,T;I"def self.ticker(row: STDSCR.rows-1, col: 0, width: STDSCR.cols, fg: White, bg: Blue, text:, delay: 0.1) text = text.gsub("\n", " ") + " " win = RubyText.window(1, width, r: row, c: col, border: false, fg: fg, bg: bg) leader = " "*width + text leader = text.chars.cycle.each_cons(width) width.times { win.rcprint 0, 0, leader.next.join } repeat = text.chars.cycle.each_cons(width) loop do # Warning: loops forever win.rcprint 0, 0, repeat.next.join sleep delay end end; T;-I"gdef ticker(row: STDSCR.rows-1, col: 0, width: STDSCR.cols, fg: White, bg: Blue, text:, delay: 0.1); T;1To;; F;!;T;;;I"RubyText.spinner; F;#[[I" label:; TI"""; T[I" win:; TI" STDSCR; T[I" &block; T0; [[@i; T; : spinner;;;[;{;IC;"TODO delay, etc.; T;[;[;I"TODO delay, etc.; T;0;@;%i;&F;'o;(;)F;*i;+i;@+;,T;I"def self.spinner(label: "", win: STDSCR, &block) # TODO delay, etc. chars = "-\\|/" RubyText.hide_cursor t0 = Time.now.to_i thread = Thread.new do i=0 loop do t1 = Time.now.to_i elapsed = "0:%02d" % (t1-t0) # FIXME breaks at 60 sec i = (i+1) % 4 win.print " #{label} #{chars[i]} #{elapsed}" win.left! sleep 0.04 end end ret = block.call win.puts Thread.kill(thread) RubyText.show_cursor ret end; T;-I"0def spinner(label: "", win: STDSCR, &block); T;1To;; F;!;T;;;I"RubyText.splash; F;#[[I"msg; T0; [[@i+; F; : splash;;;[;{;IC;" ; T;[;[;@;0;@;%i;@+;,T;I"def self.splash(msg) lines = msg.split("\n") high = lines.size + 4 wide = lines.map {|x| x.length }.max + 4 r0 = (STDSCR.rows - high)/2 c0 = (STDSCR.cols - wide)/2 STDSCR.saveback(high, wide, r0, c0) win = RubyText.window(high, wide, r: r0, c: c0, fg: White, bg: Red, title: "[Press any key]") win.print "\n " win.puts msg getch STDSCR.restback(high, wide, r0, c0) end; T;-I"def splash(msg); T;1To;; F;!;T;;;I"RubyText.window; F;#[[I" high; T0[I" wide; T0[I"r:; TI"nil; T[I"c:; TI"nil; T[I" border:; TI" true; T[I"fg:; TI" White; T[I"bg:; TI" Blue; T[I" scroll:; TI" false; T[I" title:; TI"nil; T; [[@i; F; : window;;;[;{;IC;" ; T;[;[;@;0;@;%i;@+;,T;I")def self.window(high, wide, r: nil, c: nil, border: true, fg: White, bg: Blue, scroll: false, title: nil) r ||= (STDSCR.rows - high)/2 c ||= (STDSCR.cols - wide)/2 win = RubyText::Window.new(high, wide, r, c, border, fg, bg, scroll) win.add_title(title) if title win end; T;-I"idef window(high, wide, r: nil, c: nil, border: true, fg: White, bg: Blue, scroll: false, title: nil); T;1To;/;IC;[ o; ; [[@!i; T; : Modes;;;;;[;{;IC;"Text modes ; T;[;[;I"Text modes; T;0;@;&F;'o;(;)F;*i;+i;@;I"RubyText::Effects::Modes; T;I"}Modes = {bold: Curses::A_BOLD, normal: Curses::A_NORMAL, reverse: Curses::A_REVERSE, under: Curses::A_UNDERLINE}; T;I"t{bold: Curses::A_BOLD, normal: Curses::A_NORMAL, reverse: Curses::A_REVERSE, under: Curses::A_UNDERLINE}; T;1To; ; [[@!i; T; : Others;;;;;[;{;IC;""Other text modes "of our own" ; T;[;[;I""Other text modes "of our own"; T;0;@;&F;'o;(;)F;*i;+i;@;I"RubyText::Effects::Others; T;I"Others = %[:show, :hide]; T;I"%[:show, :hide]; T;1To;; F;!;";;;I"RubyText::Effects#value; T;#[; [[@!i; T; ;d;;;[;{;IC;"#show/hide cursor; more later?? ; T;[;[;I"#show/hide cursor; more later??; T;0;@ ;&F;'o;(;)F;*i;+i;@;I"def value @value end; T;-I"def value; T;1To;; F;!;";;;I"RubyText::Effects#fg; T;#[; [[@!i; T; ;|;;;[;{;IC;"#show/hide cursor; more later?? ; T;[;[;@ ;0;@ ;&F;'@ ;@;I"def fg @fg end; T;-I" def fg; T;1To;; F;!;";;;I"RubyText::Effects#bg; T;#[; [[@!i; T; ;~;;;[;{;IC;"#show/hide cursor; more later?? ; T;[;[;@ ;0;@ ;&F;'@ ;@;I"def bg @bg end; T;-I" def bg; T;1To;; F;!;";;;I"!RubyText::Effects#initialize; T;#[[I" *args; T0[I"bg:; TI"nil; T; [[@!i#; T; ;[;;;[;{;IC;"!Initialize an Effects object; T;[o;G ;HI" return; F;II"a new instance of Effects; T; 0;J[I" Effects; F;@( ;[;I"!Initialize an Effects object; T;0;@( ;%i;&F;'o;(;)F;*i!;+i!;@;,T;I"def initialize(*args, bg: nil) bits = 0 @list = args args.each do |arg| if Modes.keys.include?(arg) val = Modes[arg] bits |= val elsif ::Colors.include?(arg) @fg = arg # symbol end end @bg = bg || @bg @value = bits end; T;-I"#def initialize(*args, bg: nil); T;1To;; F;!;";;;I"RubyText::Effects#set; T;#[[I"win; T0; [[@!i4; T; ;;;;[;{;IC;")"Turn on" effect to specified window; T;[;[;I")"Turn on" effect to specified window; T;0;@@ ;%i;&F;'o;(;)F;*i2;+i2;@;,T;I"def set(win) @old_fg, @old_bg = win.fg, win.bg # Save off current state? attr, fg, bg = self.value, self.fg, self.bg win.cwin.attron(attr) fg ||= win.fg bg ||= win.bg win.set_colors(fg, bg) end; T;-I"def set(win); T;1To;; F;!;";;;I"RubyText::Effects#reset; T;#[[I"win; T0; [[@!i?; T; ;;;;[;{;IC;"*"Turn off" effect in specified window; T;[;[;I"*"Turn off" effect in specified window; T;0;@P ;%i;&F;'o;(;)F;*i=;+i=;@;,T;I"~def reset(win) attr = self.value win.cwin.attroff(attr) win.set_colors(@old_fg, @old_bg) # Does restore logic work? end; T;-I"def reset(win); T;1T;e@;fIC;[;e@;gIC;[;e@;hIC;i{;TIC;i{;jT;"IC;i{;dIC;i{;@ ;0;jT;|IC;i{;@ ;0;jT;~IC;i{;@ ;0;jT;jT;jT;k{;l[; [[@!i; T; : Effects;;;;;[;{;IC;":Hande text effects (bold, normal, reverse, underline); T;[;[;I":Hande text effects (bold, normal, reverse, underline); T;0;@;%i;&F;'o;(;)F;*i;+i;o;o ;p0;q0;r0; ;;@;t@+;u0;I"RubyText::Effects; T;no;o ;p0;q0;r0; ;s;@;t0;u;To;/;IC;[ o; ; [[@ i; F; ;;;;;;[;{;IC;" ; T;[;[;@;0;@x ;@v ;I"RubyText::Color::Colors; T;I"Colors = ::Colors; T;I" ::Colors; T;1To;; F;!;T;;;I"RubyText::Color.sym2const; T;#[[I" color; T0; [[@ i; T; :sym2const;;;[;{;IC;"6Convert Ruby symbol to curses color constant name; T;[;[;I"6Convert Ruby symbol to curses color constant name; T;0;@ ;%i;&F;'o;(;)F;*i;+i;@v ;,T;I"jdef self.sym2const(color) # to curses constant Curses.const_get("COLOR_#{color.to_s.upcase}") end; T;-I"def sym2const(color); T;1To;; F;!;T;;;I"RubyText::Color.index; T;#[[I" color; T0; [[@ i; T; : index;;;[;{;IC;"Find "our" color number; T;[;[;I"Find "our" color number; T;0;@ ;%i;&F;'o;(;)F;*i;+i;@v ;,T;I"Idef self.index(color) Colors.find_index(color) # "our" number end; T;-I"def index(color); T;1To;; F;!;T;;;I"RubyText::Color.pair; T;#[[I"fg; T0[I"bg; T0; [[@ i$; T; : pair;;;[;{;IC;"Define a fg/bg color pair; T;[;[;I"Define a fg/bg color pair; T;0;@ ;%i;&F;'o;(;)F;*i";+i";@v ;,T;I"def self.pair(fg, bg) nf, nb = index(fg), index(bg) num = 8*nf + nb Curses.init_pair(num, sym2const(fg), sym2const(bg)) num end; T;-I"def pair(fg, bg); T;1T;e@v ;fIC;[;e@v ;gIC;[;e@v ;hIC;i{;TIC;i{;jT;"IC;i{;jT;jT;k{;l[; [[@ i; T; : Color;;;;;[;{;IC;",Handles color constants and fg/bg pairs; T;[;[;I",Handles color constants and fg/bg pairs; T;0;@v ;%i;&F;'o;(;)F;*i ;+i ;o;o ;p0;q0;r0; ;;@;t@+;u0;I"RubyText::Color; T;no;o ;p0;q0;r0; ;s;@;t0;u;T;e@+;fIC;[;e@+;gIC;[;e@+;hIC;i{;TIC;i{;jT;"IC;i{;jT;jT;k{;l[; [ [@?i[@i [@i[@3i[@Li[@i[@i; T; ;;;;;;[;{;IC;"?Skeleton... Can't put classes at top because of #initalize; T;[;[;I"?Skeleton... Can't put classes at top because of #initalize; T;0;@+;%i;&F;'o;(;)F;*i;+i;@;I" RubyText; Fo;.;IC;[ o;; F;!;";;;I"WindowIO#puts; F;#[[I" *args; T0; [[@i2; T; ;L;;;[;{;IC;"%Doesn't affect STDOUT.puts, etc.; T;[;[;I"%Doesn't affect STDOUT.puts, etc.; T;0;@ ;%i;&F;'o;(;)F;*i2;+i2;@ ;,T;I"|def puts(*args) # Doesn't affect STDOUT.puts, etc. recv = RubyText.started ? $stdscr : Kernel recv.puts(*args) end; T;-I"def puts(*args); T;1To;; F;!;";;;I"WindowIO#print; F;#[[I" *args; T0; [[@i7; F; ;M;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@ ;,T;I"Zdef print(*args) recv = RubyText.started ? $stdscr : Kernel recv.print(*args) end; T;-I"def print(*args); T;1To;; F;!;";;;I"WindowIO#p; F;#[[I" *args; T0; [[@i<; F; ;N;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@ ;,T;I"Rdef p(*args) recv = RubyText.started ? $stdscr : Kernel recv.p(*args) end; T;-I"def p(*args); T;1To;; F;!;";;;I"WindowIO#rcprint; F;#[[I"r; T0[I"c; T0[I" *args; T0; [[@iA; F; ;O;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@ ;,T;I"idef rcprint(r, c, *args) recv = RubyText.started ? $stdscr : Kernel recv.rcprint r, c, *args end; T;-I"def rcprint(r, c, *args); T;1To;; F;!;";;;I"WindowIO#getch; F;#[; [[@iH; T; : getch;;;[;{;IC;"3FIXME These don't/can't honor @started flag...; T;[;[;I"3FIXME These don't/can't honor @started flag...; T;0;@ ;%i;&F;'o;(;)F;*iF;+iF;@ ;,T;I"!def getch Curses.getch end; T;-I"def getch; T;1To;; F;!;";;;I"WindowIO#gets; F;#[; [[@iL; T; ;v;;;[;{;IC;"still needs improvement; T;[;[;I"still needs improvement; T;0;@- ;%i;&F;'o;(;)F;*iL;+iL;@ ;,T;I"edef gets # still needs improvement recv = RubyText.started ? $stdscr : Kernel recv.gets end; T;-I" def gets; T;1To;; F;!;";;;I"WindowIO#putch; F;#[ [I"ch; T0[I"r:; TI"nil; T[I"c:; TI"nil; T[I"fx:; TI"nil; T; [[@iQ; F; ;R;;;[;{;IC;" ; T;[;[;@;0;@; ;%i;@ ;,T;I"def putch(ch, r: nil, c: nil, fx: nil) r, c = STDSCR.rc r ||= r0 c ||= c0 STDSCR.putch(ch, r: r, c: c, fx: fx) end; T;-I"+def putch(ch, r: nil, c: nil, fx: nil); T;1T;e@ ;fIC;[;e@ ;gIC;[;e@ ;hIC;i{;TIC;i{;jT;"IC;i{;jT;jT;k{;l[; [[@i1; F; : WindowIO;;;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@;I" WindowIO; Fo;; F;!;";;;I" #import; T;#[[I" meth; T0[I" recv; T0; [[@i); T; : import;;;[;{;IC;"*FIXME lots of changes to make here...; T;[;[;I"*FIXME lots of changes to make here...; T;0;@a ;%i;&F;'o;(;)F;*i';+i';@;,T;I"wdef import(meth, recv) Kernel.module_eval do define_method(meth) {|*args| recv.send(meth, *args) } end end; T;-I"def import(meth, recv); To;; F;!;";;;I"#make_exception; T;#[[I"sym; T0[I"str; T0; [[@i/; T; :make_exception;;;[;{;IC;"FIXME refactor; T;[;[;I"FIXME refactor; T;0;@s ;%i;&F;'o;(;)F;*i/;+i/;@;,T;I"Kdef make_exception(sym, str) # FIXME refactor return if Object.constants.include?(sym) Object.const_set(sym, StandardError.dup) define_method(sym) do |*args| msg = str list = (args + [nil]*2)[0..2] list.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg.to_s) } Object.class_eval(sym.to_s).new(msg) end end; T;-I"!def make_exception(sym, str); To;; F;!;";;;I"#debugging; T;#[[I" onoff; T0; [[@i=; T; :debugging;;;[;{;IC;"TODO more...; T;[;[;I"TODO more...; T;0;@ ;%i;&F;'o;(;)F;*i;;+i;;@;,T;I"Ldef debugging(onoff) $debugging = onoff # FIXME eschew global? end; T;-I"def debugging(onoff); To;; F;!;";;;I" #debug; T;#[[I" *args; T0; [[@iA; F; : debug;;;[;{;IC;" ; T;[;[;@;0;@ ;%i;@;,T;I"def debug(*args) return unless $debugging return unless $debug # FIXME eschew global? $debug.puts *args $debug.flush end; T;-I"def debug(*args); T;e@;fIC;[;e@;gIC;[;e@;hIC;i{;TIC;i{;jT;"IC;i{;jT;jT;k{;l[; [; F; ;;;;;;[;{;IC;" ; T;[;[;@;0;@;%i;0;@;@:RubyText::Color@v :#fx@:RubyText::Effects@:RubyText::Keys@u;@+:RubyText::Window@-:RubyText::Window#topmenu@/:RubyText::Window#menu@I:RubyText::Window#multimenu@n:RubyText::Window#yesno@: RubyText::Window#radio_menu@:RubyText.selector@:RubyText::Window#coords@:RubyText::Window#goto@:RubyText::Window#go@:RubyText::Window#up@:RubyText::Window#down@ :RubyText::Window#left@:RubyText::Window#right@.:RubyText::Window#top@?:RubyText::Window#bottom@M:RubyText::Window#up!@[:RubyText::Window#down!@i:RubyText::Window#left!@w:RubyText::Window#right!@:RubyText::Window#home@:RubyText::Window#rc@:RubyText::Window#center@:RubyText::Window#effect?@:%RubyText::Window#delegate_output@:RubyText::Window#puts@:RubyText::Window#print@:RubyText::Window#p@:RubyText::Window#rcprint@ :RubyText::Window#rcprint!@:RubyText::Window#_putch@0:RubyText::Window#putch@>:RubyText::Window#crlf@U:RubyText::Window.clear@c:RubyText::Window#clear@s:RubyText::Window#output@:RubyText::Window#[]@:RubyText::Window#[]=@:RubyText::Window#boxme@:RubyText::Window#refresh@: RubyText::Window::GetString@:+RubyText::Window::GetString#initialize@:&RubyText::Window::GetString#enter@:+RubyText::Window::GetString#left_arrow@:,RubyText::Window::GetString#right_arrow@ :*RubyText::Window::GetString#backspace@:-RubyText::Window::GetString#history_prev@#:-RubyText::Window::GetString#history_next@/:)RubyText::Window::GetString#complete@;:$RubyText::Window::GetString#add@G:&RubyText::Window::GetString#value@U:RubyText::Window#gets@q;@ :WindowIO#puts@ :WindowIO#print@ :WindowIO#p@ :WindowIO#rcprint@ :WindowIO#getch@ :WindowIO#gets@- :WindowIO#putch@; : #import@a :#make_exception@s :#debugging@ : #debug@ :RubyText::VERSION@0:RubyText::Path@<:RubyText::Settings@G:"RubyText::Settings::ValidArgs@I:"RubyText::Settings#initialize@U:"RubyText::Settings#set_curses@f:#RubyText::Settings#set_boolean@t:%RubyText::Settings#reset_boolean@:RubyText::Settings#set@:RubyText::Settings#reset@:RubyText.started@:RubyText.started?@:RubyText.beep@:RubyText.flash@:RubyText.start@:RubyText.stop@:RubyText#set@(:RubyText#reset@6:RubyText.method_missing@B:RubyText.hide_cursor@T:RubyText.show_cursor@b:RubyText.show_cursor!@p:RubyText.ticker@|:RubyText.spinner@:RubyText.splash@:RubyText.window@:"RubyText::Window::ScreenStack@:RubyText::Window#cwin@:RubyText::Window#rows@:RubyText::Window#cols@:RubyText::Window#width@:RubyText::Window#height@:RubyText::Window#scrolling@:RubyText::Window#r0@:RubyText::Window#c0@:RubyText::Window#fg@:RubyText::Window#fg=@:RubyText::Window#bg@$:RubyText::Window#bg=@1: RubyText::Window#initialize@C:RubyText::Window.main@n:RubyText::Window.make@:RubyText::Window#add_title@:RubyText::Window#scroll@:!RubyText::Window#screen_text@: RubyText::Window#background@:RubyText::Window#saveback@:RubyText::Window#restback@:RubyText::Window#beep@ :RubyText::Window#flash@,:RubyText::Keys::Down@w:RubyText::Keys::Up@:RubyText::Keys::Left@:RubyText::Keys::Right@:RubyText::Keys::Enter@:RubyText::Keys::NL@:RubyText::Keys::LF@:RubyText::Keys::EOF@:RubyText::Keys::CtlD@:RubyText::Keys::Back@:RubyText::Keys::BS@:RubyText::Keys::Tab@:RubyText::Keys::TAB@:RubyText::Keys::Escape@ :RubyText::Keys::ESC@:RubyText::Keys::Esc@:RubyText::Keys::Delete@*:RubyText::Keys::DEL@5:RubyText::Keys::Del@@:RubyText::Keys::F1@K:RubyText::Keys::F2@V:RubyText::Keys::F3@a:RubyText::Keys::F4@l:RubyText::Keys::F5@w:RubyText::Keys::F6@:RubyText::Keys::F7@:RubyText::Keys::F8@:RubyText::Keys::F9@:RubyText::Keys::F10@:RubyText::Keys::F11@:RubyText::Keys::F12@:RubyText::Effects::Modes@:RubyText::Effects::Others@:RubyText::Effects#value@ :RubyText::Effects#fg@ :RubyText::Effects#bg@ :!RubyText::Effects#initialize@( :RubyText::Effects#set@@ :RubyText::Effects#reset@P :RubyText::Color::Colors@x :RubyText::Color.sym2const@ :RubyText::Color.index@ :RubyText::Color.pair@ :RubyText::Window.colorize!@8: RubyText::Window#set_colors@L:RubyText::Window#colorize!@^