97 Commits

Author SHA1 Message Date
Allan Odgaard
94d3b9b670 Remove old build files 2021-02-15 16:01:50 +01:00
Allan Odgaard
f7d765ba0e Add build files (for new build system) 2021-02-15 16:01:50 +01:00
Allan Odgaard
746b9aba08 Do not declare a few ‘auto’ loop variables as also being ‘const’
This produces a warning with latest Xcode, stating that it produces a copy, as the variable is already const. This does seem a little strange, so it could be a problem with the analyzer, but not marking these variables const shouldn’t affect anything.
2020-09-27 13:57:34 +02:00
Allan Odgaard
066acad708 Remove use of WATCH_LEAKS (C++) 2020-06-05 21:22:50 +07:00
Allan Odgaard
c93030b385 Remove all debug output from custom log macros
This provided value during early development, but has been unused for years, and it would generate too much noise if converted to os_log.

So better to just remove it all and add os_log statements as needed.
2020-06-05 21:22:50 +07:00
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
Ronald Wampler
4aed5b4d9b Add virtual destructors for buffer_api_t and layout_movement_t
This suppresses the warning `Wdelete-non-virtual-dtor`. AFAICT, the existing usage isn't necessarily wrong (i.e., we don't delete through them) so another way to resolve the warning is to mark the classes that inherit from them, e.g., `buffer_t` as `final`.
2018-10-12 19:37:41 +02:00
Allan Odgaard
11bbd59efb Fix potential deadlock when using ⇧⌘T just after loading new document
Using the NSSpellChecker API while main thread is blocked can result in this exception:

    Dispatch Thread Soft Limit Reached: 64
    (too many dispatch threads blocked in synchronous operations)

Therefor we disable spell checking when we are waiting (on main thread) for buffer refresh.

First noticed with macOS 10.12.
2018-06-11 15:29:43 +02:00
mathbunnyru
440414f96c Use nullptr in all C++ files instead of NULL
This brings us a bit of extra type safety, for example where an integer is expected, nullptr should be disallowed by the compiler (unlike NULL).
2016-10-22 21:40:14 +07:00
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
mathbunnyru
284b5a3896 Slight perfomance improvements 2016-10-18 23:06:48 +02:00
Allan Odgaard
1f40f69c07 Only have one parser running at a time (per buffer)
The parser takes time proportional with line length, so if doing a dozen quick edits on a very long line, we could have a dozen parsers running, making the CPU hot.
2016-10-02 22:51:24 +02:00
Allan Odgaard
1a7e6fda4d Add leak detection to our parser result type
This is only so that when e.g. a test leak scope and/or pattern objects, we can determine whether or not it was because a parser was still running when the test finished.
2016-09-12 09:25:12 +02:00
Allan Odgaard
8676827ede Support calling marks_t::prev when there are no marks 2016-09-11 08:32:58 +02:00
Allan Odgaard
9c4589d541 Inform callbacks about updated scopes when interrupting “batch parsing”
We delay updating callbacks until we have parsed 10 lines to avoid line-by-line redraw of the screen, but incase the buffer got mutated during this batch parsing, we would previously restart the parser and forget about the ranges already parsed (that no-one had been told about).
2016-08-28 17:03:58 +02:00
Allan Odgaard
7029992159 Only suppress “did parse” callback when next dirty line is our next line
Incase something earlier in the document became dirty, while in batch update mode, we would keep using the old value of ‘batch_start’ when eventually calling ‘did_update_scopes’.

Under normal circumstances though making the buffer dirty would bump the revision, which drops the batch info, but if e.g. we change grammar, we mark the document dirty without bumping the revision.
2016-08-28 17:03:58 +02:00
Allan Odgaard
8dd33c654c Pass function parameter by value instead of const-reference 2016-08-28 17:03:58 +02:00
Allan Odgaard
5df4da9eb3 Removed unused function parameter 2016-08-28 17:03:58 +02:00
Allan Odgaard
5ff520a403 Add move semantics to storage_t 2016-08-28 09:17:59 +02:00
Allan Odgaard
61aa554dbd Use current run loop instead of main dispatch queue
This change is for the tests which are not being run in the main queue, so it is wrong to assume that we can use the main queue for callbacks.
2016-07-10 11:29:42 +02:00
Allan Odgaard
33aec21dcb Provide buffer_t visitor with offset and a way to stop the visit
If the lambda stops the visit then buffer_t::visit_data will return true, otherwise it returns false.
2016-06-22 23:22:47 +02:00
Allan Odgaard
ff4a796c20 Don’t pass inserted data to the buffer_t metadata hooks
None of the hooks actually use this data and as they are called after the replacement has been done, they can query the buffer, should they require information about its content.

The problem with having to pass the data pointer to the hooks is that there could be future situations in where the buffer’s data is not inserted as one contiguous block of memory, for example we could allow constructing a buffer from a storage_t instance.
2016-06-22 18:31:49 +02:00
Allan Odgaard
61a3a6229a Use constructor delegation for buffer_t 2016-06-22 18:31: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
e8df02f4a4 Let buffer_t delegate operator== to its storage member 2016-06-21 06:19:04 +02:00
Allan Odgaard
da96be12c9 Add comparison operators to storage_t class 2016-06-21 06:18:55 +02:00
Allan Odgaard
aa310c87c5 Add const access to buffer_t’s underlying storage
This is to be used for cheap snapshots.
2016-06-20 18:19:14 +02:00
Allan Odgaard
a2dfe22339 Only expose pointer to const bytes owned by memory_t::helper_t
This guards against misuse of the API, as the compiler should now enforce our append-only design.
2016-06-20 18:19:13 +02:00
Allan Odgaard
608b375b30 Let the constructor of memory_t::helper_t accept an iterator pair
This should make the API more clear, as there is no longer the requirement to copy bytes after constructing memory_t with a non-zero size.
2016-06-20 18:19:13 +02:00
Allan Odgaard
b6861444c8 Replace memory_t::grow with memory_t::append
This makes it clear that we can only append to a memory_t type.
2016-06-20 18:19:13 +02:00
Allan Odgaard
3c3b48f9ad Rename memory_t::free → memory_t::available 2016-06-20 18:19:13 +02:00
Allan Odgaard
a340811771 Allow access to buffer_t’s raw storage via the visitor interface
Previously this was done by exposing iterators but for this to go into the abstract base class we sort of need abstract iterators and that is too complex and visitor interface is sufficient for our single use case.
2016-06-13 13:02:49 +02:00
Allan Odgaard
b5747ec6a6 Return text::indent_t by value so we can create it on the fly 2016-06-13 13:02:49 +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
84ef816ec3 Introduce a buffer_api_t abstract base class
This allows us to use the various helper functions (mainly found in the selection library) with alternative buffer implementations.
2016-06-13 13:01:10 +02:00
Allan Odgaard
32be8a4541 Cap line/column given to buffer_t::convert 2016-06-13 12:59:31 +02:00
Allan Odgaard
20fb69494b Make two buffer_t member functions private
One of them is used by the undo manager so we declare undo_manager_t a friend of buffer_t.
2016-06-13 12:59:31 +02:00
Allan Odgaard
414c336ba9 Remove descendants when mark to remove has a trailing slash 2016-06-02 21:07:43 +02:00
Allan Odgaard
4ee49c95f6 Remove forward declaration of non-existing data type 2016-06-02 21:07:43 +02:00
Allan Odgaard
e83fee564c Refactor: use emplace_back(…) instead of push_back(make_pair(…)) 2016-05-28 22:12:46 +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
e80f1ff49f Leaving out mark type will search for next/previous of any type
This commit is based on work by Ronald Wampler.
2016-02-25 13:11:12 +07: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
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