Re: Patch 8.2.2345

2021-01-17 Fir de Conversatie John Marriott

Hi Bram,

I manually remove features that I don't need for each of my builds.
My work's HP-UX machine is very old and is lacking in resources so I try 
to keep the build as small as workable. Because with this machine I have 
no mouse capability I comment out all of the mouse related features in 
feature.h, including FEAT_MOUSE_XTERM.


Sorry for any confusion.

Cheers
John

On 16-Jan-2021 08:28, Bram Moolenaar wrote:

John Marriott wrote:


On 15-Jan-2021 03:35, Bram Moolenaar wrote:

Patch 8.2.2345
Problem:No focus events in a terminal.
Solution:   Add the t_fd and t_fe termcap entries and implement detecting
  focus events. (Hayaki Saito, Magnus Groß, closes #7673,
  closes #609, closes #5526)
Files:  runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h



After this patch, HP-UX spits out this linker error if FEAT_MOUSE_XTERM
is not defined:

   cc   -L/usr/local/lib -o vim objects/arabic.o

[...]


/usr/ccs/bin/ld: Unsatisfied symbols:
     use_xterm_like_mouse (first referenced in objects/term.o) (code)
link.sh: Linking doesn't work at all, removing auto/link.sed
*** Error exit code 1

Stop.
*** Error exit code 1

Stop.


It looks like a mismatch of #defines.
In term.c, lines 2057-2074 are conditionally included if UNIX or VMS are
defined. However, the function use_xterm_like_mouse() is only included
(in os_unix.c) if FEAT_MOUSE_XTERM or PROTO are also defined (line 2326).

Hmm, I wonder how you got the defines in this state.  The feature.h file
contains:

#if defined(UNIX) || defined(VMS)
# define FEAT_MOUSE_XTERM

We can adjust the #ifdef, but I still wonder why it doensn't work for
you currently.  Is FEAT_MOUSE_XTERM undefined somehow?



--
--
You received this message from the "vim_dev" 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_dev" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/04a36f76-6241-c42a-9fa6-e13da5421a9f%40internode.on.net.


Re: Patch 8.2.2345

2021-01-15 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> On 15-Jan-2021 03:35, Bram Moolenaar wrote:
> > Patch 8.2.2345
> > Problem:No focus events in a terminal.
> > Solution:   Add the t_fd and t_fe termcap entries and implement detecting
> >  focus events. (Hayaki Saito, Magnus Groß, closes #7673,
> >  closes #609, closes #5526)
> > Files:  runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h
> >
> >
> After this patch, HP-UX spits out this linker error if FEAT_MOUSE_XTERM 
> is not defined:
> 
>   cc   -L/usr/local/lib -o vim objects/arabic.o  

[...]

> /usr/ccs/bin/ld: Unsatisfied symbols:
>     use_xterm_like_mouse (first referenced in objects/term.o) (code)
> link.sh: Linking doesn't work at all, removing auto/link.sed
> *** Error exit code 1
> 
> Stop.
> *** Error exit code 1
> 
> Stop.
> 
> 
> It looks like a mismatch of #defines.
> In term.c, lines 2057-2074 are conditionally included if UNIX or VMS are 
> defined. However, the function use_xterm_like_mouse() is only included 
> (in os_unix.c) if FEAT_MOUSE_XTERM or PROTO are also defined (line 2326).

Hmm, I wonder how you got the defines in this state.  The feature.h file
contains:

#if defined(UNIX) || defined(VMS)
# define FEAT_MOUSE_XTERM

We can adjust the #ifdef, but I still wonder why it doensn't work for
you currently.  Is FEAT_MOUSE_XTERM undefined somehow?

-- 
hundred-and-one symptoms of being an internet addict:
157. You fum through a magazine, you first check to see if it has a web
 address.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202101152128.10FLS1Kc103999%40masaka.moolenaar.net.


Re: Patch 8.2.2345

2021-01-15 Fir de Conversatie John Marriott



On 15-Jan-2021 03:35, Bram Moolenaar wrote:

Patch 8.2.2345
Problem:No focus events in a terminal.
Solution:   Add the t_fd and t_fe termcap entries and implement detecting
 focus events. (Hayaki Saito, Magnus Groß, closes #7673,
 closes #609, closes #5526)
Files:  runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h


After this patch, HP-UX spits out this linker error if FEAT_MOUSE_XTERM 
is not defined:


 cc   -L/usr/local/lib -o vim objects/arabic.o  
objects/arglist.o  objects/autocmd.o objects/beval.o  objects/buffer.o  
objects/change.o objects/blob.o  objects/blowfish.o  objects/cindent.o 
objects/clientserver.o  objects/clipboard.o  objects/cmdexpand.o 
objects/cmdhist.o  objects/crypt.o  objects/crypt_zip.o 
objects/debugger.o  objects/dict.o  objects/diff.o objects/digraph.o  
objects/drawline.o  objects/drawscreen.o objects/edit.o  objects/eval.o  
objects/evalbuffer.o objects/evalfunc.o  objects/evalvars.o  
objects/evalwindow.o objects/ex_cmds.o  objects/ex_cmds2.o  
objects/ex_docmd.o objects/ex_eval.o  objects/ex_getln.o  
objects/fileio.o objects/filepath.o  objects/findfile.o  objects/fold.o 
objects/getchar.o  objects/gui_xim.o  objects/hardcopy.o 
objects/hashtab.o  objects/help.o  objects/highlight.o 
objects/if_cscope.o  objects/if_xcmdsrv.o  objects/indent.o 
objects/insexpand.o  objects/list.o  objects/locale.o objects/map.o  
objects/mark.o  objects/match.o  objects/mbyte.o objects/memline.o  
objects/menu.o  objects/misc1.o objects/misc2.o  objects/mouse.o  
objects/move.o objects/normal.o  objects/ops.o  objects/option.o 
objects/optionstr.o  objects/os_unix.o  objects/pathdef.o 
objects/popupmenu.o  objects/popupwin.o  objects/profiler.o 
objects/pty.o  objects/quickfix.o  objects/regexp.o objects/register.o  
objects/screen.o  objects/scriptfile.o objects/search.o  
objects/session.o  objects/sha256.o objects/sign.o  objects/sound.o  
objects/spell.o objects/spellfile.o  objects/spellsuggest.o  
objects/syntax.o objects/tag.o  objects/term.o  objects/terminal.o 
objects/testing.o  objects/textformat.o  objects/textobject.o 
objects/textprop.o  objects/time.o  objects/typval.o objects/ui.o  
objects/undo.o  objects/usercmd.o objects/userfunc.o  objects/version.o  
objects/vim9compile.o objects/vim9execute.o  objects/vim9script.o  
objects/vim9type.o objects/viminfo.o  objects/window.o 
objects/bufwrite.o  objects/xdiffi.o 
objects/xemit.o  objects/xprepare.o  objects/xutils.o 
objects/xhistogram.o  objects/xpatience.o objects/charset.o 
objects/json.o  objects/main.o  objects/memfile.o 
objects/message.o   -lm -ltermlib -lelf

/usr/ccs/bin/ld: Unsatisfied symbols:
   use_xterm_like_mouse (first referenced in objects/term.o) (code)
link.sh: Linking doesn't work at all, removing auto/link.sed
*** Error exit code 1

Stop.
*** Error exit code 1

Stop.


It looks like a mismatch of #defines.
In term.c, lines 2057-2074 are conditionally included if UNIX or VMS are 
defined. However, the function use_xterm_like_mouse() is only included 
(in os_unix.c) if FEAT_MOUSE_XTERM or PROTO are also defined (line 2326).


Cheers
John

--
--
You received this message from the "vim_dev" 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_dev" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/73bfc4c3-46fc-9021-0e18-0f1d6b72d249%40internode.on.net.


Re: Patch 8.2.2345

2021-01-14 Fir de Conversatie Bram Moolenaar


Christ van Willegen wrote:

> Op do 14 jan. 2021 17:36 schreef Bram Moolenaar :
> 
> >
> > Patch 8.2.2345
> > Problem:No focus events in a terminal.
> > Solution:   Add the t_fd and t_fe termcap entries and implement detecting
> > focus events. (Hayaki Saito, Magnus Gro=C3=9F, closes #7673,
> > closes #609, closes #5526)
> > Files:  runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.=
> h
> >
> >
> >
> > +   {
> > +   int did_aucmd =3D FALSE;
> > +
> > +   if (key_name[1] =3D=3D KE_FOCUSGAINED && !focus_state)
> > +   {
> > +   did_aucmd =3D apply_autocmds(EVENT_FOCUSGAINED,
> > +   NULL, NULL, FALSE,
> > curbuf);
> > +   did_cursorhold =3D TRUE;
> > +   focus_state =3D TRUE;
> > +   key_name[1] =3D (int)KE_IGNORE;
> > +   }
> > +   else if (key_name[1] =3D=3D KE_FOCUSLOST && focus_state)
> > +   {
> > +   did_aucmd =3D apply_autocmds(EVENT_FOCUSLOST,
> > +   NULL, NULL, FALSE,
> > curbuf);
> > +   did_cursorhold =3D TRUE;
> > +   focus_state =3D FALSE;
> > +   key_name[1] =3D (int)KE_IGNORE;
> > +   }
> > +   if (did_aucmd && (State & (NORMAL | INSERT | TERMINAL)))
> > +   {
> > +   // in case a message was displayed: reposition the cursor
> > +   setcursor();
> > +   out_flush();
> > +   }
> > +   }
> > + #endif
> >
> 
> If the (Un)focus escape sequence happens to be sent twice, the key_name[1]
> will not be set to KE_IGNORE. Is that a problem?

It should not happen, but if it does happen it would be a problem.
It's easy enough to change.

-- 
hundred-and-one symptoms of being an internet addict:
149. You find your computer sexier than your girlfriend

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202101142058.10EKwNGr1690741%40masaka.moolenaar.net.


Re: Patch 8.2.2345

2021-01-14 Fir de Conversatie Christ van Willegen
Hi,

Op do 14 jan. 2021 17:36 schreef Bram Moolenaar :

>
> Patch 8.2.2345
> Problem:No focus events in a terminal.
> Solution:   Add the t_fd and t_fe termcap entries and implement detecting
> focus events. (Hayaki Saito, Magnus Groß, closes #7673,
> closes #609, closes #5526)
> Files:  runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h
>
>
>
> +   {
> +   int did_aucmd = FALSE;
> +
> +   if (key_name[1] == KE_FOCUSGAINED && !focus_state)
> +   {
> +   did_aucmd = apply_autocmds(EVENT_FOCUSGAINED,
> +   NULL, NULL, FALSE,
> curbuf);
> +   did_cursorhold = TRUE;
> +   focus_state = TRUE;
> +   key_name[1] = (int)KE_IGNORE;
> +   }
> +   else if (key_name[1] == KE_FOCUSLOST && focus_state)
> +   {
> +   did_aucmd = apply_autocmds(EVENT_FOCUSLOST,
> +   NULL, NULL, FALSE,
> curbuf);
> +   did_cursorhold = TRUE;
> +   focus_state = FALSE;
> +   key_name[1] = (int)KE_IGNORE;
> +   }
> +   if (did_aucmd && (State & (NORMAL | INSERT | TERMINAL)))
> +   {
> +   // in case a message was displayed: reposition the cursor
> +   setcursor();
> +   out_flush();
> +   }
> +   }
> + #endif
>

If the (Un)focus escape sequence happens to be sent twice, the key_name[1]
will not be set to KE_IGNORE. Is that a problem?

Christ van Willegen

>

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CA%2BOt1Oy5HYPqu65-pJDBaE5R3hqWUhG0-MdV6pFtMVggRkX_mg%40mail.gmail.com.


Re: Patch 8.2.2345

2021-01-14 Fir de Conversatie Bram Moolenaar


> Just tried to build and see -
> 
> term.c: In function ‘out_flush’:
> term.c:2553:5: error: ‘gui’ undeclared (first use in this function)
>  2553 |(gui.in_use && !gui.dying && !gui.starting)
>   | ^~~
> 
> Do I need a manual re-configure ?

Missing #ifdef.  This wasn't supposed to be part of this patch, but
slipt in anyway.  I'll send out a patch with the #ifdef.

-- 
Drink wet cement and get really stoned.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202101141819.10EIJi601647727%40masaka.moolenaar.net.


Re: Patch 8.2.2345

2021-01-14 Fir de Conversatie mckel...@gmail.com
Hi,

2347 fixes, thanks!

-m

On Thursday, January 14, 2021 at 12:31:22 PM UTC-5 mckel...@gmail.com wrote:

> Hi,
>
> Just tried to build and see -
>
> term.c: In function ‘out_flush’:
> term.c:2553:5: error: ‘gui’ undeclared (first use in this function)
>  2553 |(gui.in_use && !gui.dying && !gui.starting)
>   | ^~~
>
> Do I need a manual re-configure ?
>
> thx,
> -m
>
> On Thursday, January 14, 2021 at 11:36:05 AM UTC-5 Bram Moolenaar wrote:
>
>>
>> Patch 8.2.2345 
>> Problem: No focus events in a terminal. 
>> Solution: Add the t_fd and t_fe termcap entries and implement detecting 
>> focus events. (Hayaki Saito, Magnus Groß, closes #7673, 
>> closes #609, closes #5526) 
>> Files: runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h 
>>
>>
>> *** ../vim-8.2.2344/runtime/doc/term.txt 2020-12-29 20:53:28.299402080 
>> +0100 
>> --- runtime/doc/term.txt 2021-01-14 17:20:23.946278238 +0100 
>> *** 
>> *** 372,377  
>> --- 373,382  
>> t_Ri restore icon text from stack *t_Ri* *'t_Ri'* 
>> t_TE end of "raw" mode *t_TE* *'t_TE'* 
>> t_TI put terminal into "raw" mode *t_TI* *'t_TI'* 
>> + t_fd disable focus-event tracking *t_TI* *'t_TI'* 
>> + |xterm-focus-event| 
>> + t_fe enable focus-event tracking *t_TI* *'t_TI'* 
>> + |xterm-focus-event| 
>>
>> Some codes have a start, middle and end part. The start and end are 
>> defined 
>> by the termcap option, the middle part is text. 
>> *** 
>> *** 545,550  
>> --- 550,565  
>> value with the context menu (right mouse button while CTRL key is 
>> pressed), 
>> there should be a tick at allow-window-ops. 
>>
>> + *xterm-focus-event* 
>> + Some terminals including xterm support the focus event tracking 
>> feature. 
>> + If this feature is enabled by the 't_fe' sequence, special key 
>> sequences are 
>> + sent from the terminal to Vim every time the terminal gains or loses 
>> focus. 
>> + Vim fires focus events (|FocusGained|/|FocusLost|) by handling them 
>> accordingly. 
>> + Focus event tracking is disabled by a 't_fd' sequence when exiting 
>> "raw" mode. 
>> + If you would like to disable this feature, add the following to your 
>> .vimrc: 
>> + `set t_fd=` 
>> + `set t_fe=` 
>> + 
>> *termcap-colors* 
>> Note about colors: The 't_Co' option tells Vim the number of colors 
>> available. 
>> When it is non-zero, the 't_AB' and 't_AF' options are used to set the 
>> color. 
>> *** ../vim-8.2.2344/src/optiondefs.h 2020-08-11 21:58:12.585968185 +0200 
>> --- src/optiondefs.h 2021-01-14 17:20:23.946278238 +0100 
>> *** 
>> *** 2957,2962  
>> --- 2957,2964  
>> p_term("t_EC", T_CEC) 
>> p_term("t_EI", T_CEI) 
>> p_term("t_fs", T_FS) 
>> + p_term("t_fd", T_FD) 
>> + p_term("t_fe", T_FE) 
>> p_term("t_GP", T_CGP) 
>> p_term("t_IE", T_CIE) 
>> p_term("t_IS", T_CIS) 
>> *** ../vim-8.2.2344/src/term.c 2020-12-30 14:08:30.908689169 +0100 
>> --- src/term.c 2021-01-14 17:33:48.443716246 +0100 
>> *** 
>> *** 196,201  
>> --- 196,206  
>>
>> static int detected_8bit = FALSE; // detected 8-bit terminal 
>>
>> + #if (defined(UNIX) || defined(VMS)) 
>> + static int focus_mode = FALSE; // xterm's "focus reporting" 
>> availability 
>> + static int focus_state = FALSE; // TRUE if the terminal window gains 
>> focus 
>> + #endif 
>> + 
>> #ifdef FEAT_TERMRESPONSE 
>> // When the cursor shape was detected these values are used: 
>> // 1: block, 2: underline, 3: vertical bar 
>> *** 
>> *** 908,913  
>> --- 913,922  
>> {(int)KS_CRT, IF_EB("\033[23;2t", ESC_STR "[23;2t")}, 
>> {(int)KS_SSI, IF_EB("\033[22;1t", ESC_STR "[22;1t")}, 
>> {(int)KS_SRI, IF_EB("\033[23;1t", ESC_STR "[23;1t")}, 
>> + # if (defined(UNIX) || defined(VMS)) 
>> + {(int)KS_FD, IF_EB("\033[?1004l", ESC_STR "[?1004l")}, 
>> + {(int)KS_FE, IF_EB("\033[?1004h", ESC_STR "[?1004h")}, 
>> + # endif 
>>
>> {K_UP, IF_EB("\033O*A", ESC_STR "O*A")}, 
>> {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")}, 
>> *** 
>> *** 2044,2049  
>> --- 2053,2079  
>> set_mouse_termco

Re: Patch 8.2.2345

2021-01-14 Fir de Conversatie mckel...@gmail.com
Hi,

Just tried to build and see -

term.c: In function ‘out_flush’:
term.c:2553:5: error: ‘gui’ undeclared (first use in this function)
 2553 |(gui.in_use && !gui.dying && !gui.starting)
  | ^~~

Do I need a manual re-configure ?

thx,
-m

On Thursday, January 14, 2021 at 11:36:05 AM UTC-5 Bram Moolenaar wrote:

>
> Patch 8.2.2345
> Problem: No focus events in a terminal.
> Solution: Add the t_fd and t_fe termcap entries and implement detecting
> focus events. (Hayaki Saito, Magnus Groß, closes #7673,
> closes #609, closes #5526)
> Files: runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h
>
>
> *** ../vim-8.2.2344/runtime/doc/term.txt 2020-12-29 20:53:28.299402080 
> +0100
> --- runtime/doc/term.txt 2021-01-14 17:20:23.946278238 +0100
> ***
> *** 372,377 
> --- 373,382 
> t_Ri restore icon text from stack *t_Ri* *'t_Ri'*
> t_TE end of "raw" mode *t_TE* *'t_TE'*
> t_TI put terminal into "raw" mode *t_TI* *'t_TI'*
> + t_fd disable focus-event tracking *t_TI* *'t_TI'*
> + |xterm-focus-event|
> + t_fe enable focus-event tracking *t_TI* *'t_TI'*
> + |xterm-focus-event|
>
> Some codes have a start, middle and end part. The start and end are defined
> by the termcap option, the middle part is text.
> ***
> *** 545,550 
> --- 550,565 
> value with the context menu (right mouse button while CTRL key is pressed),
> there should be a tick at allow-window-ops.
>
> + *xterm-focus-event*
> + Some terminals including xterm support the focus event tracking feature.
> + If this feature is enabled by the 't_fe' sequence, special key sequences 
> are
> + sent from the terminal to Vim every time the terminal gains or loses 
> focus.
> + Vim fires focus events (|FocusGained|/|FocusLost|) by handling them 
> accordingly.
> + Focus event tracking is disabled by a 't_fd' sequence when exiting "raw" 
> mode.
> + If you would like to disable this feature, add the following to your 
> .vimrc:
> + `set t_fd=`
> + `set t_fe=`
> + 
> *termcap-colors*
> Note about colors: The 't_Co' option tells Vim the number of colors 
> available.
> When it is non-zero, the 't_AB' and 't_AF' options are used to set the 
> color.
> *** ../vim-8.2.2344/src/optiondefs.h 2020-08-11 21:58:12.585968185 +0200
> --- src/optiondefs.h 2021-01-14 17:20:23.946278238 +0100
> ***
> *** 2957,2962 
> --- 2957,2964 
> p_term("t_EC", T_CEC)
> p_term("t_EI", T_CEI)
> p_term("t_fs", T_FS)
> + p_term("t_fd", T_FD)
> + p_term("t_fe", T_FE)
> p_term("t_GP", T_CGP)
> p_term("t_IE", T_CIE)
> p_term("t_IS", T_CIS)
> *** ../vim-8.2.2344/src/term.c 2020-12-30 14:08:30.908689169 +0100
> --- src/term.c 2021-01-14 17:33:48.443716246 +0100
> ***
> *** 196,201 
> --- 196,206 
>
> static int detected_8bit = FALSE; // detected 8-bit terminal
>
> + #if (defined(UNIX) || defined(VMS))
> + static int focus_mode = FALSE; // xterm's "focus reporting" availability
> + static int focus_state = FALSE; // TRUE if the terminal window gains 
> focus
> + #endif
> + 
> #ifdef FEAT_TERMRESPONSE
> // When the cursor shape was detected these values are used:
> // 1: block, 2: underline, 3: vertical bar
> ***
> *** 908,913 
> --- 913,922 
> {(int)KS_CRT, IF_EB("\033[23;2t", ESC_STR "[23;2t")},
> {(int)KS_SSI, IF_EB("\033[22;1t", ESC_STR "[22;1t")},
> {(int)KS_SRI, IF_EB("\033[23;1t", ESC_STR "[23;1t")},
> + # if (defined(UNIX) || defined(VMS))
> + {(int)KS_FD, IF_EB("\033[?1004l", ESC_STR "[?1004l")},
> + {(int)KS_FE, IF_EB("\033[?1004h", ESC_STR "[?1004h")},
> + # endif
>
> {K_UP, IF_EB("\033O*A", ESC_STR "O*A")},
> {K_DOWN, IF_EB("\033O*B", ESC_STR "O*B")},
> ***
> *** 2044,2049 
> --- 2053,2079 
> set_mouse_termcode(KS_MOUSE, (char_u *)"\233M");
> #endif
>
> + #if (defined(UNIX) || defined(VMS))
> + // focus reporting is supported by xterm compatible terminals and tmux.
> + if (use_xterm_like_mouse(term))
> + {
> + char_u name[3];
> + name[0] = (int)KS_EXTRA;
> + name[2] = NUL;
> + 
> + // handle focus in event
> + name[1] = (int)KE_FOCUSGAINED;
> + add_termcode(name, (char_u *)"\033[I", FALSE);
> + 
> + // handle focus out event
> + name[1] = (int)KE_FOCUSLOST;
> + add_termcode(name, (char_u *)"\033[O", FALSE);
> + 
> + focus_mode = TRUE;
> + focus_state = TRUE;
> + }
> + #endif
> + 
> #ifdef US

Patch 8.2.2345

2021-01-14 Fir de Conversatie Bram Moolenaar


Patch 8.2.2345
Problem:No focus events in a terminal.
Solution:   Add the t_fd and t_fe termcap entries and implement detecting
focus events. (Hayaki Saito, Magnus Groß, closes #7673,
closes #609, closes #5526)
Files:  runtime/doc/term.txt, src/optiondefs.h, src/term.c, src/term.h


*** ../vim-8.2.2344/runtime/doc/term.txt2020-12-29 20:53:28.299402080 
+0100
--- runtime/doc/term.txt2021-01-14 17:20:23.946278238 +0100
***
*** 372,377 
--- 373,382 
t_Rirestore icon text from stack*t_Ri* *'t_Ri'*
t_TEend of "raw" mode   *t_TE* *'t_TE'*
t_TIput terminal into "raw" mode*t_TI* *'t_TI'*
+   t_fddisable focus-event tracking*t_TI* *'t_TI'*
+   |xterm-focus-event|
+   t_feenable focus-event tracking *t_TI* *'t_TI'*
+   |xterm-focus-event|
  
  Some codes have a start, middle and end part.  The start and end are defined
  by the termcap option, the middle part is text.
***
*** 545,550 
--- 550,565 
  value with the context menu (right mouse button while CTRL key is pressed),
  there should be a tick at allow-window-ops.
  
+   *xterm-focus-event*
+ Some terminals including xterm support the focus event tracking feature.
+ If this feature is enabled by the 't_fe' sequence, special key sequences are
+ sent from the terminal to Vim every time the terminal gains or loses focus.
+ Vim fires focus events (|FocusGained|/|FocusLost|) by handling them 
accordingly.
+ Focus event tracking is disabled by a 't_fd' sequence when exiting "raw" mode.
+ If you would like to disable this feature, add the following to your .vimrc:
+   `set t_fd=`
+   `set t_fe=`
+ 
*termcap-colors*
  Note about colors: The 't_Co' option tells Vim the number of colors available.
  When it is non-zero, the 't_AB' and 't_AF' options are used to set the color.
*** ../vim-8.2.2344/src/optiondefs.h2020-08-11 21:58:12.585968185 +0200
--- src/optiondefs.h2021-01-14 17:20:23.946278238 +0100
***
*** 2957,2962 
--- 2957,2964 
  p_term("t_EC", T_CEC)
  p_term("t_EI", T_CEI)
  p_term("t_fs", T_FS)
+ p_term("t_fd", T_FD)
+ p_term("t_fe", T_FE)
  p_term("t_GP", T_CGP)
  p_term("t_IE", T_CIE)
  p_term("t_IS", T_CIS)
*** ../vim-8.2.2344/src/term.c  2020-12-30 14:08:30.908689169 +0100
--- src/term.c  2021-01-14 17:33:48.443716246 +0100
***
*** 196,201 
--- 196,206 
  
  static int  detected_8bit = FALSE;// detected 8-bit terminal
  
+ #if (defined(UNIX) || defined(VMS))
+ static int focus_mode = FALSE; // xterm's "focus reporting" availability
+ static int focus_state = FALSE; // TRUE if the terminal window gains focus
+ #endif
+ 
  #ifdef FEAT_TERMRESPONSE
  // When the cursor shape was detected these values are used:
  // 1: block, 2: underline, 3: vertical bar
***
*** 908,913 
--- 913,922 
  {(int)KS_CRT, IF_EB("\033[23;2t", ESC_STR "[23;2t")},
  {(int)KS_SSI, IF_EB("\033[22;1t", ESC_STR "[22;1t")},
  {(int)KS_SRI, IF_EB("\033[23;1t", ESC_STR "[23;1t")},
+ #  if (defined(UNIX) || defined(VMS))
+ {(int)KS_FD,  IF_EB("\033[?1004l", ESC_STR "[?1004l")},
+ {(int)KS_FE,  IF_EB("\033[?1004h", ESC_STR "[?1004h")},
+ #  endif
  
  {K_UP,IF_EB("\033O*A", ESC_STR "O*A")},
  {K_DOWN,  IF_EB("\033O*B", ESC_STR "O*B")},
***
*** 2044,2049 
--- 2053,2079 
  set_mouse_termcode(KS_MOUSE, (char_u *)"\233M");
  #endif
  
+ #if (defined(UNIX) || defined(VMS))
+ // focus reporting is supported by xterm compatible terminals and tmux.
+ if (use_xterm_like_mouse(term))
+ {
+   char_u name[3];
+   name[0] = (int)KS_EXTRA;
+   name[2] = NUL;
+ 
+   // handle focus in event
+   name[1] = (int)KE_FOCUSGAINED;
+   add_termcode(name, (char_u *)"\033[I", FALSE);
+ 
+   // handle focus out event
+   name[1] = (int)KE_FOCUSLOST;
+   add_termcode(name, (char_u *)"\033[O", FALSE);
+ 
+   focus_mode = TRUE;
+   focus_state = TRUE;
+ }
+ #endif
+ 
  #ifdef USE_TERM_CONSOLE
  // DEFAULT_TERM indicates that it is the machine console.
  if (STRCMP(term, DEFAULT_TERM) != 0)
***
*** 2519,2525 
if (ch_log_output)
{
out_buf[len] = NUL;
!   ch_log(NULL, "raw terminal output: \"%s\"", out_buf);
ch