-
Notifications
You must be signed in to change notification settings - Fork 13
Keep a 96-set designation out of the 94-set lookup when DECNRCM moves #146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -715,9 +715,7 @@ private void SetCharset(CharsetMode mode, string charsetId) | |
| // with DECNRCM set and ASCII without it, so the designation has to outlive the | ||
| // resolution -- a program designating French and then enabling NRC mode expects | ||
| // French, and it never designates again. | ||
| _charsetIds[mode] = charsetId; | ||
| _charsets[mode] = Charsets.GetCharset(charsetId, _terminal.NationalReplacementCharsets); | ||
| RefreshActiveCharset(); | ||
| Designate(mode, charsetId, ninetySix: false); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -732,20 +730,57 @@ private void SetCharset(CharsetMode mode, string charsetId) | |
| /// </remarks> | ||
| private void SetNinetySixCharset(CharsetMode mode, string charsetId) | ||
| { | ||
| _charsetIds[mode] = charsetId; | ||
| _charsets[mode] = Charsets.ASCII; | ||
| Designate(mode, charsetId, ninetySix: true); | ||
| } | ||
|
|
||
| private void Designate(CharsetMode mode, string charsetId, bool ninetySix) | ||
| { | ||
| var designation = (charsetId, ninetySix); | ||
| _charsetIds[mode] = designation; | ||
| _charsets[mode] = Resolve(designation); | ||
|
Comment on lines
+739
to
+740
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed, and it is worse than the 96-set case you found. The same fault exists a designation earlier, with no 96-set involved: That one predates this branch -- it arrived with the identifiers themselves in #141 -- so a TUI that saves the cursor mid-border gets its border back and then loses it the next time anything touches DECNRCM, arbitrarily far from the DECRC that caused it. Fixed in 7dff244 the way you suggest: DECSC saves the Every G-set is now seeded to The regression test covers both spaces, and also asserts the restore without a mode change -- that half was never broken, and a test that stopped there would have passed on the defect. |
||
| RefreshActiveCharset(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The table a designation resolves to NOW -- which depends on DECNRCM, and so is asked | ||
| /// again every time that mode moves rather than being decided once at designation time. | ||
| /// </summary> | ||
| private Dictionary<char, string>? Resolve((string Id, bool NinetySix) designation) => | ||
| // The 96-set space has its own identifiers, and only ASCII-transparent members: routing | ||
| // one through the 94-set lookup is what turns a Latin-1 designation into the UK set. | ||
| // DECNRCM does not reach here either -- the national replacement sets are all 94-set. | ||
| designation.NinetySix | ||
| ? Charsets.ASCII | ||
| : Charsets.GetCharset(designation.Id, _terminal.NationalReplacementCharsets); | ||
|
|
||
| /// <summary>Re-resolves every designation, for when DECNRCM changes under them.</summary> | ||
| internal void RefreshDesignatedCharsets() | ||
| { | ||
| foreach (var mode in _charsetIds.Keys.ToList()) | ||
| _charsets[mode] = Charsets.GetCharset(_charsetIds[mode], _terminal.NationalReplacementCharsets); | ||
| foreach (var mode in GSets) | ||
| _charsets[mode] = Resolve(_charsetIds[mode]); | ||
|
|
||
| RefreshActiveCharset(); | ||
| } | ||
|
|
||
| /// <summary>The designation a G-set is holding, for DECSC to save.</summary> | ||
| internal (string Id, bool NinetySix) DesignationOf(CharsetMode mode) => _charsetIds[mode]; | ||
|
|
||
| /// <summary> | ||
| /// Puts a saved designation back, for DECRC, resolving it against the mode state as it is NOW. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// The DESIGNATION is what DECSC saves, not the table it had resolved to. Saving the table | ||
| /// restores the right glyphs and leaves the identifier behind it stale, so the next DECNRCM | ||
| /// re-resolves the restored slot from whatever was designated after the save -- and a program | ||
| /// doing ESC ( 0, DECSC, ESC ( R, DECRC gets its line drawing back and then loses it again the | ||
| /// first time the mode moves, which is further from the fault than any test looks. | ||
| /// </remarks> | ||
| internal void RestoreDesignation(CharsetMode mode, (string Id, bool NinetySix) designation) | ||
| { | ||
| _charsetIds[mode] = designation; | ||
| _charsets[mode] = Resolve(designation); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Shift Out - Select G1 character set (SO, 0x0E). | ||
| /// </summary> | ||
|
|
@@ -799,15 +834,21 @@ public void InvokeSingleShift(CharsetMode mode) | |
| /// </summary> | ||
| public void ResetCharsets() | ||
| { | ||
| _charsetIds.Clear(); | ||
| _charsets[CharsetMode.G0] = Charsets.ASCII; | ||
| _charsets[CharsetMode.G1] = Charsets.ASCII; | ||
| _charsets[CharsetMode.G2] = Charsets.ASCII; | ||
| _charsets[CharsetMode.G3] = Charsets.ASCII; | ||
| foreach (var mode in GSets) | ||
| { | ||
| // Seeded rather than cleared: US ASCII IS the designation every slot starts with, and | ||
| // saying so keeps every walk over the four total. | ||
| _charsetIds[mode] = (UsAsciiId, NinetySix: false); | ||
| _charsets[mode] = Charsets.ASCII; | ||
| } | ||
|
|
||
| _currentCharset = CharsetMode.G0; | ||
| RefreshActiveCharset(); | ||
| } | ||
|
|
||
| /// <summary>The identifier US ASCII is designated by, which is where every G-set starts.</summary> | ||
| private const string UsAsciiId = "B"; | ||
|
|
||
| /// <summary> | ||
| /// Prints the payload of an OSC 66 whose metadata could not be parsed, as ordinary text. | ||
| /// </summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, and the PR body was the thing that was wrong -- I described the change and did not make it. Fixed in 7dff244: both halves now designate G1 with
ESC )/ESC -and invoke it with SO, so they differ by the namespace and nothing else.