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

Cursor placement with multi-column characters #94

Closed
jtdaugherty opened this issue Jun 6, 2016 · 2 comments
Closed

Cursor placement with multi-column characters #94

jtdaugherty opened this issue Jun 6, 2016 · 2 comments

Comments

@jtdaugherty
Copy link
Owner

At some point vty started being smarter about multi-column characters and I didn't notice. Now I'm trying out adding multi-column character support to brick and I have encountered something interesting.

brick has to do layout of Vty images, and sometimes those images come with cursor placement requests. So we might have to lay out two images as follows:

"寬字" (no cursor) next to "foobar" (cursor location (0, 0))

so that the final result would be

寬字foobar

with the cursor placed on the f. The (currently broken) way brick figures out that the new cursor location should be on the f is by adding the imageWidth of "寬字" to the requested cursor position (0,0) to determine a new position. This approach works when all characters are single-column.

But the problem is that the width returned by imageWidth is the physical width of the image (in display columns), but the position needed for cursor placement is in characters. So I end up getting 4+0=4 rather than 2+0=2 and my cursor is placed too far to the right.

I don't know how to get this right with the current API. Am I missing something?

@jtdaugherty
Copy link
Owner Author

(CC jtdaugherty/brick#61)

@glguy
Copy link
Collaborator

glguy commented Aug 28, 2016

My use-case for rendering a text box that overflows by scrolling requires me to work around this clever behavior. Basically I have to compute the opposite transformation and then use that when requesting a cursor position.

I working around this feature with the following code: https://github.com/glguy/irc-core/blob/v2/src/Client/Image/Textbox.hs

Even better than inverting the operation would be a setting to turn off this more clever behavior.

glguy added a commit to glguy/vty that referenced this issue Sep 1, 2016
This allows advanced applications to compute their own direct cursor
placement by absolute column without having to invert the logical
cursor computation.

Fixes jtdaugherty#94
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

2 participants