#151 FLTK console command prompt display problems

v0.7.x (release)
closed-fixed
nobody
5
2009-02-15
2009-02-12
Shai
No

I've experienced issues with the FLTK console (colinux-console-fltk.exe) but was unable to reproduce the problem systematically. What would happen is that using the command line, either with tab-completion or with scroll history (ctrl-p/up-arrow) at times text would not be cleared properly, leaving leftover text from the previously entered command. I've finally managed to pinpoint the problem and it appears to be related to all these issues (tab completion, history, backspace, etc.)

To reproduce the problem, in a bash shell using colinux-console-fltk.exe, do the following:
1. Type a very long string, at least 40 characters, say:
$ 1234567890123456789012345678901234567890
Now, press ctrl-a to get to the start of the line and press delete three times. What you'll see is this:
$ 4567890123456789012345678901222234567890

Notice how the digit 2 towards the end of the string are multiplied 4 times. The right output should be of course:
$ 4567890123456789012345678901234567890

There are many other ways to cause this to happen, and it appears to be happening when the command string length is about 40 characters long.

Configuration: this happens on Windows XP SP3; both version 0.8.x and 0.7.3. This does not happen on colinux-console-nt.exe as far as I could tell.

Thanks,

- Shai

Discussion

  • Shai

    Shai - 2009-02-15

    The cause for this is the number of bytes to memmov() function call in file src/colinux/common/console.c, it should be multiplied by the sizeof(co_console_cell_t). There are two calls to memmov() that don't multiply by the sizeof value. Since the sizeof(co_console_cell_t) is probably 2 bytes long (character and attribute), this very easily explains the reason why after 40 bytes on a 80 characters monitor text appears wrong.

    This is the modification that seems to be working for me:
    *** console.c Sun Feb 15 03:15:10 2009
    --- console_old.c Sun Feb 15 03:14:39 2009
    ***************
    *** 176,182 ****
    while (t <= b) {
    memmove(&console->screen[y*console->x+x],
    &console->screen[t*console->x+l],
    ! (r-l+1)*sizeof(co_console_cell_t));
    t++;
    y++;
    }
    --- 176,182 ----
    while (t <= b) {
    memmove(&console->screen[y*console->x+x],
    &console->screen[t*console->x+l],
    ! r-l+1);
    t++;
    y++;
    }
    ***************
    *** 185,191 ****
    while (t <= b) {
    memmove(&console->screen[y*console->x+x],
    &console->screen[b*console->x+l],
    ! (r-l+1)*sizeof(co_console_cell_t));
    b--;
    y--;
    }
    --- 185,191 ----
    while (t <= b) {
    memmove(&console->screen[y*console->x+x],
    &console->screen[b*console->x+l],
    ! r-l+1);
    b--;
    y--;
    }

    I've only tested it on Windows XP with coLinux version 0.8.0 (but I think it should fix 0.7.3 as well).

    This might also explain other related issues with the FLTK console display.

    - Shai

     
  • Henry N.

    Henry N. - 2009-02-15

    Thanks, committed to SVN as revision r1224.

     
  • Henry N.

    Henry N. - 2009-02-15
    • labels: --> Daemons (Windows)
    • status: open --> closed-fixed