Commit Graph

5281 Commits

Author SHA1 Message Date
Allan Odgaard
ff22bb58fa Add allowsEmptySelection to ScopeBarViewController
Also change selectedIndex to NSUInteger as it will be NSNotFound when there is no selection.
2020-04-17 19:19:53 +07:00
Allan Odgaard
36489aa076 Rename (internal) API method
This might be closer to Cocoa naming conventions.
2020-04-17 19:19:53 +07:00
Allan Odgaard
342e612505 Add controlSize to OakScopeBarViewController
Ideally this would be a view property, but the view controller only expose the content view, which is an NSView instance that does not support the property by default, so we would have to introduce a subclass for this.
2020-04-17 19:19:53 +07:00
Allan Odgaard
f8203bccfa Use columnWithIdentifier: instead of tableColumnWithIdentifier:
This simplifies the code.
2020-04-17 19:19:53 +07:00
Allan Odgaard
744219d436 Adjust font size of find window’s status bar to match NSControlSizeSmall 2020-04-17 19:19:53 +07:00
Allan Odgaard
2bdce95293 Refactor OakScopeBarView to be a view controller subclass 2020-04-17 19:19:53 +07:00
Andreas
e62bbea182 Miscapitalization of Menu Items
`Jump to Next/Previous Mark` should be capitalized like `Jump to Next/Previous Bookmark`. Prepositions are generally not capitalized in title case.
2020-04-14 13:01:43 +07:00
Allan Odgaard
3a21cbfd85 Move Go To… menu updating and next/previous actions to ScopeBarView 2020-04-14 12:58:11 +07:00
Allan Odgaard
7d67bb7f80 Add preliminary UI for flagging clipboard history items 2020-04-14 12:58:11 +07:00
Allan Odgaard
b06c34eb0f Refactor helper method to only have a single point of return 2020-04-14 12:58:11 +07:00
Allan Odgaard
7e5daad0ad Add “flagged” property to OakPasteboardEntry
Flagged items will not be implicitly deleted when pruning history or removing all items.
2020-04-14 12:58:11 +07:00
Allan Odgaard
d6ce2e3abf Use tertiaryLabelColor for “replacement characters” in strings
This is instead of lightGrayColor which is not sensitive to light/dark mode.
2020-04-14 12:58:11 +07:00
Allan Odgaard
3668245163 Convert to reference URL for file browser’s “Select Current Document”
This fixes problems with symbolic links, for example file browser may show contents of /private/tmp when we ask to select /tmp/foo.txt. Comparing file path URLs will fail even though /tmp is a symbolic link for /private/tmp.

Note that this fix only works for when the current document is already part of the items in the file browser, as we still store pending URLs to select as file path URLs.
2020-04-14 12:58:10 +07:00
Allan Odgaard
3eaaff7f47 Support selecting multiple items in pasteboard history dialogs
This can either be used to more easily delete multiple items, or for inserting/searching for multiple items.
2020-04-14 12:58:10 +07:00
Allan Odgaard
e0db2f5ec1 Make OakPasteboardEntry’s historyId public 2020-04-14 12:58:10 +07:00
Allan Odgaard
babb989288 Add pasteboard method to store multiple items
This is for multi-selecting items in the pasteboard chooser and they are stored as auto-generated items and with their history identifiers, so that we can treat them as multiple items.
2020-04-14 12:58:10 +07:00
Allan Odgaard
7c78e8316c Support copy/paste of discontinuous selections that contain newlines
Previously we stored discontinuous selections as a newline-delimited string, and therefore the individual fragments could not contain any newlines.

Now that we use NSPasteboard’s multi-string support, we no longer have this limitation.
2020-04-14 12:58:10 +07:00
Allan Odgaard
f2efe71aff Store discontinuous selections as multiple strings on clipboard 2020-04-14 12:58:10 +07:00
Allan Odgaard
34eb6967c8 Use sqlite3 for clipboard history instead of CoreData
I was using the clipboard history as a testbed for CoreData but my conclusion is that it was not a good fit, and with the API we used now being deprecated, and the clipboard history needing various improvements, it’s easier just to replace the CoreData backend with sqlite3 and offers us more flexibility going forward.

With this re-implementation there is now support for storing multiple strings on the clipboard and the check to see if other applications changed the clipboard should work better (it appears that if an application is changing the clipboard while TextMate is active, sometimes the NSPasteboard’s changeCount is not updated).

It now also stores the history item’s row ID on the pasteboard, so if we select the non-latest history item and relaunch TextMate, it will no longer treat the current item on the pasteboard as a new item.
2020-04-14 12:58:10 +07:00
Allan Odgaard
d63f12993f Use class properties for general, find, and replace pasteboard instances 2020-04-14 12:58:10 +07:00
Allan Odgaard
c682655d4a Use readObjectsForClasses: with NSURL instead of NSFilenamesPboardType 2020-04-14 12:58:10 +07:00
Allan Odgaard
e1fdc852e4 Make sure URLs placed on the undo stack are file path URLs
Incase of a file reference URL, moving an item will have the URL resolve to the new file path, therefore such URL cannot be used for storing the old location/path of the item.

This is currently not a problem with TextMate, as all URLs are file path URLs, but as we are moving to using readObjectsForClasses: with NSURL, we will be receiving file reference URLs from Finder.
2020-04-14 12:58:10 +07:00
Allan Odgaard
969c541202 Fix copying files from file browser and pasting in Terminal.app
Terminal.app is peculiar about what it expects to be on the clipboard. If we only write URLs like this:

	[pboard clearContents];
	[pboard writeObjects:urls];

Then it will not paste anything. There *must* be string fallbacks for it to support paste. But if we also write an array of strings like this:

	[pboard clearContents];
	[pboard writeObjects:urls];
	[pboard writeObjects:[urls valueForKeyPath:@"path.lastPathComponent"]];

Then it will paste both the URLs and the strings, but where the URLs will be space-separated, the strings will not. If instead we write a single string fallback only for the first item, like this:

	[pboard clearContents];
	[pboard writeObjects:urls];
	[pboard setString:@"whatever" forType:NSPasteboardTypeString];

Then it will paste the URLs and ignore the string fallback for the first URL.
2020-04-14 12:58:10 +07:00
Allan Odgaard
fec16ec203 Don’t use virtual member functions for clipboard_t::entry_t
There are no subclasses of this type, so no need to make them virtual, and going forward, we will be refactoring how this API works and subclassing will not be supported.
2020-04-14 12:58:10 +07:00
Allan Odgaard
93033c0f47 Add clipboard_t::entry_t constructor taking multiple strings and options
Currently this just moves constructing the options and LF-separating the strings into the clipboard_t::entry_t, but going forward, we will be able to utilize NSPasteboard’s native support for multiple strings (and avoid storing the “fragments” count).
2020-04-14 12:58:10 +07:00
Allan Odgaard
a6258bb625 Snippet pop-up menu would scroll horizontally opposite of the document 2020-04-14 12:58:10 +07:00
Allan Odgaard
31bd361131 Don’t use CommonAncestor to find parent of single file browser item
When CommonAncestor is called with only a single directory then it returns that directory, which meant that searching a selected folder and selecting File Browser → Enclosing Folder would not go up a level (only on second use of this action, would it ascend to the parent folder).

As the CommonAncestor function is used in several places, I didn’t want to change its behavior, but it appears that there are multiple checks in the code to see if “file browser items” only contain a single item, and we just added a new one, so grounds for refactoring.
2020-04-14 12:58:10 +07:00
Allan Odgaard
2e1ed018d4 Query array controller directly for count of objects
The reason we were doing a fetch was because it may provide better performance, furthermore, the count returned by the array controller is count of filtered objects, so this change is a slight regression, should be addressed later.
2020-04-14 12:58:10 +07:00
Allan Odgaard
29f43d2385 Let OakPasteboard create NSArrayController used by clipboard history
Again to hide that we are backed by CoreData storage.
2020-04-14 12:58:10 +07:00
Allan Odgaard
de9c7811de Use filter predicate instead of fetch predicate for clipboard history
This is in anticipation of dropping the CoreData backend.
2020-04-14 12:58:10 +07:00
Allan Odgaard
883a45568f Fix clipboard history predicate string used for filtering 2020-04-14 12:58:10 +07:00
Allan Odgaard
623267ba98 Add API to remove all entries from OakPasteboard
This is one of several steps toward making CoreData an implementation details of OakPasteboard (which it is currently not).
2020-04-14 12:58:10 +07:00
Allan Odgaard
d0c43840c6 Remove code that was migrating settings from beta release of TextMate 2020-04-14 12:58:10 +07:00
Allan Odgaard
5166b6bfed Introduce constants for clipboard option names 2020-04-14 12:58:10 +07:00
Allan Odgaard
47d0345d5a Omit “default” options argument for clipboard_t::entry_t constructor 2020-04-14 12:58:10 +07:00
Allan Odgaard
a3aa7f3225 Make ‘options’ argument of clipboard_t::entry_t constructor be optional 2020-04-14 12:58:10 +07:00
Allan Odgaard
38305e7fc4 Fix code that should return NO when bundle install is in progress 2020-04-14 12:58:10 +07:00
Allan Odgaard
4a1e9113f3 Make file browser state API wrap the system UI restoration methods
This avoids duplicating code, although for compatibility with old saved state, we still can restore state from a dictionary.
2020-04-14 12:58:10 +07:00
Allan Odgaard
61ec959b37 Change data type of file browser state from dictionary to opaque object
This gives us more flexibility in how we wish to represent the state, although the state should be a property list object.
2020-04-14 12:58:10 +07:00
Allan Odgaard
65a379ce71 Let Open With menu delegate respond to menuHasKeyEquivalent:forEvent:…
By implementing this, we avoid potentially updating the menu when pressing “menu keys”, which can be slow due to collecting information about system applications, such as supported file types, icon, and display name.

This would happen when opening the menu via the file browser’s action menu, and then using arrow keys in the text view. On my setup, moving the insertion point was slowed down noticeably.
2020-04-14 12:58:10 +07:00
Allan Odgaard
1e065153d6 Remove legacy API for observing changes to a single file
New code should use KEventManager instead of document::watch_server_t.
2020-04-14 12:58:10 +07:00
Allan Odgaard
386c1f53db Use KEventManager to observe the file backed by OakDocument
This should handle more edge-cases than the previous API, specifically renaming ancestors or moving files to trash (now treated as a delete).
2020-04-14 12:58:10 +07:00
Allan Odgaard
ac903a1fa8 Add API to observe changes to a single file
While in theory just a wrapper for VNODE events, there are some edge cases:

- Observe missing file: Report when created (observe all ancestors to know).
- Rename ancestor: Treat as rename (observe all ancestors to know).
- Move observed file to trash: Treat as delete (reported as rename).
- Rename file with symbolic link in path (e.g. /tmp): Preserve symbolic path.
- Delete observed file and write new one: Treat as a write (reported as delete).
- Rename observed file and write new one: Treat as a write (reported as rename).
- Change case of file: Tricky on case-insensitive but preserving file systems because newPath != oldPath but both exist, so it looks the same as “rename and write new file” (previous case) that should be reported as write.

There is also an issue observing a symbolic link, here we should really observe both the link itself (does it get renamed or deleted) but also the resolved path (does this file get updated).

Currently though this is NOT implemented.
2020-04-14 12:58:10 +07:00
Allan Odgaard
4013020b14 Use dot syntax for NSNumber’s boolValue property 2020-04-14 12:58:10 +07:00
Allan Odgaard
4f43bf497c Use the ‘console’ pool to run executables
This avoids output buffering so is necessary for executables that produce output without immediately terminating.
2020-04-14 12:58:10 +07:00
Allan Odgaard
9782343576 Make completion and quick open work out of the box for TextMate headers
Since we no longer have a shared directory for all the framework headers, we need to either explicitly list each header directory in the compiler flags (or TM_SYS_HEADER_PATH) for header completion and quick open to work, or we need to create a dummy directory with symbolic links.

Previously I was using the previous method, but include folder has to be created when building on a new system, and it doesn’t avoid having to update the symbolic links if we add/remove frameworks to the project, so listing them all in the .tm_properties, while not ideal, is a better solution.
2020-04-14 12:58:10 +07:00
Allan Odgaard
be29a7711a Export the SCMManager from FileBrowser framework
This should probably be its own framework, but nothing beyond the file browser is currently using the SCMManager.
2020-04-14 12:58:10 +07:00
Allan Odgaard
c7548d0bb4 Ensure we have a default include glob for file chooser
We setup a default in default.tmProperties but incase file chooser code is used outside of TextMate then no such default is found, and the file chooser defaults to excluding everything.
2020-04-14 12:58:10 +07:00
Allan Odgaard
e083ed4ce1 Add OakTabBarViewController to simplify using OakTabBarView
This is a subclass of NSTitlebarAccessoryViewController so it can be added directly to windows as an accessory view controller.

It is key/value bindings-compliant for its properties, which should be bound directly to an NSArrayController, which will make the tab bar view reflect the objects managed by this array controller, including updating the tab bar view when object properties such as title or modified state changes.
2020-04-14 12:58:10 +07:00
Allan Odgaard
43934ab9ed Do not export non-existing OakTabBarStyle.h header 2020-04-14 12:58:10 +07:00