Skip to content

Commit

Permalink
MENU: maple/menu.c: domenu(): Invoke hotkey functions for keyboard …
Browse files Browse the repository at this point in the history
…input only.
  • Loading branch information
IepIweidieng committed Feb 13, 2020
1 parent 8b9dc9e commit e54219a
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions maple/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,8 @@ domenu(
mode = 0;
}

switch (cmd)
/* Invoke hotkey functions for keyboard input only */
switch ((keyboard_cmd) ? cmd : KEY_NONE)
{
case KEY_PGUP:
cc = (cc == 0) ? max : 0;
Expand Down Expand Up @@ -1440,46 +1441,51 @@ domenu(
// Falls through
// to move the cursor to option 'G' ('Goodbye'; exiting BBS)

/* Command matching */
default:
switch (cmd)
{
int maxlen = 0;
default:
{
int maxlen = 0;

cmd = tolower(cmd);
cmd = tolower(cmd);

/* IID.20200107: Match input sequence. */
for (int i = 0; i <= max; i++)
{
const char *const mdesc = table[i]->desc;
int match_max = BMIN(cmdcur_max, strlen(mdesc));
/* Skip spaces */
cmdcur[i] += strspn(mdesc + cmdcur[i], " ");
/* Not matched or cursor reached the end */
if (cmdcur[i] >= match_max
|| tolower(mdesc[cmdcur[i]]) != cmd)
/* IID.20200107: Match input sequence. */
for (int i = 0; i <= max; i++)
{
/* Reset and skip spaces */
cmdcur[i] = strspn(mdesc + cmdcur[0], " ");
cmdlen[i] = 0;
}
if (tolower(mdesc[cmdcur[i]]) == cmd)
{
cmdcur[i]++;
cmdlen[i]++;
}
if (cmdlen[i] > maxlen)
{
maxlen = cmdlen[i];
cc = i;
const char *const mdesc = table[i]->desc;
int match_max = BMIN(cmdcur_max, strlen(mdesc));
/* Skip spaces */
cmdcur[i] += strspn(mdesc + cmdcur[i], " ");
/* Not matched or cursor reached the end */
if (cmdcur[i] >= match_max
|| tolower(mdesc[cmdcur[i]]) != cmd)
{
/* Reset and skip spaces */
cmdcur[i] = strspn(mdesc + cmdcur[0], " ");
cmdlen[i] = 0;
}
if (tolower(mdesc[cmdcur[i]]) == cmd)
{
cmdcur[i]++;
cmdlen[i]++;
}
if (cmdlen[i] > maxlen)
{
maxlen = cmdlen[i];
cc = i;
}
}
}
}

// Falls through
// to keep the input
// Falls through
// to keep the input

case ' ': /* Ignore space for matching */
if (keyboard_cmd) /* `cmd` is from keyboard */
keep_cmd = true;
case ' ': /* Ignore space for matching */
if (keyboard_cmd) /* `cmd` is from keyboard */
keep_cmd = true;
}
}

if (cc != cx)
Expand Down

0 comments on commit e54219a

Please sign in to comment.