szermatt / mistty

Shell/Comint alternative with a fully functional terminal for Emacs 29.1 and later.
GNU General Public License v3.0
102 stars 5 forks source link

Clarify fullscreen mode #17

Closed cole-jacobs closed 5 months ago

cole-jacobs commented 6 months ago

Hey, awesome package! I'm really enjoying it, but I'm a little confused about fullscreen mode. The documentation says

"MisTTY detects when a program such as less or vi asks to run full screen and splits the MisTTY buffers into... a terminal buffer [and a]... scrollback buffer... C-c C-j or M-x mistty-toggle-buffers switches between these two.

I'm not sure if I've misconfigured something or if my other packages are causing conflict, but fullscreen mode doesn't work for me.

I'm using GNU Emacs 29.3 on macOS 14.4.1.

szermatt commented 6 months ago

The most common cause of MisTTY not detecting when a program like vi wants to switch to fullscreen mode is if the program is not communicating with the terminal properly. The same issue tends to cause very weird display and input errors - though I have no idea what would make Emacs crash.

What is the value of the TERM environment variable on your shell? That's what vi uses to figure out how to communicate with its terminal.

If you type, in your shell: echo $TERM You must get back eterm-color for things to work properly. If you're getting something else, check your shell init script and, at worse, reset the TERM environment variable to eterm-color.

Note that when MisTTY switches to fullscreen mode, a message appears saying "Fullscreen mode ON" and the status line display the buffer mode as Term instead of mistty. If you don't see it when you launch vi, something's still wrong.

cole-jacobs commented 6 months ago

Thanks for the response! I'm still not sure what my issue is, and I'm sorry I'm not providing providing a more helpful report here. echo $TERM reports eterm-color as it should. I tried with multiple shells (my default shell is zsh, but I also tried both bash and fish), and I got the same result when running emacs -Q (I typically use doom)

szermatt commented 6 months ago

Did you try other tools that switch to fullscreen, such as less? Do they behave sanely? If yes, the particular version of vi you're running might be handling terminals in an unusual way.

If you run M-x ansi-term then start a shell and start vi, does it behave as it should? If yes, there's a problem with MisTTY, if no, that's a problem that both MisTTY and term-mode have.

If you run infocmp eterm-color from inside a MisTTY buffer, what do you get? If you get an error, then that means that the definition of eterm-color is missing for some reason. Emacs normally sets the env variables TERMCAP and TERMINFO for that.

cole-jacobs commented 6 months ago

Did you try other tools that switch to fullscreen, such as less? Do they behave sanely?

I did try less -- mistty still reports that it's not in fullscreen mode.

If you run M-x ansi-term then start a shell and start vi, does it behave as it should?

Yeah, things appear to behave correctly in ansi-term

If you run infocmp eterm-color from inside a MisTTY buffer, what do you get?

Here's the output of infocmp eterm-color:

❯ infocmp eterm-color
#       Reconstructed via infocmp from file: /usr/share/terminfo/65/eterm-color
eterm-color|Emacs term.el terminal emulator term-protocol-version 0.96,
        am, mir, msgr, xenl,
        colors#8, cols#80, lines#24, pairs#64,
        bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[J, cr=^M,
        csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
        cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
        cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
        dch=\E[%p1%dP, dch1=\E[P, dl=\E[%p1%dM, dl1=\E[M, ed=\E[J,
        el=\E[K, el1=\E[1K, home=\E[H, ht=^I, ich=\E[%p1%d@,
        il=\E[%p1%dL, il1=\E[L, ind=^J, invis=\E[8m, kbs=\177,
        kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
        kdch1=\E[3~, kend=\E[4~, khome=\E[1~, kich1=\E[2~,
        knp=\E[6~, kpp=\E[5~, op=\E[39;49m, rc=\E8, rev=\E[7m,
        ri=\EM, rmir=\E[4l, rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
        sc=\E7, setab=\E[%p1%'('%+%dm, setaf=\E[%p1%{30}%+%dm,
        sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;m,
        sgr0=\E[m, smir=\E[4h, smso=\E[7m, smul=\E[4m,
        u6=\E[%i%d;%dR, u7=\E[6n,

None of that means anything to me, but I'll read up on it. FWIW I spun up a linux vm and re-tested and mistty worked perfectly! I noticed the output from infocmp term-color was different too, so maybe that's the issue.

szermatt commented 6 months ago

The output of infocmp eterm-color is indeed interesting, because it doesn't define the fullscreen-mode switching capabilities. smcup=\E[47h and rmcup=\E[47l are missing. The active definition of eterm-color seems to be from a version of Emacs < 29.1 installed in /usr/share/terminfo/65/eterm-color

Normally, on Macos, the definition is read from the Emacs installation, from $TERMINFO/e/eterm-color.ti or directly from $TERMCAP. These env variables, set by Emacs, should take precedence. Something's not working as it should.

A simple fix for you would be to install your own updated version of eterm-color in your home: tic -x -o ~/.terminfo $TERMINFO/e/eterm-color.ti So you don't have to worry about env variables.

If TERMINFO isn't set properly by Emacs, you'll find e/eterm-color.ti in the Emacs installation. It's usually in /Applications/Emacs.app/Contents/Resources/etc/ but if you installed it using homebrew, you might find it in a location such as /usr/local/Cellar/emacs-mac/emacs-29.3-mac-10.0/share/emacs/29.3/etc/ You can also just copy it from Linux if it's easier.

cole-jacobs commented 6 months ago

tic -x -o ~/.terminfo $TERMINFO/e/eterm-color.ti solved it for me! I haven't figured out what caused the issue in the first place.. is macOS bundling a bad version? Did something go wrong when installing from homebrew? If I discover the answer I'll gladly update the thread for others, but for now I think we can close this issue. Thank you very much for your help!