diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index c55e49a676..8a315f4648 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -207,6 +207,11 @@ type ); TSynEditTextFlags = set of TSynEditTextFlag; + TSynEditHasTextFlag = ( + shtIncludeVirtual // trailing spaces + ); + TSynEditHasTextFlags = set of TSynEditHasTextFlag; + TSynStateFlag = (sfCaretChanged, sfHideCursor, sfEnsureCursorPos, sfEnsureCursorPosAtResize, sfEnsureCursorPosForEditRight, sfEnsureCursorPosForEditLeft, sfExplicitTopLine, sfExplicitLeftChar, // when doing EnsureCursorPos keep top/Left, if they where set explicitly after the caret (only applies before handle creation) @@ -945,6 +950,7 @@ type // Text Raw (not undo-able) procedure Clear; procedure Append(const Value: String); + function HasText(AFlags: TSynEditHasTextFlags = []): Boolean; property LineText: string read GetLineText write SetLineText; // textline at CaretY property Text: string read SynGetText write SynSetText; // No uncommited (trailing/trimmable) spaces @@ -4715,6 +4721,16 @@ begin FTheLinesView.Append(Value); end; +function TCustomSynEdit.HasText(AFlags: TSynEditHasTextFlags): Boolean; +begin + if shtIncludeVirtual in AFlags then + Result := (FTheLinesView.Count > 1) or + ( (FTheLinesView.Count = 1) and ((FTheLinesView[0] <> '')) ) + else + Result := (FLines.Count > 1) or + ( (FLines.Count = 1) and ((FLines[0] <> '')) ); +end; + procedure TCustomSynEdit.DoBlockSelectionChanged(Sender : TObject); begin StatusChanged([scSelection]); diff --git a/components/synedit/synpopupmenu.pas b/components/synedit/synpopupmenu.pas index 5b5ba4db0e..4b0ce3fda5 100644 --- a/components/synedit/synpopupmenu.pas +++ b/components/synedit/synpopupmenu.pas @@ -121,7 +121,7 @@ begin meCopy: Items[i].Enabled := SelAvail; mePaste: Items[i].Enabled := CanPaste; meDelete: Items[i].Enabled := SelAvail and not ReadOnly; - meSelectAll: Items[i].Enabled := (Lines.Count > 1) or (Lines.Text <> ''); + meSelectAll: Items[i].Enabled := HasText([shtIncludeVirtual]); end; end; inherited;