aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorRodrigo Arias Mallo <rodarima@gmail.com>2025-05-07 23:54:32 +0200
committerRodrigo Arias Mallo <rodarima@gmail.com>2025-05-08 00:00:32 +0200
commitd901d8b641c88f9f22b0479d4b3326b2ed06e958 (patch)
tree5e43ce0b923368457215651b2a1eb68921e275a2 /dw
parent1e5da933a4ef2c5de8ca711215918e9f3ff9df3e (diff)
Make Ctrl+C copy selection into clipboard
Follows the behavior of so many other programs by copying the current text selection into the clipboard with Ctrl+C. Selecting text continues to copy it into the primary selection. Fixes: https://github.com/dillo-browser/dillo/issues/228
Diffstat (limited to 'dw')
-rw-r--r--dw/layout.hh5
-rw-r--r--dw/selection.cc6
-rw-r--r--dw/selection.hh23
3 files changed, 29 insertions, 5 deletions
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,