12 #include <format/format.h> 13 #include "../bscript/eprog.h" 14 #include "../bscript/impstr.h" 15 #include "../clib/cfgelem.h" 16 #include "../clib/cfgfile.h" 17 #include "../clib/fileutil.h" 18 #include "../clib/kbhit.h" 19 #include "../clib/logfacility.h" 20 #include "../clib/refptr.h" 21 #include "../clib/stlutil.h" 22 #include "../plib/systemstate.h" 50 if ( !( is >> charspec >>
script ) )
52 elem.
throw_error(
"Ill-formed console command desc: " + cmd );
54 if ( charspec[0] ==
'^' && charspec.size() == 2 )
56 ch =
static_cast<char>( toupper( charspec[1] ) ) -
'A' + 1;
58 else if ( charspec.size() == 1 )
64 elem.
throw_error(
"Ill-formed console command char: " + charspec );
73 ConsoleCommand::unlock_char =
ch;
121 while ( cf.
read( elem ) )
136 if ( ch == 0 || static_cast<unsigned char>( ch ) == 0xE0 )
145 tmp <<
"Commands: \n";
150 if ( sc.size() == 1 )
152 tmp <<
" " << sc <<
": ";
155 tmp <<
" ?: Help (This list)\n";
167 if ( cmd->
script ==
"[lock]" )
169 ConsoleCommand::console_locked =
true;
173 if ( cmd->
script ==
"[unlock]" )
175 ConsoleCommand::console_locked =
true;
179 if ( cmd->
script ==
"[lock/unlock]" )
182 if ( ConsoleCommand::console_locked )
188 if ( cmd->
script ==
"[threadstatus]" )
193 if ( cmd->
script ==
"[crash]" )
200 if ( ConsoleCommand::console_locked )
202 INFO_PRINT <<
"Console is locked. Press '" << ConsoleCommand::unlock_char <<
"' to unlock.\n";
206 std::string filename =
"scripts/console/" + cmd->
script;
214 if ( prog.
get() != nullptr )
217 catch (
const char* msg )
219 ERROR_PRINT <<
"Command aborted due to: " << msg <<
"\n";
221 catch ( std::string& str )
223 ERROR_PRINT <<
"Command aborted due to: " << str <<
"\n";
225 catch ( std::runtime_error& re )
227 ERROR_PRINT <<
"Command aborted due to: " << re.what() <<
"\n";
229 catch ( std::exception& ex )
231 ERROR_PRINT <<
"Command aborted due to: " << ex.what() <<
"\n";
235 ERROR_PRINT <<
"Command aborted due to: " << xn <<
"\n";
ref_ptr< Bscript::EScriptProgram > find_script2(const ScriptDef &script, bool complain_if_not_found, bool cache_script)
void quickconfig(const Plib::Package *pkg, const std::string &name_ecl)
static void load_console_commands()
static void check_console_commands(Clib::KeyboardHook *kb)
static bool console_locked
POL_NORETURN void throw_error(const std::string &errmsg) const
std::vector< ConsoleCommand > console_commands
std::string getcmdstr(char ch)
static ConsoleCommand * find_console_command(char ch)
volatile bool report_status_signalled
StateManager stateManager
bool remove_prop(const char *propname, std::string *value)
static void exec_console_cmd(char ch)
size_t estimateSize() const
bool FileExists(const char *filename)
bool read(ConfigElem &elem)
void start_script(const char *filename, Bscript::BObjectImp *param0, Bscript::BObjectImp *param1)
ConsoleCommand(Clib::ConfigElem &elem, const std::string &cmd)