@@ -2033,27 +2033,36 @@ static iBool setUrl_DocumentWidget_(iDocumentWidget *d, const iString *url) {
2033
2033
return iFalse ;
2034
2034
}
2035
2035
2036
+ static void makePastePrecedingLineMenuItem_ (iMenuItem * item_out , const iWidget * buttons ,
2037
+ const char * precedingLine ) {
2038
+ const iBinding * bind = findCommand_Keys ("input.precedingline" );
2039
+ * item_out = (iMenuItem ){
2040
+ "${menu.input.precedingline}" ,
2041
+ bind -> key ,
2042
+ bind -> mods ,
2043
+ format_CStr ("!valueinput.set ptr:%p text:%s" , buttons , precedingLine )
2044
+ };
2045
+ }
2046
+
2036
2047
static const iArray * updateInputPromptMenuItems_ (iWidget * menu ) {
2037
2048
const char * context = cstr_String (& menu -> data );
2038
2049
const iWidget * buttons = pointerLabel_Command (context , "buttons" );
2039
2050
const iString * url = string_Command (context , "url" );
2040
2051
const char * precedingLine = suffixPtr_Command (context , "preceding" );
2041
- const iBinding * bind = findCommand_Keys ("input.precedingline" );
2042
2052
/* Compose new menu items. */
2043
2053
iArray * items = collectNew_Array (sizeof (iMenuItem ));
2054
+ iMenuItem pasteItem ;
2055
+ makePastePrecedingLineMenuItem_ (& pasteItem , buttons , precedingLine );
2056
+ pushBack_Array (items , & pasteItem );
2044
2057
pushBackN_Array (
2045
2058
items ,
2046
2059
(iMenuItem []){
2047
- { "${menu.input.precedingline}" ,
2048
- bind -> key ,
2049
- bind -> mods ,
2050
- format_CStr ("!valueinput.set ptr:%p text:%s" , buttons , precedingLine ) },
2051
2060
{ "---" },
2052
2061
{ !isPromptUrl_SiteSpec (url ) ? "${menu.input.setprompt}" : "${menu.input.unsetprompt}" ,
2053
2062
0 ,
2054
2063
0 ,
2055
2064
format_CStr ("!prompturl.toggle url:%s" , cstr_String (url )) } },
2056
- 3 );
2065
+ 2 );
2057
2066
/* Recently submitted input texts can be restored. */ {
2058
2067
const iStringArray * recentInput = recentlySubmittedInput_App ();
2059
2068
if (!isEmpty_StringArray (recentInput )) {
@@ -2130,8 +2139,13 @@ iWidget *makeInputPrompt_DocumentWidget(iDocumentWidget *d, const iString *url,
2130
2139
if (lineBreak && deviceType_App () != desktop_AppDeviceType ) {
2131
2140
addChildPos_Widget (buttons , iClob (lineBreak ), front_WidgetAddPos );
2132
2141
}
2142
+ /* Shortcut for the Paste Preceding Line. The menu is dynamic so it won't listen
2143
+ for the keys as usual. */ {
2144
+ iMenuItem pasteItem ;
2145
+ makePastePrecedingLineMenuItem_ (& pasteItem , buttons , cstr_String (& d -> linePrecedingLink ));
2146
+ addAction_Widget (dlg , pasteItem .key , pasteItem .kmods , pasteItem .command );
2147
+ }
2133
2148
/* Menu for additional actions, past entries. */ {
2134
-
2135
2149
iLabelWidget * ellipsisButton =
2136
2150
makeMenuButton_LabelWidget (midEllipsis_Icon , NULL , 0 );
2137
2151
iWidget * menu = findChild_Widget (as_Widget (ellipsisButton ), "menu" );
@@ -2142,10 +2156,6 @@ iWidget *makeInputPrompt_DocumentWidget(iDocumentWidget *d, const iString *url,
2142
2156
buttons ,
2143
2157
cstr_String (canonicalUrl_String (url )),
2144
2158
cstr_String (& d -> linePrecedingLink )));
2145
- // iWidget *menu = findChild_Widget(as_Widget(ellipsisButton), "menu");
2146
- // menu->updateMenuItems = updateInputPromptMenuItems_;
2147
- // set_String(&menu->data, url); /* needed when updating items */
2148
- //}
2149
2159
if (deviceType_App () == desktop_AppDeviceType ) {
2150
2160
addChildPos_Widget (buttons , iClob (ellipsisButton ), front_WidgetAddPos );
2151
2161
}
0 commit comments