Writing a text editor
Posted: Fri Mar 01, 2013 2:40 pm
I'm writing a text editor and I'd like some advice and or code on programming one.
I have it working ok, but notice corruption of the text - repeated text and gibberish after saving sometimes.
It would be nice to have certain words within the editor change color, is that easy to accomplish? And some dotted lines to indicate words in the same column.
Thanks in advance
Saving code:
Loading code:
I have it working ok, but notice corruption of the text - repeated text and gibberish after saving sometimes.
It would be nice to have certain words within the editor change color, is that easy to accomplish? And some dotted lines to indicate words in the same column.
Thanks in advance

Saving code:
Code: Select all
Case #MenuItem_SaveAs
StandardFile$ = "TestProg.txt"
Pattern$ = "Text (*.txt)|*.txt|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = OpenFileRequester("Choose file to save", StandardFile$, Pattern$, Pattern)
If File$
If OpenFile(0,"TestProg.txt")
WriteString(0,GetGadgetText(Editor_0))
CloseFile(0)
EndIf
EndIf
Code: Select all
Case #MenuItem_Load
StandardFile$ = "TestProg.txt"
Pattern$ = "Text (*.txt)|*.txt|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = OpenFileRequester("Choose file to load", StandardFile$, Pattern$, Pattern)
If File$
If ReadFile(0,"C:\Programming\TestProg.txt")
*mem = AllocateMemory(Lof(0))
ReadData(0, *mem, Lof(0))
SetGadgetText(Editor_0, PeekS(*mem))
EndIf
EndIf