Enable going back to previous search matches (Shift-F3)

This commit is contained in:
Daniel Lange 2020-12-23 18:59:51 +01:00 committed by BenBE
parent 1cc3f8074f
commit 8b83a9f055
2 changed files with 6 additions and 5 deletions

1
CRT.c
View File

@ -689,6 +689,7 @@ void CRT_init(const int* delay, int colorScheme, bool allowUnicode) {
define_key("\033[12~", KEY_F(2)); define_key("\033[12~", KEY_F(2));
define_key("\033[13~", KEY_F(3)); define_key("\033[13~", KEY_F(3));
define_key("\033[14~", KEY_F(4)); define_key("\033[14~", KEY_F(4));
define_key("\033[14;2~", KEY_F(15));
define_key("\033[17;2~", KEY_F(18)); define_key("\033[17;2~", KEY_F(18));
char sequence[3] = "\033a"; char sequence[3] = "\033a";
for (char c = 'a'; c <= 'z'; c++) { for (char c = 'a'; c <= 'z'; c++) {

View File

@ -29,9 +29,9 @@ void IncSet_reset(IncSet* this, IncType type) {
IncMode_reset(&this->modes[type]); IncMode_reset(&this->modes[type]);
} }
static const char* const searchFunctions[] = {"Next ", "Cancel ", " Search: ", NULL}; static const char* const searchFunctions[] = {"Next ", "Prev ", "Cancel ", " Search: ", NULL};
static const char* const searchKeys[] = {"F3", "Esc", " "}; static const char* const searchKeys[] = {"F3", "S-F3", "Esc", " "};
static const int searchEvents[] = {KEY_F(3), 27, ERR}; static const int searchEvents[] = {KEY_F(3), KEY_F(15), 27, ERR};
static inline void IncMode_initSearch(IncMode* search) { static inline void IncMode_initSearch(IncMode* search) {
memset(search, 0, sizeof(IncMode)); memset(search, 0, sizeof(IncMode));
@ -141,11 +141,11 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
int size = Panel_size(panel); int size = Panel_size(panel);
bool filterChanged = false; bool filterChanged = false;
bool doSearch = true; bool doSearch = true;
if (ch == KEY_F(3)) { if (ch == KEY_F(3) || ch == KEY_F(15)) {
if (size == 0) if (size == 0)
return true; return true;
IncMode_find(mode, panel, getPanelValue, 1); IncMode_find(mode, panel, getPanelValue, ch == KEY_F(3) ? 1 : -1);
doSearch = false; doSearch = false;
} else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) { } else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) {
if (mode->index < INCMODE_MAX) { if (mode->index < INCMODE_MAX) {