Commit Graph

274 Commits

Author SHA1 Message Date
Allan Odgaard
0715331daf Let OakDocument use OakSourceControlManager 2016-09-21 08:11:48 +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
Allan Odgaard
5cea5cd4c1 Let OakDocumentController know about documents with changed path/inode 2016-09-13 07:37:16 +02:00
Allan Odgaard
d65bbc567a Handle document sticky flag in the UI layer 2016-09-13 07:37:16 +02:00
Allan Odgaard
6e56e709e8 Use OakDocumentController to track OakDocument instances
Currently all OakDocument factory methods goes via the document controller but it would probably be better to move these methods to the document controller so that all document creation happens via the controller (unless one wants to opt out of the services provided, e.g. documents used with the bundle editor and commit window do not need to be “tracked”).
2016-09-12 10:48:05 +02:00
Allan Odgaard
00634dde59 Add OakDocumentController
This can be used to track all OakDocument instances and also as a factory to create them (from a path).
2016-09-12 10:39:21 +02:00
Allan Odgaard
656912ae17 Let documentWithString: go via documentWithData:
This is just to limit the functions that create new documents.

Also make initWithPath: and untitledCount: available in OakDocument’s private interface.
2016-09-12 10:25:11 +02:00
Allan Odgaard
ba35bc6b74 Don’t check if path exists when path is nil
Also add initializer signatures to our (private) interface.
2016-09-12 10:20:57 +02:00
Allan Odgaard
57d9f0602d Allow Objective-C(++) tests in the document framework
Now that we have OakDocument, we should rewrite the tests against this API.
2016-09-12 09:25:12 +02:00
Allan Odgaard
37943741ad Fix potential retain cycle
This would happen when creating a document with content and never opening and closing that document, so our buffer would never be deleted (previously deleted when closing a document), and the buffer callback previously held a strong reference to our document.
2016-09-12 09:25:12 +02:00
Allan Odgaard
553e89ceb6 Update include statements and link declarations 2016-09-11 12:47:39 +02:00
Allan Odgaard
9f4ff49529 Change kBookmarkIdentifier → OakDocumentBookmarkIdentifier 2016-09-11 08:46:11 +02:00
Allan Odgaard
04def9dfd0 Add convenience constructor to OakDocument 2016-09-11 08:45:30 +02:00
Allan Odgaard
f961b5a683 Treat nil as empty payload when setting a mark 2016-09-11 08:31:21 +02:00
Allan Odgaard
2ba9366669 Add API to enumerate all marks for a single line 2016-09-11 08:30:59 +02:00
Allan Odgaard
d252e262be Add API to enumerate all bookmarks 2016-09-11 08:29:09 +02:00
Allan Odgaard
24ae5b0d21 Move grammars_for_path to the file framework 2016-09-04 20:17:42 +02:00
Ronald Wampler
06ba9b6dab Don't store our font scale factor as a percentage
While we want to show the font scale factor as a percentage in the UI, internally, we should represent it as a CGFloat, which is more consistent with the NSFont APIs and makes interacting with them easier.
2016-09-04 20:17:42 +02:00
Allan Odgaard
6bc27b8511 Handle begin/end undo grouping for document w/o document editor
Previously this would be a no-op basically bringing the undo stack out of sync and making TextMate prone to crashing.

We create an undo group when reloading document changes and here we do not create a document editor, hence when this happened for unselected tabs (which currently have no document editor), the undo stack was brought out of sync.
2016-08-30 09:15:17 +02:00
Allan Odgaard
b0c77ff656 Fix minor whitespace issues 2016-08-29 12:44:15 +02:00
Allan Odgaard
2b3f0734d5 Use path::rename_or_copy for backups 2016-08-29 07:50:19 +02:00
Allan Odgaard
46fb745bbe Use perrorf when printing errors with dynamic strings
Also revise error messages to be more consistent.
2016-08-28 17:25:26 +02:00
Allan Odgaard
c78473dc6c Make OakDocument’s visibleIndex and selection properties public 2016-08-28 17:21:35 +02:00
Allan Odgaard
0153e837a8 Remove document::run API 2016-08-28 13:32:49 +02:00
Allan Odgaard
0638874b61 Tag code that can be retired when updating OS requirement
When bumping the minimum requirement we can do a search for MAC_OS_X to find all places where we have compatibility code.
2016-08-28 09:13:33 +02:00