MCPcopy Create free account
hub / github.com/NetHack/NetHack / mswin_get_ext_cmd

Function mswin_get_ext_cmd

win/win32/mswproc.c:1796–1885  ·  view source on GitHub ↗

int get_ext_cmd(void) -- Get an extended command in a window-port specific way. An index into extcmdlist[] is returned on a successful selection, -1 otherwise. */

Source from the content-addressed store, hash-verified

1794 selection, -1 otherwise.
1795*/
1796int
1797mswin_get_ext_cmd(void)
1798{
1799 char cmd[BUFSZ];
1800 int ret;
1801 logDebug("mswin_get_ext_cmd()\n");
1802
1803 if (!iflags.wc_popup_dialog) {
1804 char c;
1805 int i, len;
1806 int createcaret;
1807
1808 createcaret = 1;
1809 SendMessage(mswin_hwnd_from_winid(WIN_MESSAGE), WM_MSNH_COMMAND,
1810 (WPARAM) MSNH_MSG_CARET, (LPARAM) &createcaret);
1811
1812 cmd[0] = '\0';
1813 i = -2;
1814 mswin_clear_nhwindow(WIN_MESSAGE);
1815 mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, "#", 0);
1816 len = 0;
1817 ShowCaret(mswin_hwnd_from_winid(WIN_MESSAGE));
1818 while (i == -2) {
1819 int oindex, com_index;
1820 c = mswin_nhgetch();
1821 switch (c) {
1822 case VK_ESCAPE:
1823 i = -1;
1824 break;
1825 case '\n':
1826 case '\r':
1827 case -115:
1828 for (i = 0; extcmdlist[i].ef_txt != (char *) 0; i++)
1829 if (!strcmpi(cmd, extcmdlist[i].ef_txt))
1830 break;
1831
1832 if (extcmdlist[i].ef_txt == (char *) 0) {
1833 pline("%s%s: unknown extended command.",
1834 visctrl(extcmd_initiator()), cmd);
1835 i = -1;
1836 }
1837 break;
1838 default:
1839 if (cmd[0])
1840 mswin_putstr_ex(WIN_MESSAGE, ATR_BOLD, cmd,
1841 -(int) strlen(cmd));
1842 if (c == VK_BACK) {
1843 if (len > 0)
1844 len--;
1845 cmd[len] = '\0';
1846 } else {
1847 cmd[len++] = c;
1848 cmd[len] = '\0';
1849 /* Find a command with this prefix in extcmdlist */
1850 com_index = -1;
1851 for (oindex = 0; extcmdlist[oindex].ef_txt != (char *) 0;
1852 oindex++) {
1853 if ((extcmdlist[oindex].flags & AUTOCOMPLETE)

Callers

nothing calls this directly

Calls 10

visctrlFunction · 0.85
extcmd_initiatorFunction · 0.85
logDebugFunction · 0.70
mswin_hwnd_from_winidFunction · 0.70
mswin_clear_nhwindowFunction · 0.70
mswin_putstr_exFunction · 0.70
mswin_nhgetchFunction · 0.70
mswin_ext_cmd_windowFunction · 0.70
plineFunction · 0.50
strncmpiFunction · 0.50

Tested by

no test coverage detected