summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-02-09 10:40:08 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-02-09 10:40:40 +0200
commit4ae755de3ff4a37763aacc22ea119edab2099e84 (patch)
treec7f11d470fe26b3daedb258284b1f52c0eef3cf2 /src
parent3701cdcdc96beaf8dd0aa5c6fd82db5ea760652f (diff)
DocumentWidget: "Paste Preceding Line" should be undoable
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwidget.c17
-rw-r--r--src/ui/inputwidget.h2
-rw-r--r--src/ui/util.c2
3 files changed, 19 insertions, 2 deletions
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) {
1115} 1115}
1116 1116
1117void setText_InputWidget(iInputWidget *d, const iString *text) { 1117void setText_InputWidget(iInputWidget *d, const iString *text) {
1118 setTextUndoable_InputWidget(d, text, iFalse);
1119}
1120
1121void setTextUndoable_InputWidget(iInputWidget *d, const iString *text, iBool isUndoable) {
1118 if (!d) return; 1122 if (!d) return;
1123 if (isUndoable) {
1124 pushUndo_InputWidget_(d);
1125 }
1119 if (d->inFlags & isUrl_InputWidgetFlag) { 1126 if (d->inFlags & isUrl_InputWidgetFlag) {
1120 if (prefs_App()->decodeUserVisibleURLs) { 1127 if (prefs_App()->decodeUserVisibleURLs) {
1121 iString *enc = collect_String(copy_String(text)); 1128 iString *enc = collect_String(copy_String(text));
@@ -1139,7 +1146,9 @@ void setText_InputWidget(iInputWidget *d, const iString *text) {
1139 iString *nfcText = collect_String(copy_String(text)); 1146 iString *nfcText = collect_String(copy_String(text));
1140 normalize_String(nfcText); 1147 normalize_String(nfcText);
1141#if !LAGRANGE_USE_SYSTEM_TEXT_INPUT 1148#if !LAGRANGE_USE_SYSTEM_TEXT_INPUT
1142 clearUndo_InputWidget_(d); 1149 if (!isUndoable) {
1150 clearUndo_InputWidget_(d);
1151 }
1143 splitToLines_(nfcText, &d->lines); 1152 splitToLines_(nfcText, &d->lines);
1144 iAssert(!isEmpty_Array(&d->lines)); 1153 iAssert(!isEmpty_Array(&d->lines));
1145 iForEach(Array, i, &d->lines) { 1154 iForEach(Array, i, &d->lines) {
@@ -1175,6 +1184,12 @@ void setTextCStr_InputWidget(iInputWidget *d, const char *cstr) {
1175 delete_String(str); 1184 delete_String(str);
1176} 1185}
1177 1186
1187void setTextUndoableCStr_InputWidget(iInputWidget *d, const char *cstr, iBool isUndoable) {
1188 iString *str = newCStr_String(cstr);
1189 setTextUndoable_InputWidget(d, str, isUndoable);
1190 delete_String(str);
1191}
1192
1178void selectAll_InputWidget(iInputWidget *d) { 1193void selectAll_InputWidget(iInputWidget *d) {
1179#if LAGRANGE_USE_SYSTEM_TEXT_INPUT 1194#if LAGRANGE_USE_SYSTEM_TEXT_INPUT
1180 if (d->sysCtrl) { 1195 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);
46void setMaxLen_InputWidget (iInputWidget *, size_t maxLen); 46void setMaxLen_InputWidget (iInputWidget *, size_t maxLen);
47void setText_InputWidget (iInputWidget *, const iString *text); 47void setText_InputWidget (iInputWidget *, const iString *text);
48void setTextCStr_InputWidget (iInputWidget *, const char *cstr); 48void setTextCStr_InputWidget (iInputWidget *, const char *cstr);
49void setTextUndoable_InputWidget (iInputWidget *, const iString *text, iBool isUndoable);
50void setTextUndoableCStr_InputWidget (iInputWidget *, const char *cstr, iBool isUndoable);
49void setFont_InputWidget (iInputWidget *, int fontId); 51void setFont_InputWidget (iInputWidget *, int fontId);
50void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */ 52void setContentPadding_InputWidget (iInputWidget *, int left, int right); /* only affects the text entry */
51void setLineLimits_InputWidget (iInputWidget *, int minLines, int maxLines); 53void 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) {
1778 } 1778 }
1779 else if (equal_Command(cmd, "valueinput.set")) { 1779 else if (equal_Command(cmd, "valueinput.set")) {
1780 iInputWidget *input = findChild_Widget(dlg, "input"); 1780 iInputWidget *input = findChild_Widget(dlg, "input");
1781 setTextCStr_InputWidget(input, suffixPtr_Command(cmd, "text")); 1781 setTextUndoableCStr_InputWidget(input, suffixPtr_Command(cmd, "text"), iTrue);
1782 validate_InputWidget(input); 1782 validate_InputWidget(input);
1783 return iTrue; 1783 return iTrue;
1784 } 1784 }