Author Topic: history scroller WIP  (Read 1810 times)

mahuti

  • Administrator
  • Sr. Member
  • *****
  • Posts: 252
    • View Profile
    • Github Repositories
history scroller WIP
« on: January 25, 2021, 12:02:48 AM »
I started writing a scroller for the history.dat info in one of my layouts. It works pretty well, but I know for a fact that I need to get a little more sophisticated with it before it manages every scenario correctly.

So far it's useful, but not 100%, so I figured I'd share the basic premise in the hope that it might spark an idea for someone else.

What this does is use the font size to guess the height of the text that comes back from the history.dat plugin and then scroll that amount up off the screen before resetting it at the bottom

The calculation so far is this:

total character count of the history data / (assumed/guessed) average # of characters per line of text (this gets a guess on the total number of lines of text) *  font height = overall guestimate of the text box height

This doesn't account for text boxes that are wide enough to allow for more characters per line than a standard book / article might be (this is usally 56-70 characters, my guess is set at 75). It would make more sense for me to set it based on how wide a character is in pixels and how many chars could fit in the current text box than assume number of characters per line.

I suppose there's some way to calculate the size of 1 average character like X and make a guestimate based on that. There's probably some greedy algorithm out there for this purpose too, but I haven't had time to look for it.

Anyway, let me know if you have any ideas or experiment. The attached file may have bugs in it... I culled it from a layout I was working on and tried to distill it down to a minimum so you could see what i was doing, I haven't had time to JUST test this script on its own.
« Last Edit: January 25, 2021, 12:04:38 AM by mahuti »