Closed zhiayang closed 5 months ago
there is no function existing to do this, but the o(n) algorithm you've presented is exactly how it would be done.
okay thanks! good that i'm not doing something completely dumb LOL
nope! you ask a good question, actually. for about two months in 2020 i worked on exactly this problem, for a different reason -- when we render a frame, we want to go through each viewable coordinate, starting at the top plane, and going down until we have the coordinate locked in (see "rendering" on my wiki). if we could start at the first plane that was actually on the coordinate, we could optimize that.
unfortunately, doing so required keeping a good bit of data around for the fast lookup. updating this data knocked out any benefits i could make it provide. furthermore, there just aren't many cases where you have the big-ass pile of planes necessary to get a win off this.
so just take the O(1) ncpile_top()
and the O(n) ncplane_below()
walk as you've done here.
btw, what are you working on with notcurses, if i might ask?
right, that makes sense!
i'm working on a top
program (because the world needs more of those, right?), which I think you might've seen a glimpse of in one of the other issues (:
this is what it currently looks like:
totally sweet!
one thing i'd recommend: if you're not using the graph feature of notcurses for your graphical load, you might want to. a lot of fonts don't support braille, or have really weird-looking braille. if you are, fucking fantastic!
i love it!
i actually implemented that before i poked around and realised you already had something for that LOL. i should probably use the library version, yea. i'm not even checking if the terminal supports braille atm xD
actually i remembered why:
hehe
Say I have some mouse position (x, y); is there a way to query notcurses to ask it for the topmost plane that contains those coordinates? Basically like a way to let me send events to the plane that the mouse is currently over.
I'm currently doing something like this, not sure if this is the most efficient way either:
thanks!