Pseudo-Code/Algorithm for an InputBox?

BlitzMax Forums/BlitzMax Programming/Pseudo-Code/Algorithm for an InputBox?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm trying to improve my InputBox gadget in my GUI module, and I'm struggling to find a good way to make it scroll. When there is more text than will fit into the inputbox, I currently just draw as much text as will fit, ending at the end of the string and starting as early as possible in the string without the string being too long to fit.

That's fine, unless the cursor is too far foward in the inputbox, in which case you can't see what you're editing, lol. So I'm wondering what the pseudo-code or algorithm to decide which part of the string to draw should be.

Obviously you can't give code because you don't have a clue what I'm doing in my code. That's fine, I don't need code. Just the pseudo code so I know what I should be trying to do is fine.