Exemple #1
0
def makeSelection(scr):
    """
    ALlow the user to select an option
    Returns the line number of the users selection starting at 0
    """
    inchar = 0
    selection = 0
    selection_count = len(SELECTIONS)
    selection_start_y = scr.getyx()[0]
    width = scr.getmaxyx()[1]

    while inchar != NEWLINE:
        # move to start of selections and hightlight current selection
        scr.move(selection_start_y, 0)
        line = 0
        for sel in SELECTIONS:
            whole_line = '> ' + SELECTIONS[line]
            space = width - len(whole_line) % width
            whole_line += ' ' * space

            if line == selection:
                scr.addstr(whole_line, curses.A_REVERSE)
            else:
                scr.addstr(whole_line)
            line += 1
            scr.refresh()

        inchar = scr.getch()

        # move up and down
        if inchar == curses.KEY_UP and selection > 0:
            selection -= 1
        elif inchar == curses.KEY_DOWN and selection < selection_count - 1:
            selection += 1
    if selection == 0:
        curses.use_default_colors()
        size = scr.getmaxyx()
        width = size[1]
        height = size[0]
        # set screen to initial position
        scr.erase()
        curses.curs_set(0)
        scr.move(height // 2 - 3, 0)
        centeredWrite(scr, FLAG)
        scr.refresh()
        curses.napms(10000)

        exit(0)

    return selection
Exemple #2
0
def runLocked(scr):
    """
    Start the locked out portion of the terminal
    """
    curses.use_default_colors()
    size = scr.getmaxyx()
    width = size[1]
    height = size[0]
    # set screen to initial position
    scr.erase()
    curses.curs_set(0)
    scr.move(height / 2 - 1, 0)
    centeredWrite(scr, LOCKED_1)
    scr.move(height / 2 + 1, 0)
    centeredWrite(scr, LOCKED_2)
    scr.refresh()
    curses.napms(LOCKED_OUT_TIME)
def runLocked(scr):
    """
    Start the locked out portion of the terminal
    """
    curses.use_default_colors()
    size = scr.getmaxyx()
    width = size[1]
    height = size[0]
    # set screen to initial position
    scr.erase()
    curses.curs_set(0)
    scr.move(height / 2 - 1, 0)
    centeredWrite(scr, LOCKED_1)
    scr.move(height / 2 + 1, 0)
    centeredWrite(scr, LOCKED_2)
    scr.refresh()
    curses.napms(LOCKED_OUT_TIME)
Exemple #4
0
def runSelection(scr):
    """
    Print the selections and allow the user to select one
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)
    curses.curs_set(0)
    curses.noecho()

    width = scr.getmaxyx()[1]

    for header in CENTERED_HEADERS:
        centeredWrite(scr, header + '\n')

    for header in OTHER_HEADERS:
        slowWrite(scr, header + '\n')

    for i in xrange(width):
        scr.addch(curses.ACS_BSBS)
    scr.refresh()

    return makeSelection(scr)
def runSelection(scr):
    """
    Print the selections and allow the user to select one
    """
    curses.use_default_colors()
    scr.erase()
    scr.move(0, 0)
    curses.curs_set(0)
    curses.noecho()

    width = scr.getmaxyx()[1]

    for header in CENTERED_HEADERS:
        centeredWrite(scr, header + '\n')

    for header in OTHER_HEADERS:
        slowWrite(scr, header + '\n')

    for i in xrange(width):
        scr.addch(curses.ACS_BSBS)
    scr.refresh()

    return makeSelection(scr)