Module: Binocs::TUI::Colors
- Defined in:
- lib/binocs/tui/colors.rb
Constant Summary collapse
- NORMAL =
Color pair constants
1- HEADER =
2- SELECTED =
3- METHOD_GET =
4- METHOD_POST =
5- METHOD_PUT =
6- METHOD_DELETE =
7- STATUS_SUCCESS =
8- STATUS_REDIRECT =
9- STATUS_CLIENT_ERROR =
10- STATUS_SERVER_ERROR =
11- MUTED =
12- ERROR =
13- BORDER =
14- TITLE =
15- KEY_HINT =
16- SEARCH =
17- METHOD_GET_PILL =
Pill-style colors (with backgrounds)
18- METHOD_POST_PILL =
19- METHOD_PUT_PILL =
20- METHOD_DELETE_PILL =
21- STATUS_SUCCESS_PILL =
22- STATUS_REDIRECT_PILL =
23- STATUS_CLIENT_ERROR_PILL =
24- STATUS_SERVER_ERROR_PILL =
25
Class Method Summary collapse
- .init ⇒ Object
- .method_color(method) ⇒ Object
- .method_pill_color(method) ⇒ Object
- .status_color(status) ⇒ Object
- .status_pill_color(status) ⇒ Object
Class Method Details
.init ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/binocs/tui/colors.rb', line 35 def self.init # Note: Curses.start_color and use_default_colors are called in App#setup_curses # Define color pairs (foreground, background) # -1 means default/transparent background # Colors adjusted for terminal compatibility (BLUE shows as teal in some themes) Curses.init_pair(NORMAL, Curses::COLOR_WHITE, -1) Curses.init_pair(HEADER, Curses::COLOR_YELLOW, -1) Curses.init_pair(SELECTED, Curses::COLOR_BLACK, Curses::COLOR_WHITE) Curses.init_pair(METHOD_GET, Curses::COLOR_BLUE, -1) # teal in your theme Curses.init_pair(METHOD_POST, Curses::COLOR_YELLOW, -1) Curses.init_pair(METHOD_PUT, Curses::COLOR_MAGENTA, -1) Curses.init_pair(METHOD_DELETE, Curses::COLOR_RED, -1) Curses.init_pair(STATUS_SUCCESS, Curses::COLOR_BLUE, -1) # teal = success Curses.init_pair(STATUS_REDIRECT, Curses::COLOR_YELLOW, -1) Curses.init_pair(STATUS_CLIENT_ERROR, Curses::COLOR_MAGENTA, -1) Curses.init_pair(STATUS_SERVER_ERROR, Curses::COLOR_RED, -1) Curses.init_pair(MUTED, Curses::COLOR_WHITE, -1) # Will use dim attribute Curses.init_pair(ERROR, Curses::COLOR_RED, -1) Curses.init_pair(BORDER, Curses::COLOR_BLUE, -1) Curses.init_pair(TITLE, Curses::COLOR_YELLOW, -1) Curses.init_pair(KEY_HINT, Curses::COLOR_YELLOW, -1) Curses.init_pair(SEARCH, Curses::COLOR_BLACK, Curses::COLOR_YELLOW) # Pill-style pairs (text on colored background) # Using colors with best terminal compatibility Curses.init_pair(METHOD_GET_PILL, Curses::COLOR_WHITE, Curses::COLOR_BLUE) Curses.init_pair(METHOD_POST_PILL, Curses::COLOR_BLACK, Curses::COLOR_YELLOW) Curses.init_pair(METHOD_PUT_PILL, Curses::COLOR_WHITE, Curses::COLOR_MAGENTA) Curses.init_pair(METHOD_DELETE_PILL, Curses::COLOR_WHITE, Curses::COLOR_RED) Curses.init_pair(STATUS_SUCCESS_PILL, Curses::COLOR_WHITE, Curses::COLOR_BLUE) Curses.init_pair(STATUS_REDIRECT_PILL, Curses::COLOR_BLACK, Curses::COLOR_YELLOW) Curses.init_pair(STATUS_CLIENT_ERROR_PILL, Curses::COLOR_WHITE, Curses::COLOR_MAGENTA) Curses.init_pair(STATUS_SERVER_ERROR_PILL, Curses::COLOR_WHITE, Curses::COLOR_RED) end |
.method_color(method) ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/binocs/tui/colors.rb', line 70 def self.method_color(method) case method.to_s.upcase when 'GET' then METHOD_GET when 'POST' then METHOD_POST when 'PUT', 'PATCH' then METHOD_PUT when 'DELETE' then METHOD_DELETE else NORMAL end end |
.method_pill_color(method) ⇒ Object
92 93 94 95 96 97 98 99 100 |
# File 'lib/binocs/tui/colors.rb', line 92 def self.method_pill_color(method) case method.to_s.upcase when 'GET' then METHOD_GET_PILL when 'POST' then METHOD_POST_PILL when 'PUT', 'PATCH' then METHOD_PUT_PILL when 'DELETE' then METHOD_DELETE_PILL else NORMAL end end |
.status_color(status) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/binocs/tui/colors.rb', line 80 def self.status_color(status) return MUTED if status.nil? case status when 200..299 then STATUS_SUCCESS when 300..399 then STATUS_REDIRECT when 400..499 then STATUS_CLIENT_ERROR when 500..599 then STATUS_SERVER_ERROR else NORMAL end end |
.status_pill_color(status) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/binocs/tui/colors.rb', line 102 def self.status_pill_color(status) return MUTED if status.nil? case status when 200..299 then STATUS_SUCCESS_PILL when 300..399 then STATUS_REDIRECT_PILL when 400..499 then STATUS_CLIENT_ERROR_PILL when 500..599 then STATUS_SERVER_ERROR_PILL else NORMAL end end |