How to use the ptpython.python_input.Option function in ptpython

To help you get started, we’ve selected a few ptpython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prompt-toolkit / ptpython / ptpython / python_input.py View on Github external
field_name='highlight_matching_parenthesis'),
            ]),
            OptionCategory('Colors', [
                simple_option(title='Syntax highlighting',
                              description='Use colors for syntax highligthing',
                              field_name='enable_syntax_highlighting'),
                simple_option(title='Swap light/dark colors',
                              description='Swap light and dark colors.',
                              field_name='swap_light_and_dark'),
                Option(title='Code',
                       description='Color scheme to use for the Python code.',
                       get_current_value=lambda: self._current_code_style_name,
                       get_values=lambda: dict(
                            (name, partial(self.use_code_colorscheme, name)) for name in self.code_styles)
                       ),
                Option(title='User interface',
                       description='Color scheme to use for the user interface.',
                       get_current_value=lambda: self._current_ui_style_name,
                       get_values=lambda: dict(
                            (name, partial(self.use_ui_colorscheme, name)) for name in self.ui_styles)
                       ),
                Option(title='Color depth',
                       description='Monochrome (1 bit), 16 ANSI colors (4 bit),\n256 colors (8 bit), or 24 bit.',
                       get_current_value=lambda: COLOR_DEPTHS[self.color_depth],
                       get_values=lambda: dict(
                           (name, partial(self._use_color_depth, depth)) for depth, name in COLOR_DEPTHS.items())
                       ),
                Option(title='Min brightness',
                       description='Minimum brightness for the color scheme (default=0.0).',
                       get_current_value=lambda: '%.2f' % self.min_brightness,
                       get_values=lambda: dict(
                           ('%.2f' % value, partial(self._set_min_brightness, value))
github prompt-toolkit / ptpython / ptpython / python_input.py View on Github external
return Option(title=title, description=description,
                          get_values=get_values,
                          get_current_value=get_current_value)

        brightness_values = [1.0 / 20 * value for value in range(0, 21)]

        return [
            OptionCategory('Input', [
                simple_option(title='Editing mode',
                              description='Vi or emacs key bindings.',
                              field_name='vi_mode',
                              values=[EditingMode.EMACS, EditingMode.VI]),
                simple_option(title='Paste mode',
                              description="When enabled, don't indent automatically.",
                              field_name='paste_mode'),
                Option(title='Complete while typing',
                       description="Generate autocompletions automatically while typing. "
                                   'Don\'t require pressing TAB. (Not compatible with "History search".)',
                       get_current_value=lambda: ['off', 'on'][self.complete_while_typing],
                       get_values=lambda: {
                           'on': lambda: enable('complete_while_typing') and disable('enable_history_search'),
                           'off': lambda: disable('complete_while_typing'),
                       }),
                Option(title='Enable fuzzy completion',
                       description="Enable fuzzy completion.",
                       get_current_value=lambda: ['off', 'on'][self.enable_fuzzy_completion],
                       get_values=lambda: {
                           'on': lambda: enable('enable_fuzzy_completion'),
                           'off': lambda: disable('enable_fuzzy_completion'),
                       }),
                Option(title='Dictionary completion',
                       description='Enable experimental dictionary completion.\n'
github prompt-toolkit / ptpython / ptpython / python_input.py View on Github external
def simple_option(title, description, field_name, values=None):
            " Create Simple on/of option. "
            values = values or ['off', 'on']

            def get_current_value():
                return values[bool(getattr(self, field_name))]

            def get_values():
                return {
                    values[1]: lambda: enable(field_name),
                    values[0]: lambda: disable(field_name),
                }

            return Option(title=title, description=description,
                          get_values=get_values,
                          get_current_value=get_current_value)