getlin(const char *ques, char *input) -- Prints ques as a prompt and reads a single line of text, up to a newline. The string entered is returned without the newline. ESC is used to cancel, in which case the string "\033\000" is returned. -- getlin() must call flush_screen(1) before doing anything. -- This uses the
| 1721 | ports might use a popup. |
| 1722 | */ |
| 1723 | void |
| 1724 | mswin_getlin(const char *question, char *input) |
| 1725 | { |
| 1726 | logDebug("mswin_getlin(%s, %p)\n", question, input); |
| 1727 | |
| 1728 | if (!iflags.wc_popup_dialog) { |
| 1729 | char c; |
| 1730 | int len; |
| 1731 | int done; |
| 1732 | int createcaret; |
| 1733 | |
| 1734 | createcaret = 1; |
| 1735 | SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_MSNH_COMMAND, |
| 1736 | (WPARAM) MSNH_MSG_CARET, (LPARAM) &createcaret); |
| 1737 | |
| 1738 | /* mswin_clear_nhwindow(WIN_MESSAGE); */ |
| 1739 | mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, question, 0); |
| 1740 | mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, " ", 1); |
| 1741 | #ifdef EDIT_GETLIN |
| 1742 | mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, input, 0); |
| 1743 | len = strlen(input); |
| 1744 | #else |
| 1745 | input[0] = '\0'; |
| 1746 | len = 0; |
| 1747 | #endif |
| 1748 | ShowCaret(mswin_hwnd_from_winid(WIN_MESSAGE)); |
| 1749 | done = FALSE; |
| 1750 | while (!done) { |
| 1751 | c = mswin_nhgetch(); |
| 1752 | switch (c) { |
| 1753 | case VK_ESCAPE: |
| 1754 | strcpy(input, "\033"); |
| 1755 | done = TRUE; |
| 1756 | break; |
| 1757 | case '\n': |
| 1758 | case '\r': |
| 1759 | case -115: |
| 1760 | done = TRUE; |
| 1761 | break; |
| 1762 | default: |
| 1763 | if (input[0]) |
| 1764 | mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, input, -len); |
| 1765 | if (c == VK_BACK) { |
| 1766 | if (len > 0) |
| 1767 | len--; |
| 1768 | input[len] = '\0'; |
| 1769 | } else if (len>=(BUFSZ-1)) { |
| 1770 | PlaySound((LPCSTR)SND_ALIAS_SYSTEMEXCLAMATION, NULL, SND_ALIAS_ID|SND_ASYNC); |
| 1771 | } else { |
| 1772 | input[len++] = c; |
| 1773 | input[len] = '\0'; |
| 1774 | } |
| 1775 | mswin_putstr_ex(WIN_MESSAGE, ATR_NONE, input, 1); |
| 1776 | break; |
| 1777 | } |
| 1778 | } |
| 1779 | HideCaret(mswin_hwnd_from_winid(WIN_MESSAGE)); |
| 1780 | createcaret = 0; |
nothing calls this directly
no test coverage detected