Page 1 of 1

Scintilla :switch source

Posted: Fri Jun 06, 2003 12:38 am
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 ???

Posted: Fri Jun 06, 2003 4:15 pm
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!