Escape Sequences, Some Don't Work For Me

BlitzMax Forums/BlitzMax Beginners Area/Escape Sequences, Some Don't Work For Me

Within text, the ~n and ~r don't seem to make a newline or return. The ~q works, so I know the placement of the sequence is correct. They work with Print command in the console, maybe they aren't supposed to work with Graphics and DrawText? Any suggestions?

Graphics 800,600

While Not KeyHit(key_escape)
DrawText("this is a test of ~n newline, ~r return, and ~q quotation mark escape sequences",100,10)
Flip
Wend


Try ~r~n

maybe they aren't supposed to work with Graphics and DrawText?
Bingo.

I hate to bump something so old, but I was trying this very thing. Is there a way around it that I could try to format my DrawText with newlines?

You could split the line yourself into 2 different DrawTexts.

Heres som old code i had lying around (modified slightly to support newlines) if anyone wants.

This draws text inside a frame and wraps on words/cr.

Hope it helps =)

Graphics 640,480, 0

Repeat

	SetColor 128,128,128
	DrawRect 32,32, 128,128
	
	SetColor 256,256,256	
	DrawTextRect( 32+1,32+1, 128-2,128-2, "A quick brown fox jumped over the fence...~n1~n2~n3")
	
	Flip
	Cls
	
Until KeyHit( KEY_ESCAPE)
End


Function GetNextEx:String( value:String Var, seps:String[])
	Local index:Int, s:String
	If (value.Length <= 0) Or (seps.Length <= 0) Then Return Null
	For s = EachIn seps
		index = value.Find( s)
		If index = 0 Then
			value = value[s.Length..]
			Return Null
		ElseIf index >= 1 Then			
			Local res:String = value[..index]
			value = value[index + s.Length..]
			Return res
		EndIf
	Next
	If value.Length > 0 Then
		s = value
		value = Null
		Return s
	EndIf
	Return Null
EndFunction

Function DrawTextRect( x:Int,y:Int,w:Int,h:Int, text:String)
	' seperate text into words with spaces,tabs & crlf
	Local words:String[], ss:String, idx:Int
	Repeat		
		ss = GetNextEx( text, [" ","~t"])
		idx = ss.Find( "~n")
		If idx <> -1 Then
			Repeat
				Local tmp:String = GetNextEx( ss, ["~r~n","~n"])
				If tmp.Length > 0 Then
					words = words[..words.Length + 2]
					words[words.length - 2] = tmp
				EndIf
			Until ss.Length = 0		
		Else
			words = words[..words.Length + 1]
			words[words.Length - 1] = ss		
		EndIf
	Until text.Length = 0	
	' draw it within the suplied frame
	Local xx:Int,yy:Int, ww:Int,hh:Int
	For Local s:String = EachIn words
		If s.length <= 0 Then
			xx = 0
			yy :+ TextHeight("jX")
		Else
			ww = TextWidth(s)
			hh = TextHeight(s)
			If xx + ww > w Then
				xx = 0
				yy :+ hh
			EndIf
			DrawText s, x+xx,y+yy
			xx :+ ww + TextWidth( " ")
		EndIf
	Next
EndFunction