Still need to try.
Two questions arised meanwhile:
- Is HTML panel the best solution for my intention? Text box would work faster for sure, but I couldn't use coloured text... Is there any other option?
- Please comment the following pseudo code, considering optimization (I believe that stills too slow and probably can run faster with some optimization), that is what happens when my app receive text (example):
TEXT RECEIVED:
- "The sun shines brightly in the [1;33meastern[0m sky."
MMC (my app)
- Receives the text in buffer() ("length=stream.ReadBytes(buffer(),4096)")
- Loops all bytes in search for Telnet protocols codes (it always start with byte 255 followed by two bytes more)
- Transform bytes to string (text=stream.BytesToString(buffer(),0,counter))
- Loop again all chars in search for special characters (like ", &, line breaks, etc), and when find one substitutes it for the corresponding HTML syntax (" for " ; or line break for <br/>). Also when find ANSI color syntax, like the "[1;33m" (to put yellow color) and "[0m" (to return to standard color) in the previous example, substitutes it by "</font> <font color='yellow'>eastern</font><font color='white'>"
- Adds start HTML tag ("<HTML><font bgcolor='black' color='white'>") and end tag ("</font></HTML>") to the previous changed text
- Adds the resulting text to previous text already received
- Html.showHtml (resultingText)
I can only see one optimization at the starting point, when the app does a loop/substitution in all bytes received, then a new loop to change bytes to string, then a new loop on all string chars/substitution. Better do every change in bytes and then do bytesToString (will then be a code harder to read/maintain), do immediately bytesToString and all substitutions then (I tried this before but was having some troubles tracking byte 255 and escape char), or keep it this way?
Thank you in advance (once again)
Best regards