From e3746a7c31e345adfbf799934115c974e670a37c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Fri, 6 Oct 2023 22:14:37 +0300
Subject: [PATCH 1/1] DocumentWidget: Fixed "Paste Preceding Line" keyboard
shortcut
The dynamic menu is empty while not open.
src/ui/documentwidget.c | 32 +++++++++++++++++++++-----------
src/ui/util.c | 2 +-
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 9fa5298f..8b2e2c06 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -2033,27 +2033,36 @@ static iBool setUrl_DocumentWidget_(iDocumentWidget *d, const iString *url) {
return iFalse;
}
+static void makePastePrecedingLineMenuItem_(iMenuItem *item_out, const iWidget *buttons,
const char *precedingLine) {
"${menu.input.precedingline}",
bind->key,
bind->mods,
format_CStr("!valueinput.set ptr:%p text:%s", buttons, precedingLine)
+}
static const iArray *updateInputPromptMenuItems_(iWidget *menu) {
const char *context = cstr_String(&menu->data);
const iWidget *buttons = pointerLabel_Command(context, "buttons");
const iString *url = string_Command(context, "url");
const char *precedingLine = suffixPtr_Command(context, "preceding");
/* Compose new menu items. */
iArray *items = collectNew_Array(sizeof(iMenuItem));
pushBackN_Array(
items,
(iMenuItem[]){
{ "${menu.input.precedingline}",
bind->key,
bind->mods,
format_CStr("!valueinput.set ptr:%p text:%s", buttons, precedingLine) },
{ "---" },
{ !isPromptUrl_SiteSpec(url) ? "${menu.input.setprompt}" : "${menu.input.unsetprompt}",
0,
0,
format_CStr("!prompturl.toggle url:%s", cstr_String(url)) } },
3);
2);
/* Recently submitted input texts can be restored. */ {
const iStringArray *recentInput = recentlySubmittedInput_App();
if (!isEmpty_StringArray(recentInput)) {
@@ -2130,8 +2139,13 @@ iWidget *makeInputPrompt_DocumentWidget(iDocumentWidget *d, const iString *url,
if (lineBreak && deviceType_App() != desktop_AppDeviceType) {
addChildPos_Widget(buttons, iClob(lineBreak), front_WidgetAddPos);
}
for the keys as usual. */ {
iMenuItem pasteItem;
makePastePrecedingLineMenuItem_(&pasteItem, buttons, cstr_String(&d->linePrecedingLink));
addAction_Widget(dlg, pasteItem.key, pasteItem.kmods, pasteItem.command);
/* Menu for additional actions, past entries. */ {
iLabelWidget *ellipsisButton =
makeMenuButton_LabelWidget(midEllipsis_Icon, NULL, 0);
iWidget *menu = findChild_Widget(as_Widget(ellipsisButton), "menu");
@@ -2142,10 +2156,6 @@ iWidget *makeInputPrompt_DocumentWidget(iDocumentWidget *d, const iString *url,
buttons,
cstr_String(canonicalUrl_String(url)),
cstr_String(&d->linePrecedingLink)));
// iWidget *menu = findChild_Widget(as_Widget(ellipsisButton), "menu");
// menu->updateMenuItems = updateInputPromptMenuItems_;
// set_String(&menu->data, url); /* needed when updating items */
//}
if (deviceType_App() == desktop_AppDeviceType) {
addChildPos_Widget(buttons, iClob(ellipsisButton), front_WidgetAddPos);
}
diff --git a/src/ui/util.c b/src/ui/util.c
index b45c345b..727cd788 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2588,7 +2588,7 @@ iWidget *makeValueInputWithAdditionalActions_Widget(iWidget *parent, const iStri
pushBack_Array(&actions, &(iMenuItem){ "---" });
}
pushBack_Array(&actions, &(iMenuItem){ "${cancel}", SDLK_ESCAPE, 0, "valueinput.cancel" });
pushBack_Array(&actions, &(iMenuItem){ "---" });
}
pushBack_Array(&actions,
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).