terminator icon indicating copy to clipboard operation
terminator copied to clipboard

Tmux control mode v2

Open iamjackg opened this issue 3 years ago • 14 comments

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.

iamjackg avatar Mar 21 '21 22:03 iamjackg

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

iamjackg avatar Mar 21 '21 22:03 iamjackg

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.

mattrose avatar Mar 21 '21 23:03 mattrose

No worries! Honestly the majority of the credit goes to Manno and the original contributors.

I still feel like this approach might not be right and we might want to switch to a model where Tmux is driving the entirety of the logic, but that's a bit too far for me and my limited free time! :P

On Sun, Mar 21, 2021, at 19:24, Matt Rose wrote:

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.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gnome-terminator/terminator/pull/408#issuecomment-803679109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUSPLWNIBO7U26QPYVI6CTTEZ52RANCNFSM4ZSBKJFQ.

iamjackg avatar Mar 21 '21 23:03 iamjackg

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 avatar Mar 21 '21 23:03 mattrose

Yay, tests pass!

mattrose avatar Mar 22 '21 19:03 mattrose

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

iamjackg avatar Apr 06 '21 14:04 iamjackg

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 avatar Apr 06 '21 18:04 mattrose

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 avatar Apr 08 '21 20:04 mattrose

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.

mattrose avatar Apr 08 '21 21:04 mattrose

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.

iamjackg avatar Apr 10 '21 14:04 iamjackg

@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

ya-isakov avatar May 08 '21 12:05 ya-isakov

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.

iamjackg avatar Jun 17 '21 14:06 iamjackg

Thanks so much for staying with this.

mattrose avatar Jun 17 '21 15:06 mattrose

I left a comment about this on #79.

iamjackg avatar Jul 03 '21 02:07 iamjackg