Commit Graph

32 Commits

Author SHA1 Message Date
Maxime Coste
2fa55be40a Default comparison operators that can be 2023-10-25 21:06:52 +11:00
Maxime Coste
96884193dd Remove redundant comparison operators
Since C++20 (a != b) get automatically rewritten as !(a == b) if
the != operator does not exist.
2023-10-25 20:40:04 +11:00
Hampus Fröjdholm
18a84c6b3c Fix compilation failure with clang 12 and debug=yes
The pointer type alias was missing from FlattenedView::Iterator causing
std::iterator_traits to be an empty class.
2022-10-02 14:04:07 +02:00
Johannes Altmanninger
1529cfb2c2 Stop using deprecated std::iterator
As reported in #4615 and others, GCC 12.1 emits deprecation warnings
because we use std::iterator. Replace it with the modern equivalent.

Closes #4615
2022-05-21 15:10:03 +02:00
Maxime Coste
81b520847c Introduce a flatten range adapter and use it in execute_keys_cmd
This avoids allocating a KeyList vector in which to flatten all
the different arguments and simplifies the client logic.
2022-04-25 19:27:16 +10:00
Maxime Coste
91550639bb More C++20 refactorings
Use CTAD instead of make functions, requires instead of enable_if
2021-11-21 11:41:50 +11:00
Maxime Coste
bea23c6bf2 Use std::remove_cvref instead of std::decay 2021-11-21 09:44:57 +11:00
Frank LENORMAND
16dfe977b2 src: Make gf open all selected paths
The buffer whose path is under the main selection will be focused
after all others have been opened.

Closes #2164
2021-10-24 09:01:24 +02:00
Frank LENORMAND
0af234a329 src: Implement the enumerate() range filter 2021-10-21 10:58:46 +02:00
Maxime Coste
94f33bb638 Add a range based remove_if overload 2020-05-29 11:59:03 +10:00
Maxime Coste
3ef8a6160d Small code style tweak in ranges.hh 2020-02-18 19:28:41 +11:00
geppettodivacin
39a2ab84fa Use ReverseView to perform fewer allocations
The first attempt at a bug fix for @ symbols in selection buffer names
worked, but it was very inefficient. In particular, it allocated three
different vectors, and we really only needed the correct elements.
Manipulating iterators to give us the right slices of the existing
vector is far more efficient.

By reversing the original content and taking the last two, we're able to
get the number of selections and main selection without too much hassle.
The buffer name is everything from the start of the content to the
selection count. This gets us through with only one vector allocation.

Credit to @mawww for the optimization idea and for fixing my types.
2020-02-02 22:12:18 -06:00
geppettodivacin
5596b4b2b9 Add support for @ symbols in selection buffer
The selection descriptions use the format
`<buffer>@<timestamp>@<main_index>`. This fails when file paths have `@`
symbols in them: the parser splits on `@` symbols and finds more values
than it expects.

We here modify the behavior to require *at least* two @ symbols, using
the last two for `<timestamp>` and `<main_index>` and leaving the
remaining text for the <buffer>. This should work for any number of `@`
symbols, since `<timestamp>` and `<main_index>` are numbers and should
never contain `@` symbols.
2020-01-26 16:03:03 -06:00
Maxime Coste
f119fb9524 Aggregatify ConcatView 2019-11-10 12:04:44 +11:00
Jason Felice
d26bb0ce2b Add static or const where useful 2019-11-09 12:53:45 -05:00
Maxime Coste
d2dac558e7 Add a gather overload that infer element type 2019-06-10 21:57:06 +10:00
Maxime Coste
b91367f8a3 Replace std::mem_fn with custom lambda in ranges 2019-01-24 23:24:50 +11:00
Maxime Coste
36e9e7eaf9 Change pipe diffing to work linewise
This should greatly improve performances as we only need to diff
lines instead of individual characters.

Closes #2678
Fixes #2037
2019-01-23 20:20:54 +11:00
Maxime Coste
0919679e0d Make TransformView iterator's category match its underlying's
In particular, this make gathering a transformed range to a vector
faster because we can use the random access nature of underlying
iterator to get the size to allocate in the vector upfront.
2018-07-26 20:58:55 +10:00
Maxime Coste
087a940fbe Add 'skip(size_t)' range utility to skip a number of elements 2018-07-05 07:54:28 +10:00
Maxime Coste
e207bd30d4 Extract a for_n_best algorithm from completion function
Provide the heap based n-best algorithm through a nice interface.
2018-04-19 07:58:42 +10:00
Maxime Coste
49c52b025f Remove contains_that and use any_of to be closer to the c++ stdlib 2018-03-25 16:47:19 +11:00
Maxime Coste
435b5b7ff9 Unify code that validates identifiers in Kakoune
Session/Client/User modes names are now requiered to be "identifiers"
they must be in [a-zA-Z0-9_-]. Option names are the same except they
do not allow '-' as they need to be made available through the env vars
and '-' is not supported there.

Fixes #1946
2018-03-25 16:35:33 +11:00
Maxime Coste
a480e566dc ranges: Add transform overload taking directly a pointer to member
This overload will forward to the general transform implementation
using std::mem_fn to generate a callable.
2018-03-13 14:24:03 +11:00
Maxime Coste
a6fd70c456 Ranges: Fix copiability of some range view iterators
Some iterators were refering to to their view with a const ref, this
was making them non-copiable. Change those const ref into const pointers
in order to fix that.
2018-02-28 15:16:49 +11:00
Maxime Coste
6239357e99 ranges: Support temporary parameters passed to concatenated 2018-02-20 21:55:06 +11:00
Maxime Coste
e74b581b0a Save/restore main selection from/to strings
Always consider that the first selection in the list is the main
one, save selections that way.

This approach was suggested by PR #1786 but the implementation here
is different, and is used more generally whenever we save selections
to strings.

This is also the prefered way to work only on the main selection:
save selections with Z, reduce to main with <space>, restore with z.

Closes #1786
Fixes #1750
2018-01-12 07:51:19 +11:00
Maxime Coste
bedb98220c Ranges: add unit test and fix corner case in split view 2017-12-07 01:58:19 +08:00
Maxime Coste
99636c6230 Remove Vector returning split functions, use range adaptor
Do not allocate temporary vectors to store splitted data, use the
'split' range adaptor along with transform(unescape) to provide the
same feature with less allocations.
2017-12-06 17:18:44 +08:00
Maxime Coste
274367116a Replace uses of getpwuid which is incompatible with static linking
Introduce a get_user_name function which parses '/etc/passwd' to find
the username associated with a user id.
2017-12-04 15:19:57 +08:00
Maxime Coste
39e63cf518 Append '/' to highlighter group completion candidates 2017-11-02 18:05:18 +08:00
Maxime Coste
ab6a999431 Rename containers.hh to ranges.hh (and Container to Range) 2017-08-29 15:23:03 +07:00