Commit Graph

159 Commits

Author SHA1 Message Date
Allan Odgaard
47ccee4f36 Do not pass variables to run_command callback
The caller already has a copy of the environment variables so this was redundant.
2017-10-02 20:53:04 +02:00
Ronald Wampler
49cc123544 Change std::vector< std::pair<char const*, char const*> > to auto (C++17)
C++17 added a non-const overload for std::string::data().
2017-06-23 10:44:28 -04: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
mathbunnyru
284b5a3896 Slight perfomance improvements 2016-10-18 23:06:48 +02:00
Allan Odgaard
3d39c03ced Remove layout dependency from editor framework 2016-10-01 09:03:22 +02:00
Allan Odgaard
b0c77ff656 Fix minor whitespace issues 2016-08-29 12:44:15 +02:00
Allan Odgaard
16de4dc07a Fix reversed logic
If the pruned ranges are empty we should use the original ranges, not the empty ones.
2016-08-25 09:41:21 +02:00
Allan Odgaard
dbdfa3c6af Add identifying information to perror output 2016-08-21 12:09:30 +02:00
Allan Odgaard
c6bea5c3ff Update LINK dependencies in target files 2016-07-16 13:13:44 +02:00
Allan Odgaard
4854139426 Remove use of document::run from tests 2016-07-16 13:13:44 +02:00
Allan Odgaard
bc344827bc Remove document_t from editor_t
We still link with the document framework because the tests still use document::run().
2016-07-16 13:13:44 +02:00
Allan Odgaard
df35494b80 Remove ng::editor_for_document 2016-07-16 13:13:43 +02:00
Allan Odgaard
4f4eef50f3 Don’t use ng::editor_for_document in tests 2016-07-16 13:13:43 +02:00
Allan Odgaard
bd3acf8e96 Pass lambda (to run commands) to editor_t instead of document_t 2016-07-16 13:13:43 +02:00
Allan Odgaard
e4f4ec603a Don’t let editor_t keep a document_t instance as member data 2016-07-14 12:22:44 +02:00
Allan Odgaard
d25f6aa6cb Pass document_t to macro and execute_dispatch member functions
This way the editor_t instance no longer require a reference to a document instance.
2016-07-14 12:22:44 +02:00
Ronald Wampler
e50dc57db0 Manually release GCD objects in C++ libraries
Since these are pure C++ libraries, they are not managed by ARC. This commit partially reverts 469fd74a7b.
2016-07-14 12:21:28 +02:00
Allan Odgaard
5dccc9f824 Multiple selections copied to find clipboard creates alternation regexp 2016-06-29 14:21:56 +02:00
Allan Odgaard
469fd74a7b Rely on ARC to manage GCD types (10.8) 2016-06-22 20:43:28 +02:00
Allan Odgaard
f5832c975f Add missing include statements 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
4758061719 Do not add final newline to hex dump 2016-06-21 10:51:55 +02:00
Allan Odgaard
2ae0f41a10 Make write_unit_to_fd helper function work with buffer_api_t 2016-06-13 13:01:10 +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
36fedf5bee Change most buffer helper functions to accept buffer_api_t 2016-06-13 13:01:10 +02:00
Allan Odgaard
b59dee8e6d Use semantic assertion 2016-06-13 12:59:31 +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
7400fb63ad fixup! Use empty last line from commands working on multiple selections
We only use the last empty line when there are more than a single line break in the string to be inserted.

The use-case here is having multiple carets and then running a command like “echo foo”. Here we receive “foo\n” which is split into (“foo”, “”), so every second caret would get the empty string inserted.
2015-08-27 23:02:17 +02:00
Allan Odgaard
c603b83050 Don’t use “entire document” fallback input with multiple carets 2015-08-27 22:58:56 +02:00
Allan Odgaard
d02421670f Don’t skip sanitizing ranges when input is “entire document”
Incase there are multiple carets, we’ll get multiple “entire documents” ranges.
2015-08-27 22:55:03 +02:00
Allan Odgaard
98206004dc Support fallback units for multiple carets
For example a command that works on selection but falls back to current word will now also work with multiple carets.
2015-07-31 12:37:29 +02:00
Allan Odgaard
755a9e1f7e Look at all carets to decide if there is a selection
Previously we only looked at the last caret, and if this one was not a selection then we would treat the multiple carets (selection ranges) as nothing being selected, and thus, a command replacing the carets, would not leave anything selected.
2015-07-31 12:18:53 +02:00
Allan Odgaard
3047212ed2 Use empty last line from commands working on multiple selections
When pasting or using Filter Through Command with multiple carets, we ignore a potential final empty line, this is because our text will be something like “foo\nbar\n” and we split on the newline, so we end up with (“foo”, “bar”, “”) and if we have more than two carets, then we insert the empty string for every third caret.

For a command though we expect there is a 1:1 between number of carets and newlines in the result, so we should never skip the last element.
2015-07-31 12:01:46 +02:00
Allan Odgaard
58bacfb763 Command with multiple selections would never select output
This now uses the same logic as with a single selection.
2015-07-31 11:48:56 +02:00
Allan Odgaard
d17f509536 Implement a “deselect last” action method
If there are multiple (discontinuous) selections then this action will drop the last one.

If there are multiple carets (with no selections) then this action will drop all but the first caret.
2015-06-12 14:17:06 +02:00
Allan Odgaard
ec37b09faf Use find clipboard when no string is present in macro
This makes it possible to combine the “Use Selection for Find / Replace” with a non-simple find action (e.g. “Replace All”).

If any find options are set (case sensitive, regular expression, etc.) then these will trump the options set for the entry on the find clipboard.
2015-06-12 14:16:50 +02:00
Allan Odgaard
3c49b4fd69 fixup! Support discontinuous selections in command input API
Fixes textmate/bugs#12
2015-03-26 12:13:36 +07:00
Allan Odgaard
491ef65e65 fixup! Support discontinuous selections in command input API 2015-03-23 11:28:19 +07:00
Allan Odgaard
6e5169a9af When command input is discontinuous then split result on LF
Input range i will get the i’th line from the output (module n, with n being total number of output lines).
2015-03-08 16:51:55 +07:00
Allan Odgaard
100c13f3b5 Let command input be LF separated selections when discontinues
This is only when the command input requested is “selection”. In theory it probably should also do this when input is character, word, or line, but in this case, we can end up with overlapping input ranges.
2015-03-08 16:49:19 +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
2721b22426 Use recede instead of retreat as the inverse of advance 2014-08-21 16:06:34 +02:00
Allan Odgaard
e81286b0cd Remove unused include 2014-05-16 22:11:28 +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
09ea4b3e46 When document changes (on disk) ensure all selections are valid 2014-04-12 14:13:50 +07:00
Allan Odgaard
2bfd8a8118 Give local function ‘static’ storage 2014-04-12 11:23:07 +07:00
Allan Odgaard
f05f77909e No need to sanitize UTF-8 data in editor_t::paste
We now have the clipboard_t::entry_t ensure that the data is UTF-8.
2014-04-05 14:13:40 +07:00