Add class Style
This commit is contained in:
parent
bb5e5b2d9b
commit
0771a13d82
2 changed files with 24 additions and 8 deletions
14
lib/main.rb
14
lib/main.rb
|
@ -6,6 +6,7 @@ require 'curses'
|
|||
require 'faker'
|
||||
|
||||
require 'events'
|
||||
require 'style'
|
||||
|
||||
# Basic
|
||||
require 'widgets/base'
|
||||
|
@ -63,14 +64,7 @@ private
|
|||
Curses.timeout = 0 # non-blocking input
|
||||
Curses.stdscr.keypad = true
|
||||
|
||||
Curses.init_pair 1, Curses::COLOR_WHITE, Curses::COLOR_BLACK
|
||||
Curses.init_pair 2, Curses::COLOR_BLACK, Curses::COLOR_WHITE
|
||||
Curses.init_pair 3, Curses::COLOR_WHITE, Curses::COLOR_BLACK # editing text
|
||||
Curses.init_pair 4, Curses::COLOR_BLACK, Curses::COLOR_GREEN # cursor
|
||||
Curses.init_pair 5, Curses::COLOR_BLACK, Curses::COLOR_CYAN
|
||||
Curses.init_pair 6, Curses::COLOR_CYAN, Curses::COLOR_BLACK
|
||||
Curses.init_pair 7, Curses::COLOR_GREEN, Curses::COLOR_BLACK
|
||||
|
||||
style
|
||||
initials
|
||||
end
|
||||
|
||||
|
@ -90,6 +84,10 @@ private
|
|||
end
|
||||
end
|
||||
|
||||
def style
|
||||
@style ||= Style.new
|
||||
end
|
||||
|
||||
def initials
|
||||
menu_width = Curses.stdscr.maxx / 5
|
||||
messenger_width = Curses.stdscr.maxx - menu_width
|
||||
|
|
18
lib/style.rb
Normal file
18
lib/style.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Style
|
||||
def self.counter
|
||||
@counter ||= 0
|
||||
@counter += 1
|
||||
end
|
||||
|
||||
def initialize
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_WHITE, Curses::COLOR_BLACK # text
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_BLACK, Curses::COLOR_WHITE # selection
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_WHITE, Curses::COLOR_BLACK # editing text
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_BLACK, Curses::COLOR_GREEN # cursor
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_BLACK, Curses::COLOR_CYAN # menu item
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_CYAN, Curses::COLOR_BLACK # message time
|
||||
Curses.init_pair self.class.counter, Curses::COLOR_GREEN, Curses::COLOR_BLACK # message author
|
||||
end
|
||||
end
|
Reference in a new issue