33 Commits

Author SHA1 Message Date
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
caaa36161d Change most fprintf log statements to using os_log 2020-05-04 19:20:04 +07:00
Allan Odgaard
cb4c12681e Use NSNotificationName as type of all our notification names 2020-05-04 19:20:04 +07:00
Allan Odgaard
34bc5ea0fe Increase timeout for commands with HTML output from < 2 hours to FLT_MAX 2020-04-29 08:02:02 +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
d5440d86e8 For bundle commands we now write the script to ~/Library/Caches
Previously we used the system’s temporary directory and removed the script after use.

This is because macOS 10.15 will “call home” (notarization?) when executing a new script (that it has not seen before), so with an unstable network connection, running commands could take several seconds.
2019-10-27 15:24:08 +01: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
f6fa273912 Update coding style for where to place colon after dictionary keys
This follows the Swift style and also makes it possible to align dictionary values using TextMate’s Align Assignments command.
2018-10-07 09:54:45 +02:00
Allan Odgaard
5f2e0dac28 Limit command error output to 7 lines with a “Show Full Output” button 2018-10-03 20:11:20 +02:00
Allan Odgaard
e70791ee89 Rename a bunch of constants to fix deprecation warnings (10.12) 2018-06-16 22:55:30 +02:00
Ryan Schmidt
bade4054dc Mark strong properties as strong
Versions of the OS X 10.11 SDK prior to 10.11.4 require this to
be done explicitly. This fixes the build on OS X 10.10 when
using the OS X 10.11 SDK from Xcode 7.2.1 and earlier.
2018-02-06 17:23:26 +07:00
Allan Odgaard
ed91562780 Use encode::url_part instead of NSString’s deprecated API
While NSString does have a “modern” replacement, it seems simpler to use our own API because we are already dealing with a std::string.
2017-09-12 16:57:00 +02:00
Allan Odgaard
ffd6271a69 Allow disabling TextMate’s JavaScript API for commands with HTML output
This is done by setting the ‘disableJavaScriptAPI’ key to ‘true’ in the tmCommand file.

The rationale behind this is that a command like “HTML → Show Preview” is using the HTML output view with user data which should not have access to the special TextMate JavaScript object, for example a user may have a `<script>` tag that loads JavaScript from a CDN, and such script would effectively have shell access to the user’s machine.
2017-07-12 10:35:31 +02:00
Allan Odgaard
8c5936d3d7 Only run modal event loop runner when it exists
When running commands without a text view (i.e. no windows open), we do not have a modal event runner.
2016-11-04 19:22:39 +07:00
Allan Odgaard
a1a5430abb Fix potential nil value in dictionary literal 2016-11-04 19:22:39 +07:00
Allan Odgaard
122bd0b8a1 File descriptor was closed twice causing a potential crash 2016-11-04 19:22:39 +07:00
Allan Odgaard
690e8d22b0 Do not run modal event loop when doing command preflight actions
Preflight actions could show dialogs (such as a save dialog) which would then be unresponsive, since we were running a modal event loop.
2016-11-02 23:02:18 +07:00
Allan Odgaard
3b2a075808 Add public htmlOutputView property to OakCommand 2016-09-27 21:51:55 +02:00
Allan Odgaard
ce55f5691e Add public closeHTMLOutputView method to OakCommand 2016-09-27 21:51:55 +02:00
Allan Odgaard
d7f06c70c6 Don’t check requirements or new HTML output view when reusing OakCommand 2016-09-27 21:51:55 +02:00
Allan Odgaard
ecee5e62e3 Add updateHTMLViewAtomically property to OakCommand
This can be used to refresh the output from a command that is already visible (to avoid flicker and resetting scroll position).
2016-09-27 21:36:26 +02:00
Allan Odgaard
8e9cd68c4f Refactor handling of HTML output in OakCommand
Setup and teardown is now contained in the same method.
2016-09-27 21:36:26 +02:00
Allan Odgaard
4dea28811c Let OakTextView run modal event loop waiting for command 2016-09-27 21:34:55 +02:00
Allan Odgaard
bf2eb3eb83 Add terminationHandler property and terminate method to OakCommand 2016-09-27 21:29:03 +02:00
Allan Odgaard
ede6b4b026 Change named parameter completionHandler: to outputHandler:
The handler is only called for commands with output to insert into the text view, hence completionHandler is a misnomer.
2016-09-27 21:29:03 +02:00
Allan Odgaard
3af916629c Let OakCommand use OakDocumentController API 2016-09-24 08:33:33 +02:00
Allan Odgaard
74a2c9e801 Handle potential exception when asking NSFileHandle for fileDescriptor
Based on crash logs this occasionally throws an “Operation not permitted” or “unknown error” exception, so now we catch these.
2016-09-21 20:39:41 +02:00
Allan Odgaard
51faf0ed3c Remove WebKit workaround that no longer seems necessary
The workaround was introduced in May 2005, so the underlying issue was probably addressed a long time ago :)
2016-09-17 07:22:41 +02:00
Allan Odgaard
e9cf7df4a6 Do not close file handle potentially used by another thread 2016-09-07 22:13:10 +02:00
Allan Odgaard
800f47e85d Deliver all data from custom URL protocol on main thread
This closes textmate/bundle-support.tmbundle#26.
2016-09-05 08:56:23 +02:00
Allan Odgaard
95580d5ec7 Do not assume NSApp.keyWindow nor NSApp.mainWindow are valid
These are both set to nil when the app loses focus, and even in an NSApplicationDidBecomeActiveNotification these are still nil.

This means any command running while the app was inactive or as part of a “did become active” notification, would not find the proper objects to setup environment etc.
2016-08-30 18:33:24 +02:00
Allan Odgaard
f3745fe034 Add new OakCommand framework
A lot of the code is copy/pasted from the document::run implementation, our command::runner and HTMLOutput (custom URL protocol).
2016-08-28 13:32:48 +02:00