Allow specifying a marker when launching windows

This commit is contained in:
Kovid Goyal
2020-01-15 07:22:32 +05:30
parent 24d45b99e3
commit 9c3390c5e6
3 changed files with 13 additions and 1 deletions

View File

@@ -890,6 +890,7 @@ def cmd_launch(global_opts, opts, args):
stdin_add_formatting: Boolean indicating whether to add formatting codes to stdin stdin_add_formatting: Boolean indicating whether to add formatting codes to stdin
stdin_add_line_wrap_markers: Boolean indicating whether to add line wrap markers to stdin stdin_add_line_wrap_markers: Boolean indicating whether to add line wrap markers to stdin
no_response: Boolean indicating whether to send back the window id no_response: Boolean indicating whether to send back the window id
marker: Specification for marker for new window, for example: "text 1 ERROR"
''' '''
if opts.no_response: if opts.no_response:
global_opts.no_command_response = True global_opts.no_command_response = True

View File

@@ -116,6 +116,9 @@ want to pipe to program that wants to duplicate the screen layout of the
screen. screen.
--marker
Create a marker that highlights text in the newly created window. The syntax is
the same as for the :opt:`toggle_marker` map action.
''' '''
options_spec.ans = OPTIONS options_spec.ans = OPTIONS
return options_spec.ans return options_spec.ans
@@ -178,6 +181,8 @@ def launch(boss, opts, args, target_tab=None):
kw['override_title'] = opts.window_title kw['override_title'] = opts.window_title
if opts.copy_colors and active: if opts.copy_colors and active:
kw['copy_colors_from'] = active kw['copy_colors_from'] = active
if opts.marker:
kw['marker'] = opts.marker
cmd = args or None cmd = args or None
if opts.copy_cmdline and active_child: if opts.copy_cmdline and active_child:
cmd = active_child.foreground_cmdline cmd = active_child.foreground_cmdline

View File

@@ -263,7 +263,7 @@ class Tab: # {{{
def new_window( def new_window(
self, use_shell=True, cmd=None, stdin=None, override_title=None, self, use_shell=True, cmd=None, stdin=None, override_title=None,
cwd_from=None, cwd=None, overlay_for=None, env=None, location=None, cwd_from=None, cwd=None, overlay_for=None, env=None, location=None,
copy_colors_from=None, allow_remote_control=False copy_colors_from=None, allow_remote_control=False, marker=None
): ):
child = self.launch_child( child = self.launch_child(
use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd, env=env, allow_remote_control=allow_remote_control) use_shell=use_shell, cmd=cmd, stdin=stdin, cwd_from=cwd_from, cwd=cwd, env=env, allow_remote_control=allow_remote_control)
@@ -275,6 +275,12 @@ class Tab: # {{{
# Must add child before laying out so that resize_pty succeeds # Must add child before laying out so that resize_pty succeeds
get_boss().add_child(window) get_boss().add_child(window)
self._add_window(window, location=location) self._add_window(window, location=location)
if marker:
try:
window.set_marker(marker)
except Exception:
import traceback
traceback.print_exc()
return window return window
def new_special_window(self, special_window, location=None, copy_colors_from=None, allow_remote_control=False): def new_special_window(self, special_window, location=None, copy_colors_from=None, allow_remote_control=False):