MCPcopy Index your code
hub / github.com/NetHack/NetHack / qt_getlin

Method qt_getlin

win/Qt/qt_bind.cpp:957–989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

955}
956
957void NetHackQtBind::qt_getlin(const char *prompt, char *line)
958{
959 NetHackQtStringRequestor requestor(mainWidget(),prompt);
960 if (!requestor.Get(line, BUFSZ, 40)) {
961 Strcpy(line, "\033");
962 // discard any input that Get() might have left pending
963 keybuffer.Drain();
964 }
965
966 // add the prompt with appended response to the message window
967 char buf[BUFSZ + 20], *q; /* +20: plenty of extra room for visctrl() */
968 copynchars(buf, prompt, BUFSZ - 1);
969 q = eos(buf);
970 *q++ = ' '; /* guaranteed to fit; temporary lack of terminator is ok */
971
972 if (line[0] == '\033') {
973 Strcpy(q, "ESC");
974 } else if (line[0] == ' ' && !line[1]) {
975 Strcpy(q, "SPC");
976 } else {
977 /* buf[] has more than enough room to hold one extra visctrl()
978 in case q is at the last viable slot and *p yields "M-^c" */
979 for (char *p = line; *p && q < &buf[BUFSZ - 1]; ++p, q = eos(q))
980 Strcpy(q, visctrl(*p));
981 }
982 if (q > &buf[BUFSZ - 1])
983 q = &buf[BUFSZ - 1];
984 *q = '\0';
985
986 NetHackQtBind::qt_putstr(WIN_MESSAGE, ATR_BOLD, buf);
987 // unhighlight the prompt; does not erase the multi-line message window
988 NetHackQtBind::qt_clear_nhwindow(WIN_MESSAGE);
989}
990
991// User has typed '#' to begin entering an extended command; core calls us.
992int NetHackQtBind::qt_get_ext_cmd()

Callers

nothing calls this directly

Calls 5

copyncharsFunction · 0.85
eosFunction · 0.85
visctrlFunction · 0.85
DrainMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected