Patch 9.0.0972

3 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 29, 2022, 11:10:01 AM11/29/22
to vim...@googlegroups.com

Patch 9.0.0972 (after 9.0.0971)
Problem: Build failure on some systems.
Solution: Adjust #ifdefs related to the termresponse feature.
Files: src/term.c, src/message.c, src/drawscreen.c


*** ../vim-9.0.0971/src/term.c 2022-11-29 13:59:07.362045291 +0000
--- src/term.c 2022-11-29 15:56:37.470644552 +0000
***************
*** 66,81 ****
static int term_is_builtin(char_u *name);
static int term_7to8bit(char_u *p);

- #ifdef HAVE_TGETENT
- static char *invoke_tgetent(char_u *, char_u *);
-
- /*
- * Here is our own prototype for tgetstr(), any prototypes from the include
- * files have been disabled by the define at the start of this file.
- */
- char *tgetstr(char *, char **);
-
- # ifdef FEAT_TERMRESPONSE
// Change this to "if 1" to debug what happens with termresponse.
# if 0
# define DEBUG_TERMRESPONSE
--- 66,71 ----
***************
*** 85,90 ****
--- 75,90 ----
# define LOG_TR(msg) do { /**/ } while (0)
# endif

+ #ifdef HAVE_TGETENT
+ static char *invoke_tgetent(char_u *, char_u *);
+
+ /*
+ * Here is our own prototype for tgetstr(), any prototypes from the include
+ * files have been disabled by the define at the start of this file.
+ */
+ char *tgetstr(char *, char **);
+ #endif
+
typedef enum {
STATUS_GET, // send request when switching to RAW mode
STATUS_SENT, // did send request, checking for response
***************
*** 97,103 ****
time_t tr_start; // when request was sent, -1 for never
} termrequest_T;

! # define TERMREQUEST_INIT {STATUS_GET, -1}

// Request Terminal Version status:
static termrequest_T crv_status = TERMREQUEST_INIT;
--- 97,103 ----
time_t tr_start; // when request was sent, -1 for never
} termrequest_T;

! # define TERMREQUEST_INIT {STATUS_GET, -1}

// Request Terminal Version status:
static termrequest_T crv_status = TERMREQUEST_INIT;
***************
*** 108,114 ****
// Request xterm compatibility check:
static termrequest_T xcc_status = TERMREQUEST_INIT;

! # ifdef FEAT_TERMINAL
// Request foreground color report:
static termrequest_T rfg_status = TERMREQUEST_INIT;
static int fg_r = 0;
--- 108,115 ----
// Request xterm compatibility check:
static termrequest_T xcc_status = TERMREQUEST_INIT;

! #ifdef FEAT_TERMRESPONSE
! # ifdef FEAT_TERMINAL
// Request foreground color report:
static termrequest_T rfg_status = TERMREQUEST_INIT;
static int fg_r = 0;
***************
*** 117,123 ****
static int bg_r = 255;
static int bg_g = 255;
static int bg_b = 255;
! # endif

// Request background color report:
static termrequest_T rbg_status = TERMREQUEST_INIT;
--- 118,124 ----
static int bg_r = 255;
static int bg_g = 255;
static int bg_b = 255;
! # endif

// Request background color report:
static termrequest_T rbg_status = TERMREQUEST_INIT;
***************
*** 152,159 ****
// MAYBE -> tried outputting t_8u while FALSE
// OK -> can write t_8u
int write_t_8u_state = FALSE;
! # endif

/*
* Don't declare these variables if termcap.h contains them.
* Autoconf checks if these variables should be declared extern (not all
--- 153,161 ----
// MAYBE -> tried outputting t_8u while FALSE
// OK -> can write t_8u
int write_t_8u_state = FALSE;
! #endif

+ #ifdef HAVE_TGETENT
/*
* Don't declare these variables if termcap.h contains them.
* Autoconf checks if these variables should be declared extern (not all
***************
*** 1406,1411 ****
--- 1408,1414 ----
static char_u termleader[256 + 1]; // for check_termcode()
#ifdef FEAT_TERMRESPONSE
static int check_for_codes = FALSE; // check for key code response
+ #endif

/*
* Structure and table to store terminal features that can be detected by
***************
*** 1467,1473 ****
if (all || term_props[i].tpr_set_by_termresponse)
term_props[i].tpr_status = TPR_UNKNOWN;
}
- #endif

#if defined(FEAT_EVAL) || defined(PROTO)
void
--- 1470,1475 ----
***************
*** 1619,1625 ****
set_string_option_direct((char_u *)"t_Co", -1, nr_colors, OPT_FREE, 0);
}

- #if defined(FEAT_TERMRESPONSE)
/*
* Set the color count to "val" and redraw if it changed.
*/
--- 1621,1626 ----
***************
*** 1628,1652 ****
{
if (val != t_colors)
{
! // Nr of colors changed, initialize highlighting and
! // redraw everything. This causes a redraw, which usually
! // clears the message. Try keeping the message if it
! // might work.
set_keep_msg_from_hist();
set_color_count(val);
init_highlight(TRUE, FALSE);
! # ifdef DEBUG_TERMRESPONSE
{
int r = redraw_asap(UPD_CLEAR);

log_tr("Received t_Co, redraw_asap(): %d", r);
}
! # else
redraw_asap(UPD_CLEAR);
! # endif
}
}
- #endif

#ifdef HAVE_TGETENT
static char *(key_names[]) =
--- 1629,1651 ----
{
if (val != t_colors)
{
! // Nr of colors changed, initialize highlighting and redraw everything.
! // This causes a redraw, which usually clears the message. Try keeping
! // the message if it might work.
set_keep_msg_from_hist();
set_color_count(val);
init_highlight(TRUE, FALSE);
! #ifdef DEBUG_TERMRESPONSE
{
int r = redraw_asap(UPD_CLEAR);

log_tr("Received t_Co, redraw_asap(): %d", r);
}
! #else
redraw_asap(UPD_CLEAR);
! #endif
}
}

#ifdef HAVE_TGETENT
static char *(key_names[]) =
***************
*** 4552,4558 ****
termcodes[i] = termcodes[i + 1];
}

- #ifdef FEAT_TERMRESPONSE
/*
* Called when detected that the terminal sends 8-bit codes.
* Convert all 7-bit codes to their 8-bit equivalent.
--- 4551,4556 ----
***************
*** 4580,4586 ****
detected_8bit = TRUE;
LOG_TR(("Switching to 8 bit"));
}
- #endif

#ifdef CHECK_DOUBLE_CLICK
static linenr_T orig_topline = 0;
--- 4578,4583 ----
***************
*** 4815,4822 ****
// Figure out more if the response is CSI > 99 ; 99 ; 99 c
if (first == '>' && argc == 3)
{
- int need_flush = FALSE;
-
// mintty 2.9.5 sends 77;20905;0c.
// (77 is ASCII 'M' for mintty.)
if (arg[0] == 77)
--- 4812,4817 ----
***************
*** 4825,4830 ****
--- 4820,4826 ----
term_props[TPR_MOUSE].tpr_status = TPR_MOUSE_SGR;
}

+ #ifdef FEAT_TERMRESPONSE
// If xterm version >= 141 try to get termcap codes. For other
// terminals the request should be ignored.
if (version >= 141 && p_xtermcodes)
***************
*** 4834,4839 ****
--- 4830,4836 ----
need_gather = TRUE;
req_codes_from_term();
}
+ #endif

// libvterm sends 0;100;0
// Konsole sends 0;115;0 and works the same way
***************
*** 4962,4971 ****
--- 4959,4970 ----
set_string_option_direct((char_u *)"t_8u", -1, (char_u *)"",
OPT_FREE, 0);
}
+ #ifdef FEAT_TERMRESPONSE
if (*T_8U != NUL && write_t_8u_state == MAYBE)
// Did skip writing t_8u, a complete redraw is needed.
redraw_later_clear();
write_t_8u_state = OK; // can output t_8u now
+ #endif

// Only set 'ttymouse' automatically if it was not set
// by the user already.
***************
*** 4978,4983 ****
--- 4977,4985 ----
? (char_u *)"sgr" : (char_u *)"xterm2", 0);
}

+ #ifdef FEAT_TERMRESPONSE
+ int need_flush = FALSE;
+
// Only request the cursor style if t_SH and t_RS are
// set. Only supported properly by xterm since version
// 279 (otherwise it returns 0x18).
***************
*** 5013,5018 ****
--- 5015,5021 ----

if (need_flush)
out_flush();
+ #endif
}
}

***************
*** 5245,5250 ****
--- 5248,5254 ----
key_name[1] = (int)KE_IGNORE;
}

+ #ifdef FEAT_TERMRESPONSE
// Check blinking cursor from xterm:
// {lead}?12;1$y set
// {lead}?12;2$y not set
***************
*** 5263,5272 ****
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
*slen = csi_len;
! #ifdef FEAT_EVAL
set_vim_var_string(VV_TERMBLINKRESP, tp, *slen);
! #endif
}

// Kitty keyboard protocol status response: CSI ? flags u
else if (first == '?' && argc == 1 && trail == 'u')
--- 5267,5277 ----
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
*slen = csi_len;
! # ifdef FEAT_EVAL
set_vim_var_string(VV_TERMBLINKRESP, tp, *slen);
! # endif
}
+ #endif

// Kitty keyboard protocol status response: CSI ? flags u
else if (first == '?' && argc == 1 && trail == 'u')
***************
*** 5291,5296 ****
--- 5296,5302 ----
*slen = csi_len;
}

+ #ifdef FEAT_TERMRESPONSE
// Check for a window position response from the terminal:
// {lead}3;{x};{y}t
else if (did_request_winpos && argc == 3 && arg[0] == 3
***************
*** 5306,5311 ****
--- 5312,5318 ----
if (--did_request_winpos <= 0)
winpos_status.tr_progress = STATUS_GOT;
}
+ #endif

// Key with modifier:
// {lead}27;{modifier};{key}~
***************
*** 5372,5378 ****
char_u *tp_r = tp + j + 7;
char_u *tp_g = tp + j + (is_4digit ? 12 : 10);
char_u *tp_b = tp + j + (is_4digit ? 17 : 13);
! #ifdef FEAT_TERMINAL
int rval, gval, bval;

rval = hexhex2nr(tp_r);
--- 5379,5385 ----
char_u *tp_r = tp + j + 7;
char_u *tp_g = tp + j + (is_4digit ? 12 : 10);
char_u *tp_b = tp + j + (is_4digit ? 17 : 13);
! #if defined(FEAT_TERMRESPONSE) && defined(FEAT_TERMINAL)
int rval, gval, bval;

rval = hexhex2nr(tp_r);
***************
*** 5385,5395 ****
*tp_b) ? "light" : "dark";

LOG_TR(("Received RBG response: %s", tp));
rbg_status.tr_progress = STATUS_GOT;
! #ifdef FEAT_TERMINAL
bg_r = rval;
bg_g = gval;
bg_b = bval;
#endif
if (!option_was_set((char_u *)"bg")
&& STRCMP(p_bg, new_bg_val) != 0)
--- 5392,5404 ----
*tp_b) ? "light" : "dark";

LOG_TR(("Received RBG response: %s", tp));
+ #ifdef FEAT_TERMRESPONSE
rbg_status.tr_progress = STATUS_GOT;
! # ifdef FEAT_TERMINAL
bg_r = rval;
bg_g = gval;
bg_b = bval;
+ # endif
#endif
if (!option_was_set((char_u *)"bg")
&& STRCMP(p_bg, new_bg_val) != 0)
***************
*** 5401,5407 ****
redraw_asap(UPD_CLEAR);
}
}
! #ifdef FEAT_TERMINAL
else
{
LOG_TR(("Received RFG response: %s", tp));
--- 5410,5416 ----
redraw_asap(UPD_CLEAR);
}
}
! #if defined(FEAT_TERMRESPONSE) && defined(FEAT_TERMINAL)
else
{
LOG_TR(("Received RFG response: %s", tp));
***************
*** 5468,5476 ****
--- 5477,5487 ----
if ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')
|| tp[i] == STERM)
{
+ #ifdef FEAT_TERMRESPONSE
// handle a key code response, drop a resource response
if (i - j >= 3 && argp[2] == 'r')
got_code_from_term(tp + j, i);
+ #endif
key_name[0] = (int)KS_EXTRA;
key_name[1] = (int)KE_IGNORE;
*slen = i + 1 + (tp[i] == ESC);
***************
*** 5493,5500 ****
if (i - j == 6 && tp[i] != ESC && tp[i] != STERM)
break;
if ((i - j == 6 && tp[i] == STERM)
! || (i - j == 7 && tp[i] == '\\'))
{
int number = argp[3] - '0';

// 0, 1 = block blink, 2 = block
--- 5504,5512 ----
if (i - j == 6 && tp[i] != ESC && tp[i] != STERM)
break;
if ((i - j == 6 && tp[i] == STERM)
! || (i - j == 7 && tp[i] == '\\'))
{
+ #ifdef FEAT_TERMRESPONSE
int number = argp[3] - '0';

// 0, 1 = block blink, 2 = block
***************
*** 5507,5512 ****
--- 5519,5525 ----
initial_cursor_shape_blink =
(number & 1) ? FALSE : TRUE;
rcs_status.tr_progress = STATUS_GOT;
+ #endif
LOG_TR(("Received cursor shape response: %s", tp));

key_name[0] = (int)KS_EXTRA;
*** ../vim-9.0.0971/src/message.c 2022-11-18 22:14:04.802988148 +0000
--- src/message.c 2022-11-29 15:57:25.298839921 +0000
***************
*** 1417,1423 ****
keep_msg_attr = attr;
}

- #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
/*
* If there currently is a message being displayed, set "keep_msg" to it, so
* that it will be displayed again after redraw.
--- 1417,1422 ----
***************
*** 1429,1435 ****
&& (State & MODE_NORMAL))
set_keep_msg(last_msg_hist->msg, last_msg_hist->attr);
}
- #endif

/*
* Prepare for outputting characters in the command line.
--- 1428,1433 ----
*** ../vim-9.0.0971/src/drawscreen.c 2022-11-07 12:16:46.393761740 +0000
--- src/drawscreen.c 2022-11-29 15:58:20.535048295 +0000
***************
*** 2917,2923 ****
}
#endif

- #if defined(FEAT_TERMRESPONSE) || defined(PROTO)
/*
* Redraw as soon as possible. When the command line is not scrolled redraw
* right away and restore what was on the command line.
--- 2917,2922 ----
***************
*** 3049,3055 ****

return ret;
}
- #endif

/*
* Invoked after an asynchronous callback is called.
--- 3048,3053 ----
*** ../vim-9.0.0971/src/version.c 2022-11-29 13:59:07.362045291 +0000
--- src/version.c 2022-11-29 15:43:57.717285694 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 972,
/**/

--
When I die, I want to go peacefully in my sleep like my grandfather.
Not screaming in terror, like his passengers.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages