[PATCH] libmisc/shell: Work around tmux bug in row and column
Chris Johns
chrisj at rtems.org
Wed Dec 13 06:36:10 UTC 2023
On 13/12/2023 5:32 pm, Sebastian Huber wrote:
> On 13.12.23 03:47, chrisj at 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
More information about the devel
mailing list