Skip to content

Commit

Permalink
bug relating to clearing links if set to custom colour
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbannon committed Jan 15, 2023
1 parent 4551bb9 commit c569095
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion source/editbox.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object EditBoxForm: TEditBoxForm
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
LCLVersion = '2.2.0.2'
LCLVersion = '2.3.0.0'
object PanelReadOnly: TPanel
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = KMemo1
Expand All @@ -30,6 +30,7 @@ object EditBoxForm: TEditBoxForm
ClientHeight = 60
ClientWidth = 695
Color = clYellow
ParentBackground = False
ParentColor = False
ParentFont = False
TabOrder = 1
Expand Down
13 changes: 7 additions & 6 deletions source/editbox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2628,6 +2628,7 @@ function TEditBoxForm.UnlinkBlock(StartBlock : integer) : integer;


procedure TEditBoxForm.ClearNearLink(const StartS, EndS : integer); inline;
// note that kmemo is locked before we get here.
var
Blar, StartBlock, EndBlock : longint;
LinkText : ANSIString;
Expand Down Expand Up @@ -2678,23 +2679,23 @@ procedure TEditBoxForm.ClearNearLink(const StartS, EndS : integer); inline;
while StartBlock < EndBlock do begin
if TKMemoTextBlock(KMemo1.Blocks.Items[StartBlock]).TextStyle.Font.Size = Sett.FontTitle then begin
inc(StartBlock);
continue;
continue; // We are NOT dealing with title here
end;
if KMemo1.Blocks.Items[StartBlock].ClassNameIs('TKMemoHyperlink') then begin
LinkText := lowercase(Kmemo1.Blocks.Items[StartBlock].Text); // ! trim()
// Only if its not a valid link, remove it. But don't check for Local links in SingleNoteMode
if not (ValidWebLink() or ValidLocalLink()) then begin
// Only if its not a valid link, remove it.
if not (ValidWebLink() or ValidLocalLink()) then begin // LocalLinks ignored in SingleNoteMode
StartBlock := UnLinkBlock(StartBlock);
if EndBlock > Kmemo1.Blocks.Count then EndBlock := Kmemo1.Blocks.Count;
end;
end else begin
// Must check here that its not been subject to the copying of a links colour and underline
// we know its not a link and we know its not title. So, if TextBlock, check color ...
// Note : as of Jan 2023, title and link can be different colours
with TKMemoTextBlock(KMemo1.Blocks.Items[StartBlock]) do
if KMemo1.Blocks.Items[StartBlock].ClassNameIs('TKMemoTextBlock') // Only an issue with TextBlocks
and (TextStyle.Font.Color = Sett.TitleColour) then begin // we set links to title colour
TextStyle.Font.Style
:= TextStyle.Font.Style - [fsUnderLine];
and (TextStyle.Font.Color = Sett.LinkColour ) then begin
TextStyle.Font.Style := TextStyle.Font.Style - [fsUnderLine];
TextStyle.Font.Color := Sett.TextColour;
end;
end;
Expand Down

0 comments on commit c569095

Please sign in to comment.