Thursday, 20 March 2014

[PATCH 2/2] Truncate caret of text input field at top & bottom boundaries.

---
desktop/textarea.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/desktop/textarea.c b/desktop/textarea.c
index 8e4b1dd..c148a58 100644
--- a/desktop/textarea.c
+++ b/desktop/textarea.c
@@ -462,12 +462,19 @@ static bool textarea_set_caret_internal(struct textarea *ta, int caret_b)
((ta->bar_x == NULL) ?
0 : SCROLLBAR_WIDTH)
};
+
+ /* Truncate height of caret on top and bottom boundaries */
+ height = ta->line_height;
+ if (y - ta->scroll_y + height > cr.y1) {
+ height = cr.y1 - y + ta->scroll_y;
+ }
+
msg.ta = ta;
msg.type = TEXTAREA_MSG_CARET_UPDATE;
msg.data.caret.type = TEXTAREA_CARET_SET_POS;
msg.data.caret.pos.x = x - ta->scroll_x;
msg.data.caret.pos.y = y - ta->scroll_y;
- msg.data.caret.pos.height = ta->line_height;
+ msg.data.caret.pos.height = height;
msg.data.caret.pos.clip = &cr;

ta->callback(ta->data, &msg);
--
1.8.3.2

No comments:

Post a Comment