#ifndef selectors_hh_INCLUDED #define selectors_hh_INCLUDED #include "selection.hh" namespace Kakoune { class Regex; class Context; inline Selection keep_direction(Selection res, const Selection& ref) { if ((res.cursor() < res.anchor()) != (ref.cursor() < ref.anchor())) std::swap(res.cursor(), res.anchor()); return res; } template Optional select_to_next_word(const Context& context, const Selection& selection); template Optional select_to_next_word_end(const Context& context, const Selection& selection); template Optional select_to_previous_word(const Context& context, const Selection& selection); Optional select_line(const Context& context, const Selection& selection); Optional select_matching(const Context& context, const Selection& selection); Optional select_to(const Context& context, const Selection& selection, Codepoint c, int count, bool inclusive); Optional select_to_reverse(const Context& context, const Selection& selection, Codepoint c, int count, bool inclusive); template Optional select_to_line_end(const Context& context, const Selection& selection); template Optional select_to_line_begin(const Context& context, const Selection& selection); Optional select_to_first_non_blank(const Context& context, const Selection& selection); enum class ObjectFlags { ToBegin = 1, ToEnd = 2, Inner = 4 }; constexpr bool with_bit_ops(Meta::Type) { return true; } template Optional select_word(const Context& context, const Selection& selection, int count, ObjectFlags flags); Optional select_number(const Context& context, const Selection& selection, int count, ObjectFlags flags); Optional select_sentence(const Context& context, const Selection& selection, int count, ObjectFlags flags); Optional select_paragraph(const Context& context, const Selection& selection, int count, ObjectFlags flags); Optional select_whitespaces(const Context& context, const Selection& selection, int count, ObjectFlags flags); Optional select_indent(const Context& context, const Selection& selection, int count, ObjectFlags flags); Optional select_argument(const Context& context, const Selection& selection, int level, ObjectFlags flags); Optional select_lines(const Context& context, const Selection& selection); Optional trim_partial_lines(const Context& context, const Selection& selection); void select_buffer(SelectionList& selections); enum Direction { Forward, Backward }; template Selection find_next_match(const Context& context, const Selection& sel, const Regex& regex, bool& wrapped); void select_all_matches(SelectionList& selections, const Regex& regex, int capture = 0); void split_selections(SelectionList& selections, const Regex& regex, int capture = 0); Optional select_surrounding(const Context& context, const Selection& selection, StringView opening, StringView closing, int level, ObjectFlags flags); } #endif // selectors_hh_INCLUDED