SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.59k stars 3.19k forks source link

LibGUI: CRLF messes up text layout #7279

Open bcoles opened 3 years ago

bcoles commented 3 years ago

There are a lot of instances where CR 0x0d LF 0x0a messes up text layouts. There are likely other problematic characters (0x09).

Here's a couple of examples; however, this appears to systemic across most user interfaces.

File names:

image

image

Processes:

image

MaxWipfli commented 3 years ago

The question here is what we should do? We could:

1) Cut output at the first CR or LF and add .... 2) Replace them with escape codes (e.g. CR with \r). This seems very programmer-ish, so probably doesn't fit with what we want to achieve with the GUI. 3) Replace them characters with ?. That's what GNU ls does when you have file names containing a newline. Maybe this is POSIX, I have no idea. 4) Remove them entirely. This is what KDE Dolphin and the tree view of JetBrains IDEs do. 5) Replace them with whitespace (so `). This is what procpspsdoes. 6) Replace e.g.te\nstwith'te'$'\n''st'. This is what GNUlsdoes in-lmode and what you have to enter into a shell likebashorzshto actually get them to accept the control character (except if you open a quote and type a literal newline). 7) Replace them with something obvious, like � (U+FFFD` replacement character). This one is not in our font yet, though.

My suggestion: GUI applications: ? or � (It would be more idiomatic to use �, and because the character is not in the fonts used by Serenity, a "?" would be substituted anyway.) Terminal (Shell Autocomplete, ls -l): Something you can type into the shell prompt to actually communicate exactly what you want (like maybe what bash does). Terminal (various others, like ps): ?, �, whitespace or ignoring all seem fine.

Note: This post also adresses #7277 and #7280.