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


Python LayoutDimension.exact方法代码示例

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


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

示例1: get_dimensions

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
    def get_dimensions(cli):
        """
        Return a list of LayoutDimension instances for this split.
        These dimensions will take the weight from the
        arrangement.VSplit/HSplit instances.
        """
        average_weight = get_average_weight()

        # Make sure that weight is distributed

        result = []
        for i, item in enumerate(split):
            result.append(D(weight=split.weights.get(item) or average_weight))

            # Add dimension for the vertical border.
            last_item = i == len(split) - 1
            if is_vsplit and not last_item:
                result.append(D.exact(1))
            elif is_hsplit and not last_item:
                if pymux.enable_pane_status:
                    result.append(D.exact(0))
                else:
                    result.append(D.exact(1))

        return result
开发者ID:haridsv,项目名称:pymux,代码行数:27,代码来源:layout.py

示例2: __init__

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
    def __init__(self, python_input):
        token = Token.Toolbar.Status

        version = sys.version_info
        tokens = [
            (token, ' [F2] Options'),
            (token, ' - '),
            (token.PythonVersion, '%s %i.%i.%i' % (platform.python_implementation(),
                                                   version[0], version[1], version[2])),
            (token, ' '),
        ]
        width = token_list_width(tokens)

        def get_tokens(cli):
            # Python version
            return tokens

        super(ShowSidebarButtonInfo, self).__init__(
            content=Window(
                TokenListControl(get_tokens, default_char=Char(token=token)),
                height=LayoutDimension.exact(1),
                width=LayoutDimension.exact(width)),
            filter=~IsDone() & RendererHeightIsKnown() &
                Condition(lambda cli: python_input.show_status_bar and
                                      not python_input.show_exit_confirmation))
开发者ID:azinoviev,项目名称:ptpython,代码行数:27,代码来源:layout.py

示例3: __init__

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
    def __init__(self, editor, buffer_window, buffer_name):
        def get_scroll_text():
            info = buffer_window.render_info

            if info:
                if info.full_height_visible:
                    return 'All'
                elif info.top_visible:
                    return 'Top'
                elif info.bottom_visible:
                    return 'Bot'
                else:
                    percentage = info.vertical_scroll_percentage
                    return '%2i%%' % percentage

            return ''

        def get_tokens(cli):
            main_document = cli.buffers[buffer_name].document

            return [
                (Token.Toolbar.CursorPosition, '(%i,%i)' % (main_document.cursor_position_row + 1,
                                                            main_document.cursor_position_col + 1)),
                (Token.Toolbar, ' - '),
                (Token.Toolbar.Percentage, get_scroll_text()),
                (Token.Toolbar, ' '),
            ]

        super(WindowStatusBarRuler, self).__init__(
            Window(
                TokenListControl(get_tokens, default_char=Char(' ', Token.Toolbar), align_right=True),
                height=LayoutDimension.exact(1),
                width=LayoutDimension.exact(15)),
            filter=Condition(lambda cli: editor.show_ruler))
开发者ID:yxf07,项目名称:pyvim,代码行数:36,代码来源:layout.py

示例4: __init__

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
    def __init__(self, python_input):
        def get_tokens(cli):
            tokens = []
            T = Token.Sidebar

            # Show navigation info.
            tokens.extend([
                (T.Separator , ' ' * 43 + '\n'),
                (T, '    '),
                (T.Key, '[Arrows]'),
                (T, ' '),
                (T.Key.Description, 'Navigate'),
                (T, ' '),
                (T.Key, '[Enter]'),
                (T, ' '),
                (T.Key.Description, 'Hide menu'),
            ])

            return tokens

        super(PythonSidebarNavigation, self).__init__(
            TokenListControl(get_tokens, Char(token=Token.Sidebar)),
            width=LayoutDimension.exact(43),
            height=LayoutDimension.exact(2),
            filter=ShowSidebar(python_input) & ~IsDone())
开发者ID:blackrobot,项目名称:ptpython,代码行数:27,代码来源:layout.py

示例5: python_sidebar_navigation

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
def python_sidebar_navigation(python_input):
    """
    Create the `Layout` showing the navigation information for the sidebar.
    """
    def get_tokens(cli):
        tokens = []
        T = Token.Sidebar

        # Show navigation info.
        tokens.extend([
            (T.Separator, ' ' * 43 + '\n'),
            (T, '    '),
            (T.Key, '[Arrows]'),
            (T, ' '),
            (T.Key.Description, 'Navigate'),
            (T, ' '),
            (T.Key, '[Enter]'),
            (T, ' '),
            (T.Key.Description, 'Hide menu'),
        ])

        return tokens

    return ConditionalContainer(
        content=Window(
            TokenListControl(get_tokens, Char(token=Token.Sidebar)),
            width=LayoutDimension.exact(43),
            height=LayoutDimension.exact(2)),
        filter=ShowSidebar(python_input) & ~IsDone())
开发者ID:AMIRUJK,项目名称:2505,代码行数:31,代码来源:layout.py

示例6: show_sidebar_button_info

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
def show_sidebar_button_info(python_input):
    """
    Create `Layout` for the information in the right-bottom corner.
    (The right part of the status bar.)
    """
    @if_mousedown
    def toggle_sidebar(cli, mouse_event):
        " Click handler for the menu. "
        python_input.show_sidebar = not python_input.show_sidebar

    token = Token.Toolbar.Status

    version = sys.version_info
    tokens = [
        (token.Key, '[F2]', toggle_sidebar),
        (token, ' Menu', toggle_sidebar),
        (token, ' - '),
        (token.PythonVersion, '%s %i.%i.%i' % (platform.python_implementation(),
                                               version[0], version[1], version[2])),
        (token, ' '),
    ]
    width = token_list_width(tokens)

    def get_tokens(cli):
        # Python version
        return tokens

    return ConditionalContainer(
        content=Window(
            TokenListControl(get_tokens, default_char=Char(token=token)),
            height=LayoutDimension.exact(1),
            width=LayoutDimension.exact(width)),
        filter=~IsDone() & RendererHeightIsKnown() &
            Condition(lambda cli: python_input.show_status_bar and
                                  not python_input.show_exit_confirmation))
开发者ID:AMIRUJK,项目名称:2505,代码行数:37,代码来源:layout.py

示例7: get_anyhline

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
def get_anyhline(config):
    """ if there is a line between descriptions and example """
    if config.BOOLEAN_STATES[config.config.get('Layout', 'command_description')] or\
       config.BOOLEAN_STATES[config.config.get('Layout', 'param_description')]:
        return Window(
            width=LayoutDimension.exact(1),
            height=LayoutDimension.exact(1),
            content=FillControl('-', token=Token.Line))
    return get_empty()
开发者ID:GeekTrainer,项目名称:azure-cli-extensions,代码行数:11,代码来源:layout.py

示例8: vertical_line

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
 def vertical_line():
     " Draw a vertical line between windows. (In case of a vsplit) "
     char = '│'
     content.append(HSplit([
             Window(
                width=D.exact(1), height=D.exact(1),
                content=FillControl(char, token=Token.TitleBar.Line)),
             Window(width=D.exact(1),
                    content=FillControl(char, token=Token.Line))
         ]))
开发者ID:amjith,项目名称:pymux-test,代码行数:12,代码来源:layout.py

示例9: vertical_line

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
 def vertical_line():
     " Draw a vertical line between windows. (In case of a vsplit) "
     char = '│'
     content.append(HSplit([
             ConditionalContainer(
                 content=Window(
                     width=D.exact(1), height=D.exact(1),
                     content=FillControl(char, token=Token.TitleBar.Line)),
                 filter=Condition(lambda cli: pymux.enable_pane_status),
             ),
             Window(width=D.exact(1),
                    content=FillControl(char, token=Token.Line))
         ]))
开发者ID:haridsv,项目名称:pymux,代码行数:15,代码来源:layout.py

示例10: signature_toolbar

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
def signature_toolbar(python_input):
    """
    Return the `Layout` for the signature.
    """
    def get_tokens(cli):
        result = []
        append = result.append
        Signature = Token.Toolbar.Signature

        if python_input.signatures:
            sig = python_input.signatures[0]  # Always take the first one.

            append((Signature, ' '))
            try:
                append((Signature, sig.full_name))
            except IndexError:
                # Workaround for #37: https://github.com/jonathanslenders/python-prompt-toolkit/issues/37
                # See also: https://github.com/davidhalter/jedi/issues/490
                return []

            append((Signature.Operator, '('))

            for i, p in enumerate(sig.params):
                # Workaround for #47: 'p' is None when we hit the '*' in the signature.
                #                     and sig has no 'index' attribute.
                # See: https://github.com/jonathanslenders/ptpython/issues/47
                #      https://github.com/davidhalter/jedi/issues/598
                description = (p.description if p else '*') #or '*'
                sig_index = getattr(sig, 'index', 0)

                if i == sig_index:
                    # Note: we use `_Param.description` instead of
                    #       `_Param.name`, that way we also get the '*' before args.
                    append((Signature.CurrentName, str(description)))
                else:
                    append((Signature, str(description)))
                append((Signature.Operator, ', '))

            if sig.params:
                # Pop last comma
                result.pop()

            append((Signature.Operator, ')'))
            append((Signature, ' '))
        return result

    return ConditionalContainer(
        content=Window(
            TokenListControl(get_tokens),
            height=LayoutDimension.exact(1)),
        filter=
            # Show only when there is a signature
            HasSignature(python_input) &
            # And there are no completions to be shown. (would cover signature pop-up.)
            ~(HasCompletions() & (show_completions_menu(python_input) |
                                   show_multi_column_completions_menu(python_input)))
            # Signature needs to be shown.
            & ShowSignature(python_input) &
            # Not done yet.
            ~IsDone())
开发者ID:AMIRUJK,项目名称:2505,代码行数:62,代码来源:layout.py

示例11: __init__

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
    def __init__(self, python_input):
        def get_tokens(cli):
            tokens = []
            T = Token.Sidebar

            tokens.extend([
                (T, '  '),
                (T.Title, 'Options'),
                (T, '\n'),
            ])

            def append(selected, label, status):
                token = T.Selected if selected else T

                tokens.append((T, ' >' if selected else '  '))
                tokens.append((token.Label, '%-24s' % label))
                tokens.append((token.Status, ' %-14s' % status))
                tokens.append((T, '<' if selected else ''))
                tokens.append((T, '\n'))

            for i, option in enumerate(python_input.options):
                append(i == python_input.selected_option,
                       option.description, '%s' % option.get_current_value())

            tokens.pop()  # Remove last newline.

            return tokens

        super(PythonSidebar, self).__init__(
            TokenListControl(get_tokens, Char(token=Token.Sidebar)),
            width=LayoutDimension.exact(43),
            filter=ShowSidebar(python_input) & ~IsDone())
开发者ID:amiorin,项目名称:ptpython,代码行数:34,代码来源:layout.py

示例12: create_default_layout

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
def create_default_layout(message='', lexer=None, is_password=False,
                          reserve_space_for_menu=False, get_bottom_toolbar_tokens=None,
                          extra_input_processors=None):
    """
    Generate default layout.
    """
    assert get_bottom_toolbar_tokens is None or callable(get_bottom_toolbar_tokens)

    # Create processors list.
    # (DefaultPrompt should always be at the end.)
    input_processors = [HighlightSearchProcessor(preview_search=Always()),
                        HighlightSelectionProcessor()]
    if extra_input_processors:
        input_processors.extend(extra_input_processors)

    if is_password:
        input_processors.extend([PasswordProcessor(), DefaultPrompt(message)])
    else:
        input_processors.append(DefaultPrompt(message))

    # Create bottom toolbar.
    if get_bottom_toolbar_tokens:
        toolbars = [Window(TokenListControl(get_bottom_toolbar_tokens,
                                            default_char=Char(' ', Token.Toolbar)),
                           height=LayoutDimension.exact(1),
                           filter=~IsDone())]
    else:
        toolbars = []

    def get_height(cli):
        # If there is an autocompletion menu to be shown, make sure that our
        # layout has at least a minimal height in order to display it.
        if reserve_space_for_menu and not cli.is_done:
            return LayoutDimension(min=8)
        else:
            return LayoutDimension()

    # Create and return Layout instance.
    return HSplit([
        FloatContainer(
            Window(
                BufferControl(
                    input_processors=input_processors,
                    lexer=lexer,
                    # Enable preview_search, we want to have immediate feedback
                    # in reverse-i-search mode.
                    preview_search=Always()),
                get_height=get_height,
            ),
            [
                Float(xcursor=True,
                      ycursor=True,
                      content=CompletionsMenu(max_height=16,
                                              extra_filter=HasFocus(DEFAULT_BUFFER)))
            ]
        ),
        ValidationToolbar(),
        SystemToolbar(),
    ] + toolbars)
开发者ID:weima,项目名称:python-prompt-toolkit,代码行数:61,代码来源:shortcuts.py

示例13: __init__

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
 def __init__(self):
     super(CommandLine, self).__init__(
         BufferControl(
             buffer_name=COMMAND_BUFFER,
             input_processors=[BeforeInput.static(':')],
             lexer=create_command_lexer()),
         height=LayoutDimension.exact(1),
         filter=HasFocus(COMMAND_BUFFER))
开发者ID:AxEofBone7,项目名称:pyvim,代码行数:10,代码来源:layout.py

示例14: horizontal_line

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
 def horizontal_line():
     char = '─'
     content.append(
         ConditionalContainer(
             content=Window(height=D.exact(1),
                            content=FillControl(char, token=Token.Line)),
             filter=Condition(lambda cli: not pymux.enable_pane_status)),
     )
开发者ID:haridsv,项目名称:pymux,代码行数:10,代码来源:layout.py

示例15: __init__

# 需要导入模块: from prompt_toolkit.layout.dimension import LayoutDimension [as 别名]
# 或者: from prompt_toolkit.layout.dimension.LayoutDimension import exact [as 别名]
 def __init__(self):
     super(CommandPrompt, self).__init__(
         BufferControl(
             buffer_name=COMMAND_BUFFER,
             input_processors=[BeforeInput.static(self.PROMPT)],
         ),
         height=D.exact(1)
     )
开发者ID:andythigpen,项目名称:chromeconsole,代码行数:10,代码来源:layout.py


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