diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 18 | ||||
-rw-r--r-- | src/Document.h | 6 | ||||
-rw-r--r-- | src/Editor.cxx | 10 |
3 files changed, 31 insertions, 3 deletions
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; |