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; end;
// word selection // word selection
ecWordLeft, ecSelWordLeft, ecColSelWordLeft, ecWordLeft, ecSelWordLeft, ecColSelWordLeft,
ecWordEndLeft, ecSelWordEndLeft, ecHalfWordLeft, ecSelHalfWordLeft: ecWordEndLeft, ecSelWordEndLeft, ecHalfWordLeft, ecSelHalfWordLeft,
ecSmartWordLeft, ecSelSmartWordLeft:
begin begin
case Command of case Command of
ecWordEndLeft, ecSelWordEndLeft: CaretNew := PrevWordLogicalPos(swbWordEnd); ecWordEndLeft, ecSelWordEndLeft: CaretNew := PrevWordLogicalPos(swbWordEnd);
ecHalfWordLeft, ecSelHalfWordLeft: CaretNew := PrevWordLogicalPos(swbCaseChange); ecHalfWordLeft, ecSelHalfWordLeft: CaretNew := PrevWordLogicalPos(swbCaseChange);
ecWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmart); ecSmartWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmart);
ecSelWordLeft, ecColSelWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmartSel); ecSelSmartWordLeft: CaretNew := PrevWordLogicalPos(swbWordSmartSel);
else CaretNew := PrevWordLogicalPos;
end; end;
if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then begin if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then begin
CY := FindNextUnfoldedLine(CaretNew.Y, False); CY := FindNextUnfoldedLine(CaretNew.Y, False);
@ -6672,13 +6674,15 @@ begin
FCaret.LineBytePos := CaretNew; FCaret.LineBytePos := CaretNew;
end; end;
ecWordRight, ecSelWordRight, ecColSelWordRight, ecWordRight, ecSelWordRight, ecColSelWordRight,
ecWordEndRight, ecSelWordEndRight, ecHalfWordRight, ecSelHalfWordRight: ecWordEndRight, ecSelWordEndRight, ecHalfWordRight, ecSelHalfWordRight,
ecSmartWordRight, ecSelSmartWordRight:
begin begin
case Command of case Command of
ecWordEndRight, ecSelWordEndRight: CaretNew := NextWordLogicalPos(swbWordEnd); ecWordEndRight, ecSelWordEndRight: CaretNew := NextWordLogicalPos(swbWordEnd);
ecHalfWordRight, ecSelHalfWordRight: CaretNew := NextWordLogicalPos(swbCaseChange); ecHalfWordRight, ecSelHalfWordRight: CaretNew := NextWordLogicalPos(swbCaseChange);
ecWordRight: CaretNew := NextWordLogicalPos(swbWordSmart); ecSmartWordRight: CaretNew := NextWordLogicalPos(swbWordSmart);
ecSelWordRight, ecColSelWordRight: CaretNew := NextWordLogicalPos(swbWordSmartSel); ecSelSmartWordRight: CaretNew := NextWordLogicalPos(swbWordSmartSel);
else CaretNew := NextWordLogicalPos;
end; end;
if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then if FFoldedLinesView.FoldedAtTextIndex[CaretNew.Y - 1] then
CaretNew := Point(1, FindNextUnfoldedLine(CaretNew.Y, True)); 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 ecLineTextStart = 18; // Move cursor to the first none whitespace in the line
ecWordEndLeft = 19; // Move cursor left one word (to end of word) ecWordEndLeft = 19; // Move cursor left one word (to end of word)
ecWordEndRight = 20; // Move cursor right 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 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 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 // Allow selecting with any movement
ecStickySelection = 95; ecStickySelection = 95;
@ -124,6 +126,8 @@ const
ecSelWordEndRight = ecWordEndRight + ecSelection; ecSelWordEndRight = ecWordEndRight + ecSelection;
ecSelHalfWordLeft = ecHalfWordLeft + ecSelection; ecSelHalfWordLeft = ecHalfWordLeft + ecSelection;
ecSelHalfWordRight= ecHalfWordRight + ecSelection; ecSelHalfWordRight= ecHalfWordRight + ecSelection;
ecSelSmartWordLeft= ecSmartWordLeft + ecSelection;
ecSelSmartWordRight=ecSmartWordRight + ecSelection;
ecSelCmdRangeStart = ecLeft + ecSelection; ecSelCmdRangeStart = ecLeft + ecSelection;
ecSelCmdRangeEnd = ecLeft + ecSelection + 49; ecSelCmdRangeEnd = ecLeft + ecSelection + 49;
@ -490,7 +494,7 @@ end;
{ Command mapping routines } { Command mapping routines }
const const
EditorCommandStrs: array[0..153] of TIdentMapEntry = ( EditorCommandStrs: array[0..157] of TIdentMapEntry = (
(Value: ecNone; Name: 'ecNone'), (Value: ecNone; Name: 'ecNone'),
(Value: ecLeft; Name: 'ecLeft'), (Value: ecLeft; Name: 'ecLeft'),
(Value: ecRight; Name: 'ecRight'), (Value: ecRight; Name: 'ecRight'),
@ -502,6 +506,8 @@ const
(Value: ecWordEndRight; Name: 'ecWordEndRight'), (Value: ecWordEndRight; Name: 'ecWordEndRight'),
(Value: ecHalfWordLeft; Name: 'ecHalfWordLeft'), (Value: ecHalfWordLeft; Name: 'ecHalfWordLeft'),
(Value: ecHalfWordRight; Name: 'ecHalfWordRight'), (Value: ecHalfWordRight; Name: 'ecHalfWordRight'),
(Value: ecSmartWordLeft; Name: 'ecSmartWordLeft'),
(Value: ecSmartWordRight; Name: 'ecSmartWordRight'),
(Value: ecLineStart; Name: 'ecLineStart'), (Value: ecLineStart; Name: 'ecLineStart'),
(Value: ecLineEnd; Name: 'ecLineEnd'), (Value: ecLineEnd; Name: 'ecLineEnd'),
(Value: ecPageUp; Name: 'ecPageUp'), (Value: ecPageUp; Name: 'ecPageUp'),
@ -528,6 +534,8 @@ const
(Value: ecSelWordEndRight; Name: 'ecSelWordEndRight'), (Value: ecSelWordEndRight; Name: 'ecSelWordEndRight'),
(Value: ecSelHalfWordLeft; Name: 'ecSelHalfWordLeft'), (Value: ecSelHalfWordLeft; Name: 'ecSelHalfWordLeft'),
(Value: ecSelHalfWordRight; Name: 'ecSelHalfWordRight'), (Value: ecSelHalfWordRight; Name: 'ecSelHalfWordRight'),
(Value: ecSelSmartWordLeft; Name: 'ecSelSmartWordLeft'),
(Value: ecSelSmartWordRight; Name: 'ecSelSmartWordRight'),
(Value: ecSelLineStart; Name: 'ecSelLineStart'), (Value: ecSelLineStart; Name: 'ecSelLineStart'),
(Value: ecSelLineEnd; Name: 'ecSelLineEnd'), (Value: ecSelLineEnd; Name: 'ecSelLineEnd'),
(Value: ecSelPageUp; Name: 'ecSelPageUp'), (Value: ecSelPageUp; Name: 'ecSelPageUp'),

View File

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