summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--poezio/roster.py6
-rw-r--r--poezio/size_manager.py7
-rw-r--r--poezio/tabs/basetabs.py2
-rw-r--r--poezio/windows/__init__.py2
-rw-r--r--poezio/windows/base_wins.py5
-rw-r--r--poezio/windows/bookmark_forms.py7
-rw-r--r--poezio/windows/data_forms.py7
-rw-r--r--poezio/windows/info_bar.py2
-rw-r--r--poezio/windows/info_wins.py2
-rw-r--r--poezio/windows/input_placeholders.py2
-rw-r--r--poezio/windows/inputs.py15
-rw-r--r--poezio/windows/list.py2
-rw-r--r--poezio/windows/misc.py2
-rw-r--r--poezio/windows/muc.py2
-rw-r--r--poezio/windows/roster_win.py2
-rw-r--r--poezio/windows/text_win.py3
16 files changed, 37 insertions, 31 deletions
diff --git a/poezio/roster.py b/poezio/roster.py
index 15b3b01c..ac8012cb 100644
--- a/poezio/roster.py
+++ b/poezio/roster.py
@@ -238,16 +238,16 @@ class Roster(object):
def export(self, path):
"""Export a list of bare jids to a given file"""
if p.isfile(path):
- return
+ return False
try:
f = open(path, 'w+', encoding='utf-8')
f.writelines([str(i) + "\n" for i in self.contacts if self[i] and (self[i].subscription == "both" or self[i].ask)])
f.close()
return True
except IOError:
- return
+ return False
except OSError:
- return
+ return False
def exists(self, contact):
if not contact:
diff --git a/poezio/size_manager.py b/poezio/size_manager.py
index 1a8735ab..a573e176 100644
--- a/poezio/size_manager.py
+++ b/poezio/size_manager.py
@@ -3,6 +3,9 @@ Size Manager:
used to check size boundaries of the whole window and
specific tabs
"""
+
+from poezio import windows
+
THRESHOLD_WIDTH_DEGRADE = 45
THRESHOLD_HEIGHT_DEGRADE = 10
@@ -17,12 +20,12 @@ class SizeManager(object):
@property
def tab_degrade_x(self):
- _, x = self._win_class._tab_win.getmaxyx()
+ _, x = windows.TAB_WIN.getmaxyx()
return x < THRESHOLD_WIDTH_DEGRADE
@property
def tab_degrade_y(self):
- y, x = self._win_class._tab_win.getmaxyx()
+ y, x = windows.TAB_WIN.getmaxyx()
return y < THRESHOLD_HEIGHT_DEGRADE
@property
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index b54cd542..6f0ed7ab 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -166,7 +166,7 @@ class Tab(object):
@staticmethod
def resize(scr):
Tab.height, Tab.width = scr.getmaxyx()
- windows.Win._tab_win = scr
+ windows.TAB_WIN = scr
def missing_command_callback(self, command_name):
"""
diff --git a/poezio/windows/__init__.py b/poezio/windows/__init__.py
index 463c27e1..24754d2d 100644
--- a/poezio/windows/__init__.py
+++ b/poezio/windows/__init__.py
@@ -3,6 +3,8 @@ Module exporting all the Windows, which are wrappers around curses wins
used to display information on the screen
"""
+TAB_WIN = None
+
from poezio.windows.base_wins import Win
from poezio.windows.data_forms import FormWin
from poezio.windows.bookmark_forms import BookmarksWin
diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py
index a5629ed5..daab504b 100644
--- a/poezio/windows/base_wins.py
+++ b/poezio/windows/base_wins.py
@@ -13,6 +13,7 @@ log = logging.getLogger(__name__)
import curses
import string
+from poezio import windows
from poezio.theming import to_curses_attr, read_tuple
FORMAT_CHAR = '\x19'
@@ -30,8 +31,8 @@ class DummyWin(object):
def __bool__(self):
return False
+
class Win(object):
- _tab_win = None
def __init__(self):
self._win = None
self.height, self.width = 0, 0
@@ -42,7 +43,7 @@ class Win(object):
return
self.height, self.width, self.x, self.y = height, width, x, y
try:
- self._win = Win._tab_win.derwin(height, width, y, x)
+ self._win = windows.TAB_WIN.derwin(height, width, y, x)
except:
log.debug('DEBUG: mvwin returned ERR. Please investigate')
if self._win is None:
diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py
index 7aaee65a..4df151ee 100644
--- a/poezio/windows/bookmark_forms.py
+++ b/poezio/windows/bookmark_forms.py
@@ -3,7 +3,8 @@ Windows used inthe bookmarkstab
"""
import curses
-from poezio.windows import Win
+from poezio import windows
+from poezio.windows.base_wins import Win
from poezio.windows.inputs import Input
from poezio.windows.data_forms import FieldInput
from poezio.theming import to_curses_attr, get_theme
@@ -130,7 +131,7 @@ class BookmarkAutojoinWin(FieldInput, Win):
class BookmarksWin(Win):
def __init__(self, bookmarks, height, width, y, x):
- self._win = Win._tab_win.derwin(height, width, y, x)
+ self._win = windows.TAB_WIN.derwin(height, width, y, x)
self.scroll_pos = 0
self._current_input = 0
self.current_horizontal_input = 0
@@ -181,7 +182,7 @@ class BookmarksWin(Win):
def resize(self, height, width, y, x):
self.height = height
self.width = width
- self._win = Win._tab_win.derwin(height, width, y, x)
+ self._win = windows.TAB_WIN.derwin(height, width, y, x)
# Adjust the scroll position, if resizing made the window too small
# for the cursor to be visible
while self.current_input - self.scroll_pos > self.height-1:
diff --git a/poezio/windows/data_forms.py b/poezio/windows/data_forms.py
index 8c4e9a7c..27b7f2c5 100644
--- a/poezio/windows/data_forms.py
+++ b/poezio/windows/data_forms.py
@@ -6,7 +6,8 @@ does not inherit from the Win base class), as it will create the
others when needed.
"""
-from poezio.windows import Win
+from poezio import windows
+from poezio.windows.base_wins import Win
from poezio.windows.inputs import Input
from poezio.theming import to_curses_attr, get_theme
@@ -341,7 +342,7 @@ class FormWin(object):
}
def __init__(self, form, height, width, y, x):
self._form = form
- self._win = Win._tab_win.derwin(height, width, y, x)
+ self._win = windows.TAB_WIN.derwin(height, width, y, x)
self.scroll_pos = 0
self.current_input = 0
self.inputs = [] # dict list
@@ -364,7 +365,7 @@ class FormWin(object):
def resize(self, height, width, y, x):
self.height = height
self.width = width
- self._win = Win._tab_win.derwin(height, width, y, x)
+ self._win = windows.TAB_WIN.derwin(height, width, y, x)
# Adjust the scroll position, if resizing made the window too small
# for the cursor to be visible
while self.current_input - self.scroll_pos > self.height-1:
diff --git a/poezio/windows/info_bar.py b/poezio/windows/info_bar.py
index ed9dc385..cac56db9 100644
--- a/poezio/windows/info_bar.py
+++ b/poezio/windows/info_bar.py
@@ -12,7 +12,7 @@ import curses
from poezio.config import config
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio.theming import get_theme, to_curses_attr
class GlobalInfoBar(Win):
diff --git a/poezio/windows/info_wins.py b/poezio/windows/info_wins.py
index 938128ed..1d1b5683 100644
--- a/poezio/windows/info_wins.py
+++ b/poezio/windows/info_wins.py
@@ -9,7 +9,7 @@ log = logging.getLogger(__name__)
from poezio.common import safeJID
from poezio.config import config
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio.windows.funcs import truncate_nick
from poezio.theming import get_theme, to_curses_attr
diff --git a/poezio/windows/input_placeholders.py b/poezio/windows/input_placeholders.py
index 4617392e..dd7468a7 100644
--- a/poezio/windows/input_placeholders.py
+++ b/poezio/windows/input_placeholders.py
@@ -7,7 +7,7 @@ import logging
log = logging.getLogger(__name__)
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio.theming import get_theme, to_curses_attr
diff --git a/poezio/windows/inputs.py b/poezio/windows/inputs.py
index 51b9f4ea..d1716914 100644
--- a/poezio/windows/inputs.py
+++ b/poezio/windows/inputs.py
@@ -11,8 +11,7 @@ import string
from poezio import keyboard
from poezio import common
from poezio import poopt
-from poezio.windows import Win
-from poezio.windows.base_wins import format_chars
+from poezio.windows.base_wins import Win, format_chars
from poezio.windows.funcs import find_first_format_char
from poezio.config import config
from poezio.theming import to_curses_attr
@@ -239,7 +238,7 @@ class Input(Win):
"""
self.reset_completion()
if self.pos == 0:
- return
+ return False
self.key_left()
self.key_dc()
return True
@@ -457,7 +456,7 @@ class Input(Win):
"""
return self.text
- def addstr_colored_lite(self, text, y=None, x=None):
+ def _addstr_colored_lite(self, text, y=None, x=None):
"""
Just like addstr_colored, with the single-char attributes
(\x0E to \x19 instead of \x19 + attr). We do not use any }
@@ -491,7 +490,7 @@ class Input(Win):
"""
Refresh the line onscreen, but first, always adjust the
view_pos. Also, each FORMAT_CHAR+attr_char count only take
- one screen column (this is done in addstr_colored_lite), we
+ one screen column (this is done in _addstr_colored_lite), we
have to do some special calculations to find the correct
length of text to display, and the position of the cursor.
"""
@@ -502,7 +501,7 @@ class Input(Win):
self._win.attron(to_curses_attr(self.color))
displayed_text = text[self.view_pos:self.view_pos+self.width-1].replace('\t', '\x18')
self._win.attrset(0)
- self.addstr_colored_lite(displayed_text)
+ self._addstr_colored_lite(displayed_text)
# Fill the rest of the line with the input color
if self.color:
(_, x) = self._win.getyx()
@@ -705,8 +704,8 @@ class CommandInput(HistoryInput):
self.key_func["M-B"] = self.key_down
self.histo_pos = -1
- def do_command(self, key, refresh=True, raw=False):
- res = Input.do_command(self, key, refresh, raw)
+ def do_command(self, key, reset=True, raw=False):
+ res = Input.do_command(self, key, reset=reset, raw=raw)
if self.on_input:
self.on_input(self.get_text())
return res
diff --git a/poezio/windows/list.py b/poezio/windows/list.py
index 64d6a2bf..c0dc44cf 100644
--- a/poezio/windows/list.py
+++ b/poezio/windows/list.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
import curses
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio.theming import to_curses_attr, get_theme
diff --git a/poezio/windows/misc.py b/poezio/windows/misc.py
index 0b6bd629..634248fb 100644
--- a/poezio/windows/misc.py
+++ b/poezio/windows/misc.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
import curses
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio.theming import get_theme, to_curses_attr
class VerticalSeparator(Win):
diff --git a/poezio/windows/muc.py b/poezio/windows/muc.py
index ee57ab6e..3e78bfb3 100644
--- a/poezio/windows/muc.py
+++ b/poezio/windows/muc.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
import curses
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio import poopt
from poezio.config import config
diff --git a/poezio/windows/roster_win.py b/poezio/windows/roster_win.py
index f940963c..f8ca90a2 100644
--- a/poezio/windows/roster_win.py
+++ b/poezio/windows/roster_win.py
@@ -7,7 +7,7 @@ log = logging.getLogger(__name__)
from datetime import datetime
-from poezio.windows import Win
+from poezio.windows.base_wins import Win
from poezio import common
from poezio.config import config
diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py
index c03c08d0..4b16043d 100644
--- a/poezio/windows/text_win.py
+++ b/poezio/windows/text_win.py
@@ -9,8 +9,7 @@ log = logging.getLogger(__name__)
import curses
from math import ceil, log10
-from poezio.windows import Win
-from poezio.windows.base_wins import FORMAT_CHAR
+from poezio.windows.base_wins import Win, FORMAT_CHAR
from poezio.windows.funcs import truncate_nick, parse_attrs
from poezio import poopt