QScintilla component
by JohnK

This component uses the open source Scintilla RichEdit replacement. It supports line numbers, multiple undo and redo, Code folding, support for several programming languages and more.

for details see http://Scintilla.org

ActiveLineColor(BackClr AS INTEGER, Alpha AS INTEGER)
SUB
AddBookMark(TheLine AS INTEGER) As Long

You must CREATEBOOKMARK before adding one. Returns a handle
FUNCTION
AnchorPosition () AS INTEGER
	This is the start of a selection
FUNCTION
	BookmarkPresent(TheLine AS INTEGER) As Long
FUNCTION
CanCopy() AS INTEGER
FUNCTION
CanPaste() AS INTEGER
FUNCTION
CanRedo() AS INTEGER
FUNCTION
CanUndo() AS INTEGER
FUNCTION
Clear()
SUB
Close()
Sub
CopyToClipboard ()
SUB
CreateBookMark(TheSymbol AS INTEGER, Fore AS INTEGER, Back AS INTEGER) As Integer
FUNCTION
CurrentLineNumber() As Integer
FUNCTION
CutToClipboard ()
SUB
DelBookMark(TheLine AS INTEGER)
SUB
DeleteBookMarkHandle(MarkHandle AS INTEGER)
SUB
EnsureLineVisible(TheLine AS INTEGER)
SUB
Find(S As String, Searchflags As Integer,  GlobalSearch As Integer, backwards As Integer) AS INTEGER

	Resets current position
	GlobalSearch can be:
	0 - from current location
	1 - from the start of the document
	2 - selected text
FUNCTION
FindLocation(S As String, Searchflags As Integer,  SearchLoc As Integer, backwards As Integer) AS INTEGER
	This just returns a location
FUNCTION
FoldCollapseAll
SUB
FoldExpandAll
SUB
FoldToggleAll
SUB
GetEditor(CommandCode AS INTEGER, Value1 AS INTEGER, Value2 AS INTEGER) AS INTEGER
FUNCTION
GetLineLength(line As Integer) As Integer
FUNCTION
GoToBookMarkHandle(MarkHandle AS INTEGER)
SUB
GoToLine(n AS INTEGER)
SUB
GotoText(Text AS STRING)
SUB
HideSelection(flag AS INTEGER)
SUB
Init(MenuForm AS LONG)
SUB
Line(n AS INTEGER) AS STRING
FUNCTION
LineCount() AS INTEGER
FUNCTION
LoadFromFile (FileName$)
SUB
LoadFromMemStream (Stream AS QMEMORYSTREAM)
SUB
LoadKeywordList(indx AS INTEGER, TheList AS QSTRINGLIST)
SUB
LoadKeywords(indx AS INTEGER, TheList AS STRING)
SUB
Modified () AS INTEGER
FUNCTION
New
	This will reset the object
SUB
NextBookmark(ForwardScan AS INTEGER, SelectIt AS INTEGER) AS INTEGER
FUNCTION
PasteFromClipboard ()
SUB
Position() AS INTEGER
	This is the current character position
FUNCTION
ReadOnly() AS INTEGER
FUNCTION
Replace(S As String, Rep As String, Searchflags As Integer, GlobalSearch As Integer, backwards As Integer) AS INTEGER
	Resets current position
	GlobalSearch can be:
	0 - from current location
	1 - from the start of the document
	2 - selected text
FUNCTION
Resize(top%, left%, Width%, Height%)
SUB
SaveToFile(FileName$)
SUB
SaveToMemStream (Stream AS QMEMORYSTREAM)
SUB
ScrollWidth() As INTEGER
FUNCTION
SelectAll()
SUB
SelEnd() AS INTEGER
FUNCTION
SelLength() AS INTEGER
FUNCTION
SelStart() AS INTEGER
FUNCTION
SelText() AS STRING
FUNCTION
SendEditor(CommandCode AS INTEGER, Value1 AS INTEGER, Value2 AS INTEGER) AS INTEGER
	You can use this instead of SendMessage(Handle, arg1, arg2, arg3) 
SUB
Set_AnchorPosition(NewPos AS INTEGER)
SUB
Set_CodeFolding(flag AS INTEGER, WantLines AS INTEGER)
SUB
Set_CodePage(ByVal NewValue As INTEGER)
SUB
Set_Font(TheFont AS QFONT)
SUB
Set_Language(LangIndx AS INTEGER)
SUB
Set_LanguageByName(LangName AS STRING)
SUB
Set_LineNumbers(flag AS INTEGER)
SUB
Set_Position(ThePos AS INTEGER)
SUB
Set_ReadOnly(flag AS INTEGER)
SUB
Set_ScrollBars(ScrollSet AS INTEGER)
SUB
Set_ScrollWidth(ByVal NewValue As Long)
SUB
Set_SelColor(ForeColr AS INTEGER, BackColr AS INTEGER)
SUB
Set_SelEnd(ThePos AS INTEGER)
SUB
Set_SelLength(n AS INTEGER)
SUB
Set_SelStart(ThePos AS INTEGER)
SUB
Set_SelText(Txt AS STRING)
SUB
Set_TabWidth(NewValue AS Integer)
SUB
Set_Text(NewText As String)
SUB
Set_WantTabs(flag AS INTEGER)
SUB
Set_WordWrap(ByVal NewValue As INTEGER)
SUB
SetFocus()
	Lets you set the focus without knowing the handle
SUB
SetStyleByAttributes(StyleIndex AS INTEGER)
SUB
SetStyleColors(StyleIndex AS INTEGER, Forecolor AS INTEGER, BackColor AS INTEGER)
SUB
Size() AS INTEGER
FUNCTION
AddStrings(...)
SUBI
SetStyle(...)
SUBI
TabWidth() AS Integer
FUNCTION
Text() As String
FUNCTION
ToggleCodeFolding
SUB
ToggleFoldLine(LineNum As Integer)
SUB
UniCode() As String
FUNCTION
UpdateLexerFont
SUB
ViewBookMarks(flag AS INTEGER)
SUB
ViewIndentation(flag As Integer)
SUB
ViewWhiteSpace(flag As Integer)
SUB
WantTabs() AS INTEGER
FUNCTION
WhereX () AS INTEGER
FUNCTION
WhereY () AS INTEGER
FUNCTION
WndProc(Hwnd AS Long, Msg AS Long, wParam AS Long, lParam AS Long) AS lONG
FUNCTION
WordAtCursor () AS STRING
FUNCTION
WordLeftOfCursor () AS STRING
FUNCTION
WordRightOfCursor () AS STRING
FUNCTION
WordWrap () AS INTEGER
FUNCTION

'Example code

'***************************************************
' *** Test code 
'***************************************************
$TYPECHECK ON
$INCLUDE <RapidQ2.inc>
$INCLUDE <QScintilla.inc>

CREATE Form AS QForm
	Width = 800
	Height = 700
	KeyPreview = True

CREATE RichEdit AS QScintilla
	Init(0) 'no form menus
	Width = Form.ClientWidth 'Screen.Width
	Height = Form.ClientHeight 'Screen.Height
END CREATE
END CREATE
Form.Showmodal

'Example #2

'***************************************************
' *** Test code 
'***************************************************
$TYPECHECK ON
$INCLUDE <RapidQ2.inc>
$INCLUDE <QScintilla.inc>

DECLARE SUB editDblClick
DECLARE Sub TestMenu


CREATE Form AS QForm
Width = Screen.Width
Height = Screen.Height
KeyPreview = True

CREATE MainMenu AS QMainMenu
CREATE mnuItem1 AS QMenuItem
Caption = "&File"

CREATE mnuItem2 AS QMenuItem 
Caption = "Test Click" 
Shortcut = "shift+ctrl+S"
OnClick = TestMenu
END CREATE
END CREATE
END CREATE

CREATE RichEdit AS QScintilla
Init(Form.Handle) 'Form has menus with shortcut keys
Width = Form.ClientWidth 'Screen.Width
Height = Form.ClientHeight 'Screen.Height

OnDblClick = editDblClick
LoadFromFile("QScintilla.inc")
END CREATE
END CREATE

SUB editDblClick 'display selected text
Showmessage RichEdit.SelText
END SUB

Form.ShowModal



Sub TestMenu
Showmessage "going to find LoadKeywordList"
RichEdit.Find("LoadKeywordList", SCFIND_WORDSTART, 0, 0)
Showmessage "Go to next find of SUB"
RichEdit.GotoText("Sub")
Showmessage "row cursor is at: " +str$(RichEdit.WhereY)
end sub