| 470 | } |
| 471 | |
| 472 | static int dfhack_lineedit(lua_State *S) |
| 473 | { |
| 474 | lua_settop(S, 2); |
| 475 | |
| 476 | Console *pstream = get_console(S); |
| 477 | if (!pstream) { |
| 478 | lua_pushnil(S); |
| 479 | lua_pushstring(S, "no console"); |
| 480 | return 2; |
| 481 | } |
| 482 | |
| 483 | lua_rawgetp(S, LUA_REGISTRYINDEX, &DFHACK_QUERY_COROTABLE_TOKEN); |
| 484 | lua_rawgetp(S, -1, S); |
| 485 | bool in_coroutine = !lua_isnil(S, -1); |
| 486 | lua_settop(S, 2); |
| 487 | |
| 488 | if (in_coroutine) |
| 489 | { |
| 490 | lua_pushcfunction(S, yield_helper); |
| 491 | lua_pushvalue(S, 1); |
| 492 | lua_pushvalue(S, 2); |
| 493 | return Lua::TailPCallK<dfhack_lineedit_cont>(S, 2, LUA_MULTRET, 0, 0); |
| 494 | } |
| 495 | |
| 496 | return dfhack_lineedit_sync(S, pstream); |
| 497 | } |
| 498 | |
| 499 | /* |
| 500 | * Exception handling |
nothing calls this directly
no test coverage detected