From 19c1ea602bde2e131bdc89f78786a2efced41d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 13 Sep 2014 23:00:19 +0200 Subject: Introduce some helper functions dealing with Filerange --- window.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'window.c') 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; } -- cgit v1.2.3