164 Commits

Author SHA1 Message Date
Allan Odgaard
346b52b108 Remove image, modified, and SCMStatus properties from FileItem 2021-10-12 21:43:20 +02:00
Allan Odgaard
ef89550788 Bind file browser’s location icon to the image of a TMFileReference
This is the last place using FileItem’s image property.
2021-10-12 21:43:20 +02:00
Allan Odgaard
fb8da4622e Remove open/isOpen property from FileItem 2021-05-17 21:19:18 +02:00
Allan Odgaard
fd9d4f07ed Remove openURLs and modifiedURLs properties from file browser 2021-05-17 21:19:18 +02:00
Allan Odgaard
5867cf2c8e Use TMFileReference for icon and close button in file browser table view 2021-05-17 21:19:18 +02:00
Allan Odgaard
5b0437da08 Tweak implementation of FileItem’s localizedName
We now log an error if we are unable to obtain the NSURLLocalizedNameKey property, but still cache the (fallback) name (so that we do not repeatedly try to obtain the missing property).
2021-05-17 21:19:18 +02:00
Allan Odgaard
a5c6fe985f Ensure low content hugging priority for text field used in table view
When the NSTextField is not editable then it will (by default) hug its content, which is undesired, since the potential views following the text field (tags and close button) should appear right-aligned.

In general though, we do not have controls after the text field when it is read-only, as it represents a missing file, so this is just for layout consistency.
2021-05-17 21:19:18 +02:00
Allan Odgaard
f609a46e3a Use TMFileReference for a few icons in file browser
Specifically the folder pop-up menu and the zooming icon animation.

The former is so that we can ensure that the icon has a size of 16×16.
2021-05-17 21:19:18 +02:00
Allan Odgaard
2e8becc54a Let file browser’s SCMManager update status of TMFileReference objects
Ideally the SCMManager should be moved out of the file browser framework, but I am not yet sure where the best place is.
2021-05-17 21:19:18 +02:00
Allan Odgaard
3de3642842 Make sure we set image size to 16×16 when using with NSMenuItem 2021-05-17 21:19:18 +02:00
Allan Odgaard
866ae0f770 Add TMFileReference framework
The motivation is to have a universal type for a file that knows whether or not the file is open/modified, if it has SCM status, what icon to use for the file, and supporting bindings for the latter (incase icon is updated).

This does sound like a “document” but there are many places where we just want to show a file icon (with SCM and “modified” status) without instantiating a full document, for example folder pop-up menus.

We would also like a way to “close” the file, incase it is open, for example from file browser or “open quickly”, which is not really a document action per se, furthermore, we may delete the file from the file browser, which again, is more of a file than document action, but if the file is “open” somewhere, it should be notified about the delete operation.
2021-05-17 21:19:18 +02:00
Allan Odgaard
6d4b0ecc96 Default value for file browser’s “keep folders on top” now match Finder 2021-04-16 20:36:14 +02:00
Allan Odgaard
c7dd98ec01 Disable floating group rows in file browser + search results (macOS 11)
There appears to be a problem with floating views (in tables) on Big Sur, so this is an attempt of a temporary workaround. The visual look of group rows is currently not very good (on macOS 11).
2021-04-16 08:59:44 +02:00
Allan Odgaard
a8601fd9f7 Use NSTableViewStylePlain for file browser and search results
I am a little torn about this, as this is basically “revert Big Sur’s UI changes”, but I don’t think the new default look is appropriate for these lists.
2021-04-16 08:53:36 +02:00
Allan Odgaard
88ca589cbc Increase padding for file browser’s top folder pop-up
The spacing was so that the icon (in the folder pop-up) was aligned with the file item icons in the list below, but this no longer holds on Big Sur, and the spacing is too tight on Big Sur.

Like with the status bar pop-ups, I am using the increased spacing for all builds, to keep things simple.
2021-03-29 10:00:56 +02:00
Allan Odgaard
3c611f00c9 Autohide scrollbar in file browser
By default, scrollbars are hidden on macOS when using a trackpad, but for mouse users, or people with scrollbars set to always visible, this is probably preferable (all other scrollviews in TextMate use autohiding scrollbars).
2021-03-25 08:25:44 +01:00
Allan Odgaard
7f9fe4cd90 Change NSCompositingOperationSourceOver to NSCompositingOperationCopy
This is when we know the destination is “empty”, so we might as well pick the simpler copy operation.
2021-03-25 08:20:35 +01:00
Allan Odgaard
dfff5d27e3 The Open With submenu item is a shortcut for opening with default app
This is only when the default application is not TextMate.

Ideally the regular “Open” item would change to “Open With «application»” when the selected items are not text documents, and there is an application to handle them, but the code changes required for this are non-trivial because what the item does, is not decided until the user triggers it, and it may not treat all selected items the same.
2021-03-08 12:25:54 +01:00
Allan Odgaard
4324aaf341 Rework API for the Open With submenu
The API expose a few more implementation details and require the user retains the delegate for the duration of the menu’s lifecycle.

The upside is that we avoid the global singleton and it is now possible to examine and use the information gathered by the Open With menu delegate.
2021-03-08 12:25:54 +01:00
Allan Odgaard
3453bddac6 Ensure ⌘⌫ / [⌥]⌘V are not sent to file browser with focused text view
Due to the high priority menus have in the responder chain, we effectively cannot have context menus with key equivalents, if these menu items have explicit targets.

We need the explicit targets so that the context menu works when the application is not the active application.
2021-03-08 08:23:54 +01:00
Allan Odgaard
4d7eeeb383 Ensure ⌘Z / ⇧⌘Z are not sent to file browser when it does not have focus
Since the context menu is outside the normal view/responder hierarchy, it can receive key events even when file browser is not the active view.
2021-02-25 21:23:50 +01:00
Allan Odgaard
94d3b9b670 Remove old build files 2021-02-15 16:01:50 +01:00
Allan Odgaard
f7d765ba0e Add build files (for new build system) 2021-02-15 16:01:50 +01:00
Allan Odgaard
7e69f5bb2c Fix compiler warnings by initializing struct members in correct order 2021-02-04 09:35:27 +01:00
Allan Odgaard
8e6c60d013 build: Remove Info.plist files from frameworks
These were previously required when we built frameworks as dynamically linked, but the files are now explicitly ignored by our build system.
2021-01-24 10:37:22 +01:00
Allan Odgaard
6b6ff32e99 Avoid compiler warning by typecasting anonymous enum
The warning only appears when the anonymous enum is used in a conditional, hence why we do not need this change for all calls to NSFileTypeForHFSTypeCode.
2021-01-17 14:06:36 +01:00
Allan Odgaard
4e4d8ff352 File browser’s field editor (rename) would stay after pressing return
This problem started after f1a1e1920f (handling key equivalents in performKeyEquivalent: instead of keyDown:).

It does however not appear that it is necessary to manually handle the return key to activate editing, therefore we have removed handling of this key.

Most likely it was required before view-based table views.
2020-06-12 21:34:40 +07:00
Allan Odgaard
a11625421a Add “Create Link to Items” file browser context menu action
This will create symbolic links to the files on the clipboard.

It is equivalent to holding down control (⌃) when dropping files on the file browser.
2020-06-09 16:48:37 +07:00
Allan Odgaard
0f219bae4b Set (visible) key equivalents for file browser context menu
Some of the items require the key equivalent to be set as “inactive” as menu item keys are “global” and thus need to be unique, and can be triggered even when the view containing the context menu is not active.
2020-06-09 16:48:37 +07:00
Allan Odgaard
6e35cb98e1 Only update file browser menu item titles when it is the explicit target
Previously “Paste Next” in the Edit → Paste submenu could have its title updated to “Move Item Here”, which would never be restored back to “Paste Next”, similarly for regular paste.

This commit also drops the wrappers for the cut:, copy:, paste:, and delete: methods, as these wrappers resulted in a bit of redundancy related to menu item validation.
2020-06-09 16:48:37 +07:00
Allan Odgaard
b0228b9aff Remove redundant target setting from file browser context menu
We set target for all items in the menu during post-processing.
2020-06-09 16:48:37 +07:00
Allan Odgaard
f97946244a Let file browser call copyAsPathname: when seeing ⌥⌘C
We cannot do this via a menu item because this key equivalent is already used for Ignore Case in the Edit → Find → Find Options menu.
2020-06-09 16:48:37 +07:00
Allan Odgaard
f1a1e1920f Handle file browser shortcuts in performKeyEquivalent:
This is called before the main menu acts on keys, and thus allows us to catch keys that are otherwise assigned to menu items.

We only do this when the file browser is first responder, so it should be acceptable to have a few menu keys change behavior in that case.
2020-06-09 16:48:37 +07:00
Allan Odgaard
4ec10c0923 Don’t annotate types and classes with PUBLIC
This was required when we linked each framework as its own thing, which we do not do anymore, and if we do go back to this system, we can simply have symbols public by default.
2020-06-05 21:22:50 +07:00
Allan Odgaard
b1e41a7f5f Abort iterating over parent URLs if the path string grows in length
It appears that NSURL’s algorithm for “delete last path component” is to first append ‘../’ and then “normalize” the result, but the latter step can fail for some file URLs, for example with “file://localhost/path/to/https://macromates.com/” it will be stuck at the two slashes (continuing to append ‘../’).

Such malformed (file) URL can be created by running ‘mate https://macromates.com/’.
2020-05-30 10:02:52 +07:00
Allan Odgaard
eaad76f83d Minor tweak of log message 2020-05-30 09:54:30 +07:00
Allan Odgaard
d500f6e53d Remove support for initial first responder in OakSetupKeyViewLoop 2020-05-25 12:47:47 +07:00
Allan Odgaard
b693db4fd1 Use NSDictionary for SCM repository variables (instead of std::map) 2020-05-22 21:48:09 +07:00
Allan Odgaard
ad1cc8abd8 Deliver all NSUserDefaultsDidChangeNotification in main queue
This is easier than ensuring that we do not update user defaults from a background thread.
2020-05-14 09:52:38 +07:00
Allan Odgaard
cb4c12681e Use NSNotificationName as type of all our notification names 2020-05-04 19:20:04 +07:00
Allan Odgaard
f0b48ba736 Fix a few double trailing semi-colons 2020-05-04 19:20:04 +07:00
Allan Odgaard
f8c9ee079f Copy callbacks array before enumerating it (and invoking the callbacks)
This is incase a callback makes changes to the callback array, as that is not supported for fast enumerations.
2020-04-30 14:40:55 +07:00
Allan Odgaard
e4f61f12b7 Change a few leading spaces to tabs 2020-04-30 13:28:24 +07:00
Allan Odgaard
decb7f96ee Set wantsLayer to YES for file browser header view
This is required on macOS 10.12.
2020-04-29 08:02:02 +07:00
Allan Odgaard
f06161b395 Do not set content hugging and compression resistance for image button 2020-04-28 09:52:10 +07:00
Allan Odgaard
6e6dbd4a1e Ensure label colors are aligned between open and non-open files 2020-04-28 09:52:10 +07:00
Allan Odgaard
ce651e8acb Ensure labels are rendered as selected when table row is emphasized 2020-04-28 09:52:10 +07:00
Allan Odgaard
17aada3471 Let FileItemTableCellView give access to its close button via a property
This is simpler than having to proxy the action (and target) for the button.

Previously the button was created on demand, but now that we always create it (and hide it when not required), we might as well have users set action and target directly on the button instance.
2020-04-28 09:52:10 +07:00
Allan Odgaard
05a50a436b Use NSStackView for our file browser items
Minor downside is that labels for open and closed files are no longer aligned.

It would be nice to find a solution for that, but without dropping the stack view, as it saves us > 100 lines of code.
2020-04-28 09:52:10 +07:00
Allan Odgaard
19624f0fd8 Use NSStackView for tag buttons in file browser menu 2020-04-28 09:52:10 +07:00