diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | doc/user_help.in.html | 5 | ||||
-rw-r--r-- | dw/layout.hh | 5 | ||||
-rw-r--r-- | dw/selection.cc | 6 | ||||
-rw-r--r-- | dw/selection.hh | 23 | ||||
-rw-r--r-- | src/keys.cc | 1 | ||||
-rw-r--r-- | src/keys.hh | 1 | ||||
-rw-r--r-- | src/keysrc | 3 | ||||
-rw-r--r-- | src/ui.cc | 5 | ||||
-rw-r--r-- | src/uicmd.cc | 10 | ||||
-rw-r--r-- | src/uicmd.hh | 1 |
11 files changed, 53 insertions, 8 deletions
@@ -11,6 +11,7 @@ dillo-3.3.0 [Unreleased] +- Add optional support for brotli (br) content encoding. - Add about:keys to display current keyboard shortcuts. - Control + left click opens links in new tab (emulates mouse middle button). + - Ctrl+C copies selected text into the clipboard so Ctrl+V works as expected. Patches: Rodrigo Arias Mallo +- Middle click on back or forward button opens page in new tab. Patches: Alex diff --git a/doc/user_help.in.html b/doc/user_help.in.html index 48b39669..50a2b28d 100644 --- a/doc/user_help.in.html +++ b/doc/user_help.in.html @@ -248,8 +248,8 @@ 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. +press the middle mouse button. To copy text into the Clipboard, select the text +and press Ctrl+C then go to the destination and press Ctrl+V to paste. <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. @@ -823,6 +823,7 @@ The list of default bindings is given in the following table. <tr><td>Ctrl-U <td> <td>View source <tr><td>Ctrl-B <td>Bookmarks <td>View bookmarks <tr><td>Ctrl-Q <td>Quit <td>Quit dillo +<tr><td>Ctrl-C <td>Copy <td>Copy to clipboard <tr><td>Ctrl-+ or Ctrl-= <td>Bigger <td>Zoom in <tr><td>Ctrl-- <td>Smaller <td>Zoom out <tr><td>Ctrl-0 <td>100% <td>Reset zoom to 100% diff --git a/dw/layout.hh b/dw/layout.hh index 36f433b5..1794179c 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -438,6 +438,11 @@ public: platform->copySelection(text, destination); } + inline void copyCurrentSelection(int destination) + { + selectionState.copy(destination); + } + inline ui::ResourceFactory *getResourceFactory () { return platform->getResourceFactory (); diff --git a/dw/selection.cc b/dw/selection.cc index 899fad69..78cd23ce 100644 --- a/dw/selection.cc +++ b/dw/selection.cc @@ -198,7 +198,7 @@ bool SelectionState::buttonRelease (Iterator *it, int charPos, int linkNo, // nothing selected resetSelection (); else { - copy (); + copy (0); selectionState = SELECTED; } } @@ -423,7 +423,7 @@ void SelectionState::highlight0 (bool fl, DeepIterator *from, int fromChar, } } -void SelectionState::copy() +void SelectionState::copy(int selection) { if (from && to) { Iterator *si; @@ -495,7 +495,7 @@ void SelectionState::copy() delete i; } - layout->copySelection(strbuf.getChars(), 0); + layout->copySelection(strbuf.getChars(), selection); } } diff --git a/dw/selection.hh b/dw/selection.hh index d9d5af72..11ac96e6 100644 --- a/dw/selection.hh +++ b/dw/selection.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_SELECTION_H__ #define __DW_SELECTION_H__ @@ -214,8 +234,6 @@ private: void highlight0 (bool fl, DeepIterator *from, int fromChar, DeepIterator *to, int toChar, int dir); - void copy (); - public: enum EventType { BUTTON_PRESS, BUTTON_RELEASE, BUTTON_MOTION }; @@ -224,6 +242,7 @@ public: inline void setLayout (Layout *layout) { this->layout = layout; } void reset (); + void copy (int selection); bool buttonPress (Iterator *it, int charPos, int linkNo, EventButton *event); bool buttonRelease (Iterator *it, int charPos, int linkNo, diff --git a/src/keys.cc b/src/keys.cc index bbbd30bb..2a97a160 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -139,6 +139,7 @@ static const KeyBinding_t default_keys[] = { { "right" , KEYS_RIGHT , 0 , FL_Right }, { "top" , KEYS_TOP , 0 , FL_Home }, { "bottom" , KEYS_BOTTOM , 0 , FL_End }, + { "copy" , KEYS_COPY , FL_CTRL , 'c' }, { "zoom-in" , KEYS_ZOOM_IN , FL_CTRL , '+' }, { "zoom-in" , KEYS_ZOOM_IN , FL_CTRL , '=' /* US + */ }, { "zoom-out" , KEYS_ZOOM_OUT , FL_CTRL , '-' }, diff --git a/src/keys.hh b/src/keys.hh index 40c01718..72b62d18 100644 --- a/src/keys.hh +++ b/src/keys.hh @@ -49,6 +49,7 @@ typedef enum { KEYS_RIGHT, KEYS_TOP, KEYS_BOTTOM, + KEYS_COPY, KEYS_ZOOM_IN, KEYS_ZOOM_OUT, KEYS_ZOOM_RESET @@ -78,6 +78,9 @@ # "goto" goes to the location bar at the top of the window. #<ctrl>l = goto +# "copy" copies the selected text into the clipboard. +#<ctrl>c = copy + # "stop" loading the page. #(stop has no default binding) @@ -2,7 +2,7 @@ * File: ui.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 @@ -742,6 +742,9 @@ int UI::handle(int event) } else if (cmd == KEYS_FORWARD) { a_UIcmd_forw(a_UIcmd_get_bw_by_widget(this)); ret = 1; + } else if (cmd == KEYS_COPY) { + a_UIcmd_copy(a_UIcmd_get_bw_by_widget(this)); + ret = 1; } else if (cmd == KEYS_ZOOM_IN) { a_UIcmd_zoom_in(a_UIcmd_get_bw_by_widget(this)); ret = 1; diff --git a/src/uicmd.cc b/src/uicmd.cc index a2c21311..a46fd7c5 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -953,6 +953,16 @@ void a_UIcmd_redirection0(void *vbw, const DilloUrl *url) } /* + * Copy selection to clipboard + */ +void a_UIcmd_copy(void *vbw) +{ + BrowserWindow *bw = (BrowserWindow*) vbw; + Layout *layout = (Layout*)bw->render_layout; + layout->copyCurrentSelection(1); +} + +/* * Zoom in */ void a_UIcmd_zoom_in(void *vbw) diff --git a/src/uicmd.hh b/src/uicmd.hh index 54b8750b..581eac30 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -35,6 +35,7 @@ void a_UIcmd_forw(void *vbw); void a_UIcmd_forw_nt(void *vbw); void a_UIcmd_forw_popup(void *vbw, int x, int y); void a_UIcmd_home(void *vbw); +void a_UIcmd_copy(void *vbw); void a_UIcmd_zoom_in(void *vbw); void a_UIcmd_zoom_out(void *vbw); void a_UIcmd_zoom_reset(void *vbw); |