deno_tui Label-class
Hello.
I just started testing around with deno_tui and found the DrawObject-Class. How do i actually use this class? Afaik there is no proper documentation to deno_tui at all and especially not for this class specifically.
72 Replies
DrawObject
doesn't do that much by itself, it's used to create TextDrawObject
and BoxDrawObject
which then are used in components to render on the canvas. To build Tui you probably want to use components instead, if you want to create your own components and use them you can take a look at any of the components in src/components
, keep in mind that I'm planning on replacing DrawObjects in the future, I have PR open to do it, will try to finish it as soon as I will have some spare time.My problem is just, that i dont know, what i need to use for achieving my goal. Basically, i want to have blocks which consist of 16x16 pixel (16 rows, 32 columns) to display textures. The texture of each "block" has to be adjustable. Is there a component that does this?
there's a way to workaround this using styles, but that's not good DX at all, it seems like your usecase is actually in need of custom
DrawObject
I was planning on implementing ShapePainter
in my PR which is essentially what you need, but I didn't even start working on it :/
@realdna it totally escaped my head 🤦♂️
you could just use Label
component for thatessentially you could just convert the texture into a string and pass it to the label
my brain isn't braining
I tried that but with a textbox and it didnt work
And i gave up
I think the label is gonna work
Let me try in a few minutes
https://deno.land/x/tui@2.1.1/src/components/mod.ts
you should check that for simple component descriptions
textbox is a multiline text input :p
Lmao
Me being braindead
Sorry
I didnt want to waste your time
you didn't
tui definitely needs better docs
I just tried that method, but it doesnt seem to work properly for me
This is my code:
The outcome in terminal:
When i manually print the text (textures.stone) reading it from the file:
Okay, I think I know what's going wrong here, could you file an issue about it please?
Just created the issue: https://github.com/Im-Beast/deno_tui/issues/31
thanks, I'll look at it ASAP
im in bed rn so I will probably take a look at it tommorow/after tommorow
Np np
Thank you so much for even creating such an impressive tool in the first place
@realdna Feel free to update to 2.1.2
it should work just fine now, simply set
multiCodePointSupport
to true
in LabelOptions
I just updated 2.1.2 and i think you might have broken a few things
Code:
With 2.1.1 i have no errors at all
After updating to 2.1.2:
the code you just posted has
tui@2.1.1
and even then, it works fine for me
(even after I updated it to 2.1.2)Oopsie
I forgot to add the second code block
Sorry
The only thing i changed though was just the import version and this code block, where the only change is multiCodePointSupport is set true
it still works fine in my case?
I cant even compile a new version because the check fails
what is your deno version?
deno 1.36.4 (release, x86_64-pc-windows-msvc)
v8 11.6.189.12
typescript 5.1.6
wtf
why does it work for me and not for you then?
Idk tbh
are you sure the only thing you changed is this?
try running it with the
-r
flag, maybe your cache got fucked upSame issue with
-r
its definitely not deno_tui's issue
I don't know...
Thats literally all i did
you didn't update other imports...
Imma kms
Im done
Naw now
Im so sorry for wasting your time this bad
thats fine :p
It works now
great to see 😄
If youre alreadyhere , is it possible to get the current fps?
Like not what its supposed to be, but the actual current fps?
after I'll rework
DrawObject
to TextPainter
's I'll make sure that the styles will work fine even without multiCodePointSupport
Nice
to get the actual actual fps you'd need to use external program to see terminal's refreshrate
to see how fast tui's drawing frames you can calculate that by using
tui.canvas.on("render")
you can go to https://deno.land/x/tui/examples/demo.ts
to see how it can be done
basically
Oh ok
Thank you
np
Hey
New problem
When changing the text via Signal/Computed afterwards, this is the outcome
The before texture and the newly set textures are both completely fine by themselves
But when changing via signal, it doesnt work until the windows has been resized or something like that
holy shit, that's a strange bug
most likely I will take a swing at this in monday, I won't be home for a long time tommorow
as a work around you could probably create multiple labels and toggle
visible
property on componentsOh ok
Have you already worked on this?
oh, sorry I forgot
yes I did, I actually fixed it but didn't push it yet
gimme a sec
released
2.1.3
Ok np
Another thing, how can i have, for example a rectangle completely transparent?
what do you mean by transparent
do you want to just hide a component?
No
I mean actually transparent
Like this
But transparent
Like
No background color
that's impossible in terminal
Lemme try to explain this better
if you don't want
Tui
to have a background by default (so default terminal background color) just don't set tui.style
propertyjust remove
style
hereWhen i have two elements, where one has zIndex 0 and theme.base crayon.blue, while the second is a Text and has zIndex 1 but its supposed to have no background
To prevent something like this
do you mean "no background" here as "its supposed to be blue" or "its supposed to be default terminal background color"
Just a transparent background
In this case blue then
there's no concept of transparency in a terminal
you can assign a theme you used for the box to the text
so they'll share their background color
No other way then?
Sadge
not really
Ok
Thank you very much
np