procedure TCompileForm.MemoWndProc(var Message: TMessage);
function GetCodeVariableDebugEntryFromLineCol(Line, Col: Integer):
PVariableDebugEntry;
var
I: Integer;
begin
Result := nil;
for I := 0 to FVariableDebugEntriesCount - 1 do
begin
if (FVariableDebugEntries[i].LineNumber = Line) and
(FVariableDebugEntries[i].Col = Col)
then
begin
Result := @FVariableDebugEntries[i];
Break;
end;
end;
end;
var
Line, Col, I, J: Integer;
P, P2: TPoint;
S, Output: string;
DebugEntry: PVariableDebugEntry;
begin
if (Message.Msg = CM_HINTSHOW) and (FDebugClientWnd <> 0) then
begin
with TCMHintShow(Message).HintInfo^ do
begin
P := Memo.PixelsToRowColumn(Point(CursorPos.X - Memo.CharWidth div 2, CursorPos.Y));
if P.Y <= Memo.Lines.Count then
begin
Line := P.Y;
Col := P.X;
S := Memo.Lines[Line - 1];
if (Col >= 1) and (Col <= Length(S)) and (S[Col] in ['a'..'z', 'A'..'Z',
'0'..'9', '_'])
then
begin
while (Col > 1) and (S[Col - 1] in ['a'..'z', 'A'..'Z', '0'..'9', '_'])
do
Dec(Col);
DebugEntry := GetCodeVariableDebugEntryFromLineCol(Line, Col);
if DebugEntry <> nil then
begin
J := Col;
while S[J] in ['a'..'z', 'A'..'Z', '0'..'9', '_'] do
Inc(J);
case EvaluateVariableEntry(DebugEntry, Output) of
1: HintStr := Output;
2: HintStr := Output;
else
HintStr := 'Unknown error';
end;
P2 := Memo.RowColumnToPixels(DisplayCoord(Col, P.Y));
CursorRect := Bounds(P2.X, P2.Y, (J - Col) * Memo.CharWidth,
Memo.LineHeight);
HideTimeout := High(Integer); Exit;
end;
end;
I := 1;
while I <= Length(S) do
begin
if S[i] = '{' then
begin
if (I < Length(S)) and (S[I + 1] = '{') then
Inc(I, 2)
else
begin
J := SkipPastConst(S, I);
if J = 0 then Break;
if (P.X >= I) and (P.X < J) then
begin
HintStr := Copy(S, I, J - I);
case EvaluateConstant(HintStr, Output) of
1: HintStr := HintStr + ' = "' + Output + '"';
2: HintStr := HintStr + ' = ' + Output;
else
HintStr := HintStr + ' = Unknown error';
end;
P2 := Memo.RowColumnToPixels(DisplayCoord(I, P.Y));
CursorRect := Bounds(P2.X, P2.Y, (J - I) * Memo.CharWidth,
Memo.LineHeight);
HideTimeout := High(Integer); Break;
end;
I := J;
end;
end
else
begin
if S[i] in ConstLeadBytes^ then
Inc(I);
Inc(I);
end;
end;
end;
end;
end
else
Memo.WndProc(Message);
end;