how do I remove Text formatting in TextEditor

Discuss GUI programming with the RapaGUI plugin here
Post Reply
User avatar
Redlion
Posts: 94
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

how do I remove Text formatting in TextEditor

Post by Redlion »

Hi All,

I have been using the text editor to show text formatted in colour. When I save the text, the colour formatting is saved with it and when I load the text back, the formatting is returned as well. However for my purposes colour is just for ease of reading and editing but causes problems with processing the text. Is there a way to remove the formatting code from the text so I can save it without any formatting at all.

I have tried to find the colour format code ( \33P[ff4529] ) using find and replace but it does not find anything, when I look at the text in a hex dump the code is represented as .P[ff4529] can't find that in the text either.

In the TextEditor example in RapaGUI you can change Bold, Italic and Underline but there is nothing to return the code back to normal.

Can anyone set me in the right direction or show me some code that will remove all formatting from the text.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: how do I remove Text formatting in TextEditor

Post by plouf »

Isnt /33n (text style back to normal) help youon this ?
Christos
User avatar
Redlion
Posts: 94
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: how do I remove Text formatting in TextEditor

Post by Redlion »

Hi Christos,

Unfortunately \n does not work as it adds characters into the text and this causes problems.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
plouf
Posts: 467
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: how do I remove Text formatting in TextEditor

Post by plouf »

when searching with strings use \27

here is an example that removes bold start and end in text

Code: Select all

fl$ = FileToString("c:\\test.txt")
DebugPrint(fl$)
fl$ = ReplaceStr(fl$,"\27b","") ; no BOLD entry   (\33b)
DebugPrint(fl$)
fl$ = ReplaceStr(fl$,"\27n","") ; no back to normal (\33n)
edit

also about your question of TextEditor in examples, the example uses unmidstr and removes these escape characters from text

as an extra note/idea if you dont need editing, you may consider htmlview, where html/xml files are easier to manipulate
Christos
User avatar
Redlion
Posts: 94
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

Re: how do I remove Text formatting in TextEditor

Post by Redlion »

Hi Christos,

Sorted now, thanks for the info it was the UnmidStr() that was what I needed, ReplaceStr() did not seem to work - not sure why.

Thanks again for your help.

Cheers
Leo
----------------------------------------------------------------------------------------
Redlion
Sam460 Lite
A4000 A3000 A2000 A1200 A1000 A600 A500 CD32
Post Reply