edit an action, using title_prompt for text entry @return true if an action was fully set
| 1362 | /// edit an action, using title_prompt for text entry |
| 1363 | /// @return true if an action was fully set |
| 1364 | bool edit_action() |
| 1365 | { |
| 1366 | char buff[1024]; |
| 1367 | const string edit_prompt = make_stringf("<w>%s</w>\nInput new %s for %s:", |
| 1368 | prompt.c_str(), |
| 1369 | parent.mode_name().c_str(), |
| 1370 | _keyseq_desc(key).c_str()); |
| 1371 | |
| 1372 | int old_last_hovered = last_hovered; |
| 1373 | set_hovered(-1); |
| 1374 | set_more("Input a key sequence. Use <w>\\{n}</w> to enter keycode <w>n</w>. [<w>esc</w>] for menu"); |
| 1375 | if (!title_prompt(buff, sizeof(buff), edit_prompt.c_str())) |
| 1376 | { |
| 1377 | set_hovered(old_last_hovered); |
| 1378 | set_more(""); |
| 1379 | // line reader success code is 0 |
| 1380 | return lastch == 0; |
| 1381 | } |
| 1382 | |
| 1383 | keyseq new_action = parse_keyseq(buff); |
| 1384 | // it's still possible to get a blank keyseq by having parsing |
| 1385 | // issues with backslashes, for example |
| 1386 | if (!new_action.size()) |
| 1387 | { |
| 1388 | set_more(make_stringf("Parsing error in key sequence '%s'", buff)); |
| 1389 | return true; |
| 1390 | } |
| 1391 | set_hovered(old_last_hovered); |
| 1392 | action = new_action; |
| 1393 | reset_key_prompt(); |
| 1394 | update_menu(true); |
| 1395 | return true; |
| 1396 | } |
| 1397 | |
| 1398 | bool process_key(int keyin) |
| 1399 | { |
nothing calls this directly
no test coverage detected