Commit Graph

303 Commits

Author SHA1 Message Date
Allan Odgaard
bdf47657fe Remove document_t and related tests
Tests should be ported to OakDocument.
2016-10-03 22:09:10 +02:00
Allan Odgaard
b598784dbe Don’t make assumptions about document having a path 2016-09-30 12:44:01 +02:00
Allan Odgaard
07a44f7540 Always wrap document saving in open/close and inline didSaveAtPath:
Since open no longer tries to load the document it is safe to call even for a document with isLoaded == NO.
2016-09-29 09:56:49 +02:00
Allan Odgaard
e59b023119 Post OakDocumentContentDidChangeNotification for all buffer changes 2016-09-28 20:56:55 +02:00
Allan Odgaard
e93f34b5ab Only remove buffer callback if added
This is incase our initializer fails, here dealloc is still called, but we didn’t get to add the callback so we should not try to remove it.

Why our initializer would fail is beyond me, but I see a few crashes from this (though all from the same user on 10.8.5).
2016-09-27 21:49:32 +02:00
Allan Odgaard
2bf803b889 Post OakDocumentWillSaveNotification before reading extended attributes
The notification makes the text view update the visualIndex (saved as an extended attribute) so previously we would save the previous value for this attribute.
2016-09-26 11:11:15 +02:00
Allan Odgaard
e6ed50c107 Introduce kMacClassicThemeUUID since we reference it in multiple places 2016-09-26 11:09:32 +02:00
Allan Odgaard
d8312b833e Rely on NSUUID overload of to_s 2016-09-26 11:09:16 +02:00
Allan Odgaard
7cb8755a66 Fix issue with updating bufferEmpty property
We should initiate it to YES and the logic for when to skip updating was wrong because of precedence.
2016-09-26 08:09:58 +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