Lagrange [work/v1.10]

InputWidget: Fixed cursor and selection issues

=> ae8cdc792cfa402d99fb3717c2d9ad7d56d4a9b2

diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 1d036939..c9779ff0 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 
 static const int    refreshInterval_InputWidget_ = 256;
 static const size_t maxUndo_InputWidget_         = 64;
+static const int    unlimitedWidth_InputWidget_  = 1000000; /* TODO: WrapText disables some functionality if maxWidth==0 */
 
 static void enableEditorKeysInMenus_(iBool enable) {
 #if defined (iPlatformAppleDesktop)
@@ -420,9 +421,10 @@ static const char *sensitive_     = "\u25cf";
 static iWrapText wrap_InputWidget_(const iInputWidget *d, int y) {
     return (iWrapText){
         .text     = range_String(&line_InputWidget_(d, y)->text),
-        .maxWidth = d->maxLen == 0 ? width_Rect(contentBounds_InputWidget_(d)) : 0,
-        .mode     = (d->inFlags & isUrl_InputWidgetFlag ? anyCharacter_WrapTextMode
-                                                        : word_WrapTextMode),
+        .maxWidth = d->maxLen == 0 ? width_Rect(contentBounds_InputWidget_(d))
+                                   : unlimitedWidth_InputWidget_,
+        .mode =
+            (d->inFlags & isUrl_InputWidgetFlag ? anyCharacter_WrapTextMode : word_WrapTextMode),
         .overrideChar = (d->inFlags & isSensitive_InputWidgetFlag ? sensitiveChar_ : 0),
     };
 }
@@ -829,13 +831,13 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
         updateLine_InputWidget_(d, i.value); /* count number of visible lines */
     }
     updateLineRangesStartingFrom_InputWidget_(d, 0);
-    //if (isFocused_Widget(d)) {
-        d->cursor = cursorMax_InputWidget_(d);
-//    }
+    d->cursor = cursorMax_InputWidget_(d);
+    if (!isFocused_Widget(d)) {
+        iZap(d->mark);
+    }
 //    else {
 //        d->cursor.y = iMin(d->cursor.y, (int) size_Array(&d->lines) - 1);
 //        d->cursor.x = iMin(d->cursor.x, size_String(&cursorLine_InputWidget_(d)->text));
-        iZap(d->mark);
 //    }
     if (!isFocused_Widget(d)) {
         d->inFlags |= needUpdateBuffer_InputWidgetFlag;
@@ -1257,7 +1259,7 @@ static iInt2 coordCursor_InputWidget_(const iInputWidget *d, iInt2 coord) {
         return cursorMax_InputWidget_(d);
     }
     iWrapText wrapText = {
-        .maxWidth = d->maxLen == 0 ? width_Rect(bounds) : 0,
+        .maxWidth = d->maxLen == 0 ? width_Rect(bounds) : unlimitedWidth_InputWidget_,
         .mode = (d->inFlags & isUrl_InputWidgetFlag ? anyCharacter_WrapTextMode : word_WrapTextMode),
         .hitPoint = relCoord,
         .overrideChar = (d->inFlags & isSensitive_InputWidgetFlag ? sensitiveChar_ : 0),
@@ -1839,7 +1841,7 @@ static void draw_InputWidget_(const iInputWidget *d) {
                              : isFocused /*&& !isEmpty_Array(&d->lines)*/ ? uiInputTextFocused_ColorId
                                                                       : uiInputText_ColorId;
     iWrapText wrapText = {
-        .maxWidth     = d->maxLen == 0 ? width_Rect(contentBounds) : 0,
+        .maxWidth     = d->maxLen == 0 ? width_Rect(contentBounds) : unlimitedWidth_InputWidget_,
         .mode         = (d->inFlags & isUrl_InputWidgetFlag ? anyCharacter_WrapTextMode
                                                             : word_WrapTextMode),
         .overrideChar = (d->inFlags & isSensitive_InputWidgetFlag ? sensitiveChar_ : 0),
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.10/cdiff/ae8cdc792cfa402d99fb3717c2d9ad7d56d4a9b2
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
24.1808 milliseconds
Gemini-to-HTML Time
0.254719 milliseconds

This content has been proxied by September (ba2dc).