Lagrange [release]

Persistent input prompt zoom level

23d95fe695b12d5863a2f224ac24d7634391a1be
diff --git a/src/app.c b/src/app.c
index 6ca2b663..7cb04a8d 100644
--- a/src/app.c
+++ b/src/app.c
@@ -288,6 +288,7 @@ static iString *serializePrefs_App_(const iApp *d) {
                         cstr_String(&d->prefs.strings[monospaceFont_PrefsString]),
                         cstr_String(&d->prefs.strings[monospaceDocumentFont_PrefsString]));
     appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent);
+    appendFormat_String(str, "inputzoom.set arg:%d\n", d->prefs.inputZoomLevel);
     appendFormat_String(str, "pinsplit.set arg:%d\n", d->prefs.pinSplit);
     appendFormat_String(str, "smoothscroll arg:%d\n", d->prefs.smoothScrolling);
     appendFormat_String(str, "scrollspeed arg:%d type:%d\n", d->prefs.smoothScrollSpeed[keyboard_ScrollType], keyboard_ScrollType);
@@ -4177,6 +4178,11 @@ iBool handleCommand_App(const char *cmd) {
                                        0);
         return iTrue;
     }
+    else if (equal_Command(cmd, "inputzoom.set")) {
+        d->prefs.inputZoomLevel = arg_Command(cmd);
+        d->prefs.inputZoomLevel = iClamp(d->prefs.inputZoomLevel, 0, 2);
+        return iTrue;
+    }
     else if (equal_Command(cmd, "zoom.set")) {
         if (!isFrozen) {
             setFreezeDraw_MainWindow(get_MainWindow(), iTrue); /* no intermediate draws before docs updated */
diff --git a/src/prefs.c b/src/prefs.c
index 25021f7a..bb204ab4 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -45,6 +45,7 @@ void init_Prefs(iPrefs *d) {
     d->retainWindowSize  = iTrue;
     d->uiAnimations      = iTrue;
     d->uiScale           = 1.0f; /* default set elsewhere */
+    d->inputZoomLevel    = 0;
     d->zoomPercent       = 100;
     d->navbarActions[0]  = back_ToolbarAction;
     d->navbarActions[1]  = forward_ToolbarAction;
diff --git a/src/prefs.h b/src/prefs.h
index 5cf5e6a3..09acae8e 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -200,6 +200,7 @@ struct Impl_Prefs {
     float            uiScale;
     enum iToolbarAction navbarActions[maxNavbarActions_Prefs];
     enum iToolbarAction toolbarActions[2];
+    int              inputZoomLevel;
     /* Document presentation */
     int              zoomPercent;
     /* Behavior */
diff --git a/src/ui/util.c b/src/ui/util.c
index eab6ca96..176fda9e 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2097,8 +2097,6 @@ static void acceptValueInput_(iWidget *dlg) {
     }
 }
 
-static int valueInputSizeIndex_ = 0;
-
 iLocalDef int metricFromIndex_(int index) {
     const int sizes[3] = { 100, 115, 130 };
     return sizes[iClamp(index, 0, iElemCount(sizes) - 1)];
@@ -2117,7 +2115,7 @@ static void updateValueInputSizing_(iWidget *dlg) {
     }
     else {
         dlg->rect.size.x = iMin(rootSize.x,
-                                metricFromIndex_(valueInputSizeIndex_) * gap_UI);
+                                metricFromIndex_(prefs_App()->inputZoomLevel) * gap_UI);
                                             /*title ? title->rect.size.x : 0*//*,
                                       prompt->rect.size.x);*/
     }
@@ -2249,17 +2247,19 @@ iBool valueInputHandler_(iWidget *dlg, const char *cmd) {
            if resizing in needed in other contexts. */
         if (startsWith_String(id_Widget(dlg), "!document.input.submit")) {
             iInputWidget *input = findChild_Widget(dlg, "input");
+            int sizeIndex = prefs_App()->inputZoomLevel;
             if (equal_Command(cmd, "zoom.set")) {
-                valueInputSizeIndex_ = 0;
+                sizeIndex = 0;
             }
             else {
-                valueInputSizeIndex_ += iSign(arg_Command(cmd));
-                valueInputSizeIndex_ = iClamp(valueInputSizeIndex_, 0, 2);
+                sizeIndex += iSign(arg_Command(cmd));
+                sizeIndex = iClamp(sizeIndex, 0, 2);
             }
+            ((iPrefs *) prefs_App())->inputZoomLevel = sizeIndex; /* const cast... */
             setFont_InputWidget(input,
                                 FONT_ID(default_FontId,
                                         regular_FontStyle,
-                                        uiMedium_FontSize + valueInputSizeIndex_));
+                                        uiMedium_FontSize + sizeIndex));
             updateValueInputSizing_(dlg);
             arrange_Widget(dlg);
             arrange_Widget(dlg);
@@ -2385,9 +2385,10 @@ iWidget *makeValueInputWithAdditionalActions_Widget(iWidget *parent, const iStri
     }
     else if (isDesktop_Platform()) {
         /* The input prompt font is resizable. */
-        setFont_InputWidget(
-            input,
-            FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize + valueInputSizeIndex_));
+        setFont_InputWidget(input,
+                            FONT_ID(default_FontId,
+                                    regular_FontStyle,
+                                    uiMedium_FontSize + prefs_App()->inputZoomLevel));
     }
     if (initialValue) {
         setText_InputWidget(input, initialValue);