Text Editor

Blitz3D Forums/Blitz3D Beginners Area/Text Editor

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.

It's not impossible, it'd just take a lot more code than that. You have to remember a LOT of information, to do the most basic operations.

For instance, because B3D has no built-in text multi-line handling capability, imagine the problems you'd run into when you wanted to do a click,drag,select. You have to know all the text that is on those lines, at those positions on the screen. You can't read the text off the screen - you'd have to see:
a) how many pixels down the screen the inital mouse click is
b) stringheight of each line
c) calculate based on stringheight which line of text is being clicked on, vertically
d) figure out which line that is, over the course of the file - if the top of the file is off the top of the screen then it's going to be offset by the number of lines up to the one displayed at the top
e) once you know what line of text that is, find the horizontal pixel click location
f) do a stringwidth check for every combination of letters in the line until it is equal or more than the location you've clicked on the screen
g) remember this location of starting the text select, based not on pixel location, but on text row and column from the text data for the entire document stored in memory.
h) and NOW - you've got to start handling the dragging to select....... So far I've covered less than half of the operation.

That is one of the most basic operations you'd need in a text editor - but programming it manually without multi-line editboxes.. insanely time-consuming.

To do a single-line edit box even, is quite consuming, just for entering in names, etc. It has to handle key presses, backspaces (find the stringwidth of the previous character, remove that character from the string, AND move the cursor back that far), make sure they don't type too far or backspace too far, handle extended ascii characters, error checking to make sure people don't crash the program by it trying to "TYPE" out an F8 or whatever when they press it, support arrow-keys moving the cursor, support pressing TAB, etc etc etc.

Don't give up, just make sure you're programming within your limits. Start with a simple routine like you've got above. Figure out what you want to do with it next, and work that into it. Find any bugs in the new additions and fix them. Rinse, repeat, ad nauseum.

+BlackD