Commit d7516902 authored by mae's avatar mae
Browse files

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
parent dfe4c7f5
...@@ -1270,7 +1270,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m ...@@ -1270,7 +1270,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
state = 7; state = 7;
break; break;
default: default:
return cursor.movePosition(QTextCursor::WordRight, mode); return true;
} }
break; break;
case 4: case 4:
...@@ -1288,7 +1288,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m ...@@ -1288,7 +1288,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
state = 7; state = 7;
break; break;
default: default:
return cursor.movePosition(QTextCursor::WordRight, mode); return true;
} }
break; break;
case 6: case 6:
...@@ -1299,7 +1299,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m ...@@ -1299,7 +1299,7 @@ bool BaseTextEditor::camelCaseRight(QTextCursor &cursor, QTextCursor::MoveMode m
state = 7; state = 7;
break; break;
default: default:
return cursor.movePosition(QTextCursor::WordRight, mode); return true;
} }
break; break;
case 7: case 7:
...@@ -1577,7 +1577,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e) ...@@ -1577,7 +1577,7 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
e->accept(); e->accept();
QTextCursor c = textCursor(); QTextCursor c = textCursor();
int pos = c.position(); int pos = c.position();
c.movePosition(QTextCursor::PreviousWord); camelCaseLeft(c, QTextCursor::MoveAnchor);
int targetpos = c.position(); int targetpos = c.position();
forever { forever {
handleBackspaceKey(); handleBackspaceKey();
...@@ -1587,6 +1587,18 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e) ...@@ -1587,6 +1587,18 @@ void BaseTextEditor::keyPressEvent(QKeyEvent *e)
pos = cpos; pos = cpos;
} }
return; 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()) { } else switch (e->key()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment