當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。