diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-16 11:09:35 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-16 11:09:35 +0200 |
commit | a5a59eb664cdfb5fe37fb7d8c82d11c7008cbac7 (patch) | |
tree | 73221a4b7c0c1bf60b570cca80d2c963303d02e9 /src/app.c | |
parent | 01c298520d7b6d9ad268d59a6d2a0b99c5cded78 (diff) |
DocumentWidget: Paste preceding line
Added a special actions menu in the input prompt to allow the user to paste the line preceding the latest clicked link from the originating document.
One use case for this is user-editable lines.
Diffstat (limited to 'src/app.c')
-rw-r--r-- | src/app.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -356,7 +356,7 @@ static void loadPrefs_App_(iApp *d) { | |||
356 | setUiScale_Window(get_Window(), argf_Command(cmd)); | 356 | setUiScale_Window(get_Window(), argf_Command(cmd)); |
357 | } | 357 | } |
358 | else if (equal_Command(cmd, "uilang")) { | 358 | else if (equal_Command(cmd, "uilang")) { |
359 | const char *id = cstr_Rangecc(range_Command(cmd, "id")); | 359 | const char *id = cstr_Command(cmd, "id"); |
360 | setCStr_String(&d->prefs.strings[uiLanguage_PrefsString], id); | 360 | setCStr_String(&d->prefs.strings[uiLanguage_PrefsString], id); |
361 | setCurrent_Lang(id); | 361 | setCurrent_Lang(id); |
362 | } | 362 | } |
@@ -2190,6 +2190,7 @@ iBool handleCommand_App(const char *cmd) { | |||
2190 | return iTrue; | 2190 | return iTrue; |
2191 | } | 2191 | } |
2192 | else if (equal_Command(cmd, "fontpack.suggest.classic")) { | 2192 | else if (equal_Command(cmd, "fontpack.suggest.classic")) { |
2193 | /* TODO: Don't use this when system fonts are accessible. */ | ||
2193 | if (!isInstalled_Fonts("classic-set") && !isInstalled_Fonts("cjk")) { | 2194 | if (!isInstalled_Fonts("classic-set") && !isInstalled_Fonts("cjk")) { |
2194 | makeQuestion_Widget( | 2195 | makeQuestion_Widget( |
2195 | uiHeading_ColorEscape "${heading.fontpack.classic}", | 2196 | uiHeading_ColorEscape "${heading.fontpack.classic}", |
@@ -2243,6 +2244,9 @@ iBool handleCommand_App(const char *cmd) { | |||
2243 | (argLabel_Command(cmd, "axis") ? vertical_WindowSplit : 0) | (arg_Command(cmd) << 1); | 2244 | (argLabel_Command(cmd, "axis") ? vertical_WindowSplit : 0) | (arg_Command(cmd) << 1); |
2244 | const char *url = suffixPtr_Command(cmd, "url"); | 2245 | const char *url = suffixPtr_Command(cmd, "url"); |
2245 | setCStr_String(d->window->pendingSplitUrl, url ? url : ""); | 2246 | setCStr_String(d->window->pendingSplitUrl, url ? url : ""); |
2247 | if (hasLabel_Command(cmd, "origin")) { | ||
2248 | set_String(d->window->pendingSplitOrigin, string_Command(cmd, "origin")); | ||
2249 | } | ||
2246 | postRefresh_App(); | 2250 | postRefresh_App(); |
2247 | return iTrue; | 2251 | return iTrue; |
2248 | } | 2252 | } |
@@ -2732,12 +2736,21 @@ iBool handleCommand_App(const char *cmd) { | |||
2732 | openInDefaultBrowser_App(url); | 2736 | openInDefaultBrowser_App(url); |
2733 | return iTrue; | 2737 | return iTrue; |
2734 | } | 2738 | } |
2739 | iDocumentWidget *doc = document_Command(cmd); | ||
2740 | iDocumentWidget *origin = doc; | ||
2741 | if (hasLabel_Command(cmd, "origin")) { | ||
2742 | iDocumentWidget *cmdOrig = findWidget_App(cstr_Command(cmd, "origin")); | ||
2743 | if (cmdOrig) { | ||
2744 | origin = cmdOrig; | ||
2745 | } | ||
2746 | } | ||
2735 | const int newTab = argLabel_Command(cmd, "newtab"); | 2747 | const int newTab = argLabel_Command(cmd, "newtab"); |
2736 | if (newTab & otherRoot_OpenTabFlag && numRoots_Window(get_Window()) == 1) { | 2748 | if (newTab & otherRoot_OpenTabFlag && numRoots_Window(get_Window()) == 1) { |
2737 | /* Need to split first. */ | 2749 | /* Need to split first. */ |
2738 | const iInt2 winSize = get_Window()->size; | 2750 | const iInt2 winSize = get_Window()->size; |
2739 | postCommandf_App("ui.split arg:3 axis:%d newtab:%d url:%s", | 2751 | postCommandf_App("ui.split arg:3 axis:%d origin:%s newtab:%d url:%s", |
2740 | (float) winSize.x / (float) winSize.y < 0.7f ? 1 : 0, | 2752 | (float) winSize.x / (float) winSize.y < 0.7f ? 1 : 0, |
2753 | cstr_String(id_Widget(as_Widget(origin))), | ||
2741 | newTab & ~otherRoot_OpenTabFlag, | 2754 | newTab & ~otherRoot_OpenTabFlag, |
2742 | cstr_String(url)); | 2755 | cstr_String(url)); |
2743 | return iTrue; | 2756 | return iTrue; |
@@ -2749,7 +2762,6 @@ iBool handleCommand_App(const char *cmd) { | |||
2749 | setKeyRoot_Window(as_Window(d->window), root); | 2762 | setKeyRoot_Window(as_Window(d->window), root); |
2750 | setCurrent_Root(root); /* need to change for widget creation */ | 2763 | setCurrent_Root(root); /* need to change for widget creation */ |
2751 | } | 2764 | } |
2752 | iDocumentWidget *doc = document_Command(cmd); | ||
2753 | if (newTab & (new_OpenTabFlag | newBackground_OpenTabFlag)) { | 2765 | if (newTab & (new_OpenTabFlag | newBackground_OpenTabFlag)) { |
2754 | doc = newTab_App(NULL, (newTab & new_OpenTabFlag) != 0); /* `newtab:2` to open in background */ | 2766 | doc = newTab_App(NULL, (newTab & new_OpenTabFlag) != 0); /* `newtab:2` to open in background */ |
2755 | } | 2767 | } |
@@ -2766,13 +2778,14 @@ iBool handleCommand_App(const char *cmd) { | |||
2766 | } | 2778 | } |
2767 | setInitialScroll_DocumentWidget(doc, argfLabel_Command(cmd, "scroll")); | 2779 | setInitialScroll_DocumentWidget(doc, argfLabel_Command(cmd, "scroll")); |
2768 | setRedirectCount_DocumentWidget(doc, redirectCount); | 2780 | setRedirectCount_DocumentWidget(doc, redirectCount); |
2781 | setOrigin_DocumentWidget(doc, origin); | ||
2769 | showCollapsed_Widget(findWidget_App("document.progress"), iFalse); | 2782 | showCollapsed_Widget(findWidget_App("document.progress"), iFalse); |
2770 | if (prefs_App()->decodeUserVisibleURLs) { | 2783 | if (prefs_App()->decodeUserVisibleURLs) { |
2771 | urlDecodePath_String(url); | 2784 | urlDecodePath_String(url); |
2772 | } | 2785 | } |
2773 | else { | 2786 | else { |
2774 | urlEncodePath_String(url); | 2787 | urlEncodePath_String(url); |
2775 | } | 2788 | } |
2776 | setUrlFlags_DocumentWidget(doc, url, | 2789 | setUrlFlags_DocumentWidget(doc, url, |
2777 | (isHistory ? useCachedContentIfAvailable_DocumentWidgetSetUrlFlag : 0) | | 2790 | (isHistory ? useCachedContentIfAvailable_DocumentWidgetSetUrlFlag : 0) | |
2778 | (fromSidebar ? openedFromSidebar_DocumentWidgetSetUrlFlag : 0)); | 2791 | (fromSidebar ? openedFromSidebar_DocumentWidgetSetUrlFlag : 0)); |