Skip to content
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

element.setContent fails when mixing spaces and tags #42

Open
danikaze opened this issue Jan 10, 2020 · 0 comments
Open

element.setContent fails when mixing spaces and tags #42

danikaze opened this issue Jan 10, 2020 · 0 comments

Comments

@danikaze
Copy link

danikaze commented Jan 10, 2020

Basically, I'm setting an element (box with tags: true) with a content, and setting its width to content.width... something like this:

const lines = ['123', '456'];
box.setContent(lines.join('\n'))
box.width = lines[0].length;
box.height = lines.length;

this works fine... if you don't mix spaces and tags...

I'll explain with examples (height = 1, width = 3):

// OK cases:
box.setContent('abc');
box.setContent('abc\n');
box.setContent('a c\n');
box.setContent('{red-fg}a{/red-fg}b{green-fg}c{/green-fg}\n');
// NG cases (last character "doesn't fit" and it ("c") is rendered in the next line
box.setContent('{red-fg}a{/red-fg} {green-fg}c{/green-fg}');
box.setContent('{red-fg}a{/red-fg} {green-fg}c{/green-fg}\n');

so it looks like at some point of the rendering, it's not calculating well the line size and adds new \n characters breaking all the text positioning.

@danikaze danikaze changed the title element.parseContent fails when there are tags element.setContent fails when mixing spaces and tags Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant