(self, highlight, misc, *add)
A universal method to generate a menu.

        misc is a tupel of triples (y, x, 'text')

        add are more tuples but the content should not be accessable
A universal method to generate a menu.
A universal method to generate a menu .
def gen_menu(self, highlight, misc, *add):
        '''A universal method to generate a menu.

        misc is a tupel of triples (y, x, 'text')

        add are more tuples but the content should not be accessable

        '''

        if len(misc) == 0:
            return False
        h_color = 6
        n_color = 1
        e = ''
        while e != NL:
            try:
                self.stdscr.clear()
                self.stdscr.addstr(
                    0, 0, self.loginname + '@' + self.hostname + ':',
                    cur.color_pair(2))
                self.stdscr.addstr(0,
                                   len(self.loginname +
                                       '@' + self.hostname + ':'),
                                   self.cur_dir)
                for i, j, k in misc:
                    if i == highlight:
                        self.stdscr.addstr(i, j, k, cur.color_pair(h_color))
                    else:
                        self.stdscr.addstr(i, j, k, cur.color_pair(n_color))
                for i, j, k in add:
                    self.stdscr.addstr(i, j, k)
            except:
                pass
            finally:
                self.stdscr.refresh()
            try:
                e = self.stdscr.getch()
            except KeyboardInterrupt:
                e = 4
            if e == 4:
                return -1
            elif e == cur.KEY_RESIZE:
                self.resize_all()
            elif e == cur.KEY_F5:
                return False
            elif e == NL:
                return highlight
            elif (e == cur.KEY_DOWN or e == ord('j')) and highlight < len(misc):
                highlight += 1
            elif (e == cur.KEY_UP or e == ord('k')) and highlight > 1:
                highlight -= 1
            elif 49 <= e <= 48 + len(misc):  # ASCII(49) = 1 ...
                return e - 48
def gen_menu ( self , highlight , misc , * add ) : if len ( misc ) == 0 : return False h_color = 6 n_color = 1 e = '' while e != NL : try : self . stdscr . clear ( ) self . stdscr . addstr ( 0 , 0 , self . loginname + '@' + self . hostname + ':' , cur . color_pair ( 2 ) ) self . stdscr . addstr ( 0 , len ( self . loginname + '@' + self . hostname + ':' ) , self . cur_dir ) for i , j , k in misc : if i == highlight : self . stdscr . addstr ( i , j , k , cur . color_pair ( h_color ) ) else : self . stdscr . addstr ( i , j , k , cur . color_pair ( n_color ) ) for i , j , k in add : self . stdscr . addstr ( i , j , k ) except : pass finally : self . stdscr . refresh ( ) try : e = self . stdscr . getch ( ) except KeyboardInterrupt : e = 4 if e == 4 : return - 1 elif e == cur . KEY_RESIZE : self . resize_all ( ) elif e == cur . KEY_F5 : return False elif e == NL : return highlight elif ( e == cur . KEY_DOWN or e == ord ( 'j' ) ) and highlight < len ( misc ) : highlight += 1 elif ( e == cur . KEY_UP or e == ord ( 'k' ) ) and highlight > 1 : highlight -= 1 elif 49 <= e <= 48 + len ( misc ) : # ASCII(49) = 1 ... return e - 48