Scintilla :switch source

Just starting out? Need help? Post your questions and find answers here.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Scintilla :switch source

Post by eddy »

I read that I can open many sources in one scintilla window.

To create a new empty source :

Code: Select all

*doc=SCI_GETDOCPOINTER() ;get current doc handle
SCI_ADDREFDOCUMENT(*doc) ;save current doc
SCI_SETDOCPOINTER(0)     ;remove current doc / create a new doc
To switch source :

Code: Select all

*doc=SCI_GETDOCPOINTER()       ;get current doc handle
SCI_ADDREFDOCUMENT(*doc)       ;save current doc
SCI_SETDOCPOINTER(*save_doc)   ;remove current doc / activate a saved doc
Is it correct ?
I don't understand what is the problem with SCI_RELEASEDOCUMENT ???
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Not realy:

First of all: All Documents have a reference count. This count is increased, when a SCI-Edit-Gadget shows this Document and is decreased, when a SCI-Edit-Gadget had shown this document and now a other Document should be showned in this gadget. If this count reach 0, the document is earesed!

Create a new Document (is not shown!)

Code: Select all

*document=SCI_CREATEDOCUMENT()
Switch to an other document and save the old one

Code: Select all

*old_doc=SCI_GETDOCPOINTER()
SCI_ADDREFDOCUMENT(*old_doc) ; increase the count, because set... will decrease it, and when it reach zero -> delete the old one
SCI_SETDOCPOINTER(*new_doc)
When you want to "remove" the current document and show a other:
(the old document is deleted, when no other sci-edit-gadget showed it)

Code: Select all

SCI_SETDOCPOINTER(*new_doc)
When you want to delete a document:

Code: Select all

SCI_RELEASEDOCUMENT(*document)
BUT MAKE SURE, THAT NO OTHER SCIEDI-GADGET SHOW THIS DOCUMENT!
Post Reply