diff --git a/components/synedit/syneditfoldedview.pp b/components/synedit/syneditfoldedview.pp index 7e7b91996c..ff8f68396b 100644 --- a/components/synedit/syneditfoldedview.pp +++ b/components/synedit/syneditfoldedview.pp @@ -284,7 +284,9 @@ type ColCount : Integer = 0; Skip: Boolean = False); procedure UnFoldAtTextIndexCollapsed(AStartIndex: Integer); (* UnFolds only if Index is in the fold, ignores cfcollapsed line, if unfolded / 1-based *) - function IsFoldedAtTextIndex(AStartIndex, ColIndex: Integer): Boolean; (* Checks xth Fold at nth TextIndex (all lines in buffer) / 1-based *) + function IsFoldedAtTextIndex(AStartIndex, ColIndex: Integer): Boolean; (* Checks xth Fold at nth TextIndex (all lines in buffer) / 1-based *) + function LogicalPosToNodeIndex(AStartIndex: Integer; LogX: Integer; (* Returns the index of the node, at the logical char pos *) + Previous: Boolean = False): Integer; procedure UnfoldAll; @@ -1829,6 +1831,39 @@ begin Result := hl.FoldLineLength(ALine, AFoldIndex); end; +function TSynEditFoldedView.LogicalPosToNodeIndex(AStartIndex: Integer; LogX: Integer; + Previous: Boolean): Integer; +var + hl: TSynCustomFoldHighlighter; + c, i: Integer; + nd: TSynFoldNodeInfo; +begin + if not(assigned(FHighLighter) and (FHighLighter is TSynCustomFoldHighlighter)) + then exit; + hl := TSynCustomFoldHighlighter(FHighLighter); + // AStartIndex is 0-based + // FoldTree is 1-based AND first line remains visble + c := hl.FoldNodeInfoCount[AStartIndex]; + if c = 0 then + exit(-1); + i := 0; + while i < c do begin + nd := hl.FoldNodeInfo[aStartIndex, i]; + if sfaOpen in nd.FoldAction then begin + if (nd.LogXStart >= LogX) then begin + dec(i); + if not Previous then + i := -1; + break; + end; + if (nd.LogXEnd >= LogX) then + break; + end; + inc(i); + end; + Result := i; +end; + procedure TSynEditFoldedView.FoldAtTextIndex(AStartIndex : Integer; ColIndex : Integer = -1; ColCount : Integer = 1; Skip: Boolean = False); var diff --git a/components/synedit/syneditmousecmds.pp b/components/synedit/syneditmousecmds.pp index a487f67f8c..c618645ac3 100644 --- a/components/synedit/syneditmousecmds.pp +++ b/components/synedit/syneditmousecmds.pp @@ -74,6 +74,8 @@ const emcoCodeFoldCollapsOne = 0; emcoCodeFoldCollapsAll = 1; + emcoCodeFoldCollapsAtCaret = 2; + emcoCodeFoldCollapsPreCaret = 3; emcoCodeFoldExpandOne = 0; emcoCodeFoldExpandAll = 1; diff --git a/components/synedit/syneditstrconst.pp b/components/synedit/syneditstrconst.pp index 137c83fef4..64413c65e2 100644 --- a/components/synedit/syneditstrconst.pp +++ b/components/synedit/syneditstrconst.pp @@ -290,7 +290,7 @@ const SYNS_emcContextMenu = 'Popup Menu'; SYNS_emcBreakPointToggle = 'Toggle Breakpoint'; SYNS_emcCodeFoldCollaps = 'Fold Code'; - SYNS_emcCodeFoldCollaps_opt = 'Nodes,One,All'; + SYNS_emcCodeFoldCollaps_opt = 'Nodes,One,All,"At Caret","Current Node"'; SYNS_emcCodeFoldExpand = 'Unfold Code'; SYNS_emcCodeFoldExpand_opt = 'Nodes,One,All'; SYNS_emcCodeFoldContextMenu = 'Fold Menu'; diff --git a/ide/mouseactiondialog.lrs b/ide/mouseactiondialog.lrs index 4d4c813082..7eab1c2d2f 100644 --- a/ide/mouseactiondialog.lrs +++ b/ide/mouseactiondialog.lrs @@ -1,5 +1,3 @@ -{ This is an automatically generated lazarus resource file } - LazarusResources.Add('TMouseaActionDialog','FORMDATA',[ 'TPF0'#19'TMouseaActionDialog'#18'MouseaActionDialog'#4'Left'#3#27#1#6'Height' +#3#213#0#3'Top'#3#237#0#5'Width'#3'j'#1#8'AutoSize'#9#11'BorderIcons'#11#12 diff --git a/ide/mouseactiondialog.pas b/ide/mouseactiondialog.pas index 332636c7d6..d5a7dfa0c0 100644 --- a/ide/mouseactiondialog.pas +++ b/ide/mouseactiondialog.pas @@ -109,6 +109,7 @@ end; procedure TMouseaActionDialog.ActionBoxChange(Sender: TObject); begin + OptBox.Items.Clear; OptBox.Items.CommaText := MouseCommandConfigName (TSynEditorMouseCommand(PtrUInt(Pointer(ActionBox.items.Objects[ActionBox.ItemIndex])))); if OptBox.Items.Count > 0 then begin @@ -149,6 +150,7 @@ begin CtrlCheck.Checked := (ssCtrl in MAct.ShiftMask) and (ssCtrl in MAct.Shift); if not(ssCtrl in MAct.ShiftMask) then CtrlCheck.State := cbGrayed; + OptBox.Items.Clear; OptBox.Items.CommaText := MouseCommandConfigName(MAct.Command); if OptBox.Items.Count > 0 then begin OptLabel.Caption := OptBox.Items[0];