How to program a text editor?

BlitzPlus Forums/BlitzPlus Beginners Area/How to program a text editor?

vibe37(Posted 2005) [#1]
Does anyone know of a tutorial / sample code on how to do a simple text editor in B+ (with basic features like wordwrap, centering / aligning text, changing the font, etc.)?

Regards,
Kungfista


CS_TBL(Posted 2005) [#2]
You need at least api_KeyASyncKeyState for decent keyboard input. The rest I dunno. Any advantages in your own text-editor over Notepad or Wordpad?


vibe37(Posted 2005) [#3]
No advantages, just got B+ and wanted to do it as an exercise... My impression is that B+ is quite poorly documented (at least when compared to B3d) - there are few tutorials around and the included help files do not help either. Do you know of a great tutorial resource I have overlooked?


CS_TBL(Posted 2005) [#4]
Mwah, I think the built-in help is sufficient, esp. when you have a background in B3d/2d already. Only tricky part is userlibs I think, and types are explained a bit too abstract, rather than low-level (imho).

To get the hang out of B+, try something obvious 'n simple, like a map-editor.

B+'s main issue is that there are only a few gadgets available (things like an image-button are missing!). It is however possible to make your own gadgets (see my tut in the tut-section), but many would argue that such gadgets should be present in B+ natively.


Gauge(Posted 2005) [#5]
Heres some basic code to get you started. What kind of features do you want to add btw? This works in blitz3d so no special 2d functions, just draws the text on the screen.
Print "TEXT EDITOR STARTING"
Global x
Global Y
Global key
x=10
y=10

While Not KeyHit(1)
key=0
key=GetKey()
If key<>0 Then
Text x,y,Chr$(key)
x=x+10
checkline
EndIf

Wend

End

Function checkline()
	If x>390 Then
	y=y+10
	x=0
	EndIf
End Function