-
- /* nuke the current line */
- /* first, go home */
- BEGINNING_OF_LINE();
-
- /* erase to end of line */
- ERASE_TO_EOL();
-
- /* copy new line into place and display */
- strcpy(buf, hline);
- eol_num = strlen(buf);
- REFRESH_TO_EOL();
- continue;
- }
+ break;
+ case KEY_PPAGE: /* history-search-backward */
+ case KEY_NPAGE: /* history-search-forward */
+ if (enable_history) {
+ char *hline;
+ if (ichar == KEY_PPAGE)
+ hline = hist_search_backward(buf, num);
+ else
+ hline = hist_search_forward(buf, num);
+
+ if (hline) {
+ uint_fast8_t num2 = num;
+ /* overwrite current line from cursor position */
+ cread_add_str(hline+num, 0, &num2, &eol_num, buf, len);
+ /* erase to end of line */
+ erase_to_eol(&num2, &eol_num);
+ /* cursor back */
+ while (num2-- > num)
+ getcmd_putch(CTL_BACKSPACE);
+ } else {
+ getcmd_cbeep();
+ }
+ } else {
+ getcmd_cbeep();
+ }
+ break;