save item index
This commit is contained in:
parent
445351c09a
commit
aad8baef66
|
@ -324,7 +324,6 @@ MD5() is deprecated as of OpenSSL 3.0, but this would also make it very
|
|||
easy to have LibreSSL compatibility.</li>
|
||||
<li>Image support: Ability to display icons, similar to rofi</li>
|
||||
<li>Text drawing: Use cairo for text drawing over Xft.</li>
|
||||
<li>Item updating: Save item index before drawing the menu again</li>
|
||||
<li>Typing: Disable insert mode completely when !type</li>
|
||||
<li>Lines: Rofi-like newlines in the same entry
|
||||
<ul>
|
||||
|
|
|
@ -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`
|
||||
|
|
21
libs/draw.c
21
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,6 +270,15 @@ drawitem(int x, int y, int w)
|
|||
2 * borderwidth
|
||||
));
|
||||
|
||||
if (itemoverride) {
|
||||
itemnumber++;
|
||||
}
|
||||
|
||||
if (item == sel) {
|
||||
itemoverride = 0;
|
||||
}
|
||||
}
|
||||
|
||||
w = rarrowWidth + numberWidth + modeWidth + capsWidth + menumarginh + 2 * sp + 2 * borderwidth;
|
||||
x = drawrarrow(mw - w, y, w);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
1
spmenu.c
1
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;
|
||||
|
|
Loading…
Reference in a new issue