Commit Graph

35 Commits

Author SHA1 Message Date
Johannes Altmanninger
746e0d032f rc windowing: allow to configure windowing system and window placement in new/terminal commands
Today I can control "terminal" and "new" by changing the terminal
alias but I always need to choose a concrete implementation, like
"tmux-terminal-horizontal", even when there is otherwise no need to
mention tmux in my config.

Allow to configure windowing system and window placement independently
by introducing dedicated options.

This allows to create mappings that work in any windowing system like

	map global user c   %{:with-option windowing_placement window new<ret>}
	map global user '"' %{:with-option windowing_placement vertical new<ret>}
	map global user '%' %{:with-option windowing_placement horizontal new<ret>}

For windowing systems that don't support all placements, you can wrap
the above in try/catch to fall back on the "window" variant which is
defined for all windowing systems.

When using multiple (nested) windowing systems, you might want to
add mappings like

	map global user t %{:with-option windowing_module tmux new<ret>}
	map global user T %{:with-option windowing_module wayland new<ret>}

---

This changes the default "terminal" alias for some modules. In
particular, instead of delegating to

    iterm-terminal-vertical
    screen-terminal-vertical
    tmux-terminal-horizontal
    wezterm-terminal-vertical

it will now by default delegate to the respective "-window" variant.
We could maintain backwards compatiblity here by setting the
"windowing_placement" option accordingly, but the new behavior seems
more logical?

Also, this removes the "terminal-tab" alias which was only defined
by the kitty module.

We could try to keep the alias approach and implement a "with-alias"
command, however that approach can only capture both dimensions
(windowing system and placement) if we add tons of commands
like "terminal-horizontal" (with implied windowing system) and
"tmux-terminal" (with implied placement).

Side thought: we could also get rid of the "focus" alias and instead
define

    define-command focus %{
        "%opt{windowing_module}-focus"
    }

Closes #3943, #4425
2023-11-13 22:54:49 +01:00
Hampus Fröjdholm
7c54de2334 Match against kitty window id directly when using kitty @ launch
When launch matches using `id` kitty tries to match against tab id
before matching windows. When there are multiple tabs it's likely to
match a tab before matching a window.

Use `window_id` directly to avoid any possiblity of matching tabs.

This is only needed for `kitty @ launch` for other commands there is
no specific `window_id` field.
2023-05-07 17:06:09 +02:00
Johannes Altmanninger
f69d8c3e12 rc repl tmux: always spawn repl in calling client
Just like the parent commit but for tmux-repl-* commands.

Note that tmux-repl-set-pane without arguments is kind of broken; it
increments the current pane ID, which only works in the most basic
scenarios. We should probably replace it with something better,
with menu completions etc.
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
37dcba9089 rc repl tmux: do not record repl session/window since pane might move
A pane's ID is immutable for the lifetime of the tmux server.
Same with window/session IDs.
When creating a new tmux repl, we record all three IDs to later use
them to send text to the repl.
The window/session IDs can be invalidating when a pane is moved to
a different window/session (via "tmux move-pane", "tmux move-window"
etc). This will cause repl-send-text to fail.
Fix this by dropping the redundant and potentially incorrect
window/session IDs.  The immutable pane ID is enough.
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
9891f11157 rc repl tmux: remove bashisms 2022-11-19 15:21:38 +01:00
Johannes Altmanninger
79db90349d rc repl tmux: show error when the repl pane is gone
tmux-send-text would silently fail when the repl is no more.  Let's
instead print an error, pointing the user to the *debug* buffer which
has tmux' stderr.
2022-11-19 15:21:38 +01:00
Johannes Altmanninger
9190fa9b5f rc repl: complete tmux-repl with shell commands, not Kakoune commands 2022-07-21 16:48:44 +02:00
Maxime Coste
7061001728 Add a complete-command command to configure command completion
This makes it possible to change command completion in hooks and
paves the way to more flexibility in how custom commands can be
completed
2022-03-06 10:13:14 +11:00
Maxime Coste
13eb5a677f Merge remote-tracking branch 'StatPal/master' into HEAD 2021-08-28 13:55:11 +10:00
Subrata
25ffbacb70 In the tmux-repl, it tackles the situations where there is already some other tmux pane open
and we want to send text (or do other works) in that specific pane.
2021-08-22 09:57:09 -05:00
Tilman List
0d74268451 add module dtach-repl 2021-08-21 18:42:29 +02:00
basbebe
1183e716bc
make kitty repl command consistent with other kitty commands 2021-03-11 10:40:14 +01:00
Matthew Forrester
e1db59fb8d rc repl x11: do not send new line
The X11 repl is unique in that it sends the selection (or parameter) with a
new line appended.

This patch removes that new line and thus, brings it into line with the tmux
and kitty versions.
2021-02-05 06:04:16 +00:00
Matthew Forrester
c9d50660f1 rc repl x11: allow arg for repl send & refocus kak
tmux-send-text allows sending an argument, when supplied the argument
will be sent to the REPL instead of the current selection.

tmux-send-text also keeps kak focussed, which does not happen in the x11
variant as it uses xdotool to switch window.

this patch allows:

 * Passing an argument to x11-send-text, so that value will be sent
 instead of the current selection.
 * We capture the window id of the current (presumably kak window)
 before we use xdotool to switch window. We can therefore switch back to
 kak afterwards (which we do)
2021-01-16 15:57:32 +00:00
Hao Deng
d6c96dc456
Update tmux.kak
When $1 or ${kak_selection} start with dash, like "-1", the command will fail, because tmux think it's an argument flag.
-- prevent this.
Also the doc (append new line) is no longer valid.
2020-12-30 16:11:02 -05:00
Maxime Coste
6cf3c13d97 Merge remote-tracking branch 'listentolist/tmux-repl' into master 2020-11-08 14:53:38 +11:00
Tilman List
d545d2c181 if the $WINDOWID is not set, use xdotool to get the window id 2020-10-30 14:35:20 +01:00
Tilman List
a5dbeeb5ee simplify x11-repl by using x11-terminal 2020-10-30 12:19:53 +01:00
Tilman List
9955cfdd8d changed scope of tmux_repl_id from global to current
By setting the tmux_repl_id in the `current` scope it is possible to have
different REPLs for different buffers or windows.
2020-10-27 17:20:33 +01:00
Tilman List
de6e86da46 changed the way the x11 REPL interaction works
Now it uses the window id to identify the REPL window. It is stored in
the option x11_repl_id. That way it is possible to have different REPLs
for different buffers or windows.
2020-10-27 14:26:27 +01:00
Frank LENORMAND
87f9be6723 rc repl: Normalise REPL commands
It's unclear what the `send-text` alias does at first glance,
so prefixing it with "repl-" both fixes that and helps make it
discoverable via the command prompt's fuzzy matcher.

The `repl` alias also seems too generic a name, the "-new" suffix
should hopefully give a hint that it creates a new window.
2020-09-01 13:34:52 +03:00
Maxime Coste
4793a4e8ce Allow multiple arguments in tmux repl
Fixes #3680
2020-08-30 10:53:03 +10:00
Johannes Altmanninger
7d52bae5cb rc/x11: failure message when some external tools are missing
Addresses #3591
2020-07-28 20:32:56 +02:00
Philman
63c4336a3c
finetuned the :send-text command
See discussions on [github](https://github.com/philgee1981/kakoune/pull/1) and on [the kakoune message board](https://discuss.kakoune.com/t/trying-to-run-kakoune-repl-with-st-and-dwm/1122/3)
2020-07-03 06:46:41 +02:00
Jason Felice
d287251326 Split modules and allow kitty-send-text to take a parameter 2020-04-27 11:58:39 -04:00
Frank LENORMAND
275abb227e rc: Make docstrings more readable
This cosmetics commit makes use of the auto-deindentation syntax,
available to docstrings.
2020-02-03 20:53:28 +01:00
Frank LENORMAND
7b9ae595c0 rc repl tmux: Do not check for the Tmux version
This commit removes attempts to auto-detect the version of the local
Tmux binary.

The Tmux package that ships with OpenBSD doesn't have a version
number[1], and therefore doesn't provide any way to check if it's
compatible with the REPL module, making the feature disabled by
default in that distribution.

Fixes #3237.

[1] https://github.com/tmux/tmux/issues/1141#issuecomment-340244302
2019-12-10 12:15:08 +01:00
Frank LENORMAND
5b1f9255a1 rc: Use the standard fail command to report errors
Merely using `echo` with markup doesn't log errors in the debug
buffers, and is also less readable.
2019-11-14 08:32:55 +01:00
Jason Felice
6f443537e4 Accept tmux pre-release and rc versions 2019-10-22 10:25:41 -04:00
codesoap
ca2741fe20 Rename ModuleLoad hook to ModuleLoaded
This clarifies, that the hook is run *after* the module is loaded.
2019-06-25 19:16:47 +02:00
codesoap
df03a8850c Comment on the escape sequence for setting the terminal's title 2019-06-18 11:52:33 +02:00
codesoap
9d8fb8bc31 Print escape sequence to set the window title
Using xdotool was probably a little less portable, because it relied on
the newly created window to be activated by the window manager.
2019-06-18 11:41:59 +02:00
codesoap
feebad14b0 Set the REPL window title using xdotool
As mentioned in issue #2973, the -t argument for setting the terminal
title was not very portable.
2019-06-18 09:58:32 +02:00
Justin Frank
aa6d19bee6 Added modules to extra files 2019-04-08 17:05:55 -07:00
Alex Leferry 2
7d400dce7f Add windowing/repl category 2019-03-21 12:09:39 +01:00