Module: Hiiro::TaskColors
- Defined in:
- lib/hiiro/task_colors.rb
Constant Summary collapse
- PALETTE =
12 visually distinct, dark-background color pairs for tmux status bars. All use colour255 (white) as foreground for readability.
[ { bg: 'colour24', fg: 'colour255' }, # 0: Steel blue { bg: 'colour88', fg: 'colour255' }, # 1: Dark red { bg: 'colour28', fg: 'colour255' }, # 2: Forest green { bg: 'colour130', fg: 'colour255' }, # 3: Sienna { bg: 'colour54', fg: 'colour255' }, # 4: Purple { bg: 'colour23', fg: 'colour255' }, # 5: Dark teal { bg: 'colour52', fg: 'colour255' }, # 6: Crimson { bg: 'colour58', fg: 'colour255' }, # 7: Olive { bg: 'colour17', fg: 'colour255' }, # 8: Navy { bg: 'colour90', fg: 'colour255' }, # 9: Magenta { bg: 'colour94', fg: 'colour255' }, # 10: Burnt orange { bg: 'colour22', fg: 'colour255' }, # 11: Dark forest ].freeze
Class Method Summary collapse
-
.apply(session_name, color_index) ⇒ Object
Apply status-bg / status-fg to the named tmux session.
- .for_index(index) ⇒ Object
-
.next_index(existing_indices) ⇒ Object
Return the first palette index not already used by existing_indices, falling back to modulo wrap-around when all colors are taken.
Class Method Details
.apply(session_name, color_index) ⇒ Object
Apply status-bg / status-fg to the named tmux session.
25 26 27 28 29 |
# File 'lib/hiiro/task_colors.rb', line 25 def self.apply(session_name, color_index) colors = for_index(color_index) Background.run('tmux', 'set-option', '-t', session_name, 'status-bg', colors[:bg]) Background.run('tmux', 'set-option', '-t', session_name, 'status-fg', colors[:fg]) end |
.for_index(index) ⇒ Object
20 21 22 |
# File 'lib/hiiro/task_colors.rb', line 20 def self.for_index(index) PALETTE[index.to_i % PALETTE.size] end |
.next_index(existing_indices) ⇒ Object
Return the first palette index not already used by existing_indices, falling back to modulo wrap-around when all colors are taken.
33 34 35 36 |
# File 'lib/hiiro/task_colors.rb', line 33 def self.next_index(existing_indices) (0...PALETTE.size).find { |i| !existing_indices.include?(i) } || (existing_indices.length % PALETTE.size) end |