summaryrefslogtreecommitdiff
path: root/src/core.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-09-21 00:52:03 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-09-21 00:52:03 +0200
commit700b11e42d8045e8f4ef53588aab8e44dd9ac010 (patch)
treee913e8d5cd50701d6c95f4db6a11bb477744dbb3 /src/core.py
parent46705e18611cf49e5c0b45ce51ced221b0162167 (diff)
downloadpoezio-700b11e42d8045e8f4ef53588aab8e44dd9ac010.tar.gz
poezio-700b11e42d8045e8f4ef53588aab8e44dd9ac010.tar.bz2
poezio-700b11e42d8045e8f4ef53588aab8e44dd9ac010.tar.xz
poezio-700b11e42d8045e8f4ef53588aab8e44dd9ac010.zip
Handles 256 colors, easier theming and more flexible way to define colors
Doesn’t run yet if term doesn’t support 256 colors, I know (thus the branch "256")
Diffstat (limited to 'src/core.py')
-rw-r--r--src/core.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/core.py b/src/core.py
index 96531e5f..c47af752 100644
--- a/src/core.py
+++ b/src/core.py
@@ -18,7 +18,7 @@ import traceback
from datetime import datetime
import common
-import theme
+import theming
import logging
import singleton
import collections
@@ -45,6 +45,7 @@ from roster import Roster, RosterGroup, roster
from contact import Contact, Resource
from text_buffer import TextBuffer
from keyboard import read_char
+from theming import get_theme
# http://xmpp.org/extensions/xep-0045.html#errorstatus
ERROR_AND_STATUS_CODES = {
@@ -603,7 +604,7 @@ class Core(object):
remote_nick = roster.get_contact_by_jid(jid.bare).get_name() or jid.user
else:
remote_nick = jid.user
- conversation.get_room().add_message(body, nickname=remote_nick, nick_color=theme.COLOR_REMOTE_USER)
+ conversation.get_room().add_message(body, nickname=remote_nick, nick_color=get_theme().COLOR_REMOTE_USER)
if conversation.remote_wants_chatstates is None:
if message['chat_state']:
conversation.remote_wants_chatstates = True
@@ -613,7 +614,7 @@ class Core(object):
if 'private' in config.get('beep_on', 'highlight private').split():
curses.beep()
if self.current_tab() is not conversation:
- conversation.set_color_state(theme.COLOR_TAB_PRIVATE)
+ conversation.set_color_state(get_theme().COLOR_TAB_PRIVATE)
self.refresh_tab_win()
else:
self.refresh_window()
@@ -675,7 +676,7 @@ class Core(object):
roster.add_contact(contact, jid)
roster.edit_groups_of_contact(contact, [])
contact.set_ask('asked')
- self.get_tab_by_number(0).set_color_state(theme.COLOR_TAB_HIGHLIGHT)
+ self.get_tab_by_number(0).set_color_state(get_theme().COLOR_TAB_HIGHLIGHT)
self.information('%s wants to subscribe to your presence'%jid, 'Roster')
if isinstance(self.current_tab(), tabs.RosterInfoTab):
self.refresh_window()
@@ -804,9 +805,10 @@ class Core(object):
curses.noecho()
curses.nonl()
curses.raw()
- theme.init_colors()
stdscr.idlok(True)
stdscr.keypad(True)
+ curses.start_color()
+ curses.use_default_colors()
curses.ungetch(" ") # H4X: without this, the screen is
stdscr.getkey() # erased on the first "getkey()"
@@ -824,7 +826,7 @@ class Core(object):
"""
Refresh everything
"""
- self.current_tab().set_color_state(theme.COLOR_TAB_CURRENT)
+ self.current_tab().set_color_state(get_theme().COLOR_TAB_CURRENT)
self.current_tab().refresh()
self.doupdate()
@@ -872,15 +874,15 @@ class Core(object):
- A Muc with any new message
"""
for tab in self.tabs:
- if tab.get_color_state() == theme.COLOR_TAB_PRIVATE:
+ if tab.get_color_state() == get_theme().COLOR_TAB_PRIVATE:
self.command_win('%s' % tab.nb)
return
for tab in self.tabs:
- if tab.get_color_state() == theme.COLOR_TAB_HIGHLIGHT:
+ if tab.get_color_state() == get_theme().COLOR_TAB_HIGHLIGHT:
self.command_win('%s' % tab.nb)
return
for tab in self.tabs:
- if tab.get_color_state() == theme.COLOR_TAB_NEW_MESSAGE:
+ if tab.get_color_state() == get_theme().COLOR_TAB_NEW_MESSAGE:
self.command_win('%s' % tab.nb)
return
for tab in self.tabs:
@@ -1179,7 +1181,7 @@ class Core(object):
def command_theme(self, arg):
"""
"""
- theme.reload_theme()
+ # get_theme().reload_theme()
self.refresh_window()
def command_win(self, arg):