add 'edited' read-only textbox property

This commit is contained in:
MihailRis
2025-03-12 02:32:41 +03:00
parent 433c12a17a
commit 93f20b1746
5 changed files with 30 additions and 4 deletions
+18 -4
View File
@@ -141,10 +141,7 @@ namespace gui {
auto action =
std::make_unique<InputAction>(getTextBoxWeakptr(), pos, string);
history.store(std::move(action), erasing);
pos = -1;
length = 0;
ss = {};
erasing = false;
reset();
}
void undo() {
@@ -160,6 +157,17 @@ namespace gui {
history.redo();
locked = false;
}
void reset() {
pos = -1;
length = 0;
erasing = false;
ss = {};
}
bool isSynced() const {
return length == 0;
}
private:
TextBox& textBox;
ActionsHistory& history;
@@ -556,6 +564,10 @@ bool TextBox::isEditable() const {
return editable;
}
bool TextBox::isEdited() const {
return history->size() != 0 || !historian->isSynced();
}
size_t TextBox::getSelectionStart() const {
return selectionStart;
}
@@ -986,6 +998,8 @@ const std::wstring& TextBox::getText() const {
void TextBox::setText(const std::wstring& value) {
this->input = value;
input.erase(std::remove(input.begin(), input.end(), '\r'), input.end());
historian->reset();
history->clear();
refreshSyntax();
}