only have 64 colours, so everything works fine on every terminal, even on tmux. Fixed #1824

parent 92d155ac
......@@ -5,7 +5,7 @@
[Poezio]
# the server. Make sure the server you're using accepts anonymous authentification
server = anon.louiz.org:jeproteste.info
server = anon.louiz.org
# the port you'll use to connect
port = 5222
......
......@@ -3,54 +3,56 @@
# Message text color
COLOR_NORMAL_TEXT = 80
COLOR_INFORMATION_TEXT = 76
COLOR_HIGHLIGHT_TEXT = 79
COLOR_NORMAL_TEXT = 0
COLOR_INFORMATION_TEXT = 6
COLOR_HIGHLIGHT_TEXT = 4
# User list color
COLOR_USER_VISITOR = 78
COLOR_USER_PARTICIPANT = 73
COLOR_USER_NONE = 80
COLOR_USER_MODERATOR = 77
COLOR_USER_VISITOR = 8
COLOR_USER_PARTICIPANT = 5
COLOR_USER_NONE = 1
COLOR_USER_MODERATOR = 2
# The character printed in color (COLOR_STATUS_*) before the nickname
# in the user list
CHAR_STATUS = '|'
# Separators
COLOR_VERTICAL_SEPARATOR = 72
COLOR_NEW_TEXT_SEPARATOR = 75
COLOR_VERTICAL_SEPARATOR = 1
COLOR_NEW_TEXT_SEPARATOR = 4
# Time
COLOR_TIME_SEPARATOR = 79
COLOR_TIME_BRACKETS = 72
COLOR_TIME_SEPARATOR = 7
COLOR_TIME_LIMITER = 0
CHAR_TIME_LEFT = ''
CHAR_TIME_RIGHT = ''
COLOR_TIME_NUMBERS = 0
# Tabs
COLOR_TAB_NORMAL = 8
COLOR_TAB_CURRENT = 0
COLOR_TAB_NEW_MESSAGE = 7
COLOR_TAB_HIGHLIGHT = 5
COLOR_TAB_PRIVATE = 3
COLOR_TAB_NORMAL = 58
COLOR_TAB_CURRENT = 8
COLOR_TAB_NEW_MESSAGE = 11
COLOR_TAB_HIGHLIGHT = 9
COLOR_TAB_PRIVATE = 10
# Nickname colors
LIST_COLOR_NICKNAMES = [
73, 74, 75, 76, 77, 79
2, 3, 4, 5, 6, 7
]
COLOR_OWN_NICK = 80
COLOR_OWN_NICK = 8
# Status color
COLOR_STATUS_XA = 76
COLOR_STATUS_NONE = 73
COLOR_STATUS_DND = 77
COLOR_STATUS_AWAY = 79
COLOR_STATUS_CHAT = 75
COLOR_STATUS_XA = 6
COLOR_STATUS_NONE = 5
COLOR_STATUS_DND = 2
COLOR_STATUS_AWAY = 4
COLOR_STATUS_CHAT = 3
# Bars
COLOR_INFORMATION_BAR = 8
COLOR_TOPIC_BAR = 8
COLOR_PRIVATE_ROOM_BAR = 3
COLOR_SCROLLABLE_NUMBER = 75
COLOR_INFORMATION_BAR = 58
COLOR_TOPIC_BAR = 15
COLOR_PRIVATE_ROOM_BAR = 10
COLOR_SCROLLABLE_NUMBER = 11
# Strings for special messages (like join, quit, nick change, etc)
......@@ -59,13 +61,13 @@ CHAR_JOIN = '---->'
CHAR_QUIT = '<----'
CHAR_KICK = '-!-'
COLOR_JOIN_CHAR = 73
COLOR_QUIT_CHAR = 77
COLOR_KICK_CHAR = 77
COLOR_JOIN_CHAR = 5
COLOR_QUIT_CHAR = 2
COLOR_KICK_CHAR = 2
# words between ()
COLOR_CURLYBRACKETED_WORD = 72
COLOR_CURLYBRACKETED_WORD = 5
# words between {}
COLOR_ACCOLADE_WORD = 74
COLOR_ACCOLADE_WORD = 7
# words between []
COLOR_BRACKETED_WORD = 79
\ No newline at end of file
COLOR_BRACKETED_WORD = 4
\ No newline at end of file
......@@ -3,53 +3,55 @@
# Message text color
COLOR_NORMAL_TEXT = 0
COLOR_INFORMATION_TEXT = 76
COLOR_HIGHLIGHT_TEXT = 77
COLOR_INFORMATION_TEXT = 6
COLOR_HIGHLIGHT_TEXT = 2
# User list color
COLOR_USER_VISITOR = 78
COLOR_USER_PARTICIPANT = 73
COLOR_USER_NONE = 80
COLOR_USER_MODERATOR = 77
COLOR_USER_VISITOR = 8
COLOR_USER_PARTICIPANT = 5
COLOR_USER_NONE = 1
COLOR_USER_MODERATOR = 2
# The character printed in color (COLOR_STATUS_*) before the nickname
# in the user list
CHAR_STATUS = ' '
# Separators
COLOR_VERTICAL_SEPARATOR = 73
COLOR_NEW_TEXT_SEPARATOR = 75
COLOR_VERTICAL_SEPARATOR = 5
COLOR_NEW_TEXT_SEPARATOR = 3
# Time
COLOR_TIME_SEPARATOR = 79
COLOR_TIME_BRACKETS = 74
COLOR_TIME_SEPARATOR = 7
COLOR_TIME_LIMITER = 0
CHAR_TIME_LEFT = ''
CHAR_TIME_RIGHT = ''
COLOR_TIME_NUMBERS = 0
# Tabs
COLOR_TAB_NORMAL = 15
COLOR_TAB_CURRENT = 24
COLOR_TAB_NEW_MESSAGE = 42
COLOR_TAB_HIGHLIGHT = 51
COLOR_TAB_PRIVATE = 33
COLOR_TAB_NORMAL = 43
COLOR_TAB_CURRENT = 57
COLOR_TAB_NEW_MESSAGE = 50
COLOR_TAB_HIGHLIGHT = 22
COLOR_TAB_PRIVATE = 29
# Nickname colors
LIST_COLOR_NICKNAMES = [
73, 74, 75, 76, 77, 79
2, 3, 4, 5, 6, 7
]
COLOR_OWN_NICK = 78
COLOR_OWN_NICK = 8
# Status color
COLOR_STATUS_XA = 40
COLOR_STATUS_NONE = 72
COLOR_STATUS_DND = 50
COLOR_STATUS_AWAY = 70
COLOR_STATUS_CHAT = 30
COLOR_STATUS_XA = 50
COLOR_STATUS_NONE = 0
COLOR_STATUS_DND = 22
COLOR_STATUS_AWAY = 36
COLOR_STATUS_CHAT = 29
# Bars
COLOR_INFORMATION_BAR = 15
COLOR_TOPIC_BAR = 15
COLOR_PRIVATE_ROOM_BAR = 33
COLOR_SCROLLABLE_NUMBER = 16
COLOR_INFORMATION_BAR = 43
COLOR_TOPIC_BAR = 43
COLOR_PRIVATE_ROOM_BAR = 29
COLOR_SCROLLABLE_NUMBER = 40
# Strings for special messages (like join, quit, nick change, etc)
......@@ -58,13 +60,13 @@ CHAR_JOIN = '---->'
CHAR_QUIT = '<----'
CHAR_KICK = '-!-'
COLOR_JOIN_CHAR = 73
COLOR_QUIT_CHAR = 77
COLOR_KICK_CHAR = 77
COLOR_JOIN_CHAR = 5
COLOR_QUIT_CHAR = 2
COLOR_KICK_CHAR = 2
# words between ()
COLOR_CURLYBRACKETED_WORD = 72
COLOR_CURLYBRACKETED_WORD = 5
# words between {}
COLOR_ACCOLADE_WORD = 74
COLOR_ACCOLADE_WORD = 7
# words between []
COLOR_BRACKETED_WORD = 73
COLOR_BRACKETED_WORD = 4
......@@ -86,6 +86,4 @@ def main():
gui.main_loop() # Refresh the screen, wait for user events etc
if __name__ == '__main__':
if os.environ['TERM'] != 'screen':
os.environ['TERM'] = 'xterm-256color' # FIXME
main()
......@@ -31,53 +31,55 @@ from config import config
# Message text color
COLOR_NORMAL_TEXT = 0
COLOR_INFORMATION_TEXT = 76
COLOR_HIGHLIGHT_TEXT = 77
COLOR_INFORMATION_TEXT = 6
COLOR_HIGHLIGHT_TEXT = 2
# User list color
COLOR_USER_VISITOR = 78
COLOR_USER_PARTICIPANT = 73
COLOR_USER_NONE = 80
COLOR_USER_MODERATOR = 77
COLOR_USER_VISITOR = 8
COLOR_USER_PARTICIPANT = 5
COLOR_USER_NONE = 1
COLOR_USER_MODERATOR = 2
# The character printed in color (COLOR_STATUS_*) before the nickname
# in the user list
CHAR_STATUS = ' '
# Separators
COLOR_VERTICAL_SEPARATOR = 73
COLOR_NEW_TEXT_SEPARATOR = 75
COLOR_VERTICAL_SEPARATOR = 5
COLOR_NEW_TEXT_SEPARATOR = 3
# Time
COLOR_TIME_SEPARATOR = 79
COLOR_TIME_BRACKETS = 74
COLOR_TIME_SEPARATOR = 7
COLOR_TIME_LIMITER = 0
CHAR_TIME_LEFT = ''
CHAR_TIME_RIGHT = ''
COLOR_TIME_NUMBERS = 0
# Tabs
COLOR_TAB_NORMAL = 15
COLOR_TAB_CURRENT = 24
COLOR_TAB_NEW_MESSAGE = 42
COLOR_TAB_HIGHLIGHT = 51
COLOR_TAB_PRIVATE = 33
COLOR_TAB_NORMAL = 43
COLOR_TAB_CURRENT = 57
COLOR_TAB_NEW_MESSAGE = 50
COLOR_TAB_HIGHLIGHT = 22
COLOR_TAB_PRIVATE = 29
# Nickname colors
LIST_COLOR_NICKNAMES = [
73, 74, 75, 76, 77, 79
2, 3, 4, 5, 6, 7
]
COLOR_OWN_NICK = 78
COLOR_OWN_NICK = 8
# Status color
COLOR_STATUS_XA = 40
COLOR_STATUS_NONE = 72
COLOR_STATUS_DND = 50
COLOR_STATUS_AWAY = 70
COLOR_STATUS_CHAT = 30
COLOR_STATUS_XA = 50
COLOR_STATUS_NONE = 0
COLOR_STATUS_DND = 22
COLOR_STATUS_AWAY = 36
COLOR_STATUS_CHAT = 29
# Bars
COLOR_INFORMATION_BAR = 15
COLOR_TOPIC_BAR = 15
COLOR_PRIVATE_ROOM_BAR = 33
COLOR_SCROLLABLE_NUMBER = 16
COLOR_INFORMATION_BAR = 43
COLOR_TOPIC_BAR = 43
COLOR_PRIVATE_ROOM_BAR = 29
COLOR_SCROLLABLE_NUMBER = 40
# Strings for special messages (like join, quit, nick change, etc)
......@@ -86,40 +88,38 @@ CHAR_JOIN = '---->'
CHAR_QUIT = '<----'
CHAR_KICK = '-!-'
COLOR_JOIN_CHAR = 73
COLOR_QUIT_CHAR = 77
COLOR_KICK_CHAR = 77
COLOR_JOIN_CHAR = 5
COLOR_QUIT_CHAR = 2
COLOR_KICK_CHAR = 2
# words between ()
COLOR_CURLYBRACKETED_WORD = 72
COLOR_CURLYBRACKETED_WORD = 5
# words between {}
COLOR_ACCOLADE_WORD = 74
COLOR_ACCOLADE_WORD = 7
# words between []
COLOR_BRACKETED_WORD = 73
COLOR_BRACKETED_WORD = 4
def init_colors():
"""
Initilization of all the available ncurses colors
limit the number of colors to 64 (because some terminals
don't handle more than that), by removing some useless colors
like 'black on black', etc.
"""
curses.start_color()
curses.use_default_colors()
colors_list = [
curses.COLOR_BLACK,
curses.COLOR_BLUE,
curses.COLOR_CYAN,
curses.COLOR_GREEN,
curses.COLOR_MAGENTA,
curses.COLOR_RED,
curses.COLOR_WHITE,
curses.COLOR_YELLOW,
-1
]
cpt = 0
for i in colors_list:
for y in colors_list:
cpt = 1
for i in range(-1, 7):
for y in range(0, 8):
if y == i:
continue
curses.init_pair(cpt, y, i)
cpt += 1
for y in range(0, 7):
# init the default fg on others bg at last
curses.init_pair(cpt, -1, y)
cpt += 1
# Have the default color be default fg on default bg
reload_theme()
def reload_theme():
......@@ -144,7 +144,7 @@ def reload_theme():
except: # TODO warning: theme not found
return
for var in dir(theme):
if var.startswith('COLOR_') or var.startswith('CHAR_'):
if var.startswith('COLOR_') or var.startswith('CHAR_') or var.startswith('LIST_'):
globals()[var] = getattr(theme, var)
if __name__ == '__main__':
......
......@@ -215,7 +215,8 @@ class TextWin(Win):
txt = message.txt
if not txt:
continue
offset = 11 # length of the time
# length of the time
offset = 9+len(theme.CHAR_TIME_LEFT[:1])+len(theme.CHAR_TIME_RIGHT[:1])
if message.nickname and len(message.nickname) >= 30:
nick = message.nickname[:30]+'…'
else:
......@@ -351,9 +352,9 @@ class TextWin(Win):
"""
Write the date on the yth line of the window
"""
self.win.attron(curses.color_pair(theme.COLOR_TIME_BRACKETS))
self.addnstr('[', 1)
self.win.attroff(curses.color_pair(theme.COLOR_TIME_BRACKETS))
self.win.attron(curses.color_pair(theme.COLOR_TIME_LIMITER))
self.addnstr(theme.CHAR_TIME_LEFT, 1)
self.win.attroff(curses.color_pair(theme.COLOR_TIME_LIMITER))
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
self.addnstr(time.strftime("%H"), 2)
......@@ -375,9 +376,9 @@ class TextWin(Win):
self.addnstr(time.strftime('%S'), 2)
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
self.win.attron(curses.color_pair(theme.COLOR_TIME_BRACKETS))
self.addstr(']')
self.win.attroff(curses.color_pair(theme.COLOR_TIME_BRACKETS))
self.win.attron(curses.color_pair(theme.COLOR_TIME_LIMITER))
self.addnstr(theme.CHAR_TIME_RIGHT, 1)
self.win.attroff(curses.color_pair(theme.COLOR_TIME_LIMITER))
self.addstr(' ')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment