Skip to content

Design wcwidth replacement

Anton Lundin edited this page Nov 13, 2013 · 1 revision

Dumping this here so we got it for future reference:

17:04 < KeithW> On wcwidth, I think our best design so far was this:
17:06 < KeithW> (a) Terminal::Complete::diff_from() is amended so that every 
                time the terminal uses a new character (that it has never used 
                before), it also includes a hint as to the intended width of 
                that character, so that the receiver can build up a database of 
                what the widths are supposed to be.
17:07 < KeithW> (b) Upon getting this hint, the client (optionally) verifies 
                that it actually does advance the user's cursor as much as it 
                was supposed to. If it doesn't, it takes evasive action (like 
                manually putting the cursor in the right spot). This deals with 
                mismatches between server and client.
17:08 < KeithW> (c) The mosh-server ships with a file containing the width of 
                every character. It stops using the libc wcwidth() and just 
                uses this file instead. The user can (optionally) run a script 
                on the client to generate the file from the terminal emulator 
                (by trying each character and then measuring where the terminal 
                is) and use that file to replace the default on the server-side.
17:08 < KeithW> (end design)
17:09 < KeithW> This would both (1) get us away from depending on libc, either 
                on client or server, and (b) provide a fix for the problem of 
                client/server mismatch.
17:09 < KeithW> Er, "(2) provide a fix".