Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tmux control mode v2 #408

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

iamjackg
Copy link

This is a cleanup of #378. A lot of changes went into this.

I spent the last couple of days getting it working. It's mostly usable at a basic level, but only if there is only one client connected at any one time. In short, the code is able to push all (most) state changes from Terminator to tmux, but it's not able to react to changes made by either an attached tmux instance or other Terminator instances attached to the same session.

If your workflow only involves having one backing headless instance of tmux running at all times and connecting/disconnecting one Terminator instance at a time, then this should be fine.

There are a few really gnarly incompatibilities between Terminator's features and what tmux allows. As an example, in Terminator you can change the zoom level of all panes independently, which is impossible in tmux. Doing it leads to very odd behaviour where a terminal appears to have a certain heightxwidth, but the backing tmux pane is actually smaller/bigger, and text wraps in odd ways in the other panes. I ended up disabling zooming and drag&drop altogether when in tmux mode.

There are other issues: tmux's window size includes all the pane separators, so if you set a client size of 80x20 and then split it in two you don't get two 40x20 terminals, but one 39x20 and one 40x20, because the vertical separator takes up a column. Terminator determines its window size excluding the separator(s). I tried to add functionality to keep them in sync, but this doesn't always work.

Feel free to give it a try and see if it works fine for you.

manno and others added 27 commits January 31, 2021 13:45
This is squashes the original commits from launchpad in 2016, since I
was unable to merge the complete history.

The main work has been done by Andrea and Dan: https://bugs.launchpad.net/terminator/+bug/1301605
For reference, this branch has the history from lp: https://github.com/manno/terminator/tree/tmux

Co-authored-by: Andrea Fagiani <[email protected]>
Co-authored-by: Dan Kilman <[email protected]>
imports, python3 strings/bytes, -M already used
multiprocessing.Queue actually has to pickle everything that goes through it. This is not possible in all cases, so the callbacks were not being added. This commit switches to an implementation that can instead find the needed function by name.
Not doing this results in double keypresses
Properly decode everywhere
Make a copy of removed pane ID keys, cleanup
@iamjackg
Copy link
Author

Ah, some tests are failing 😆 Didn't even notice those. I'll take a look later!

@mattrose
Copy link
Member

This is huge, but I think this'll be a real differentiator. I don't personally use tmux, so I may ask a bunch of questions in the process of checking it out. I have a mac with iTerm2 as well, so I may be able to help you out there. I'm usually hanging out on https://gitter.im/gnome-terminator/community if you want to chat about this. It's going to take a while to go through all the code, and just make sure I can understand at least the interface to the rest of terminator, if not understand the tmux code.

Thank you so much for this, it's why I love working on open source projects.

@iamjackg
Copy link
Author

iamjackg commented Mar 21, 2021 via email

@mattrose
Copy link
Member

Maybe you, or somebody else will come along and pick it up later and make more improvements, but If we can get this to a fit state where it can be released, that's a huge step, and will make it easier for later contributors. Thanks again.

@mattrose
Copy link
Member

Yay, tests pass!

@iamjackg
Copy link
Author

iamjackg commented Apr 6, 2021

Hey @mattrose! Did you get a chance to try this out?

@mattrose
Copy link
Member

mattrose commented Apr 6, 2021

Sorry I've been busy lately, and I wiped my normal terminator development machine, and it dropped off my radar a bit. I'll see if I can take a look today or tomorrow.

@mattrose
Copy link
Member

mattrose commented Apr 8, 2021

hmm, I get this error when running terminator -t

Traceback (most recent call last):
File "/home/mattrose/Code/terminator/terminator", line 50, in
from terminatorlib.terminator import Terminator
File "/home/mattrose/Code/terminator/terminatorlib/terminator.py", line 19, in
from .tmux import notifications
File "/home/mattrose/Code/terminator/terminatorlib/tmux/notifications.py", line 4, in
from terminatorlib.tmux import layout
File "/home/mattrose/Code/terminator/terminatorlib/tmux/layout.py", line 1, in
from pyparsing import *
ModuleNotFoundError: No module named 'pyparsing'

Is that a dependency for tmux?

@mattrose
Copy link
Member

mattrose commented Apr 8, 2021

Installed pyparsing and noticed one glaring thing which is that debug output is outputted constantly.

Also, I'm not sure how to use it with tmux. I tried terminator -t but that ... didn't work. It opened terminator, but it left the terminal in a weird state

I tried running tmux in a separate window, and tried terminator -t, and that just hung.

@iamjackg
Copy link
Author

Is that a dependency for tmux?

Ah yes, my bad -- I'll add it to setup.py.

As for the rest I'll try to take a look today. I started it again today and it's just... not working. Sigh. I might end up re-implementing this from scratch. And sorry about the debug messages, I thought I had removed all the useless ones during a cleanup, but I missed a bunch.

@ya-isakov
Copy link

ya-isakov commented May 8, 2021

@iamjackg Thank you a lot for working on this feature, which could be killer-feature for terminator. I've tried this MR today, and yes, terminator runs some tmux'es, but I cannot type anything. When I open new tab, I can see it in tmux a, and when I type something in tmux a, I can see it in terminator. Terminator is not opening new tab, when I create one in tmux a.

P.S. And sys.maxint is dropped from Python, so, please, use sys.maxsize for Wayland: https://docs.python.org/3.1/whatsnew/3.0.html#integers

@iamjackg
Copy link
Author

Just an update -- I haven't forgotten about this, I just haven't had much time to work on it. I started a complete rewrite that separates out the tmux control code into a separate library, because in its current form it's way too tied to the rest of the terminator code.

@mattrose
Copy link
Member

Thanks so much for staying with this.

@iamjackg
Copy link
Author

iamjackg commented Jul 3, 2021

I left a comment about this on #79.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants