Commit 409b1513 authored by Link Mauve's avatar Link Mauve

Move Win._tab_win into poezio.windows.TAB_WIN.

parent 4ffe32ac
...@@ -3,6 +3,9 @@ Size Manager: ...@@ -3,6 +3,9 @@ Size Manager:
used to check size boundaries of the whole window and used to check size boundaries of the whole window and
specific tabs specific tabs
""" """
from poezio import windows
THRESHOLD_WIDTH_DEGRADE = 45 THRESHOLD_WIDTH_DEGRADE = 45
THRESHOLD_HEIGHT_DEGRADE = 10 THRESHOLD_HEIGHT_DEGRADE = 10
...@@ -17,12 +20,12 @@ class SizeManager(object): ...@@ -17,12 +20,12 @@ class SizeManager(object):
@property @property
def tab_degrade_x(self): def tab_degrade_x(self):
_, x = self._win_class._tab_win.getmaxyx() _, x = windows.TAB_WIN.getmaxyx()
return x < THRESHOLD_WIDTH_DEGRADE return x < THRESHOLD_WIDTH_DEGRADE
@property @property
def tab_degrade_y(self): def tab_degrade_y(self):
y, x = self._win_class._tab_win.getmaxyx() y, x = windows.TAB_WIN.getmaxyx()
return y < THRESHOLD_HEIGHT_DEGRADE return y < THRESHOLD_HEIGHT_DEGRADE
@property @property
......
...@@ -166,7 +166,7 @@ class Tab(object): ...@@ -166,7 +166,7 @@ class Tab(object):
@staticmethod @staticmethod
def resize(scr): def resize(scr):
Tab.height, Tab.width = scr.getmaxyx() Tab.height, Tab.width = scr.getmaxyx()
windows.Win._tab_win = scr windows.TAB_WIN = scr
def missing_command_callback(self, command_name): def missing_command_callback(self, command_name):
""" """
......
...@@ -3,6 +3,8 @@ Module exporting all the Windows, which are wrappers around curses wins ...@@ -3,6 +3,8 @@ Module exporting all the Windows, which are wrappers around curses wins
used to display information on the screen used to display information on the screen
""" """
TAB_WIN = None
from poezio.windows.base_wins import Win from poezio.windows.base_wins import Win
from poezio.windows.data_forms import FormWin from poezio.windows.data_forms import FormWin
from poezio.windows.bookmark_forms import BookmarksWin from poezio.windows.bookmark_forms import BookmarksWin
......
...@@ -13,6 +13,7 @@ log = logging.getLogger(__name__) ...@@ -13,6 +13,7 @@ log = logging.getLogger(__name__)
import curses import curses
import string import string
from poezio import windows
from poezio.theming import to_curses_attr, read_tuple from poezio.theming import to_curses_attr, read_tuple
FORMAT_CHAR = '\x19' FORMAT_CHAR = '\x19'
...@@ -30,8 +31,8 @@ class DummyWin(object): ...@@ -30,8 +31,8 @@ class DummyWin(object):
def __bool__(self): def __bool__(self):
return False return False
class Win(object): class Win(object):
_tab_win = None
def __init__(self): def __init__(self):
self._win = None self._win = None
self.height, self.width = 0, 0 self.height, self.width = 0, 0
...@@ -42,7 +43,7 @@ class Win(object): ...@@ -42,7 +43,7 @@ class Win(object):
return return
self.height, self.width, self.x, self.y = height, width, x, y self.height, self.width, self.x, self.y = height, width, x, y
try: try:
self._win = Win._tab_win.derwin(height, width, y, x) self._win = windows.TAB_WIN.derwin(height, width, y, x)
except: except:
log.debug('DEBUG: mvwin returned ERR. Please investigate') log.debug('DEBUG: mvwin returned ERR. Please investigate')
if self._win is None: if self._win is None:
......
...@@ -3,6 +3,7 @@ Windows used inthe bookmarkstab ...@@ -3,6 +3,7 @@ Windows used inthe bookmarkstab
""" """
import curses import curses
from poezio import windows
from poezio.windows.base_wins import Win from poezio.windows.base_wins import Win
from poezio.windows.inputs import Input from poezio.windows.inputs import Input
from poezio.windows.data_forms import FieldInput from poezio.windows.data_forms import FieldInput
...@@ -130,7 +131,7 @@ class BookmarkAutojoinWin(FieldInput, Win): ...@@ -130,7 +131,7 @@ class BookmarkAutojoinWin(FieldInput, Win):
class BookmarksWin(Win): class BookmarksWin(Win):
def __init__(self, bookmarks, height, width, y, x): 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.scroll_pos = 0
self._current_input = 0 self._current_input = 0
self.current_horizontal_input = 0 self.current_horizontal_input = 0
...@@ -181,7 +182,7 @@ class BookmarksWin(Win): ...@@ -181,7 +182,7 @@ class BookmarksWin(Win):
def resize(self, height, width, y, x): def resize(self, height, width, y, x):
self.height = height self.height = height
self.width = width 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 # Adjust the scroll position, if resizing made the window too small
# for the cursor to be visible # for the cursor to be visible
while self.current_input - self.scroll_pos > self.height-1: while self.current_input - self.scroll_pos > self.height-1:
......
...@@ -6,6 +6,7 @@ does not inherit from the Win base class), as it will create the ...@@ -6,6 +6,7 @@ does not inherit from the Win base class), as it will create the
others when needed. others when needed.
""" """
from poezio import windows
from poezio.windows.base_wins import Win from poezio.windows.base_wins import Win
from poezio.windows.inputs import Input from poezio.windows.inputs import Input
...@@ -341,7 +342,7 @@ class FormWin(object): ...@@ -341,7 +342,7 @@ class FormWin(object):
} }
def __init__(self, form, height, width, y, x): def __init__(self, form, height, width, y, x):
self._form = form 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.scroll_pos = 0
self.current_input = 0 self.current_input = 0
self.inputs = [] # dict list self.inputs = [] # dict list
...@@ -364,7 +365,7 @@ class FormWin(object): ...@@ -364,7 +365,7 @@ class FormWin(object):
def resize(self, height, width, y, x): def resize(self, height, width, y, x):
self.height = height self.height = height
self.width = width 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 # Adjust the scroll position, if resizing made the window too small
# for the cursor to be visible # for the cursor to be visible
while self.current_input - self.scroll_pos > self.height-1: while self.current_input - self.scroll_pos > self.height-1:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment