summaryrefslogtreecommitdiff
path: root/poezio/windows
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-03-14 22:31:22 +0100
committermathieui <mathieui@mathieui.net>2021-04-02 17:44:36 +0200
commit4b198be9771594a28824cc082e737fe15ab681ec (patch)
tree01de648647136734d176ba0fa33e96a61bbafc88 /poezio/windows
parentbc4f4f1e0766aedb6b0e9f3df90fee9ea841786c (diff)
downloadpoezio-4b198be9771594a28824cc082e737fe15ab681ec.tar.gz
poezio-4b198be9771594a28824cc082e737fe15ab681ec.tar.bz2
poezio-4b198be9771594a28824cc082e737fe15ab681ec.tar.xz
poezio-4b198be9771594a28824cc082e737fe15ab681ec.zip
fix: tons of type errors
Diffstat (limited to 'poezio/windows')
-rw-r--r--poezio/windows/bookmark_forms.py7
-rw-r--r--poezio/windows/info_bar.py11
-rw-r--r--poezio/windows/text_win.py38
3 files changed, 30 insertions, 26 deletions
diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py
index f1e737fd..10851b3b 100644
--- a/poezio/windows/bookmark_forms.py
+++ b/poezio/windows/bookmark_forms.py
@@ -384,5 +384,8 @@ class BookmarksWin(Win):
def save(self) -> None:
for line in self.lines:
- for item in line:
- item.save()
+ line[0].save()
+ line[1].save()
+ line[2].save()
+ line[3].save()
+ line[4].save()
diff --git a/poezio/windows/info_bar.py b/poezio/windows/info_bar.py
index 8c2dd1a1..8fb34d91 100644
--- a/poezio/windows/info_bar.py
+++ b/poezio/windows/info_bar.py
@@ -5,17 +5,18 @@ This window is the one listing the current opened tabs in poezio.
The GlobalInfoBar can be either horizontal or vertical
(VerticalGlobalInfoBar).
"""
-import logging
+import curses
import itertools
-log = logging.getLogger(__name__)
+import logging
-import curses
+from typing import List, Optional
from poezio.config import config
from poezio.windows.base_wins import Win
from poezio.theming import get_theme, to_curses_attr
from poezio.common import unique_prefix_of
+log = logging.getLogger(__name__)
class GlobalInfoBar(Win):
__slots__ = ('core')
@@ -31,14 +32,14 @@ class GlobalInfoBar(Win):
self.addstr(0, 0, "[",
to_curses_attr(theme.COLOR_INFORMATION_BAR))
- show_names = config.getboom('show_tab_names')
+ show_names = config.getbool('show_tab_names')
show_nums = config.getbool('show_tab_numbers')
use_nicks = config.getbool('use_tab_nicks')
show_inactive = config.getbool('show_inactive_tabs')
unique_prefix_tab_names = config.getbool('unique_prefix_tab_names')
if unique_prefix_tab_names:
- unique_prefixes = [None] * len(self.core.tabs)
+ unique_prefixes: List[Optional[str]] = [None] * len(self.core.tabs)
sorted_tab_indices = sorted(
(str(tab.name), i)
for i, tab in enumerate(self.core.tabs)
diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py
index 2ddf7082..31dfb637 100644
--- a/poezio/windows/text_win.py
+++ b/poezio/windows/text_win.py
@@ -4,17 +4,13 @@ Can be locked, scrolled, has a separator, etc…
"""
import logging
-import curses
-from math import ceil, log10
from typing import Optional, List, Union
-from poezio.windows.base_wins import Win, FORMAT_CHAR
-from poezio.ui.funcs import truncate_nick, parse_attrs
+from poezio.windows.base_wins import Win
from poezio.text_buffer import TextBuffer
-from poezio import poopt
from poezio.config import config
-from poezio.theming import to_curses_attr, get_theme, dump_tuple
+from poezio.theming import to_curses_attr, get_theme
from poezio.ui.types import Message, BaseMessage
from poezio.ui.render import Line, build_lines, write_pre
@@ -26,6 +22,8 @@ class TextWin(Win):
'separator_after', 'highlights', 'hl_pos',
'nb_of_highlights_after_separator')
+ hl_pos: Optional[int]
+
def __init__(self, lines_nb_limit: Optional[int] = None) -> None:
Win.__init__(self)
if lines_nb_limit is None:
@@ -38,14 +36,14 @@ class TextWin(Win):
self.lock = False
self.lock_buffer: List[Union[None, Line]] = []
- self.separator_after: Optional[Line] = None
+ self.separator_after: Optional[BaseMessage] = None
# the Lines of the highlights in that buffer
self.highlights: List[Line] = []
# the current HL position in that list NaN means that we’re not on
# an hl. -1 is a valid position (it's before the first hl of the
# list. i.e the separator, in the case where there’s no hl before
# it.)
- self.hl_pos = float('nan')
+ self.hl_pos = None
# Keep track of the number of hl after the separator.
# This is useful to make “go to next highlight“ work after a “move to separator”.
@@ -149,6 +147,7 @@ class TextWin(Win):
self.addstr_colored(txt, y, x)
def resize(self, height: int, width: int, y: int, x: int, room: TextBuffer=None) -> None:
+ old_width: Optional[int]
if hasattr(self, 'width'):
old_width = self.width
else:
@@ -202,7 +201,6 @@ class TextWin(Win):
if room and room.messages:
self.separator_after = room.messages[-1]
-
def write_line_separator(self, y) -> None:
theme = get_theme()
char = theme.CHAR_NEW_TEXT_SEPARATOR
@@ -222,13 +220,13 @@ class TextWin(Win):
highlights, scroll to the end of the buffer.
"""
log.debug('Going to the next highlight…')
- if (not self.highlights or self.hl_pos != self.hl_pos
+ if (not self.highlights or self.hl_pos is None
or self.hl_pos >= len(self.highlights) - 1):
- self.hl_pos = float('nan')
+ self.hl_pos = None
self.pos = 0
return
hl_size = len(self.highlights) - 1
- if self.hl_pos < hl_size:
+ if self.hl_pos is not None and self.hl_pos < hl_size:
self.hl_pos += 1
else:
self.hl_pos = hl_size
@@ -239,9 +237,10 @@ class TextWin(Win):
try:
pos = self.built_lines.index(hl)
except ValueError:
- del self.highlights[self.hl_pos]
+ if isinstance(self.hl_pos, int):
+ del self.highlights[self.hl_pos]
if not self.highlights:
- self.hl_pos = float('nan')
+ self.hl_pos = None
self.pos = 0
return
self.hl_pos = 0
@@ -258,11 +257,11 @@ class TextWin(Win):
highlights, scroll to the end of the buffer.
"""
log.debug('Going to the previous highlight…')
- if not self.highlights or self.hl_pos <= 0:
- self.hl_pos = float('nan')
+ if not self.highlights or self.hl_pos and self.hl_pos <= 0:
+ self.hl_pos = None
self.pos = 0
return
- if self.hl_pos != self.hl_pos:
+ if self.hl_pos is None:
self.hl_pos = len(self.highlights) - 1
else:
self.hl_pos -= 1
@@ -273,9 +272,10 @@ class TextWin(Win):
try:
pos = self.built_lines.index(hl)
except ValueError:
- del self.highlights[self.hl_pos]
+ if self.hl_pos is not None:
+ del self.highlights[self.hl_pos]
if not self.highlights:
- self.hl_pos = float('nan')
+ self.hl_pos = None
self.pos = 0
return
self.hl_pos = 0