1317
1344
return PyInt_FromLong(wstrlen(str, len));
1347
static void setitemstring_decref(PyObject * dict,
1348
const char * s, PyObject * o)
1350
PyDict_SetItemString(dict, s, o);
1320
1354
void init_snack(void) {
1321
1355
PyObject * d, * m;
1323
1357
m = Py_InitModule("_snack", snackModuleMethods);
1324
1358
d = PyModule_GetDict(m);
1326
PyDict_SetItemString(d, "ANCHOR_LEFT", PyInt_FromLong(NEWT_ANCHOR_LEFT));
1327
PyDict_SetItemString(d, "ANCHOR_TOP", PyInt_FromLong(NEWT_ANCHOR_TOP));
1328
PyDict_SetItemString(d, "ANCHOR_RIGHT", PyInt_FromLong(NEWT_ANCHOR_RIGHT));
1329
PyDict_SetItemString(d, "ANCHOR_BOTTOM",
1360
setitemstring_decref(d, "ANCHOR_LEFT", PyInt_FromLong(NEWT_ANCHOR_LEFT));
1361
setitemstring_decref(d, "ANCHOR_TOP", PyInt_FromLong(NEWT_ANCHOR_TOP));
1362
setitemstring_decref(d, "ANCHOR_RIGHT", PyInt_FromLong(NEWT_ANCHOR_RIGHT));
1363
setitemstring_decref(d, "ANCHOR_BOTTOM",
1330
1364
PyInt_FromLong(NEWT_ANCHOR_BOTTOM));
1331
PyDict_SetItemString(d, "GRID_GROWX", PyInt_FromLong(NEWT_GRID_FLAG_GROWX));
1332
PyDict_SetItemString(d, "GRID_GROWY", PyInt_FromLong(NEWT_GRID_FLAG_GROWY));
1334
PyDict_SetItemString(d, "FD_READ", PyInt_FromLong(NEWT_FD_READ));
1335
PyDict_SetItemString(d, "FD_WRITE", PyInt_FromLong(NEWT_FD_WRITE));
1336
PyDict_SetItemString(d, "FD_EXCEPT", PyInt_FromLong(NEWT_FD_EXCEPT));
1338
PyDict_SetItemString(d, "FORM_EXIT_HOTKEY", PyString_FromString("hotkey"));
1339
PyDict_SetItemString(d, "FORM_EXIT_WIDGET", PyString_FromString("widget"));
1340
PyDict_SetItemString(d, "FORM_EXIT_TIMER", PyString_FromString("timer"));
1341
PyDict_SetItemString(d, "FORM_EXIT_FDREADY", PyString_FromString("fdready"));
1343
PyDict_SetItemString(d, "KEY_TAB", PyInt_FromLong(NEWT_KEY_TAB));
1344
PyDict_SetItemString(d, "KEY_ENTER", PyInt_FromLong(NEWT_KEY_ENTER));
1345
PyDict_SetItemString(d, "KEY_SUSPEND", PyInt_FromLong(NEWT_KEY_SUSPEND));
1346
PyDict_SetItemString(d, "KEY_UP", PyInt_FromLong(NEWT_KEY_UP));
1347
PyDict_SetItemString(d, "KEY_DOWN", PyInt_FromLong(NEWT_KEY_DOWN));
1348
PyDict_SetItemString(d, "KEY_LEFT", PyInt_FromLong(NEWT_KEY_LEFT));
1349
PyDict_SetItemString(d, "KEY_RIGHT", PyInt_FromLong(NEWT_KEY_RIGHT));
1350
PyDict_SetItemString(d, "KEY_BACKSPACE", PyInt_FromLong(NEWT_KEY_BKSPC));
1351
PyDict_SetItemString(d, "KEY_DELETE", PyInt_FromLong(NEWT_KEY_DELETE));
1352
PyDict_SetItemString(d, "KEY_HOME", PyInt_FromLong(NEWT_KEY_HOME));
1353
PyDict_SetItemString(d, "KEY_END", PyInt_FromLong(NEWT_KEY_END));
1354
PyDict_SetItemString(d, "KEY_UNTAB", PyInt_FromLong(NEWT_KEY_UNTAB));
1355
PyDict_SetItemString(d, "KEY_PAGEUP", PyInt_FromLong(NEWT_KEY_PGUP));
1356
PyDict_SetItemString(d, "KEY_PAGEGDOWN", PyInt_FromLong(NEWT_KEY_PGDN));
1357
PyDict_SetItemString(d, "KEY_INSERT", PyInt_FromLong(NEWT_KEY_INSERT));
1358
PyDict_SetItemString(d, "KEY_F1", PyInt_FromLong(NEWT_KEY_F1));
1359
PyDict_SetItemString(d, "KEY_F2", PyInt_FromLong(NEWT_KEY_F2));
1360
PyDict_SetItemString(d, "KEY_F3", PyInt_FromLong(NEWT_KEY_F3));
1361
PyDict_SetItemString(d, "KEY_F4", PyInt_FromLong(NEWT_KEY_F4));
1362
PyDict_SetItemString(d, "KEY_F5", PyInt_FromLong(NEWT_KEY_F5));
1363
PyDict_SetItemString(d, "KEY_F6", PyInt_FromLong(NEWT_KEY_F6));
1364
PyDict_SetItemString(d, "KEY_F7", PyInt_FromLong(NEWT_KEY_F7));
1365
PyDict_SetItemString(d, "KEY_F8", PyInt_FromLong(NEWT_KEY_F8));
1366
PyDict_SetItemString(d, "KEY_F9", PyInt_FromLong(NEWT_KEY_F9));
1367
PyDict_SetItemString(d, "KEY_F10", PyInt_FromLong(NEWT_KEY_F10));
1368
PyDict_SetItemString(d, "KEY_F11", PyInt_FromLong(NEWT_KEY_F11));
1369
PyDict_SetItemString(d, "KEY_F12", PyInt_FromLong(NEWT_KEY_F12));
1370
PyDict_SetItemString(d, "KEY_ESC", PyInt_FromLong(NEWT_KEY_ESCAPE));
1372
PyDict_SetItemString(d, "FLAG_DISABLED", PyInt_FromLong(NEWT_FLAG_DISABLED));
1373
PyDict_SetItemString(d, "FLAGS_SET", PyInt_FromLong(NEWT_FLAGS_SET));
1374
PyDict_SetItemString(d, "FLAGS_RESET", PyInt_FromLong(NEWT_FLAGS_RESET));
1375
PyDict_SetItemString(d, "FLAGS_TOGGLE", PyInt_FromLong(NEWT_FLAGS_TOGGLE));
1377
PyDict_SetItemString(d, "COLORSET_ROOT", PyInt_FromLong(NEWT_COLORSET_ROOT));
1378
PyDict_SetItemString(d, "COLORSET_BORDER", PyInt_FromLong(NEWT_COLORSET_BORDER));
1379
PyDict_SetItemString(d, "COLORSET_WINDOW", PyInt_FromLong(NEWT_COLORSET_WINDOW));
1380
PyDict_SetItemString(d, "COLORSET_SHADOW", PyInt_FromLong(NEWT_COLORSET_SHADOW));
1381
PyDict_SetItemString(d, "COLORSET_TITLE", PyInt_FromLong(NEWT_COLORSET_TITLE));
1382
PyDict_SetItemString(d, "COLORSET_BUTTON", PyInt_FromLong(NEWT_COLORSET_BUTTON));
1383
PyDict_SetItemString(d, "COLORSET_ACTBUTTON", PyInt_FromLong(NEWT_COLORSET_ACTBUTTON));
1384
PyDict_SetItemString(d, "COLORSET_CHECKBOX", PyInt_FromLong(NEWT_COLORSET_CHECKBOX));
1385
PyDict_SetItemString(d, "COLORSET_ACTCHECKBOX", PyInt_FromLong(NEWT_COLORSET_ACTCHECKBOX));
1386
PyDict_SetItemString(d, "COLORSET_ENTRY", PyInt_FromLong(NEWT_COLORSET_ENTRY));
1387
PyDict_SetItemString(d, "COLORSET_LABEL", PyInt_FromLong(NEWT_COLORSET_LABEL));
1388
PyDict_SetItemString(d, "COLORSET_LISTBOX", PyInt_FromLong(NEWT_COLORSET_LISTBOX));
1389
PyDict_SetItemString(d, "COLORSET_ACTLISTBOX", PyInt_FromLong(NEWT_COLORSET_ACTLISTBOX));
1390
PyDict_SetItemString(d, "COLORSET_TEXTBOX", PyInt_FromLong(NEWT_COLORSET_TEXTBOX));
1391
PyDict_SetItemString(d, "COLORSET_ACTTEXTBOX", PyInt_FromLong(NEWT_COLORSET_ACTTEXTBOX));
1392
PyDict_SetItemString(d, "COLORSET_HELPLINE", PyInt_FromLong(NEWT_COLORSET_HELPLINE));
1393
PyDict_SetItemString(d, "COLORSET_ROOTTEXT", PyInt_FromLong(NEWT_COLORSET_ROOTTEXT));
1394
PyDict_SetItemString(d, "COLORSET_EMPTYSCALE", PyInt_FromLong(NEWT_COLORSET_EMPTYSCALE));
1395
PyDict_SetItemString(d, "COLORSET_FULLSCALE", PyInt_FromLong(NEWT_COLORSET_FULLSCALE));
1396
PyDict_SetItemString(d, "COLORSET_DISENTRY", PyInt_FromLong(NEWT_COLORSET_DISENTRY));
1397
PyDict_SetItemString(d, "COLORSET_COMPACTBUTTON", PyInt_FromLong(NEWT_COLORSET_COMPACTBUTTON));
1398
PyDict_SetItemString(d, "COLORSET_ACTSELLISTBOX", PyInt_FromLong(NEWT_COLORSET_ACTSELLISTBOX));
1399
PyDict_SetItemString(d, "COLORSET_SELLISTBOX", PyInt_FromLong(NEWT_COLORSET_SELLISTBOX));
1365
setitemstring_decref(d, "GRID_GROWX", PyInt_FromLong(NEWT_GRID_FLAG_GROWX));
1366
setitemstring_decref(d, "GRID_GROWY", PyInt_FromLong(NEWT_GRID_FLAG_GROWY));
1368
setitemstring_decref(d, "FD_READ", PyInt_FromLong(NEWT_FD_READ));
1369
setitemstring_decref(d, "FD_WRITE", PyInt_FromLong(NEWT_FD_WRITE));
1370
setitemstring_decref(d, "FD_EXCEPT", PyInt_FromLong(NEWT_FD_EXCEPT));
1372
setitemstring_decref(d, "FORM_EXIT_HOTKEY", PyString_FromString("hotkey"));
1373
setitemstring_decref(d, "FORM_EXIT_WIDGET", PyString_FromString("widget"));
1374
setitemstring_decref(d, "FORM_EXIT_TIMER", PyString_FromString("timer"));
1375
setitemstring_decref(d, "FORM_EXIT_FDREADY", PyString_FromString("fdready"));
1377
setitemstring_decref(d, "KEY_TAB", PyInt_FromLong(NEWT_KEY_TAB));
1378
setitemstring_decref(d, "KEY_ENTER", PyInt_FromLong(NEWT_KEY_ENTER));
1379
setitemstring_decref(d, "KEY_SUSPEND", PyInt_FromLong(NEWT_KEY_SUSPEND));
1380
setitemstring_decref(d, "KEY_UP", PyInt_FromLong(NEWT_KEY_UP));
1381
setitemstring_decref(d, "KEY_DOWN", PyInt_FromLong(NEWT_KEY_DOWN));
1382
setitemstring_decref(d, "KEY_LEFT", PyInt_FromLong(NEWT_KEY_LEFT));
1383
setitemstring_decref(d, "KEY_RIGHT", PyInt_FromLong(NEWT_KEY_RIGHT));
1384
setitemstring_decref(d, "KEY_BACKSPACE", PyInt_FromLong(NEWT_KEY_BKSPC));
1385
setitemstring_decref(d, "KEY_DELETE", PyInt_FromLong(NEWT_KEY_DELETE));
1386
setitemstring_decref(d, "KEY_HOME", PyInt_FromLong(NEWT_KEY_HOME));
1387
setitemstring_decref(d, "KEY_END", PyInt_FromLong(NEWT_KEY_END));
1388
setitemstring_decref(d, "KEY_UNTAB", PyInt_FromLong(NEWT_KEY_UNTAB));
1389
setitemstring_decref(d, "KEY_PAGEUP", PyInt_FromLong(NEWT_KEY_PGUP));
1390
setitemstring_decref(d, "KEY_PAGEGDOWN", PyInt_FromLong(NEWT_KEY_PGDN));
1391
setitemstring_decref(d, "KEY_INSERT", PyInt_FromLong(NEWT_KEY_INSERT));
1392
setitemstring_decref(d, "KEY_F1", PyInt_FromLong(NEWT_KEY_F1));
1393
setitemstring_decref(d, "KEY_F2", PyInt_FromLong(NEWT_KEY_F2));
1394
setitemstring_decref(d, "KEY_F3", PyInt_FromLong(NEWT_KEY_F3));
1395
setitemstring_decref(d, "KEY_F4", PyInt_FromLong(NEWT_KEY_F4));
1396
setitemstring_decref(d, "KEY_F5", PyInt_FromLong(NEWT_KEY_F5));
1397
setitemstring_decref(d, "KEY_F6", PyInt_FromLong(NEWT_KEY_F6));
1398
setitemstring_decref(d, "KEY_F7", PyInt_FromLong(NEWT_KEY_F7));
1399
setitemstring_decref(d, "KEY_F8", PyInt_FromLong(NEWT_KEY_F8));
1400
setitemstring_decref(d, "KEY_F9", PyInt_FromLong(NEWT_KEY_F9));
1401
setitemstring_decref(d, "KEY_F10", PyInt_FromLong(NEWT_KEY_F10));
1402
setitemstring_decref(d, "KEY_F11", PyInt_FromLong(NEWT_KEY_F11));
1403
setitemstring_decref(d, "KEY_F12", PyInt_FromLong(NEWT_KEY_F12));
1404
setitemstring_decref(d, "KEY_ESC", PyInt_FromLong(NEWT_KEY_ESCAPE));
1406
setitemstring_decref(d, "FLAG_DISABLED", PyInt_FromLong(NEWT_FLAG_DISABLED));
1407
setitemstring_decref(d, "FLAGS_SET", PyInt_FromLong(NEWT_FLAGS_SET));
1408
setitemstring_decref(d, "FLAGS_RESET", PyInt_FromLong(NEWT_FLAGS_RESET));
1409
setitemstring_decref(d, "FLAGS_TOGGLE", PyInt_FromLong(NEWT_FLAGS_TOGGLE));
1411
setitemstring_decref(d, "COLORSET_ROOT", PyInt_FromLong(NEWT_COLORSET_ROOT));
1412
setitemstring_decref(d, "COLORSET_BORDER", PyInt_FromLong(NEWT_COLORSET_BORDER));
1413
setitemstring_decref(d, "COLORSET_WINDOW", PyInt_FromLong(NEWT_COLORSET_WINDOW));
1414
setitemstring_decref(d, "COLORSET_SHADOW", PyInt_FromLong(NEWT_COLORSET_SHADOW));
1415
setitemstring_decref(d, "COLORSET_TITLE", PyInt_FromLong(NEWT_COLORSET_TITLE));
1416
setitemstring_decref(d, "COLORSET_BUTTON", PyInt_FromLong(NEWT_COLORSET_BUTTON));
1417
setitemstring_decref(d, "COLORSET_ACTBUTTON", PyInt_FromLong(NEWT_COLORSET_ACTBUTTON));
1418
setitemstring_decref(d, "COLORSET_CHECKBOX", PyInt_FromLong(NEWT_COLORSET_CHECKBOX));
1419
setitemstring_decref(d, "COLORSET_ACTCHECKBOX", PyInt_FromLong(NEWT_COLORSET_ACTCHECKBOX));
1420
setitemstring_decref(d, "COLORSET_ENTRY", PyInt_FromLong(NEWT_COLORSET_ENTRY));
1421
setitemstring_decref(d, "COLORSET_LABEL", PyInt_FromLong(NEWT_COLORSET_LABEL));
1422
setitemstring_decref(d, "COLORSET_LISTBOX", PyInt_FromLong(NEWT_COLORSET_LISTBOX));
1423
setitemstring_decref(d, "COLORSET_ACTLISTBOX", PyInt_FromLong(NEWT_COLORSET_ACTLISTBOX));
1424
setitemstring_decref(d, "COLORSET_TEXTBOX", PyInt_FromLong(NEWT_COLORSET_TEXTBOX));
1425
setitemstring_decref(d, "COLORSET_ACTTEXTBOX", PyInt_FromLong(NEWT_COLORSET_ACTTEXTBOX));
1426
setitemstring_decref(d, "COLORSET_HELPLINE", PyInt_FromLong(NEWT_COLORSET_HELPLINE));
1427
setitemstring_decref(d, "COLORSET_ROOTTEXT", PyInt_FromLong(NEWT_COLORSET_ROOTTEXT));
1428
setitemstring_decref(d, "COLORSET_EMPTYSCALE", PyInt_FromLong(NEWT_COLORSET_EMPTYSCALE));
1429
setitemstring_decref(d, "COLORSET_FULLSCALE", PyInt_FromLong(NEWT_COLORSET_FULLSCALE));
1430
setitemstring_decref(d, "COLORSET_DISENTRY", PyInt_FromLong(NEWT_COLORSET_DISENTRY));
1431
setitemstring_decref(d, "COLORSET_COMPACTBUTTON", PyInt_FromLong(NEWT_COLORSET_COMPACTBUTTON));
1432
setitemstring_decref(d, "COLORSET_ACTSELLISTBOX", PyInt_FromLong(NEWT_COLORSET_ACTSELLISTBOX));
1433
setitemstring_decref(d, "COLORSET_SELLISTBOX", PyInt_FromLong(NEWT_COLORSET_SELLISTBOX));