Commit Graph

53 Commits

Author SHA1 Message Date
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
2cb480364f Asking for marks of any type now return both type and value
Previously we would only return the type.
2014-10-19 20:26:00 +02:00
Allan Odgaard
862a543074 Don’t rebase mark positions when returning marks for a subset 2014-10-19 20:25:59 +02:00
Allan Odgaard
a22801f615 Remove undesired space character 2014-10-19 20:25:59 +02:00
Allan Odgaard
0d917f8f94 Allow a string value to be stored with each mark (buffer)
We were already storing a string for each mark but was (redundantly) using the mark type as value.
2014-10-19 20:25:59 +02:00
Allan Odgaard
356999392d Remove crash report info gathering from buffer type
This was affecting performance when performing actions that go through the entire buffer. Also, none of the functions are involved in any crash reports.
2014-09-15 20:41:51 +02:00
Allan Odgaard
98b08464c7 Workaround for NSSpellChecker advancing the event loop
This fixes #1260 though we may want to update our design to work with an asynchronous spell checker.
2014-09-02 11:19:34 +02: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
d7dba7cd7a Drop the oak::server_t abstraction for buffer parser 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
96de950ed1 Return initializer list instead of using std::make_pair (C++11) 2014-04-06 19:36:09 +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
9fe5a058ce Make buffer_t::wait_for_repair a no-op with no grammar 2013-09-15 21:22:44 +02:00
Allan Odgaard
1c308c810d Use map::emplace instead of inserting std::pair (C++11) 2013-09-05 20:59:11 +02:00
Allan Odgaard
5c4573873f Protect grammar_t with mutex
Presently buffer_t::wait_for_repair will use the grammar from the main thread (rather than wait for the parse thread to finish) which does cause a race condition since the parser will now mutate the grammar (graph coloring).

Ideally buffer_t::wait_for_repeat would simply wait for the parser to finish, but I’d prefer to first switch the parser to use GCD.
2013-09-05 17:26:47 +02:00
Allan Odgaard
69be0205ba Fix update of misspelled ranges
If nothing was misspelled in the updated range, and a value existed for the end of the range (indicating that what followed the updated range was misspelled) then that value would be erased.
2013-09-05 12:41:30 +02:00
Adam Strzelecki
b0b182e2e1 Invalidate spelling when ignoring or learning a word
We invalidate the entire buffer since the word can appear in multiple locations. This could be optimized to only invalidate misspelled instances of the ignored or learned word. Likewise, we redraw entire buffer since the refresh macro is not able to handle changes in spelling meta data and calculate minimal refresh region.
2013-09-03 15:06:40 +02:00
Adam Strzelecki
6c6316573f Implement Check Spelling
Now using Edit -> Spelling -> Check Spelling selects next spelling error or one
at caret if it was not yet selected, then shows context menu with correction
suggestions.

This makes checking spelling as easy as tapping Cmd+;

Closes #1103
2013-09-03 15:06:07 +02:00
Allan Odgaard
e4e80a946c Use std::make_shared 2013-09-03 12:27:20 +02:00
Allan Odgaard
282e018ec8 Use format string parser for symbol transformations
This avoids an extra layer of escapes.
2013-08-28 15:27:42 +02:00
Allan Odgaard
7247695f9b Update buffer_t::scopes to new scope_t API 2013-08-28 00:23:08 +02:00
Allan Odgaard
d93b20d571 Use new scope_t API 2013-08-28 00:23:08 +02:00
Allan Odgaard
057096af5b Rename API to make searching easier
Using generic names like ‘append’ is not good when analyzing code for potential refactoring.
2013-08-27 15:30:09 +02:00
Allan Odgaard
a4a5799835 Don’t leave buffer in partial state if failing to parse grammar 2013-08-25 21:13:06 +02:00
Allan Odgaard
97c7a01fe1 Ensure grammar is retained during parsing
Since parsing is done in a separate thread, and it works with pointers, we need to ensure that the grammar is retained for at least as long as the thread lives.
2013-08-24 01:19:29 +02:00
Allan Odgaard
bf1e92b865 Do not use global constructors for fixtures 2013-08-16 22:40:08 +02:00
Allan Odgaard
a52165694c Move crash reporter info support to own framework
This is to avoid cyclic dependencies since it was previously in a somewhat high-level framework, so everything that framework depended on, could not augment crash reports.
2013-08-12 19:32:23 +02:00
Allan Odgaard
a74bfcc206 Remove some uses of foreach() 2013-08-12 19:32:23 +02:00
Allan Odgaard
c080bd8f8b Add storage access info to crash reports 2013-08-10 13:43:59 +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
491fc8a3e3 Add missing semi-colons after assertion 2013-07-21 13:25:28 +02:00
Allan Odgaard
a366a5f9fe Move grammar changed callback from document → buffer 2013-05-15 15:45:36 +07: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
357bc92980 Let buffer_t[size()] return empty string
Previously this was undefined, yet some code could trigger it. E.g. asking for the OS dictionary pop-up with an empty document.

I wasn’t sure if this should actually be allowed but decided that since operator[] returns strings, the “end of buffer” code point is easily defined as an empty string makes the code using this API simpler.
2013-01-08 22:48:08 +01:00
Joachim Mårtensson
d501a4e81d Limit redraw
Do some checks to see if there is more to parse on the following line, before invoking the (layout) callback.
2012-12-24 13:43:22 +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
Allan Odgaard
9dd1585abe fixup! Redo spell checking after changing options 2012-09-10 10:27:42 +02:00
Allan Odgaard
05cf1232a5 Redo spell checking after changing options 2012-09-09 21:10:00 +02:00
Jacob Bandes-Storch
d4ce498f60 Use 64-bit: numeric type fixes
Unfortunately a printf precision specifier (‘%.*s’) can not come with a width specifier so we have to cast to int. The width specifier ‘t’ is used for ptrdiff_t.
The int → NSInteger change fixed a bug with popup menu positioning, but there was no associated warning or error. It's possible there are more such bugs that we haven't found yet!
2012-08-28 21:32:47 +02:00
Jacob Bandes-Storch
0fcb4c2d2c Use libc++: don’t rely on implicit conversions 2012-08-28 20:10:55 +02:00