Skip to content

Commit

Permalink
Add ccSimplifySelection as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Jun 21, 2024
1 parent 2435417 commit fde6e85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
40 changes: 19 additions & 21 deletions Projects/Src/CompForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1065,27 +1065,13 @@ procedure TCompileForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
var AShortCut := ShortCut(Key, Shift);
if AShortCut = VK_ESCAPE then begin
if BStopCompile.Enabled then
BStopCompileClick(Self)
else begin
{ The built in Esc (SCI_CANCEL) simply drops all additional selections
and does not empty the main selection, It doesn't matter if Esc is
pressed once or twice. Implement our own behaviour, same as VSCode.
Also see https://github.com/microsoft/vscode/issues/118835. }
if FActiveMemo.SelectionCount > 1 then
FActiveMemo.RemoveAdditionalSelections
else if not FActiveMemo.SelEmpty then
FActiveMemo.SetEmptySelection;
FActiveMemo.ScrollCaretIntoView;
end;
end else if AShortCut = FBackNavButtonShortCut then begin
if BackNavButton.Enabled then
BackNavButtonClick(Self);
end else if AShortCut = FForwardNavButtonShortCut then begin
if ForwardNavButton.Enabled then
ForwardNavButtonClick(Self);
end else if (Key = VK_F6) and not(ssAlt in Shift) then begin
if (AShortCut = VK_ESCAPE) and BStopCompile.Enabled then
BStopCompileClick(Self)
else if (AShortCut = FBackNavButtonShortCut) and BackNavButton.Enabled then
BackNavButtonClick(Self)
else if (AShortCut = FForwardNavButtonShortCut) and ForwardNavButton.Enabled then
ForwardNavButtonClick(Self)
else if (Key = VK_F6) and not(ssAlt in Shift) then begin
{ Toggle focus between the active memo and the active bottom pane }
Key := 0;
if ActiveControl <> FActiveMemo then
Expand All @@ -1107,6 +1093,18 @@ procedure TCompileForm.FormKeyDown(Sender: TObject; var Key: Word;
ccSelectAllOccurrences:
if ESelectAllOccurrences.Enabled then
ESelectAllOccurrencesClick(Self);
ccSimplifySelection:
begin
{ The built in Esc (SCI_CANCEL) simply drops all additional selections
and does not empty the main selection, It doesn't matter if Esc is
pressed once or twice. Implement our own behaviour, same as VSCode.
Also see https://github.com/microsoft/vscode/issues/118835. }
if FActiveMemo.SelectionCount > 1 then
FActiveMemo.RemoveAdditionalSelections
else if not FActiveMemo.SelEmpty then
FActiveMemo.SetEmptySelection;
FActiveMemo.ScrollCaretIntoView;
end;
else if ComplexCommand <> ccNone then
raise Exception.Create('Unknown ComplexCommand');
end;
Expand Down
4 changes: 3 additions & 1 deletion Projects/Src/CompScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ interface
{ Commands which require more than 1 parameterless SCI_XXXXX and need help
from the container }
TCompScintComplexCommand = (ccNone, ccSelectNextOccurrence,
ccSelectAllOccurrences);
ccSelectAllOccurrences, ccSimplifySelection);

TCompScintEdit = class(TScintEdit)
private
Expand Down Expand Up @@ -400,6 +400,8 @@ procedure TCompScintEdit.UpdateComplexCommands;
AddComplexCommand(ShortCut(VK_OEM_PERIOD, [ssShift, ssAlt]), ccSelectNextOccurrence);
AddComplexCommand(ShortCut(VK_OEM_1, [ssShift, ssAlt]), ccSelectAllOccurrences);
end;

AddComplexCommand(ShortCut(VK_ESCAPE, []), ccSimplifySelection);
end;

procedure TCompScintEdit.SetUseFolding(const Value: Boolean);
Expand Down

0 comments on commit fde6e85

Please sign in to comment.