From eebad002cd7e1791c280e900c5c410b8a0b14480 Mon Sep 17 00:00:00 2001 From: speedie Date: Fri, 24 Mar 2023 14:38:28 +0100 Subject: [PATCH] fix issues with movement --- libs/arg.c | 11 ++++++++++- spmenu.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/arg.c b/libs/arg.c index 899f0d5..7cf56b0 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -256,7 +256,16 @@ moveword(const Arg *arg) void movecursor(const Arg *arg) { - cursor = nextrune(arg->i); + if (arg->i < 0) { + if (cursor > 0) { + cursor = nextrune(-1); + } + } else { + if (text[cursor]) { + cursor = nextrune(+1); + } + } + drawmenu(); } diff --git a/spmenu.c b/spmenu.c index 737e599..bf458cc 100644 --- a/spmenu.c +++ b/spmenu.c @@ -393,7 +393,7 @@ nextrune(int inc) // return location of next utf8 rune in the given direction (+1 or -1) for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc) ; - return n; + return n ? n : NULL; } void