mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-06 01:26:09 +02:00
SynEdit: fixed SynPopUpMenu, enable/disable select all / Added SynEdit.HasText to check if non-empty
This commit is contained in:
parent
4adebcb03e
commit
f21293c5d0
@ -207,6 +207,11 @@ type
|
|||||||
);
|
);
|
||||||
TSynEditTextFlags = set of TSynEditTextFlag;
|
TSynEditTextFlags = set of TSynEditTextFlag;
|
||||||
|
|
||||||
|
TSynEditHasTextFlag = (
|
||||||
|
shtIncludeVirtual // trailing spaces
|
||||||
|
);
|
||||||
|
TSynEditHasTextFlags = set of TSynEditHasTextFlag;
|
||||||
|
|
||||||
TSynStateFlag = (sfCaretChanged, sfHideCursor,
|
TSynStateFlag = (sfCaretChanged, sfHideCursor,
|
||||||
sfEnsureCursorPos, sfEnsureCursorPosAtResize, sfEnsureCursorPosForEditRight, sfEnsureCursorPosForEditLeft,
|
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)
|
sfExplicitTopLine, sfExplicitLeftChar, // when doing EnsureCursorPos keep top/Left, if they where set explicitly after the caret (only applies before handle creation)
|
||||||
@ -946,6 +951,7 @@ type
|
|||||||
// Text Raw (not undo-able)
|
// Text Raw (not undo-able)
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
procedure Append(const Value: String);
|
procedure Append(const Value: String);
|
||||||
|
function HasText(AFlags: TSynEditHasTextFlags = []): Boolean;
|
||||||
property LineText: string read GetLineText write SetLineText; // textline at CaretY
|
property LineText: string read GetLineText write SetLineText; // textline at CaretY
|
||||||
property Text: string read SynGetText write SynSetText; // No uncommited (trailing/trimmable) spaces
|
property Text: string read SynGetText write SynSetText; // No uncommited (trailing/trimmable) spaces
|
||||||
|
|
||||||
@ -4730,6 +4736,16 @@ begin
|
|||||||
FTheLinesView.Append(Value);
|
FTheLinesView.Append(Value);
|
||||||
end;
|
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);
|
procedure TCustomSynEdit.DoBlockSelectionChanged(Sender : TObject);
|
||||||
begin
|
begin
|
||||||
StatusChanged([scSelection]);
|
StatusChanged([scSelection]);
|
||||||
|
@ -121,7 +121,7 @@ begin
|
|||||||
meCopy: Items[i].Enabled := SelAvail;
|
meCopy: Items[i].Enabled := SelAvail;
|
||||||
mePaste: Items[i].Enabled := CanPaste;
|
mePaste: Items[i].Enabled := CanPaste;
|
||||||
meDelete: Items[i].Enabled := SelAvail and not ReadOnly;
|
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;
|
||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
|
Loading…
Reference in New Issue
Block a user