diff options
| -rw-r--r-- | include/ILexer.h | 8 | ||||
| -rw-r--r-- | include/Scintilla.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 3 | ||||
| -rw-r--r-- | src/Document.cxx | 18 | ||||
| -rw-r--r-- | src/Document.h | 6 | ||||
| -rw-r--r-- | src/Editor.cxx | 10 | 
6 files changed, 43 insertions, 3 deletions
diff --git a/include/ILexer.h b/include/ILexer.h index b119ff649..e08b8701c 100644 --- a/include/ILexer.h +++ b/include/ILexer.h @@ -62,6 +62,14 @@ public:  	virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0;  }; +class ILoader { +public: +	virtual int SCI_METHOD Release() = 0; +	// Returns a status code from SC_STATUS_* +	virtual int SCI_METHOD AddData(char *data, int length) = 0; +	virtual void * SCI_METHOD ConvertToDocument() = 0; +}; +  #ifdef SCI_NAMESPACE  }  #endif diff --git a/include/Scintilla.h b/include/Scintilla.h index 1cccd7872..11f9bbd9e 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -831,6 +831,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,  #define SC_TECHNOLOGY_DIRECTWRITE 1  #define SCI_SETTECHNOLOGY 2630  #define SCI_GETTECHNOLOGY 2631 +#define SCI_CREATELOADER 2632  #define SCI_STARTRECORD 3001  #define SCI_STOPRECORD 3002  #define SCI_SETLEXER 4001 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index e0462a3fd..30aa8caea 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2202,6 +2202,9 @@ set void SetTechnology=2630(int technology,)  # Get the tech.  get int GetTechnology=2631(,) +# Create an ILoader*. +fun int CreateLoader=2632(int bytes,) +  # Start notifying the container of all key presses and commands.  fun void StartRecord=3001(,) diff --git a/src/Document.cxx b/src/Document.cxx index 4a7546cf1..86d5c6077 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -169,7 +169,7 @@ int Document::AddRef() {  // Decrease reference count and return its previous value.  // Delete the document if reference count reaches zero. -int Document::Release() { +int SCI_METHOD Document::Release() {  	int curRefCount = --refCount;  	if (curRefCount == 0)  		delete this; @@ -825,6 +825,22 @@ bool Document::InsertString(int position, const char *s, int insertLength) {  	return !cb.IsReadOnly();  } +int SCI_METHOD Document::AddData(char *data, int length) { +	try { +		int position = Length(); +		InsertString(position,data, length); +	} catch (std::bad_alloc &) { +		return SC_STATUS_BADALLOC; +	} catch (...) { +		return SC_STATUS_FAILURE; +	} +	return 0; +} + +void * SCI_METHOD Document::ConvertToDocument() { +	return this; +} +  int Document::Undo() {  	int newPos = -1;  	CheckReadOnly(); diff --git a/src/Document.h b/src/Document.h index 15aecbfe4..bd8a58274 100644 --- a/src/Document.h +++ b/src/Document.h @@ -193,7 +193,7 @@ public:  /**   */ -class Document : PerLine, public IDocument { +class Document : PerLine, public IDocument, public ILoader {  public:  	/** Used to pair watcher pointer with user data. */ @@ -252,7 +252,7 @@ public:  	virtual ~Document();  	int AddRef(); -	int Release(); +	int SCI_METHOD Release();  	virtual void Init();  	virtual void InsertLine(int line); @@ -281,6 +281,8 @@ public:  	void CheckReadOnly();  	bool DeleteChars(int pos, int len);  	bool InsertString(int position, const char *s, int insertLength); +	int SCI_METHOD AddData(char *data, int length); +	void * SCI_METHOD ConvertToDocument();  	int Undo();  	int Redo();  	bool CanUndo() { return cb.CanUndo(); } diff --git a/src/Editor.cxx b/src/Editor.cxx index fb7f4c636..d52d2498f 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -8708,6 +8708,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {  		(reinterpret_cast<Document *>(lParam))->Release();  		break; +	case SCI_CREATELOADER: { +			Document *doc = new Document(); +			if (doc) { +				doc->AddRef(); +				doc->Allocate(wParam); +				doc->SetUndoCollection(false); +			} +			return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc)); +		} +  	case SCI_SETMODEVENTMASK:  		modEventMask = wParam;  		return 0;  | 
