ScintillaSendMessage()

Syntax

Result = ScintillaSendMessage(#Gadget, Message [, Param [, LParam]])
Description
Sends a message to the scintilla control to perform a specific task.

Parameters

#Gadget The scintilla gadget to use.
Message The message to send. More information about the possible messages may be found on the Scintilla Homepage. The #SCI_[...] constants representing the possible values are already defined in PureBasic.
Param (optional) The first custom parameter for the specified message. Default value if not specified is zero.
LParam (optional) The second custom parameter for the specified message. Default value if not specified is zero.

Return value

The result of the message sent.

Example: Text with red highlighting

  #num_indicator = 0
  
  If OpenWindow(0, 0, 0, 330, 90, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
    If InitScintilla()
      ScintillaGadget(0, 5, 5, 320, 80, 0)
      *Text = UTF8("This is a simple ScintillaGadget with text..." + #LF$ + "More text" + #LF$ + "Even more text!")
      ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Text)
      FreeMemory(*Text) ; The buffer made by UTF8() has to be freed, to avoid memory leak
      
      ScintillaSendMessage(0, #SCI_INDICSETSTYLE, #num_indicator, #INDIC_STRAIGHTBOX) ; first indicator with style 8 (0-19)
      ScintillaSendMessage(0, #SCI_INDICSETFORE, #num_indicator, #Red)                ; first indicator with red color
      ScintillaSendMessage(0, #SCI_SETINDICATORCURRENT, #num_indicator, #INDIC_STRAIGHTBOX) ; set the indicator as the current one
      ScintillaSendMessage(0, #SCI_INDICSETUNDER, #num_indicator, 1)   ; set indicator under the text, i.e. doesn't obscure it
      ScintillaSendMessage(0, #SCI_INDICSETALPHA, #num_indicator, 127) ; set transparency
      nLine = 1 ; line number starts from 0
      start = ScintillaSendMessage(0, #SCI_POSITIONFROMLINE, nLine)
      length = ScintillaSendMessage(0, #SCI_GETLINEENDPOSITION, nLine) - start
      ScintillaSendMessage(0, #SCI_INDICATORFILLRANGE, start, length) ; start and length
    EndIf
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Supported OS

All

<- ScintillaGadget() - Scintilla Index