minor optimization to the message widget

This commit is contained in:
Basile Burg 2020-06-07 21:00:04 +02:00
parent 2ab76e07d3
commit b65e38f23f
6 changed files with 36 additions and 10 deletions

View File

@ -943,8 +943,10 @@ begin
(sender as TDexedProcess).getFullLines(lst)
else
processOutputToStrings(TProcess(sender), lst);
fMsgs.beginMessageCall();
for str in lst do
fMsgs.message(str, fAsProjectItf, amcProj, amkBub);
fMsgs.endMessageCall();
finally
lst.Free;
end;
@ -974,8 +976,10 @@ begin
lst := TStringList.Create;
try
fCompilProc.getFullLines(lst);
fMsgs.beginMessageCall();
for str in lst do
fMsgs.message(str, fAsProjectItf, amcProj, amkAuto);
fMsgs.endMessageCall();
finally
lst.Free;
end;

View File

@ -1066,8 +1066,10 @@ begin
lst := TStringList.Create;
try
fDubProc.getFullLines(lst);
fMsgs.beginMessageCall();
for str in lst do
fMsgs.message(str, fAsProjectItf, amcProj, amkAuto);
fMsgs.endMessageCall();
finally
lst.Free;
end;

View File

@ -271,6 +271,10 @@ type
* Single service provided by the messages widget.
*)
IMessagesDisplay = interface(ISingleService)
// begins several calls to message()
procedure beginMessageCall();
// ends several calls to message()
procedure endMessageCall();
// displays a message.
procedure message(const value: string; aData: Pointer; aCtxt: TAppMessageCtxt; aKind: TAppMessageKind);
// clears the messages related to the context aCtxt.

View File

@ -2931,12 +2931,14 @@ begin
lst := TStringList.Create;
try
proc.getFullLines(lst);
fMsgs.beginMessageCall();
if proc = fRunProc then
for str in lst do
fMsgs.message(str, fDoc, amcEdit, amkBub)
else // dmd used to compile runnable
for str in lst do
fMsgs.message(str, fDoc, amcEdit, amkAuto);
fMsgs.endMessageCall();
finally
lst.Free;
end;

View File

@ -164,6 +164,8 @@ type
//
function singleServiceName: string;
procedure message(const value: string; aData: Pointer; aCtxt: TAppMessageCtxt; aKind: TAppMessageKind);
procedure beginMessageCall();
procedure endMessageCall();
procedure clearbyContext(aCtxt: TAppMessageCtxt);
procedure clearbyData(data: Pointer);
procedure scrollToBack;
@ -942,6 +944,16 @@ begin
exit('IMessagesDisplay');
end;
procedure TMessagesWidget.beginMessageCall();
begin
list.BeginUpdate;
end;
procedure TMessagesWidget.endMessageCall();
begin
list.EndUpdate;
end;
procedure TMessagesWidget.message(const value: string; aData: Pointer;
aCtxt: TAppMessageCtxt; aKind: TAppMessageKind);
var
@ -952,7 +964,7 @@ begin
showWidget;
if not fAlwaysFilter then
TreeFilterEdit1.Filter:='';
if (value.length > fOptions.maxLineLength) and (fOptions.maxLineLength > 0) then
if (fOptions.maxLineLength > 0) and (value.length > fOptions.maxLineLength) then
msg := value[1..fOptions.maxLineLength]
else
msg := value;
@ -963,23 +975,23 @@ begin
if aCtxt = amcAutoCompile then
begin
case fProjCompile of
false: aCtxt := amcAutoEdit;
true: aCtxt := amcAutoProj;
false: aCtxt := amcAutoEdit;
true: aCtxt := amcAutoProj;
end;
end;
if aCtxt = amcAutoEdit then
begin
aData := fDoc;
aCtxt := amcEdit;
aData := fDoc;
aCtxt := amcEdit;
end
else if aCtxt = amcAutoProj then
begin
aData := fProj;
aCtxt := amcProj;
aData := fProj;
aCtxt := amcProj;
end;
dt := new(PMessageData);
dt^.data := aData;
dt^.ctxt := aCtxt;
dt := new(PMessageData);
dt^.data := aData;
dt^.ctxt := aCtxt;
if fAutoSelect and (fCtxt <> aCtxt) then
fBtns[aCtxt].Click;
if fastDisplay then

View File

@ -279,8 +279,10 @@ begin
lst := TStringList.Create;
try
fProcess.getFullLines(lst);
fMsgs.beginMessageCall();
for str in lst do
fMsgs.message(str, nil, amcMisc, amkAuto);
fMsgs.endMessageCall();
finally
lst.Free;
end;