Page 1 of 1

how do I remove Text formatting in TextEditor

Posted: Sat Apr 09, 2022 5:44 am
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

Re: how do I remove Text formatting in TextEditor

Posted: Sat Apr 09, 2022 6:59 am
by plouf
Isnt /33n (text style back to normal) help youon this ?

Re: how do I remove Text formatting in TextEditor

Posted: Sat Apr 09, 2022 9:58 am
by Redlion
Hi Christos,

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

Cheers
Leo

Re: how do I remove Text formatting in TextEditor

Posted: Sat Apr 09, 2022 4:30 pm
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

Re: how do I remove Text formatting in TextEditor

Posted: Mon Apr 11, 2022 1:48 am
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