46 Commits

Author SHA1 Message Date
Allan Odgaard
e4f61f12b7 Change a few leading spaces to tabs 2020-04-30 13:28:24 +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
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
351ba81527 Use “space” instead of “␣” when creating string from key equivalent 2018-06-28 10:40:27 +02:00
Allan Odgaard
e70791ee89 Rename a bunch of constants to fix deprecation warnings (10.12) 2018-06-16 22:55:30 +02:00
Ronald Wampler
a124b494c2 Revert "Explicitly cast back to the CGEventFlags typedef"
This reverts commit 9e4e88ce76.

CGEventFlags is (correctly) defined in the 10.12 sdk as:

   typedef CF_OPTIONS(uint64_t, CGEventFlags)
2017-05-31 21:58:31 +02:00
Allan Odgaard
de92b7dbe9 Provide to_s for NSUUID 2016-09-26 11:07:56 +02:00
Allan Odgaard
a6ecde745d Change how we run NSSpellChecker code on the main thread
We only run uniqueSpellDocumentTag and closeSpellDocumentWithTag: on the main thread, as the spelling methods themselves should be thread safe and do not cause any tests to fail (even when running them in parallel).

The way we check if we must “jump” to main thread is done by looking at our current run loop rather than using the deprecated (as of 10.9) dispatch_get_current_queue() function. Since we are looking at the run loop, we now use CFRunLoopPerformBlock() instead of the dispatch functions.
2016-07-10 17:49:43 +02:00
Allan Odgaard
669928f4de Remove use of @synthesize in miscellaneous files 2016-06-22 20:44:41 +02:00
Allan Odgaard
7ac10b7b29 Add to_ns helper function which creates an NSString from std::string 2016-06-21 22:11:13 +02:00
Allan Odgaard
3fab3fe3d0 Use CoreFoundation when converting NSString → std::string
This is significantly faster on OS X 10.11.

The API is slightly different so this is probably still faster in macOS 10.12 where there should be less of a performance difference between using Foundation and CoreFoundation.
2016-06-18 10:34:49 +02:00
Allan Odgaard
8483826fae Always use '\0' as fill value when creating a string buffer 2016-06-18 10:34:08 +02:00
Adam Strzelecki
e59db8375f Use panel language unless spellingLanguage is specified
This partially reverts changes of 3fdc72b93a:
Support spell checking being “automatic by language”.

Before 3fdc72b spellingLanguage .tm_properties setting (default "en") was the
only way to set spelling language for file (buffer). English was default
language for all files. 3fdc72b introduced change that when “automatic by
language” was selected in system's spelling panel then TextMate was ignoring
spellingLanguage setting and was using automatic by language.

However because “automatic by language” is default on OS X, effectively 3fdc72b
makes spellingLanguage setting no longer effective. To make it work one needs
to set explicit spelling language either in System Preferences or in spelling
panel upon each TextMate run (since this is getting reset after application
restart) - which is counter-intuitive, can be treated as regression and it is
vaguely described in ChangeLog:

 * Support spell checking being “automatic by language”. This is set via the
   spelling panel.

This change presents alternative approach, introducing new empty
spellingLanguage setting "" (which is now default), which makes use system
panel language setting, including “automatic by language”.

From now on all files will be checked against system panel selected language
(or automatic), unless .tm_properties project specifies explicitly language for
given file using, eg.:

    [ locale-en_US.ini ]
    spellingLanguage = en_US

    [ locale-pl_PL.ini ]
    spellingLanguage = pl_PL

Or automatically depending on file name:

    [ locale-*.ini ]
    spellingLanguage = '${TM_FILEPATH/^.*locale-([a-z]+_[A-Z]+).*$/$1/}'
2016-01-29 08:46:18 +07:00
Ronald Wampler
9e4e88ce76 Explicitly cast back to the CGEventFlags typedef
The SDK for 10.11 (Xcode 7 GM and Xcode 7.1 beta) declares this enum using CF_ENUM instead of CF_OPTIONS, which forces us to explicitly cast back to the typedef type. <rdar://22743357>

Hopefully, we can revert this after OS 10.11 is officially released.
2015-09-21 09:50:04 -04:00
Allan Odgaard
3fdc72b93a Support spell checking being “automatic by language”
This must be set in the spelling panel and changing language via the spelling panel does not update the buffer (recheck the text with the new spelling language), so toggle automatic spelling after using the spelling panel to change language.

Closes #1139
2015-06-24 00:46:49 +02: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
b854201acf Improve NSEvent decoding for non-Latin key mappings
If control (⌃) is down and the system gives us a non-ASCII key string then we will disregard it and instead convert the virtual key code to its ANSI character.
2015-01-18 18:17:33 +07:00
Allan Odgaard
691a6b4086 Remove redundancy 2015-01-18 18:07:41 +07:00
Allan Odgaard
c8960dee94 Add to_s for NSAttributedString and id 2014-11-29 09:50:18 +07:00
Allan Odgaard
7f0c323f66 Use NSMaxRange helper function 2014-11-29 07:55:48 +07:00
Allan Odgaard
694e6e17dc fixup! Normalize newline and backspace characters in key event strings 2014-11-17 15:24:32 +01:00
Allan Odgaard
790a497a07 Use font’s maximumAdvancement for aligning key equivalents
Previously we would use the width of the delete glyph (⌫).
2014-11-17 00:02:03 +01:00
Allan Odgaard
12013fef38 Add OakAttributedStringForEventString helper function
This will convert the event string to the proper glyphs and lookup function key glyphs in the font and set the proper glyph info attributes (if found).
2014-11-14 10:22:50 +01:00
Allan Odgaard
ae02add21c Normalize newline and backspace characters in key event strings
The system’s key binding dictionaries use both CR and LF for newline and \x08 and \x7F for backspace.
2014-11-10 17:11:31 +01:00
Allan Odgaard
39b94e6ac3 Harmonize whitespace and add trailing newline 2014-04-14 14:26:52 +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
c38a1a64af Add to_s overload for NSError 2014-03-04 10:23:01 +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
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
bf1e92b865 Do not use global constructors for fixtures 2013-08-16 22:40:08 +02:00
Allan Odgaard
97ad8294a6 Initialize shared spell checker during setup
The first time we ask for the shared spell checker it does some setup involving AppKit (creating the shared spelling panel?). While we already ensure that the spell checker is only called from the main queue, it seems this setup code must run on thread 0, which, when we are not in a Cocoa application, is not necessarily the thread used for the main queue.
2013-08-05 18:55:43 +02:00
Allan Odgaard
cd8b554b59 Ensure NSSpellChecker methods are called from main queue
I have been told that the spell checker should be thread safe (except for the spelling panel) but after moving to concurrent execution of the integration tests, several segmentation faults have pointed toward the spell checker not being thread safe.
2013-08-04 22:15:34 +02:00
Allan Odgaard
a8e677db3c Update testing system for ns framework 2013-08-01 19:03:31 +02:00
Allan Odgaard
34c44bd647 Don’t create NSSpellChecker tags until needed 2013-07-26 22:45:36 +02:00
Allan Odgaard
72b587e147 Account for strings with \0 characters
Previously we would truncate such strings.
2013-01-22 19:23:16 +01:00
Allan Odgaard
a65b7640f9 Handle empty string given to glyphs_for_key
Previously it would work, but as it was calling utf8::to_ch with the empty string, this would trigger an assertion (when running a debug build).
2012-12-28 02:47:19 +01:00
Allan Odgaard
71be61cbbb Enable ARC by default
We now explicitly disable it for targets that hasn’t yet been upgraded to ARC. This way, it’s easier to get an overview of which targets hasn’t yet been upgraded and ensures new targets has ARC enabled.
2012-12-19 19:42:36 +01:00
Allan Odgaard
6bc36a565b ARC: Update ns framework 2012-12-19 19:42:35 +01:00
Allan Odgaard
1eb54282af Move attr_string.h to Find framework 2012-12-19 19:42:35 +01:00
Allan Odgaard
983bce86aa Use @autoreleasepool blocks 2012-09-25 12:30:12 +02:00
Allan Odgaard
6afa7601c0 Provide utf16::advance with range end
There are several crashes reported from firstRectForCharacterRange: which indicate that the system may ask for indexes “out of range”, hence why we now effectively just cap such request.
2012-09-21 01:32:41 +02:00
Allan Odgaard
cbe91ff831 Assume compiler support for explicit keyword
Since we require a fairly recent clang for other features, there is no reason to test for this one.
2012-08-29 14:27:35 +02:00
Jacob Bandes-Storch
9584afba16 Use 64-bit: replace SELNAME with sel_getName 2012-08-28 21:32:46 +02:00
Jacob Bandes-Storch
e3aa997b06 Use libc++: replace std::tr1 with std 2012-08-28 13:30:20 +02:00
Allan Odgaard
783514fcff Strip the numeric keypad flag for key events
This means pressing e.g. ⌘/ (using the slash on the numeric keypad) will still work to toggle comments.

It also means that we can no longer bind specifically to the numeric keypad keys, but I don’t think anyone actually does that (given that few have numeric keypads).

The ideal solution would be to first do a literal check and then, if there was no match and the key event had the numeric keypad flag set, do a test with this flag removed, but that would change the simple string compare we presently use plus the easy caching and binary search of finding the item that matches a key event, i.e. it would add complexity to the code with no known argument in favor of this flexibility.
2012-08-19 21:08:05 +02:00
Allan Odgaard
9894969e67 Initial commit 2012-08-09 16:25:56 +02:00