diff options
author | Rodrigo Arias Mallo <rodarima@gmail.com> | 2025-05-06 23:46:26 +0200 |
---|---|---|
committer | Rodrigo Arias Mallo <rodarima@gmail.com> | 2025-05-07 23:31:02 +0200 |
commit | 1e5da933a4ef2c5de8ca711215918e9f3ff9df3e (patch) | |
tree | eb387b2afd3059d81a5dae61a2d02025f04c328c | |
parent | ab78cb4b3db6d63cb8da5a9d1390c2b6e50e69af (diff) |
Copy links to clipboard selection too
Selecting text in the page copies only to the primary selection. Copying
links via the context menu now places the URL both in the primary and
clipboard selections so it can also be pasted with Ctrl+V.
See: https://github.com/dillo-browser/dillo/issues/228
-rw-r--r-- | doc/user_help.in.html | 23 | ||||
-rw-r--r-- | dw/fltkplatform.cc | 5 | ||||
-rw-r--r-- | dw/fltkplatform.hh | 22 | ||||
-rw-r--r-- | dw/layout.hh | 24 | ||||
-rw-r--r-- | dw/platform.hh | 22 | ||||
-rw-r--r-- | dw/selection.cc | 3 | ||||
-rw-r--r-- | src/menu.cc | 4 | ||||
-rw-r--r-- | src/uicmd.cc | 10 | ||||
-rw-r--r-- | src/uicmd.hh | 4 |
9 files changed, 96 insertions, 21 deletions
diff --git a/doc/user_help.in.html b/doc/user_help.in.html index 9fba7770..48b39669 100644 --- a/doc/user_help.in.html +++ b/doc/user_help.in.html @@ -241,16 +241,27 @@ ESC. <h3 id="copy-and-paste">Copy and paste</h3> <p> -To copy some text just hold down the left mouse button and move to select the -area to copy. To paste, go to the target application and press the middle mouse -button. +Dillo uses the Primary and Clipboard selections to copy and paste text. The +Primary selection captures text that gets selected as soon as the left button is +released, while to copy it in the Clipboard selection it requires the usual +Ctrl+C and Ctrl+V shortcut. +<p> +To copy some text in the Primary selection just hold down the left mouse button +and move to select the area to copy. To paste, go to the target application and +press the middle mouse button. Currently it is not possible to copy the +selection to the Clipboard via Ctrl+C. <p> If you want to select more than one screen, hold the mouse left button down and scroll with PgUp, PgDn or the arrow keys. -<P> -If you want to paste an URL into Dillo, do it on the "clear-URL" -button (the "X" next to the <a href="#location-bar">location bar</a>). <p> +When a link is copied from the context menu, it is placed both in the Primary +and Clipboard selections, so you can paste the URL with the middle click or with +Ctrl+V. +<p> +If you want to paste an URL into Dillo from the Primary selection, do it on the +"clear-URL" button (the "X" next to the <a href="#location-bar">location +bar</a>) and the URL will be opened as well. You can also paste the URL using +the Clipboard by using the Ctrl+V shortcut then pressing Enter to visit it. <h3 id="zoom">Zoom</h3> <p> diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index 21c0866a..5551a80c 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -700,9 +701,9 @@ core::style::Tooltip *FltkPlatform::createTooltip (const char *text) return FltkTooltip::create (text); } -void FltkPlatform::copySelection(const char *text) +void FltkPlatform::copySelection(const char *text, int destination) { - Fl::copy(text, strlen(text), 0); + Fl::copy(text, strlen(text), destination); } core::Imgbuf *FltkPlatform::createImgbuf (core::Imgbuf::Type type, diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 60dca7f2..f1b68b0a 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef __DW_FLTKPLATFORM_HH__ #define __DW_FLTKPLATFORM_HH__ @@ -174,7 +194,7 @@ public: core::Imgbuf *createImgbuf (core::Imgbuf::Type type, int width, int height, double gamma); - void copySelection(const char *text); + void copySelection(const char *text, int destination); core::ui::ResourceFactory *getResourceFactory (); diff --git a/dw/layout.hh b/dw/layout.hh index 08360e19..36f433b5 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef __DW_LAYOUT_HH__ #define __DW_LAYOUT_HH__ @@ -413,9 +433,9 @@ public: return platform->createImgbuf (type, width, height, gamma); } - inline void copySelection(const char *text) + inline void copySelection(const char *text, int destination) { - platform->copySelection(text); + platform->copySelection(text, destination); } inline ui::ResourceFactory *getResourceFactory () diff --git a/dw/platform.hh b/dw/platform.hh index 5270098b..9d90c9df 100644 --- a/dw/platform.hh +++ b/dw/platform.hh @@ -1,3 +1,23 @@ +/* + * Dillo Widget + * + * Copyright 2005-2013 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + #ifndef __DW_PLATFORM_HH__ #define __DW_PLATFORM_HH__ @@ -158,7 +178,7 @@ public: /** * \brief Copy selected text (0-terminated). */ - virtual void copySelection(const char *text) = 0; + virtual void copySelection(const char *text, int destination) = 0; /** * ... diff --git a/dw/selection.cc b/dw/selection.cc index a69eb82a..899fad69 100644 --- a/dw/selection.cc +++ b/dw/selection.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org> + * Copyright 2025 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -494,7 +495,7 @@ void SelectionState::copy() delete i; } - layout->copySelection(strbuf.getChars()); + layout->copySelection(strbuf.getChars(), 0); } } diff --git a/src/menu.cc b/src/menu.cc index 0a33e0ce..cc2245bf 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -2,7 +2,7 @@ * File: menu.cc * * Copyright (C) 2005-2007 Jorge Arellano Cid <jcid@dillo.org> - * Copyright (C) 2024 Rodrigo Arias Mallo <rodarima@gmail.com> + * Copyright (C) 2024-2025 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,7 +89,7 @@ static void Menu_copy_urlstr_cb(Fl_Widget*, void *user_data) { if (user_data) { DilloUrl *url = (DilloUrl *)user_data ; - a_UIcmd_copy_urlstr(popup_bw, URL_STR(url)); + a_UIcmd_copy_urlstr(popup_bw, URL_STR(url), 2); } } diff --git a/src/uicmd.cc b/src/uicmd.cc index 06333d0c..a2c21311 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -2,7 +2,7 @@ * File: uicmd.cc * * Copyright (C) 2005-2011 Jorge Arellano Cid <jcid@dillo.org> - * Copyright (C) 2024 Rodrigo Arias Mallo <rodarima@gmail.com> + * Copyright (C) 2024-2025 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1317,12 +1317,14 @@ void a_UIcmd_file_popup(void *vbw, void *v_wid) } /* - * Copy url string to paste buffer + * Copy url string to paste buffer. + * + * For destination use: 0=primary, 1=clipboard, 2=both */ -void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr) +void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr, int destination) { Layout *layout = (Layout*)bw->render_layout; - layout->copySelection(urlstr); + layout->copySelection(urlstr, destination); } /* diff --git a/src/uicmd.hh b/src/uicmd.hh index b69b50db..54b8750b 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -2,7 +2,7 @@ * File: uicmd.cc * * Copyright (C) 2005-2011 Jorge Arellano Cid <jcid@dillo.org> - * Copyright (C) 2024 Rodrigo Arias Mallo <rodarima@gmail.com> + * Copyright (C) 2024-2025 Rodrigo Arias Mallo <rodarima@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,7 +67,7 @@ void a_UIcmd_image_popup(void *vbw, const DilloUrl *url, bool_t loaded_img, void a_UIcmd_form_popup(void *vbw, const DilloUrl *url, void *vform, bool_t showing_hiddens); void a_UIcmd_file_popup(void *vbw, void *v_wid); -void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr); +void a_UIcmd_copy_urlstr(BrowserWindow *bw, const char *urlstr, int destination); void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url); void a_UIcmd_view_page_bugs(void *vbw); void a_UIcmd_bugmeter_popup(void *vbw); |