Skip to content

Commit

Permalink
Smarter Shift+Enter with alphabetical lists
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujan committed Mar 10, 2020
1 parent 6f15978 commit 176a51b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ V0.6.0
* Added a workaround for an old Qt bug, because of which, QTimer may not work after resuming from suspend or hibernation.
* Give focus to text-edit/side-pane with Escape.
* Don't let custom shortcuts be read from global config files.
* Yet smarter Shift+Enter with alphabetical lists.

V0.5.1
---------
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Latest version:

6 Mar 2020, V0.6.0
10 Mar 2020, V0.6.0

See "ChangeLog" for changes.
9 changes: 7 additions & 2 deletions feathernotes/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,27 @@ void TextEdit::keyPressEvent (QKeyEvent *event)
/* still check if a letter or number follows */
if (i < curBlockPos)
{
if (blockText.at (i).isLetter())
QChar c = blockText.at (i);
if (c.isLetter())
{
if (i + 1 < curBlockPos
&& !prefix.isEmpty() && !prefix.at (prefix.size() - 1).isSpace()
&& blockText.at (i + 1).isSpace())
{ // non-letter and non-space character -> singlle letter -> space
prefix = blockText.left (i + 2);
QChar cc = QChar (c.unicode() + 1);
if (cc.isLetter()) prefix.replace (c, cc);
}
else if (i + 2 < curBlockPos
&& !blockText.at (i + 1).isLetterOrNumber() && !blockText.at (i + 1).isSpace()
&& blockText.at (i + 2).isSpace())
{ // singlle letter -> non-letter and non-space character -> space
prefix = blockText.left (i + 3);
QChar cc = QChar (c.unicode() + 1);
if (cc.isLetter()) prefix.replace (c, cc);
}
}
else if (blockText.at (i).isNumber())
else if (c.isNumber())
{ // making lists with numbers
QString num;
while (i < curBlockPos)
Expand Down

0 comments on commit 176a51b

Please sign in to comment.