summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-01-14 09:56:09 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2023-01-14 09:56:09 +0100
commit37775538c4c343a3de86b114953cd4c3363e18fa (patch)
treebdf062c1360fcf37682957b8401987309d418105 /src/drivers
parent82ac84a7c8f6f91837c4452ff2a5595c7e3b3c39 (diff)
Extend commit a4b33f8 to other uses of function convert_crlf()
Helper function convert_crlf() from file fl_wayland_clipboard_dnd.cxx has been repaired by commit a4b33f8 (13 jan 2023). But the same function was also in file Fl_cocoa.mm. This commit moves the repaired code to class Fl_Screen_Driver and has both fl_wayland_clipboard_dnd.cxx and Fl_cocoa.mm use it.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
index 89fcb2867..0a0d10cf2 100644
--- a/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
+++ b/src/drivers/Wayland/fl_wayland_clipboard_dnd.cxx
@@ -320,32 +320,6 @@ static void data_device_handle_selection(void *data, struct wl_data_device *data
}
-// turn '\r' characters into '\n' and "\r\n" sequences into '\n'
-// returns new length
-static size_t convert_crlf(char *s, size_t len) {
- char *src = (char *)memchr(s, '\r', len); // find first `\r` in buffer
- if (src) {
- char *dst = src;
- char *end = s + len;
- while (src < end) {
- if (*src == '\r') {
- if (src + 1 < end && *(src + 1) == '\n') {
- src++; // skip '\r'
- continue;
- } else {
- *dst++ = '\n'; // replace single '\r' with '\n'
- }
- } else {
- *dst++ = *src;
- }
- src++;
- }
- return (dst - s);
- }
- return len;
-}
-
-
// Gets from the system the clipboard or dnd text and puts it in fl_selection_buffer[1]
// which is enlarged if necessary.
static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) {
@@ -365,7 +339,7 @@ static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) {
fl_selection_buffer[1][ fl_selection_length[1] ] = 0;
return;
}
- n = convert_crlf(to, n);
+ n = Fl_Screen_Driver::convert_crlf(to, n);
to += n;
rest -= n;
}
@@ -398,7 +372,7 @@ static void get_clipboard_or_dragged_text(struct wl_data_offer *offer) {
close(fds[0]);
break;
}
- n = convert_crlf(from, n);
+ n = Fl_Screen_Driver::convert_crlf(from, n);
from += n;
}
fl_selection_length[1] = from - fl_selection_buffer[1];;