Commit Graph

93 Commits

Author SHA1 Message Date
Allan Odgaard
c2397484b8 Use C++11 for loop
Majority of the edits done using the following ruby script:

    def update_loops(src)
      dst, cnt = '', 0

      block_indent, variable = nil, nil
      src.each_line do |line|
        if block_indent
          if line =~ /^#{block_indent}([{}\t])|^\t*$/
            block_indent = nil if $1 == '}'
            line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
              $1.to_s + variable + ($2 == "->" ? "." : "")
            end
          else
            block_indent = nil
          end
        elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
          block_indent, variable = $1, $2
          line = "#$1for(auto const& #$2 : #$3\n"
          cnt += 1
        end
        dst << line
      end
      return dst, cnt
    end

    paths.each do |path|
      src = IO.read(path)

      cnt = 1
      while cnt != 0
        src, cnt = update_loops(src)
        STDERR << "#{path}: #{cnt}\n"
      end

      File.open(path, "w") { |io| io << src }
    end
2014-03-03 10:34:13 +07:00
Allan Odgaard
57e8e37313 Rename NSReplacePboard → OakReplacePboard
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).
2014-02-18 12:41:47 +07:00
Allan Odgaard
8ebbb338c2 Disallow creating OakPasteboardEntry outside OakPasteboard.mm
This is in preparation of adopting CoreData which will require a managed object context to create pasteboard entry objects.
2014-02-18 11:53:41 +07:00
Allan Odgaard
7287fc7359 Indicate that Find and HTML output are auxiliary windows
This doesn’t seem to change anything wrt. behavior, but perhaps it will in the future.
2014-02-09 23:09:21 +07:00
Allan Odgaard
c2bb5253ef Ensure text view find operations use values from the UI
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
2013-12-12 14:45:05 +07:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
b53fb59528 Fix crash when giving nil string to FFDocumentSearch 2013-08-30 12:30:33 +02:00
Shelby Munsch
283ecd069e Fixed typo 2013-08-27 22:49:47 -07:00
Allan Odgaard
cfa913d0f5 Fix retain cycle 2013-08-28 00:23:07 +02:00
David Howden
1faaf77d99 Stop Find window showing an NSSavePanel on ⌘S 2013-08-23 23:21:16 +02:00
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