You do not need to remember the index of each jump key because you can count it up after a key is pressed.
Showing the changes to scripts (3 of 3 files). Show all
Unified · Split
| @@ -275,7 +275,6 @@ struct jump_key { · 274 unmodified lines | |||
| 275 | struct list_head entries; | 275 | struct list_head entries; |
| 276 | size_t offset; | 276 | size_t offset; |
| 277 | struct menu *target; | 277 | struct menu *target; |
| 278 | int index; | ||
| 279 | }; | 278 | }; |
| 280 | 279 | ||
| 281 | extern struct file *file_list; | 280 | extern struct file *file_list; |
| @@ -22,8 +22,6 @@ · 21 unmodified lines | |||
| 22 | #include "lkc.h" | 22 | #include "lkc.h" |
| 23 | #include "lxdialog/dialog.h" | 23 | #include "lxdialog/dialog.h" |
| 24 | 24 | ||
| 25 | #define JUMP_NB 9 | ||
| 26 | |||
| 27 | static const char mconf_readme[] = | 25 | static const char mconf_readme[] = |
| 28 | "Overview\n" | 26 | "Overview\n" |
| 29 | "--------\n" | 27 | "--------\n" |
| @@ -402,18 +400,21 @@ static int handle_search_keys(int key, size_t start, size_t end, void *_data) · 372 unmodified lines | |||
| 402 | { | 400 | { |
| 403 | struct search_data *data = _data; | 401 | struct search_data *data = _data; |
| 404 | struct jump_key *pos; | 402 | struct jump_key *pos; |
| 403 | int index = 0; | ||
| 405 | 404 | ||
| 406 | if (key < '1' || key > '9') | 405 | if (key < '1' || key > '9') |
| 407 | return 0; | 406 | return 0; |
| 408 | 407 | ||
| 409 | list_for_each_entry(pos, data->head, entries) { | 408 | list_for_each_entry(pos, data->head, entries) { |
| 409 | index = next_jump_key(index); | ||
| 410 | |||
| 410 | if (pos->offset < start) | 411 | if (pos->offset < start) |
| 411 | continue; | 412 | continue; |
| 412 | 413 | ||
| 413 | if (pos->offset >= end) | 414 | if (pos->offset >= end) |
| 414 | break; | 415 | break; |
| 415 | 416 | ||
| 416 | if (key == '1' + (pos->index % JUMP_NB)) { | 417 | if (key == index) { |
| 417 | data->target = pos->target; | 418 | data->target = pos->target; |
| 418 | return 1; | 419 | return 1; |
| 419 | } | 420 | } |
| @@ -735,15 +735,7 @@ static void get_prompt_str(struct gstr *r, struct property *prop, · 734 unmodified lines | |||
| 735 | } | 735 | } |
| 736 | if (head && location) { | 736 | if (head && location) { |
| 737 | jump = xmalloc(sizeof(struct jump_key)); | 737 | jump = xmalloc(sizeof(struct jump_key)); |
| 738 | |||
| 739 | jump->target = location; | 738 | jump->target = location; |
| 740 | |||
| 741 | if (list_empty(head)) | ||
| 742 | jump->index = 0; | ||
| 743 | else | ||
| 744 | jump->index = list_entry(head->prev, struct jump_key, | ||
| 745 | entries)->index + 1; | ||
| 746 | |||
| 747 | list_add_tail(&jump->entries, head); | 739 | list_add_tail(&jump->entries, head); |
| 748 | } | 740 | } |
| 749 | 741 | ||