2011-09-21 16:37:09 +02:00
|
|
|
#ifndef selectors_hh_INCLUDED
|
|
|
|
#define selectors_hh_INCLUDED
|
|
|
|
|
2012-02-07 15:26:51 +01:00
|
|
|
#include "selection.hh"
|
2013-01-07 18:53:27 +01:00
|
|
|
#include "unicode.hh"
|
2011-09-21 16:37:09 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-03-07 20:20:32 +01:00
|
|
|
template<bool punctuation_is_word>
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_to_next_word(const Buffer& buffer,
|
|
|
|
const Selection& selection);
|
2012-03-07 20:20:32 +01:00
|
|
|
template<bool punctuation_is_word>
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_to_next_word_end(const Buffer& buffer,
|
|
|
|
const Selection& selection);
|
2012-03-07 20:20:32 +01:00
|
|
|
template<bool punctuation_is_word>
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_to_previous_word(const Buffer& buffer,
|
|
|
|
const Selection& selection);
|
2012-10-08 19:12:09 +02:00
|
|
|
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_line(const Buffer& buffer,
|
|
|
|
const Selection& selection);
|
|
|
|
Selection select_matching(const Buffer& buffer,
|
|
|
|
const Selection& selection);
|
2012-10-08 19:12:09 +02:00
|
|
|
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_to(const Buffer& buffer, const Selection& selection,
|
2012-11-30 18:32:49 +01:00
|
|
|
Codepoint c, int count, bool inclusive);
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_to_reverse(const Buffer& buffer, const Selection& selection,
|
2012-11-30 18:32:49 +01:00
|
|
|
Codepoint c, int count, bool inclusive);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_to_eol(const Buffer& buffer, const Selection& selection);
|
|
|
|
Selection select_to_eol_reverse(const Buffer& buffer, const Selection& selection);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2013-05-15 14:24:09 +02:00
|
|
|
enum class ObjectFlags
|
|
|
|
{
|
|
|
|
ToBegin = 1,
|
|
|
|
ToEnd = 2,
|
|
|
|
Inner = 4
|
|
|
|
};
|
|
|
|
constexpr bool operator&(ObjectFlags lhs, ObjectFlags rhs)
|
|
|
|
{ return (bool)((int)lhs & (int) rhs); }
|
|
|
|
constexpr ObjectFlags operator|(ObjectFlags lhs, ObjectFlags rhs)
|
|
|
|
{ return (ObjectFlags)((int)lhs | (int) rhs); }
|
|
|
|
|
2012-03-12 15:23:30 +01:00
|
|
|
template<bool punctuation_is_word>
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_whole_word(const Buffer& buffer, const Selection& selection,
|
|
|
|
ObjectFlags flags);
|
|
|
|
Selection select_whole_sentence(const Buffer& buffer, const Selection& selection,
|
|
|
|
ObjectFlags flags);
|
|
|
|
Selection select_whole_paragraph(const Buffer& buffer, const Selection& selection,
|
|
|
|
ObjectFlags flags);
|
2013-07-22 19:58:16 +02:00
|
|
|
Selection select_whole_indent(const Buffer& buffer, const Selection& selection,
|
|
|
|
ObjectFlags flags);
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_whole_lines(const Buffer& buffer, const Selection& selection);
|
|
|
|
Selection select_whole_buffer(const Buffer& buffer, const Selection& selection);
|
|
|
|
Selection trim_partial_lines(const Buffer& buffer, const Selection& selection);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2013-07-02 14:55:34 +02:00
|
|
|
enum Direction { Forward, Backward };
|
|
|
|
|
|
|
|
template<Direction direction>
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_next_match(const Buffer& buffer, const Selection& selection,
|
|
|
|
const Regex& regex);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2013-06-01 14:22:57 +02:00
|
|
|
SelectionList select_all_matches(const Buffer& buffer, const Selection& selection,
|
2013-04-05 19:28:08 +02:00
|
|
|
const Regex& regex);
|
2012-02-10 00:47:55 +01:00
|
|
|
|
2013-06-01 14:22:57 +02:00
|
|
|
SelectionList split_selection(const Buffer& buffer, const Selection& selection,
|
2013-04-05 19:28:08 +02:00
|
|
|
const Regex& separator_regex);
|
2011-11-21 20:30:44 +01:00
|
|
|
|
2013-01-07 18:53:27 +01:00
|
|
|
using CodepointPair = std::pair<Codepoint, Codepoint>;
|
2013-06-01 14:22:57 +02:00
|
|
|
Selection select_surrounding(const Buffer& buffer, const Selection& selection,
|
2013-01-07 18:53:27 +01:00
|
|
|
const CodepointPair& matching,
|
2013-05-15 14:24:09 +02:00
|
|
|
ObjectFlags flags);
|
2013-01-07 18:53:27 +01:00
|
|
|
|
2011-09-21 16:37:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // selectors_hh_INCLUDED
|