26 Commits

Author SHA1 Message Date
Ronald Wampler
4a7e774196 Use oak::random_shuffle instead of std::random_shuffle
The latter is deprecated in C++14 and will be removed in C++17
2016-10-18 23:06:49 +02:00
Allan Odgaard
371d426c5f Add ‘char const*’ insertion API to ng::buffer_t 2016-06-21 23:23:44 +02:00
Allan Odgaard
da96be12c9 Add comparison operators to storage_t class 2016-06-21 06:18:55 +02:00
Allan Odgaard
029dab73be Make to_xml a member function of buffer_t
We could implement this by using the public scopes member function though this function includes dynamic scopes such as misspelled ranges which would change the current semantics of the to_xml helper function.

It might actually make sense to make this change, but I’m avoiding functional changes while refactoring.
2016-06-13 13:01:10 +02:00
Allan Odgaard
e83fee564c Refactor: use emplace_back(…) instead of push_back(make_pair(…)) 2016-05-28 22:12:46 +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
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
123471a6e8 Use arc4random_uniform (in tests) to avoid modulus bias 2014-12-16 16:02:09 +07:00
Allan Odgaard
e78764a89e Let threaded syntax highlight parsing for ng::buffer_t be opt-in 2014-06-28 17:42:23 +02:00
Allan Odgaard
2b74e76a2f Disable concurrent buffer parsing when not on main thread
The problem is that we can only return to the proper thread/queue when we know what that thread/queue is. Additionally, when running tests, we are calling from a concurrent queue, so even knowing the queue, we cannot safely update the buffer with the new scopes, as only a serial queue can give us exclusive access.
2014-05-16 22:11:29 +07:00
Allan Odgaard
af3f4aaa33 Check result of most CF/CT ‘Create’ functions 2014-05-15 13:17:30 +07:00
Allan Odgaard
39b94e6ac3 Harmonize whitespace and add trailing newline 2014-04-14 14:26:52 +07:00
Allan Odgaard
3646f0630d Add test for thai script
This isn’t causing an issue, though at a higher level we wish to split the combined characters when using backward delete.
2014-03-13 17:25:29 +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
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
d6360426e3 Avoid function-local static storage for std::map
This gives the venerable warning about map::~map being a weak reference or something along those lines.
2013-03-25 13:19:38 +01:00
Allan Odgaard
53d1928b9d Update buffer tests
Mainly improving function names including appropriate prefix for benchmark functions so that they are picked up by the new test system.
2013-03-10 14:34:44 +01:00
Allan Odgaard
e3e643468f Use constructor function instead of class 2013-03-10 14:34:44 +01:00
Allan Odgaard
cd2b0882f0 Use new test system for a few frameworks 2013-02-22 15:55:28 +01:00
Allan Odgaard
e75e7ec8e5 Change text::format → std::to_string (C++11) 2013-02-08 11:20:34 +01:00
Allan Odgaard
0f3861fec7 Retire custom begin/endof functions
We can now use std::begin/end although for containers we explicitly call the member functions.
2012-09-20 12:22:21 +02:00
Allan Odgaard
ebab500ba3 Use std::map/set instead of C arrays
These types come with a find() method and avoids having to use helper functions to get the begin/end of the array (for linear search).
2012-09-20 12:22:20 +02:00
Jacob Bandes-Storch
fd419fd0b1 Use libc++: replace __gnu_cxx with std 2012-08-28 13:30:20 +02:00
Allan Odgaard
9894969e67 Initial commit 2012-08-09 16:25:56 +02:00