91861 / wayst

A simple terminal emulator
MIT License
287 stars 9 forks source link

Empty CSI parameters seems to be ignored #25

Closed mawww closed 4 years ago

mawww commented 4 years ago

A CSI m sequence whose first character is ';' does not reset attributes. This seems to be due to string_split_on that explicitely drops empty entries (if (ret.buf[ret.size - 1].size == 2) line 666). This looks wrong, an empty entry is accepted by most terminal emulators and in the case of CSI m should be interpretted as if the value was 0 (i.e. reset all attributes).

91861 commented 4 years ago

Fixed by fc06d0685bba92b8d262dcb8d066e8ec796ecd33.

explicitely drops empty entries

It worked this way because it's expected for ':' in some cases, for example CSI 58:2::0:0:255 m is the same as CSI 58:2:0:0:255 m. Positions where '::' is interpreted as ':' vary between terminal emulators I tested.

Now, if an empty string is followed by ';' it's interpreted as 0, if by ':' it's dropped. This accepts many sequences that other terminals don't, but seems to be producing correct results for valid ones.