aboutsummaryrefslogtreecommitdiff
path: root/cmd-if-shell.c
Commit message (Collapse)AuthorAge
* if-shell doesn't need to queue its error message into a callback, and innicm2017-04-25
| | | | | fact it can't do so because the item it was working with will have been freed. Reported by Daniel Hahler.
* Get rid of the extra layer of flags and cmd_prepare() and just store thenicm2017-04-22
| | | | | | 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.
* Fix if-shell without a client (so in the config file). Reported by Theonicm2017-04-22
| | | | Buehler.
* Store state shared between multiple commands in the queue in a sharednicm2017-04-21
| | | | structure.
* If a #() command doesn't exit, use its most recent line of output (itnicm2017-04-20
| | | | | | | must be a full line). Don't let it redraw the status line more than once a second. Requested by someone about 10 years ago...
* Add a helper function for the most common format_create/defaults/expandnicm2017-03-08
| | | | pattern.
* Add a window or pane id "tag" to each format tree and use it to separatenicm2017-02-03
| | | | | | jobs, this means that if the same job is used for different windows or panes (for example in pane-border-format), it will be run separately for each pane.
* It is silly for cmd_list_parse to return an integer error when it couldnicm2017-01-15
| | | | just return NULL.
* Mass rename struct cmd_q to struct cmdq_item and related.nicm2016-10-16
|
* Rewrite command queue handling. Each client still has a command queue,nicm2016-10-16
| | | | | | | | | | | | | | | but there is also now a global command queue. Instead of command queues being dispatched on demand from wherever the command happens to be added, they are now all dispatched from the top level server loop. Command queues may now also include callbacks as well as commands, and items may be inserted after the current command as well as at the end. This all makes command queues significantly more predictable and easier to use, and avoids the complex multiple nested command queues used by source-file, if-shell and friends. A mass rename of struct cmdq to a better name (cmdq_item probably) is coming.
* Trying to do hooks generically is way too complicated and unreliable andnicm2016-10-13
| | | | | | | | | | | | | | | | | | confusing, particularly trying to automatically figure out what target hooks should be using. So simplify it: - drop before hooks entirely, they don't seem to be very useful; - commands with special requirements now fire their own after hook (for example, if they change session or window, or if they have -t and -s and need to choose which one the hook uses as current target); - commands with no special requirements can have the CMD_AFTERHOOK flag added and they will use the -t state. At the moment new-session, new-window, split-window fire their own hook, and display-message uses the flag. The remaining commands still need to be looked at.
* Add static in cmd-* and fix a few other nits.nicm2016-10-10
|
* Pass file/line to new command for if-shell so that errors appearnicm2016-10-09
| | | | sensibly.
* Expand client formats (like run-shell), from Stephen M Coakley.nicm2016-04-29
|
* Final parts of command hooks, add before- and after- hooks to each command.nicm2016-04-29
|
* Remove some more unused variables, and use RB_FOREACH_SAFE innicm2016-03-01
| | | | key_bindings_unref_table.
* Instead of combined flags for -c, -s, -t, split into different setsnicm2015-12-14
| | | | using an enum and simplify the parsing code.
* Use member names in cmd_entry definitions so I stop getting confusednicm2015-12-13
| | | | about the order.
* Instead of every command resolving the target (-t or -s) itself, preparenicm2015-12-13
| | | | | | | | | | | | | | | | 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.
* Add cmdq as an argument to format_create and add a format for thenicm2015-12-11
| | | | command name (will also be used for more later).
* Remove format_create_flags and just pass flags to format_create.nicm2015-12-08
|
* Memory leaks and an uninitialized part of utf8_data, from Patrick Palka.nicm2015-11-20
|
* Because pledge(2) does not allow us to pass directory file descriptorsnicm2015-10-31
| | | | | | | | | 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).
* Rename cmd_q dead flag to a general flags bitmask (will be more flags later).nicm2015-09-16
|
* Set working directory for run-shell and if-shell.nicm2015-04-24
|
* The free callback could end up being fired before the done callbacknicm2015-04-21
| | | | | (happens on Cygwin), so use a reference count instead of a single flag. SF bug 188 reported by "iceboy".
* Pass mouse events through to commands for if-shell.nicm2015-04-21
|
* Rewrite of tmux mouse support which was a mess. Instead of havingnicm2015-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | options for "mouse-this" and "mouse-that", mouse events may be bound as keys and there is one option "mouse" that turns on mouse support entirely (set -g mouse on). See the new MOUSE SUPPORT section of the man page for description of the key names and new flags (-t= to specify the pane or window under mouse as a target, and send-keys -M to pass through a mouse event). The default builtin bindings for the mouse are: bind -n MouseDown1Pane select-pane -t=; send-keys -M bind -n MouseDown1Status select-window -t= bind -n MouseDrag1Pane copy-mode -M bind -n MouseDrag1Border resize-pane -M To get the effect of turning mode-mouse off, do: unbind -n MouseDrag1Pane unbind -temacs-copy MouseDrag1Pane The old mouse options are now gone, set-option -q may be used to suppress warnings if mixing configuration files.
* Wrap all the individual format_* calls in a single format_defaultsnicm2015-02-05
| | | | functions.
* Add -F to if-shell to allow it to be used to check for format or optionnicm2014-12-02
| | | | values rather than executing a command.
* Instead of setting up the default keys by building the key structnicm2014-10-20
| | | | | | | | | directly with a helper function in the cmd_entry, include a table of bind-key commands and pass them through the command parser and a temporary cmd_q. As well as being smaller, this will allow default bindings to be command sequences which will probably be needed soon.
* Make cmdq->client_exit a tristate (-1 means "not set") so that ifnicm2013-10-10
| | | | | explicitly set it can be copied from child to parent cmdq by if-shell and source-file. This fixes using attach or new. From Chris Johnsen.
* Try to establish client for run-shell and if-shell if no -t.Nicholas Marriott2013-03-25
|
* Extend jobs to support writing and use that for copy-pipe instead ofNicholas Marriott2013-03-25
| | | | popen, from Chris Johnsen.
* Add a command queue to standardize and simplify commands that call otherNicholas Marriott2013-03-24
| | | | | | | | | | | | | | | | | | | | | | 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.
* Expand format variables in the run-shell and if-shell shell commands,Nicholas Marriott2013-03-24
| | | | from Thiago Padilha.
* Add functions to allocate and free command contexts rather than doing itNicholas Marriott2013-03-22
| | | | all on the stack.
* Remove dead code, from Sean Estabrooks.Nicholas Marriott2012-08-11
|
* Make command exec functions return an enum rather than -1/0/1 values andNicholas Marriott2012-07-11
| | | | | | 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.
* xfree is not particularly helpful, remove it. From Thomas Adam.Nicholas Marriott2012-07-10
|
* Didn't really think the else behaviour through - requiring argv toNicholas Marriott2011-10-27
| | | | | contain "else" is silly so just omit that, also some manpage tweaks. From Tiago Cunha.
* Add an else clause for if-shell, from "arno-" on SourceForge.Nicholas Marriott2011-10-18
|
* Nuke a redundant if statement, from Tiago Cunha.Nicholas Marriott2011-05-25
|
* Simplify the way jobs work and drop the persist type, so all jobs areNicholas Marriott2011-01-26
| | | | | | | | | | | | | | | | | fire-and-forget. Status jobs now managed with two trees of output (new and old), rather than storing the output in the jobs themselves. When the status line is processed any jobs which don't appear in the new tree are started and the output from the old tree displayed. When a job finishes it updates the new tree with its output and that is used for any subsequent redraws. When the status interval expires, the new tree is moved to the old so that all jobs are run again. This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands of identical persistent jobs and high memory use (this can still be achieved by adding "sleep 30" but that is much less likely to happen by accident).
* Clean up and simplify tmux command argument parsing.Nicholas Marriott2011-01-04
| | | | | | | | | | | | | | | | | | | Originally, tmux commands were parsed in the client process into a struct with the command data which was then serialised and sent to the server to be executed. The parsing was later moved into the server (an argv was sent from the client), but the parse step and intermediate struct was kept. This change removes that struct and the separate parse step. Argument parsing and printing is now common to all commands (in arguments.c) with each command left with just an optional check function (to validate the arguments at parse time), the exec function and a function to set up any key bindings (renamed from the old init function). This is overall more simple and consistent. There should be no changes to any commands behaviour or syntax although as this touches every command please watch for any unexpected changes.
* When changing so that the client passes its stdout and stderr as well asNicholas Marriott2010-07-24
| | | | | | | | | | | | | | | | | | stdin up to the server, I forgot one essential point - the tmux server could now be both the producer and consumer. This happens when tmux is run inside tmux, as well as when piping tmux commands together. So, using stdio(3) was a bad idea - if sufficient data was written, this could block in write(2). When that happened and the server was both producer and consumer, it deadlocks. Change to use libevent bufferevents for the client stdin, stdout and stderr instead. This is trivial enough for output but requires a callback mechanism to trigger when stdin is finished. This relies on the underlying polling mechanism for libevent to work with whatever devices to which the user could redirect stdin, stdout or stderr, hence the change to use poll(2) over kqueue(2) for tmux.
* Return the command client return code with MSG_EXIT now that MSG_ERROR andNicholas Marriott2010-07-11
| | | | | | | MSG_PRINT are unused. New clients should be compatible with old tmux servers but vice versa may print an error.
* Get rid of the ugly CMD_CHFLAG macro and use a const string (eg "dDU") in theNicholas Marriott2009-11-13
| | | | command entry structs and a couple of functions to check/set the flags.
* Add a flag for jobs that shouldn't be freed after they've died and use it forNicholas Marriott2009-11-01
| | | | | | | status jobs, then only kill those jobs when status-left, status-right or set-titles-string is changed. Fixes problems with changing options from inside #().
* Convert if-shell over to the background job framework as well.Nicholas Marriott2009-10-11
|