Through a asynch shell, I receive server log data (text) and the shell waits for another data like ‘tail -f’ command. ( in TextArea ).
I want to color the predefined text by using TextChange event, it works well.
The problem is that when I load the data initially, the number of lines are about 2000, so it is really slow due to TextChange event(Regexp / Coloring).
If I make another Button to call ‘Coloring’ method, it works but I think it is not good user experience.
If I could fire the TextChange only after the initial loading is done, it would be helpful.
The another issue is that I need to apply the TextChange event for coloring the text to the just added text later instead of the whole text.
Do you have any idea on this matter?
- Add a
dontColor as boolean property default True to your window
- In the TextChange event, place as first line
If dontColor then
dontColor = False
// Now proceed as before with the color routine
The first time TextChange fires (presumably when you load your text) your event will stop there. Subsequent events will happen normally. Whenever you need to suppress your color routine, just set dontColor to True.
At the start of your shell method set a property
IsLoadingData = true
then in the TextChange event do
if IsLoadingData then return
At the end of your shell method you need to call the coloring method, which shouldn’t be in the TextChange vent only. That’s one possibility.
Or you could make the text read-only during data load. Or you could fake the coloring by coloring only the visible part of the text.
Also consider using a Listbox instead of a TextArea. Each row will be one line of the log and will be colored in the TextPaint event. If you have really long log lines, you can wrap then manually, if needed.
The Boolean value would make it easier to control the time of coloring. Thank you.
By the way, after initial loading, I need to call ‘coloring’ method.
I’m using async shell and it is just connected to the remote server, that’s because I use ‘tail -f’ command in the shell.
Completed shell event doen’t get fired. It makes sense.
I tried to call ‘coloring’ method after the my method calling the Shell, the ‘coloring’ method didn’t affect.
I have a button to call ‘coloring’ method, and after checking the last rows and clicking it, it affects.
'Initial loading method
IsLoadingDataSRC = True
IsLoadingDataTGT = True
How can I call the ‘coloring’ method?
It makes sense to use a Listbox.
What do you think is the advantage of using Listbox in this log-viewing situation?
Speed and convenience. The drawback is having to manually wrap the text.
Btw, you are using the TextArea AppendText method?
Speed. Interesting. I will try that.
Yes, I use AppendText in Shell DataAvailable event.