terminal-kit: Document TextBox with markdown does not function as expected
When using markdown within a TextBox
it is not rendered as expected.
Consider a TextBox
with the following options:
// ...
contentHasMarkup : true,
wordWrap : true,
Then call the following:
const s = '^GRangers ^-^gare masters of the hunt, often living very independent lives or even occasionally as hermits. Skilled with ^Yranged weapons^-^g, ^GRangers ^-^gprefer to keep their enemies at a distance during combat.';
textbox.setContent(s, true);
Results look something like this:
Expected: ", " and “prefer…” text should be “dim” Green.
Another oddity that I’m not sure is expected: “^Gfoo ^gbar” I would expect to be bright Green “Foo” and dim “bar”, but I seem to have to insert ^-
between since the bright toggles on?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (8 by maintainers)
@NuSkooler Great PoC 😉
On your
ansi-bbs.js
termconfig, you need to turn offdeltaEscapeSequence: false
(at the end of the file). It should greatly improve the support. It tells the ScreenBuffer to fully reset color/attribute anytime a cell has different style that the previous one during a blit (this only affect the blit, not how markup is interpreted).Yes, you can add an
attr
option to almost all widgets. Set it toattr: { bgColor: 'black' }
. When attr is not set on a widget, it used the lib’s default one, usually the terminal default color like CSI 49 for background. It could use some other decent default when it make more sense (e.g. highlighting a button).@NuSkooler I’m saying you that that blink is coming from your termconfig, the
bgBrightRed
was the first line containing such reference to blink, I just copied the first occurrence.It really works fine on my end.
Also everything is backed by a ScreenBuffer, that’s why you got some extra ESC seq. When a particular widget is drawn, it doesn’t know what happened before, so it set everything that should be. Also each cell in the ScreenBuffer has some properties: defaultColor and the bgDefaultColor are, well, the default color of a cell. Everytime a ScreenBuffer surface is blitted it ensures each cell will be drawn with the correct color/attributes. It remembers color/attributes during that process so it only send necessary code between cell, but not between surface blit (everything can happen between 2 blits, including userland codes messing with attributes).
Also the markup was never meant to be a way of writing ESC seq, instead it is meant to convey features of Terminal Kit. You express what you want (color/attributes), the lib try its best to make it work across all supported platforms. E.g. bold in Terminal Kit is meant to write something using bold font. If the platform doesn’t support bold font, the termconfig should fallback to what is as close as possible of bold (in a User eXperience sense), eventually just disable it if no clean fallback is possible, but not wildly send “\x1b[1m” because “hey, it’s the bold code”. The lib is supposed to abstract that away, the userland code may not even know how terminals work (and how messy they are).
@NuSkooler Ok post me the whole sample code. But I have a lot of work this week, I don’t know if I can check/fix something anytime soon.