Module: Rfd::PreviewWindow::RougeSupport

Included in:
Rfd::PreviewWindow
Defined in:
lib/rfd/preview_window.rb

Overview

Module for Rouge syntax highlighting support (extractable for testing)

Constant Summary collapse

ROUGE_COLORS =
{
  'Comment' => Curses::COLOR_GREEN,
  'Keyword' => Curses::COLOR_CYAN,
  'Name.Function' => Curses::COLOR_MAGENTA,
  'Name.Class' => Curses::COLOR_MAGENTA,
  'Literal.String' => Curses::COLOR_RED,
  'Literal.Number' => Curses::COLOR_RED,
  'Operator' => Curses::COLOR_CYAN,
}.freeze

Instance Method Summary collapse

Instance Method Details

#rouge_token_color(token_type) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rfd/preview_window.rb', line 17

def rouge_token_color(token_type)
  token_str = token_type.qualname
  ROUGE_COLORS.each do |prefix, color|
    return Curses.color_pair(color) if token_str.start_with?(prefix)
  end
  Curses::A_NORMAL
end