There doesn't seem to be any flicker when just using the API.
Code: Select all
If OpenWindow(0, 0, 0, 330, 290, "Title", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 40, 20, 250, 250)
AddWindowTimer(0, 1, 5)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Timer
If EventTimer() = 1
i + 1
;AddGadgetItem(0, -1, "Editor Line " + Str(i))
text$ = "Editor Line " + Str(i) + #LF$
SendMessage_(GadgetID(0), #EM_REPLACESEL, i, @text$)
EndIf
EndSelect
ForEver
EndIf
Edit:
After some investigation, it seems that the flicker occurs when the #LF$ character is added.
The code below also has no flicker.
Code: Select all
Global old
Procedure EdWProc(hWnd, uMsg, wParam, lParam)
Protected s.s
If uMsg = #EM_REPLACESEL
If lParam
s = PeekS(lParam)
If s = #LF$
ProcedureReturn 0
EndIf
EndIf
EndIf
ProcedureReturn CallWindowProc_(old, hWnd, uMsg, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 330, 290, "Title", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 40, 20, 250, 250)
AddWindowTimer(0, 1, 5 )
old = SetWindowLongPtr_(GadgetID(0), #GWLP_WNDPROC, @EdWProc())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Timer
If EventTimer() = 1
i + 1
AddGadgetItem(0, -1, "Editor Line " + Str(i) + #LF$)
SendMessage_(GadgetID(0), #EM_SETSEL, $fffffff, $fffffff)
EndIf
EndSelect
ForEver
EndIf
Edit 2:
Interestingly, passing two characters(#CRLF$) instead of one(#LF$) works just fine.
Code: Select all
Global old
Global CRLF$ = #CRLF$
Procedure EdWProc(hWnd, uMsg, wParam, lParam)
If uMsg = #EM_REPLACESEL
If lParam
If PeekC(lParam) = #LF
ProcedureReturn CallWindowProc_(old, hWnd, uMsg, wParam, @CRLF$)
EndIf
EndIf
EndIf
ProcedureReturn CallWindowProc_(old, hWnd, uMsg, wParam, lParam)
EndProcedure
If OpenWindow(0, 0, 0, 330, 290, "Title", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 40, 20, 250, 250)
AddWindowTimer(0, 1, 5 )
old = SetWindowLongPtr_(GadgetID(0), #GWLP_WNDPROC, @EdWProc())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Timer
If EventTimer() = 1
i + 1
AddGadgetItem(0, -1, "Editor Line " + Str(i))
SendMessage_(GadgetID(0), #EM_SETSEL, $fffffff, $fffffff)
EndIf
EndSelect
ForEver
EndIf