render: scroll input to ensure cursor is always visible
Before adoption: this commit came in with the history the project adopted, so no landing records it.
The input string now scrolls with the cursor (when the string is longer than the available space), ensuring the cursor and surrounding text is always visible. When calculating whether a glyph will fit or not, we use the largest value of the glyphs advance width, and its X offset + glyph width. The advance width is how much the pen position is moved after rendering the glyph. The X-offset + width tells us where the last pixel column of the glyph will be. By using the largest of the two, we ensure the glyph, and the cursor, will be fully visible. (kerning is also taken into account). Limitations and peculiarities: * Text is always left-aligned. That is, we always start rendering on the left side, at the exact same pixel offset. This means characters will "jump around" close to the right side. * When scrolling, we try to keep the cursor at the edge (either left or right). But, since the text is always left-aligned, we may sometimes scroll in *two* characters when moving the cursor one step to the right. This happens if the scrolled out character is wide, and the scrolled in character(s) are narrow(er). * Even before this patch, ligatures (both emoji ZWJ sequences, and fi, ff, ft, etc) were not handled well. For example, the cursor couldn't be moved "into" the ligature, and you had to press a cursor key twice to move over e.g. 'ff'. One way to solve this is to split the input string into two text runs; everything on the left side of the cursor, and everything on the right side of the cursor. This would however complicate rendering quite a bit. Instead, I decided to disable shaping completely, of the input string (the prompt string, and application entries, are still shaped). Closes #378
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+170 added−25 removed
- other:+170 added−25 removed