mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MdEditOperations: Ctrl+U to delete till the space of block
This commit is contained in:
parent
2e7b2e1e5d
commit
9b49de3ab5
@ -25,6 +25,7 @@ public:
|
|||||||
// Need to call setTextCursor() to make it take effect.
|
// Need to call setTextCursor() to make it take effect.
|
||||||
static void moveCursorFirstNonSpaceCharacter(QTextCursor &p_cursor,
|
static void moveCursorFirstNonSpaceCharacter(QTextCursor &p_cursor,
|
||||||
QTextCursor::MoveMode p_mode);
|
QTextCursor::MoveMode p_mode);
|
||||||
|
|
||||||
// Indent current block as next/previous block.
|
// Indent current block as next/previous block.
|
||||||
// Return true if some changes have been made.
|
// Return true if some changes have been made.
|
||||||
// @p_cursor will be placed at the position after inserting leading spaces.
|
// @p_cursor will be placed at the position after inserting leading spaces.
|
||||||
|
@ -1383,7 +1383,7 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos)
|
|||||||
case Qt::Key_AsciiCircum:
|
case Qt::Key_AsciiCircum:
|
||||||
{
|
{
|
||||||
if (modifiers == Qt::ShiftModifier) {
|
if (modifiers == Qt::ShiftModifier) {
|
||||||
// ~, go to first non-space character of current line (block).
|
// ^, go to first non-space character of current line (block).
|
||||||
tryGetRepeatToken(m_keys, m_tokens);
|
tryGetRepeatToken(m_keys, m_tokens);
|
||||||
if (!m_keys.isEmpty()) {
|
if (!m_keys.isEmpty()) {
|
||||||
// Not a valid sequence.
|
// Not a valid sequence.
|
||||||
|
@ -565,8 +565,15 @@ bool VMdEditOperations::handleKeyU(QKeyEvent *p_event)
|
|||||||
if (cursor.atBlockStart()) {
|
if (cursor.atBlockStart()) {
|
||||||
ret = cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
|
ret = cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
|
||||||
} else {
|
} else {
|
||||||
|
int indent = VEditUtils::fetchIndentation(cursor.block());
|
||||||
|
int pib = cursor.positionInBlock();
|
||||||
|
if (pib <= indent) {
|
||||||
ret = cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
ret = cursor.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||||
|
} else {
|
||||||
|
ret = cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, pib - indent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
cursor.removeSelectedText();
|
cursor.removeSelectedText();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user