MaxGUI Text area

BlitzMax Forums/BlitzMax Programming/MaxGUI Text area

Gavin Beard(Posted 2006) [#1]
Is it poss to read data in from a text area and still use ~n to start a new line, i've tried doing this and so far all i can get is ~n actually included in the text...

thanks


skidracer(Posted 2006) [#2]
You mean when calling TextAreaText using TEXTAREA_LINES?

Unfortunately you will need to crop the result as a TEXTAREA_LINES selection should always include the end of line character.
text$=TextAreaText(textarea,0,1,TEXTAREA_LINES)
text=text[..text.length-1]



Gavin Beard(Posted 2006) [#3]
Well i usually use
SetTextAreaText (systemtext,"Welcome~n~n")
but if i try :
SetTextAreaText (systemtext,TextAreaText(systemtext)+"~n" + result.getval(0,1) + "~n"+result.getval(0,2))

getval(0,1) being = "Welcome"
and getval(0,2) being = "Welcome~n~nand thankyou"

the output i get is :

Welcome


Welcome
Welcome~n~nand thankyou

instead of

Welcome


Welcome
Welcome

and thankyou


skidracer(Posted 2006) [#4]
can you explain how your getval(0,2) command works?

~n is translated into chr(10) characters by the blitzmax compiler (not the textarea gadget) so ~n only works with string literals (characters between quotes in .bmx source files)


Gavin Beard(Posted 2006) [#5]
getval(0,0) is reading a string from a mysql database.
it returns a String when called


skidracer(Posted 2006) [#6]
so if you want your stored strings to also use the ~n convention you will need to do something like:
a$=ReadStringFromDataBase()
a=a.Replace("~~n","~n")



Gavin Beard(Posted 2006) [#7]
Thankyou does the job nicely


Gavin Beard(Posted 2006) [#8]
trying to set the color of specific text using this code

Function drawMsg(_textarea:TGadget,txt:String,append:Int,subject:String="",r:Int = 0, g:Int = 0,b:Int = 0,bold:Int =0)
Local bg:Int = TextAreaLen(_textarea)

Local tmpstr:String =""
If append = 1 Then
tmpstr = TextAreaText(_textarea)
EndIf
LockTextArea(_textarea)
If subject <> "" Then
tmpstr = tmpstr + "~n" + subject +"~n"
FormatTextAreaText(_textarea,r,g,b,1,bg,bg+10)
EndIf
tmpstr = tmpstr + txt
tmpstr=tmpstr.Replace("~~n","~n")
UnlockTextArea(_textarea)
SetTextAreaText (_textarea,tmpstr)
End Function

but doesnt seem to work..... what have i missing?


Gavin Beard(Posted 2006) [#9]
Sorry, another question

when i use FormatTextareatext do i have to do the whole document ment again or should it retian formatting if i add new text?