MCPcopy Create free account
hub / github.com/crawl/crawl / process_key

Method process_key

crawl-ref/source/macro.cc:1398–1518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1396 }
1397
1398 bool process_key(int keyin)
1399 {
1400 // rebinding mouse click generally won't work
1401 // TODO: CK_MOUSE_Bn keys don't generally seem implemented
1402 if (is_synthetic_key(keyin)
1403 || keyin == CK_MOUSE_B2
1404 || keyin == 0 || keyin == CK_NO_KEY)
1405 {
1406 return true;
1407 }
1408 // stateful key processing:
1409 // * in raw action input mode, fill keys into raw_tmp
1410 // * in key input mode, fill exactly one key into `key`, either
1411 // by key entry or keycode
1412 // * otherwise, use normal menu key handling
1413 //
1414 // regular action input as well as keycode entry use title_prompt,
1415 // and so are handled in the superclass
1416 if (doing_raw_action_input)
1417 {
1418 if (keyin == CK_MOUSE_CLICK || keyin == CK_MOUSE_B1 || keyin == CK_MOUSE_B2)
1419 return true;
1420 if (keyin == ESCAPE || keyin == CONTROL('G'))
1421 {
1422 doing_raw_action_input = false;
1423 raw_tmp.clear();
1424 set_more("");
1425 reset_key_prompt();
1426#ifdef USE_TILE_WEB
1427 tiles.json_open_object();
1428 tiles.json_write_string("msg", "title_prompt");
1429 tiles.json_write_bool("close", true);
1430 tiles.json_close_object();
1431 tiles.finish_message();
1432#endif
1433 return true;
1434 }
1435 else if (keyin == '\r' || keyin == '\n')
1436 {
1437 doing_raw_action_input = false;
1438 if (raw_tmp.size() && raw_tmp[0] != 0)
1439 action = raw_tmp;
1440 set_more("");
1441 reset_key_prompt();
1442 return true;
1443 }
1444 raw_tmp.push_back(keyin);
1445 set_title(new MenuEntry(prompt + vtostr(raw_tmp)));
1446 return true;
1447 }
1448 else if (doing_key_input)
1449 {
1450 if (keyin == CK_MOUSE_CLICK || keyin == CK_MOUSE_B1 || keyin == CK_MOUSE_B2)
1451 return true;
1452 doing_key_input = false;
1453 if (keyin == ESCAPE || keyin == CONTROL('G'))
1454 {
1455 abort = true;

Callers

nothing calls this directly

Calls 15

is_synthetic_keyFunction · 0.85
vtostrFunction · 0.85
title_promptFunction · 0.85
read_key_codeFunction · 0.85
make_stringfFunction · 0.85
_keyseq_descFunction · 0.85
update_menuFunction · 0.85
show_specific_helpsFunction · 0.85
json_open_objectMethod · 0.80
json_write_stringMethod · 0.80
json_write_boolMethod · 0.80
json_close_objectMethod · 0.80

Tested by

no test coverage detected