From 5aa9a73f16dea4031612772589f64b86532fc6c0 Mon Sep 17 00:00:00 2001 From: Paul Nameless Date: Mon, 18 Feb 2019 19:10:51 +0100 Subject: [PATCH] Add status view --- controller.py | 1 + view.py | 52 ++++++++++++++++++++++++++++++--------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/controller.py b/controller.py index 33a80ab..c0a44af 100644 --- a/controller.py +++ b/controller.py @@ -116,6 +116,7 @@ class Controller: self.model.get_chats() ) self.refresh_msgs() + self.view.draw_status() def refresh_msgs(self): msgs = self.model.get_current_msgs() diff --git a/view.py b/view.py index 3f2e5e5..ab448fe 100644 --- a/view.py +++ b/view.py @@ -22,11 +22,15 @@ class View: self.stdscr = stdscr self.chats = ChatView(stdscr) self.msgs = MsgView(stdscr) + self.status = StatusView(stdscr) self.max_read = 2048 def draw_chats(self, current, chats): self.chats.draw(current, chats) + def draw_status(self, msg=None): + self.status.draw(msg) + def draw_msgs(self, current, msgs): self.msgs.draw(current, msgs) @@ -60,13 +64,13 @@ class View: logger.info('Trying to chr: %s', chr(key)) # except ValueError: # logger.exception() - if key == 10: + if key == 10: # return logger.info('Sending msg: %s', buff) break - elif key == 127: + elif key == 127: # del if buff: buff = buff[:-1] - elif key == 7: + elif key == 7: # ^G cancel logger.info('Not Sending msg: %s', buff) buff = None break @@ -88,28 +92,21 @@ class View: class StatusView: def __init__(self, stdscr): - # self.stdscr = stdscr - pass + self.h = 1 + self.w = curses.COLS + self.y = curses.LINES - 1 + self.x = 0 + self.win = stdscr.subwin(self.h, self.w, self.y, self.x) def resize(self): - pass + self.w = curses.COLS + self.y = curses.LINES - 1 + self.win.resize(self.h, self.w) + self.win.wmove(self.y, self.x) def draw(self, msg): - # draw msg on the last line - pass - - -emoji_pattern = re.compile( - "[" - "\U0001F600-\U0001F64F" # emoticons - "\U0001F300-\U0001F5FF" # symbols & pictographs - "\U0001F680-\U0001F6FF" # transport & map symbols - "\U0001F1E0-\U0001F1FF" # flags (iOS) - "\U00002702-\U000027B0" - "\U000024C2-\U0001F251" - "]+", - flags=re.UNICODE -) + msg = ' ' * (self.w - 1) + self.win.addstr(0, 0, msg, curses.A_REVERSE) class ChatView: @@ -235,3 +232,16 @@ def parse_content(content): else: logger.debug('Unknown content: %s', content) return f'[unknown type {_type}]' + + +emoji_pattern = re.compile( + "[" + "\U0001F600-\U0001F64F" # emoticons + "\U0001F300-\U0001F5FF" # symbols & pictographs + "\U0001F680-\U0001F6FF" # transport & map symbols + "\U0001F1E0-\U0001F1FF" # flags (iOS) + "\U00002702-\U000027B0" + "\U000024C2-\U0001F251" + "]+", + flags=re.UNICODE +)