[Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Bo Berglund via lazarus
I am using a TListbox component on a form for displaying debug data arriving
over a serial line at 115200 baud.
The data are a set of MQTT telegram texts which arrive in packets of about 40
lines each time (once per 10 seconds).
I add them to the listbox as follows:

procedure THanSimulatorMain.OnRxData(Sender: TObject; const Data: TBytes);
var
  len, oldlen: integer;
  DataTxt: AnsiString;
begin
  len := Length(Data); //Incoming packet
  oldlen := Length(DataBuffer);
  SetLength(DataBuffer, oldlen + len);
  Move(Data[0], DataBuffer[oldlen], len);
  SetLength(DataTxt, Length(DataBuffer));
  Move(DataBuffer[0], DataTxt[1], Length(DataBuffer));
  lbxRxData.Items.Text := DataTxt;  //Add the text to the list
  lbxRxData.ItemIndex := lbxRxData.Items.Count -1; //To make it visible
end;

DataBuffer is a global TBytes container where the incoming data are stuffed as
they arrive (it grows during the session).
You see that the buffer contains the complete log history from the start...

I have noticed that after a while the display becomes very sluggish when data
arrives and I think that is due to the way the component operates.

Now I wonder if there is some way to do as I did when I worked in Delphi with
TListView objects, where I could use the BeginUpdate and EndUpdate calls to make
all screen updates wait until it was all put in place.
This was MUCH faster!

But I can not find a BeginUpdate on the TListBox object, only BeginUpdateBounds,
which does not tell me much

Any suggestions?


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Qt6 widgetset

2022-11-11 Thread zeljko via lazarus

Hi all,
I've just committed Qt6 widgetset into main :)
Tested only under linux atm (win32/64 and mac users can try to build 
libQt6Pas, if something went wrong pls inform me or open an issue about 
it), lazarus ide qt6 works just fine.


libQt6Pas is based on LTS Qt6-6.2.3, so to build libQt6Pas.so.6.2.3 you 
must have installed Qt6 with minimum version 6.2.

Read lcl/interfaces/qt6/cbindings/README howto build libQt6Pas.
Printing (Printers4Lazarus) is not yet implemented, but other stuff is 
complete.
libQt6Pas does not depend on qtnetwork anymore, it's removed since fpc 
have complete network solution.


Bug reports are welcome :)

zeljko
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Luca Olivetti via lazarus

El 11/11/22 a les 16:29, Bo Berglund via lazarus ha escrit:

I have noticed that after a while the display becomes very sluggish when data
arrives and I think that is due to the way the component operates.


You could try using a TSynEdit instead of a TListBox: some years ago I 
switched from TMemo to TSynEdit to do some logging in a similar (though 
I add lines instead of assigning the complete text, also, I delete the 
oldest line when there are 5000 lines) because I found that, under 
windows, TSynEdit is an order of magnitude (or more) faster than TMemo.

No difference under linux though, and maybe it's no longer true nowadays.

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Bo Berglund via lazarus
On Fri, 11 Nov 2022 16:29:31 +0100, Bo Berglund via lazarus
 wrote:

>Now I wonder if there is some way to do as I did when I worked in Delphi with
>TListView objects, where I could use the BeginUpdate and EndUpdate calls to 
>make
>all screen updates wait until it was all put in place.
>This was MUCH faster!
>
>But I can not find a BeginUpdate on the TListBox object, only 
>BeginUpdateBounds,
>which does not tell me much

In fact I found TListbox.Items.Beginupdate/EndUpdate, but it did not do much to
improve the handling, too slow anyway


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Bo Berglund via lazarus
On Fri, 11 Nov 2022 17:10:08 +0100, Luca Olivetti via lazarus
 wrote:

>El 11/11/22 a les 16:29, Bo Berglund via lazarus ha escrit:
>> I have noticed that after a while the display becomes very sluggish when data
>> arrives and I think that is due to the way the component operates.
>
>You could try using a TSynEdit instead of a TListBox: some years ago I 
>switched from TMemo to TSynEdit to do some logging in a similar (though 
>I add lines instead of assigning the complete text, also, I delete the 
>oldest line when there are 5000 lines) because I found that, under 
>windows, TSynEdit is an order of magnitude (or more) faster than TMemo.
>No difference under linux though, and maybe it's no longer true nowadays.
>

I have never used TSynEdit before so I tried dropping one onto my form and it
looked a bit "strange" with a wide margin to the left...
How does it work (especially the margin that steals space)?

Note that I do not need an editor as such, just somewhere to show the log lines,
and possibly also a way to copy certain lines or text sections to paste
somewhere else.

BTW this application is on Windows and I am using Lazarus 2.0.12 and FPC 3.2.0


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Werner Pamler via lazarus

Am 11.11.2022 um 16:29 schrieb Bo Berglund via lazarus:

You see that the buffer contains the complete log history from the start...


When the first block of data has arrived I would store the length of the 
buffer at this time. Then next time when new data come in, I would 
extract the "new data", i.e. the bytes between the stored length and the 
new length of the buffer and add them to the listbox. And store the 
current length for the next round. Etc... This avoids moving all the 
data to the listbox, which it already has, again and again. Because 
extraction of the individual lines in lbxRxdata.Items.Text := DataTxt is 
a length process.



--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Luca Olivetti via lazarus

El 11/11/22 a les 17:56, Bo Berglund via lazarus ha escrit:


I have never used TSynEdit before so I tried dropping one onto my form and it
looked a bit "strange" with a wide margin to the left... > How does it work 
(especially the margin that steals space)?


Play with the properties in the project inspector, you can remove the 
gutter (gutter.visible -> false), the margin (by setting RightEdge to a 
very big value, say 800) and customize much of its appearance..




Note that I do not need an editor as such, just somewhere to show the log lines,
and possibly also a way to copy certain lines or text sections to paste
somewhere else.


Me too. Just set the readonly property to true and that's it.
Then just treat it like a TMemo (using the Lines property). It has some 
more goodies that aren't available in a Tmemo.
As I said, I was using a TMemo for logging and it was too slow under 
windows, I switched to a TSynEdit and had great improvement in performance.




BTW this application is on Windows and I am using Lazarus 2.0.12 and FPC 3.2.0


So you'll probably see an improvement by using a TSynEdit (or maybe not, 
the only way to know is to try it).


Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to fix slow screen refresh of TListbox?

2022-11-11 Thread Bo Berglund via lazarus
On Fri, 11 Nov 2022 18:49:15 +0100, Luca Olivetti via lazarus
 wrote:

>Play with the properties in the project inspector, you can remove the 
>gutter (gutter.visible -> false), the margin (by setting RightEdge to a 
>very big value, say 800) and customize much of its appearance..
>
I replaced the TListBox with a TSynEdit as suggested and I have "played with"
the properties a bit.
Seems to work quite well so far.

>
>Me too. Just set the readonly property to true and that's it.
>Then just treat it like a TMemo (using the Lines property). It has some 
>more goodies that aren't available in a Tmemo.
>As I said, I was using a TMemo for logging and it was too slow under 
>windows, I switched to a TSynEdit and had great improvement in performance.
>
I have a couple of questions:

1) Is there a way to make sure that when adding text the view shifts such that
the last line is visible?
I.e. Automatically scroll the text up when new text is added.

2) The reason I am not adding incoming data to the listbox as tyhey arrive is
that I don't know if the serial component provides the data at line endings or
in the middle of a line, so I add the data to the old data in the TBytes array
and then dump the content of the TBytes into the text property of the box.

What happens if one adds the text as a block to this synedit where the block
does not end in a line feed?
Will the end of it be some way into the last line such that if I then add the
next transmission it will start at tahat position and not on a new line?

If that is possible then the handling will become a lot easier since I just have
to add the few new lines at the end directly in synedit...

I'll test that too.
But how to jump to the end of the text on screen?

-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus