Texteditor.SetColor

Discuss GUI programming with the RapaGUI plugin here
Post Reply
ilbarbax
Posts: 170
Joined: Thu Apr 01, 2010 6:41 pm

Texteditor.SetColor

Post by ilbarbax »

How to disable setcolor in a texteditor string?
I casually found that moai.DoMethod(id$, "SetColor", start, end, 0) does it but I'm not sure it is the right way. I'm not sure that all the escape characters are removed and I get a plain text.
Can someone give some light on this matter?

thanks
ilbarbax
Posts: 170
Joined: Thu Apr 01, 2010 6:41 pm

Re: Texteditor.SetColor

Post by ilbarbax »

Sorry I selected the wrong thread lt needed to be under rapagui
May the administrator move this post? Thanks
plouf
Posts: 722
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Texteditor.SetColor

Post by plouf »

you dont need at all coloring?
maybe seting Texteditor.Styled to false which disables it?
Christos
ilbarbax
Posts: 170
Joined: Thu Apr 01, 2010 6:41 pm

Re: Texteditor.SetColor

Post by ilbarbax »

I think that styled would apply to the whole document of the texteditor, while instead I need to reset the color in just few specific words of the document leaving the rest untouched (with colors)
User avatar
airsoftsoftwair
Posts: 5959
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Texteditor.SetColor

Post by airsoftsoftwair »

ilbarbax wrote: Sat May 02, 2026 8:08 pm I think that styled would apply to the whole document of the texteditor, while instead I need to reset the color in just few specific words of the document leaving the rest untouched (with colors)
Hmm, if you only need to reset the color in a few specific words why not use Texteditor.SetColor?
ilbarbax
Posts: 170
Joined: Thu Apr 01, 2010 6:41 pm

Re: Texteditor.SetColor

Post by ilbarbax »

Yes I did that as described in my first message but I'm not sure I found the correct way
User avatar
airsoftsoftwair
Posts: 5959
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Texteditor.SetColor

Post by airsoftsoftwair »

I think it's the only way. Maybe in the future a method for resetting style information for a part of the text can be added.
ilbarbax
Posts: 170
Joined: Thu Apr 01, 2010 6:41 pm

Re: Texteditor.SetColor

Post by ilbarbax »

I approached the problem in a more pragmatic way with the following function

Code: Select all

Function p_te_uncolor(id$,l_n,txt$)
		Local line_pos=moai.DoMethod(id$, "GetPosition", "0", ToString(l_n-1))
		Local line_len=moai.DoMethod(id$, "GetLineLength", ToString(l_n-1))
		Local t$ = moai.DoMethod(id$, "GetText", line_pos, line_pos+line_len)
		Local pz=FindStr(t$,txt$)
		If pz>=0 
			ntxt$=MidStr(t$,pz-10,StrLen(txt$)+20); my text including evenctual color escape chr
			If StartsWith(ntxt$,Chr(27).."P[")
				t$=UnmidStr(t$, pz+StrLen(txt$), 10)
				t$=UnmidStr(t$, pz-10, 10)
				moai.Set(id$,"CursorPos",line_pos)
				moai.DoMethod(id$, "Mark", line_pos, line_pos+line_len)
				DebugPrint(line_pos, line_pos+line_len, moai.DoMethod(id$, "GetSelection"))

				moai.DoMethod(id$, "Cut")
				moai.Set(id$,"CursorPos",line_pos)
				moai.DoMethod(id$, "Insert", t$, "Cursor")
			EndIf
		EndIf
EndFunction 
It works but I have a problem with the Cut command. It seems not work. In fact I get the line repeated with the color and without the color.
The mark command seems working because the debug print shows coherent figures.
Atm I'm stuck with this problem that is another problem respect the first one.
ilbarbax
Posts: 170
Joined: Thu Apr 01, 2010 6:41 pm

Re: Texteditor.SetColor

Post by ilbarbax »

found the problem!.
The texteditor was readonly but at this point why only cut is effected by the readonly and not set color?
Post Reply