Commit Graph

82 Commits

Author SHA1 Message Date
Allan Odgaard
98585e166e Use byte range for replacement API 2013-07-27 16:30:02 +02:00
Allan Odgaard
707e026c19 Update testing system for Find framework 2013-07-26 13:53:58 +02:00
Allan Odgaard
06f349507a Add a “did wrap” boolean to the OakFindProtocol API
This informs the “server” that searching wrapped around to find the match.
2013-07-23 22:45:52 +02:00
Allan Odgaard
5fc03a8630 Don’t ignore save errors for multi-file search/replace
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.
2013-07-22 03:00:13 +02:00
Allan Odgaard
97caace4d2 Some further tweaks related to stopping search
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.
2013-07-21 22:54:12 +02:00
David Howden
cfb2335761 Added “Stop Search” button to Find dialog
Previously wasn't possible to stop a search in progress (even
when closing the Find window).
2013-07-21 17:36:16 +02:00
Allan Odgaard
fd6e47b023 Let a document search clear the folder results used by ⌘G
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 ↩.
2013-06-28 21:50:07 +02:00
Allan Odgaard
b8b00b5fe8 Make OakCreateCheckBox a public function 2013-06-27 23:26:46 +02:00
Allan Odgaard
0c26060f1c Find dialog now responds to findAllInSelection:
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).
2013-06-23 11:23:42 +07:00
Allan Odgaard
c04eb1cd2a Fix exception when finding all in untitled documents
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.
2013-06-16 17:44:34 +07:00
Jakub Suder
ac9f5e5d8d Don't add files from find window to recent list 2013-06-15 16:13:22 +07:00
Allan Odgaard
0795b89bdb Clicking already selected search result reselects the match
Previously we ignored clicks and only selected matches when the selection was changed. This was done to prevent firing off two “select match” actions. We now ignore the “selection changed” notification if the current event is a mouse-up.
2013-05-15 15:45:36 +07:00
Allan Odgaard
4188c486fb Ensure height of find/replace fields are >= 22 points
Fixes #972.
2013-05-06 14:51:31 +07:00
Allan Odgaard
e1ff0ceaff Move already open find/HTML windows to active space
This is only when invoking the “order front” action and the window is already showing on another space.
2013-04-28 11:46:35 +07:00
Allan Odgaard
fda19c565d Only clear find status string for non-folder search
I find myself often closing folder search results and later re-opening (via ⇧⌘F) which would previously have the status string cleared, yet the results still showing.

Status should probably be stored together with the folder search results, so when toggling between document and folder search, the status string would follow as well.
2013-04-28 11:46:35 +07:00
Allan Odgaard
97c9a20f6e Use localizedStandardCompare:
This is instead of our custom displayNameCompare: which has now been removed.
2013-04-21 12:20:07 +07:00
Allan Odgaard
49235210ca Use NSNumberFormatter class method
Once we drop 10.7 support we can avoid NSNumberFormatter entirely by using ‘localizedStringWithFormat:’ with ‘%lu’.
2013-04-21 12:20:07 +07:00
Allan Odgaard
15a5527986 Reset find dialog state when re-opening it
Previously doing a Find All in Document would stay with Find All as the default button, even if closed and re-opened.

We also clear the status text, this isn’t always desirable, but I find it more weird when the dialog shows an outdated status message.
2013-03-26 14:02:40 +01:00
Allan Odgaard
40a9cb4e40 Limit height of Find dialog text fields
These would previously always be the height of the content, now they are limited to roughly 13 lines (225 “pixels”).
2013-03-26 13:51:41 +01:00
Michael Sheets
17e67642b8 Re-align Find/Replace labels due the larger font size 2013-03-22 12:31:36 +01:00
Michael Sheets
1af89c97a1 Use OakCreateSmallLabel for the status text
This treats the label as a small size control.
2013-03-22 12:31:36 +01:00
Allan Odgaard
45dc49eb29 Retire compiler workaround
Previously we could get a compiler error when using std::map<std::string, std::string>() as a default argument.
2013-03-16 17:49:49 +01:00
Allan Odgaard
d8cf1e3591 Gather UI construction code and harmonize fonts 2013-03-13 12:38:11 +01:00
Allan Odgaard
9f8b7bf27c Improve layout constraints for labels
The widest should now be exactly 20 pixels from the window’s left border, and the others are right-aligned with this label.
2013-03-13 12:37:23 +01:00
Allan Odgaard
b5136bcdc7 Set window’s defaultButtonCell
This is instead of setting the key equivalent to ‘\r’ for the button that should be default.
2013-03-13 12:37:22 +01:00
Allan Odgaard
c44e85f258 Avoid delayed window resize 2013-03-13 12:37:22 +01:00
Allan Odgaard
7acf168904 Keep title and enabled state of Replace All button updated 2013-03-13 12:37:22 +01:00
Allan Odgaard
f553f20cc7 Change criterion for focusing find string when dialog is open
We now move focus to the find string unless the window is visible, key, and focus is already in a text field (technically an NSTextView).
2013-03-13 12:37:22 +01:00
Allan Odgaard
db5df4a58c Update Find window API 2013-03-13 12:37:22 +01:00
Allan Odgaard
df512d98fa Remember height of find in folder results 2013-03-12 10:25:04 +01:00
Allan Odgaard
59fb3bc1a9 The ⌘1-n keys wouldn’t always work in find dialog 2013-03-10 14:34:44 +01:00
Allan Odgaard
ee2c2b33fb Fix potential deadlock when opening find window
The Find object is assigned to a variable with (guarded) static storage, so the initializer of the Find object will run with a lock on the guarded variable, which turns out to be shared with all other guarded variables.

When setting up the window controller, from the Find object’s initializer, we create a “recent folders” menu which hold icons with SCM badges.

When creating these SCM icons, blocks are scheduled (asynchronously) to “fetch status”. These asynchronous blocks will need to lock the same mutex as we currently have locked (because we haven’t yet left the initializer).

The issue is that we also schedule synchronous blocks on the same queue, and that’s why we get a deadlock, because those can’t run before the asynchronous blocks have finished, yet those are waiting on the global lock that our main thread has currently obtained.

Fixes #874.
2013-03-07 22:03:50 +01:00
Allan Odgaard
14cfedb287 Implement Replace [and Find] bound to ⌥⌘G
Currently this is implemented in OakTextView which means that it doesn’t work for macros. Some refactoring is in order so that the implementation can be shared (lack of sharing has to do with how OakTextView reports status to Find dialog or via tool tips, and macros want none of that).

There is also no check to see if the current state of the editor is the result of a find operation, i.e. you can invoke “replace” regardless of wether or not “find” was the last action.

Finally, doing a multi-file search and using “find next” at the end of one document, which brings you to the first match of next document (part of the results), will not update “captures” from a potential regular expression search, meaning that if you then do “replace”, and your replacement string is a format string that references the match (via $1-n) then it will not be correctly expanded.

Closes #104.
2013-03-07 16:21:57 +01:00
Allan Odgaard
02f32977f2 Introduce Replace [and Find] in find protocol
Previously there was a single replace action and the options would indicate if it was a “replace all”, this mimics the “find” (which can be a “find all”) but since single match replacement is somewhat different than a “replace all”, as the former may need to know the captures from a previous find action, it makes sense to factor out these things as different actions.
2013-03-07 16:21:47 +01:00
Allan Odgaard
599d903eb4 ARC: Update Find framework 2013-03-07 10:50:41 +01:00
Allan Odgaard
4a24d0ad58 Rework find dialog (part one)
This is work in progress but I don’t think any functionality is missing compared to previous commit, although some functionality might be less polished, e.g. the action buttons don’t properly enable/disable and the height of the results list gets lost when hiding it.

Some of the stuff that has changed / improved:

 * The find/replace text fields adjust their height to encompass the content (closes #94). Presently though the initial height of the ontrols is one line regardless of content (but they should adjust on first edit).
 * You can use Save All (⌥⌘S) to save affected files after Replace All (closes #558).
 * The key equivalents / actions available in the Find dialog is now easier to find via the action pop-up, which also has enables accessibility.
 * Using Next (⌘G) or Previous (⇧⌘G) with search results will move selection up/down.
 * Using Find All with ‘in’ set to ‘Selection’ will find and select all matches in the current document, which fixes #425, though it might be more desirable to show the results in the find dialog (like Find All does for a document or folder).
2013-03-07 10:50:19 +01:00
Allan Odgaard
699d0676b3 Add to undo stack when replacing after folder search
Fixes #536.
2013-03-03 23:19:34 +01:00
Allan Odgaard
6d6c3e4de6 Use path::is_absolute instead of custom code 2013-02-25 15:25:17 +01:00
Allan Odgaard
e62ef9cf6d Re-use file icon image
These are expensive to create and it was noticeable when lots of files matched and the menu had to be created (as it would when the user press a potential menu key like ⌘W).
2013-02-18 15:38:25 +01:00
Allan Odgaard
e75e7ec8e5 Change text::format → std::to_string (C++11) 2013-02-08 11:20:34 +01:00
Allan Odgaard
8265a469d8 Improve locating Find framework resources
The FFWindowController class is an implementation detail where the Find class is the public class, so depending on the latter should make the code safe against potential rewrites.
2013-02-04 19:38:31 +01:00
Allan Odgaard
f57b06fa2c Move instance variables to implementation 2013-02-04 19:38:00 +01:00
Allan Odgaard
645f8d91e1 Let OS handle keys for Go to Tab submenu
My memory is a little vague here, but I believe the point of handling the menu keys was to workaround a bug in NSMenu.

The bug was that NSMenu would look at (the target of) cached menu items, probably for UI validation, so potentially sending methods to unretained objects, which could lead to a crash. Several workarounds were attempted (like clearing the target property after the menu had been displayed) but the only effective one was overloading key handling.

I’m quite sure though that this bug is no longer relevant.
2013-01-22 11:00:27 +01:00
Allan Odgaard
54f1343ca2 Folder search now reads all relevant exclude patterns
Previously it wouldn’t read kSettingsExcludeDirectoriesKey and kSettingsExcludeFilesKey.
2013-01-13 11:56:06 +01:00
Allan Odgaard
bccaee4be6 Simplify document open API
Removed the ability to specify wether documents should open in current window or a new window — all documents opened via this API will go through the same algorithm to find where the documents should end up (more choice is just adding confusion and complexity).
2013-01-10 06:46:44 +01:00
Allan Odgaard
d96dbc4269 Clicking a ‘find all’ result would be handled twice
Normally this wouldn’t be noticed, as the second action would do the same as the first (go to the result in the associated project window), but when there was no project window a new window opens (to show the result), and that would be done twice.

This fixes issue #281.

There is still an issue with successive selections for the “no project window” situation, as each time, a new window is opened, rather than reuse the first one that opened.
2013-01-08 22:48:07 +01:00
Allan Odgaard
9c35f445de Convert strings files to UTF-8 2013-01-02 01:46:48 +01:00
Allan Odgaard
47fa0f040c Use Objective-C literals for YES/NO 2013-01-02 01:46:48 +01:00
Allan Odgaard
c273b3d4fe Set Find and Go to Line dialogs to “join active space”
If user opens the dialog on one space, moves to another space (with a TextMate window) and then re-activate the (already open) dialog, it would previously switch back to the space containing the dialog, whereas with the changed setting, it now moves the dialog to the active space.

This should address issue #599.
2012-12-30 04:35:47 +01:00
Allan Odgaard
71be61cbbb Enable ARC by default
We now explicitly disable it for targets that hasn’t yet been upgraded to ARC. This way, it’s easier to get an overview of which targets hasn’t yet been upgraded and ensures new targets has ARC enabled.
2012-12-19 19:42:36 +01:00