Commit Graph

4224 Commits

Author SHA1 Message Date
Allan Odgaard
77bc9f7a6f Remove test for localized folder names as it does not work (10.14)
I cannot find any information online about Apple dropping support for this, but I also cannot make it work, and it wouldn’t surprise me if they view localized folder names as a security problem.
2019-07-16 20:02:42 +02:00
Allan Odgaard
dae1103728 Update LINK declarations 2019-07-16 19:42:29 +02:00
Allan Odgaard
36f414dbea Add missing include in test file 2019-07-16 19:42:20 +02:00
Allan Odgaard
f21d570b73 Remove test for VOL_CAP_INT_EXCHANGEDATA
This is no longer supported (with APFS) so there is no reason to keep this code around.
2019-07-16 14:29:20 +02:00
Allan Odgaard
eb4e0bfcd0 Update tests to reflect how the code works
The “matching pair” move behavior was changed in 7f99c4cbc7
2019-07-16 14:27:28 +02:00
Allan Odgaard
f47a7b5f53 Code to bump date in filename is no longer a testable separate function 2019-07-16 14:24:07 +02:00
Allan Odgaard
eecfe6e619 Add more debug output for when TextMate is activated via mate
Related to 2ffc74ad8b
2019-07-16 08:33:05 +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
dfd5f85fb5 Remove unnecessary Info.plist file from Find framework 2019-07-14 10:59:30 +02:00
Allan Odgaard
63e82b9bc0 Drop localization support in Find dialog
This was unnecessary indirection as we don’t generally lookup strings for the UI (so TextMate is not actually localizable) and the catalog for the strings we did look up was actually out of date.
2019-07-14 10:57:27 +02:00
Allan Odgaard
6b3c8747e7 Remove unused localization strings 2019-07-14 10:46:31 +02:00
Allan Odgaard
a7542c7ea1 Retain current thread’s run loop 2019-07-13 11:43:24 +02:00
Allan Odgaard
f5d0f38cc7 Don’t update NSUSerDefaults in OakTabBarView’s initialize
The use of an animator proxy is causing the initialize method to be called during animation, and when registering user defaults in initialize, we may trigger key/value observers to be notified, which for this code can result in a crash in OS code with the message: “Trying to recursively lock an os_unfair_lock”.
2019-07-13 11:18:20 +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
2ffc74ad8b Add debug output when TextMate is activated via mate
Some users report a significant delay from executing mate until the TextMate window is brought to front.

The debug information can be extracted by running the following in a terminal:

    log show --predicate 'subsystem = "com.macromates.TextMate" && category = "BringToFront"'

Alternatively use `stream` instead of `log` to get a live stream of debug output.

See `man log` for options such as `--start date/time` (to limit the query to e.g. the last 10 minutes)
2019-07-13 10:20:09 +02:00
Allan Odgaard
168915307d Assign small icon to sieve scripts (file browser etc.) 2019-07-13 08:23:06 +02:00
Allan Odgaard
087e0ce0a7 Import os/log.h when deployment target is macOS 10.12 or later 2019-07-13 08:22:00 +02:00
Allan Odgaard
a9b5925f57 Saving a file would lose existing file permission flags 2019-07-08 13:07:28 +02:00
Allan Odgaard
58414e9def Resolve potential symbolic link in path to save
Trying to save a file as /path/to/symlink will fail with “file does not exist” using the new NSFileManager API, even when the symbolic link does point to an existing file.
2019-07-08 07:27:36 +02:00
Allan Odgaard
824981eaa2 Produce error string for any failure from saving with NSFileManager 2019-07-07 22:10:11 +02:00
Allan Odgaard
423e8e9a43 Allow disabling atomic save via .tm_properties
This is done by setting `atomicSave` to one of the following values:

    always           Always use atomic saving (default)
    externalVolumes  Use for non-internal volumes (e.g. USB drives)
    remoteVolumes    Use for non-local volumes (e.g. network mounts)
    never            Never use atomic saving
    legacy           Always enabled, but do not use NSFileManager

Setting it to `externalVolumes` also includes `remoteVolumes`.
2019-07-07 20:52:50 +02:00
Allan Odgaard
538283cc67 Use NSFileManager’s replaceItemAtURL:… as default way to save atomically
NSFileManager’s approach is inferior to exchangedata(), but as this feature is no longer supported with Apple’s default file system (APFS), there is little reason to maintain our own implementation of the fallback code required when we cannot use exchangedata(), especially as the OS know more about file references (aliases), metadata, and other stuff that should be preserved when writing a new (replacement) file.

In theory the NSFileManager strategy can fail to create the temporary destination, in which case we will pass NULL to open() and crash.

Will fix this in a later commit.
2019-07-07 20:52:50 +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
Allan Odgaard
997e70059a Switch to Objective-C for the implementation of atomic saving
The most appropriate API for dealing with temporary files and atomic saving seems to be NSFileManager.
2019-07-07 11:37:59 +02:00
Allan Odgaard
4c4822e1ca Make it easier to change (atomic) saving strategy
The intermediate_t type now wraps the actual saving strategy to make it easier to change strategy based on the destination file system, user preferences, or other factors.
2019-07-07 11:12:16 +02:00
Allan Odgaard
ba43f2ec5e The $1-n variables in nested replacements weren’t cleared properly
When searching for a regular expression with captures, we have $1-n available in the replacement (format) string.

If this format string does further replacements with optional captures (e.g. /^(_)?foo/) then $1 would be inherited from the parent match, when the optional capture did not match anything.

This bug was introduced in 0b1496011f.
2019-07-06 19:35:51 +02:00
Allan Odgaard
1c1358bcce Workaround for missing content when expanding file browser items
The workaround is untested, as I have not found a way to reproduce the issue, but there is some debug output that can be reviewed and hopefully give some idea as to what is causing the issue.

The debug information can be collected by running the following in a terminal:

    log show --predicate 'process = "TextMate" AND eventMessage CONTAINS "loadChildrenForItem:expandChildren:"'
2019-07-06 18:18:56 +02:00
Allan Odgaard
91d7aecf1b Changing BundleItemChooser’s hasSelection property now update item names
The items can be named “Do something with «unit» / Selection” and TextMate will show the proper title based on whether or not there is a selection, e.g. “Diff ▸ Document With Clipboard” versus “Diff ▸ Selection With Clipboard”.

Previously though, the item titles were not re-generated when changing the hasSelection property, so the user could be presented with stale titles until some other action triggered re-generation, e.g. indicating that an adaptive item works on current line when there is a selection.
2019-07-04 10:51:23 +02:00
Allan Odgaard
dc47206829 fixup! Make OakChooser windows inherit from NSWindowController 2019-07-04 10:36:53 +02:00
Allan Odgaard
11d67f3a22 Avoid NSString’s deprecated percent encoding methods 2019-06-30 10:32:45 +02:00
Ronald Wampler
b1fdd4377b Allow customization of DocumentWindowController touch bar items 2019-06-30 10:32:45 +02:00
Ronald Wampler
2294d369d0 Add accessibility support for DocumentWindowController's touch bar 2019-06-29 19:21:45 -04: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
Ronald Wampler
d8b17a1f06 Let DocumentWindowController's touch bar support nested touch bars 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
04c3ce2d73 Filter string was not cleared when closing pasteboard history
This was because our windowWillClose: delegate method was never called, as our object was no longer a window delegate, an issue introduced in 709570049f when the superclass was changed to NSWindowController and I erroneously assumed that the superclass would set itself as delegate.
2019-06-27 22:32:57 +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
1bc285270e Make OakCommand link with BundleEditor
We previously avoided this link dependency because it would cause a cyclic dependency. The build system does however not error on cycles in the dependency graph as they are all statically linked together (rather than dynamically linking with each other).

Only cycles between root targets would cause a problem.
2019-06-26 23:32:54 +02:00
Allan Odgaard
412e6798ca Update build generator script
This changes a bunch of things:

1. Each framework now creates its own include directory for exported headers, and any target linking with this framework, gets that directory added to its include search path. This ensures deterministic behavior, unlike previously where a single shared directory was used, so even if target A did not explicitly link with target B, there was a reasonable chance that target B’s headers would be available when target A was built.

2. There is a new IMPORT keyword to indicate that a target depends on the headers of another framework but does not want to link with it. For example the `commit` shell command imports headers from the CommitWindow framework (related to their communications protocol) but linking with the CommitWindow framework would not be practical (as that would bring in all the resources of the CommitWindow).

3. All embedded targets are signed before being copied to their destination.

4. A new CS_ENTITLEMENTS keyword allows specifying `codesign` entitlements. Currently the hardened runtime is enabled, although this does make development problematic, as modifying files of a running instance (as done during rebuild) can cause TextMate to crash with EXC_BAD_ACCESS (Code Signature Invalid). Worse though, it seems the system has a cache of blacklisted executables indexed by inode. So if e.g. the embedded `mate` executable gets blacklisted, one has to manually remove and rebuild it, before it gets possible to use it again (by default, rebuilding causes the inode to be re-used, but I may change the build system to unlink before copy).

5. The build file no longer contains rules related to deployment. Instead variables are declared that a user build file can reference to extend the build with notarization/deployment rules (without having to hardcode build directory paths).

6. The code has been made modular with a Compiler super class that is subclassed to add support for file transformations (xib, ragel, asset catalogs, etc.) and a transformed file can have its own settings.

7. If target A links with target B, the linker flags of target B will now be included when linking target A.

8. Currently no indexing of help books. Unsure if this is actually useful.

9. Previously it was possible to have umbrella targets that would not generate any output, but just change settings for their sub-targets. This is no longer supported, as the implementation was arcane. I would like to introduce a different system for managing sectioned settings. Related to this; settings in target files are now always merged, regardless of whether using ‘=’ or ‘+=’.
2019-06-26 23:32:19 +02:00
Allan Odgaard
b5b36a558b Add missing framework dependencies 2019-06-26 13:21:11 +02:00
Allan Odgaard
da996b6542 Use “quote” include statements for framework’s own headers 2019-06-26 13:21:11 +02:00
DaeHyun Sung
66c96b8393 Fix typo in character set name: ‘Korean – {ISO-2022-JP → ISO-2022-KR}’ 2019-06-20 16:58:57 +02:00
Allan Odgaard
5202dc34bd Revert "Let NSScrollView draw border above/below search results"
The scroll view’s border is black on 10.13.6 (and possibly earlier) which is undesired.

See https://lists.macromates.com/textmate/2018-December/040858.html

This reverts commit a0ac9c9a92.
2019-03-19 12:08:11 +07: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
97fb1f07cd Only use checkbox convenience constructor on 10.14 or later
The button created on 10.12 or 10.13 has a “Button” label next to it when used in table views (as used in the Find in Project results and Commit sheet).
2019-02-13 18:57:44 +07:00
Ronald Wampler
e0ddc61794 OakSyntaxFormatter: Clean up font attributes
See https://lists.macromates.com/textmate/2019-January/040883.html.

The issue is caused by commit f850dbdbc7, which added support for font style changes. It did so by applying a single font across the entire string. But, in some cases not all characters (e.g., Chinese or Japanese characters) may be available for that font so these characters would not be rendered correctly while editing.
2019-02-13 18:47:54 +07:00
Allan Odgaard
8e2ccd0dff Convenience constructor for labels appear to not use controlTextColor
Issue: https://lists.macromates.com/textmate/2018-December/040853.html
2018-12-07 12:55:47 +07:00
Allan Odgaard
56f073a8ef Associate search results with the current find delegate
This fixes the problem where a folder search has been done and the dialog is later re-opened for another project (which will then take ownership) and then selecting one of the old search results: The “select match” is now sent to the project that was active, when the search was performed.
2018-12-06 22:00:26 +07:00
Allan Odgaard
1a1a910c92 Introduce find dialog delegate instead of using project identifier 2018-12-06 22:00:22 +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