diff --git a/README.html b/README.html
index 49ca999..ce67bb3 100644
--- a/README.html
+++ b/README.html
@@ -324,7 +324,6 @@ MD5() is deprecated as of OpenSSL 3.0, but this would also make it very
easy to have LibreSSL compatibility.
Image support: Ability to display icons, similar to rofi
Text drawing: Use cairo for text drawing over Xft.
-Item updating: Save item index before drawing the menu again
Typing: Disable insert mode completely when !type
Lines: Rofi-like newlines in the same entry
diff --git a/README.md b/README.md
index 699b5e8..7df7556 100644
--- a/README.md
+++ b/README.md
@@ -127,7 +127,6 @@ is deprecated as of OpenSSL 3.0, but this would also make it very easy to
have LibreSSL compatibility.
- Image support: Ability to display icons, similar to rofi
- Text drawing: Use cairo for text drawing over Xft.
-- Item updating: Save item index before drawing the menu again
- Typing: Disable insert mode completely when !type
- Lines: Rofi-like newlines in the same entry
- Just need to `XMoveResizeWindow()` as well as `mh += bh` and `y += bh`
diff --git a/libs/draw.c b/libs/draw.c
index e549bb0..05c90aa 100644
--- a/libs/draw.c
+++ b/libs/draw.c
@@ -232,6 +232,8 @@ drawitem(int x, int y, int w)
rx = x;
}
+ int itemoverride = 1;
+
for (item = curr; item != next; item = item->right, i++) {
x = drawitemtext(
item,
@@ -239,6 +241,11 @@ drawitem(int x, int y, int w)
y + (((i % lines) + 1) * bh),
(mw - rx) / columns
);
+
+ if (item == sel && itemoverride) {
+ itemnumber = i;
+ itemoverride = 0;
+ }
}
// horizontal list
@@ -248,7 +255,10 @@ drawitem(int x, int y, int w)
w = larrowWidth;
x = drawlarrow(x, y, w);
- for (item = curr; item != next; item = item->right) // draw items
+ itemnumber = 0;
+ int itemoverride = 1;
+
+ for (item = curr; item != next; item = item->right) { // draw items
x = drawitemtext(item, x, y, MIN(pango_item ? TEXTWM(item->text) : TEXTW(item->text),
mw - x -
rarrowWidth -
@@ -260,8 +270,17 @@ drawitem(int x, int y, int w)
2 * borderwidth
));
- w = rarrowWidth + numberWidth + modeWidth + capsWidth + menumarginh + 2 * sp + 2 * borderwidth;
- x = drawrarrow(mw - w, y, w);
+ if (itemoverride) {
+ itemnumber++;
+ }
+
+ if (item == sel) {
+ itemoverride = 0;
+ }
+ }
+
+ w = rarrowWidth + numberWidth + modeWidth + capsWidth + menumarginh + 2 * sp + 2 * borderwidth;
+ x = drawrarrow(mw - w, y, w);
}
return x;
diff --git a/libs/event.c b/libs/event.c
index 863356c..c73e797 100644
--- a/libs/event.c
+++ b/libs/event.c
@@ -58,6 +58,13 @@ void eventloop(void) {
if (listchanged) {
match();
+
+ for (int i = 0; i < itemnumber; i++) {
+ if (sel && sel->right && (sel = sel->right) == next) {
+ curr = next;
+ }
+ }
+
drawmenu();
}
}
diff --git a/spmenu.c b/spmenu.c
index b1356db..d93b98c 100644
--- a/spmenu.c
+++ b/spmenu.c
@@ -148,6 +148,7 @@ static int lrpad; // sum of left and right padding
static int vp; // vertical padding for bar
static int sp; // side padding for bar
static int cursorstate = 1; // cursor state
+static int itemnumber = 0; // item number
static size_t cursor;
static struct item *items = NULL, *backup_items, *list_items;
static struct item *matches, *matchend;