aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/misc.c b/misc.c
index 334e08d..6b5f3f8 100644
--- a/misc.c
+++ b/misc.c
@@ -351,15 +351,16 @@ void draw_rect_corners(drawing *dr, int cx, int cy, int r, int col)
draw_line(dr, cx + r, cy + r, cx + r/2, cy + r, col);
}
-void move_cursor(int button, int *x, int *y, int maxw, int maxh, bool wrap)
+char *move_cursor(int button, int *x, int *y, int maxw, int maxh, bool wrap,
+ bool *visible)
{
- int dx = 0, dy = 0;
+ int dx = 0, dy = 0, ox = *x, oy = *y;
switch (button) {
case CURSOR_UP: dy = -1; break;
case CURSOR_DOWN: dy = 1; break;
case CURSOR_RIGHT: dx = 1; break;
case CURSOR_LEFT: dx = -1; break;
- default: return;
+ default: return MOVE_UNUSED;
}
if (wrap) {
*x = (*x + dx + maxw) % maxw;
@@ -368,6 +369,13 @@ void move_cursor(int button, int *x, int *y, int maxw, int maxh, bool wrap)
*x = min(max(*x+dx, 0), maxw - 1);
*y = min(max(*y+dy, 0), maxh - 1);
}
+ if (visible != NULL && !*visible) {
+ *visible = true;
+ return MOVE_UI_UPDATE;
+ }
+ if (*x != ox || *y != oy)
+ return MOVE_UI_UPDATE;
+ return MOVE_NO_EFFECT;
}
/* Used in netslide.c and sixteen.c for cursor movement around edge. */