From 332a5c2553db41de777473a1e1be9cd1522c9496 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 31 Mar 2016 18:54:41 +0100 Subject: Move the src directory to poezio, for better cython compatibility. --- poezio/size_manager.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 poezio/size_manager.py (limited to 'poezio/size_manager.py') diff --git a/poezio/size_manager.py b/poezio/size_manager.py new file mode 100644 index 00000000..1cad83fd --- /dev/null +++ b/poezio/size_manager.py @@ -0,0 +1,46 @@ +""" +Size Manager: + used to check size boundaries of the whole window and + specific tabs +""" +THRESHOLD_WIDTH_DEGRADE = 45 +THRESHOLD_HEIGHT_DEGRADE = 10 + +FULL_WIDTH_DEGRADE = 66 +FULL_HEIGHT_DEGRADE = 10 + +class SizeManager(object): + + def __init__(self, core, win_cls): + self._win_class = win_cls + self._core = core + + @property + def tab_scr(self): + return self._win_class._tab_win + + @property + def core_scr(self): + return self._core.stdscr + + @property + def tab_degrade_x(self): + _, x = self.tab_scr.getmaxyx() + return x < THRESHOLD_WIDTH_DEGRADE + + @property + def tab_degrade_y(self): + y, x = self.tab_scr.getmaxyx() + return y < THRESHOLD_HEIGHT_DEGRADE + + @property + def core_degrade_x(self): + y, x = self.core_scr.getmaxyx() + return x < FULL_WIDTH_DEGRADE + + @property + def core_degrade_y(self): + y, x = self.core_scr.getmaxyx() + return y < FULL_HEIGHT_DEGRADE + + -- cgit v1.2.3