EM_SETSEL scrolls if outside of the visible range.
"shift+home" selection improved in the edit control.
diff --git a/controls/edit.c b/controls/edit.c
index 03b7b97..f5e268f 100644
--- a/controls/edit.c
+++ b/controls/edit.c
@@ -358,6 +358,7 @@
case EM_SETSEL:
DPRINTF_EDIT_MSG32("EM_SETSEL");
EDIT_EM_SetSel(wnd, es, wParam, lParam, FALSE);
+ EDIT_EM_ScrollCaret(wnd, es);
result = 1;
break;
@@ -1509,7 +1510,7 @@
HIWORD(EDIT_EM_PosFromChar(wnd, es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
else
e = 0;
- EDIT_EM_SetSel(wnd, es, e, extend ? es->selection_start : e, FALSE);
+ EDIT_EM_SetSel(wnd, es, extend ? es->selection_start : e, e, FALSE);
EDIT_EM_ScrollCaret(wnd, es);
}
@@ -3028,22 +3029,26 @@
*/
static LRESULT EDIT_WM_Create(WND *wnd, EDITSTATE *es, LPCREATESTRUCTA cs)
{
- /*
- * To initialize some final structure members, we call some helper
- * functions. However, since the EDITSTATE is not consistent (i.e.
- * not fully initialized), we should be very careful which
- * functions can be called, and in what order.
- */
- EDIT_WM_SetFont(wnd, es, 0, FALSE);
- EDIT_EM_EmptyUndoBuffer(wnd, es);
+ /*
+ * To initialize some final structure members, we call some helper
+ * functions. However, since the EDITSTATE is not consistent (i.e.
+ * not fully initialized), we should be very careful which
+ * functions can be called, and in what order.
+ */
+ EDIT_WM_SetFont(wnd, es, 0, FALSE);
+ EDIT_EM_EmptyUndoBuffer(wnd, es);
- if (cs->lpszName && *(cs->lpszName) != '\0') {
- EDIT_EM_ReplaceSel(wnd, es, FALSE, cs->lpszName);
- /* if we insert text to the editline, the text scrolls out of the window, as the caret is placed after the insert pos normally; thus we reset es->selection... to 0 and update caret */
- es->selection_start = es->selection_end = 0;
- EDIT_EM_ScrollCaret(wnd, es);
- }
- return 0;
+ if (cs->lpszName && *(cs->lpszName) != '\0') {
+ EDIT_EM_ReplaceSel(wnd, es, FALSE, cs->lpszName);
+ /* if we insert text to the editline, the text scrolls out
+ * of the window, as the caret is placed after the insert
+ * pos normally; thus we reset es->selection... to 0 and
+ * update caret
+ */
+ es->selection_start = es->selection_end = 0;
+ EDIT_EM_ScrollCaret(wnd, es);
+ }
+ return 0;
}