Python curses 模块,COLOR_BLUE 实例源码

我们从Python开源项目中,提取了以下24个代码示例,用于说明如何使用curses.COLOR_BLUE

项目:pyfeld    作者:scjurgen    | 项目源码 | 文件源码
def __init__(self):
        self.selected_index_stack = [0]
        self.returnString = ""
        self.play_in_room = None
        self.dir = DirBrowse()
        self.selected_index = 0
        self.selected_column = 0
        self.window = curses.initscr()
        curses.start_color()
        curses.noecho()
        curses.cbreak()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_RED)
        curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLUE)

        self.window.keypad(1)
        self.draw_ui()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def balls():
    treescrn.overlay(treescrn2)

    set_color(treescrn2, curses.COLOR_BLUE)
    treescrn2.addch(3, 9, ord('@'))
    treescrn2.addch(3, 15, ord('@'))
    treescrn2.addch(4, 8, ord('@'))
    treescrn2.addch(4, 16, ord('@'))
    treescrn2.addch(5, 7, ord('@'))
    treescrn2.addch(5, 17, ord('@'))
    treescrn2.addch(7, 6, ord('@'))
    treescrn2.addch(7, 18, ord('@'))
    treescrn2.addch(8, 5, ord('@'))
    treescrn2.addch(8, 19, ord('@'))
    treescrn2.addch(10, 4, ord('@'))
    treescrn2.addch(10, 20, ord('@'))
    treescrn2.addch(11, 2, ord('@'))
    treescrn2.addch(11, 22, ord('@'))
    treescrn2.addch(12, 1, ord('@'))
    treescrn2.addch(12, 23, ord('@'))

    unset_color(treescrn2)
    treescrn2.refresh()
    w_del_msg.refresh()
    return
项目:logviewer    作者:romuloceccon    | 项目源码 | 文件源码
def __init__(self, curses, curses_window):
        curses.start_color()

        curses.curs_set(0)
        curses_window.nodelay(1)

        curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(5, curses.COLOR_CYAN, curses.COLOR_BLACK)
        curses.init_pair(6, curses.COLOR_BLUE, curses.COLOR_BLACK)

        self._curses = curses
        self._curses_window = curses_window

        self._stack = list()
项目:flux_line_bot    作者:blesscat    | 项目源码 | 文件源码
def setup(self):
        curses.start_color()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)

        curses.cbreak()
        curses.echo()

        lines, cols = self.stdscr.getmaxyx()
        self.logwin = self.stdscr.subwin(lines - 2, cols, 0, 0)
        self.sepwin = self.stdscr.subwin(1, cols, lines - 2, 0)
        self.cmdwin = self.stdscr.subwin(1, cols, lines - 1, 0)

        self.logwin.scrollok(True)

        self.sepwin.bkgd(curses.color_pair(1))
        self.sepwin.refresh()
项目:danmu.fm    作者:twocucao    | 项目源码 | 文件源码
def __init__(self, use_colors):
        logging.Handler.__init__(self)
        self.use_colors = use_colors

        # Initialize environment
        curses.setupterm()

        # Get the foreground color attribute for this environment
        self.fcap = curses.tigetstr('setaf')

        # Get the normal attribute
        self.COLOR_NORMAL = curses.tigetstr('sgr0').decode("utf-8")

        # Get + Save the color sequences
        self.COLOR_INFO = curses.tparm(self.fcap, curses.COLOR_GREEN).decode("utf-8")
        self.COLOR_ERROR = curses.tparm(self.fcap, curses.COLOR_RED).decode("utf-8")
        self.COLOR_WARNING = curses.tparm(self.fcap, curses.COLOR_YELLOW).decode("utf-8")
        self.COLOR_DEBUG = curses.tparm(self.fcap, curses.COLOR_BLUE).decode("utf-8")
项目:botany    作者:jifunks    | 项目源码 | 文件源码
def define_colors(self):
        # set curses color pairs manually
        curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK)
        curses.init_pair(5, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
        curses.init_pair(6, curses.COLOR_YELLOW, curses.COLOR_BLACK)
        curses.init_pair(7, curses.COLOR_RED, curses.COLOR_BLACK)
        curses.init_pair(8, curses.COLOR_CYAN, curses.COLOR_BLACK)
项目:slacky    作者:mathiasbc    | 项目源码 | 文件源码
def set_color_pairs():
    # based on the colors of pyradio
    curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_BLACK)
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
    curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_GREEN)
    curses.init_pair(8, curses.COLOR_MAGENTA, curses.COLOR_BLACK)
    curses.init_pair(9, curses.COLOR_BLACK, curses.COLOR_GREEN)
项目:reinforcement_learning    作者:andreweskeclarke    | 项目源码 | 文件源码
def init_colors(self):
        curses.start_color()
        curses.use_default_colors()
        colors = [ curses.COLOR_BLUE,
                   curses.COLOR_CYAN,
                   curses.COLOR_GREEN,
                   curses.COLOR_MAGENTA,
                   curses.COLOR_RED,
                   curses.COLOR_WHITE,
                   curses.COLOR_YELLOW ]
        curses.init_pair(0, curses.COLOR_WHITE, curses.COLOR_BLACK)
        for i, c in enumerate(colors):
            curses.init_pair(i + 1, c, curses.COLOR_BLACK)
项目:paint-it    作者:plainspooky    | 项目源码 | 文件源码
def __init__(self, arena_size):
        self.arena_size = arena_size
        self.max_moves = int(25*(2*arena_size*COLORS)/(28*6))
        self.screen = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.start_color()
        try:
            curses.curs_set(False)
        except curses.error:
            pass
        self.screen.nodelay(True)
        self.window_size = self.screen.getmaxyx()

        if self.window_size[0] < self.arena_size+4 or self.window_size[1] < self.arena_size*2:
            print('Your screen is too short!')
            exit()

        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_GREEN)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_CYAN)
        curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_RED)
        curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
        curses.init_pair(6, curses.COLOR_WHITE, curses.COLOR_YELLOW)
        curses.init_pair(7, curses.COLOR_WHITE, curses.COLOR_WHITE)

        self.offset_x = int((self.window_size[1]-2*self.arena_size)/2)
        self.offset_y = int((self.window_size[0]-self.arena_size)/2)
        self.moves_position=[ self.offset_y+self.arena_size+1, self.offset_x+self.arena_size-5 ]

        self.arena_initialize()

        self.screen.addstr( self.offset_y-2, self.offset_x, self.title, curses.color_pair(0))
        self.screen.addstr( self.offset_y-2, self.offset_x+2*self.arena_size-17, "Press '?' to help", curses.color_pair(0))
项目:pyfeld    作者:scjurgen    | 项目源码 | 文件源码
def __init__(self):
        self.notification_count = 0
        self.window = curses.initscr()
        curses.start_color()
        curses.noecho()
        curses.cbreak()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_WHITE)
        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
        curses.init_pair(4, curses.COLOR_WHITE, curses.COLOR_RED)
        curses.init_pair(5, curses.COLOR_YELLOW, curses.COLOR_BLUE)

        self.window.keypad(1)
        self.draw_ui()
项目:sandsifter    作者:xoreaxeaxeax    | 项目源码 | 文件源码
def init_colors(self):

        if curses.has_colors() and curses.can_change_color():
            curses.init_color(self.COLOR_BLACK, 0, 0, 0)
            curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000)
            curses.init_color(self.COLOR_BLUE, 0, 0, 1000)
            curses.init_color(self.COLOR_RED, 1000, 0, 0)
            curses.init_color(self.COLOR_GREEN, 0, 1000, 0)

            for i in xrange(0, self.GRAYS):
                curses.init_color(
                        self.GRAY_BASE + i,
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1)
                        )
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.GRAY_BASE + i,
                        self.COLOR_BLACK
                        )

        else:
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN

            for i in xrange(0, self.GRAYS):
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.COLOR_WHITE,
                        self.COLOR_BLACK
                        )

        curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK)
        curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK)
        curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK)
        curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK)
        curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK)
项目:AsciiDots-Java    作者:LousyLynx    | 项目源码 | 文件源码
def __init__(self, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, head):
        super().__init__()

        self.ticks = ticks
        self.silent = silent
        self.debug = debug
        self.compat_debug = compat_debug
        self.debug_lines = debug_lines
        self.autostep_debug = autostep_debug
        self.head = head

        self.tick_number = 0

        self.output_count = 0

        if self.debug and not self.compat_debug:
            self.logging_loc = 0
            self.logging_x = 1

            self.stdscr = curses.initscr()

            curses.start_color()

            curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
            curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
            curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
            curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK)

            curses.noecho()

            curses.curs_set(False)

            self.win_program = curses.newwin(self.debug_lines, curses.COLS - 1, 0, 0)

            self.logging_pad = curses.newpad(1000, curses.COLS - 1)

            def signal_handler(signal, frame):
                    self.on_finish()
                    sys.exit(0)

            signal.signal(signal.SIGINT, signal_handler)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def mkpanel(color, rows, cols, tly, tlx):
    win = curses.newwin(rows, cols, tly, tlx)
    pan = panel.new_panel(win)
    if curses.has_colors():
        if color == curses.COLOR_BLUE:
            fg = curses.COLOR_WHITE
        else:
            fg = curses.COLOR_BLACK
        bg = color
        curses.init_pair(color, fg, bg)
        win.bkgdset(ord(' '), curses.color_pair(color))
    else:
        win.bkgdset(ord(' '), curses.A_BOLD)

    return pan
项目:Halite    作者:shummie    | 项目源码 | 文件源码
def setup_colors():
    """Setup the colors for each player. Entry 8 is reserved for
    zero-strength unowned squares.
    """
    curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
    curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
    curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
    curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_GREEN)
    curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_CYAN)
    curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_YELLOW)
    curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_BLACK)
项目:solent    作者:solent-eng    | 项目源码 | 文件源码
def screen_curses_init():
    #
    # number of milliseconds to wait after reading an escape character, to
    # distinguish between an individual escape character entered on the
    # keyboard from escape sequences sent by cursor and function keys (see
    # curses(3X).
    os.putenv("ESCDELAY", "0") # was 25
    #
    global STDSCR
    STDSCR = curses.initscr()
    curses.noecho()
    curses.cbreak()
    #
    if not curses.has_colors():
        raise Exception("Need colour support to run.")
    curses.raw()
    #
    curses.start_color()
    #
    # This is what allows us to use -1 for default when we initialise
    # the pairs
    curses.use_default_colors()
    #
    curses.init_pair(PROFILE_GREY       , curses.COLOR_WHITE    , -1)
    curses.init_pair(PROFILE_WHITE      , curses.COLOR_WHITE    , -1)
    curses.init_pair(PROFILE_RED        , curses.COLOR_RED      , -1)
    curses.init_pair(PROFILE_VERMILION  , curses.COLOR_RED      , -1)
    curses.init_pair(PROFILE_ORANGE     , curses.COLOR_RED      , -1)
    curses.init_pair(PROFILE_AMBER      , curses.COLOR_YELLOW   , -1)
    curses.init_pair(PROFILE_YELLOW     , curses.COLOR_YELLOW   , -1)
    curses.init_pair(PROFILE_CHARTREUSE , curses.COLOR_GREEN    , -1)
    curses.init_pair(PROFILE_GREEN      , curses.COLOR_GREEN    , -1)
    curses.init_pair(PROFILE_TEAL       , curses.COLOR_CYAN     , -1)
    curses.init_pair(PROFILE_BLUE       , curses.COLOR_BLUE     , -1)
    curses.init_pair(PROFILE_VIOLET     , curses.COLOR_MAGENTA  , -1)
    curses.init_pair(PROFILE_PURPLE     , curses.COLOR_MAGENTA  , -1)
    curses.init_pair(PROFILE_MAGENTA    , curses.COLOR_MAGENTA  , -1)
    curses.init_pair(PROFILE_BLACK_INFO , curses.COLOR_BLACK    , curses.COLOR_WHITE)
    curses.init_pair(PROFILE_ALARM,       curses.COLOR_RED      , curses.COLOR_WHITE)
项目:youtube_watcher    作者:Sjc1000    | 项目源码 | 文件源码
def start_screen(self):
        self.screen = curses.initscr()
        curses.noecho()
        curses.cbreak()
        curses.curs_set(0)
        self.screen.keypad(True)
        curses.start_color()
        curses.use_default_colors()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        curses.init_pair(2, curses.COLOR_GREEN, -1)
        curses.init_pair(3, curses.COLOR_CYAN, -1)
        curses.init_pair(4, curses.COLOR_YELLOW, -1)
        return None
项目:HaliteBot    作者:jheilema-nerdery    | 项目源码 | 文件源码
def setup_colors():
    """Setup the colors for each player. Entry 8 is reserved for
    zero-strength unowned squares.
    """
    curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
    curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_RED)
    curses.init_pair(3, curses.COLOR_BLACK, curses.COLOR_BLUE)
    curses.init_pair(4, curses.COLOR_BLACK, curses.COLOR_GREEN)
    curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_MAGENTA)
    curses.init_pair(6, curses.COLOR_BLACK, curses.COLOR_CYAN)
    curses.init_pair(7, curses.COLOR_BLACK, curses.COLOR_YELLOW)
    curses.init_pair(8, curses.COLOR_WHITE, curses.COLOR_BLACK)
项目:Utils    作者:disconsis    | 项目源码 | 文件源码
def parse_args():
    parser = argparse.ArgumentParser()
    # parser.add_argument('-a', '--abs', action='store_true')
    parser.add_argument('abs_rel', choices=['at', 'after'])
    font_choices = [font.split('.')[0]
                    for font in os.listdir('/usr/share/figlet')
                    if font.split('.')[1] == 'tlf']
    parser.add_argument('-f', '--font', default=DEFAULT_FONT,
                        choices=font_choices)
    parser.add_argument('-m', '--msg', default=None)
    # parser.add_argument('-z', '--snooze', type=float, default=2)
    parser_volume = parser.add_mutually_exclusive_group()
    parser_song = parser_volume.add_argument_group()
    parser_song.add_argument('-d', '--dir', default=DEFAULT_MUSIC_DIR)
    parser_song.add_argument('--song', default=DEFAULT_SONG)
    parser_volume.add_argument('-ns', '--silent', action='store_true')
    parser.add_argument('-fg', choices=['black', 'red', 'green', 'yellow',
                                        'blue', 'magenta', 'cyan', 'white'],
                        default='white')
    parser.add_argument('-bg', choices=['black', 'red', 'green', 'yellow',
                                        'blue', 'magenta', 'cyan', 'white'],
                        default='black')
    parser.add_argument('time', nargs='+')
    args = parser.parse_args()
    args.abs = False if args.abs_rel == 'after' else True
    if not args.silent:
        args.song = validate_song(args)
    args.time = ' '.join(args.time)
    color_mapping = {
        'black': curses.COLOR_BLACK,
        'red': curses.COLOR_RED,
        'green': curses.COLOR_GREEN,
        'yellow': curses.COLOR_YELLOW,
        'blue': curses.COLOR_BLUE,
        'magenta': curses.COLOR_MAGENTA,
        'cyan': curses.COLOR_CYAN,
        'white': curses.COLOR_WHITE,
    }
    args.fg = color_mapping[args.fg]
    args.bg = color_mapping[args.bg]
    return args
项目:connect4    作者:guglielmilo    | 项目源码 | 文件源码
def defineColors():
    curses.start_color()
    curses.use_default_colors()
    curses.init_pair(color.BLACK,    curses.COLOR_BLACK,  -1)
    curses.init_pair(color.GREY,     250,                 -1)
    curses.init_pair(color.RED,      curses.COLOR_RED,    -1)
    curses.init_pair(color.YELLOW,   143,                 -1)
    curses.init_pair(color.BLUE,     curses.COLOR_BLUE,   -1)
    # highlight text
    curses.init_pair(color.RED_H,    curses.COLOR_RED,    curses.COLOR_WHITE)
    curses.init_pair(color.YELLOW_H, curses.COLOR_YELLOW, curses.COLOR_WHITE)
项目:toot    作者:ihabunek    | 项目源码 | 文件源码
def setup_palette():
        curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK)
        curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
        curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
项目:sandsifter    作者:xoreaxeaxeax    | 项目源码 | 文件源码
def init_colors(self):
        if curses.has_colors() and curses.can_change_color():
            curses.init_color(self.COLOR_BLACK, 0, 0, 0)
            curses.init_color(self.COLOR_WHITE, 1000, 1000, 1000)
            curses.init_color(self.COLOR_BLUE, 0, 0, 1000)
            curses.init_color(self.COLOR_RED, 1000, 0, 0)
            curses.init_color(self.COLOR_GREEN, 0, 1000, 0)

            # this will remove flicker, but gives boring colors
            '''
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN
            '''

            for i in xrange(0, self.GRAYS):
                curses.init_color(
                        self.GRAY_BASE + i,
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1),
                        i * 1000 / (self.GRAYS - 1)
                        )
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.GRAY_BASE + i,
                        self.COLOR_BLACK
                        )

        else:
            self.COLOR_BLACK = curses.COLOR_BLACK
            self.COLOR_WHITE = curses.COLOR_WHITE
            self.COLOR_BLUE = curses.COLOR_BLUE
            self.COLOR_RED = curses.COLOR_RED
            self.COLOR_GREEN = curses.COLOR_GREEN

            for i in xrange(0, self.GRAYS):
                curses.init_pair(
                        self.GRAY_BASE + i,
                        self.COLOR_WHITE,
                        self.COLOR_BLACK
                        )

        curses.init_pair(self.BLACK, self.COLOR_BLACK, self.COLOR_BLACK)
        curses.init_pair(self.WHITE, self.COLOR_WHITE, self.COLOR_BLACK)
        curses.init_pair(self.BLUE, self.COLOR_BLUE, self.COLOR_BLACK)
        curses.init_pair(self.RED, self.COLOR_RED, self.COLOR_BLACK)
        curses.init_pair(self.GREEN, self.COLOR_GREEN, self.COLOR_BLACK)
项目:treesel    作者:mcchae    | 项目源码 | 文件源码
def c_main(stdscr):
    cargo_cult_routine(stdscr)
    stdscr.nodelay(0)
    mydir = factory(start)
    mydir.expand()
    curidx = 3
    pending_action = None
    pending_save = False

    while True:
        stdscr.clear()
        curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE)
        line = 0
        offset = max(0, curidx - curses.LINES + 3)
        for data, depth in mydir.traverse():
            if line == curidx:
                stdscr.attrset(curses.color_pair(1) | curses.A_BOLD)
                if pending_action:
                    getattr(data, pending_action)()
                    pending_action = None
                elif pending_save:
                    global result
                    result = data.name
                    return
            else:
                stdscr.attrset(curses.color_pair(0))
            if 0 <= line - offset < curses.LINES - 1:
                stdscr.addstr(line - offset, 0,
                              data.render(depth, curses.COLS))
            line += 1
        stdscr.refresh()
        ch = stdscr.getch()
        if ch == curses.KEY_UP:
            curidx -= 1
        elif ch == curses.KEY_DOWN:
            curidx += 1
        elif ch == curses.KEY_PPAGE:
            curidx -= curses.LINES
            if curidx < 0: curidx = 0
        elif ch == curses.KEY_NPAGE:
            curidx += curses.LINES
            if curidx >= line: curidx = line - 1
        elif ch == curses.KEY_RIGHT:
            pending_action = 'expand'
        elif ch == curses.KEY_LEFT:
            pending_action = 'collapse'
        elif ch == ESC:
            return
        elif ch == ord('\n'):
            pending_save = True

        curidx %= line


################################################################################
项目:soyouhaveanidea    作者:yigitbey    | 项目源码 | 文件源码
def init_ui():
    check_size()
    begin_x = 1
    begin_y = 1
    height = 40
    width = 160
    left_win_width = 28
    middle_win_width = 80
    right_win_width = width - left_win_width - middle_win_width - 4

    win = newwin(height, width, begin_y, begin_x)
    win.border(0, 0, 0, 0, 0, 0, 0, 0)
    win.addstr("So You Have an Idea")
    win.refresh()

    left_win = win.subwin(height-5, left_win_width, 2, 2)
    left_win.border(0, 0, 0, 0, 0, 0, 0, 0)
    left_win.refresh()
    left_win = left_win.derwin(height-7, left_win_width-2, 1, 1)

    middle_win = win.subwin(height-5, middle_win_width, 2, left_win_width+2)
    middle_win.border(0, 0, 0, 0, 0, 0, 0, 0)
    for x in range(6, 20, 2):
        middle_win.addstr(x, middle_win_width-1, ">")
    middle_win.refresh()
    middle_win = middle_win.derwin(height-7, middle_win_width-2, 1, 1)

    right_win = win.subwin(height-5, right_win_width, 2, left_win_width + middle_win_width + 2)
    right_win.border(0, 0, 0, 0, 0, 0, 0, 0)
    for x in range(7, 21, 2):
        right_win.addstr(x, 0, "<")
    right_win.refresh()
    right_win = right_win.derwin(height-7, right_win_width-2, 1, 1)

    bottom_win = win.subwin(3, width-4, height-3, 2)
    bottom_win.border(0, 0, 0, 0, 0, 0, 0, 0)
    bottom_win.refresh()
    bottom_win = bottom_win.derwin(1, 114, 1, 1)

    left_win.refresh()
    middle_win.refresh()
    right_win.refresh()
    bottom_win.refresh()

    curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.init_pair(3, curses.COLOR_BLUE, curses.COLOR_BLACK)
    curses.init_pair(4, curses.COLOR_CYAN, curses.COLOR_BLACK)
    curses.init_pair(5, curses.COLOR_MAGENTA, curses.COLOR_BLACK)

    return left_win, middle_win, right_win, bottom_win, win
项目:asciidots    作者:aaronduino    | 项目源码 | 文件源码
def __init__(self, env, ticks, silent, debug, compat_debug, debug_lines, autostep_debug, output_limit):
        """

        :param dots.environment.Env env: The env of the interpreter
        :param int ticks: The max number of ticks for the program
        :param bool silent: True to turn off all outputs
        :param bool debug: True to show the execution of the program
        :param bool compat_debug: True to show the debug with only builtin functions
        :param int debug_lines: The number of lines to show the debug
        :param float autostep_debug: The timebetween automatic ticks. 0 disables the auto ticks.
        :param int output_limit: The max number of outputs for the program
        """
        super().__init__(env)

        # if it is zero or false, we don't want to stop
        self.ticks_left = ticks or float('inf')
        self.outputs_left = output_limit or float('inf')

        self.silent = silent
        self.debug = debug
        self.compat_debug = compat_debug
        self.debug_lines = debug_lines
        self.debug_cols = terminalsize.get_terminal_size()[0] - 1
        self.autostep_debug = autostep_debug

        self.compat_logging_buffer = ''
        self.compat_logging_buffer_lines = terminal_lines - debug_lines - 1

        self.first_tick = True

        if self.debug and not self.compat_debug:
            self.logging_loc = 0
            self.logging_x = 1

            self.stdscr = curses.initscr()

            curses.start_color()

            curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
            curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
            curses.init_pair(3, curses.COLOR_YELLOW, curses.COLOR_BLACK)
            curses.init_pair(4, curses.COLOR_BLUE, curses.COLOR_BLACK)

            curses.noecho()

            # hides the cursor
            curses.curs_set(False)

            # defining the two main parts of the screen: the view of the program
            self.win_program = curses.newwin(self.debug_lines, curses.COLS, 0, 0)
            # and pad for the output of the prog
            self.logging_pad = curses.newpad(1000, curses.COLS - 1)

            def signal_handler(signal, frame):
                self.on_finish()
                sys.exit(0)

            signal.signal(signal.SIGINT, signal_handler)