view: do not highlight matching symbols if selection is active
[vis.git] / register.c
blobb1a445367b256ebebb41fcdaa05bf8bb3166e760
1 #include <stdlib.h>
2 #include <string.h>
4 #include "register.h"
5 #include "buffer.h"
6 #include "text.h"
7 #include "util.h"
9 void register_release(Register *reg) {
10 buffer_release((Buffer*)reg);
13 bool register_put(Register *reg, Text *txt, Filerange *range) {
14 size_t len = range->end - range->start;
15 if (!buffer_grow((Buffer*)reg, len))
16 return false;
17 reg->len = text_bytes_get(txt, range->start, len, reg->data);
18 return true;
21 bool register_append(Register *reg, Text *txt, Filerange *range) {
22 size_t rem = reg->size - reg->len;
23 size_t len = range->end - range->start;
24 if (len > rem && !buffer_grow((Buffer*)reg, reg->size + len - rem))
25 return false;
26 reg->len += text_bytes_get(txt, range->start, len, reg->data + reg->len);
27 return true;