Commit Graph

173 Commits

Author SHA1 Message Date
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
Allan Odgaard
36fedf5bee Change most buffer helper functions to accept buffer_api_t 2016-06-13 13:01:10 +02:00
Allan Odgaard
414c336ba9 Remove descendants when mark to remove has a trailing slash 2016-06-02 21:07:43 +02:00
Allan Odgaard
417193e089 Update link dependencies for all targets
Some targets were including headers from frameworks not specified in their link dependencies. For a clean build this could cause an issue because the header was not available at the time of building the target.

The updated link dependencies are also based on what a target’s tests require. Ideally tests would have separate link dependencies, but as we don’t want to maintain this manually, this will have to wait until the build system automatically handles link dependencies.

Currently the commit command uses constants from the CommitWindow framework but should actually not be linked with it. However, the optimizer will strip dead code, so it should not result in much if any difference in the resulting binary and does solve a build dependency issue.
2016-05-07 13:00:55 +02:00
Adam Strzelecki
e59db8375f Use panel language unless spellingLanguage is specified
This partially reverts changes of 3fdc72b93a:
Support spell checking being “automatic by language”.

Before 3fdc72b spellingLanguage .tm_properties setting (default "en") was the
only way to set spelling language for file (buffer). English was default
language for all files. 3fdc72b introduced change that when “automatic by
language” was selected in system's spelling panel then TextMate was ignoring
spellingLanguage setting and was using automatic by language.

However because “automatic by language” is default on OS X, effectively 3fdc72b
makes spellingLanguage setting no longer effective. To make it work one needs
to set explicit spelling language either in System Preferences or in spelling
panel upon each TextMate run (since this is getting reset after application
restart) - which is counter-intuitive, can be treated as regression and it is
vaguely described in ChangeLog:

 * Support spell checking being “automatic by language”. This is set via the
   spelling panel.

This change presents alternative approach, introducing new empty
spellingLanguage setting "" (which is now default), which makes use system
panel language setting, including “automatic by language”.

From now on all files will be checked against system panel selected language
(or automatic), unless .tm_properties project specifies explicitly language for
given file using, eg.:

    [ locale-en_US.ini ]
    spellingLanguage = en_US

    [ locale-pl_PL.ini ]
    spellingLanguage = pl_PL

Or automatically depending on file name:

    [ locale-*.ini ]
    spellingLanguage = '${TM_FILEPATH/^.*locale-([a-z]+_[A-Z]+).*$/$1/}'
2016-01-29 08:46:18 +07:00
Allan Odgaard
8fe7681ebd Remove unnecessary include of oak/compat.h 2015-08-05 12:31:20 +02:00
Allan Odgaard
40879d5683 Replace sizeofA macro with range-based for loop or std::begin/end 2015-03-05 16:38:09 +07:00
Allan Odgaard
439601b8b0 Introduce API to check if a file reader works on an “open” buffer 2015-01-29 14:35:34 +07:00
Allan Odgaard
29a576ffbe Don’t go via helper for pthread_setname_np
This was previously done because the function wasn’t available until 10.7, but since that is (now) our deployment target, there is no need to wrap the call.
2014-12-25 09:36:01 +01:00