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
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 |
# File 'lib/cygnus/textpad.rb', line 852 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. Or if its an mp3 or non-text file. 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 |