aboutsummaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-13 22:25:06 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-13 22:29:36 +0200
commitc17ca10e11db30f4b4924b69dbf3b1693025d4dc (patch)
treedb8f9ed1b95d895e111f68181ab8433b6349639b /window.c
parentc94579526c082e75b9ee8ec2fc189540884ac039 (diff)
downloadvis-c17ca10e11db30f4b4924b69dbf3b1693025d4dc.tar.gz
vis-c17ca10e11db30f4b4924b69dbf3b1693025d4dc.tar.xz
Introduce and use EPOS instead of (size_t)-1
Diffstat (limited to 'window.c')
-rw-r--r--window.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/window.c b/window.c
index dc1cb6d..3b579d6 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 = (size_t)-1;
+ win->sel.start = win->sel.end = EPOS;
window_draw(win);
window_cursor_update(win);
curs_set(1);
@@ -113,11 +113,11 @@ static void window_clear(Win *win) {
Filerange window_selection_get(Win *win) {
Filerange sel = win->sel;
- if (sel.start == (size_t)-1) {
- sel.end = (size_t)-1;
- } else if (sel.end == (size_t)-1) {
- sel.start = (size_t)-1;
- } else if (sel.start > sel.end) {
+ 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;
@@ -254,7 +254,7 @@ void window_cursor_getxy(Win *win, size_t *lineno, size_t *col) {
* its changes. */
static size_t window_cursor_update(Win *win) {
Cursor *cursor = &win->cursor;
- if (win->sel.start != (size_t)-1) {
+ if (win->sel.start != EPOS) {
win->sel.end = cursor->pos;
window_draw(win);
}