Page 1 of 1

Scintilla multiple views

Posted: Sat Apr 21, 2007 11:14 pm
by Hydrate
Ive been looking at the scintilla documentation, and it would appear in the multiple views section that it allows scintilla to load multiple documents and switch between them.

My issue is that I have no idea how it works, at all, and im wondering if someone could give me some pointers here.

The documentation for Scintilla is below:
http://scintilla.sourceforge.net/Scinti ... rectAccess

Posted: Thu May 31, 2007 1:53 pm
by aaaaaaaargh
Using ts-soft's excellent Scintilla Userlibrary
(available at http://www.ts-soft.eu/dl/scintilla.zip)
you can open several Scintilla Gadgets and work with them as seperate documents or as one document with in a "split view" mode
the example below shows two SCIgadgets that use the same Document

XIncludeFile "SciLexer.pbi"
WindowID = OpenWindow(#PB_Any,px,py,400,400,"Scintilla Test",#PB_Window_SystemMenu|#PB_Window_TitleBar)
CreateGadgetList(WindowID(WindowID))
SCIGadget0 = ScintillaGadget(#PB_Any, 0, 0, 380, 180)
DocPointer = SCI_GetDocPointer(SCIGadget0)
SCI_ADDREFDOCUMENT(SCIGadget0,DocPointer)
SCIGadget1 = ScintillaGadget(#PB_Any, 0, 200, 380, 180)
SCI_SetDocPointer(SCIGadget1,DocPointer)
Buffer.s = "Bla "+Chr(10)

For a = 1 To 300
SCI_AppendText(SCIGadget1,Len(Buffer),@Buffer)
Next
Repeat
ev=WaitWindowEvent()
Until ev=#PB_Event_CloseWindow

Hope this helps!

Posted: Fri Dec 26, 2008 2:37 am
by eddy
PB 4.30

Code: Select all

ProcedureDLL ScintillaCallBack(ID, *scinotify.SCNotification)
  Protected Text.s, TextLength
  Protected LineBefore
  
  With *scinotify
    Select \nmhdr\code
      Case #SCN_CHARADDED
        Debug Str(ID) + " > character added"
        If \ch = #LF
          LineBefore = ScintillaSendMessage(ID, #SCI_LINEFROMPOSITION, ScintillaSendMessage(ID, #SCI_GETCURRENTPOS))-1
          TextLength = ScintillaSendMessage(ID, #SCI_LINELENGTH, LineBefore)
          Text = Space(TextLength + 1)
          Debug Text
        EndIf
    EndSelect
  EndWith
EndProcedure

InitScintilla()
WindowID = OpenWindow(#PB_Any, px, py, 400, 400, "Scintilla MultiViews", #PB_Window_SystemMenu | #PB_Window_TitleBar)

;twin scintilla gadgets
SCIGadget0 = ScintillaGadget(#PB_Any, 0, 0, 380, 180, @ScintillaCallBack())
SCIGadget1 = ScintillaGadget(#PB_Any, 0, 200, 380, 180, @ScintillaCallBack())

*DocPointer = ScintillaSendMessage(SCIGadget0, #SCI_GETDOCPOINTER)
ScintillaSendMessage(SCIGadget0, #SCI_ADDREFDOCUMENT, 0, *DocPointer)
ScintillaSendMessage(SCIGadget1, #SCI_SETDOCPOINTER, 0, *DocPointer)
;set margin width
ScintillaSendMessage(SCIGadget0, #SCI_SETMARGINWIDTHN, 0, ScintillaSendMessage(SCIGadget0, #SCI_TEXTWIDTH, #STYLE_LINENUMBER, @"_99999"))
ScintillaSendMessage(SCIGadget0, #SCI_SETMARGINWIDTHN, 1, 16)
;change type of margin ( can display folding mark )
ScintillaSendMessage(SCIGadget0, #SCI_SETMARGINMASKN, 1, #SC_MASK_FOLDERS)

;append text 
Text.s = "Bla"
Text + #LF$ + "Hi people,"
Text + #LF$ + "I'm a robot!"
Text + #LF$ + "Obey me!"
Text + #LF$ + "Try to write your text here..."
ScintillaSendMessage(SCIGadget1, #SCI_APPENDTEXT, Len(Text), @Text)

Repeat
  e = WaitWindowEvent()
Until e = #PB_Event_CloseWindow