Commit Graph

223 Commits

Author SHA1 Message Date
Boris Dušek
b80d60db57 Add OakSetAccessibilityLabel function
This function makes it easy to set accessibility "labels" for UI elements.
It is flexible - takes care of NSView vs. NSControl case, labels can be
specified directly as a string or as a user interface element.
2014-04-01 13:37:45 +07:00
Allan Odgaard
617e9df202 Move missing accessibility API declarations to OakAppKit.h 2014-04-01 13:33:49 +07:00
Allan Odgaard
69c83e56df The ‘const’ keyword should be to the right of its type
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”.
2014-03-31 08:27:19 +07:00
Allan Odgaard
a63edc149f Set default merge policy for CoreData
This is only relevant when another process is updating the CoreData storage (while TextMate is running), i.e. not a scenario normal users should see.
2014-03-31 08:27:17 +07:00
Allan Odgaard
5f69ef31c7 Don’t use NS prefix for custom functions 2014-03-28 19:31:14 +07:00
Allan Odgaard
619a2cfec7 Change a few instances of floorf/fabsf → floor/fabs 2014-03-28 19:31:14 +07:00
Allan Odgaard
a6654f56c9 Using cut/copy will always update the system pasteboard
Previously we only updated the system pasteboard if it was different, but some users copy rich text from one application, paste it in TextMate and then copy it (in TextMate) with the expectation that the rich styles are stripped.
2014-03-26 19:02:42 +07:00
Allan Odgaard
7e02902ab0 Remove retain cycle from pasteboard history window 2014-03-26 19:02:41 +07:00
Allan Odgaard
6535546c87 Use view’s undo manager rather than the window’s 2014-03-26 15:30:36 +07:00
Allan Odgaard
1a20f3a42d Set accessibility description when creating action buttons 2014-03-26 15:30:36 +07:00
Allan Odgaard
a004fe685d Only set raised background style for borderless action buttons 2014-03-26 15:30:35 +07:00
Allan Odgaard
ec491a4e19 Exclude divider images from accessibility
Since it is the cell that is providing the accessibility attributes the simplest way I could think of to have it ignored was to remove NSImageView’s support for the NSAccessibilityChildrenAttribute.

I tried using accessibilitySetOverrideValue:forAttribute: but it did not work for me, so a subclass was required.
2014-03-26 15:30:35 +07:00
Allan Odgaard
2cc71e57f9 Limit clipboard history display string to ~1024 code points
This should fix performance issues (during scroll).
2014-03-26 15:30:35 +07:00
Ronald Wampler
f45cb07d52 Moved OakCreateActionPopUpButton method to OakUIConstructionFunctions.h
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.
2014-03-25 16:51:40 -04:00
Allan Odgaard
90d1fd432d Non-local drags from TextMate now include NSDragOperationGeneric 2014-03-25 12:19:57 +07:00
Allan Odgaard
1a95579844 Rework OakFileIconImage
We no longer let the image representation point back to the image, since the image might be copied.
2014-03-23 22:47:16 +07:00
Allan Odgaard
175e4cf183 Let ‘tab’ in pasteboard history move to next key view
Similarly shift-tab moves to previous key view.
2014-03-14 16:08:56 +07:00
Allan Odgaard
fe1134c6c1 Full implementation of ‘labels’ property 2014-03-13 20:51:31 +07:00
Allan Odgaard
9a9614e264 Workaround for “format string is not a string literal” warning 2014-03-13 20:51:15 +07:00
Allan Odgaard
20dd3f0126 Use ‘assign’ instead of ‘weak’ when building for 10.7
On Mac OS X 10.7 we cannot use weak references to (amongst others) NSImage objects. In this case, there shouldn’t be a problem with using assign.
2014-03-13 09:37:58 +07:00
Allan Odgaard
a89ca5c930 Ensure scope bar has one button selected
It was possible to press the already selected button to deselect it. Now we reselect it, when that happens.
2014-03-12 15:50:39 +07:00
Allan Odgaard
166bfad140 Fix include paths 2014-03-07 00:10:35 +07:00
Allan Odgaard
6ded0873a3 Remove (somewhat) redundant code 2014-03-05 21:18:59 +07:00
Allan Odgaard
8e63d2729f Setting current pasteboard entry to itself lose auxiliary options
An example where this is desired is when doing a folder search for “foo”, then going to first match and using ⌘E to copy the match to the find pasteboard. This is effectively a no-op except for dropping the auxiliary options that contain other documents with matches (which is what causes ⌘G to advance to next document).
2014-03-05 21:18:59 +07:00
Allan Odgaard
c5c88843e8 Let OakFileIconImage be lazy wrt. stat’ing and obtaining SCM info
There are situations where we create an OakFileIconImage that won’t be drawn, for example when using it with an NSMenuItem. In that case, we previously paid a somewhat noticeable price in the initializer doing work that was not required.
2014-03-05 16:39:55 +07:00
Allan Odgaard
83aabbf53c Move properties from OakFileIconImageRep to OakFileIconImage 2014-03-05 16:39:55 +07:00
Allan Odgaard
1e11a30a53 Remove redundant storage keywords for @property
These were required prior to the new 64 bit run-time.
2014-03-05 16:39:54 +07:00
Allan Odgaard
947b352952 Set pasteboard history search field to fire immediately 2014-03-04 10:40:05 +07:00
Allan Odgaard
a6f6185123 Add NSError info to crash report 2014-03-04 10:24:05 +07:00
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
d700447d8b Remove unused API 2014-03-02 21:10:15 +07:00
Allan Odgaard
0e0a6e0252 Fallback on system pasteboard when history is empty
This is for the next/previous methods, the method that returns current already would fallback on the system pasteboard.
2014-03-02 12:13:06 +07:00
Allan Odgaard
95508d9757 Add new pasteboard history browser 2014-03-02 12:12:57 +07:00
Allan Odgaard
7483829245 OakPasteboard: Setting currentEntry now updates system clipboard 2014-02-28 19:20:21 +07:00
Allan Odgaard
72f4811d0b Use @property with @dynamic for ‘primitiveOptions’ property 2014-02-28 19:18:28 +07:00
Allan Odgaard
c0c8a073b9 Avoid property access in fetch predicate 2014-02-28 14:33:20 +07:00
Allan Odgaard
79a47ee277 Don’t store pasteboard entries in an ordered collection
Instead we date stamp each entry and do a sorted fetch (with a limit of one) to find next/previous entry (when required).

The reason for moving away from an ordered collection is twofold, the main reason is that NSArrayController does not support ordered collections, so we lose one of the advantages of switching to CoreData. The secondary reason is that using an ordered collection requires that we use an index for “current item” (or maybe liberal use of indexOfObject:) and it’s problematic to ensure that the index is kept 100% in sync with the entries in the collection (especially with bindings and delayed actions).
2014-02-28 14:28:03 +07:00
Allan Odgaard
13e810e8be Add exception handler for NSManagedObjectContext’s save: method
If an exception is thrown, a dialog is shown. This isn’t very user friendly, but the goal is to call attention to the problem, as I wouldn’t expect any exceptions to be thrown by this method, but I have seen multiple “optimistic locking failure” exceptions despite single-app / single-thread access to the persistent store.
2014-02-27 12:36:33 +07:00
Allan Odgaard
1a4314fce2 Wrap initialize code in dispatch_once
This is only done for code where running it twice would actually cause a problem.

Dispatch_once is favored over a static boolean only because it seems to carry slightly more semantic information.
2014-02-26 19:36:54 +07:00
Allan Odgaard
0663a39bcf Abort copy file if target is child of source 2014-02-26 08:29:42 +07:00
Allan Odgaard
3baea707e2 Fix typo 2014-02-23 08:33:38 +07:00
Allan Odgaard
60e8af92e4 Delay saving of pasteboard history by 30 seconds
Since we save the history during applicationWillTerminate: there is (in theory) no reason to periodically save the history, but in case of a crash or similar, we would not get to applicationWillTerminate:.
2014-02-22 15:51:45 +07:00
Allan Odgaard
9fcde0791e Add CoreData index to pasteboard entry content 2014-02-21 22:04:02 +07:00
Allan Odgaard
8b44ab2c41 Avoid duplicate entries on find/replace pasteboard 2014-02-21 21:36:13 +07:00
Allan Odgaard
8956207789 Avoid detached objects in core data store 2014-02-20 22:40:20 +07:00
Allan Odgaard
520084a08c Limit clipboard history to about 10,000 items
Once we reach the threshold we delete half the history to ensure a good amortized time complexity.
2014-02-20 10:34:49 +07:00
Allan Odgaard
b1ec5cf4c2 Use CoreData for storing clipboard history
Previously this was stored in NSUserDefaults. The problem with that approach is that if large items were stored in the history, it would cause slowdowns, presumably by periodic writing the entire user defaults to disk.
2014-02-19 15:34:07 +07:00
Allan Odgaard
59e27e5cbb Avoid direct instance variable access 2014-02-18 20:37:26 +07:00
Allan Odgaard
978b85cc1d Refactor OakPasteboard class
Remove logic from the setter methods and limit their use. This is in preparation for making the classes NSManagedObject subclasses where we prefer to use the generated accessor methods.
2014-02-18 17:42:01 +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