Commit Graph

328 Commits

Author SHA1 Message Date
Maxime Coste
e51ef6c3c2 Wrap the shell params en env vars in a ShellContext struct 2015-10-22 13:48:57 +01:00
Maxime Coste
2cd0ce41ac Do not try to extend last match when updating regex matches
It does not work well with regexes starting with a lookbehind, as
we would need to reparse from further away, leading to the last
match just being removed. It seems safer not to remove it, as
the motivating use case (multiline macros) is better left to
regions anyway.

Fixes #440
2015-10-18 11:37:04 +01:00
Maxime Coste
3262a6902c Allow custom separator for line numbers
the number_lines highlighter accepts a -separator <arg> switch
to change the default '│' separator.

Fixes #295
2015-09-25 13:47:57 +01:00
Maxime Coste
aa4b98af7c Add utf8::read_codepoint that both gets the codepoint and advance iterator 2015-09-24 23:00:47 +01:00
Maxime Coste
12ef466f3a Avoid redundant calls to get_face in highlight_selections 2015-09-24 13:55:06 +01:00
Maxime Coste
693d9a4861 Store key hash in IdMap 2015-09-16 20:02:12 +01:00
Maxime Coste
ae720b90b1 Small code tweak in show_whitespaces highlighter 2015-09-04 13:47:16 +01:00
Maxime Coste
dc504284c3 Change flag lines highlighter to use faces instead of colors
Fixes #130
2015-08-23 12:13:14 +01:00
Maxime Coste
1af82e2e24 Tweak regex constructor calls 2015-07-25 11:15:03 +01:00
Maxime Coste
2946504a17 Improve column highlighter to cooperate better with other highlighters
Fixes #268
2015-07-23 13:58:23 +01:00
Maxime Coste
17e3be48a5 Transform boost/std regex_error to Kakoune::regex_error at Regex construction
Fixes #318
2015-07-14 21:06:41 +01:00
Maxime Coste
1d1927647a Fix formatting 2015-07-09 13:53:21 +01:00
Maxime Coste
6870895374 Add support for hex formatting 2015-06-22 13:56:00 +01:00
Maxime Coste
2c15dbe6b2 Fix regions highlighter docstring 2015-06-11 19:04:30 +01:00
Maxime Coste
f19bb4fe6d Port more code to use the format function instead of adhoc string concat 2015-06-01 19:06:35 +01:00
Maxime Coste
993e842fdf Retreat ! go back to C++11 only code
This reverts commit b42de85031.
2015-05-26 18:42:09 +01:00
Maxime Coste
7b7427e1a6 Add missing 'override' specifiers 2015-05-25 13:54:18 +01:00
Maxime Coste
b42de85031 Migrate code to c++14 2015-05-25 13:51:17 +01:00
Maxime Coste
0ee95d02c4 line highlighter highlights up to window's end 2015-05-05 20:21:17 +01:00
Maxime Coste
1a1db1cb3a {line,column}_option highlighters use an expanded string instead of an option name
That allows access to non option values, such as cursor_column or cursor_line with
:addhl line '%val{cursor_line}' default,rgb:404040

Fixes #38
2015-05-04 17:12:51 +01:00
Maxime Coste
7f0588c02c Dont use a regex to match face spec for regex highlighter 2015-05-03 18:22:49 +01:00
Maxime Coste
4e89cbfe83 Add a column_option highlighter that highlight a column given in an option 2015-04-30 19:18:20 +01:00
Maxime Coste
5bff742e0a Replace some String temporaries with StringViews 2015-04-27 16:46:57 +01:00
Maxime Coste
bbefde9379 Move Colors enum class as NamedColor enum inside Color struct 2015-04-25 10:47:39 +01:00
Maxime Coste
4e1ed13f25 Use a struct for RangeAndMatches 2015-04-23 21:44:20 +01:00
Maxime Coste
045272ab8a Use a struct for BufferRange rather than std::pair 2015-04-23 21:38:45 +01:00
Maxime Coste
e0f7a6f0be Remove simple_factory for highlighters 2015-04-23 20:27:52 +01:00
Maxime Coste
f714766854 Fix search highlighter wrong code 2015-04-19 15:19:39 +01:00
Maxime Coste
d1b81c8f8a minor cleanup 2015-03-27 13:47:02 +00:00
Maxime Coste
c2150dd163 Rework show_matching highlighter implementation 2015-03-27 13:18:06 +00:00
Maxime Coste
4188335b51 Fix segfault in highlighting 2015-03-23 19:21:35 +00:00
Maxime Coste
f5da1671fd Refactor number_line higlighter, use a switch to higlhight the cursor line 2015-03-19 00:31:11 +00:00
Maxime Coste
006f8ca588 Merge remote-tracking branch 'ekie/relative_line_numbers' 2015-03-19 00:03:59 +00:00
Eike Plack
5627d33ac3 Add support for relative line numbers 2015-03-18 22:07:57 +01:00
Maxime Coste
b5854ece43 Change ParameterParser switch interface, use an Optional<StringView>
Merge has_option and option_value into a single method get_switch.
2015-03-14 19:16:46 +00:00
Maxime Coste
65fd0df041 More code style cleanup 2015-03-14 17:30:44 +00:00
Maxime Coste
3c1a325b6f Refactor String, use a common StringOps interface, hide std::string 2015-03-10 19:50:22 +00:00
Maxime Coste
1cec8df45e ArrayView content is not const anymore
As in upcoming std c++ array_view, ArrayView<T> points to mutable
data, use ArrayView<const T> or alias ConstArrayView<T> for const
data.
2015-03-09 13:54:09 +00:00
Maxime Coste
6c65c5e080 Add docstrings to highlighters, displayed by addhl help 2015-02-19 13:54:03 +00:00
Maxime Coste
fd3365deb1 Remove unused RegionMatch::timestamp 2015-02-17 13:56:26 +00:00
Maxime Coste
59177c12f9 Replace vector of vector in RegexHighlighter with a single vector. 2015-02-17 13:50:31 +00:00
Maxime Coste
2f890f12c6 Fix RegexHighlighter cache invalidation when changing the regex 2015-02-16 22:43:14 +00:00
Maxime Coste
8f6dab08d6 Try to limit the quantity of buffer reparsed by RegexHighlighter 2015-02-16 19:13:55 +00:00
Maxime Coste
ce950ec9f7 Fix RegexHighlighter in a few corner cases 2015-02-16 13:25:17 +00:00
Maxime Coste
53f1c35013 Fix caching of regex highlighter matches
The previous method was constantly invalidating cache when used in
conjunction with region highlighters.
2015-02-15 19:42:48 +00:00
Maxime Coste
2a28260f87 Extend line numbering max width to 15 char 2015-02-03 13:44:42 +00:00
Maxime Coste
b4442055e8 Fix recursive regions matching when a recursive matches just before an end
%sh{ $test {} $test } was incorrrectly closing the %sh block at the first {
because it was immediatly followed by a }.
2015-02-02 13:48:27 +00:00
Maxime Coste
09fc14be4b Small refactor in highlighters.cc 2015-02-01 23:30:58 +00:00
Maxime Coste
4d6b8a70e1 Fix highlighter update with new LineModification behaviour 2015-02-01 23:19:07 +00:00
Maxime Coste
0b4ecef2d2 Rewrite line modifications, hopefully with easier to comprehend code 2015-01-31 23:50:24 +00:00
Maxime Coste
19797ae8d6 Fix flag line highlighting 2015-01-12 19:35:31 +00:00
Maxime Coste
da562e03a0 replace all std::vector with Vector 2015-01-12 13:58:41 +00:00
Maxime Coste
0bdf1778cb Some more memory tracking 2015-01-12 13:32:14 +00:00
Maxime Coste
295a97f2a6 Rename memoryview to ArrayView 2015-01-06 13:43:37 +00:00
Maxime Coste
c698032ace Style tweak 2014-12-31 13:09:35 +00:00
Maxime Coste
b0fef1a962 Rename id_map to IdMap 2014-12-23 22:51:00 +00:00
Maxime Coste
fb611e2f62 Use an id_map directly for HighlighterRegistry rather than the FunctionRegistry class 2014-12-23 22:15:53 +00:00
Maxime Coste
b6ff15aa75 Unify completion from container content logic 2014-12-23 13:54:09 +00:00
Maxime Coste
ebecd60eb8 Rework hashing, use a more extensible framework similar to n3876 proposal
std::hash specialization is a pain to work with, stop using that, and
just specialize a 'size_t hash_value(const T&)' free function.
2014-12-16 18:57:19 +00:00
Maxime Coste
def4221ac7 Pass a BufferRange to highlighters, fix subregions
Regions highlighter can now correctly be applied to only subrange
of the buffer, fixing some corner cases in recursive regions.
2014-12-02 19:56:17 +00:00
Maxime Coste
e38ba6ce3d Add scope class and encapsulate Options, Keymaps, Aliases and Hooks in it 2014-10-30 14:04:57 +00:00
Maxime Coste
b2e90fe21e Refactor highlighters, use an interface with virtual methods 2014-10-22 13:54:03 +01:00
Maxime Coste
fa85f0fc32 Refactor regex uses, do not reference boost except in regex.hh 2014-10-13 13:14:23 +01:00
Maxime Coste
d4a84125ef Use InternedStrings for buffer contents 2014-10-03 13:39:13 +01:00
Maxime Coste
f738316689 small refactor in highlighters 2014-09-19 13:45:11 +01:00
Maxime Coste
5092494427 Add support for target column preservation
Fixes #64
2014-09-09 19:42:57 +01:00
Maxime Coste
032b621150 Use strongly typed enum for Face Attribute, add Dim 2014-07-15 20:11:47 +01:00
Maxime Coste
ac5cbba0ae Remove region highlighter, rename multi_regions to regions, cleanup 2014-07-14 21:42:19 +01:00
Maxime Coste
ec37adc523 Fix bug in nested highlighting 2014-07-14 21:41:29 +01:00
Maxime Coste
d5d76721b0 Avoid infinite loop in MultiRegionHighlighter when regexes generate empty matches 2014-07-14 20:46:46 +01:00
Maxime Coste
cbfceba149 Do not resolve faces in highlighter factories, defer to actual highlighting 2014-07-13 16:52:51 +01:00
Maxime Coste
d78ece490f Rename RegexColorizer to RegexHighlighter 2014-07-12 13:57:16 +01:00
Maxime Coste
72ccb9bce6 Refactor RegexColorizers face handling 2014-07-12 11:19:35 +01:00
Maxime Coste
a32b49acd1 Rename ColorPair to Face and ColorRegistry to FaceRegistry
Face also stores the attributes
2014-07-11 00:27:43 +01:00
Maxime Coste
ed68d1ff28 utf8: use end of sequence iterators for more security 2014-07-05 12:10:06 +01:00
Maxime Coste
7aa78d726a fix potential infinite loop in show_matching highlighter 2014-06-27 21:10:09 +01:00
Maxime Coste
7235180614 Use main selection index as default when accessing only one register value
Fixes #117
2014-06-21 11:31:08 +01:00
Maxime Coste
e202b7af50 Add a line_option highlighter that highlight the line stored in an int option
Use it to highlight the current error in the *make* buffer
2014-06-18 20:50:39 +01:00
Maxime Coste
6f2569ff30 Color Default now means 'keep as is' for most highlighters 2014-06-18 20:33:23 +01:00
Maxime Coste
54590f5d79 Minor code cleanup in highlighters 2014-06-18 20:31:49 +01:00
Maxime Coste
fc6a16a571 Fix corner cases in region highlighting 2014-06-16 19:41:07 +01:00
Maxime Coste
51da452dc4 Merge branch 'master' into hierarchical-highlighters 2014-06-16 01:06:09 +01:00
Maxime Coste
2acfe85281 Highlight selection cursors in a second pass
This allows cursors to overlap on next selection and still be
visible.
2014-06-16 00:59:05 +01:00
Maxime Coste
205e8b2889 Refactor highlighter command completions 2014-06-15 16:04:38 +01:00
Maxime Coste
9130f0334b Remove defhl, use addhl -group 2014-06-12 22:35:40 +01:00
Maxime Coste
dac5e89e14 Add MultiRegionHighlighter
MultiRegionHighlighter provides a way to segment the buffer in
logical regions using the common left-most rule for finding the
next region. It then provides highlighting groups for each region
that can be filled.
2014-06-11 23:29:23 +01:00
Maxime Coste
0faf7ff5e6 Refactor region highlighter, extract code to helper classes 2014-06-11 23:29:15 +01:00
Maxime Coste
0a76fe3040 Add support for recursion in region highlighter
An optional parameter defines the recursion regex, that match
potential closers.

For example, %sh{ ... } blocks support nested { }, so defining \{
as the recurse regex make the region highlighter correctly match
%sh{ ... { ... } ... } constructs
2014-06-11 00:23:44 +01:00
Maxime Coste
37d66b1e0b Convert Region highlighter to a HierarchicalHighlighter
add a region using addhl region <id> <begin_regex> <end_regex>
then fill the region with addhl -group <id>/content ...
2014-06-10 22:02:42 +01:00
Maxime Coste
4c942c4a3a ref highlighter tolerates unexisting reference 2014-06-10 22:02:08 +01:00
Maxime Coste
ca93ae807d Add a fill highlighter that just fills the display buffer 2014-06-10 21:46:16 +01:00
Maxime Coste
479c31b571 Replace FunctionGroup template with HighlighterGroup class 2014-06-10 19:58:02 +01:00
Maxime Coste
8d9ed5e8c7 Fix in region highlighter 2014-06-02 15:42:03 +01:00
Maxime Coste
ce469398c5 Revert "Use Modification for region highlighter"
This reverts commit aa64851de6.

Conflicts:
	src/highlighters.cc
2014-05-26 21:02:09 +01:00
Maxime Coste
0a060b62a2 Merge branch 'master' into remove-buffer-change-listener 2014-05-25 20:01:55 +01:00
Maxime Coste
fc0700d1fd Fix segfault in region highlighter 2014-05-24 17:17:14 +01:00
Maxime Coste
aa64851de6 Use Modification for region highlighter 2014-05-21 23:35:11 +01:00
Maxime Coste
55959f2cb1 Make expand_unprintable more tolerant to invalid utf8 2014-05-21 00:24:58 +01:00
Maxime Coste
03e5264df4 Remove per lines timestamp in Buffer 2014-05-17 12:17:05 +01:00
Maxime Coste
211b78f536 Merge branch 'master' into remove-buffer-change-listener
Conflicts:
	src/highlighters.cc
2014-05-17 11:39:56 +01:00
Maxime Coste
2f1388df7b replace LineChangeWatcher with a free function compute_line_modifications 2014-05-14 21:19:19 +01:00
Maxime Coste
34e1c2ddd5 Fix RegexColorizer cache handling 2014-05-14 19:22:42 +01:00
Maxime Coste
016ede38d1 Fix show_matching highlighter when opening char is the first buffer char
Fixes #119
2014-05-13 19:45:32 +01:00
Maxime Coste
6b42c48c3f Refactor DynamicRegexHighlighter, search hl uses Search colalias
fixes #122
2014-05-13 19:35:28 +01:00
Maxime Coste
c7d24ac7db Add a show_whitespaces highlighter 2014-05-09 13:50:12 +01:00
Maxime Coste
8546788b43 Refactor LineAndColumn coordinates
BufferCoord -> ByteCoord
DisplayCoord -> CharCoord

Moved their definition along with LineAndColumn into coord.hh
2014-05-07 19:53:45 +01:00
Maxime Coste
26dd21706e Replace some typedefs with usings 2014-05-01 19:03:13 +01:00
Maxime Coste
49bc7f8767 minor formatting cleanup 2014-04-27 12:37:58 +01:00
Maxime Coste
e94a82ac98 More OSX fixes 2014-04-02 22:52:00 +01:00
Maxime Coste
6d651c59d0 regionref highlighter just ignore invalid references
fixes #68
2014-02-25 00:19:31 +00:00
Maxime Coste
2159fc9563 Rename selections first,last to more explicit anchor,cursor 2014-01-28 19:06:52 +00:00
Maxime Coste
e364137196 Fix compilation with clang 3.4 2014-01-27 20:28:38 +00:00
Maxime Coste
a96b2d3cd2 Rework regions highlighter, refactor and extract line tracking 2014-01-27 19:51:58 +00:00
Maxime Coste
2cbb0bb27f Add a show_matching highlighter 2014-01-20 21:02:43 +00:00
Maxime Coste
2ac545d306 RegionHighlighter: correct coordinates that are one past end of line
As region highlighters store per lines matches, end of line ones
are not valid buffer coordinates and must be corrected as begining
of next line.
2014-01-18 11:47:18 +00:00
Maxime Coste
5cffc48efc Pass a HighlightFlags parameter to highlighters
When only highlighting for finding character position on screen
pass HighlightFlags::MoveOnly so that non moving highlighters do
not need to run.
2014-01-18 01:59:37 +00:00
Maxime Coste
e1eec8903a only highlight actually displayed regions 2014-01-17 23:39:01 +00:00
Maxime Coste
a6b386e9b8 RegionHighlighter: Find the lines to be reparsed using the changes 2014-01-15 20:28:58 +00:00
Maxime Coste
c2f18e6e78 Use inplace_merge for sorting matches in region highlighter 2014-01-14 19:42:57 +00:00
Maxime Coste
86eaa64982 Optimization and code cleanup in the region highlighter. 2014-01-13 21:40:02 +00:00
Maxime Coste
737837216b minor code cleanup 2014-01-12 21:24:59 +00:00
Maxime Coste
faabd24e11 Region highlighters track line changes in the buffer
This way, region highlighters only need to regex-parse lines that
actually changed. matches on lines that just moved around but whose
content did not change can be updated simply by updating their line
coordinate.
2014-01-12 16:28:11 +00:00
Maxime Coste
1d51e6922a minor code cleanup 2014-01-10 13:36:40 +00:00
Maxime Coste
d466193ee7 Use a per line caching strategy for region highlighter 2014-01-09 22:52:39 +00:00
Maxime Coste
d96b5aa04d Move highlighter cache logic to BufferSideCache template 2014-01-09 22:51:23 +00:00
Maxime Coste
85cc740de0 Use Buffer values for storing highlighting caches 2014-01-09 21:57:37 +00:00
Maxime Coste
aadbd390c7 Use wide character function for categorizing codepoints
Previously we used the is... rather than isw...
These functions were not supporting non ascii characters correctly
2014-01-05 15:14:58 +00:00
Maxime Coste
cb324a4b88 highlighters: add some optimization flags to regexes 2013-12-17 20:03:54 +00:00
Maxime Coste
d1ac813f61 Pass a Context rather than a Window to highlighters 2013-12-16 23:24:08 +00:00
Maxime Coste
e369b60258 Remove insert_hide_sel option 2013-12-15 14:57:55 +00:00
Maxime Coste
6afef079b6 Remove Editor::main_selection(|index), directly use the SelectionList method 2013-12-14 14:38:17 +00:00
Maxime Coste
ed484dc333 Region highlighter takes regexes for region start/end 2013-12-12 22:49:41 +00:00
Maxime Coste
277b02eee6 Add experimental region_ref highlighter
highlights a region using another highlighter.
2013-12-11 23:19:24 +00:00
Maxime Coste
35f12bc5a0 Use a cache for region highlighter 2013-12-04 18:52:16 +00:00
Maxime Coste
8b2f340238 Add basic region highlighter 2013-12-04 00:48:46 +00:00
Maxime Coste
45d5dbcc85 Add support for defining and referencing highlighters
* defhl <name> defines a shared highlighter
* addhl -def-group <name> adds highlighters to the defined highlighter
* addhl ref <name> add the defined highlighter to the window's ones
2013-12-03 22:07:23 +00:00
Maxime Coste
d880465f38 Do not pass a window to highlighters factories 2013-11-28 18:48:40 +00:00
Maxime Coste
a9d832965f RegexColorizer maintains a per buffer cache 2013-11-28 18:48:39 +00:00
Maxime Coste
255a747fdd Simplify FlagLines, do not try to update the option 2013-11-28 18:48:39 +00:00
Maxime Coste
dd6462ed57 regex option highlighter use runtime window rather than creation time one 2013-11-04 22:02:44 +00:00
Maxime Coste
eedd37c09a memoryview: always pass by value 2013-07-26 01:50:36 +02:00
Maxime Coste
3862b5cbb8 LineAndColumns: always pass by value 2013-07-26 01:50:09 +02:00
Maxime Coste
8f73d3c173 fix last eol matching in regex highlighters 2013-07-25 00:18:50 +02:00
Maxime Coste
d6425f1d50 merge AtomContent into DisplayAtom 2013-07-24 13:55:57 +01:00
Maxime Coste
c7e52a650d DisplayLine no longer map to a single buffer line, but to a buffer range 2013-07-24 01:33:12 +02:00
Maxime Coste
5a6922a045 expand_unprintable: use iscntrl rather than isprint which does not work as expected 2013-07-23 20:42:35 +02:00
Maxime Coste
c1b2f7ef6a use C locale function instead of C++ ones 2013-07-02 19:48:04 +01:00
Maxime Coste
245e68e26e utf8_iterators: rename underlying_iterator to base 2013-06-06 19:44:07 +02:00
Maxime Coste
51acd456cc remove BufferIterator::{line,column}() 2013-06-04 18:53:28 +02:00
Maxime Coste
c4f9253634 Remove Buffer::iterator_at_line_{begin,end}, use iterator_at(line{,+1}) 2013-06-04 14:21:07 +02:00