Re: [PATCH] libmisc/shell: Work around tmux bug in row and column
On 13.12.23 03:47, chr...@rtems.org wrote: +/* + *https://github.com/tmux/tmux/issues/3457 + * + * Tmux has a bug where the lines and cols are swapped. There is a lag + * in the time it takes to get the fix into code so see if tmux is + * running and which version and work around the bug. + * + * CSI > Ps q + *Ps = 0 => DCS > | text ST + */ +fputs("\033[>0q", stdout); +fflush(stdout); +if (rtems_shell_term_wait_for(fd, "\033P>|", timeout)) { + int len = rtems_shell_term_buffer_until(fd, buf, sizeof(buf), "\033\\", timeout); + if (len > 0) { +if (memcmp(buf, "tmux ", 5) == 0) { + static const char* bad_versions[] = { static const char* const bad_versions +"3.2", "3.2a", "3.3", "3.3a" + }; + #define bad_versions_num (sizeof(bad_versions) / sizeof(bad_versions[0])) + size_t i; + for (i = 0; i < bad_versions_num; ++i) { Maybe use RTEMS_ARRAY_SIZE(bad_versions_num). +if (strcmp(bad_versions[i], buf + 5) == 0) { + row_cols_swapped = true; + break; +} + } +} + } +} Maybe this should be placed in a helper function which returns row_cols_swapped? -- embedded brains GmbH & Co. KG Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] libmisc/shell: Work around tmux bug in row and column
On 13/12/2023 5:32 pm, Sebastian Huber wrote: > On 13.12.23 03:47, chr...@rtems.org wrote: >> + /* >> + *https://github.com/tmux/tmux/issues/3457 >> + * >> + * Tmux has a bug where the lines and cols are swapped. There is a >> lag >> + * in the time it takes to get the fix into code so see if tmux is >> + * running and which version and work around the bug. >> + * >> + * CSI > Ps q >> + * Ps = 0 => DCS > | text ST >> + */ >> + fputs("\033[>0q", stdout); >> + fflush(stdout); >> + if (rtems_shell_term_wait_for(fd, "\033P>|", timeout)) { >> + int len = rtems_shell_term_buffer_until(fd, buf, sizeof(buf), >> "\033\\", timeout); >> + if (len > 0) { >> + if (memcmp(buf, "tmux ", 5) == 0) { >> + static const char* bad_versions[] = { > > static const char* const bad_versions > >> + "3.2", "3.2a", "3.3", "3.3a" >> + }; >> + #define bad_versions_num (sizeof(bad_versions) / >> sizeof(bad_versions[0])) >> + size_t i; >> + for (i = 0; i < bad_versions_num; ++i) { > > Maybe use RTEMS_ARRAY_SIZE(bad_versions_num). Sure >> + if (strcmp(bad_versions[i], buf + 5) == 0) { >> + row_cols_swapped = true; >> + break; >> + } >> + } >> + } >> + } >> + } > > Maybe this should be placed in a helper function which returns > row_cols_swapped? > Sorry, I am not sure I understand. Are you suggesting the version detection against the string in the buffer is in a helper function? Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] libmisc/shell: Work around tmux bug in row and column
On 13.12.23 07:36, Chris Johns wrote: Sorry, I am not sure I understand. Are you suggesting the version detection against the string in the buffer is in a helper function? Yes, this complete new code block. -- embedded brains GmbH & Co. KG Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] libmisc/shell: Work around tmux bug in row and column
On 13/12/2023 5:37 pm, Sebastian Huber wrote: > On 13.12.23 07:36, Chris Johns wrote: >> Sorry, I am not sure I understand. Are you suggesting the version detection >> against the string in the buffer is in a helper function? > > Yes, this complete new code block. The query for the terminal type as well? :) Chris ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH] libmisc/shell: Work around tmux bug in row and column
On 13.12.23 03:47, chr...@rtems.org wrote: +const int timeout = 150; +bool row_cols_swapped = false; memset(&buf[0], 0, sizeof(buf)); +/* + *https://github.com/tmux/tmux/issues/3457 + * + * Tmux has a bug where the lines and cols are swapped. There is a lag + * in the time it takes to get the fix into code so see if tmux is + * running and which version and work around the bug. + * + * CSI > Ps q + *Ps = 0 => DCS > | text ST + */ +fputs("\033[>0q", stdout); +fflush(stdout); +if (rtems_shell_term_wait_for(fd, "\033P>|", timeout)) { + int len = rtems_shell_term_buffer_until(fd, buf, sizeof(buf), "\033\\", timeout); + if (len > 0) { +if (memcmp(buf, "tmux ", 5) == 0) { + static const char* bad_versions[] = { +"3.2", "3.2a", "3.3", "3.3a" + }; + #define bad_versions_num (sizeof(bad_versions) / sizeof(bad_versions[0])) + size_t i; + for (i = 0; i < bad_versions_num; ++i) { +if (strcmp(bad_versions[i], buf + 5) == 0) { + row_cols_swapped = true; + break; +} + } +} + } +} I think the above new code block could be moved to a helper function which returns the value of row_cols_swapped. -- embedded brains GmbH & Co. KG Herr Sebastian HUBER Dornierstr. 4 82178 Puchheim Germany email: sebastian.hu...@embedded-brains.de phone: +49-89-18 94 741 - 16 fax: +49-89-18 94 741 - 08 Registergericht: Amtsgericht München Registernummer: HRB 157899 Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler Unsere Datenschutzerklärung finden Sie hier: https://embedded-brains.de/datenschutzerklaerung/ ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel