Ejemplo n.º 1
0
static Filerange text_object_customword_outer(Text *txt, size_t pos, int (*isboundary)(int)) {
    Filerange r;
    char c, prev = '0', next = '0';
    Iterator it = text_iterator_get(txt, pos);
    if (!text_iterator_byte_get(&it, &c))
        return text_range_empty();
    if (text_iterator_byte_prev(&it, &prev))
        text_iterator_byte_next(&it, NULL);
    text_iterator_byte_next(&it, &next);
    if (space(c)) {
        /* middle of two words, include leading white space */
        r.start = text_char_next(txt, text_customword_end_prev(txt, pos, isboundary));
        r.end = text_char_next(txt, text_customword_end_next(txt, pos, isboundary));
    } else if (boundary(prev) && boundary(next)) {
        if (boundary(c)) {
            r.start = text_char_next(txt, text_customword_end_prev(txt, pos, isboundary));
            r.end = text_word_start_next(txt, text_customword_end_next(txt, pos, isboundary));
        } else {
            /* on a single character */
            r.start = pos;
            r.end = text_customword_start_next(txt, pos, isboundary);
        }
    } else if (boundary(prev)) {
        /* at start of a word */
        r.start = pos;
        r.end = text_customword_start_next(txt, text_customword_end_next(txt, pos, isboundary), isboundary);
    } else if (boundary(next)) {
        /* at end of a word */
        r.start = text_customword_start_prev(txt, pos, isboundary);
        r.end = text_customword_start_next(txt, pos, isboundary);
    } else {
        /* in the middle of a word */
        r.start = text_customword_start_prev(txt, pos, isboundary);
        r.end = text_customword_start_next(txt, text_customword_end_next(txt, pos, isboundary), isboundary);
    }

    return r;
}
Ejemplo n.º 2
0
size_t text_word_end_next(Text *txt, size_t pos) {
	return text_customword_end_next(txt, pos, is_word_boundary);
}
Ejemplo n.º 3
0
size_t text_longword_end_next(Text *txt, size_t pos) {
	return text_customword_end_next(txt, pos, isspace);
}