keymacro_kprint(): * Print the specified key and its associated * function specified by val */
| 583 | * function specified by val |
| 584 | */ |
| 585 | protected void |
| 586 | keymacro_kprint(EditLine *el, const Char *key, keymacro_value_t *val, int ntype) |
| 587 | { |
| 588 | el_bindings_t *fp; |
| 589 | char unparsbuf[EL_BUFSIZ]; |
| 590 | static const char fmt[] = "%-15s-> %s\n"; |
| 591 | |
| 592 | if (val != NULL) |
| 593 | switch (ntype) { |
| 594 | case XK_STR: |
| 595 | case XK_EXE: |
| 596 | (void) keymacro__decode_str(val->str, unparsbuf, |
| 597 | sizeof(unparsbuf), |
| 598 | ntype == XK_STR ? "\"\"" : "[]"); |
| 599 | (void) fprintf(el->el_outfile, fmt, |
| 600 | ct_encode_string(key, &el->el_scratch), unparsbuf); |
| 601 | break; |
| 602 | case XK_CMD: |
| 603 | for (fp = el->el_map.help; fp->name; fp++) |
| 604 | if (val->cmd == fp->func) { |
| 605 | ct_wcstombs(unparsbuf, fp->name, sizeof(unparsbuf)); |
| 606 | unparsbuf[sizeof(unparsbuf) -1] = '\0'; |
| 607 | (void) fprintf(el->el_outfile, fmt, |
| 608 | ct_encode_string(key, &el->el_scratch), unparsbuf); |
| 609 | break; |
| 610 | } |
| 611 | #ifdef DEBUG_KEY |
| 612 | if (fp->name == NULL) |
| 613 | (void) fprintf(el->el_outfile, |
| 614 | "BUG! Command not found.\n"); |
| 615 | #endif |
| 616 | |
| 617 | break; |
| 618 | default: |
| 619 | EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype)); |
| 620 | break; |
| 621 | } |
| 622 | else |
| 623 | (void) fprintf(el->el_outfile, fmt, ct_encode_string(key, |
| 624 | &el->el_scratch), "no input"); |
| 625 | } |
| 626 | |
| 627 | |
| 628 | #define ADDC(c) \ |
no test coverage detected