summaryrefslogtreecommitdiff
path: root/poezio/windows
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2018-08-17 02:16:03 +0200
committermathieui <mathieui@mathieui.net>2018-08-17 02:16:03 +0200
commitb4d3b93da2e23cefb85dd98f1f7f9706aa0402d4 (patch)
treef8c489bbf65a9a4a24d268281d3da798bbfe3ba2 /poezio/windows
parent6ccf7ea71d5e5194dd036a90e36c0db6a0ec757a (diff)
downloadpoezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.tar.gz
poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.tar.bz2
poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.tar.xz
poezio-b4d3b93da2e23cefb85dd98f1f7f9706aa0402d4.zip
Add typing information and reformat stuff
Diffstat (limited to 'poezio/windows')
-rw-r--r--poezio/windows/base_wins.py10
-rw-r--r--poezio/windows/funcs.py17
-rw-r--r--poezio/windows/info_bar.py9
3 files changed, 21 insertions, 15 deletions
diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py
index eaedd82b..89c4b73c 100644
--- a/poezio/windows/base_wins.py
+++ b/poezio/windows/base_wins.py
@@ -15,6 +15,8 @@ log = logging.getLogger(__name__)
import curses
import string
+from typing import Optional, Tuple
+
from poezio.theming import to_curses_attr, read_tuple
FORMAT_CHAR = '\x19'
@@ -51,7 +53,7 @@ class Win:
if self._win is None:
self._win = DummyWin()
- def resize(self, height, width, y, x):
+ def resize(self, height: int, width: int, y: int, x: int):
"""
Override if something has to be done on resize
"""
@@ -81,13 +83,13 @@ class Win:
except:
pass
- def move(self, y, x):
+ def move(self, y: int, x: int):
try:
self._win.move(y, x)
except:
pass
- def addstr_colored(self, text, y=None, x=None):
+ def addstr_colored(self, text: str, y=None, x=None):
"""
Write a string on the window, setting the
attributes as they are in the string.
@@ -146,7 +148,7 @@ class Win:
next_attr_char = text.find(FORMAT_CHAR)
self.addstr(text)
- def finish_line(self, color=None):
+ def finish_line(self, color: Optional[Tuple] = None):
"""
Write colored spaces until the end of line
"""
diff --git a/poezio/windows/funcs.py b/poezio/windows/funcs.py
index 3648bac3..d118f353 100644
--- a/poezio/windows/funcs.py
+++ b/poezio/windows/funcs.py
@@ -3,16 +3,17 @@ Standalone functions used by the modules
"""
import string
-DIGITS = string.digits + '-'
-
+from typing import Optional, List
from poezio.windows.base_wins import FORMAT_CHAR, format_chars
+DIGITS = string.digits + '-'
+
-def find_first_format_char(text, chars=None):
- if chars is None:
- chars = format_chars
+def find_first_format_char(text: str,
+ chars: Optional[List[str]] = None) -> int:
+ to_find = chars or format_chars
pos = -1
- for char in chars:
+ for char in to_find:
p = text.find(char)
if p == -1:
continue
@@ -21,7 +22,7 @@ def find_first_format_char(text, chars=None):
return pos
-def truncate_nick(nick, size=10):
+def truncate_nick(nick: str, size=10) -> str:
if size < 1:
size = 1
if nick and len(nick) > size:
@@ -29,7 +30,7 @@ def truncate_nick(nick, size=10):
return nick
-def parse_attrs(text, previous=None):
+def parse_attrs(text: str, previous: Optional[List[str]] = None) -> List[str]:
next_attr_char = text.find(FORMAT_CHAR)
if previous:
attrs = previous
diff --git a/poezio/windows/info_bar.py b/poezio/windows/info_bar.py
index 6e338a78..f4ba1f1f 100644
--- a/poezio/windows/info_bar.py
+++ b/poezio/windows/info_bar.py
@@ -32,7 +32,8 @@ class GlobalInfoBar(Win):
show_inactive = config.get('show_inactive_tabs')
for nb, tab in enumerate(self.core.tabs):
- if not tab: continue
+ if not tab:
+ continue
color = tab.color
if not show_inactive and color is get_theme().COLOR_TAB_NORMAL:
continue
@@ -72,8 +73,10 @@ class VerticalGlobalInfoBar(Win):
self._win.erase()
sorted_tabs = [tab for tab in self.core.tabs if tab]
if not config.get('show_inactive_tabs'):
- sorted_tabs = [tab for tab in sorted_tabs if\
- tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL]
+ sorted_tabs = [
+ tab for tab in sorted_tabs
+ if tab.vertical_color != get_theme().COLOR_VERTICAL_TAB_NORMAL
+ ]
nb_tabs = len(sorted_tabs)
use_nicks = config.get('use_tab_nicks')
if nb_tabs >= height: