SynEdit: introduce new commands for the new smart word right/left logic

git-svn-id: trunk@57876 -
This commit is contained in:
ondrej 2018-05-09 16:49:55 +00:00
parent 239d5a386c
commit 56996beaa2
3 changed files with 23 additions and 11 deletions

View File

@ -6657,13 +6657,15 @@ begin
end;
// word selection
ecWordLeft, ecSelWordLeft, ecColSelWordLeft,
ecWordEndLeft, ecSelWordEndLeft, ecHalfWordLeft, ecSelHalfWordLeft:
ecWordEndLeft, ecSelWordEndLeft, ecHalfWordLeft, ecSelHalfWordLeft,
ecSmartWordLeft, ecSelSmartWordLeft:
begin
case Command of
ecWordEndLeft, ecSelWordEndLeft: CaretNew := PrevWordLogicalPos(swbWordEnd);
ecHalfWordLeft, ecSelHalfWordLeft: CaretNew := PrevWordLogicalPos(swbCaseChange);
ecWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmart);
ecSelWordLeft, ecColSelWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmartSel);
ecSmartWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmart);
ecSelSmartWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmartSel);
else CaretNew := PrevWordLogicalPos;
end;
if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then begin
CY := FindNextUnfoldedLine(CaretNew.Y, False);
@ -6672,13 +6674,15 @@ begin
FCaret.LineBytePos := CaretNew;
end;
ecWordRight, ecSelWordRight, ecColSelWordRight,
ecWordEndRight, ecSelWordEndRight, ecHalfWordRight, ecSelHalfWordRight:
ecWordEndRight, ecSelWordEndRight, ecHalfWordRight, ecSelHalfWordRight,
ecSmartWordRight, ecSelSmartWordRight:
begin
case Command of
ecWordEndRight, ecSelWordEndRight: CaretNew := NextWordLogicalPos(swbWordEnd);
ecHalfWordRight, ecSelHalfWordRight: CaretNew := NextWordLogicalPos(swbCaseChange);
ecWordRight: CaretNew := NextWordLogicalPos(swbWordSmart);
ecSelWordRight, ecColSelWordRight: CaretNew := NextWordLogicalPos(swbWordSmartSel);
ecSmartWordRight: CaretNew := NextWordLogicalPos(swbWordSmart);
ecSelSmartWordRight: CaretNew := NextWordLogicalPos(swbWordSmartSel);
else CaretNew := NextWordLogicalPos;
end;
if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then
CaretNew := Point(1, FindNextUnfoldedLine(CaretNew.Y, True));

View File

@ -85,8 +85,10 @@ const
ecLineTextStart = 18; // Move cursor to the first none whitespace in the line
ecWordEndLeft = 19; // Move cursor left one word (to end of word)
ecWordEndRight = 20; // Move cursor right one word (to end of word)
ecHalfWordLeft = 21; // Move cursor left to word-begin/end or case change lower to uppper
ecHalfWordRight = 22; // Move cursor right to word-begin/end or case change lower to uppper
ecHalfWordLeft = 21; // Move cursor left to word-begin/end or case change lower to uppper
ecHalfWordRight = 22; // Move cursor right to word-begin/end or case change lower to uppper
ecSmartWordLeft = 23; // Move cursor left one word with smart boundaries (either start of current word or end of previous word)
ecSmartWordRight = 24; // Move cursor right one word with smart boundaries (either end of current word or start of next word)
// Allow selecting with any movement
ecStickySelection = 95;
@ -124,6 +126,8 @@ const
ecSelWordEndRight = ecWordEndRight + ecSelection;
ecSelHalfWordLeft = ecHalfWordLeft + ecSelection;
ecSelHalfWordRight= ecHalfWordRight + ecSelection;
ecSelSmartWordLeft= ecSmartWordLeft + ecSelection;
ecSelSmartWordRight=ecSmartWordRight + ecSelection;
ecSelCmdRangeStart = ecLeft + ecSelection;
ecSelCmdRangeEnd = ecLeft + ecSelection + 49;
@ -490,7 +494,7 @@ end;
{ Command mapping routines }
const
EditorCommandStrs: array[0..153] of TIdentMapEntry = (
EditorCommandStrs: array[0..157] of TIdentMapEntry = (
(Value: ecNone; Name: 'ecNone'),
(Value: ecLeft; Name: 'ecLeft'),
(Value: ecRight; Name: 'ecRight'),
@ -502,6 +506,8 @@ const
(Value: ecWordEndRight; Name: 'ecWordEndRight'),
(Value: ecHalfWordLeft; Name: 'ecHalfWordLeft'),
(Value: ecHalfWordRight; Name: 'ecHalfWordRight'),
(Value: ecSmartWordLeft; Name: 'ecSmartWordLeft'),
(Value: ecSmartWordRight; Name: 'ecSmartWordRight'),
(Value: ecLineStart; Name: 'ecLineStart'),
(Value: ecLineEnd; Name: 'ecLineEnd'),
(Value: ecPageUp; Name: 'ecPageUp'),
@ -528,6 +534,8 @@ const
(Value: ecSelWordEndRight; Name: 'ecSelWordEndRight'),
(Value: ecSelHalfWordLeft; Name: 'ecSelHalfWordLeft'),
(Value: ecSelHalfWordRight; Name: 'ecSelHalfWordRight'),
(Value: ecSelSmartWordLeft; Name: 'ecSelSmartWordLeft'),
(Value: ecSelSmartWordRight; Name: 'ecSelSmartWordRight'),
(Value: ecSelLineStart; Name: 'ecSelLineStart'),
(Value: ecSelLineEnd; Name: 'ecSelLineEnd'),
(Value: ecSelPageUp; Name: 'ecSelPageUp'),

View File

@ -2460,7 +2460,7 @@ procedure TSynCustomPluginMultiCaret.ProcessAllSynCommand(Sender: TObject; After
Include(FStateFlags, sfProcessingRepeat);
case Command of
ecLeft, ecUp, ecWordLeft, ecLineStart, ecPageUp, ecPageLeft,
ecPageTop, ecLineTextStart, ecWordEndLeft, ecHalfWordLeft:
ecPageTop, ecLineTextStart, ecWordEndLeft, ecHalfWordLeft, ecSmartWordLeft:
begin
Carets.StartIteratorAtFirst;
while Carets.IterateNextUp do begin
@ -2646,7 +2646,7 @@ begin
Include(FStateFlags, sfSkipUndoCarets);
Include(FStateFlags, sfExtendingColumnSel);
end;
ecLeft..ecHalfWordRight: begin
ecLeft..ecSmartWordRight: begin
Include(FStateFlags, sfSkipUndoCarets);
if ActiveMode = mcmMoveAllCarets then begin
Include(FStateFlags, sfProcessingCmd);