Lagrange [work/v1.12]

Fixed command handling regressions

=> fad76a45f72b161680db4b33660e20645afefaba

diff --git a/src/app.c b/src/app.c
index e317e4c6..ef120749 100644
--- a/src/app.c
+++ b/src/app.c
@@ -2272,7 +2272,7 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
         updateFontButton_(findChild_Widget(d, "prefs.font.monodoc"), string_Command(cmd, "monodoc"));
         return iFalse;
     }
-    else if (startsWith_CStr(cmd, "input.ended id:prefs.linespacing")) {
+    else if (equalArg_Command(cmd, "input.ended", "id", "prefs.linespacing")) {
         /* Apply line spacing changes immediately. */
         const iInputWidget *lineSpacing = findWidget_App("prefs.linespacing");
         postCommandf_App("linespacing.set arg:%f", toFloat_String(text_InputWidget(lineSpacing)));
diff --git a/src/ui/bindingswidget.c b/src/ui/bindingswidget.c
index 13f9434e..4365fb1e 100644
--- a/src/ui/bindingswidget.c
+++ b/src/ui/bindingswidget.c
@@ -183,7 +183,7 @@ static iBool processEvent_BindingsWidget_(iBindingsWidget *d, const SDL_Event *e
         postCommand_App("bindings.changed");
         return iTrue;
     }
-    else if (startsWith_CStr(cmd, "tabs.changed id:bindings")) {
+    else if (equalArg_Command(cmd, "tabs.changed", "id", "bindings")) {
         /* Force the scrollbar to unfade. The list is created hidden so the scrollbar is not
            shown by default.*/
         updateVisible_ListWidget(d->list);
diff --git a/src/ui/command.c b/src/ui/command.c
index a4868ca9..307fd44c 100644
--- a/src/ui/command.c
+++ b/src/ui/command.c
@@ -61,6 +61,12 @@ iBool equal_Command(const char *cmdWithArgs, const char *cmd) {
     return equal_CStr(cmdWithArgs, cmd);
 }
 
+iBool equalArg_Command(const char *commandWithArgs, const char *command, const char *label,
+                       const char *value) {
+    return equal_Command(commandWithArgs, command) &&
+           equal_Rangecc(range_Command(commandWithArgs, label), value);
+}
+
 int argLabel_Command(const char *cmd, const char *label) {
     iToken tok;
     init_Token(&tok, label);
diff --git a/src/ui/command.h b/src/ui/command.h
index 8dcae892..5f85250a 100644
--- a/src/ui/command.h
+++ b/src/ui/command.h
@@ -27,6 +27,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 #include 
 
 iBool       equal_Command           (const char *commandWithArgs, const char *command);
+iBool       equalArg_Command        (const char *commandWithArgs, const char *command,
+                                     const char *label, const char *value);
 
 int         arg_Command             (const char *); /* arg: */
 float       argf_Command            (const char *); /* arg: */
diff --git a/src/ui/lookupwidget.c b/src/ui/lookupwidget.c
index 4ace1a30..e14b43a9 100644
--- a/src/ui/lookupwidget.c
+++ b/src/ui/lookupwidget.c
@@ -710,7 +710,7 @@ static iBool processEvent_LookupWidget_(iLookupWidget *d, const SDL_Event *ev) {
         updateVisible_ListWidget(d->list);
         invalidate_ListWidget(d->list);
     }
-    if (startsWith_CStr(cmd, "input.ended id:url ") &&
+    if (equalArg_Command(cmd, "input.ended", "id", "url") &&
         (deviceType_App() != desktop_AppDeviceType || !isFocused_Widget(w))) {
         showCollapsed_Widget(w, iFalse);
     }
diff --git a/src/ui/root.c b/src/ui/root.c
index d7d7c32f..a5177558 100644
--- a/src/ui/root.c
+++ b/src/ui/root.c
@@ -990,7 +990,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
             return iTrue;
         }
     }
-    else if (startsWith_CStr(cmd, "input.ended id:url ")) {
+    else if (equalArg_Command(cmd, "input.ended", "id", "url")) {
         iInputWidget *url = findChild_Widget(navBar, "url");
         showSearchQueryIndicator_(iFalse);
         if (isEmpty_String(text_InputWidget(url))) {
@@ -1133,8 +1133,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
 }
 
 static iBool handleSearchBarCommands_(iWidget *searchBar, const char *cmd) {
-    if (equal_Command(cmd, "input.ended") &&
-        equal_Rangecc(range_Command(cmd, "id"), "find.input")) {
+    if (equalArg_Command(cmd, "input.ended", "id", "find.input")) {
         iInputWidget *input = findChild_Widget(searchBar, "find.input");
         if (arg_Command(cmd) && argLabel_Command(cmd, "enter") && isVisible_Widget(input)) {
             postCommand_Root(searchBar->root, "find.next");
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index ac4e4081..bed61d18 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1393,7 +1393,8 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
     }
     else if (ev->type == SDL_USEREVENT && ev->user.code == command_UserEventCode) {
         const char *cmd = command_UserEvent(ev);
-        if (startsWith_CStr(cmd, "tabs.changed id:doc") || equal_Command(cmd, "document.changed")) {
+        if (equalArg_Command(cmd, "tabs.changed", "id", "doc") ||
+            equal_Command(cmd, "document.changed")) {
             updateItems_SidebarWidget_(d);
             scrollOffset_ListWidget(d->list, 0);
         }
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.12/cdiff/fad76a45f72b161680db4b33660e20645afefaba
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
78.952148 milliseconds
Gemini-to-HTML Time
0.311345 milliseconds

This content has been proxied by September (3851b).