Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2022-11

Displaying Tree Data from a Shell/Terminal command in a TListView [Linux Debian]

7 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aruna Hewapathirane

Hello Everyone,

I am running Linux Debian and putting together a utility that displays my system information.
I am trying to display data from a disk file in a TListView box and this part works.

The data I am trying to display is the output from the lsblk command, I redirect the shell output to a disk file as shown below.

lsblk > lsblk.txt ( in my case lsblk.ajh )

My problem is when the data from this file is displayed in the TListView there is a space/padding/margin between each displayed item which under normal circumstances would have been fine.

But in this case, the output of the lsblk command has a tree on the very left and this is not contiguous which breaks the tree lines so I would like the displayed line/item to be sharing a common border so thereby touching and making the tree lines smooth and contiguous.

As it is for my needs it is fine but if someday I decide to share the code then this has to be resolved. I realize a TListView may not be the correct or best component for this but I thought if there is a way to do this in a TListView why not?

The displayed item height I am unable to change the through the object inspector or through code.

Here is a screenshot <https://pasteboard.co/K7wTjTNR08bf.png> which should be self-explanatory once you view the screenshot. The bottom left is a shell/terminal and the output is rendered the way I expected. The form on the top right you will notice has the tree lines separated by a space/padding/margin. Please look at the 'tree' lines then you will understand what my problem is.

After asking for help on the Lazarus forum I twiddled with the font size and then it displayed the tree lines perfectly but I would like to know if there is a way to do this using a TListView without having to be stuck with a Monospace font and a specific font size? The forum question history is here.
<https://forum.lazarus.freepascal.org/index.php/topic,61352.msg461356.html#msg461356>

Thank you for reading all this and I look forward to any advice + guidance.

Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20221126/a973742a/attachment.htm>

Reply by email

Unknown author
to Aruna Hewapathirane: I am running Linux Debian and putting together a utility that displays my system…
Aruna Hewapathirane wrote
After asking for help on the Lazarus forum? I twiddled with the font size and then it displayed the tree lines perfectly but I would like to know if there is a way to do this using a TListView without having to be stuck with a Monospace font and a specific font size?

no, there is not really any way to do this without using a monospace font... terminals are monospace by design... their resolutions are represented by the cols*rows of their characters... eg: 80*24, 80*43, 132*24, 132*43...

each character is in a cell that has a fixed width and height... some common cell sizes are 9*12, 9*14, 9*16, 6*12... these are not pixels, though... pixels were not a thing when these were designed... they are basically dots in a raster cell... these cells are what are counted for terminal resolutions because each cell holds one character and terminals are character based, not pixel based...

not only do you have the vertical spacing but also the horizontal... note in your image that your column spacing is off so that needs to be fixed, too... note how your proportional spacing image cannot properly align the columns of information... FSTYPE, FSVER, LABEL, UUID, FSAVAIL, FSUSE%, and MOUNTPOINT...

if you are going to replicate the output of a terminal on a graphic canvas, monospace fonts are the best and easiest way... especially if you are going to easily deal with tabular output and column alignment... this because you don't have to do any extra work to get everything aligned properly...

then there's the aesthetics... personally speaking, seeing, for example, the UUID column in proportional font would drive me bananananananananas... columnar/tabular data is meant to be displayed in a fixed width format... proportional fonts simply cannot properly do that...

NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!*

Reply by email

Aruna Hewapathirane
to Alexey Torgashin: This is a matter of a) chosen font in TMemo, b) interline spacing, which must be…

On Sun, Nov 27, 2022 at 4:08 AM Alexey Torgashin via lazarus <

Show quoted text 8 lines
wrote: This is a matter of a) chosen font in TMemo, b) interline spacing, which must be controlled but I don't know how to change it in TMemo (I know how to change it in ATSynEdit). Alex --

Thank you Alex. I have to read a lot more about TListView and friends. I also had no idea there is
an interline spacing property many thanks for pointing that out.

Show quoted text 5 lines
_______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20221127/3b343cd6/attachment.htm>

Reply by email

Aruna Hewapathirane
to Alexey Torgashin: Another answer. You use TListview, yes? It cannot change interline spacing! So avoid it.…

On Sun, Nov 27, 2022 at 4:20 AM Alexey Torgashin via lazarus <

wrote: Another answer. You use TListview, yes?

Yes I am using a TListView.

It cannot change interline spacing! So avoid it.

Alright understood and will comply. But it has two properties that we may be able to
use to do what I am trying to do? lbOwnerDrawVariable and lbOwnerDrawFixed what
do these mean? Anyone have any sample code please?

Change to TTreeView. It has a) prop DefaultItemHeight, b) Options item tvoAutoItemHeight (turn it off).

I will look at TTreeView it is just that I like to keep things *simple* as I possibly can..
This is the reason I went with a TListView.

Thank you Alex.

Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20221127/5a7a6b9b/attachment.htm>

Reply by email

Aruna Hewapathirane
to Unknown author: no, there is not really any way to do this without using a monospace font... terminals…

On Sun, Nov 27, 2022 at 5:06 AM wkitty42--- via lazarus <

Show quoted text 17 lines
wrote: On 11/26/22 8:24 PM, Aruna Hewapathirane via lazarus wrote: > After asking for help on the Lazarus forum I twiddled with the font size and > then it displayed the tree lines perfectly but I would like to know if there is > a way to do this using a TListView without having to be stuck with a Monospace > font and a specific font size? no, there is not really any way to do this without using a monospace font... terminals are monospace by design... their resolutions are represented by the cols*rows of their characters... eg: 80*24, 80*43, 132*24, 132*43...

Oh I miss those days... DOS and Clipper 5.3 and VGA monitors that had a maximum
resolution of 640 x 480 px and tape drives.

Show quoted text 12 lines
each character is in a cell that has a fixed width and height... some common cell sizes are 9*12, 9*14, 9*16, 6*12... these are not pixels, though... pixels were not a thing when these were designed... they are basically dots in a raster cell... these cells are what are counted for terminal resolutions because each cell holds one character and terminals are character based, not pixel based...

You know I was just thinking with support like this you just cannot go wrong :-)

Show quoted text 10 lines
not only do you have the vertical spacing but also the horizontal... note in your image that your column spacing is off so that needs to be fixed, too... note how your proportional spacing image cannot properly align the columns of information... FSTYPE, FSVER, LABEL, UUID, FSAVAIL, FSUSE%, and MOUNTPOINT...

Yes, that was actually fixed when I started using the Monospace font.

Show quoted text 9 lines
if you are going to replicate the output of a terminal on a graphic canvas, monospace fonts are the best and easiest way... especially if you are going to easily deal with tabular output and column alignment... this because you don't have to do any extra work to get everything aligned properly...

Very true and thank you I had to find this out the hard way :-)

Show quoted text 7 lines
then there's the aesthetics... personally speaking, seeing, for example, the UUID column in proportional font would drive me bananananananananas... columnar/tabular data is meant to be displayed in a fixed width format... proportional fonts simply cannot properly do that...

Yes, very true and agreed.

Thank you wkitty42.

Aruna

Show quoted text 10 lines
-- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!* -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20221127/cbb66fdd/attachment.htm>

Reply by email