74 Commits

Author SHA1 Message Date
Allan Odgaard
b5b36a558b Add missing framework dependencies 2019-06-26 13:21:11 +02:00
Allan Odgaard
e70791ee89 Rename a bunch of constants to fix deprecation warnings (10.12) 2018-06-16 22:55:30 +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
Ronald Wampler
038acacca9 Avoid use of NSRunAlertPanel (10.9)
Although this is actually deprecated in 10.10, new APIs are available in 10.9 and it will make addressing deprecation warnings when upgrading to 10.10 easier.
2017-05-31 21:58:31 +02:00
mathbunnyru
9632a8d804 Deleted unused variables 2016-10-18 23:06:48 +02:00
Allan Odgaard
525c7837e3 Change autoRefresh value to array instead of string
The array can contain the following strings: DocumentChanged, DocumentSaved, and DocumentClosed.
2016-10-03 22:05:39 +02:00
Allan Odgaard
553e89ceb6 Update include statements and link declarations 2016-09-11 12:47:39 +02:00
Allan Odgaard
0f90dfd4dd Explicitly set default values for bundle_command_t members 2016-08-28 13:32:48 +02:00
Allan Odgaard
0dbd7ff903 Introduce exit_insert_snippet_no_indent
By default a command with snippet output will have the snippet indented to the current indent level.

This can be disabled in the bundle item’s property list but there might be situations where we want to disable it dynamically.

For an example see http://lists.macromates.com/textmate/2016-August/039845.html
2016-08-25 10:10:58 +02:00
Allan Odgaard
29279118c3 Introduce symbolic name for last defined exit code 2016-08-25 10:10:33 +02:00
Allan Odgaard
dbdfa3c6af Add identifying information to perror output 2016-08-21 12:09:30 +02:00
Allan Odgaard
1d78a4fc83 Don’t initialize variable to expected value (to improve test) 2016-07-10 17:49:43 +02:00
Allan Odgaard
26e66b887a Use current run loop instead of main dispatch queue
While the previous changes were motivated by the tests, this one affects TextMate in that we run a local event loop if we want to wait for commands to finish, but as we previously used the main dispatch queue to send back command results, it meant that we could not wait for command completion from a block running in the main queue.

Currently the code works around this by using performSelector:withObject:afterDelay: when there is a chance of being in a local event loop, which is no longer required.
2016-07-10 11:29:42 +02:00
Allan Odgaard
61492af33c Fix typo 2016-06-30 15:25:46 +02:00
Allan Odgaard
469fd74a7b Rely on ARC to manage GCD types (10.8) 2016-06-22 20:43:28 +02:00
Allan Odgaard
36fedf5bee Change most buffer helper functions to accept buffer_api_t 2016-06-13 13:01:10 +02:00
Allan Odgaard
417193e089 Update link dependencies for all targets
Some targets were including headers from frameworks not specified in their link dependencies. For a clean build this could cause an issue because the header was not available at the time of building the target.

The updated link dependencies are also based on what a target’s tests require. Ideally tests would have separate link dependencies, but as we don’t want to maintain this manually, this will have to wait until the build system automatically handles link dependencies.

Currently the commit command uses constants from the CommitWindow framework but should actually not be linked with it. However, the optimizer will strip dead code, so it should not result in much if any difference in the resulting binary and does solve a build dependency issue.
2016-05-07 13:00:55 +02:00
Allan Odgaard
8d8c539313 Truncate environment variables that exceed ARG_MAX
Previously we only logged an error when this happened, but (recently?) exceeding the limit will cause execve().
2015-10-28 15:38:18 +07:00
Allan Odgaard
a003d76234 Do not go via /usr/bin/env for bash
For standard commands we want to use the system’s standard interpreter, as that makes it easier to ensure compatibility.
2015-03-24 13:38:43 +07:00
Allan Odgaard
30be46a166 Support discontinuous selections in command input API 2015-03-08 14:21:59 +07:00
Allan Odgaard
40879d5683 Replace sizeofA macro with range-based for loop or std::begin/end 2015-03-05 16:38:09 +07:00
Allan Odgaard
57033d89a3 Insert at caret for exit_insert_snippet when input is document
Previously we would insert “after input” which I don’t think is desired (when input is entire document).
2014-12-16 16:02:09 +07:00
Allan Odgaard
38b68bd4fe Don’t support dispatch queue parameter for runner_t::launch
We do not use it and starting with the 10.8 SDK, dispatch types are Objective-C objects when building as Objective-C(++), which is a problem for a header that is included from both C(++) and Objective-C(++).
2014-11-30 05:25:26 +07:00
Allan Odgaard
c5e1303a2a Rename stdinFd variable to inputFd
This is just to make it consistent with our outputFd and errorFd variable names.
2014-09-13 16:19:07 +02:00
Allan Odgaard
6359a2ef7c Use symbolic exit success/failure constants 2014-04-21 17:05:35 +07:00
Allan Odgaard
ec6d0b7e4e fixup! Add assertion about being called in the main dispatch queue 2014-04-11 20:54:13 +07:00
Allan Odgaard
c7bfb36d25 Use variadic template function instead of varargs macros (C++11) 2014-04-10 11:13:13 +07:00
Allan Odgaard
4307d9eb91 Add ‘onDocumentSave’ HTML output auto refresh option 2014-04-10 11:13:13 +07:00
Allan Odgaard
6d1da8ce97 Use bundle item’s effective name in error and cancel sheets
For example the bundle item “Execute Line / Selection” will (without a selection) show as “Execute Line” in the menu, and now also if the command causes the error sheet to appear or the user press ⌃C / ⌘. to prematurely kill it.
2014-04-09 15:15:36 +07:00
Allan Odgaard
7bb584c604 Add assertion about being called in the main dispatch queue 2014-04-08 15:43:19 +07:00
Allan Odgaard
f93f793bc5 Keep dispatch group around as we may call wait after process exit 2014-04-02 14:02:28 +07:00
Allan Odgaard
a735a37b9b We shouldn’t (potentially) call fprintf() after vfork()
Since it was only incase of failing to close a file descriptor, it shouldn’t have played any role in practice.
2014-04-02 12:36:07 +07:00
Allan Odgaard
589e62b1a7 File descriptors without FD_CLOEXEC are closed before we execve()
No file descriptors (other than input/output) should be inherited by our child process. We set FD_CLOEXEC ourself, but system frameworks might not always set it, or there might be a race condition (e.g. with socket(), pipe(), mkstemp(), etc.).
2014-03-29 13:44:13 +07:00
Allan Odgaard
7a66926231 Let command::runner_t use io::create_pipe 2014-03-29 09:57:10 +07:00
Allan Odgaard
dac27f7587 Use constants for input, output, and error file descriptors 2014-03-29 09:57:09 +07:00
Allan Odgaard
e68290aaec Convert CxxTest test to custom test framework 2014-03-29 09:57:09 +07:00
Allan Odgaard
d985a83845 Use runner_t::wait_for_command instead of runner_t::wait(true)
The latter API has been removed.
2014-03-29 09:57:09 +07:00
Allan Odgaard
ffd034453a Extend command::runner_t API 2014-03-29 09:57:09 +07:00
Allan Odgaard
c9400e036d Use std::string for memory management 2014-03-28 19:31:15 +07:00
Allan Odgaard
935da75a43 Use new path::temp API to set initial content 2014-03-28 19:31:15 +07:00
Allan Odgaard
1fbf878a4d Refactor/simplify command runner 2014-03-28 19:31:15 +07:00
Allan Odgaard
ccac862602 Remove process_t 2014-03-28 10:19:06 +07:00
Allan Odgaard
45b297a150 Use custom code instead of process_t 2014-03-28 10:19:06 +07:00
Allan Odgaard
1e2f10ed46 Use dispatch queue instead of a thread for reading command output 2014-03-28 10:19:06 +07:00
Allan Odgaard
9d218ea846 We use camelCase for parameter names 2014-03-28 10:19:06 +07:00
Allan Odgaard
63d431b5ed Simplify parsing of multiple choice keys (tmCommand) 2014-03-28 10:19:06 +07:00
Allan Odgaard
4313571fc9 Parse ‘autoRefresh’ key from tmCommand files
This can be set to ‘onDocumentChange’ to indicate that the command should be re-run when the document changes, though the code hasn’t yet been written to handle this.
2014-03-28 10:19:05 +07:00
Allan Odgaard
cf8f796053 Do not use va_start macro with variable reference
This is undefined according to the standard and is a warning with clang-503.0.38.
2014-03-13 20:51:15 +07:00
Allan Odgaard
19d03df1fb Add bundle item setting for how to re-use output windows
This presently does not have any effect.
2014-03-09 17:13:57 +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