Extend camel-case cursor movement

Fix small issue with forward movement, and overwrite deleting to start
or end of word (normally Ctrl+Delete and Ctrl+Backspace)

Reviewed-by: Erik Verbruggen
This commit is contained in:
mae
2010-11-10 12:26:18 +01:00
parent dfe4c7f58e
commit d7516902c9

View File

@@ -1270,7 +1270,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
state = 7;
break;
default:
return cursor.movePosition(QTextCursor::WordRight, mode);
return true;
}
break;
case 4:
@@ -1288,7 +1288,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
state = 7;
break;
default:
return cursor.movePosition(QTextCursor::WordRight, mode);
return true;
}
break;
case 6:
@@ -1299,7 +1299,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
state = 7;
break;
default:
return cursor.movePosition(QTextCursor::WordRight, mode);
return true;
}
break;
case 7:
@@ -1577,7 +1577,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
e->accept();
QTextCursor c = textCursor();
int pos = c.position();
c.movePosition(QTextCursor::PreviousWord);
camelCaseLeft(c, QTextCursor::MoveAnchor);
int targetpos = c.position();
forever {
handleBackspaceKey();
@@ -1587,6 +1587,18 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
pos = cpos;
}
return;
} else if (!ro && e == QKeySequence::DeleteStartOfWord && !textCursor().hasSelection()) {
e->accept();
QTextCursor c = textCursor();
camelCaseLeft(c, QTextCursor::KeepAnchor);
c.removeSelectedText();
return;
} else if (!ro && e == QKeySequence::DeleteEndOfWord && !textCursor().hasSelection()) {
e->accept();
QTextCursor c = textCursor();
camelCaseRight(c, QTextCursor::KeepAnchor);
c.removeSelectedText();
return;
} else switch (e->key()) {