From 4ae755de3ff4a37763aacc22ea119edab2099e84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Wed, 9 Feb 2022 10:40:08 +0200
Subject: [PATCH 1/1] DocumentWidget: "Paste Preceding Line" should be undoable
res/about/version.gmi | 1 +
src/ui/inputwidget.c | 17 ++++++++++++++++-
src/ui/inputwidget.h | 2 ++
src/ui/util.c | 2 +-
4 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/res/about/version.gmi b/res/about/version.gmi
index 41b4fed7..905b0221 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -10,6 +10,7 @@
+* Fixed "Paste Preceding Line" not being undoable.
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index aa55f3f0..6a8d428a 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -1115,7 +1115,14 @@ static void updateBuffered_InputWidget_(iInputWidget *d) {
}
void setText_InputWidget(iInputWidget *d, const iString *text) {
+}
+void setTextUndoable_InputWidget(iInputWidget *d, const iString *text, iBool isUndoable) {
if (!d) return;
pushUndo_InputWidget_(d);
if (d->inFlags & isUrl_InputWidgetFlag) {
if (prefs_App()->decodeUserVisibleURLs) {
iString *enc = collect_String(copy_String(text));
@@ -1139,7 +1146,9 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
iString *nfcText = collect_String(copy_String(text));
normalize_String(nfcText);
#if !LAGRANGE_USE_SYSTEM_TEXT_INPUT
clearUndo_InputWidget_(d);
splitToLines_(nfcText, &d->lines);
iAssert(!isEmpty_Array(&d->lines));
iForEach(Array, i, &d->lines) {
@@ -1175,6 +1184,12 @@ void setTextCStr_InputWidget(iInputWidget *d, const char *cstr) {
delete_String(str);
}
+void setTextUndoableCStr_InputWidget(iInputWidget *d, const char *cstr, iBool isUndoable) {
+}
void selectAll_InputWidget(iInputWidget *d) {
#if LAGRANGE_USE_SYSTEM_TEXT_INPUT
if (d->sysCtrl) {
diff --git a/src/ui/inputwidget.h b/src/ui/inputwidget.h
index 5a61ec22..000fa4b7 100644
--- a/src/ui/inputwidget.h
+++ b/src/ui/inputwidget.h
@@ -46,6 +46,8 @@ void setMode_InputWidget (iInputWidget *, enum iInputMode mode);
void setMaxLen_InputWidget (iInputWidget *, size_t maxLen);
void setText_InputWidget (iInputWidget *, const iString *text);
void setTextCStr_InputWidget (iInputWidget *, const char *cstr);
+void setTextUndoable_InputWidget (iInputWidget *, const iString *text, iBool isUndoable);
+void setTextUndoableCStr_InputWidget (iInputWidget *, const char *cstr, iBool isUndoable);
void setFont_InputWidget (iInputWidget *, int fontId);
void setContentPadding_InputWidget (iInputWidget , int left, int right); / only affects the text entry */
void setLineLimits_InputWidget (iInputWidget *, int minLines, int maxLines);
diff --git a/src/ui/util.c b/src/ui/util.c
index 31907721..5dd8a0bd 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1778,7 +1778,7 @@ iBool valueInputHandler_(iWidget *dlg, const char *cmd) {
}
else if (equal_Command(cmd, "valueinput.set")) {
iInputWidget *input = findChild_Widget(dlg, "input");
setTextCStr_InputWidget(input, suffixPtr_Command(cmd, "text"));
setTextUndoableCStr_InputWidget(input, suffixPtr_Command(cmd, "text"), iTrue);
validate_InputWidget(input);
return iTrue;
}
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).