Commit Graph

321 Commits

Author SHA1 Message Date
Allan Odgaard
dc5028f039 Let text view and find window show documents using OakDocumentController 2016-09-24 08:33:33 +02:00
Allan Odgaard
631ced7b3c Introduce keepSearchResultsOnDoubleClick user defaults key
This prevents the find dialog from closing when double-clicking search results.
2016-09-22 09:22:56 +02:00
Allan Odgaard
1f6b87d4ea Double-clicking inactive search results would not trigger select action 2016-09-22 09:22:56 +02:00
Allan Odgaard
7713496749 Searching “other” folder would still use project folder 2016-09-21 22:20:39 +02:00
Allan Odgaard
017f4a3ba1 Check if path is a folder before calling path::entries()
This is just to suppress a warning from path::entries().
2016-09-21 20:39:42 +02:00
Allan Odgaard
2f5b8559fb Only add folders to find dialog’s Recent Places
Now that documents selected in the file browser can be searched, we can end up with a document path in the ‘otherFolder’ property.

This would happen by selecting a document in the file browser, opening the find dialog, and then selecting this document in the pop-up, as it is listed in the pop-up with a menu item tag of “FFSearchTargetOther”.
2016-09-21 20:39:42 +02:00
Allan Odgaard
2ffbfe02a5 Remove find::kSearchOpenFiles constant 2016-09-20 20:04:33 +02:00
Allan Odgaard
1087a68f44 Add “File Browser Items” as find dialog search target 2016-09-20 20:04:19 +02:00
Allan Odgaard
4dc3de163e Guard against infinite loop 2016-09-20 20:03:32 +02:00
Allan Odgaard
9d97662b89 Let FFDocumentSearch accept an array of paths 2016-09-20 20:02:08 +02:00
Allan Odgaard
315735a13a Add helper function for common ancestor 2016-09-20 19:55:16 +02:00
Allan Odgaard
c04430ebe4 FFDocumentSearch no longer search current document or open files 2016-09-20 18:20:36 +02:00
Allan Odgaard
d7f4b5bfb6 Use ‘enabled2’ in binding since we already bind to ‘enabled’
Before the Replace & Find button was enabled for folder searches.
2016-09-20 18:19:20 +02:00
Allan Odgaard
dbee4704cc Clear the countOfMatches properties after unbinding
The Replace All button’s enabled state is based on count of matches (via bindings), so unbinding would leave it possibly enabled when it should have been disabled.
2016-09-20 18:17:37 +02:00
Allan Odgaard
2e61de9f7d Do not show missing items under Recent Places in folder search 2016-09-20 18:17:06 +02:00
Allan Odgaard
e20bb55d18 Use home folder as fallback in FFFolderMenu
This is to avoid an exception when the code is used with menu items that have no represented object (which it normally wouldn’t in shipping code, but it seems it should be supported nonetheless).
2016-09-20 18:16:41 +02:00
Allan Odgaard
330695a775 Import Find.h instead of redeclaring some of its symbols 2016-09-20 18:14:07 +02:00
Allan Odgaard
e3874bcecb Only set menu item image when required
The system can be updating the menu only to resolve a key equivalent, hence the image is not required. The document icon can be a little expensive to create because of the SCM badge. This would be noticeable when doing a folder search with hundres or thousands of results and then pressing ⌘1, here it would previously need to create all the document icons before responding to the key.
2016-09-20 18:12:13 +02:00
Allan Odgaard
7cc017f343 Harmonize all implementations of sharedInstance 2016-09-19 12:54:19 +02:00
Allan Odgaard
297cfa1726 Remove unused OakFileIconImage.h includes 2016-09-19 12:49:03 +02:00
Allan Odgaard
5f53075864 Disable recent tracking for non-open documents instead of non-loaded 2016-09-18 10:33:45 +02:00
Allan Odgaard
d66b2b982d Search open files using OakDocument’s isOpen property 2016-09-18 10:33:20 +02:00
Allan Odgaard
ddefdec649 Change document’s isOpen property to isLoaded
Since we do not load documents before the user selects them, e.g. after session restore or when opening multiple documents, it makes sense to have both an isOpen and isLoaded property, the former means “is shown somewhere in the UI” and would make it appear (e.g. in file browser) with close button etc., whereas the latter means that data has been loaded from disk, and we can safely access the buffer.
2016-09-18 10:29:21 +02:00
Allan Odgaard
cd58781f19 Increase find results update interval from 0.03 to 0.20 seconds
It looks better when we have a “full page” of results on the first update, rather than building up the first page of results file-by-file with only 0.03 seconds between each “increment”.
2016-09-18 10:29:20 +02:00
Allan Odgaard
9aafadbe25 Fix retain cycles responsible for leaked NSTableCellView objects 2016-09-18 10:26:00 +02:00
Allan Odgaard
4b000cc633 Rename scannerProbeTimer variable to folder search code
This is so that the code mimics FileChooser.mm
2016-09-18 10:25:53 +02:00
Allan Odgaard
83113e4765 Use NSUUID for documentIdentifier properties 2016-09-18 07:32:05 +02:00
Allan Odgaard
4307501170 Let type of kSearchMarkIdentifier be NSString 2016-09-16 15:45:18 +02:00
Allan Odgaard
d8a18057fa Remove find::match_t 2016-09-16 15:40:13 +02:00
Allan Odgaard
7314f7391c Use OakDocumentMatch instead of find::match_t 2016-09-16 15:40:10 +02:00
Allan Odgaard
61f6835f9f Track FFResultNode leaks 2016-09-16 15:39:33 +02:00
Allan Odgaard
d021ba0eb2 Clearing search results would still keep FFResultNode objects around
Since the checkbox button shown in the search results had its values bound directly to an FFResultNode instance, it would retain this object for as long as the checkbox was around, which is basically forever, although it could be reused with another FFResultNode instance, in which case the previous instance would be released.

To avoid this, we have introduced an NSTableCellView that stores the FFResultNode instance as its object value, and the checkbox uses a key path that goes via the object value for the bound values. This still creates a retain cycle, but the NSOutlineView will set all object value properties to nil when its data is cleared, thereby at least releasing the FFResultNode objects.
2016-09-16 15:39:33 +02:00
Allan Odgaard
a914aaea99 Remove unused property 2016-09-16 15:39:33 +02:00
Allan Odgaard
fcee7b38ab Remove find::scan_path_t 2016-09-16 15:39:33 +02:00
Allan Odgaard
aacfb3f127 Use OakDocument/OakDocumentController for folder search 2016-09-16 15:38:43 +02:00
Allan Odgaard
aef8529bc6 Use NSTimer instead of OakTimer
This requires the document search to be stopped explicitly rather than released, but I think this is an acceptable requirement. If it is not stopped, the search will simply run its course, which would also have been the case, if something else was retaining the object.
2016-09-16 15:12:15 +02:00
Allan Odgaard
fb929aee10 Remove redundant member data 2016-09-14 21:46:07 +02:00
Allan Odgaard
553e89ceb6 Update include statements and link declarations 2016-09-11 12:47:39 +02:00
Jacob Bandes-Storch
f7c11c2436 Update visual style of OakChooser matches 2016-09-11 07:46:09 +02:00
Jacob Bandes-Storch
b3e1e3bf0f Fix the Find window status bar font 2016-09-10 10:49:37 -07:00
Jacob Bandes-Storch
e0a49637f9 Use yellow background and underline for project find results
This style is a de facto standard across a handful of popular Mac apps.
2016-09-10 10:18:21 +02:00
Allan Odgaard
349db77eba Make matched part of search results have a light grey background
The motivation for this was so that we can see if we match whitespace, e.g. searching for trailing whitespace using ‘[\t ]+$’ would not indicate how much whitespace we actually matched.
2016-08-28 13:32:47 +02:00
Allan Odgaard
a4b8abe73c Disable “tightening” of truncated match results
When we tighten the text then it doesn’t line up properly (especially line numbers) which looks off.
2016-08-28 13:32:47 +02:00
Allan Odgaard
817b2dc75e Remove attr_string_t class 2016-08-28 13:32:47 +02:00
Allan Odgaard
7844e50f5b Use string_builder_t instead of attr_string_t
Two minor changes:

- Matches now (correctly) use a font with monospace digits for all line numbers (not just first).
- Matches with ‘\r’ characters now have the replacement string (‘<CR>’) be bold if it is part of the match.
2016-08-28 13:32:47 +02:00
Allan Odgaard
c83e2e80ba Add helper class for building NSAttributedString
The existing ‘attr_string_t’ is a little inflexible in that it has to know how to handle each attribute type and also lack a way to push/pop styles, which means that in practice we have to reset styles when leaving a scope.
2016-08-28 13:30:30 +02:00
Allan Odgaard
22c1162707 Add “Copy Replacements” to the Find dialog’s action menu
This will expand the replace (format) string using the captures of each match and copy each expansion to the pasteboard.

For example searching for `object->(\w+)\()` with replace set to `$1` will copy only the function name from each invocation.
2016-08-28 09:08:17 +02:00
Allan Odgaard
b254d94192 Set a text color for find window status bar
After an OS upgrade (10.11?) clicking the status bar text (making it switch to the alternate text) would make it change color of the text.
2016-08-25 09:22:37 +02:00
Allan Odgaard
20f90b507b Add leading/trailing ellipsis for truncated search results 2016-08-24 19:51:56 +02:00
Allan Odgaard
5d4b9e3168 Ensure monospaced digits for search results line number prefix 2016-08-24 19:51:55 +02:00