remove one more possible ncurses glitch by using a muttex. Also correctly receive the error messages. And little cleanup
This commit is contained in:
parent
007466f6aa
commit
77df6feb97
5 changed files with 104 additions and 52 deletions
|
@ -37,8 +37,19 @@ class Connection(sleekxmpp.ClientXMPP):
|
||||||
appropriate signals
|
appropriate signals
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
sleekxmpp.ClientXMPP.__init__(self, None, None, ssl=True,
|
if config.get('jid', ''):
|
||||||
|
self.anon = False # Field used to know if we are anonymous or not.
|
||||||
|
# many features will be handled diferently
|
||||||
|
# depending on this setting
|
||||||
|
jid = config.get('jid', '')
|
||||||
|
password = config.get('password', '')
|
||||||
|
else: # anonymous auth
|
||||||
|
self.anon = True
|
||||||
|
jid = None
|
||||||
|
password = None
|
||||||
|
sleekxmpp.ClientXMPP.__init__(self, jid, password, ssl=True,
|
||||||
resource=config.get('resource', 'poezio'))
|
resource=config.get('resource', 'poezio'))
|
||||||
|
|
||||||
self.registerPlugin('xep_0045')
|
self.registerPlugin('xep_0045')
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
52
src/gui.py
52
src/gui.py
|
@ -150,6 +150,8 @@ class Gui(object):
|
||||||
self.xmpp.add_event_handler("groupchat_presence", self.on_groupchat_presence)
|
self.xmpp.add_event_handler("groupchat_presence", self.on_groupchat_presence)
|
||||||
self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message)
|
self.xmpp.add_event_handler("groupchat_message", self.on_groupchat_message)
|
||||||
self.xmpp.add_event_handler("message", self.on_message)
|
self.xmpp.add_event_handler("message", self.on_message)
|
||||||
|
self.xmpp.add_event_handler("presence", self.on_presence)
|
||||||
|
self.xmpp.add_event_handler("roster_update", self.on_roster_update)
|
||||||
# self.handler = Handler()
|
# self.handler = Handler()
|
||||||
# self.handler.connect('on-connected', self.on_connected)
|
# self.handler.connect('on-connected', self.on_connected)
|
||||||
# self.handler.connect('join-room', self.join_room)
|
# self.handler.connect('join-room', self.join_room)
|
||||||
|
@ -166,6 +168,11 @@ class Gui(object):
|
||||||
self.information(_("Welcome on Poezio \o/!"))
|
self.information(_("Welcome on Poezio \o/!"))
|
||||||
self.information(_("Your JID is %s") % self.xmpp.fulljid)
|
self.information(_("Your JID is %s") % self.xmpp.fulljid)
|
||||||
|
|
||||||
|
if not self.xmpp.anon:
|
||||||
|
# request the roster
|
||||||
|
self.xmpp.getRoster()
|
||||||
|
# send initial presence
|
||||||
|
self.xmpp.makePresence(pfrom=self.xmpp.jid).send()
|
||||||
rooms = config.get('rooms', '')
|
rooms = config.get('rooms', '')
|
||||||
if rooms == '' or not isinstance(rooms, str):
|
if rooms == '' or not isinstance(rooms, str):
|
||||||
return
|
return
|
||||||
|
@ -184,6 +191,7 @@ class Gui(object):
|
||||||
nick = default
|
nick = default
|
||||||
self.open_new_room(roomname, nick)
|
self.open_new_room(roomname, nick)
|
||||||
muc.join_groupchat(self.xmpp, roomname, nick)
|
muc.join_groupchat(self.xmpp, roomname, nick)
|
||||||
|
# if not self.xmpp.anon:
|
||||||
# Todo: SEND VCARD
|
# Todo: SEND VCARD
|
||||||
return
|
return
|
||||||
if config.get('jid', '') == '': # Don't send the vcard if we're not anonymous
|
if config.get('jid', '') == '': # Don't send the vcard if we're not anonymous
|
||||||
|
@ -362,13 +370,18 @@ class Gui(object):
|
||||||
When receiving private message from a muc OR a normal message
|
When receiving private message from a muc OR a normal message
|
||||||
(from one of our contacts)
|
(from one of our contacts)
|
||||||
"""
|
"""
|
||||||
|
from common import debug
|
||||||
|
debug('message: %s\n' % message)
|
||||||
if message['type'] == 'groupchat':
|
if message['type'] == 'groupchat':
|
||||||
return None
|
return None
|
||||||
# Differentiate both type of messages, and call the appropriate handler.
|
# Differentiate both type of messages, and call the appropriate handler.
|
||||||
jid_from = message['from']
|
jid_from = message['from']
|
||||||
for room in self.rooms:
|
for room in self.rooms:
|
||||||
if room.jid is None and room.name == jid_from.bare: # check all the MUC we are in
|
if room.jid is None and room.name == jid_from.bare: # check all the MUC we are in
|
||||||
return self.on_groupchat_private_message(message)
|
if message['type'] == 'error':
|
||||||
|
return self.room_error(message, room.name)
|
||||||
|
else:
|
||||||
|
return self.on_groupchat_private_message(message)
|
||||||
return self.on_normal_message(message)
|
return self.on_normal_message(message)
|
||||||
|
|
||||||
def on_groupchat_private_message(self, message):
|
def on_groupchat_private_message(self, message):
|
||||||
|
@ -392,8 +405,28 @@ class Gui(object):
|
||||||
"""
|
"""
|
||||||
When receiving "normal" messages (from someone in our roster)
|
When receiving "normal" messages (from someone in our roster)
|
||||||
"""
|
"""
|
||||||
|
from common import debug
|
||||||
|
debug('MESSAGE: %s\n' % (presence))
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def on_presence(self, presence):
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
from common import debug
|
||||||
|
debug('PRESEEEEEEEEENCE: %s\n' % (presence))
|
||||||
|
return
|
||||||
|
|
||||||
|
def on_roster_update(self, iq):
|
||||||
|
"""
|
||||||
|
A subscription changed, or we received a roster item
|
||||||
|
after a roster request, etc
|
||||||
|
"""
|
||||||
|
from common import debug
|
||||||
|
debug("UPDATE: %s\n" % (iq))
|
||||||
|
for subscriber in iq['roster']['items']:
|
||||||
|
debug("subscriber: %s\n" % (iq['roster']['items'][subscriber]['subscription']))
|
||||||
|
|
||||||
def resize_window(self):
|
def resize_window(self):
|
||||||
"""
|
"""
|
||||||
Resize the whole screen
|
Resize the whole screen
|
||||||
|
@ -479,18 +512,6 @@ class Gui(object):
|
||||||
"""
|
"""
|
||||||
Called when Tab is pressed, complete the nickname in the input
|
Called when Tab is pressed, complete the nickname in the input
|
||||||
"""
|
"""
|
||||||
# def compare_users(a, b):
|
|
||||||
# """
|
|
||||||
# Used to sort users by their last_talked
|
|
||||||
# """
|
|
||||||
# if not a.last_talked and b.last_talked:
|
|
||||||
# return 0
|
|
||||||
# elif not b.last_talked and a.last_talked:
|
|
||||||
# return 1
|
|
||||||
# if a.last_talked < b.last_talked:
|
|
||||||
# return 1
|
|
||||||
# else:
|
|
||||||
# return -1
|
|
||||||
compare_users = lambda x: x.last_talked
|
compare_users = lambda x: x.last_talked
|
||||||
self.window.input.auto_completion([user.nick for user in sorted(self.current_room().users, key=compare_users, reverse=True)])
|
self.window.input.auto_completion([user.nick for user in sorted(self.current_room().users, key=compare_users, reverse=True)])
|
||||||
|
|
||||||
|
@ -563,6 +584,8 @@ class Gui(object):
|
||||||
"""
|
"""
|
||||||
Display the error on the room window
|
Display the error on the room window
|
||||||
"""
|
"""
|
||||||
|
from common import debug
|
||||||
|
debug('ERROR: %s\n' % error)
|
||||||
room = self.get_room_by_name(room_name)
|
room = self.get_room_by_name(room_name)
|
||||||
if not room:
|
if not room:
|
||||||
room = self.get_room_by_name('Info')
|
room = self.get_room_by_name('Info')
|
||||||
|
@ -621,7 +644,6 @@ class Gui(object):
|
||||||
"""
|
"""
|
||||||
Triggered whenever a message is received from a multi-user chat room.
|
Triggered whenever a message is received from a multi-user chat room.
|
||||||
"""
|
"""
|
||||||
# FIXME: not receiving subjects? :/
|
|
||||||
delay_tag = message.find('{urn:xmpp:delay}delay')
|
delay_tag = message.find('{urn:xmpp:delay}delay')
|
||||||
if delay_tag is not None:
|
if delay_tag is not None:
|
||||||
delayed = True
|
delayed = True
|
||||||
|
@ -638,6 +660,8 @@ class Gui(object):
|
||||||
date = None
|
date = None
|
||||||
nick_from = message['mucnick']
|
nick_from = message['mucnick']
|
||||||
room_from = message.getMucroom()
|
room_from = message.getMucroom()
|
||||||
|
if message['type'] == 'error': # Check if it's an error
|
||||||
|
return self.room_error(message, from_room)
|
||||||
if nick_from == room_from:
|
if nick_from == room_from:
|
||||||
nick_from = None
|
nick_from = None
|
||||||
room = self.get_room_by_name(room_from)
|
room = self.get_room_by_name(room_from)
|
||||||
|
|
|
@ -42,7 +42,7 @@ def read_char(s):
|
||||||
see http://en.wikipedia.org/wiki/UTF-8#Description
|
see http://en.wikipedia.org/wiki/UTF-8#Description
|
||||||
"""
|
"""
|
||||||
(first, char) = get_next_byte(s)
|
(first, char) = get_next_byte(s)
|
||||||
if first == None: # Keyboard special, like KEY_HOME etc
|
if not isinstance(first, int): # Keyboard special, like KEY_HOME etc
|
||||||
return char
|
return char
|
||||||
if first == 127 or first == 8:
|
if first == 127 or first == 8:
|
||||||
return "KEY_BACKSPACE"
|
return "KEY_BACKSPACE"
|
||||||
|
|
|
@ -61,8 +61,8 @@ def exception_handler(type_, value, trace):
|
||||||
except: # if an exception is raised but initscr has never been called yet
|
except: # if an exception is raised but initscr has never been called yet
|
||||||
pass
|
pass
|
||||||
traceback.print_exception(type_, value, trace, None, sys.stderr)
|
traceback.print_exception(type_, value, trace, None, sys.stderr)
|
||||||
# import os # used to quit the program even from a thread
|
import os # used to quit the program even from a thread
|
||||||
# os.abort()
|
os.abort()
|
||||||
|
|
||||||
sys.excepthook = exception_handler
|
sys.excepthook = exception_handler
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,21 @@ class Win(object):
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
self.win.noutrefresh()
|
self.win.noutrefresh()
|
||||||
|
|
||||||
|
def addnstr(self, *args):
|
||||||
|
"""
|
||||||
|
addnstr is safe
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self.win.addnstr(*args)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def addstr(self, *args):
|
||||||
|
"""
|
||||||
|
addstr is not safe
|
||||||
|
"""
|
||||||
|
self.win.addstr(*args)
|
||||||
|
|
||||||
class UserList(Win):
|
class UserList(Win):
|
||||||
def __init__(self, height, width, y, x, parent_win, visible):
|
def __init__(self, height, width, y, x, parent_win, visible):
|
||||||
Win.__init__(self, height, width, y, x, parent_win)
|
Win.__init__(self, height, width, y, x, parent_win)
|
||||||
|
@ -82,10 +97,10 @@ class UserList(Win):
|
||||||
role_col = self.color_role[user.role]
|
role_col = self.color_role[user.role]
|
||||||
show_col = self.color_show[user.show]
|
show_col = self.color_show[user.show]
|
||||||
self.win.attron(curses.color_pair(show_col))
|
self.win.attron(curses.color_pair(show_col))
|
||||||
self.win.addnstr(y, 0, theme.CHAR_STATUS, 1)
|
self.addnstr(y, 0, theme.CHAR_STATUS, 1)
|
||||||
self.win.attroff(curses.color_pair(show_col))
|
self.win.attroff(curses.color_pair(show_col))
|
||||||
self.win.attron(curses.color_pair(role_col))
|
self.win.attron(curses.color_pair(role_col))
|
||||||
self.win.addnstr(y, 1, user.nick, self.width-1)
|
self.addnstr(y, 1, user.nick, self.width-1)
|
||||||
self.win.attroff(curses.color_pair(role_col))
|
self.win.attroff(curses.color_pair(role_col))
|
||||||
y += 1
|
y += 1
|
||||||
if y == self.height:
|
if y == self.height:
|
||||||
|
@ -113,7 +128,7 @@ class Topic(Win):
|
||||||
g_lock.acquire()
|
g_lock.acquire()
|
||||||
self.win.erase()
|
self.win.erase()
|
||||||
if not jid:
|
if not jid:
|
||||||
self.win.addnstr(0, 0, topic[:self.width-1], curses.color_pair(theme.COLOR_TOPIC_BAR))
|
self.addnstr(0, 0, topic[:self.width-1], curses.color_pair(theme.COLOR_TOPIC_BAR))
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.win.addch(' ', curses.color_pair(theme.COLOR_TOPIC_BAR))
|
self.win.addch(' ', curses.color_pair(theme.COLOR_TOPIC_BAR))
|
||||||
|
@ -123,7 +138,7 @@ class Topic(Win):
|
||||||
room = jid.split('/')[0]
|
room = jid.split('/')[0]
|
||||||
nick = '/'.join(jid.split('/')[1:])
|
nick = '/'.join(jid.split('/')[1:])
|
||||||
topic = _('%(nick)s from room %(room)s' % {'nick': nick, 'room':room})
|
topic = _('%(nick)s from room %(room)s' % {'nick': nick, 'room':room})
|
||||||
self.win.addnstr(0, 0, topic + " "*(self.width-len(topic)), self.width-1
|
self.addnstr(0, 0, topic + " "*(self.width-len(topic)), self.width-1
|
||||||
, curses.color_pair(theme.COLOR_PRIVATE_ROOM_BAR))
|
, curses.color_pair(theme.COLOR_PRIVATE_ROOM_BAR))
|
||||||
|
|
||||||
self.win.refresh()
|
self.win.refresh()
|
||||||
|
@ -144,7 +159,8 @@ class RoomInfo(Win):
|
||||||
down
|
down
|
||||||
"""
|
"""
|
||||||
if current_room.pos > 0:
|
if current_room.pos > 0:
|
||||||
self.win.addstr(' -PLUS(%s)-' % current_room.pos, curses.color_pair(theme.COLOR_SCROLLABLE_NUMBER) | curses.A_BOLD)
|
plus = ' -PLUS(%s)-' % current_room.pos
|
||||||
|
self.addnstr(plus, len(plus), curses.color_pair(theme.COLOR_SCROLLABLE_NUMBER) | curses.A_BOLD)
|
||||||
|
|
||||||
def refresh(self, rooms, current):
|
def refresh(self, rooms, current):
|
||||||
if not self.visible:
|
if not self.visible:
|
||||||
|
@ -155,22 +171,22 @@ class RoomInfo(Win):
|
||||||
comp = lambda x: x.nb
|
comp = lambda x: x.nb
|
||||||
g_lock.acquire()
|
g_lock.acquire()
|
||||||
self.win.erase()
|
self.win.erase()
|
||||||
self.win.addnstr(0, 0, "[", self.width
|
self.addnstr(0, 0, "[", self.width
|
||||||
,curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
,curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
||||||
sorted_rooms = sorted(rooms, key=comp)
|
sorted_rooms = sorted(rooms, key=comp)
|
||||||
for room in sorted_rooms:
|
for room in sorted_rooms:
|
||||||
color = room.color_state
|
color = room.color_state
|
||||||
try:
|
try:
|
||||||
self.win.addstr("%s" % str(room.nb), curses.color_pair(color))
|
self.addstr("%s" % str(room.nb), curses.color_pair(color))
|
||||||
self.win.addstr("|", curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
self.addstr("|", curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
||||||
except: # end of line
|
except: # end of line
|
||||||
break
|
break
|
||||||
(y, x) = self.win.getyx()
|
(y, x) = self.win.getyx()
|
||||||
self.win.addstr(y, x-1, '] '+ current.name, curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
self.addstr(y, x-1, '] '+ current.name, curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
||||||
# self.print_scroll_position(current)
|
self.print_scroll_position(current)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.win.addstr(' ', curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
self.addstr(' ', curses.color_pair(theme.COLOR_INFORMATION_BAR))
|
||||||
except:
|
except:
|
||||||
break
|
break
|
||||||
self.win.refresh()
|
self.win.refresh()
|
||||||
|
@ -287,7 +303,7 @@ class TextWin(Win):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_NEW_TEXT_SEPARATOR))
|
self.win.attron(curses.color_pair(theme.COLOR_NEW_TEXT_SEPARATOR))
|
||||||
self.win.addstr(' -'*(self.width//2))
|
self.addstr(' -'*(self.width//2))
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_NEW_TEXT_SEPARATOR))
|
self.win.attroff(curses.color_pair(theme.COLOR_NEW_TEXT_SEPARATOR))
|
||||||
|
|
||||||
def write_text(self, y, x, txt, color, colorized):
|
def write_text(self, y, x, txt, color, colorized):
|
||||||
|
@ -299,7 +315,7 @@ class TextWin(Win):
|
||||||
if color:
|
if color:
|
||||||
self.win.attron(curses.color_pair(color))
|
self.win.attron(curses.color_pair(color))
|
||||||
try:
|
try:
|
||||||
self.win.addstr(y, x, txt)
|
self.addstr(y, x, txt)
|
||||||
except: # bug 1665
|
except: # bug 1665
|
||||||
pass
|
pass
|
||||||
if color:
|
if color:
|
||||||
|
@ -315,22 +331,22 @@ class TextWin(Win):
|
||||||
for word in txt.split():
|
for word in txt.split():
|
||||||
if word in list(special_words.keys()):
|
if word in list(special_words.keys()):
|
||||||
self.win.attron(curses.color_pair(special_words[word]))
|
self.win.attron(curses.color_pair(special_words[word]))
|
||||||
self.win.addstr(word)
|
self.addstr(word)
|
||||||
self.win.attroff(curses.color_pair(special_words[word]))
|
self.win.attroff(curses.color_pair(special_words[word]))
|
||||||
elif word.startswith('(') and word.endswith(')'):
|
elif word.startswith('(') and word.endswith(')'):
|
||||||
self.win.addstr('(', curses.color_pair(color))
|
self.addstr('(', curses.color_pair(color))
|
||||||
self.win.addstr(word[1:-1], curses.color_pair(theme.COLOR_CURLYBRACKETED_WORD))
|
self.addstr(word[1:-1], curses.color_pair(theme.COLOR_CURLYBRACKETED_WORD))
|
||||||
self.win.addstr(')', curses.color_pair(color))
|
self.addstr(')', curses.color_pair(color))
|
||||||
elif word.startswith('{') and word.endswith('}'):
|
elif word.startswith('{') and word.endswith('}'):
|
||||||
self.win.addstr(word[1:-1], curses.color_pair(theme.COLOR_ACCOLADE_WORD))
|
self.addstr(word[1:-1], curses.color_pair(theme.COLOR_ACCOLADE_WORD))
|
||||||
elif word.startswith('[') and word.endswith(']'):
|
elif word.startswith('[') and word.endswith(']'):
|
||||||
self.win.addstr(word[1:-1], curses.color_pair(theme.COLOR_BRACKETED_WORD))
|
self.addstr(word[1:-1], curses.color_pair(theme.COLOR_BRACKETED_WORD))
|
||||||
else:
|
else:
|
||||||
self.win.attron(curses.color_pair(color))
|
self.win.attron(curses.color_pair(color))
|
||||||
self.win.addstr(word)
|
self.addstr(word)
|
||||||
self.win.attroff(curses.color_pair(color))
|
self.win.attroff(curses.color_pair(color))
|
||||||
try:
|
try:
|
||||||
self.win.addstr(' ')
|
self.addstr(' ')
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -341,44 +357,44 @@ class TextWin(Win):
|
||||||
"""
|
"""
|
||||||
if color:
|
if color:
|
||||||
self.win.attron(curses.color_pair(color))
|
self.win.attron(curses.color_pair(color))
|
||||||
self.win.addstr(nickname)
|
self.addstr(nickname)
|
||||||
if color:
|
if color:
|
||||||
self.win.attroff(curses.color_pair(color))
|
self.win.attroff(curses.color_pair(color))
|
||||||
self.win.addnstr("> ", 2)
|
self.addnstr("> ", 2)
|
||||||
|
|
||||||
def write_time(self, time):
|
def write_time(self, time):
|
||||||
"""
|
"""
|
||||||
Write the date on the yth line of the window
|
Write the date on the yth line of the window
|
||||||
"""
|
"""
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
||||||
self.win.addnstr('[', 1)
|
self.addnstr('[', 1)
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
||||||
|
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
||||||
self.win.addnstr(time.strftime("%H"), 2)
|
self.addnstr(time.strftime("%H"), 2)
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
||||||
|
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
||||||
self.win.addnstr(':', 1)
|
self.addnstr(':', 1)
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
||||||
|
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
||||||
self.win.addnstr(time.strftime("%M"), 2)
|
self.addnstr(time.strftime("%M"), 2)
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
||||||
|
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
||||||
self.win.addnstr(':', 1)
|
self.addnstr(':', 1)
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_SEPARATOR))
|
||||||
|
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
||||||
self.win.addnstr(time.strftime('%S'), 2)
|
self.addnstr(time.strftime('%S'), 2)
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_NUMBERS))
|
||||||
|
|
||||||
self.win.attron(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
self.win.attron(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
||||||
self.win.addstr(']')
|
self.addstr(']')
|
||||||
self.win.attroff(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
self.win.attroff(curses.color_pair(theme.COLOR_TIME_BRACKETS))
|
||||||
|
|
||||||
self.win.addstr(' ')
|
self.addstr(' ')
|
||||||
|
|
||||||
def resize(self, height, width, y, x, stdscr, visible):
|
def resize(self, height, width, y, x, stdscr, visible):
|
||||||
self.visible = visible
|
self.visible = visible
|
||||||
|
@ -411,7 +427,7 @@ class Input(Win):
|
||||||
self._resize(height, width, y, x, stdscr)
|
self._resize(height, width, y, x, stdscr)
|
||||||
self.win.leaveok(0)
|
self.win.leaveok(0)
|
||||||
self.win.clear()
|
self.win.clear()
|
||||||
self.win.addnstr(0, 0, self.text, self.width-1)
|
self.addnstr(0, 0, self.text, self.width-1)
|
||||||
|
|
||||||
def jump_word_left(self):
|
def jump_word_left(self):
|
||||||
"""
|
"""
|
||||||
|
@ -511,7 +527,6 @@ class Input(Win):
|
||||||
if not len(self.history):
|
if not len(self.history):
|
||||||
return
|
return
|
||||||
self.reset_completion()
|
self.reset_completion()
|
||||||
self.win.erase()
|
|
||||||
if self.histo_pos < len(self.history)-1:
|
if self.histo_pos < len(self.history)-1:
|
||||||
self.histo_pos += 1
|
self.histo_pos += 1
|
||||||
self.text = self.history[self.histo_pos]
|
self.text = self.history[self.histo_pos]
|
||||||
|
@ -711,10 +726,12 @@ class Input(Win):
|
||||||
"""
|
"""
|
||||||
Refresh the line onscreen, from the pos and pos_line
|
Refresh the line onscreen, from the pos and pos_line
|
||||||
"""
|
"""
|
||||||
|
g_lock.acquire()
|
||||||
self.clear_text()
|
self.clear_text()
|
||||||
self.win.addstr(self.text[self.line_pos:self.line_pos+self.width-1])
|
self.addstr(self.text[self.line_pos:self.line_pos+self.width-1])
|
||||||
self.win.move(0, self.pos)
|
self.win.move(0, self.pos)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
g_lock.release()
|
||||||
|
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
if not self.visible:
|
if not self.visible:
|
||||||
|
|
Loading…
Reference in a new issue