Skip to content

Commit

Permalink
TextHint was not showing when Lines.Count = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
pyscripter committed Dec 24, 2024
1 parent 2982c0c commit ad61561
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Source/SynEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ TCustomSynEdit = class(TCustomControl)
procedure SetReadOnly(Value: boolean); virtual;
procedure SetWantReturns(Value: Boolean);
procedure SetSelText(const Value: string);
procedure SetSelTextPrimitiveEx(Value: string; AddToUndoList: Boolean = True);
procedure SetSelTextPrimitiveEx(const Value: string; AddToUndoList: Boolean = True);
procedure SetTextHint(const Value: string);
procedure SetWantTabs(Value: Boolean);
procedure StatusChanged(AChanges: TSynStatusChanges);
// If the translations requires Data, memory will be allocated for it via a
Expand Down Expand Up @@ -890,7 +891,7 @@ TCustomSynEdit = class(TCustomControl)
property Selections: TSynSelections read FSelections;
property StateFlags: TSynStateFlags read fStateFlags write fStateFlags;
property Text: string read SynGetText write SynSetText;
property TextHint: string read FTextHint write FTextHint;
property TextHint: string read FTextHint write SetTextHint;
property TopLine: Integer read fTopLine write SetTopLine;
property TextAreaWidth: Integer read FTextAreaWidth;
property WrapAreaWidth: Integer read GetWrapAreaWidth;
Expand Down Expand Up @@ -4023,7 +4024,7 @@ procedure TCustomSynEdit.SetSelText(const Value: string);
// as we would typically want the cursor to stay where it is.
// To fix this (in the absence of a better idea), I changed the code in
// DeleteSelection not to trim the string if eoScrollPastEol is not set.
procedure TCustomSynEdit.SetSelTextPrimitiveEx(Value: string;
procedure TCustomSynEdit.SetSelTextPrimitiveEx(const Value: string;
AddToUndoList: Boolean = True);
{
Works in two stages:
Expand Down Expand Up @@ -4130,6 +4131,16 @@ procedure TCustomSynEdit.SetSelTextPrimitiveEx(Value: string;
end;
end;

procedure TCustomSynEdit.SetTextHint(const Value: string);
begin
FTextHint := Value;
if (FTextHint <> '') and (FLines.Count = 0) then
// Add an empty line so that the hint will be shown
FLines.Add('');
if (FTextHint <> '') and (FLines.Count <= 1) and (FLines[0] = '') then
Invalidate;
end;

procedure TCustomSynEdit.SynSetText(const Value: string);
begin
FSelections.Clear();
Expand Down

0 comments on commit ad61561

Please sign in to comment.