2011-09-21 16:37:09 +02:00
|
|
|
#ifndef selectors_hh_INCLUDED
|
|
|
|
#define selectors_hh_INCLUDED
|
|
|
|
|
2019-02-14 15:53:36 +01:00
|
|
|
#include "enum.hh"
|
2019-02-04 02:52:55 +01:00
|
|
|
#include "optional.hh"
|
|
|
|
#include "meta.hh"
|
|
|
|
#include "unicode.hh"
|
|
|
|
#include "vector.hh"
|
2011-09-21 16:37:09 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2019-02-09 04:25:40 +01:00
|
|
|
struct Selection;
|
2019-02-04 02:52:55 +01:00
|
|
|
class Buffer;
|
2017-01-01 20:14:18 +01:00
|
|
|
class Regex;
|
2017-06-26 15:56:50 +02:00
|
|
|
class Context;
|
2017-01-01 20:14:18 +01:00
|
|
|
|
2019-02-04 02:52:55 +01:00
|
|
|
Selection keep_direction(Selection res, const Selection& ref);
|
2014-09-18 01:34:23 +02:00
|
|
|
|
2013-10-07 19:44:22 +02:00
|
|
|
template<WordType word_type>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_next_word(const Context& context, const Selection& selection);
|
2013-12-14 15:49:10 +01:00
|
|
|
|
2013-10-07 19:44:22 +02:00
|
|
|
template<WordType word_type>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_next_word_end(const Context& context, const Selection& selection);
|
2013-12-14 15:49:10 +01:00
|
|
|
|
2013-10-07 19:44:22 +02:00
|
|
|
template<WordType word_type>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_previous_word(const Context& context, const Selection& selection);
|
2012-10-08 19:12:09 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_line(const Context& context, const Selection& selection);
|
2012-10-08 19:12:09 +02:00
|
|
|
|
2018-09-30 08:41:17 +02:00
|
|
|
template<bool forward>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_matching(const Context& context, const Selection& selection);
|
2017-03-03 21:12:52 +01:00
|
|
|
|
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to(const Context& context, const Selection& selection,
|
2012-11-30 18:32:49 +01:00
|
|
|
Codepoint c, int count, bool inclusive);
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_reverse(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
Codepoint c, int count, bool inclusive);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2015-06-08 14:51:06 +02:00
|
|
|
template<bool only_move>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_line_end(const Context& context, const Selection& selection);
|
2015-06-08 14:51:06 +02:00
|
|
|
|
|
|
|
template<bool only_move>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_line_begin(const Context& context, const Selection& selection);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_to_first_non_blank(const Context& context, const Selection& selection);
|
2017-01-23 00:53:08 +01:00
|
|
|
|
2013-05-15 14:24:09 +02:00
|
|
|
enum class ObjectFlags
|
|
|
|
{
|
|
|
|
ToBegin = 1,
|
|
|
|
ToEnd = 2,
|
|
|
|
Inner = 4
|
|
|
|
};
|
2014-10-23 19:55:45 +02:00
|
|
|
|
2017-03-15 18:55:34 +01:00
|
|
|
constexpr bool with_bit_ops(Meta::Type<ObjectFlags>) { return true; }
|
2013-05-15 14:24:09 +02:00
|
|
|
|
2019-02-14 15:53:36 +01:00
|
|
|
constexpr auto enum_desc(Meta::Type<ObjectFlags>)
|
|
|
|
{
|
|
|
|
return make_array<EnumDesc<ObjectFlags>, 3>({
|
|
|
|
{ ObjectFlags::ToBegin, "to_begin" },
|
|
|
|
{ ObjectFlags::ToEnd, "to_end" },
|
|
|
|
{ ObjectFlags::Inner, "inner" },
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-10-07 19:44:22 +02:00
|
|
|
template<WordType word_type>
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_word(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int count, ObjectFlags flags);
|
2013-12-14 15:49:10 +01:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_number(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int count, ObjectFlags flags);
|
2014-05-27 10:50:12 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_sentence(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int count, ObjectFlags flags);
|
2014-05-26 22:44:57 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_paragraph(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int count, ObjectFlags flags);
|
2014-05-26 22:44:57 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_whitespaces(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int count, ObjectFlags flags);
|
2014-06-11 15:00:45 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_indent(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int count, ObjectFlags flags);
|
2014-05-26 22:44:57 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_argument(const Context& context, const Selection& selection,
|
2017-03-03 21:12:52 +01:00
|
|
|
int level, ObjectFlags flags);
|
2015-06-25 15:44:43 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_lines(const Context& context, const Selection& selection);
|
2014-05-26 22:44:57 +02:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
trim_partial_lines(const Context& context, const Selection& selection);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2018-12-27 01:29:33 +01:00
|
|
|
enum class RegexMode;
|
2013-07-02 14:55:34 +02:00
|
|
|
|
2018-12-27 01:29:33 +01:00
|
|
|
template<RegexMode mode>
|
2017-06-26 15:56:50 +02:00
|
|
|
Selection find_next_match(const Context& context, const Selection& sel,
|
2017-03-03 21:12:52 +01:00
|
|
|
const Regex& regex, bool& wrapped);
|
2013-12-14 19:39:03 +01:00
|
|
|
|
2019-02-04 02:52:55 +01:00
|
|
|
Vector<Selection, MemoryDomain::Selections>
|
|
|
|
select_matches(const Buffer& buffer, ConstArrayView<Selection> selections,
|
|
|
|
const Regex& regex, int capture = 0);
|
|
|
|
|
|
|
|
Vector<Selection, MemoryDomain::Selections>
|
|
|
|
split_on_matches(const Buffer& buffer, ConstArrayView<Selection> selections,
|
|
|
|
const Regex& regex, int capture = 0);
|
2011-11-21 20:30:44 +01:00
|
|
|
|
2017-03-03 21:12:52 +01:00
|
|
|
Optional<Selection>
|
2017-06-26 15:56:50 +02:00
|
|
|
select_surrounding(const Context& context, const Selection& selection,
|
2017-12-03 10:06:11 +01:00
|
|
|
const Regex& opening, const Regex& closing, int level,
|
2017-10-28 07:28:15 +02:00
|
|
|
ObjectFlags flags);
|
2013-01-07 18:53:27 +01:00
|
|
|
|
2011-09-21 16:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // selectors_hh_INCLUDED
|