TextEdit Documentation Vs. 1 (10/26/2002)
Written By: Andy Stone
TextEdit By: Andy Stone (astone42@attbi.com)
Visit: http://loreandlutes.sourceforge.net for more information.
See copying.txt or copying for licensing information.
//Create a sample screen 640x480x16
ASFC_Screen screen(640, 480, 16); //Setup the console, use the normal font
ASFC_Font oConFont("./fonts/normal_console_font.png", 8, 14, COLOR_BLUE); ASFC_FontPalette myoFonts; myoFonts.Push(oConFont); ASFC_Console oCon; oCon.SetFontPalette(&myoFonts); oCon.SetSurface(&screen); oCon.SetConsolePosition(0, 0); oCon.SetViewport(0, 0); oCon.SetViewportSize(52, 29); oCon.SetConsoleSize (52, 29);
If you want to see what fonts you can use with TextEdit open the fonts sub directory and look. See the ASFC section for more information about how fonts and consoles work.
Once that's done create a TE_Text object to store your textual data and a TE_TextEditor object to view\edit it. Link the editor to the console you want to display the text by using the SetConsole() member.
TE_Text oText; TE_TextEditor oEdit; oEdit.SetConsole(&oCon);
If you don't want to start editting with blank document you can load a textfile by passing the path location of the text file you want to view\edit.
oText.Load("test.txt");
Next simply edit or view the text, text edit handles the rest.
oEdit.EditText(&oText); oEdit.ViewText(&oText);
If you're editing text you can also set "boundries". The boundaries are line #s that tell TextEdit what it can edit. Anything out of the boundaries won't be viewed by the editor and can't be edited. You pass two ints for the start and end rows of the boundaries; the end row will be updated if the user adds new lines to the file.
//Only edit lines 0 - 5 int iStart = 0; int iEnd = 5; Edit.EditText(&oText, &iStart, &iEnd); /*If the user enters a new line iEnd will now be 6, or if he deletes a line it'll be 4*/
Errors, Bugs, Questions, Comments?