Commit Graph

181 Commits

Author SHA1 Message Date
Allan Odgaard
a00a4c2d86 Add displayNameWithExtension: method to OakDocument
This will also ensure the display name does not contain any slashes (which it can when a custom name is set) so that it is safe to use this as a filename.
2016-07-08 10:13:48 +02:00
Allan Odgaard
9deb1bf1be Remove content argument from didSave callback method 2016-07-08 10:13:48 +02:00
Allan Odgaard
3a84c1ca3c Simplify code to find a grammar’s file extension 2016-07-08 10:13:48 +02:00
Allan Odgaard
0e5e448295 Remove unused file type argument to file::save 2016-07-08 10:13:47 +02:00
Allan Odgaard
da47f80aaa Only update grammar and indent settings for open documents 2016-07-07 12:19:45 +02:00
Allan Odgaard
8fb18e3168 Add directory property to OakDocument
This is useful for untitled documents so that we know where to look for folder specific settings.
2016-07-07 12:19:45 +02:00
Allan Odgaard
e2b474cad6 Fix incorrect OakDocument initializer
When trying to open a non-existing document by UUID we would get back a partially initialized object.
2016-07-07 08:57:09 +02:00
Allan Odgaard
fd4395c2bf Use document’s “logical path” to lookup preferred encoding 2016-07-06 19:04:47 +02:00
Allan Odgaard
665ad94892 Document settings would not be read using document’s path
A document has both a virtual and an actual path. The virtual path is relevant e.g. when opening files via rmate, where we want to lookup file-type specific settings based on the remote path (filename) rather than the local temporary file. However, if there is no virtual path, we should fallback on the actual path, which broke when we made document_t a wrapper for OakDocument.

There is now a new logical_path getter which return the virtual path and fallback on the actual path.

Closes textmate/bugs#21
2016-07-06 16:46:07 +02:00
Allan Odgaard
6c73e4bbae Remove legacy open callback abstract base class 2016-07-05 22:58:22 +02:00
Allan Odgaard
ec430fe375 Don’t let layout_t rely on caller to set the theme’s font
The theme_t::copy_with_font_name_and_size is an implementation detail that would be nice to get rid of.
2016-07-05 12:13:05 +02:00
Allan Odgaard
823313d276 Add some assertions 2016-06-30 22:37:18 +02:00
Allan Odgaard
d9769edf6b Loading document in the progress of loading would return immediately
This could lead to a crash if the second caller of load would access the document’s buffer (before the load initiated by first caller had finished).

Issue introduced in beta 11.
2016-06-30 22:32:42 +02:00
Allan Odgaard
5f336984f3 OakDocument was only using virtual path to lookup some settings 2016-06-29 22:36:09 +02:00
Allan Odgaard
629ac714f3 Limit the steps taken by OakDocument to find a file type
If there is no custom binding and no installed grammar matches the document (based on content or path extension) then we leave the document without a file type and expect the caller (of loadModalForWindow:completionHandler:) to set the file type (in the completion handler).

The caller can consult online bundles, present UI to the user, and also know about “project directory”, so they can make a better choice than the OakDocument.
2016-06-29 21:55:02 +02:00
Allan Odgaard
15d798dde8 Add proposedGrammars method to OakDocument
This returns an array of grammars that can be used with the receiver, either matched via file type extension or first line.
2016-06-29 14:21:55 +02:00
Allan Odgaard
ca24ad9388 Remove unused grammar selection sheet resources 2016-06-29 11:37:29 +02:00
Allan Odgaard
5361e287f9 Do not handle file type sniffing in file::open
This disables support for showing the user a selection sheet when the file type is unknown, instead we fallback on text.plain.
2016-06-29 11:37:29 +02:00
Allan Odgaard
e88f40a76d Do not attempt to save document meta data for non-existing files 2016-06-29 11:37:29 +02:00
Allan Odgaard
1b7e37affa Set OakDocument’s ‘onDisk’ property during initialization
The old implementation in document_t would check the status in the getter when the document wasn’t open, since we only observe the disk for open documents.

Such solution though would not support key/value observing.

We could improve performance slightly by accepting an “isOnDisk” flag in the initializer since when we create documents from scanning the disk (folder search and file chooser) we already know the document is on disk and thus could skip the extra disk access.
2016-06-29 11:37:28 +02:00
Allan Odgaard
3f44309466 Post OakDocumentWillCloseNotification when closing a document 2016-06-29 11:37:28 +02:00
Allan Odgaard
4b0dcce670 Potentially update document’s file type when editing first line
If an edit to the first line causes the document to match with a different grammar then we switch to this grammar.
2016-06-29 11:37:28 +02:00
Allan Odgaard
f55d929aed Remove scale factor support from the print dialog
The implementation was no different than adjusting the font size, so since that is also exposed, there is no reason to provide both to the user.
2016-06-29 11:37:28 +02:00
Allan Odgaard
bcae1a8aa1 Move printing support to OakDocument 2016-06-29 11:37:28 +02:00
Allan Odgaard
f78bfd306d Remove unused constant for “mixed newlines” and callback related to this 2016-06-29 11:37:28 +02:00
Allan Odgaard
78b528f299 Update LINK dependencies in target files 2016-06-29 11:37:27 +02:00
Allan Odgaard
ab1b4a1237 Move everything about loading a document to OakDocument 2016-06-29 11:37:27 +02:00
Allan Odgaard
f97e89e84b Remove document_t::symbols 2016-06-29 11:37:27 +02:00
Allan Odgaard
1551efa8d2 Allow obtaining OakDocument from document_t and export OakDocument.h 2016-06-29 11:37:27 +02:00
Allan Odgaard
c21b421b5e Add enumerateSymbolsUsingBlock: to OakDocument
Currently this is a no-op when the document is closed.
2016-06-29 11:37:27 +02:00
Allan Odgaard
455fa2a4be Add keepBackupFile property to OakDocument 2016-06-29 11:37:27 +02:00
Allan Odgaard
8580b04e8d Move “recent documents” tracking to OakDocument 2016-06-29 11:37:19 +02:00
Allan Odgaard
cd614c9a3b Changing path already reset our file system observer 2016-06-24 17:23:18 +02:00
Allan Odgaard
994d60120f Update backup file atomically and verify that writing succeeded 2016-06-23 10:03:41 +02:00
Allan Odgaard
33aec21dcb Provide buffer_t visitor with offset and a way to stop the visit
If the lambda stops the visit then buffer_t::visit_data will return true, otherwise it returns false.
2016-06-22 23:22:47 +02:00
Allan Odgaard
4e15783500 Change document_t to be a thin wrapper for OakDocument 2016-06-22 20:56:12 +02:00
Allan Odgaard
8fac4b51a4 Add OakDocument class
This is intentionally kept very similar to document_t so that we can make document_t a wrapper and once all document_t code has been migrated to OakDocument, we can extend the API like introducing an OakDocumentEditor and possibly make it an NSDocument subclass.

The implementation of OakDocument have some minor improvements over document_t for example when a document is changed on disk we delay reloading the changes until TextMate is made active, and we currently do not reload the content when there are merge conflicts (though we need to warn the user about this).

Minimum OS requirement is now OS X 10.8 because we use NSUUID.
2016-06-22 20:56:12 +02:00
Allan Odgaard
469fd74a7b Rely on ARC to manage GCD types (10.8) 2016-06-22 20:43:28 +02:00
Allan Odgaard
371d426c5f Add ‘char const*’ insertion API to ng::buffer_t 2016-06-21 23:23:44 +02:00
Allan Odgaard
735ba3a386 Remove explicit BOM support from document_t 2016-06-21 19:20:56 +02:00
Allan Odgaard
5c7b04fbd3 Add missing include for test/jail.h 2016-06-19 08:45:16 +02:00
Allan Odgaard
41ed2817e7 Remove unused ‘searchBackups’ argument from document::find
The function will always search backups and so far there has not been a reason to disable it.
2016-06-16 10:53:11 +02:00
Allan Odgaard
221026472d Change document_t source to Objective-C++ 2016-06-14 20:42:26 +02:00
Allan Odgaard
781eb82c43 Remove unused support for non-recursive document callbacks 2016-06-14 20:42:26 +02:00
Allan Odgaard
0e52185c00 Remove const versions of document_t’s buffer and undo_manager
Also remove the document_const_ptr typedef.
2016-06-14 20:42:26 +02:00
Allan Odgaard
67e4378a1e Don’t cache last-recently-used date in document_t
This optimization is hardly worth the added code complexity.
2016-06-13 13:02:50 +02:00
Allan Odgaard
cc03dd908e Remove document_t’s old reader API 2016-06-13 13:02:50 +02:00
Allan Odgaard
e0daad4ca3 Add visitor interface to document_t
This exposes less types and thus it is easier to change the implementation.
2016-06-13 13:02:50 +02:00
Allan Odgaard
9d308e4aa0 Use file::reader_t directly (instead of file_reader_t wrapper) 2016-06-13 13:02:50 +02:00
Allan Odgaard
dfd4c1cd6f Remove unused reader subclasses 2016-06-13 13:02:49 +02:00