class CreateMarker(RemoteCommand): ''' match: Which window to create the marker in self: Boolean indicating whether to create marker in the window the command is run in marker_spec: A list or arguments that define the marker specification, for example: ['text', '1', 'ERROR'] ''' short_desc = 'Create a marker that highlights specified text' desc = ( 'Create a marker which can highlight text in the specified window. For example: ' 'create_marker text 1 ERROR. For full details see: {}' ).format(website_url('marks')) options_spec = MATCH_WINDOW_OPTION + '''\n --self type=bool-set If specified apply marker to the window this command is run in, rather than the active window. ''' argspec = 'MARKER SPECIFICATION' def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: if len(args) < 2: self.fatal('Invalid marker specification: {}'.format(' '.join(args))) parse_marker_spec(args[0], args[1:]) return {'match': opts.match, 'self': opts.self, 'marker_spec': args} def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType: args = payload_get('marker_spec') for window in self.windows_for_match_payload(boss, window, payload_get): window.set_marker(args) return None
def remove_markup(text: str) -> str: ref_map = { 'layouts': f'{website_url("overview")}#layouts', 'sessions': f'{website_url("overview")}#startup-sessions', 'functional': f'{website_url("keyboard-protocol")}#functional-key-definitions', 'action-select_tab': f'{website_url("actions")}#select-tab', 'shell_integration': website_url("shell-integration"), } def sub(m: Match) -> str: if m.group(1) == 'ref': return ref_map[m.group(2)] return str(m.group(2)) return re.sub(r':([a-zA-Z0-9]+):`(.+?)`', sub, text, flags=re.DOTALL)
def ref_map() -> Dict[str, str]: from kitty.actions import get_all_actions ref_map = { 'layouts': f'{website_url("overview")}#layouts', 'watchers': f'{website_url("launch")}#watchers', 'sessions': f'{website_url("overview")}#startup-sessions', 'functional': f'{website_url("keyboard-protocol")}#functional-key-definitions', 'shell_integration': website_url("shell-integration"), } for actions in get_all_actions().values(): for ac in actions: ref_map[ f'action-{ac.name}'] = f'{website_url("actions")}#' + ac.name.replace( '_', '-') return ref_map
def ref_map() -> Dict[str, str]: from kitty.actions import get_all_actions ref_map = { 'layouts': f'{website_url("overview")}#layouts', 'include': f'{website_url("conf")}#include', 'watchers': f'{website_url("launch")}#watchers', 'sessions': f'{website_url("overview")}#startup-sessions', 'functional': f'{website_url("keyboard-protocol")}#functional-key-definitions', 'ssh_copy_command': f'{website_url("kittens/ssh")}#ssh-copy-command', 'shell_integration': website_url("shell-integration"), 'github_discussions': 'https://github.com/kovidgoyal/kitty/discussions', } for actions in get_all_actions().values(): for ac in actions: ref_map[f'action-{ac.name}'] = f'{website_url("actions")}#' + ac.name.replace('_', '-') return ref_map
needs_sphinx = '1.7' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode', 'sphinx.ext.githubpages', 'sphinx_copybutton', 'sphinx_inline_tabs', "sphinxext.opengraph", ] # URL for OpenGraph tags ogp_site_url = website_url() # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.
--customize-processing Name of a python file in the kitty config directory which will be imported to provide custom implementations for pattern finding and performing actions on selected matches. See {hints_url} for details. You can also specify absolute paths to load the script from elsewhere. --window-title The window title for the hints window, default title is selected based on the type of text being hinted. '''.format( default_regex=DEFAULT_REGEX, line='{{line}}', path='{{path}}', hints_url=website_url('kittens/hints'), ).format help_text = 'Select text from the screen using the keyboard. Defaults to searching for URLs.' usage = '' def parse_hints_args(args: List[str]) -> Tuple[HintsCLIOptions, List[str]]: return parse_args(args, OPTIONS, usage, help_text, 'kitty +kitten hints', result_class=HintsCLIOptions) def main(args: List[str]) -> Optional[Dict[str, Any]]: text = '' if sys.stdin.isatty(): if '--help' not in args and '-h' not in args: print('You must pass the text to be hinted on STDIN', file=sys.stderr) input(_('Press Enter to quit'))