Exemplo n.º 1
0
    def p_refresh_data(self):
        """get data from file_path, create a new pad and copy that

        pad over existing pad

        """
        self.pad = defs.create_pad(self.pad, self.file_path, self.win_width)
Exemplo n.º 2
0
def main(stdscr):
    curses.noecho()
    curses.cbreak()
    curses.curs_set(0)
    #stdscr.chgat(curses.A_REVERSE)
    if curses.has_colors():
        curses.start_color()
    LINES, COLS = stdscr.getmaxyx()
    path_list = []
    defs.get_paths(conf_path, path_list)
    file_count = len(path_list)

    # create a list of WinCl objects
    pad = 0
    win = 0
    win_list = []
    win_height = int(LINES / file_count)
    running_height = 0
    i = 0
    while (i < file_count):
        pad = defs.create_pad(pad, path_list[i], COLS)
        
        if (i == 0):
            win = curses.newwin(win_height, COLS, 0, 0)
        if (i > 0):
            running_height += win_height
            y, x = win_list[i - 1].win.getbegyx()
            h, w = win_list[i - 1].win.getmaxyx()

            # if it's the last item it's height is the rest of the screen
            if (i + 1 == file_count):
                win_height = LINES - running_height - 1

            win = curses.newwin(win_height, COLS, (y + h), x)

        win_list.append(wincl.WinCl(win, pad, path_list[i]))
        i += 1

    stdscr.addstr((LINES - 1), 0, " Status bar: ", curses.A_REVERSE)
    stdscr.noutrefresh()
    i = 0
    while (i < file_count):
        win_list[i].w_refresh()
        win_list[i].p_reset()
        i += 1
    curses.doupdate()

    win_count = len(win_list)
    i = 0
    c = 0
    delta_y = 0
    while True:
        c = win_list[i].pad.getch()
        
        if ((c == ord('n'))):
            if ((i + 1) == win_count):
                i = 0
            else:
                i += 1
            k = 0
            for item in win_list:
                if k == i:
                    win_list[k].active()
                    win_list[k].w_refresh()
                else:
                    win_list[k].inactive()
                    win_list[k].w_refresh()
                k = k + 1

        elif ((c == AR_UP or c == UP)):
            win_list[i].p_scroll_line_up()
        elif ((c == AR_DWN or c == DWN)):
            win_list[i].p_scroll_line_down()
        elif (c == ord('q') or c == ('Q')):
            break
        elif (c == ord('r') or c == ('R')):
            win_list[i].p_refresh_data()
            win_list[i].p_reset()

        # refresh the windows from the bottom up (no flicker)
        stdscr.noutrefresh()
        win_list[i].w_refresh()
        curses.doupdate()