mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 17:17:52 +02:00
IDE, SynEdit: command to toggle fold on current line. Issue #41359
This commit is contained in:
parent
5f5a6dca90
commit
21d8cebd73
@ -3653,8 +3653,25 @@ procedure TSynEditFoldedView.ProcessMySynCommand(Sender: TObject;
|
||||
AfterProcessing: boolean; var Handled: boolean;
|
||||
var Command: TSynEditorCommand; var AChar: TUTF8Char; Data: pointer;
|
||||
HandlerData: pointer);
|
||||
var
|
||||
CY: Integer;
|
||||
|
||||
procedure FoldAtCaret;
|
||||
var
|
||||
CY: Integer;
|
||||
begin
|
||||
CY := ExpandedLineForBlockAtLine(FCaret.LinePos);
|
||||
if CY > 0 then begin
|
||||
FoldAtTextIndex(CY-1);
|
||||
FCaret.ChangeOnTouch; // setting the caret always clears selection (even setting to current pos / no change)
|
||||
FCaret.LineCharPos:= Point(1, CY);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure UnFoldAtCaret;
|
||||
begin
|
||||
UnFoldAtTextIndex(FCaret.LinePos-1);
|
||||
FCaret.Touch;
|
||||
end;
|
||||
|
||||
begin
|
||||
if Handled then
|
||||
exit;
|
||||
@ -3674,18 +3691,20 @@ begin
|
||||
end;
|
||||
EcFoldCurrent:
|
||||
begin
|
||||
CY := ExpandedLineForBlockAtLine(FCaret.LinePos);
|
||||
if CY > 0 then begin
|
||||
FoldAtTextIndex(CY-1);
|
||||
FCaret.ChangeOnTouch; // setting the caret always clears selection (even setting to current pos / no change)
|
||||
FCaret.LineCharPos:= Point(1, CY);
|
||||
end;
|
||||
FoldAtCaret;
|
||||
Handled := True;
|
||||
end;
|
||||
EcUnFoldCurrent:
|
||||
begin
|
||||
UnFoldAtTextIndex(FCaret.LinePos-1);
|
||||
FCaret.Touch;
|
||||
UnFoldAtCaret;
|
||||
Handled := True;
|
||||
end;
|
||||
EcFoldToggle:
|
||||
begin
|
||||
if IsFolded(FCaret.LinePos) then
|
||||
UnFoldAtCaret
|
||||
else
|
||||
FoldAtCaret;
|
||||
Handled := True;
|
||||
end;
|
||||
end;
|
||||
|
@ -232,6 +232,7 @@ const
|
||||
EcFoldCurrent = 381;
|
||||
EcUnFoldCurrent = 382;
|
||||
EcToggleMarkupWord = 383;
|
||||
EcFoldToggle = 384;
|
||||
|
||||
ecZoomOut = 400;
|
||||
ecZoomIn = 401;
|
||||
@ -516,7 +517,7 @@ end;
|
||||
{ Command mapping routines }
|
||||
|
||||
const
|
||||
EditorCommandStrs: array[0..174] of TIdentMapEntry = (
|
||||
EditorCommandStrs: array[0..175] of TIdentMapEntry = (
|
||||
(Value: ecNone; Name: 'ecNone'),
|
||||
(Value: ecLeft; Name: 'ecLeft'),
|
||||
(Value: ecRight; Name: 'ecRight'),
|
||||
@ -691,6 +692,7 @@ const
|
||||
(Value: EcFoldLevel0; Name: 'EcFoldLevel0'),
|
||||
(Value: EcFoldCurrent; Name: 'EcFoldCurrent'),
|
||||
(Value: EcUnFoldCurrent; Name: 'EcUnFoldCurrent'),
|
||||
(Value: EcFoldToggle; Name: 'EcFoldToggle'),
|
||||
(Value: EcToggleMarkupWord; Name: 'EcToggleMarkupWord')
|
||||
);
|
||||
|
||||
|
@ -633,6 +633,7 @@ begin
|
||||
EcFoldLevel0 : Result:= srkmecUnFoldAll;
|
||||
EcFoldCurrent : Result:= srkmecFoldCurrent;
|
||||
EcUnFoldCurrent : Result:= srkmecUnFoldCurrent;
|
||||
EcFoldToggle : Result:= srkmecFoldToggle;
|
||||
EcToggleMarkupWord : Result := srkmecToggleMarkupWord;
|
||||
|
||||
// file menu
|
||||
@ -3059,6 +3060,7 @@ begin
|
||||
AddDefault(C, 'Unfold all', srkmecUnFoldAll, EcFoldLevel0);
|
||||
AddDefault(C, 'Fold at Cursor', srkmecFoldCurrent, EcFoldCurrent);
|
||||
AddDefault(C, 'Unfold at Cursor', srkmecUnFoldCurrent, EcUnFoldCurrent);
|
||||
AddDefault(C, 'Toggle Fold at Cursor', srkmecFoldToggle, EcFoldToggle);
|
||||
|
||||
// marker - without menu items in the IDE bar
|
||||
C:=Categories[AddCategory('Marker',srkmCatMarker,IDECmdScopeSrcEditOnly)];
|
||||
|
@ -3224,6 +3224,7 @@ resourcestring
|
||||
srkmEcFoldLevel = 'Fold to Level %d';
|
||||
srkmecUnFoldAll = 'Unfold all';
|
||||
srkmecFoldCurrent = 'Fold at Cursor';
|
||||
srkmecFoldToggle = 'Toggle Fold at Cursor';
|
||||
srkmecUnFoldCurrent = 'Unfold at Cursor';
|
||||
srkmecToggleMarkupWord = 'Toggle Current-Word highlight';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user