Ejemplo n.º 1
0
    def refresh(self):
        """refresh(self) -> None
        Refreshing of windows.
        """
        if self._title_text != None:
            self.title = self._title_text
            self._title.refresh()
        if self._main != None:
            (maxy,maxx) = get_stdscr().getmaxyx()

            #if we have the title, then we need to cut the upper line
            if self._title == None:
                y = 0
            else:
                y = 1
            #if we have bottom bar, then we need to cut the bottom lines
            if self._bar_info:
                bottom = maxy - self._bar_info['lines'] - 1
            else:
                bottom = maxy-1
            self._main.refresh( self._up, 0, y, 0, bottom, maxx-1 )
        if self._bar_info:
            self._bar.clear()

            (maxy,maxx) = get_stdscr().getmaxyx()
            lines = self._bar_info['lines']
            self._bar.mvwin( maxy - lines , 0 )

            flags = curses.color_pair(Colors.title )
            self._bar.bkgd( ' ', flags )
            loop = -1
            for line in self._bar_info['text']:
                loop += 1
                self._bar.addstr( loop, 0, line )
            self._bar.refresh()
Ejemplo n.º 2
0
 def fill(self):
     """fill(self) -> None
     Fill the bottom window with data.
     """
     (w_maxy, w_maxx) = self.getmaxyx()
     (s_maxy, s_maxx) = get_stdscr().getmaxyx()
     if w_maxy >= s_maxy:
         maxy = w_maxy
     else:
         maxy = s_maxy
     maxx = s_maxx
     self._main = curses.newpad(maxy, maxx)
     loop = -1
     for obj in self._list:
         loop += 1
         if loop == self._number:
             flags = curses.color_pair(Colors.hover)
         else:
             flags = curses.color_pair(Colors.normal)
         self._main.addstr(loop, 0, self.text(obj), flags)
     loop += 1
     if loop == self._number:
         flags = curses.color_pair(Colors.hover)
     else:
         flags = curses.color_pair(Colors.normal)
     self._main.addstr(loop, 0, self._exit_txt, flags)
Ejemplo n.º 3
0
 def bar_init():
     self._bar_info = bar
     if self._bar_info == None:
         return
     (maxy,maxx) = get_stdscr().getmaxyx()
     lines = self._bar_info['lines']
     self._bar = curses.newwin( lines, maxx, maxy - lines , 0 )
Ejemplo n.º 4
0
 def fill(self):
     """fill(self) -> None
     Fill the bottom window with data.
     """
     (w_maxy, w_maxx) = self.getmaxyx()
     (s_maxy, s_maxx) = get_stdscr().getmaxyx()
     if w_maxy >= s_maxy:
         maxy = w_maxy
     else:
         maxy = s_maxy
     maxx = s_maxx
     self._main = curses.newpad(maxy, maxx)
     loop = -1
     for obj in self._list:
         loop += 1
         if loop == self._number:
             flags = curses.color_pair(Colors.hover)
         else:
             flags = curses.color_pair(Colors.normal)
         self._main.addstr(loop, 0, self.text(obj), flags)
     loop += 1
     if loop == self._number:
         flags = curses.color_pair(Colors.hover)
     else:
         flags = curses.color_pair(Colors.normal)
     self._main.addstr(loop, 0, self._exit_txt, flags)
Ejemplo n.º 5
0
 def getmaxyx(self):
     """getmaxyx(self) -> (int, int)
     Returns the maximum height and width at the current menu object list
     state.
     """
     (maxy, maxx) = get_stdscr().getmaxyx()
     maxy = len(self._list) + 1
     return (maxy, maxx)
Ejemplo n.º 6
0
 def getmaxyx(self):
     """getmaxyx(self) -> (int, int)
     Returns the maximum height and width at the current menu object list
     state.
     """
     (maxy, maxx) = get_stdscr().getmaxyx()
     maxy = len(self._list) + 1
     return (maxy, maxx)
Ejemplo n.º 7
0
 def _get_main_size(self):
     """_get_main_size(self) -> (int, int)
     Height and width of the main window.
     """
     (maxy, maxx) = get_stdscr().getmaxyx()
     if self._title != None:
         maxy -= 1
     if self._bar_info:
         maxy -= self._bar_info['lines']
     return (maxy, maxx)
Ejemplo n.º 8
0
 def _get_main_size(self):
     """_get_main_size(self) -> (int, int)
     Height and width of the bottom window.
     """
     (maxy, maxx) = get_stdscr().getmaxyx()
     if self._title != None:
         maxy -= 1
     if self._bar_info:
         maxy -= self._bar_info["lines"]
     return (maxy, maxx)
Ejemplo n.º 9
0
 def _set_title(self, title):
     (maxy,maxx) = get_stdscr().getmaxyx()
     if title == None:
         self._title = None
     else:
         if self._title != None:
             self._title.clear()
         self._title = curses.newwin( 1, maxx, 0, 0 )
         title = encode_string(title.strip())
         center = ( maxx / 2 ) - ( len(title) / 2 )
         flags = curses.color_pair(Colors.title )
         self._title.bkgd( ' ', flags )
         self._title.addstr( 0, center, title )
Ejemplo n.º 10
0
    def clear(self):
        """clear(self) -> None
        Clearing of windows.
        """
        if self._title != None:
            self._title.clear()
            self._title.refresh()
        if self._main != None:
            self._main.clear()

            (maxy,maxx) = get_stdscr().getmaxyx()
            if self._title == None:
                y = 0
            else:
                y = 1
            self._main.refresh( self._up, 0, y, 0, maxy-1, maxx-1 )