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

Function NHSPhoneSetKeypadFromString

outdated/sys/wince/mhcmd.c:1405–1496  ·  view source on GitHub ↗

-------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

1403}
1404/*-------------------------------------------------------------------------*/
1405void
1406NHSPhoneSetKeypadFromString(const char *str)
1407{
1408 PNHCmdWindow data;
1409 PNHCmdSet p = 0;
1410 PNHCmdLayout layout_prev = 0;
1411 PNHCmdLayout layout_cur = 0;
1412 char buf[2][BUFSZ];
1413 int i, lcount;
1414 char *s;
1415
1416 assert(NH_CMDPAD_ROWS == 4);
1417
1418 data = (PNHCmdWindow) GetWindowLong(GetNHApp()->hCmdWnd, GWL_USERDATA);
1419 if (!data)
1420 return;
1421
1422 p = nhcmdset_create();
1423
1424 ZeroMemory(buf, sizeof(buf));
1425 if (sscanf(str, "%s or %s", buf[1], buf[0]) != 2) {
1426 ZeroMemory(buf, sizeof(buf));
1427 strncpy(buf[0], str, sizeof(buf[0]) - 1);
1428 }
1429
1430 lcount = 10; /* create new layout on the first iteration */
1431 for (i = 0; i < 2; i++) {
1432 s = buf[i];
1433 while (*s) {
1434 char c_start, c_end, c_char;
1435
1436 /* parse character ranges */
1437 if (isalnum((c_start = s[0])) && s[1] == '-'
1438 && isalnum((c_end = s[2]))) {
1439 s += 2;
1440 } else {
1441 c_start = c_end = *s;
1442 }
1443
1444 for (c_char = c_start; c_char <= c_end; c_char++) {
1445 if (lcount >= 10) {
1446 /* create layout */
1447 lcount = 0;
1448 layout_prev = layout_cur;
1449 layout_cur = nhcmdlayout_create("noname", NH_CMDPAD_ROWS,
1450 NH_CMDPAD_COLS);
1451 nhcmdlayout_init(layout_cur, cells_layout_menu);
1452
1453 nhcmdlayout_cell(layout_cur, 3, 0)->data = layout_prev;
1454 nhcmdlayout_cell(layout_cur, 3, 2)->data = 0;
1455
1456 nhcmdset_add(p, layout_cur);
1457 p->elements[p->count - 1].free_on_destroy = 1;
1458
1459 if (layout_prev) {
1460 nhcmdlayout_cell(layout_prev, 3, 2)->data =
1461 layout_cur;
1462 }

Callers 3

mswin_yn_functionFunction · 0.85
onMSNHCommandFunction · 0.85

Calls 8

nhcmdset_createFunction · 0.85
nhcmdlayout_createFunction · 0.85
nhcmdlayout_initFunction · 0.85
nhcmdset_addFunction · 0.85
nhcmdset_destroyFunction · 0.85
SetCmdWindowLayoutFunction · 0.85
nhcmdset_getFunction · 0.85
GetNHAppFunction · 0.70

Tested by

no test coverage detected