diff options
-rw-r--r-- | src/client.py | 7 | ||||
-rw-r--r-- | src/common.py | 7 | ||||
-rw-r--r-- | src/connection.py | 4 | ||||
-rw-r--r-- | src/gui.py | 11 | ||||
-rw-r--r-- | src/window.py | 18 |
5 files changed, 30 insertions, 17 deletions
diff --git a/src/client.py b/src/client.py index 9616be1c..3480907b 100644 --- a/src/client.py +++ b/src/client.py @@ -21,7 +21,7 @@ import sys # disable any printout (this would mess the display) # sys.stdout = open('/dev/null', 'w') -# sys.stderr = open('/dev/null', 'w') +sys.stderr = open('debug', 'w') from connection import Connection from multiuserchat import MultiUserChat @@ -49,16 +49,13 @@ class Client(object): self.resource = config.get('resource', 'poezio') self.server = config.get('server', 'louiz.org') self.connection = Connection(self.server, self.resource) - # self.connection.demon = True self.connection.start() - # self.connection.run() self.stdscr = initscr() self.gui = Gui(self.stdscr, MultiUserChat(self.connection.client)) - # thread.start_new_thread(self.launch, ()) def launch(self): """ - launch + launch the gui """ self.gui.main_loop(self.stdscr) diff --git a/src/common.py b/src/common.py index 340eb213..1c119c1e 100644 --- a/src/common.py +++ b/src/common.py @@ -30,7 +30,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# various useful functions +__doc__ = "various useful functions" import base64 import os @@ -41,6 +41,11 @@ import curses import traceback import sys +def debug(s): + f = open("debug", 'a') + f.write(s+'\n') + f.close() + def exception_handler(type_, value, trace): """ on any traceback: exit ncurses and print the traceback diff --git a/src/connection.py b/src/connection.py index bc4928e7..a95191ba 100644 --- a/src/connection.py +++ b/src/connection.py @@ -45,7 +45,7 @@ class Connection(threading.Thread): def __init__(self, server, resource): threading.Thread.__init__(self) self.handler = Handler() - self.daemon = True # exit the program when this exits + self.daemon = True # exit the program when this thread exits self.server = server self.resource = resource self.online = 0 # 1:connected, 2:auth confirmed @@ -66,7 +66,7 @@ class Connection(threading.Thread): self.handler.emit('error', msg='Could not authenticate to server') sys.exit(-1) self.client.sendInitPresence(requestRoster=0) - self.online = 1 # 2 when confirmation of auth is received + self.online = 1 # 2 when confirmation of our auth is received self.register_handlers() while 1: self.process() @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with Poezio. If not, see <http://www.gnu.org/licenses/>. +from common import debug + from gettext import (bindtextdomain, textdomain, bind_textdomain_codeset, gettext as _) @@ -77,7 +79,7 @@ class Gui(object): 'away': (self.command_away, _('Usage: /away [message]\nAway: Sets your availability to away and (optional) sets your status message. This is equivalent to "/show away [message]"')), 'busy': (self.command_busy, _('Usage: /busy [message]\nBusy: Sets your availability to busy and (optional) sets your status message. This is equivalent to "/show busy [message]"')), 'avail': (self.command_avail, _('Usage: /avail [message]\nAvail: Sets your availability to available and (optional) sets your status message. This is equivalent to "/show available [message]"')), - 'available': (self.command_avail, _('Usage: /available [message]\nAvailable: Sets your availability to available and (optional) sets your status message. This is equivalent to "/show available [message]"')), + 'available': (self.command_avail, _('Usage: /available [message]\nAvailable: Sets your availability to available and (optional) sets your status message. This is equivalent to "/show available [message]"')), 'bookmark': (self.command_bookmark, _('Usage: /bookmark [roomname][/nick]\nBookmark: Bookmark the specified room (you will then auto-join it on each poezio start). This commands uses the same syntaxe as /join. Type /help join for syntaxe examples. Note that when typing "/bookmark" on its own, the room will be bookmarked with the nickname you\'re currently using in this room (instead of default_nick)')), 'set': (self.command_set, _('Usage: /set <option> [value]\nSet: Sets the value to the option in your configuration file. You can, for example, change your default nickname by doing `/set default_nick toto` or your resource with `/set resource blabla`. You can also set an empty value (nothing) by providing no [value] after <option>.')), 'kick': (self.command_kick, _('Usage: /kick <nick> [reason]\nKick: Kick the user with the specified nickname. You also can give an optional reason.')), @@ -116,8 +118,9 @@ class Gui(object): try: key = stdscr.getkey() except: - self.window.resize(stdscr) - self.window.refresh(self.rooms) + debug("main_loop exception") + # self.window.resize(stdscr) + # self.window.refresh(self.rooms) continue if str(key) in self.key_func.keys(): self.key_func[key]() @@ -134,7 +137,7 @@ class Gui(object): continue else: if ord(key) == 27 and ord(stdscr.getkey()) == 91: - last = ord(stdscr.getkey()) # FIXME: ugly ugly workaroung. + last = ord(stdscr.getkey()) # FIXME: ugly ugly workaround. if last == 51: self.window.input.key_dc() continue diff --git a/src/window.py b/src/window.py index 8dc31096..f361f761 100644 --- a/src/window.py +++ b/src/window.py @@ -20,6 +20,8 @@ import curses from config import config +from common import debug + class Win(object): def __init__(self, height, width, y, x, parent_win): self._resize(height, width, y, x, parent_win) @@ -33,6 +35,9 @@ class Win(object): # doesn't give a reason for this to happen, so I can't # really fix this. # just don't crash when this happens. + # (°> also, a penguin + # //\ + # V_/_ print parent_win, parent_win.height, parent_win.width, height, width, y, x raise self.win.leaveok(1) @@ -121,8 +126,11 @@ class RoomInfo(Win): def compare_room(a, b): return a.nb - b.nb self.win.clear() - self.win.addnstr(0, 0, current.name+" [", self.width + try: + self.win.addnstr(0, 0, current.name+" [", self.width ,curses.color_pair(1)) + except: + pass sorted_rooms = sorted(rooms, compare_room) for room in sorted_rooms: if current == room: @@ -483,7 +491,7 @@ class Input(Win): class Window(object): """ The whole "screen" that can be seen at once in the terminal. - It contains an userlist, an input zone and a chat zone + It contains an userlist, an input zone, a topic zone and a chat zone """ def __init__(self, stdscr): """ @@ -514,7 +522,6 @@ class Window(object): Resize the whole tabe. i.e. all its sub-windows """ self.size = (self.height, self.width) = stdscr.getmaxyx() - open('caca', 'a').write(str(self.size)) if self.height < 10 or self.width < 60: visible = False else: @@ -523,11 +530,12 @@ class Window(object): stdscr.attron(curses.color_pair(2)) stdscr.vline(1, 9*(self.width/10), curses.ACS_VLINE, self.height-2) stdscr.attroff(curses.color_pair(2)) - self.user_win.resize(self.height-3, (self.width/10)-1, 1, 9*(self.width/10)+1, stdscr, visible) + text_width = (self.width/10)*9; self.topic_win.resize(1, self.width, 0, 0, stdscr, visible) self.info_win.resize(1, self.width, self.height-2, 0, stdscr, visible) - self.text_win.resize(self.height-3, (self.width/10)*9, 1, 0, stdscr, visible) + self.text_win.resize(self.height-3, text_width, 1, 0, stdscr, visible) self.input.resize(1, self.width, self.height-1, 0, stdscr, visible) + self.user_win.resize(self.height-3, self.width-text_width-1, 1, text_width+1, stdscr, visible) def refresh(self, rooms): """ |