Commit Graph

438 Commits

Author SHA1 Message Date
Allan Odgaard
1a7ef1af2b Improve termination UX with unsaved changes
Previously when multiple windows had unsaved changes we would use the frontmost window (with unsaved changes) for all the dialogs. Now we always bring to front the document for which we are presenting a sheet (like a save panel or encoding error).
2016-07-11 12:27:05 +02:00
Allan Odgaard
78c57eb213 Let showCloseWarningUIForDocuments: accept OakDocuments 2016-07-11 12:27:05 +02:00
Allan Odgaard
b6f111f0c9 Don’t cancel app termination when we need to show a save panel
Our previous save code was incompatible with the app termination event loop, so we had to abort app termination, but the updated code does not seem to have any issue.
2016-07-11 12:27:05 +02:00
Allan Odgaard
59f31a46a8 Remove old code used for saving documents 2016-07-11 12:27:05 +02:00
Allan Odgaard
b0ca4b1773 Use new save API in DocumentController 2016-07-11 12:27:04 +02:00
Allan Odgaard
84ecf729bd Use displayNameWithExtension: instead of DefaultSaveNameForDocument 2016-07-10 23:40:17 +02:00
Allan Odgaard
c12867182b Loading document can succeed, fail, or be cancelled by user 2016-07-10 23:40:16 +02:00
Allan Odgaard
73fba5b72b Remove unused import statement 2016-07-10 23:40:16 +02:00
Allan Odgaard
60180f77ec Let OakDocument post will/did save notification
With this change we only have OakTextView observe its current document.

This does mean that currently pre and post bundle actions are only executed for the selected document.
2016-07-10 11:29:41 +02:00
Allan Odgaard
9e06e35225 fixup! Use selected document’s path to find external scope attributes 2016-07-08 10:13:48 +02:00
Allan Odgaard
7619e6e9c2 Store document’s file type in session restore info 2016-07-07 12:19:45 +02:00
Allan Odgaard
1bab8548af Set project directory when restoring session
We would only set the “default” project directory and rely on the effective project directory being set when opening first document, however, for untitled documents we need the effective project directory to be setup prior to opening (to read the correct settings).
2016-07-07 12:19:45 +02:00
Allan Odgaard
9f1641911a Remove create_untitled_document_in_folder helper function 2016-07-07 12:19:45 +02:00
Allan Odgaard
2d50db451b Don’t update settings when creating untitled documents
This is now done (properly) when we open the document.
2016-07-07 12:19:45 +02:00
Allan Odgaard
5ef7bf1b9b Set document’s directory before opening it
This ensures we get proper folder specific settings for untitled documents that belong to a project.
2016-07-07 12:19:45 +02:00
Allan Odgaard
1aee165b4e Use document’s logical path for proxy icon etc. 2016-07-06 19:12:41 +02:00
Allan Odgaard
05fa669364 Be explicit about using selected document’s path for untitledSavePath
See rationale in commit d08250c428
2016-07-06 19:08:26 +02:00
Allan Odgaard
d08250c428 Use selected document’s path to find external scope attributes
We would previously use the documentPath property which does mirror the selected document’s path, but this will change to the logical path. Though for external scope attributes (such as which SCM or build system is used, only the real path makes sense).
2016-07-06 19:02:16 +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
3ef7c81470 Ensure a dropped tab is always moved
This is done by asking to both close and insert the tab, which works as a move regardless of the “re-order tabs” setting.
2016-07-04 23:10:37 +02:00
Allan Odgaard
3812acf2bc Support providing same document(s) as insert and close arguments
This is a way to move a document. Normally inserted documents already open will be moved, but only if the user hasn’t disabled tab re-ordering.
2016-07-04 23:01:54 +02:00
Allan Odgaard
d3f7193415 Don’t use NSControl’s controlSize property (backwards compatibility)
This property wasn’t available before 10.10.
2016-07-01 21:26:41 +02:00
Allan Odgaard
1bc09c2ee7 Don’t go through buffer_t to get document’s indent settings 2016-06-30 22:48:17 +02:00
Allan Odgaard
cba83cc413 Opening a file without a grammar can now suggest installing a bundle
This can be disabled using:

	defaults write com.macromates.TextMate.preview disableBundleSuggestions -bool YES

Though the user can also hold option and select “Never” for a suggestions to never see that again, and once the user has a custom binding for a document’s type, no suggestion will be shown.
2016-06-30 16:22:10 +02:00
Allan Odgaard
34c126b634 Add new class: SelectGrammarViewController
This can be used to ask the user about installing a new bundle.
2016-06-30 15:25:46 +02:00
Allan Odgaard
194a2c35c3 Ensure document always receives a file type
If OakDocument itself is unable to find one we look at the fileType .tm_properties setting, either looking it up using ‘attr.untitled’ for untitled documents, or ‘attr.file.unknown-type’ for documents with a path.

If nothing is found we fallback to ‘text.plain’.
2016-06-29 22:30:44 +02:00
Allan Odgaard
41b987e82c Select last added document when creating multiple tabs at once
When we close a tab then we select the tab to the left, for this reason it makes most sense to select the last tab added, so that ⌘W will effectively go to the “next tab inserted”.

The exception is when we create a new project, here we select the first tab since there are no tabs to the left, so ⌘W will still work as a “next tab” button. Though I may later change this so that the behavior is consistent.
2016-06-29 11:37:28 +02:00
Allan Odgaard
e39e744636 Simplify code which inserts new documents into the tab bar
All insertion now go through the same method.
2016-06-29 11:37:28 +02:00
Allan Odgaard
afe9240883 Use initializer list instead of helper function (C++11) 2016-06-29 11:37:28 +02:00
Allan Odgaard
c76022c367 Don’t use const reference for Objective-C property
I believe this used to be a requirement (presumably since a const reference can be treated as a pointer by Objective-C) but recent versions of clang have no problem with complex C++ data types in Objective-C class interfaces.
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
8580b04e8d Move “recent documents” tracking to OakDocument 2016-06-29 11:37:19 +02:00
Allan Odgaard
383ac8c29d Remove tmColorWithCGColor: / tmCGColor (10.8) 2016-06-23 08:45:30 +02:00
Allan Odgaard
7dd19c0c0e Update deployment target to 10.8 for all xib files 2016-06-22 20:43:28 +02:00
Allan Odgaard
f5832c975f Add missing include statements 2016-06-22 18:31:49 +02:00
Allan Odgaard
f60e0dad98 Use text::transcode_t instead if iconv API 2016-06-21 18:33:20 +02:00
Allan Odgaard
fb7c2cef3f Use NSUserDefaults’s specialized «type»ForKey: 2016-06-20 11:43:40 +02:00
Allan Odgaard
89376e6ac9 Always ask OakFileBrowser to validate deselectAll: and reload:
Also simplify code so that we only need to maintain a set of which actions the file browser should validate.
2016-06-19 09:40:09 +02:00
Allan Odgaard
dc0331b781 Change File Browser → Current Document to Select Document
Also make the title dynamic so that we show the current document’s name (when we have one) and add a separator below the menu item.
2016-06-19 09:40:08 +02:00
Ronald Wampler
e452a5ee55 Move "Go to Tab" to the Window menu and rename to "Select Tab"
Also edit the source to reflect the change in name (e.g., `updateGoToMenu:` → `updateSelectTabMenu:`).
2016-06-19 08:45:16 +02:00
Allan Odgaard
8483826fae Always use '\0' as fill value when creating a string buffer 2016-06-18 10:34:08 +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
36fedf5bee Change most buffer helper functions to accept buffer_api_t 2016-06-13 13:01:10 +02:00
Allan Odgaard
57d64d515a Introduce new callback: callback.document.did-open
Bundle items using this as their semantic class will be executed when the document is first loaded.
2016-05-30 12:00:44 +02:00
Allan Odgaard
3a2fc26c79 Handle return key for text view in Unknown Encoding sheet
Without full keyboard access enabled (System Preferences → Keyboard) the text view in the Unknown Encoding dialog would be the initial first responder, and while it’s read-only, pressing return would make the text view give up focus, rather than send the key to the window’s default button.
2016-05-22 22:32:58 +02:00
Allan Odgaard
17ea3ec568 To open document in new project the null UUID must be used
Previously when providing a project UUID while opening a document, and no project used this UUID, TextMate would create a new project (with this UUID).

This was both a way to force a file to open in its own project, and to open multiple files in the same project, even though they did not share project folder.

The problem is that `mate` will read the `TM_PROJECT_UUID` environment variable and use as target project, which is generally desired, but incase we launch a new application from TextMate, and this application later opens a file via `mate`, it will use the old `TM_PROJECT_UUID` value, which might no longer exist.

We still allow forcing files to open in their own project by introducing a special “null UUID”, but with this change, it is no longer possible to use multiple invocations of `mate` to open unrelated files in the same project. Should this be desired, we can re-introduce this feature but require that `mate` is given the UUID via its -p/--project argument.

Fixes textmate/latex.tmbundle#150
2016-05-09 16:31:06 +02:00
Allan Odgaard
0ca13d8f25 Opening document on non-active desktop gave key to wrong window
When our application is activated and our key window is on a non-active desktop with windows on the active desktop, the system will give focus to one of the windows on the active desktop.

To workaround this we make our window key after our application has become active.
2016-05-08 23:24:20 +02:00
Allan Odgaard
59ef52b1f6 Don’t special-case bringing window to front when app is hidden
It used to be that if we called unhideWithoutActivation followed by makeKeyAndOrderFont:, and finally activateIgnoringOtherApps: then we would end with only the key window on top of other windows in the desktop space.

E.g. from a terminal (with TextMate hidden) using “mate -w” would cause only a single window to open on top of the terminal window, which seemed like desired behavior.

Unfortunately Apple have changed the behavior so there is no need to explicitly call unhideWithoutActivation as this is implied by activateIgnoringOtherApps:.
2016-05-08 23:17:26 +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