Commit Graph

38 Commits (master)

Author SHA1 Message Date
nicm daec63e5e6 Replace %% in command lists (by copying them) for template arguments ,
this means they can be used with {} as well. Also make argument
processing from an existing vector preserve commands. GitHub issue 2858.
2021-08-27 17:25:55 +00:00
nicm 110ba767e5 Rename a member to match what it will be in future. 2021-08-21 10:28:05 +00:00
nicm 08e6360f23 Add args parsing callback for some future work, currently unused. 2021-08-21 10:22:38 +00:00
nicm 5f32b7d961 Hide struct args behind a couple of accessor functions. 2021-08-20 19:50:16 +00:00
nicm 90dd474c3e Expose args_value struct (will be needed soon) and add some missing frees. 2021-08-20 18:59:53 +00:00
nicm f03b61131b Drop having a separate type for style options and make them all strings,
which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
  fg and bg are stored in the pane struct and act as the defaults that
  can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
  them in sync.
2020-05-16 15:01:30 +00:00
nicm 04cdd03525 Also move cmdq_item and cmdq_list into cmd-queue.c (this is to make its
use more clearly defined and preparation for some future work).
2020-04-13 10:59:58 +00:00
nicm c20eb0c0ae Make struct cmd local to cmd.c and move it out of tmux.h. 2020-04-13 08:26:27 +00:00
nicm cc8b41f294 Add a way to mark environment variables as "hidden" so they can be used
by tmux but are not passed into the environment of new panes.
2020-03-31 17:14:40 +00:00
nicm c4b0da5513 Support multiple occurances of the same argument. Use this for a new
flag -e to new-window, split-window, respawn-window, respawn-pane to
pass environment variables into the newly created process. From Steffen
Christgau in GitHub issue 1697.
2019-04-28 20:05:50 +00:00
nicm 78287e27c8 Break new window and pane creation common code from various commands and
window.c into a separate file spawn.c.
2019-04-17 14:37:48 +00:00
nicm 3f6bfbaf2b Allow multiple modes to be open in a pane. A stack of open modes is kept
and the previous restored when the top is exited. If a mode that is
already on the stack is entered, the existing instance is moved to the
top as the active mode rather than being opened new.
2019-03-12 11:16:49 +00:00
nicm 11e2af6df7 Add -c for respawn-pane and respawn-window, from J Raynor. 2017-07-21 09:17:19 +00:00
nicm c48d09ec88 Do not update TERM into config file parsing has finished. 2017-04-25 15:35:10 +00:00
nicm ee45a8a149 Get rid of the extra layer of flags and cmd_prepare() and just store the
CMD_FIND_* flags in the cmd_entry and call it for the command. Commands
with special requirements call it themselves and update the target for
hooks to use.
2017-04-22 10:22:39 +00:00
nicm dbfee6a468 Move server_fill_environ into environ.c and move some other common code
into it.
2017-03-09 17:02:38 +00:00
nicm b342bd0b46 Mass rename struct cmd_q to struct cmdq_item and related. 2016-10-16 19:04:05 +00:00
nicm a81685bfac Add static in cmd-* and fix a few other nits. 2016-10-10 21:51:39 +00:00
nicm 995af0e2b7 I no longer use my SourceForge address so replace it. 2016-01-19 15:59:12 +00:00
nicm a3129fd4e8 Instead of combined flags for -c, -s, -t, split into different sets
using an enum and simplify the parsing code.
2015-12-14 00:31:54 +00:00
nicm ecfeee2e82 Use member names in cmd_entry definitions so I stop getting confused
about the order.
2015-12-13 21:53:57 +00:00
nicm 4a4daf1303 Instead of every command resolving the target (-t or -s) itself, prepare
the state (client, session, winlink, pane) for it it before entering the
command. Each command provides some flags that tell the prepare step
what it is expecting.

This is a requirement for having hooks on commands (for example, if you
hook "select-window -t1:2", the hook command should to operate on window
1:2 not whatever it thinks is the current window), and should allow some
other target improvements.

The old cmd_find_* functions remain for the moment but that layer will
be dropped later.

Joint work with Thomas Adam.
2015-12-13 14:32:38 +00:00
nicm 01defc9f49 Because pledge(2) does not allow us to pass directory file descriptors
around, we can't use file descriptors for the working directory because
we will be unable to pass it to a privileged process to tell it where to
read or write files or spawn children. So move tmux back to using
strings for the current working directory. We try to check it exists
with access() when it is set but ultimately fall back to ~ if it fails
at time of use (or / if that fails too).
2015-10-31 08:13:58 +00:00
nicm bf9c933cae Like options, move the environ struct into environ.c. 2015-10-28 09:51:55 +00:00
nicm 02df86079b Fix some format specifier nits, from Ben Boeckel. 2015-03-31 17:45:10 +00:00
nicm 7afe417a60 Missed a couple of cmd_entry struct members from previous. 2014-10-20 22:34:31 +00:00
nicm b3e8d440ed If multiple arguments are given to new-session, new-window,
split-window, respawn-window or respawn-pane, pass them directly to
execvp() to help avoid quoting problems. One argument still goes to "sh
-c" like before. Requested by many over the years. Patch from J Raynor.
2014-05-13 08:08:32 +00:00
nicm 3e27be353d Set PATH explicitly, either from client or session
environment. Previously it came from the session environment. From J
Raynor.
2014-04-17 13:02:59 +00:00
nicm b85de1ddb3 Pass -1 for cwd now not NULL. 2013-10-10 12:29:53 +00:00
nicm d45c12b6c9 Remove the barely-used and unnecessary command check() function. 2013-10-10 12:00:18 +00:00
Nicholas Marriott 20636d956d Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.
2013-03-24 09:54:10 +00:00
Nicholas Marriott ede8312d59 Make command exec functions return an enum rather than -1/0/1 values and
add a new value to mean "leave client running but don't attach" to fix
problems with using some commands in a command sequence. Most of the
work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-11 07:10:15 +00:00
Nicholas Marriott df912e3540 xfree is not particularly helpful, remove it. From Thomas Adam. 2012-07-10 11:53:01 +00:00
Nicholas Marriott 4f480c901d $Id$ -> $OpenBSD$. 2012-03-17 22:34:12 +00:00
Nicholas Marriott 57df442916 Make window_pane_index work the same as window_index, from Ben Boeckel. 2011-11-15 23:19:51 +00:00
Nicholas Marriott 7e423ea491 Unused variable. 2011-07-09 01:37:00 +00:00
Nicholas Marriott a70379d8f9 Use screen_reinit for respawn-pane to keep history and call input_init
for respawn-window to break out of waiting for DCS/OSC to finish.
2011-07-04 13:35:37 +00:00
Nicholas Marriott 65177b82be Add a respawn-pane command, from Marcel Partap. 2011-06-05 11:19:03 +00:00