From 1c2c98c1a458dea2147fae256cd77c063319051f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Jun 2018 23:49:30 +0530 Subject: [PATCH] More conf docs --- kitty/conf/definition.py | 11 +++---- kitty/config.py | 38 ++--------------------- kitty/config_data.py | 67 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 44 deletions(-) diff --git a/kitty/conf/definition.py b/kitty/conf/definition.py index 90b5d94e9..67fc6ac08 100644 --- a/kitty/conf/definition.py +++ b/kitty/conf/definition.py @@ -96,7 +96,7 @@ def render_block(text): def render_group(a, group): - a('# ' + group.short_text + ' {{{') + a('# ' + group.short_text + ' {{''{') a('') if group.start_text: a(render_block(group.start_text)) @@ -115,16 +115,13 @@ def as_conf_file(all_options): if current_group: if current_group.end_text: a(''), a(current_group.end_text) - a('# }}}'), a('') + a('# }}''}'), a('') current_group = opt.group render_group(a, current_group) mopts = list(merged_opts(all_options, opt, i)) - a(render_block(opt.short_text)) + a(render_block(opt.long_text or opt.short_text)) a('') - if opt.long_text: - a(render_block(opt.long_text)) - a('') sz = max(len(x.name) for x in mopts) for mo in mopts: prefix = '' if mo.add_to_default else '# ' @@ -133,5 +130,5 @@ def as_conf_file(all_options): if current_group: if current_group.end_text: a(''), a(current_group.end_text) - a('# }}}') + a('# }}''}') return ans diff --git a/kitty/config.py b/kitty/config.py index c64b6b6d6..cba303d9a 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -21,25 +21,7 @@ from .constants import cache_dir, defconf from .layout import all_layouts from .rgb import color_as_int, color_from_int from .utils import log_error - - -mod_map = {'CTRL': 'CONTROL', 'CMD': 'SUPER', '⌘': 'SUPER', '⌥': 'ALT', 'OPTION': 'ALT', 'KITTY_MOD': 'KITTY'} - - -def parse_mods(parts, sc): - - def map_mod(m): - return mod_map.get(m, m) - - mods = 0 - for m in parts: - try: - mods |= getattr(defines, 'GLFW_MOD_' + map_mod(m.upper())) - except AttributeError: - log_error('Shortcut: {} has unknown modifier, ignoring'.format(sc)) - return - - return mods +from .config_data import to_modifiers, parse_mods named_keys = { @@ -266,10 +248,6 @@ def parse_send_text(val, key_definitions): return parse_key(key_str, key_definitions) -def to_modifiers(val): - return parse_mods(val.split('+'), val) or 0 - - def uniq(vals, result_type=list): seen = set() seen_add = seen.add @@ -321,25 +299,15 @@ def tab_bar_edge(x): return {'top': 1, 'bottom': 3}.get(x.lower(), 3) -def url_style(x): - return url_style.map.get(x, url_style.map['curly']) - - def window_size(val): val = val.lower() unit = 'cells' if val.endswith('c') else 'px' return positive_int(val.rstrip('c')), unit -url_style.map = dict( - ((v, i) for i, v in enumerate('none single double curly'.split())) -) - type_map = { 'allow_remote_control': to_bool, - 'open_url_with': to_cmdline, 'focus_follows_mouse': to_bool, - 'open_url_modifiers': to_modifiers, 'rectangle_select_modifiers': to_modifiers, 'repaint_delay': positive_int, 'input_delay': positive_int, @@ -368,8 +336,6 @@ type_map = { 'active_tab_font_style': tab_font_style, 'inactive_tab_font_style': tab_font_style, 'inactive_text_alpha': unit_float, - 'url_style': url_style, - 'copy_on_select': to_bool, 'window_alert_on_bell': to_bool, 'tab_bar_edge': tab_bar_edge, 'bell_on_tab': to_bool, @@ -382,7 +348,7 @@ type_map = { for name in ( 'foreground background active_border_color inactive_border_color' - ' selection_foreground selection_background url_color bell_border_color' + ' selection_foreground selection_background bell_border_color' ).split(): type_map[name] = to_color for i in range(256): diff --git a/kitty/config_data.py b/kitty/config_data.py index 4b29c5506..b63894e07 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -5,10 +5,13 @@ from gettext import gettext as _ +from . import fast_data_types as defines from .conf.definition import option_func from .conf.utils import positive_float, positive_int, to_cmdline, to_color from .fast_data_types import CURSOR_BEAM, CURSOR_BLOCK, CURSOR_UNDERLINE +from .utils import log_error +# Utils {{{ MINIMUM_FONT_SIZE = 4 @@ -47,6 +50,38 @@ def to_cursor_shape(x): ) +def url_style(x): + return url_style.map.get(x, url_style.map['curly']) + + +url_style.map = dict( + ((v, i) for i, v in enumerate('none single double curly'.split())) +) + +mod_map = {'CTRL': 'CONTROL', 'CMD': 'SUPER', '⌘': 'SUPER', + '⌥': 'ALT', 'OPTION': 'ALT', 'KITTY_MOD': 'KITTY'} + + +def parse_mods(parts, sc): + + def map_mod(m): + return mod_map.get(m, m) + + mods = 0 + for m in parts: + try: + mods |= getattr(defines, 'GLFW_MOD_' + map_mod(m.upper())) + except AttributeError: + log_error('Shortcut: {} has unknown modifier, ignoring'.format(sc)) + return + + return mods + + +def to_modifiers(val): + return parse_mods(val.split('+'), val) or 0 + + all_options = {} @@ -64,9 +99,13 @@ o, g, all_groups = option_func(all_options, { 'scrollback': [ _('Scrollback'), ], + + 'mouse': [ + _('Mouse'), + ], }) type_map = {o.name: o.option_type for o in all_options.values()} - +# }}} g('fonts') # {{{ @@ -162,3 +201,29 @@ o('wheel_scroll_multiplier', 5.0, _('Wheel/touchpad scrolling'), long_text=_(''' Wheel scroll multiplier (modify the amount scrolled by the mouse wheel). Use negative numbers to change scroll direction.''')) # }}} + +g('mouse') # {{{ + +o('url_color', '#0087BD', _('URL hover highlight'), option_type=to_color, long_text=_(''' +The color and style for highlighting URLs on mouse-over. +:code:`url_style` can be one of: none, single, double, curly''')) + +o('url_style', 'curly', option_type=url_style) + +o('open_url_modifiers', 'kitty_mod', _('Click URL modifiers'), option_type=to_modifiers, long_text=_(''' +The modifier keys to press when clicking with the +mouse on URLs to open the URL''')) + +o('open_url_with', 'default', _('Open URL with'), option_type=to_cmdline, long_text=_(''' +The program with which to open URLs that are clicked on. +The special value :code:`default` means to use the +operating system's default URL handler.''')) + +o('copy_on_select', False, _('Copy on select'), long_text=_(''' +Copy to clipboard on select. With this enabled, simply selecting text with +the mouse will cause the text to be copied to clipboard. Useful on platforms +such as macOS/Wayland that do not have the concept of primary selections. Note +that this is a security risk, as all programs, including websites open in your +browser can read the contents of the clipboard.''')) + +# }}}