当前位置: 首页>>代码示例>>Python>>正文


Python curses.A_UNDERLINE属性代码示例

本文整理汇总了Python中curses.A_UNDERLINE属性的典型用法代码示例。如果您正苦于以下问题:Python curses.A_UNDERLINE属性的具体用法?Python curses.A_UNDERLINE怎么用?Python curses.A_UNDERLINE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在curses的用法示例。


在下文中一共展示了curses.A_UNDERLINE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: drawWorld

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def drawWorld(self, world, draw_actors=True):
        for i in range(world.worldmap.shape[0]):
            for j in range(world.worldmap.shape[1]):
                if world.worldmap[i, j] == W.DirectionEast:
                    self.stdscr.addstr(i, j, '>', curses.color_pair(0))
                elif world.worldmap[i, j] == W.DirectionWest:
                    self.stdscr.addstr(i, j, '<', curses.color_pair(0))
                elif world.worldmap[i, j] == W.DirectionNorth:
                    self.stdscr.addstr(i, j, '^', curses.color_pair(0))
                elif world.worldmap[i, j] == W.DirectionSouth:
                    self.stdscr.addstr(i, j, 'v', curses.color_pair(0))
                elif world.worldmap[i, j] == W.Sidewalk:
                    self.stdscr.addstr(i, j, '#', curses.color_pair(0))
                elif world.worldmap[i, j] == W.Intersection:
                    self.stdscr.addstr(i, j, 'X', curses.color_pair(0))
                else:
                    self.stdscr.addstr(i, j, ' ')

        if draw_actors:
            for actor in world.actors:
                if actor.state.x >= 0 and actor.state.y >= 0:
                    self.stdscr.addstr(
                        actor.state.y, actor.state.x, actor.name, curses.color_pair(1) + curses.A_BOLD + curses.A_UNDERLINE)

        self.bottom_row = i 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:27,代码来源:graphics.py

示例2: parseFormatting

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def parseFormatting(cls, formatting):
        """Parse ANSI formatting; the formatting passed in should be
        stripped of the control characters and ending character"""
        fore = -1  # -1 default means "use default", not "use white/black"
        back = -1
        other = 0
        intValues = [int(value) for value in formatting.split(';') if value]
        for code in intValues:
            if (code >= cls.FOREGROUND_RANGE.bottom
                    and code <= cls.FOREGROUND_RANGE.top):
                fore = code - cls.FOREGROUND_RANGE.bottom
            elif (code >= cls.BACKGROUND_RANGE.bottom
                  and code <= cls.BACKGROUND_RANGE.top):
                back = code - cls.BACKGROUND_RANGE.bottom
            elif code == cls.BOLD_ATTRIBUTE:
                other = other | curses.A_BOLD
            elif code == cls.UNDERLINE_ATTRIBUTE:
                other = other | curses.A_UNDERLINE

        return (fore, back, other) 
开发者ID:facebook,项目名称:PathPicker,代码行数:22,代码来源:formattedText.py

示例3: add_text

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def add_text(self):
		self.win.refresh()

		h, w = self.win.getmaxyx()
		self.win.addstr(3, 3, 'Help Page', curses.A_BOLD | curses.A_UNDERLINE)
		self.win.addstr(h - 2, 3, f"{'Press any key to exit...':>{w-5}}")

		keys = {  curses.KEY_UP : '↑',
			curses.KEY_DOWN : '↓',
			curses.KEY_LEFT: '←',
			curses.KEY_RIGHT: '→',
		}
		# keybinds
		i, j = 6, 3
		self.win.addstr(i, j, 'Keybindings', curses.A_UNDERLINE)
		i += 2
		i = self.add_config(i, j, self.keybinds, keys)
		# options
		if w // 2 >= 30:
			i, j = 6, w // 2 
		else:
			i += 2

		self.win.addstr(i, j, 'Default Options', curses.A_UNDERLINE)
		i+= 2
		self.add_config(i, j, self.options, keys) 
开发者ID:Jugran,项目名称:lyrics-in-terminal,代码行数:28,代码来源:window.py

示例4: initCurses

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def initCurses():
    screen = curses.initscr()
    curses.noecho()  # disable the keypress echo to prevent double input
    curses.cbreak()  # disable line buffers to run the keypress immediately
    curses.curs_set(0)
    screen.keypad(1)  # enable keyboard use

    screen.addstr(1, 2, "Fuzzing For Worms", curses.A_UNDERLINE)
    return screen 
开发者ID:dobin,项目名称:ffw,代码行数:11,代码来源:gui.py

示例5: print_line

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def print_line(self, i):
        num_line = self.win_y + i
        is_current_line = self.cursor_y == i and self.has_focus
        force_exit = False
        x = 0

        for (string, col, is_bold) in self.token_lines[num_line]:
            if x + len(string) >= self.width - 1:
                string = string[:self.width - x - 1]
                force_exit = True

            c = color_pair(col)

            if is_current_line:
                c |= A_UNDERLINE

            if is_bold:
                c |= curses.A_BOLD

            self.screen.addstr(i, x, string, c)

            x += len(string)
            if force_exit:
                break

        if is_current_line and not force_exit:
            n = self.width - x - 1
            self.screen.addstr(i, x, " " * n, color_pair(0) | A_UNDERLINE)
            x += n

        self.highlight_search(i)
        self.screen.move(i, x) 
开发者ID:plasma-disassembler,项目名称:plasma,代码行数:34,代码来源:listbox.py

示例6: _screen_color_init

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def _screen_color_init(self):
    """Initialization of screen colors."""
    curses.start_color()
    curses.use_default_colors()
    self._color_pairs = {}
    color_index = 0

    # Prepare color pairs.
    for fg_color in self._FOREGROUND_COLORS:
      for bg_color in self._BACKGROUND_COLORS:
        color_index += 1
        curses.init_pair(color_index, self._FOREGROUND_COLORS[fg_color],
                         self._BACKGROUND_COLORS[bg_color])

        color_name = fg_color
        if bg_color != "transparent":
          color_name += "_on_" + bg_color

        self._color_pairs[color_name] = curses.color_pair(color_index)

    # Try getting color(s) available only under 256-color support.
    try:
      color_index += 1
      curses.init_pair(color_index, 245, -1)
      self._color_pairs[cli_shared.COLOR_GRAY] = curses.color_pair(color_index)
    except curses.error:
      # Use fall-back color(s):
      self._color_pairs[cli_shared.COLOR_GRAY] = (
          self._color_pairs[cli_shared.COLOR_GREEN])

    # A_BOLD or A_BLINK is not really a "color". But place it here for
    # convenience.
    self._color_pairs["bold"] = curses.A_BOLD
    self._color_pairs["blink"] = curses.A_BLINK
    self._color_pairs["underline"] = curses.A_UNDERLINE

    # Default color pair to use when a specified color pair does not exist.
    self._default_color_pair = self._color_pairs[cli_shared.COLOR_WHITE] 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:40,代码来源:curses_ui.py

示例7: _screen_init

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def _screen_init(self):
    """Screen initialization.

    Creates curses stdscr and initialize the color pairs for display.
    """

    self._stdscr = curses.initscr()
    self._command_window = None

    # Prepare color pairs.
    curses.start_color()

    self._color_pairs = {}
    color_index = 0

    for fg_color in self._FOREGROUND_COLORS:
      for bg_color in self._BACKGROUND_COLORS:

        color_index += 1
        curses.init_pair(color_index, self._FOREGROUND_COLORS[fg_color],
                         self._BACKGROUND_COLORS[bg_color])

        color_name = fg_color
        if bg_color != "black":
          color_name += "_on_" + bg_color

        self._color_pairs[color_name] = curses.color_pair(color_index)

    # A_BOLD or A_BLINK is not really a "color". But place it here for
    # convenience.
    self._color_pairs["bold"] = curses.A_BOLD
    self._color_pairs["blink"] = curses.A_BLINK
    self._color_pairs["underline"] = curses.A_UNDERLINE

    # Default color pair to use when a specified color pair does not exist.
    self._default_color_pair = self._color_pairs["white"] 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:38,代码来源:curses_ui.py

示例8: set_colors

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def set_colors(self):
        """Sets up curses color pairs."""
        hicolor = os.getenv("TERM").endswith("256color")

        if self.monochrome:
            color = self.config.monochromecolors
        elif hicolor:
            color = self.config.xterm256colors
        else:
            color = self.config.xtermcolors

        bg = color.background
        curses.init_pair(Screen.COLOR_AUTHOR, *color.author)
        curses.init_pair(Screen.COLOR_BACKGROUND, bg, bg)
        curses.init_pair(Screen.COLOR_CORRECT, *color.correct)
        curses.init_pair(Screen.COLOR_HISCORE, *color.score)
        curses.init_pair(Screen.COLOR_INCORRECT, *color.incorrect)
        curses.init_pair(Screen.COLOR_PROMPT, *color.prompt)
        curses.init_pair(Screen.COLOR_QUOTE, *color.quote)
        curses.init_pair(Screen.COLOR_STATUS, *color.top_bar)

        # Rebind class variables
        Screen.COLOR_AUTHOR = curses.color_pair(Screen.COLOR_AUTHOR)
        Screen.COLOR_BACKGROUND = curses.color_pair(Screen.COLOR_BACKGROUND)
        Screen.COLOR_CORRECT = curses.color_pair(Screen.COLOR_CORRECT)
        Screen.COLOR_HISCORE = curses.color_pair(Screen.COLOR_HISCORE)
        Screen.COLOR_INCORRECT = curses.color_pair(Screen.COLOR_INCORRECT)
        Screen.COLOR_PROMPT = curses.color_pair(Screen.COLOR_PROMPT)
        Screen.COLOR_QUOTE = curses.color_pair(Screen.COLOR_QUOTE)
        Screen.COLOR_STATUS = curses.color_pair(Screen.COLOR_STATUS)

        if not hicolor:
            # Make certain colors more visible
            Screen.COLOR_CORRECT |= curses.A_DIM
            Screen.COLOR_INCORRECT |= curses.A_UNDERLINE | curses.A_BOLD
            Screen.COLOR_QUOTE |= curses.A_BOLD
            Screen.COLOR_STATUS |= curses.A_BOLD 
开发者ID:cslarsen,项目名称:wpm,代码行数:39,代码来源:screen.py

示例9: Render

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def Render(self):
        self.stdscr.erase()
        self.stdscr.addstr(0,0,"OANDA bot",curses.A_UNDERLINE)

        # Current account status
        self.stdscr.addstr(2,0,"Account currency:   "+self._account_currency)
        self.stdscr.addstr(3,0,"Trading instrument: "+self._instrument)

        # Ticker and heartbeat
        self.stdscr.addstr(5,0,"Heartbeat: "+self._heartbeatTime)
        self.stdscr.addstr(6,0,"Ticker:    "+str(self._currentPrice))

        # Account status
        self.stdscr.addstr(8, 0,"Position:        "+self._currentPosition + " " + self._currentPositionSide)
        self.stdscr.addstr(9, 0,"Balance:         "+self._balance)
        self.stdscr.addstr(10,0,"Available units: "+self._availableUnits)
        self.stdscr.addstr(11,0,"Cash invested:   "+self._cashInvested + " leverage: "+self._leverage)
        self.stdscr.addstr(12,0,"Net Worth:       "+self._netWorth + " unrealized PnL: "+self._unrealizedPnL)

        # Strategy status
        self.stdscr.addstr(14,0,"Stop Loss price:     "+str(self._stoploss_price))
        self.stdscr.addstr(15,0,"Trailing Stop price: "+str(self._trailingstop_price))
        if self._strategy.TradingStatus():
            status = "running"
        else:
            status = "paused"
        self.stdscr.addstr(16,0,"Strategy status:     "+status)

        self.stdscr.addstr(18,0,"Available actions:", curses.A_UNDERLINE)
        if self._strategy.TradingStatus():
            command = "(P)ause - pause strategy. Disable trading, but keep tickers coming"
        else:
            command = "(R)esume - resume strategy. Reenable trading"

        self.stdscr.addstr(19,0,command)
        self.stdscr.addstr(20,0,"(B)uy - take long position on instrument")
        self.stdscr.addstr(21,0,"(S)ell - take short position on instrument")
        self.stdscr.addstr(22,0,"(C)lose - close position on instrument")
        self.stdscr.addstr(23,0,"(Q)uit - exit")

        self.stdscr.refresh() 
开发者ID:PeterMalkin,项目名称:oandapybot,代码行数:43,代码来源:ui.py

示例10: _setattr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def _setattr(self, a):
        if a is None:
            self.s.attrset(0)
            return
        elif not isinstance(a, AttrSpec):
            p = self._palette.get(a, (AttrSpec('default', 'default'),))
            a = p[0]

        if self.has_color:
            if a.foreground_basic:
                if a.foreground_number >= 8:
                    fg = a.foreground_number - 8
                else:
                    fg = a.foreground_number
            else:
                fg = 7

            if a.background_basic:
                bg = a.background_number
            else:
                bg = 0

            attr = curses.color_pair(bg * 8 + 7 - fg)
        else:
            attr = 0

        if a.bold:
            attr |= curses.A_BOLD
        if a.standout:
            attr |= curses.A_STANDOUT
        if a.underline:
            attr |= curses.A_UNDERLINE
        if a.blink:
            attr |= curses.A_BLINK

        self.s.attrset(attr) 
开发者ID:AnyMesh,项目名称:anyMesh-Python,代码行数:38,代码来源:curses_display.py

示例11: set_cursor_style

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def set_cursor_style(self, cursor_style):
        """Set cursor style.

        :param str cursor_style: Cursor type, either 'underline' or 'reverse'.
        """
        if cursor_style == "underline":
            self.cursor_style = curses.A_UNDERLINE
        elif cursor_style == "reverse":
            self.cursor_style = curses.A_REVERSE
        else:
            return False
        return True 
开发者ID:richrd,项目名称:suplemon,代码行数:14,代码来源:viewer.py

示例12: attr

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def attr(self, style: Style) -> int:
        pair = self._color_manager.color_pair(style.fg, style.bg)
        return (
            curses.color_pair(pair) |
            curses.A_BOLD * style.b |
            A_ITALIC * style.i |
            curses.A_UNDERLINE * style.u
        ) 
开发者ID:asottile,项目名称:babi,代码行数:10,代码来源:syntax.py

示例13: test_theme_256_construct

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def test_theme_256_construct():

    elements = {'CursorBar1': (None, 101, curses.A_UNDERLINE)}
    theme = Theme(elements=elements)
    assert theme.elements['CursorBar1'] == (-1, 101, curses.A_UNDERLINE)
    assert theme.required_colors == 256 
开发者ID:michael-lazar,项目名称:rtv,代码行数:8,代码来源:test_theme.py

示例14: login

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def login(self):
        username = self.api.is_login()
        if username:
            if isinstance(username, unicode):
                username = username.encode('utf-8')
            self.footer.write('%s 已登录.' % username)
            return

        curses.echo()
        self.login_win.erase()
        self.login_win.addstr(0, 2, "Username: ", curses.color_pair(1))
        self.login_win.addstr(1, 2, " " * 43, curses.A_UNDERLINE)
        username = self.login_win.getstr(1, 2)
        password = ''
        if len(username) > 0:
            self.login_win.addstr(3, 2, "Password: ", curses.color_pair(1))
            self.login_win.addstr(4, 2, " " * 43, curses.A_UNDERLINE)
            password = self.login_win.getstr(4, 2)
            fm_log(logger, "USERNAME: %s, PWD: %s", username, '*****')
        if username and password:
            try:
                result = self.api.login(username, password, '')
                login_count = 0
                if result:
                    while True:
                        login_count += 1
                        try:
                            image_to_display(self.login_win, result, 8)
                        except:
                            pass
                        self.login_win.addstr(6, 2, "Captcha(%s): " % result, curses.color_pair(1))
                        self.login_win.addstr(7, 2, " " * 43, curses.A_UNDERLINE)
                        captcha = self.login_win.getstr(7, 2)
                        result = self.api.login(username, password, captcha)
                        if not result or login_count > 3:
                            break
                if not result:
                    if isinstance(username, unicode):
                        username = username.encode('utf-8')
                    self.footer.write('%s 登录成功.' % username)
            except Exception as e:
                fm_log(logger, "Login error. %s", str(e.args))

        self.refresh_body() 
开发者ID:tdoly,项目名称:baidufm-py,代码行数:46,代码来源:fm_cli.py

示例15: update

# 需要导入模块: import curses [as 别名]
# 或者: from curses import A_UNDERLINE [as 别名]
def update(self, clear=True, cursor=True):
        if clear: self.clear()
        if self.begin_at    < 0: self.begin_at = 0
        if self.left_margin >= self.maximum_string_length:
            raise ValueError
            
        if self.cursor_position < 0:
            self.cursor_position = 0
        if self.cursor_position > len(self.value):
            self.cursor_position = len(self.value)
        
        if self.cursor_position < self.begin_at:
            self.begin_at = self.cursor_position
        
        while self.find_cursor_offset_on_screen(self.cursor_position) > \
                 self.find_cursor_offset_on_screen(self.begin_at) + \
                 self.maximum_string_length - self.left_margin -1: # -1:
            self.begin_at += 1
    

        text, highlighting = self.get_literal_text_to_display(start_at=self.begin_at)
        if self.do_colors():
            if self.important:
                color = self.parent.theme_manager.findPair(self, 'IMPORTANT') | curses.A_BOLD            
            else:
                color = self.parent.theme_manager.findPair(self, self.color)
            if self.show_bold:
                color = color | curses.A_BOLD
            if self.highlight:
                if not self.editing:
                    color = color | curses.A_STANDOUT
                else:
                    color = color | curses.A_UNDERLINE
            highlighting = [color for c in highlighting if c == curses.A_NORMAL]
        else:
            color = curses.A_NORMAL
            if self.important or self.show_bold:
                color = color | curses.A_BOLD
            if self.important:
                color = color | curses.A_UNDERLINE
            if self.highlight:
                if not self.editing:
                    color = color | curses.A_STANDOUT
                else:
                    color = color | curses.A_UNDERLINE
            highlighting = [color for c in highlighting if c == curses.A_NORMAL]
        
        self._print(text, highlighting)
        
        if self.editing and cursor:
            self.print_cursor() 
开发者ID:hexway,项目名称:apple_bleee,代码行数:53,代码来源:wgtexttokens.py


注:本文中的curses.A_UNDERLINE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。