mirror of https://github.com/procxx/kepka.git
Revert markdown by backspace only temporarily.
Don't revert if you move cursor by arrows or Home/End.
This commit is contained in:
parent
24834ced9e
commit
544aef19b4
|
@ -335,8 +335,8 @@ private:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (item.position + tagLength + 1 < length) {
|
if (item.position + tagLength < length) {
|
||||||
const auto after = text[item.position + tagLength + 1];
|
const auto after = text[item.position + tagLength];
|
||||||
if (expression.badAfter.indexOf(after) >= 0) {
|
if (expression.badAfter.indexOf(after) >= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2194,6 +2194,14 @@ void InputField::keyPressEventInner(QKeyEvent *e) {
|
||||||
&& _submitSettings != SubmitSettings::None
|
&& _submitSettings != SubmitSettings::None
|
||||||
&& _submitSettings != SubmitSettings::CtrlEnter);
|
&& _submitSettings != SubmitSettings::CtrlEnter);
|
||||||
bool enter = (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return);
|
bool enter = (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return);
|
||||||
|
if (e->key() == Qt::Key_Left
|
||||||
|
|| e->key() == Qt::Key_Right
|
||||||
|
|| e->key() == Qt::Key_Up
|
||||||
|
|| e->key() == Qt::Key_Down
|
||||||
|
|| e->key() == Qt::Key_Home
|
||||||
|
|| e->key() == Qt::Key_End) {
|
||||||
|
_reverseMarkdownReplacement = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (macmeta && e->key() == Qt::Key_Backspace) {
|
if (macmeta && e->key() == Qt::Key_Backspace) {
|
||||||
QTextCursor tc(textCursor()), start(tc);
|
QTextCursor tc(textCursor()), start(tc);
|
||||||
|
@ -2492,7 +2500,10 @@ bool InputField::commitMarkdownReplacement(
|
||||||
cursor.setPosition(from);
|
cursor.setPosition(from);
|
||||||
cursor.setPosition(till, QTextCursor::KeepAnchor);
|
cursor.setPosition(till, QTextCursor::KeepAnchor);
|
||||||
auto format = _defaultCharFormat;
|
auto format = _defaultCharFormat;
|
||||||
format.setProperty(kReplaceTagId, tag);
|
if (!edge.isEmpty()) {
|
||||||
|
format.setProperty(kReplaceTagId, edge);
|
||||||
|
_reverseMarkdownReplacement = true;
|
||||||
|
}
|
||||||
_insertedTagsAreFromMime = false;
|
_insertedTagsAreFromMime = false;
|
||||||
cursor.insertText(insert, format);
|
cursor.insertText(insert, format);
|
||||||
_insertedTags.clear();
|
_insertedTags.clear();
|
||||||
|
@ -2538,7 +2549,8 @@ bool InputField::revertFormatReplace() {
|
||||||
ApplyTagFormat(format, current);
|
ApplyTagFormat(format, current);
|
||||||
replaceCursor.insertText(what.toString(), format);
|
replaceCursor.insertText(what.toString(), format);
|
||||||
return true;
|
return true;
|
||||||
} else if (current.hasProperty(kReplaceTagId)) {
|
} else if (_reverseMarkdownReplacement
|
||||||
|
&& current.hasProperty(kReplaceTagId)) {
|
||||||
const auto tag = current.property(kReplaceTagId).toString();
|
const auto tag = current.property(kReplaceTagId).toString();
|
||||||
if (tag.isEmpty()) {
|
if (tag.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -356,6 +356,7 @@ private:
|
||||||
int _minHeight = -1;
|
int _minHeight = -1;
|
||||||
int _maxHeight = -1;
|
int _maxHeight = -1;
|
||||||
bool _forcePlaceholderHidden = false;
|
bool _forcePlaceholderHidden = false;
|
||||||
|
bool _reverseMarkdownReplacement = false;
|
||||||
|
|
||||||
object_ptr<Inner> _inner;
|
object_ptr<Inner> _inner;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue