chunqiuyiyu/ervy

Problematic 0A and 0C in scatter plot

jcubic opened this issue · 3 comments

Those codes in specification say it should not move the cursor some terminal move by one, others don't implementation is inconsistent.

Check my question on Unix stackExchange.

What you thing the code suppose to do if there is 0C or 0A?

In Xterm on Fedora this give the same results:

console.log(scatter(scatterData, { legendGap: 18, width: 15 }).replace(/\x1b\[0([A-D])/g, '\x1b[1$1'));

(replace all 0 codes with 1).

jerch commented

The earlier terminal specs (ECMA-48 in 1976) contained a mode called ZDM (zero default mode). If set, this mode would indicate, that a sequence parser should treat omitted params as 0, thus

CSI A == CSI 0 A

Furthermore the spec states, that the param of these cursor functions should default to 1, thus omitted should move the cursor by one step. To keep in line with ZDM, this should all be equal:

CSI A == CSI 0 A == CSI 1 A

Later on ZDM was completely removed from the specs, yet all CSI sequences implemented by DEC follow that scheme. Thus to call an emulator VT100+ compatible it should stay within these assumptions (same with libs expecting to drive a VT100+ terminal).

Edit: Note that the 0 in ZDM does not actually mean "0", its just a placeholder for "DEFAULT".

Thanks for clarification. I'm working on cursor position in my library and have problems, do you know how it should work? my plot is off by 1. You can look at my other question on StackOverflow How to parse cursor ANSI escape codes?. I'm using as you said, /^0?$/ as 1 and also found issues with newlines but still it's not the same as in XTerm.