Tuesday, May 13, 2014

Re: "set ttym=" on slackware

Last night I wrote:
> 3) With strace, I see that it happens after ~/.viminfo is read the
...
> That's vim writing the size of the file out (" 1L, 10C"), opening
> and reading viminfo, checking the working directory for about the
> 15th time, setting some tty ioctl()s, then it writes an escape
> sequence ("\33[>c"), detects (with select()) there is a response and
> reads that response in ("\33[>41;297;0c"), checks a few more times
> for input and then writes the file on the screen for the first time.
>
> The escape sequence "\33[>c" apparently prompts xterm to reply with
> a version escape sequence, which is read but not processed as a
> terminal response, and is instead treated as user input.
>
> I have not yet pinned down what function is sending that escape
> sequence.

The escape sequence is sent by may_req_termresponse() called from
main.c:895. The issue is not that the sequence is sent in error, it
is that check_termcode() in term.c is misparsing it.

":set termcap" shows me:

--- Terminal codes ---
... t_RV=^[[>c ...

That's the Request Version (or similar) code.

--- Terminal keys ---
... <DecMouse> ^[[ ...
... <NetMouse> ^[} ...
... <Mouse> ^[MG ...

With no "ttym=", there is no entry for <DecMouse> under "Terminal keys",
there is only the single entry for <Mouse>. And the DecMouse escape
sequence starts the same as a version response string from xterm, so
key_name[0] gets set in check_termcode(). Then when it reaches:

4066 #ifdef FEAT_TERMRESPONSE
4067 if (key_name[0] == NUL)
4068 {
4069 /* Check for xterm version string: "<Esc>[>{x};{vers};{y}c". Also

the if key_name[0] == NUL is false and the response is not parsed.

And why is <DecMouse> in there? It's over in check_mouse_termcode()
in os_unix.c:

3478 # ifdef FEAT_MOUSE_DEC
3479 /* conflicts with xterm mouse: "\033[" and "\033[M" */
3480 if (!use_xterm_mouse()
3481 # ifdef FEAT_GUI
3482 && !gui.in_use
3483 # endif
3484 )
3485 set_mouse_termcode(KS_DEC_MOUSE, (char_u *)(term_is_8bit(T_NAME)
3486 ? IF_EB("\233", CSI_STR) : IF_EB("\033[", ESC_STR "[")));
3487 else
3488 del_mouse_termcode(KS_DEC_MOUSE);
3489 # endif

By setting ttym to the empty string, use_xterm_mouse() is false, the GUI
not in use, so it adds this bogus mouse escape sequnce that confuses
check_termcode().

What's the best fix then? I'm guessing a check for ttym_flags being non-zero
to each of the set_mouse_termcode() if statements in check_mouse_termcode().

Elijah

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: