aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-13 23:00:19 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-13 23:00:19 +0200
commit19c1ea602bde2e131bdc89f78786a2efced41d42 (patch)
tree2ccc6d7a4d518d2c73fc296e90b349c791e483c5 /window.c
parent9da490af05b2aac772f0bdbb934dd313c1271749 (diff)
downloadvis-19c1ea602bde2e131bdc89f78786a2efced41d42.tar.gz
vis-19c1ea602bde2e131bdc89f78786a2efced41d42.tar.xz
Introduce some helper functions dealing with Filerange
Diffstat (limited to 'window.c')
-rw-r--r--window.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/window.c b/window.c
index 59a275e..7329077 100644
--- a/window.c
+++ b/window.c
@@ -84,7 +84,7 @@ static bool window_scroll_lines_down(Win *win, int n);
static bool window_scroll_lines_up(Win *win, int n);
void window_selection_clear(Win *win) {
- win->sel.start = win->sel.end = EPOS;
+ win->sel = text_range_empty();
window_draw(win);
window_cursor_update(win);
curs_set(1);
@@ -113,15 +113,13 @@ static void window_clear(Win *win) {
Filerange window_selection_get(Win *win) {
Filerange sel = win->sel;
- if (sel.start == EPOS || sel.end == EPOS) {
- sel.start = sel.end = EPOS;
- return sel;
- }
if (sel.start > sel.end) {
size_t tmp = sel.start;
sel.start = sel.end;
sel.end = tmp;
}
+ if (!text_range_valid(&sel))
+ return text_range_empty();
sel.end = text_char_next(win->text, sel.end);
return sel;
}