Class: RubyCurses::DefaultFileRenderer
- Defined in:
- lib/rbcurse/core/widgets/textpad.rb
Overview
a test renderer to see how things go
Instance Method Summary collapse
Instance Method Details
#render(pad, lineno, text) ⇒ Object
945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
# File 'lib/rbcurse/core/widgets/textpad.rb', line 945 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 |