calltips, fix overflowing text depending on the editor zoom level

This commit is contained in:
Basile Burg 2020-03-11 15:35:35 +01:00
parent 0730394875
commit 2eac241ac4
1 changed files with 15 additions and 14 deletions

View File

@ -540,17 +540,19 @@ var
i: integer = 0; i: integer = 0;
j: integer = 0; j: integer = 0;
x: integer; x: integer;
y: integer; y: integer = 1;
r: TStringRange = (ptr:nil; pos:0; len: 0); r: TStringRange = (ptr:nil; pos:0; len: 0);
t: TStringRange; t: TStringRange;
u: TStringRange; u: TStringRange = (ptr:nil; pos:0; len: 0);
m: integer = 0;
label label
FIXED_AUTO; FIX_AUTO;
procedure writePart(const part: string; var x: integer); procedure writePart(const part: string; var x: integer; var lineHeigth: integer);
begin begin
canvas.TextOut(x, y, part); canvas.TextOut(x, y, part);
x += canvas.TextWidth(part); x += canvas.TextWidth(part);
lineHeigth := max(canvas.TextHeight(part), lineHeigth);
end; end;
begin begin
@ -558,32 +560,32 @@ begin
if s.isEmpty then if s.isEmpty then
exit; exit;
u.init(s); u.init(s);
y := ScaleY(3,96);
while true do while true do
begin begin
i := 0; i := 0;
y += m;
b := u.nextLine(); b := u.nextLine();
if b.isEmpty then if b.isEmpty then
break; break;
FIXED_AUTO: FIX_AUTO:
r.init(b); r.init(b);
canvas.Brush.Color:= color; canvas.Brush.Color:= color;
x := ScaleX(3,96); x := ScaleX(3,96);
// result // type of result
a := r.takeUntil(' ').takeMore(1).yield(); a := r.takeUntil(' ').takeMore(1).yield();
r.popFront; r.popFront;
if a <> '%FIX% ' then // the computed HintRect does not permit additional text if a <> '%FIX% ' then // the computed HintRect does not permit additional text
writePart(a, x); writePart(a, x, m);
// name // func ident
a := r.takeUntil('(').yield(); a := r.takeUntil('(').yield();
writePart(a, x); writePart(a, x, m);
// template params // template params
t := r.save.popPair(')')^; t := r.save.popPair(')')^;
if not t.empty() and (t.popFront^.front = '(') then if not t.empty() and (t.popFront^.front = '(') then
begin begin
a := r.takePair(')').takeMore(1).yield(); a := r.takePair(')').takeMore(1).yield();
r.popFront(); r.popFront();
writePart(a, x); writePart(a, x, m);
end end
// `auto ident()` is formatted as `ident()` because `auto` in D is not a Type, // `auto ident()` is formatted as `ident()` because `auto` in D is not a Type,
// so fix the formatting and go back. // so fix the formatting and go back.
@ -593,7 +595,7 @@ begin
exit; exit;
b := '%FIX% ' + b; b := '%FIX% ' + b;
j += 1; j += 1;
goto FIXED_AUTO; goto FIX_AUTO;
end; end;
j := 0; j := 0;
// func args // func args
@ -612,10 +614,9 @@ begin
canvas.Brush.Color:= clHighlight canvas.Brush.Color:= clHighlight
else else
canvas.Brush.Color:= color; canvas.Brush.Color:= color;
writePart(a, x); writePart(a, x, m);
i += 1; i += 1;
end; end;
y += Font.Size + ScaleY(9,96);
end; end;
end; end;
{$ENDREGION} {$ENDREGION}