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


Python screen.Char方法代码示例

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


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

示例1: text_window_bar

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def text_window_bar(name=None, key_binding_manager=None):
    def get_tokens(cli):
        text_style = style.Bar.Text
        display_text, read_only = buffers.buffer_display(cli.application, name)
        if not read_only and cli.current_buffer_name == name:
            vi_mode = key_binding_manager.get_vi_state(cli).input_mode
            if vi_mode == vi_state.InputMode.INSERT:
                text_style = style.Bar.Hl_Text
            tokens = [(text_style, display_text),
                      (text_style, u' \u2022 ')]
            if vi_mode == vi_state.InputMode.INSERT:
                tokens.append((text_style, 'INSERT'))
            elif vi_mode == vi_state.InputMode.NAVIGATION:
                tokens.append((text_style, 'NORMAL'))
            else:
                tokens.append((text_style, '[     ]'))
            return tokens
        else:
            return [(text_style, display_text)]
    return toolbars.TokenListToolbar(
        get_tokens, default_char=screen.Char(' ', style.Bar.Text)) 
开发者ID:yittg,项目名称:Snipping,代码行数:23,代码来源:layout.py

示例2: _reset_screen

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def _reset_screen(self):
        """ Reset the Screen content. (also called when switching from/to
        alternate buffer. """
        self.pt_screen = Screen(default_char=Char(' ', ''))

        self.pt_screen.cursor_position = CursorPosition(0, 0)
        self.pt_screen.show_cursor = True

        self.data_buffer = self.pt_screen.data_buffer
        self.pt_cursor_position = self.pt_screen.cursor_position

        self._attrs = Attrs(color=None, bgcolor=None, bold=False,
                            underline=False, italic=False, blink=False, reverse=False)
        self._style_str = ''

        self.margins = None

        self.max_y = 0  # Max 'y' position to which is written. 
开发者ID:jonathanslenders,项目名称:ptterm,代码行数:20,代码来源:screen.py

示例3: erase_characters

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def erase_characters(self, count=None):
        """Erases the indicated # of characters, starting with the
        character at cursor position. Character attributes are set
        cursor attributes. The cursor remains in the same position.

        :param int count: number of characters to erase.

        .. warning::

           Even though *ALL* of the VTXXX manuals state that character
           attributes **should be reset to defaults**, ``libvte``,
           ``xterm`` and ``ROTE`` completely ignore this. Same applies
           too all ``erase_*()`` and ``delete_*()`` methods.
        """
        count = count or 1
        cursor_position = self.pt_cursor_position
        row = self.data_buffer[cursor_position.y]

        for column in range(cursor_position.x,
                            min(cursor_position.x + count, self.columns)):
            row[column] = Char(style=row[column].style) 
开发者ID:jonathanslenders,项目名称:ptterm,代码行数:23,代码来源:screen.py

示例4: create_tutorial_layout

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def create_tutorial_layout(lex):
    """ layout for example tutorial """
    lexer, _, _ = get_lexers(lex, None, None)
    layout_full = HSplit([
        FloatContainer(
            Window(
                BufferControl(
                    input_processors=input_processors,
                    lexer=lexer,
                    preview_search=Always()),
                get_height=get_height),
            [
                Float(xcursor=True,
                      ycursor=True,
                      content=CompletionsMenu(
                          max_height=MAX_COMPLETION,
                          scroll_offset=1,
                          extra_filter=(HasFocus(DEFAULT_BUFFER))))]),
        ConditionalContainer(
            HSplit([
                get_hline(),
                get_param(lexer),
                get_hline(),
                Window(
                    content=BufferControl(
                        buffer_name='example_line',
                        lexer=lexer
                    ),
                ),
                Window(
                    TokenListControl(
                        get_tutorial_tokens,
                        default_char=Char(' ', Token.Toolbar)),
                    height=D.exact(1)),
            ]),
            filter=~IsDone() & RendererHeightIsKnown()
        )
    ])
    return layout_full 
开发者ID:Azure,项目名称:azure-cli-shell,代码行数:41,代码来源:layout.py

示例5: __init__

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def __init__(self, pager):
        def get_tokens(cli):
            return pager.titlebar_tokens

        super(Titlebar, self).__init__(
            get_tokens,
            default_char=Char(' ', Token.Titlebar),
            filter=Condition(lambda cli: pager.display_titlebar)) 
开发者ID:jonathanslenders,项目名称:pypager,代码行数:10,代码来源:layout.py

示例6: bottombar

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def bottombar(inventory):
    TB = Token.Toolbar.Status

    def get_tokens(cli):

        tokens = [
            (TB.Key, '[Esc]'),
            (TB, ' Exit '),
            (TB.Key, '[Enter]'),
            (TB, ' SSH '),
            (TB.Key, '[F2]'),
            (TB, ' Select All '),
            (TB.Key, '[F9]'),
        ]

        if inventory.status == "refreshing":
            tokens.append((TB, ' Refreshing.. '))
        else:
            tokens.append((TB, ' Refresh '))

        return tokens

    return TokenListToolbar(
        get_tokens=get_tokens,
        default_char=Char(token=TB)
    ) 
开发者ID:joeyfeldberg,项目名称:ash,代码行数:28,代码来源:layout_bottombar.py

示例7: unicode_intern

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def unicode_intern(text):
    try:
        return _intern_dict[text]
    except KeyError:
        _intern_dict[text] = text
        return text


# Cache for Char objects. 
开发者ID:jonathanslenders,项目名称:ptterm,代码行数:11,代码来源:screen.py

示例8: alignment_display

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def alignment_display(self):
        for y in range(0, self.lines):
            line = self.data_buffer[y + self.line_offset]
            for x in range(0, self.columns):
                line[x] = Char('E')

    # Mapping of the ANSI color codes to their names. 
开发者ID:jonathanslenders,项目名称:ptterm,代码行数:9,代码来源:screen.py

示例9: get_layout

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def get_layout(self):
        return FloatContainer(
            HSplit([
                # Title
                TokenListToolbar(get_tokens=lambda cli: [(Token.Toolbar.Status.Title, 'ash')],
                                 align_center=True,
                                 default_char=Char(' ', Token.Toolbar.Status)),


                Window(height=LayoutDimension.exact(1),
                       content=FillControl(VERTICAL_LINE, token=Token.Resouce.Border)
                ),
                Window(height=LayoutDimension.exact(1),
                       content=TokenListControl(get_tokens=self.titles),
                       left_margins=[SimpleMargin(3)]
                ),
                Window(height=LayoutDimension.exact(1),
                       content=FillControl(VERTICAL_LINE, token=Token.Resouce.Border),
                       left_margins=[SimpleMargin(3)]
                ),

                # resources area
                Window(
                    cursorline=True,
                    always_hide_cursor=True,
                    cursorline_token=Token.CursorColumn,
                    get_vertical_scroll=lambda x: 0,
                    scroll_offsets=ScrollOffsets(top=2, bottom=2),
                    #right_margins=Margin.width=,
                    left_margins=[ScrollbarMargin(display_arrows=True), SimpleMargin(2)],
                    content=BufferControl(
                        lexer=PygmentsLexer(EC2Lexer),
                        default_char=Char(token=Token.Resouce),
                        buffer_name='RESOURCES_BUFFER',
                        input_processors=[HighlightSelectionProcessor()]
                    )
                ),
                VSplit([
                    bottombar(self.ash_cli.inventory)
                ])
            ]),
            [
                completion_bar()
            ]) 
开发者ID:joeyfeldberg,项目名称:ash,代码行数:46,代码来源:layout.py

示例10: erase_in_display

# 需要导入模块: from prompt_toolkit.layout import screen [as 别名]
# 或者: from prompt_toolkit.layout.screen import Char [as 别名]
def erase_in_display(self, type_of=0, private=False):
        """Erases display in a specific way.

        :param int type_of: defines the way the line should be erased in:

            * ``0`` -- Erases from cursor to end of screen, including
              cursor position.
            * ``1`` -- Erases from beginning of screen to cursor,
              including cursor position.
            * ``2`` -- Erases complete display. All lines are erased
              and changed to single-width. Cursor does not move.
            * ``3`` -- Erase saved lines. (Xterm) Clears the history.
        :param bool private: when ``True`` character attributes aren left
                             unchanged **not implemented**.
        """
        line_offset = self.line_offset
        pt_cursor_position = self.pt_cursor_position

        if type_of == 3:
            # Clear data buffer.
            for y in list(self.data_buffer):
                self.data_buffer.pop(y, None)

            # Reset line_offset.
            pt_cursor_position.y = 0
            self.max_y = 0
        else:
            try:
                interval = (
                    # a) erase from cursor to the end of the display, including
                    # the cursor,
                    range(pt_cursor_position.y + 1, line_offset + self.lines),
                    # b) erase from the beginning of the display to the cursor,
                    # including it,
                    range(line_offset, pt_cursor_position.y),
                    # c) erase the whole display.
                    range(line_offset, line_offset + self.lines)
                )[type_of]
            except IndexError:
                return

            data_buffer = self.data_buffer
            for line in interval:
                data_buffer[line] = defaultdict(lambda: Char(' '))

            # In case of 0 or 1 we have to erase the line with the cursor.
            if type_of in [0, 1]:
                self.erase_in_line(type_of) 
开发者ID:jonathanslenders,项目名称:ptterm,代码行数:50,代码来源:screen.py


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