711 Commits

Author SHA1 Message Date
Allan Odgaard
7e69f5bb2c Fix compiler warnings by initializing struct members in correct order 2021-02-04 09:35:27 +01:00
Allan Odgaard
8e6c60d013 build: Remove Info.plist files from frameworks
These were previously required when we built frameworks as dynamically linked, but the files are now explicitly ignored by our build system.
2021-01-24 10:37:22 +01:00
Allan Odgaard
0f4a857fd7 Leave out kCTUnderlinePatternSolid because of warning mixing enums
The value of this constant is zero, so it is unnecessary to include.
2020-09-27 13:57:34 +02:00
Allan Odgaard
cb5d81deef Remove commented debug output lines 2020-09-27 13:57:34 +02:00
Allan Odgaard
e80ef1d0b7 Remove use of OBJC_WATCH_LEAKS 2020-06-05 21:22:50 +07:00
Allan Odgaard
c93030b385 Remove all debug output from custom log macros
This provided value during early development, but has been unused for years, and it would generate too much noise if converted to os_log.

So better to just remove it all and add os_log statements as needed.
2020-06-05 21:22:50 +07:00
Allan Odgaard
4ec10c0923 Don’t annotate types and classes with PUBLIC
This was required when we linked each framework as its own thing, which we do not do anymore, and if we do go back to this system, we can simply have symbols public by default.
2020-06-05 21:22:50 +07:00
Allan Odgaard
d500f6e53d Remove support for initial first responder in OakSetupKeyViewLoop 2020-05-25 12:47:47 +07:00
Allan Odgaard
66c1bc7f78 Clear background when using a theme with transparent background
This partially reverts 6ffd0f2e92

While we do not support transparent themes per se, we still use the alpha colors and thus would previously fill the background using alpha, into a layer that we hadn’t previously cleared.
2020-05-17 08:15:55 +07:00
Allan Odgaard
6ffd0f2e92 Avoid potential crash by not updating window’s opaque property
This does completely remove support for transparent themes, but any recent version of macOS would not support it anyway due to layer-backed views.

The crash resulting from setting opaque is because of recursion: After session restore, the window will calculate shadow, this triggers a “user defaults did change” notification, which updates theme of text view, which sets opaque, which re-calculates shadow and tries to recursively obtain a non-recursive mutex.
2020-05-16 07:12:01 +07:00
Allan Odgaard
a7e23d2722 Expose automatic theme switching in View → Themes submenu
Theme is now stored only with OakTextView (observed by OakDocumentView) and the “global” setting is stored in user defaults (not Global.tmProperties), though it is still possible to override theme on a file-by-file basis via .tm_properties files.
2020-05-14 15:43:24 +07:00
Allan Odgaard
e310724951 Pass theme to OakDocumentView instead of querying settings in the object
This is because OakDocumentView is not in the view hierarchy and it obtains the theme via settings_t, so there is no way to notify about theme changes.
2020-05-14 15:43:24 +07:00
Allan Odgaard
ad1cc8abd8 Deliver all NSUserDefaultsDidChangeNotification in main queue
This is easier than ensuring that we do not update user defaults from a background thread.
2020-05-14 09:52:38 +07:00
Allan Odgaard
c2019e15a1 Use CGContext instead of graphicsPort 2020-05-13 18:50:02 +07:00
Allan Odgaard
90a2517600 Allow opening “Find in Project” from pasteboard history chooser
This is triggered by holding option when selecting Find Next. Improving discoverability is work in progress.
2020-05-10 20:07:31 +07:00
Allan Odgaard
caaa36161d Change most fprintf log statements to using os_log 2020-05-04 19:20:04 +07:00
Allan Odgaard
633d5e4b89 Play sound when starting/stopping macro recording 2020-04-29 08:02:02 +07:00
Ronald Wampler
18c1c1dfeb Fix Previous/Next Bookmark action in OakTextView touch bar
performNavigateBookMarksSegmentAction → performNavigateBookmarksSegmentAction
2020-04-28 09:54:47 +07:00
Allan Odgaard
c7b4b09768 Workaround for potentially running bundle items from nested run loop 2020-04-23 22:41:34 +07:00
Allan Odgaard
b514114ec7 Access most system singletons using dot syntax
These are identified by having a prefix of shared, default, or standard in the class method.
2020-04-23 12:25:11 +07:00
Allan Odgaard
814a3c78b4 Access sharedInstance using dot syntax 2020-04-23 12:25:11 +07:00
Allan Odgaard
3f8c6914af Move “documents with matches” property from OakPasteboard to Find class
Originally the idea was to store it with the current pasteboard item, so that updating the pasteboard would automatically clear the matches.

But since there is currently only one use-case for this feature, the Find class can simply register for a “pasteboard did change” notification (which it already does for other reasons), and clear the matches if the clipboard changes.

The only downside is that the text view cannot depend on the find framework, as the latter already depends on the former, but we can just import the Find interface, and assert that the class will be present at run-time.

Long-term though, we should refactor this, as we do need two-way communication between these frameworks, for example to make matches live or update the selected match in the Find window when advancing through them in the text view (with ⌘G).
2020-04-23 12:25:11 +07:00
Allan Odgaard
d63f12993f Use class properties for general, find, and replace pasteboard instances 2020-04-14 12:58:10 +07:00
Allan Odgaard
a6258bb625 Snippet pop-up menu would scroll horizontally opposite of the document 2020-04-14 12:58:10 +07:00
Allan Odgaard
eccbb81e8a Constrain height of vertical dividers and remove intrinsic height
Previously some status bars could be compressed vertically because the dividers did not have a fixed height, so they were sized based on their intrinsic height.

With a fixed height the intrinsic height is redundant and previously it was simply hiding an issue with an under-constrained layout, so better just remove them.
2020-04-14 12:58:10 +07:00
Allan Odgaard
e490b86c47 Make horizontal dividers subviews of status bar (NSVisualEffectView)
This makes the color of the separator bar better adapt to the color of the status bar and should make things more consistent, as we already have separators inside visual effect views in various places.

Also adjust height of the vertical separators in status bars to only be 15 pixels so that we have equal padding above and below.
2020-03-29 10:23:42 +07:00
Allan Odgaard
d7ec9e6690 Use OakCreateNSBoxSeparator() for live search and grammar installation
This is instead of the more opaque OakCreateHorizontalLine(OakBackgroundFillViewStyleDivider).
2020-03-29 10:21:30 +07:00
Allan Odgaard
e7ea79cffe Use OakCreateNSBoxSeparator() instead of OakCreateDividerImageView()
The latter is a wrapper around an NSBoxSeparator, only adding some size constraints.
2020-03-29 10:21:27 +07:00
Allan Odgaard
afe008e028 Allow invalid ranges to be passed to nsRangeForRange:
Since this is internal API it should not be necessary to sanitize the range, but based on textmate/bugs#34 it is causing a lot of crashes on macOS 10.15.
2019-12-15 12:06:56 +07:00
Allan Odgaard
9565bb4910 Add NSStandardKeyBindingResponding to OakTextView’s interface 2019-10-27 15:27:03 +01:00
Allan Odgaard
6f68ea7303 Do not use custom white I-beam cursor on macOS 10.14
The I-beam cursor on macOS 10.14 has a white outline that makes it visible when used with dark themes.
2019-10-14 14:47:38 +02:00
Allan Odgaard
4c7b98d0bf Remove superfluous spacing for aligned assignments 2019-10-07 21:28:16 +02:00
Allan Odgaard
4b4e5fca8b Remove code required for compatibility with 10.10 and earlier 2019-10-07 21:28:16 +02:00
Allan Odgaard
4fbc9ee6ea Fix indentation (spaces → tabs) 2019-09-05 10:01:10 +02:00
Ronald Wampler
4820e876d2 Only allow navigating bookmarks in the touch bar
See https://lists.macromates.com/textmate/2019-August/041082.html
2019-09-05 09:59:44 +02:00
Allan Odgaard
774e66c009 Ignore ‘types’ in implementation of writeSelectionToPasteboard:types:
The issue is that the types requested may be ‘NSStringPboardType’ but that symbol is deprecated (starting with 10.14), yet the replacement (‘NSPasteboardTypeString’) is not string-equivalent, therefore our simple string comparison would fail.

This effectively broke services starting with 1ef78b3af7 (where we adopted the new symbols).

Implementation of validRequestorForSendType:returnType: does not appear to be a problem, as that method is called with both ‘NSStringPboardType’ and ‘NSPasteboardTypeString’.

Also switched to using NSPasteboard’s writeObjects: so we don’t have to explicitly deal with the type of the data we write to the pasteboard (presumably NSString will declare it using both the old and new type).
2019-08-02 21:03:39 +02:00
Allan Odgaard
8f685ff25c Use std::clamp instead of oak::cap (C++17) 2019-08-01 10:23:55 +02:00
Allan Odgaard
b176bf8f9a Use number formatter for count in Find All / Replace All status text
The Find dialog was already using number formatters, but the tool tips shown in the text view (when doing searches or replacements without going through the find dialog) were not.

This makes a difference when the count is > 999, as it will then format the number with thousand separators.
2019-07-14 11:26:31 +02:00
Allan Odgaard
066e020265 Ensure temporary std::string stays in scope when using its data 2019-07-13 11:02:25 +02:00
Allan Odgaard
8f3f3d9d16 Update deployment version for xibs to 10.12
This was done using search and replace. Presumably it should be done in Xcode so that it can adjust the xib for the new deployment target, otherwise what is the point of storing deployment version in the xib and provide it as a command line argument to the xib compiler as well (only to get a warning if the versions do not match)?
2019-07-07 18:03:30 +02:00
Ronald Wampler
d8db03c426 Add initial touch bar support for OakTextView
This adds buttons for inserting/removing bookmarks and navigate them.

Since the function keys were replaced with the touch bar, there currently is no other way to set and navigate bookmarks other than these buttons so make their visibility priority high.
2019-06-29 19:21:45 -04:00
Allan Odgaard
1ef78b3af7 Rename symbols to what’s expected by the 10.14 SDK 2019-06-29 20:14:15 +02:00
Allan Odgaard
5aa58e5543 Do not include $APP_NAME in framework’s bundle identifier
Since we have multiple application targets, it doesn’t make sense with a global APP_NAME variable.

Though if building the frameworks as standalone bundles and embedding them in different applications, we may need some sort of unique component in the bundle identifier, but we currently do not do this (they are all statically linked, so the Info.plist is currently unused).
2019-06-26 23:32:54 +02:00
Allan Odgaard
b5b36a558b Add missing framework dependencies 2019-06-26 13:21:11 +02:00
Boris Dušek
85d3af94ba Implement "Symbols" accessibility rotor
Accessibility rotors allow VoiceOver user to navigate content quickly
by making possible navigation through select elements only.

In this case, we enable VoiceOver users to navigate efficiently
through symbols.

The first way to invoke a rotor is a "global" one (does not take into
account current position in text) and is invoked with VO-U. After
pressing arrow left/right sufficient times to reach "Symbols", one is
presented with a list analogical to the "Jump to symbols" TextMate
feature invokable by Shift-Cmd-T. Arrow up and down then enable
navigating through items, Return selects the result (and jumps to it),
Esc cancels the interface without moving the cursor. Also filtering
the list works by simply typing characters (implemented as
case-insensitive substring search - consistent e.g. with Safari's
"Headings" rotor).

The second way to use a rotor is a "local" one (navigates w.r.t. the
current position in text) and is typically done through Trackpad
Commander (turned on by VO + two finger "screw" gesture to the right
on the Trackpad). Then one uses two-finger "screw" gesture (like
(un)screwing the bottle lid from/to the bottle with thumb and index
finger) to select "Symbols". When this is finally selected (the
selection is persistent), the user can then use flick with one finger
up or down gestures to move to the previous/next occurrence respectively.

I made a choice at one spot - I report the "symbol location - end of
hardline" as the range of the symbol (that is e.g. what VoiceOver
reads when navigating the elements). This seemed to work best for the
user at least in the Objective-C code.

The APIs are 10.13+ only, so appropriate avaiability declarations are
put in place to not cause warnings from the compiler. I was not sure
whether some declaration like that is needed also for the
OakTextView's informal category's conformance to the
`NSAccessibilityCustomRotorItemSearchDelegate` protocol - the protocol
is 10.13+ only too, but the compiler does not warn about conforming to
it. Perhaps the Objective-C runtime is smart enough to take into
account that the `NSAccessibilityCustomRotorItemSearchDelegate` symbol
is (hopefully) weakly-linked and adds conformance to it (I assume
using the `class_addProtocol` function) only when it is non-nil. I
have however not tested whether the compiled app actually degrades
gracefully (without crashing) on macOS 10.12 and earlier, though (for
starters, I seem not to have access to a macOS Sierra image to create
a VM).
2019-02-21 14:46:19 +07:00
Allan Odgaard
b8017b9f22 Do not set NSBackgroundStyleRaised for controls and text in status bars
It appears to be ignored on 10.14 but earlier versions of macOS rendered the elements with a shadow, which is probably not a good fit for our current design.
2018-12-06 22:00:22 +07:00
Allan Odgaard
9e3b1d6028 Set wantsLayer to YES for all NSVisualEffectView subclasses
This is required when using NSVisualEffectBlendingModeWithinWindow although on macOS 10.13 and later a view is layer backed by default.
2018-12-04 15:43:15 +07:00
Boris Dušek
5ee17f2b0e Use new convenience accessibility APIs in OakTextView.mm 2018-12-04 15:40:25 +07:00
Boris Dušek
9ad976a4c0 Migrate OakTextView to new Accessibility API
macOS 10.10 SDK introduced new protocol-based accessibility APIs. The
old accessibility APIs are now deprecated. These APIs require a
minimum deployment target of 10.10, which is fulfilled since TextMate
2.0 rc 12.

Main changes connected with this new API is that it is statically
typed, so it is no longer necessary to convert parameters from (and
results to) NSValue objects.

Still some of the weakly-typed original APIs are not deprecated and
have no alternative in the new API, notably e.g. the
accessibilityArray* methods, so they are kept.
2018-12-04 15:40:25 +07:00
Allan Odgaard
dff0b6ed54 Always allow vertical scroll elasticity in text view 2018-12-02 18:08:38 +07:00