Re: [hackers] [st][PATCH v2] Add support for DSR response "OK" escape sequence

From: Alexe Stefan <stefanalexe48_AT_gmail.com>
Date: Thu, 9 Feb 2023 00:56:43 +0200

You could use sizeof -1 instead of strlen to get the same thing

mie., 8 feb. 2023, 21:16 Adam Price <komidore64_AT_gmail.com> a scris:

> ---
> Feedback rightfully indicated I should use strlen() rather than sizeof()
> to avoid writing an unintentional null byte to the tty.
>
>
> st.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/st.c b/st.c
> index 34c27ad..603cf95 100644
> --- a/st.c
> +++ b/st.c
> _AT__AT_ -1769,11 +1769,18 @@ csihandle(void)
> case 'm': /* SGR -- Terminal attribute (color) */
> tsetattr(csiescseq.arg, csiescseq.narg);
> break;
> - case 'n': /* DSR – Device Status Report (cursor position) */
> - if (csiescseq.arg[0] == 6) {
> + case 'n': /* DSR – Device Status Report */
> + switch (csiescseq.arg[0]) {
> + case 5: /* Status Report "OK" `0n` */
> + ttywrite("\033[0n", strlen("\033[0n"), 0);
> + break;
> + case 6: /* Report Cursor Position (CPR) `<row>;<column>R`
> */
> len = snprintf(buf, sizeof(buf), "\033[%i;%iR",
> term.c.y+1, term.c.x+1);
> ttywrite(buf, len, 0);
> + break;
> + default:
> + goto unknown;
> }
> break;
> case 'r': /* DECSTBM -- Set Scrolling Region */
> --
> 2.39.1
>
>
>
Received on Wed Feb 08 2023 - 23:56:43 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 09 2023 - 00:36:36 CET