We now collapse if more than half the items are expanded, otherwise expand. Previously we relied on a property to track the collapsed/expanded state, which could be out of sync if the user manually changed the state for half the items, and we also needed to reset the state variables when updating search results.
Previously these were created on demand, but that meant loading the document in the UI thread. It also meant that multiple matches from same document would cause the document to be read for multiple times.
Furthermore, storing the match excerpt with the find::match_t type should allow for more flexibility, since we no longer need special logic in the table view delegate to load a subset of a document to get the display string, but will simply read it from the record.
10.10 SDK makes NSLineBreakMode into a proper NS_ENUM enum (in 10.9 SDK it was
a plain typedef for NSUInteger with some integer NSLineBreak* values
conveniently available for it in an anonymous enum).
Nevertheless, attr_string code should have always used NSLineBreakMode instead
of NSUInteger (unless I am missing something like values in style::line_break::mode
that do not correspond to the enum), so this commit makes it so and
thus also fixes building with 10.10 SDK.
This change was prompted by the appearance of the `tabSizePopUp` button in the status bar. After dismissing the menu, the title would be disabled.
To ensure we do not have similar issues elsewhere, let's prefer the use of `NULL` to `nop:` when assigning the action for menu items unless we are sure that the menu item should always be disabled (e.g., the item is used as a label).
This seems to have been overlooked since most of logic was already implemented.
There is one known issue that exists when restoring sessions. Namely, after restoring a session only those documents (tabs), which have been actively "viewed" are considered "opened".
Previously it was only available when doing folder searches, since the items are for folder search behavior and results.
However, with “Find All” in document, we get a similar result list from which we may want to copy matches.
When saving and the document needs to execute a command (e.g. callback.document.export) then we can no longer use our special run-loop mode, as command execution is now using queues, and queue dispatching is paused when running in a custom run-loop mode.
We don’t have a specific element associated with the result being announced so we use the current responder (unless it has accessibility ignored, in which case we do not post any notification).
Using the current responder is not ideal, but I do not know how we can either associate the notification with the find panel or post it as a global notification.
The standard doesn’t care which side the keyword is placed on, but placing it on the right makes it easier to read types.
E.g. reading “int const* const” from right to left we get “const pointer to const integer”.
While code reuse is an added benefit, the main motivation was to fix the appearance of the action popup button in the Find window. The first (placeholder) item in the Find window's action button was assigned a nop action so that when the button was clicked and it's menu validated, the "action" image would always appear as disabled.
Since we are using it with an NSDocument, it defaults to use NSDocumentController as restoration class, which gives a warning during launch, if the find window was open during termination, and the conditions are so that the system wants to restore windows from last session.
Also indicate that we do not want to save drafts, unsure if this has any effect.
This is because we are using an NSDocument to perform the folder searching (as that’s a decoupled way to have the window indicate “unsaved changes” and present a warning sheet).
The downside is that by using an NSDocument we get some undesired implicit behavior, like automatically changing the window title or trying to re-open the “document” after relaunch.
We shouldn’t use Apple’s prefix for our own constants. The actual value of the constant hasn’t been renamed yet as this requires “migration” (renaming the key in user defaults).
We already commit the values when focus is lost, but it’s possible to initiate a find operation while focus is still in the find dialog text fields (via the menu).
Fixes#1183
For this change I have made the FFDocumentSearch class inherit from NSDocument. This way, we can register it with the window controller and will get callbacks when the window is about to close, with the option to cancel closing of the window. This approach seems much simpler than the alternative, which would be to introduce our own callback/delegate system for window closing, or have the window controller know about saving files.
We now show “Stopped.” as status text when search is prematurely terminated.
Closing window also cause search to stop.
The stop button has ⌘. as key equivalent (the standard “cancel” key).
Don’t let the stop action go via the search action dispatcher.
If the user does a folder search then ⌘G will step through all the matches, opening documents as required. Previously the user would have to do a new search, using a different search string, to stop ⌘G from moving to a new document. It is now possible to stop the behavior using ⌘F followed by ↩.
This is the action method sent by the Edit → Find → Find All (⌥⌘F) menu item, and is now treated as an alias to the existing findAll: action method (that the Find All button in the find dialog sends).
Untitled documents have no path, so we were creating a dictionary with a nil object. The path isn’t actually used (we go via the identifier) so removing the potential path from the dictionary avoids the problem.