I've created a small terminal program to receive characters from the serial port. While the program works as required, I do have a quirk with the display of text that I can't seem to fix.
I've created a GUI window with EditorGadget() and call a procedure in my main loop to update its contents if a byte has been received via a serial routine.
From what I understand, EditorGadget() really only works with a line of text (a string) rather than an individual character. Is this correct?
Code: Select all
; if uart_byte contains a character then read EditorGadget() contents, append uart_byte to the contents and display it in EditorGadget() again.
Procedure updateUART()
If uart_byte <> 0
SetGadgetText(#uartOutput, GetGadgetText(#uartOutput) + Chr(uart_byte))
EndIf
EndProcedure
Is there a better way to add individual characters/bytes to a GUI text window?
Should I be using a different Gadget?
One of the downsides to the above code is once the text box is full and beyond the scroll area, the cursor always remains at the top of the text ie. the first character. If I scroll down to the last character to read the text and a new character arrives then the cursor and text shoot back to the start again... quite annoying.
Does anyone have a fix for this?
The other downside is while I built my app on a Linux platform and it visually looks to update the text box smoothly, the same cannot be said for the code on the Windows platform (XP, Win7 and Win8). The text box (EditorGadget) flashes the text quite horribly as it adds a new character. Almost as though its clearing the text box window between a read of the text box content and writing of the new content.
Anyone have a fix for this?
I'd like to keep the app cross platform and avoid OS specific API's if possible.
I'm coding with Purebasic 5.62 (x64) on Debian Linux 9 with LXDE desktop
Any suggestions would be much appreciated. Thanks.