Class: Cygnus::DefaultFileRenderer
- Inherits:
-
Object
- Object
- Cygnus::DefaultFileRenderer
- Defined in:
- lib/cygnus/textpad.rb
Overview
a test renderer to see how things go
Instance Method Summary collapse
Instance Method Details
#render(pad, lineno, text) ⇒ Object
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
# File 'lib/cygnus/textpad.rb', line 806 def render pad, lineno, text bg = :black fg = :white att = NORMAL #cp = $datacolor cp = get_color($datacolor, fg, bg) ## XXX believe it or not, the next line can give you "invalid byte sequence in UTF-8 # even when processing filename at times. if text =~ /^\s*# / || text =~ /^\s*## / fg = :red #att = BOLD cp = get_color($datacolor, fg, bg) elsif text =~ /^\s*#/ fg = :blue cp = get_color($datacolor, fg, bg) elsif text =~ /^\s*(class|module) / fg = :cyan att = BOLD cp = get_color($datacolor, fg, bg) elsif text =~ /^\s*def / || text =~ /^\s*function / fg = :yellow att = BOLD cp = get_color($datacolor, fg, bg) elsif text =~ /^\s*(end|if |elsif|else|begin|rescue|ensure|include|extend|while|unless|case |when )/ fg = :magenta att = BOLD cp = get_color($datacolor, fg, bg) elsif text =~ /^\s*=/ # rdoc case fg = :blue bg = :white cp = get_color($datacolor, fg, bg) att = REVERSE end FFI::NCurses.wattron(pad,FFI::NCurses.COLOR_PAIR(cp) | att) FFI::NCurses.mvwaddstr(pad, lineno, 0, text) FFI::NCurses.wattroff(pad,FFI::NCurses.COLOR_PAIR(cp) | att) end |