388 Commits

Author SHA1 Message Date
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
Ronald Wampler
9c3923b485 Ensure path exists when adding document to Recent menu
It's possible that the path on the document is set even though it does not exist on disk. E.g., when using `mate` to create a new document from the command line.
2016-01-29 08:46:18 +07:00
Allan Odgaard
cb75d41db3 Prevent opening two tabs for the same file
This could previously be done by creating a symbolic link and then selecting both the symbolic link and the original file, and selecting to open both at once.

Since the two tabs would have same identifier, the NSView for one of the two tabs could be left behind in the tab bar when manipulating the tabs.
2015-10-17 17:42:19 +07:00
Allan Odgaard
cb1c51692c Bind Go to Tab → Last Tab to ⌘9 instead of ⌘0
Also avoid binding to ⌘0 in all other ⌘1-n contexts.

This frees up ⌘0 to “Reset Font Size”.
2015-10-16 19:52:47 +07:00
Michael Sheets
b06f20ca72 Add project scope for Cargo (Rust) projects (attr.project.cargo) 2015-10-10 19:30:22 -05:00
Allan Odgaard
10b1f3bfea Always clear SCM info when changing document
For a project window where only some tabs are under version control, switching from one tab with version control info, to one without, would use the info from the previous tab with the new one (proxy icon badge and scope attributes).
2015-09-10 14:24:28 +02:00
Allan Odgaard
8fe7681ebd Remove unnecessary include of oak/compat.h 2015-08-05 12:31:20 +02:00
Allan Odgaard
b3ec7b4c05 Setup key view loop manually for main window
The auto-calculated key view loop includes everything, which means dynamically added elements such as the close buttons for tab view items, but worse, the subviews of a view-based table view. So this change is required before switching to a view-based file browser.
2015-07-20 11:40:59 +02:00
Allan Odgaard
af82d6e540 Update OakTabBarView to use NSDraggingSession API (10.7)
Previously used API has been deprecated.
2015-06-15 16:47:01 +02:00
Allan Odgaard
30be46a166 Support discontinuous selections in command input API 2015-03-08 14:21:59 +07:00
Allan Odgaard
0e309b1056 Add “never hide left border” tab bar view property
We set this when the file browser is on the left of the tab bar view.
2015-03-05 16:38:10 +07:00
Allan Odgaard
b80b526c70 Use actual type for OakTabBarView instead of NSView 2015-03-05 16:38:10 +07:00
Ronald Wampler
438f110dc9 fixup! Use _externalScopeAttributes as a fallback to export TM_SCM_NAME
Added a const reference to avoid the unnecessary copies when using `auto` in range-based for loops. One can find other instances in the code base where we could probably avoid making copies in similar situations, but I did not want to create the patch noise. The intention here is just to correct the obvious mistake and avoid repeating it in the future.
2015-03-05 15:34:16 +07:00
Allan Odgaard
5acabfff6b Ensure document’s metadata is up-to-date before saving it
This was a problem for the saveOnBlur which takes a shortcut to saving, and previously wouldn’t save updated metadata.

This was a problem for folded text, as the old state of folded code was saved.
2015-01-29 14:40:28 +07:00
Allan Odgaard
619125600e Replace call to cascadeTopLeftFromPoint: with custom code
The problem is that cascadeTopLeftFromPoint: will change the window frame if the window frame is outside the visible screen rect.

It would appear that the way this API is supposed to be used is that new windows should be opened using the same frame as an existing, then cascadeTopLeftFromPoint: should be called on the new window, and the result should be passed to setFrameTopLeftPoint:.

Doing it like this would complicate our code because we currently want the window frame before opening the new window, and when finding the window frame, we check whether or not we should cascade to an existing window, so we would have to pass state around with the proposed new window frame (to indicate whether or not the window should be cascaded after opening it).
2014-12-25 12:47:20 +01:00
Ronald Wampler
068ee34af8 Use _externalScopeAttributes as a fallback to export TM_SCM_NAME
We set the attribute scopes `attr.scm.*` in two different places in DocumentController; however, we only export TM_SCM_NAME if the scm variables are present. So if `scmStatus` is not enabled, TM_SCM_NAME is never set or exported, but `attr.scm.*` can still be present.
2014-12-17 15:42:25 -05:00
Ronald Wampler
26523883f3 Do not export TM_SCM_BRANCH
We original exported this for the commit window, which no longer uses it.
2014-12-17 15:42:25 -05:00
Allan Odgaard
1433432d6b Use NSApp’s activateIgnoringOtherApps: instead of SetFrontProcess
It used to be that using activateIgnoringOtherApps: would bring all windows to front, which was the motivation for using SetFrontProcessWithOptions (supplying it with the kSetFrontProcessFrontWindowOnly option), but during testing (on 10.9) it appears that activateIgnoringOtherApps: brings only main/key window to front.
2014-11-30 09:12:06 +07:00
Allan Odgaard
bf4cbd33fa Remove NSString* typecast when using to_s helper
This has a small run-time cost but source looks better and theoretically safer code.
2014-11-29 09:53:40 +07:00
Allan Odgaard
5b39bdc98b Remove double semi-colons at end of line 2014-11-14 10:21:34 +01:00
Allan Odgaard
5d2f5234af Workaround for crash when option-clicking window close button 2014-11-10 09:18:28 +01:00
Allan Odgaard
56ea12db79 Use ‘self.window’ instead of ‘_window’ for consistency
The reason we use the former is so that we can easily change our superclass to NSWindowController, though this will require 10.8 since we create weak references to our DocumentController objects.
2014-11-10 09:18:25 +01:00
Allan Odgaard
7d2ed9a236 Set initial first responder when setting up key view loop 2014-11-06 16:42:22 +01:00
Allan Odgaard
7aea556533 Remove custom NSArray category
We only use the firstObject method which has existed since OS 10.6 (though wasn’t mentioned until the 10.9 FoundationKit release notes).
2014-11-05 10:58:29 +01:00
Allan Odgaard
32d40edfcf Disallow moving window by clicking anywhere in our document view
Previously this would be allowed when clicking a non-opaque view like the OakBackgroundFillView (since 3447b88850).
2014-11-05 00:15:32 +01:00
Allan Odgaard
b581e20ad9 Add wrapper for adding views with auto layout enabled 2014-11-05 00:09:37 +01:00
Allan Odgaard
7ead6d418c Make the OakCreateLabel function more versatile 2014-11-04 22:22:57 +01:00
Allan Odgaard
137e6343ba Add convenience function to setup key view loop 2014-11-04 21:42:09 +01:00
Allan Odgaard
4bde9a99c5 Never re-use a closed HTML output window
Starting with 10.10 re-using a closed HTML output window is prone to crashing, either when opening the window with the WebView, or when later closing it.

The disadvantage of not re-using HTML output windows is only that we lose potential history, for example doing multiple documentation lookups, closing the window in between, would previously allow the user to go back in the history of words that had been looked up.
2014-11-02 12:50:43 +01:00
Allan Odgaard
2c58bb80f9 Introduce ‘disableTabAutoClose’ defaults key
This disables tabs from closing when the tab bar overflows.
2014-10-29 20:47:59 +01:00
Allan Odgaard
f2c54e0e72 Don’t restore untitled document window with no project path 2014-10-29 20:36:19 +01:00
Allan Odgaard
df1a29d7b0 Improve window restoring
Zoom or minimize windows before ordering them front, and for the latter, don’t actually order them front (as that magnifies them). Also order front windows without also setting the window as key window.
2014-10-21 09:28:52 +02:00
Allan Odgaard
e867c27926 Bring project with unsaved documents to front during save warning
If multiple projects have unsaved documents then we show an app modal dialog (not a sheet).
2014-10-20 16:01:07 +02:00
Allan Odgaard
d35ee3b9ab Saved window frame was wrong if file browser didn’t adjust width 2014-10-18 12:37:59 +02:00
Allan Odgaard
796c9856c3 Rework how we handle window frame for document windows 2014-10-16 23:05:58 +02:00
Ryan Goulden
5494f7c802 Close (empty) document when open is canceled
Implements a TODO. A close-tab is now sent to clean up documents
that failed to open properly, and a close-window is further sent
if appropriate.
2014-10-12 11:46:19 +02:00
Allan Odgaard
d9341386c7 Provide save panel with current document’s encoding settings
This is instead of the encoding settings for the initially proposed save path.
2014-10-06 20:42:42 +02:00