Code: Select all
;Streaming code credit goes to El_Choni
Global *InPtr, InText$
Procedure EditStreamCallback(dwCookie.l, *pbBuff.l, cb.l, *pcb.Long)
If dwCookie = 0
length = MemoryStringLength(*InPtr)
If length > cb
CopyMemory(*InPtr, *pbBuff, cb)
*InPtr + cb
*pcb\l = cb
ElseIf length < = cb
CopyMemory(*InPtr, *pbBuff, length)
*InPtr + length
*pcb\l = length
EndIf
EndIf
ProcedureReturn #S_OK
EndProcedure
Procedure SetColor(Gadget, Color)
Protected format.CHARFORMAT2, sel.CHARRANGE, sel_saved.CHARRANGE
format\cbSize = SizeOf(CHARFORMAT2)
format\dwMask = #CFM_COLOR
format\crTextColor = Color
SendMessage_(GadgetID(Gadget), #EM_SETCHARFORMAT, #SCF_SELECTION, @format)
EndProcedure
OpenWindow(0, 0, 0, 322, 170, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
EditorGadget(0, 8, 8, 306, 133, #PB_Editor_ReadOnly)
SetActiveGadget(0)
SetColor(0, #Blue)
eStream.EDITSTREAM
eStream\dwCookie = 0
eStream\pfnCallback = @EditStreamCallback()
Restore myData
For c = 1 To 46
Read myChar.c
InText$ = Chr(myChar)
*InPtr = @InText$
Delay(100)
If Asc(InText$) < 97
SetColor(0, #Blue)
Else
SetColor(0, #Red)
EndIf
SendMessage_(GadgetID(0), #EM_STREAMIN, #SF_TEXT | #SFF_SELECTION, @eStream)
UpdateWindow_(GadgetID(0))
Next c
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
DataSection
myData:
Data.s "The Lazy Brown Fox ", Chr(13), "Jumped Over Fred's Head"
EndDataSection