Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/style.rb

282 lines
5 KiB
Ruby
Raw Normal View History

2017-07-22 05:06:15 -04:00
# frozen_string_literal: true
class Style
2017-07-22 05:46:15 -04:00
class << self
attr_accessor :default
def counter
@counter ||= 0
@counter += 1
end
2017-07-22 05:06:15 -04:00
end
def initialize
2017-07-22 12:26:04 -04:00
Curses.init_pair logo_id, logo_color, logo_bg
Curses.init_pair text_id, text_color, text_bg
Curses.init_pair selection_id, selection_color, selection_bg
Curses.init_pair editing_text_id, editing_text_color, editing_text_bg
Curses.init_pair cursor_id, cursor_color, cursor_bg
Curses.init_pair menu_item_id, menu_item_color, menu_item_bg
Curses.init_pair active_menu_item_id, active_menu_item_color, active_menu_item_bg
Curses.init_pair message_time_id, message_time_color, message_time_bg
Curses.init_pair message_author_id, message_author_color, message_author_bg
Curses.init_pair online_mark_id, online_mark_color, online_mark_bg
Curses.init_pair peer_info_name_id, peer_info_name_color, peer_info_name_bg
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def logo(window)
window.attron logo_attr
2017-07-22 10:12:36 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff logo_attr
2017-07-22 10:12:36 -04:00
end
2017-07-24 05:52:42 -04:00
def text(window)
window.attron text_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff text_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def selection(window)
window.attron selection_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff selection_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def editing_text(window)
window.attron editing_text_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff editing_text_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def cursor(window)
window.attron cursor_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff cursor_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def menu_item(window)
window.attron menu_item_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff menu_item_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def active_menu_item(window)
window.attron active_menu_item_attr
2017-07-22 12:26:04 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff active_menu_item_attr
2017-07-22 12:26:04 -04:00
end
2017-07-24 05:52:42 -04:00
def message_time(window)
window.attron message_time_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff message_time_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def message_author(window)
window.attron message_author_attr
2017-07-22 05:46:15 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff message_author_attr
2017-07-22 05:46:15 -04:00
end
2017-07-24 05:52:42 -04:00
def online_mark(window)
window.attron online_mark_attr
2017-07-22 07:16:55 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff online_mark_attr
2017-07-22 07:16:55 -04:00
end
2017-07-24 05:52:42 -04:00
def peer_info_name(window)
window.attron peer_info_name_attr
2017-07-22 07:49:55 -04:00
yield
ensure
2017-07-24 05:52:42 -04:00
window.attroff peer_info_name_attr
2017-07-22 07:49:55 -04:00
end
2017-07-22 05:46:15 -04:00
private
2017-07-22 10:12:36 -04:00
def logo_attr
Curses.color_pair(logo_id) | Curses::A_BOLD
end
2017-07-22 05:46:15 -04:00
def text_attr
Curses.color_pair text_id
end
def selection_attr
Curses.color_pair selection_id
end
def editing_text_attr
Curses.color_pair editing_text_id
end
def cursor_attr
Curses.color_pair cursor_id
end
def menu_item_attr
Curses.color_pair menu_item_id
end
2017-07-22 12:26:04 -04:00
def active_menu_item_attr
Curses.color_pair active_menu_item_id
end
2017-07-22 05:46:15 -04:00
def message_time_attr
Curses.color_pair message_time_id
end
def message_author_attr
Curses.color_pair(message_author_id) | Curses::A_BOLD
end
2017-07-22 07:16:55 -04:00
def online_mark_attr
Curses.color_pair online_mark_id
end
2017-07-22 07:49:55 -04:00
def peer_info_name_attr
Curses.color_pair(peer_info_name_id) | Curses::A_BOLD
end
2017-07-22 10:12:36 -04:00
def logo_id
@logo_id ||= self.class.counter
end
2017-07-22 05:46:15 -04:00
def text_id
@text_id ||= self.class.counter
end
def selection_id
@selection_id ||= self.class.counter
end
def editing_text_id
@editing_text_id ||= self.class.counter
end
def cursor_id
@cursor_id ||= self.class.counter
end
def menu_item_id
@menu_item_id ||= self.class.counter
end
2017-07-22 12:26:04 -04:00
def active_menu_item_id
@active_menu_item_id ||= self.class.counter
end
2017-07-22 05:46:15 -04:00
def message_time_id
@message_time_id ||= self.class.counter
end
def message_author_id
@message_author_id ||= self.class.counter
2017-07-22 05:38:38 -04:00
end
2017-07-22 07:16:55 -04:00
def online_mark_id
@online_mark_id ||= self.class.counter
end
2017-07-22 07:49:55 -04:00
def peer_info_name_id
@peer_info_name_id ||= self.class.counter
end
2017-07-22 10:12:36 -04:00
def logo_color
Curses::COLOR_BLUE
end
def logo_bg
Curses::COLOR_BLACK
end
2017-07-22 05:38:38 -04:00
def text_color
Curses::COLOR_WHITE
end
def text_bg
Curses::COLOR_BLACK
end
def selection_color
Curses::COLOR_BLACK
end
def selection_bg
Curses::COLOR_WHITE
end
def editing_text_color
Curses::COLOR_WHITE
end
def editing_text_bg
Curses::COLOR_BLACK
end
def cursor_color
Curses::COLOR_BLACK
end
def cursor_bg
Curses::COLOR_GREEN
end
def menu_item_color
Curses::COLOR_BLACK
end
def menu_item_bg
Curses::COLOR_CYAN
end
2017-07-22 12:26:04 -04:00
def active_menu_item_color
Curses::COLOR_BLACK
end
def active_menu_item_bg
Curses::COLOR_BLUE
end
2017-07-22 05:38:38 -04:00
def message_time_color
Curses::COLOR_CYAN
end
def message_time_bg
Curses::COLOR_BLACK
end
def message_author_color
Curses::COLOR_GREEN
end
def message_author_bg
Curses::COLOR_BLACK
2017-07-22 05:06:15 -04:00
end
2017-07-22 07:16:55 -04:00
def online_mark_color
Curses::COLOR_GREEN
end
def online_mark_bg
Curses::COLOR_BLACK
end
2017-07-22 07:49:55 -04:00
def peer_info_name_color
Curses::COLOR_WHITE
end
def peer_info_name_bg
Curses::COLOR_BLACK
end
2017-07-22 05:06:15 -04:00
end