Commit Graph

297 Commits

Author SHA1 Message Date
Allan Odgaard
c2a2ac591d Remove document_t and related tests
Tests should be ported to OakDocument.
2016-09-25 13:24:03 +02:00
Allan Odgaard
c6ddadbcd5 Let OakDocument use OakSourceControlManager 2016-09-25 13:24:03 +02:00
Allan Odgaard
94ad4f1dfa Initialize bufferEmpty property to YES 2016-09-25 13:24:02 +02:00
Allan Odgaard
973e38a383 Fix leak: buffer_callback_t 2016-09-25 07:31:13 +02:00
Allan Odgaard
14cdd420d3 Make backupPath property public 2016-09-24 09:37:31 +02:00
Allan Odgaard
b7e4f3bc4f Make OakDocument’s saveBackup: public API
This is required when saving session state.
2016-09-24 09:37:31 +02:00
Allan Odgaard
2f363060ee Make OakDocument’s isBufferEmpty property public 2016-09-24 09:37:30 +02:00
Allan Odgaard
331c2c08b4 Remove document::show API 2016-09-24 09:37:30 +02:00
Allan Odgaard
edaf02a6c3 Remove document_t callback system 2016-09-24 09:37:29 +02:00
Allan Odgaard
eef0878538 Remove document::show_browser
Instead use OakDocumentController’s showFileBrowserAtPath:
2016-09-24 08:55:18 +02:00
Allan Odgaard
38a2cd6c1e Remove revision and savedRevision from document API 2016-09-24 08:33:34 +02:00
Allan Odgaard
eb6b66181d Add markDocumentSaved API to OakDocument
This clears the isDocumentEdited flag and also does a “snapshot” for potentially future diff against changes on disk.
2016-09-24 08:33:33 +02:00
Allan Odgaard
9a4db4665d Add “show document” API to OakDocumentController
This is currently just a wrapper for the old C++ API.
2016-09-24 08:33:33 +02:00
Allan Odgaard
558eab8b13 Only set document revision and emptyBuffer properties on actual changes
These generate change notification for all the properties that depend on them (like isDocumentEdited and thus icon) even when set to the same value.
2016-09-24 08:33:33 +02:00
Allan Odgaard
c893dd6ba2 Reset document icon with isOnDisk changes 2016-09-24 08:33:32 +02:00
Allan Odgaard
49dadbd474 Remove backup file when setting keepBackupFile = NO 2016-09-24 08:33:32 +02:00
Allan Odgaard
49e99537a8 Allow passing nil to didTouchDocument: 2016-09-24 08:33:32 +02:00
Allan Odgaard
0cc15c10d2 Add API to create untitled document 2016-09-24 08:33:32 +02:00
Allan Odgaard
ba7ef25d66 No need for document editor to observe content did change notification 2016-09-21 22:20:39 +02:00
Allan Odgaard
bedf79aff3 Fix issue when loading the same document simultaneously
This could happen when restoring a session where the same document was open in multiple windows.
2016-09-21 20:39:42 +02:00
Allan Odgaard
5de8e6fd58 Sanitize selection if buffer is changed outside change group 2016-09-21 20:39:42 +02:00
Allan Odgaard
981b7a6d8f Move undo grouping to OakDocumentEditor 2016-09-21 20:39:42 +02:00
Allan Odgaard
c0b4e7319c Only regular expression searches use file size limit for non-open files 2016-09-21 20:39:42 +02:00
Allan Odgaard
ad01eb1ac6 Use stringArrayForKey: where appropriate 2016-09-21 20:39:41 +02:00
Allan Odgaard
53a6708c08 Add API to search for documents at multiple locations 2016-09-20 18:15:20 +02:00
Allan Odgaard
7cc017f343 Harmonize all implementations of sharedInstance 2016-09-19 12:54:19 +02:00
Allan Odgaard
238ee0cc4f Load potential backup before operating on non-loaded documents 2016-09-19 12:48:12 +02:00
Allan Odgaard
bc6c05086a Include untitled document’s directory in their description 2016-09-18 13:26:13 +02:00
Allan Odgaard
05711359a0 Also return untitled documents from enumerateDocumentsAtPath:
We look at the document’s directory property to see if it is within the folder being searched.
2016-09-18 13:26:13 +02:00
Allan Odgaard
9e5c4f27b6 OakDocumentController’s openDocuments now return a sorted array 2016-09-18 13:26:13 +02:00
Allan Odgaard
abeaa0498f OakDocument’s icon now indicate when a file is missing on disk 2016-09-18 13:26:12 +02:00
Allan Odgaard
1627a62b90 Clear document’s directory property when changing path
This is just for good measure.
2016-09-18 13:26:12 +02:00
Allan Odgaard
87dafa3332 Only let untitled documents read settings via directory property 2016-09-18 13:26:12 +02:00
Allan Odgaard
532e9742d2 Add openDocuments property to OakDocumentController
This uses OakDocument’s isOpen property to know which documents are open.

Currently not KVO compliant, but it probably should be.
2016-09-18 10:31:50 +02:00
Allan Odgaard
fa2eaa1e50 Make OakDocument’s open/isOpen separat from isLoaded
A loaded document is always open but an open document is not necessarily loaded.
2016-09-18 10:30:28 +02:00
Allan Odgaard
ddefdec649 Change document’s isOpen property to isLoaded
Since we do not load documents before the user selects them, e.g. after session restore or when opening multiple documents, it makes sense to have both an isOpen and isLoaded property, the former means “is shown somewhere in the UI” and would make it appear (e.g. in file browser) with close button etc., whereas the latter means that data has been loaded from disk, and we can safely access the buffer.
2016-09-18 10:29:21 +02:00
Allan Odgaard
31e3f37669 Remove code that ensured re-use of document_t instances
Since document_t is now a thin wrapper and OakDocument does its own tracking to ensure we do not create multiple documents for the same path, we no longer need document_t to take care of this.
2016-09-18 07:32:05 +02:00
Allan Odgaard
084ec6ac8f Invalidate backup timer when removing backup
The backup timer is retaining our document so the document would live for up to two seconds after it was closed, this was mainly a problem for untitled documents, as it meant the next new untitled document created would get a display name of “untitled n”.
2016-09-16 15:40:13 +02:00
Allan Odgaard
e34a90b30b A missing backup file would cause an assertion to fail
This is because we had the initializer search for the backup and fail (return nil) when no backup was found, but in that case, dealloc would be called on the (uninitialized) object, which would unregister the document, but the document had never been registered, hence the assertion failure (about only unregistering previously registered documents).
2016-09-16 15:39:33 +02:00
Allan Odgaard
dbc6e28dd2 Add icon property to OakDocument
This is KVO compliant with respect to calling the observer if properties that affect the icon are changed.
2016-09-16 15:39:33 +02:00
Allan Odgaard
80ee3e2d4c Make OakDocument’s performReplacements:checksum: public 2016-09-16 15:39:33 +02:00
Allan Odgaard
a187b5c7ab Remove document::scanner_t 2016-09-16 15:39:33 +02:00
Allan Odgaard
c66ccf95e7 Ensure enumerateByteRangesUsingBlock: iterate buffer on main thread
This method is called by the matchesForString:options: which can be called from a background thread.

Though we should revise this solution later to introduce proper locking on the buffer (and possibly path) instance variable to guarantee thread safety.
2016-09-16 15:12:55 +02:00
Allan Odgaard
6bb9ff2240 Add matchesForString:options: to OakDocument 2016-09-16 15:11:49 +02:00
Allan Odgaard
9088c63a1a Add mutex to make code (sort of) safe to use from multiple threads
The add/remove functions are called when opening/closing documents, in TextMate this happens in the main thread, but not when executing the tests. With the mutex, it should now be safe to call the functions from multiple threads at the same time although if file system changes are actually observed, the callback will be executed on the main thread.
2016-09-14 21:46:07 +02:00
Allan Odgaard
5506e9ccc4 Add new OakDocument-based directory scanner API 2016-09-14 08:36:13 +02:00
Allan Odgaard
6610adff97 Add scmStatus property to OakDocument
The OakDocument object will not subscribe to SCM changes until the getter has been called.
2016-09-13 23:49:17 +02:00
Allan Odgaard
74a44e2ebf fixup! Let OakDocumentController handle document LRU tracking 2016-09-13 23:49:17 +02:00
Allan Odgaard
590fd5b71b Change type of document_t::lru from oak::date_t to NSInteger 2016-09-13 08:17:35 +02:00
Allan Odgaard
8eaf1ad09c Let OakDocumentController handle document LRU tracking 2016-09-13 07:37:16 +02:00