mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
completion to console class (nw)
This commit is contained in:
parent
ad7584603a
commit
06d0afbef9
@ -16,7 +16,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
static console_frontend *gConsole = nullptr;
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// console_frontend - constructor
|
// console_frontend - constructor
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
@ -31,6 +31,7 @@ console_frontend::console_frontend(emu_options &options, osd_interface &osd)
|
|||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
m_commands.insert(std::make_pair("quit", std::bind(&console_frontend::cmd_quit, this, _1)));
|
m_commands.insert(std::make_pair("quit", std::bind(&console_frontend::cmd_quit, this, _1)));
|
||||||
m_commands.insert(std::make_pair("exit", std::bind(&console_frontend::cmd_quit, this, _1)));
|
m_commands.insert(std::make_pair("exit", std::bind(&console_frontend::cmd_quit, this, _1)));
|
||||||
|
gConsole = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,16 +43,13 @@ console_frontend::~console_frontend()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* commandList[] = {
|
void console_frontend::completion(char const* prefix, linenoiseCompletions* lc)
|
||||||
"quit", "exit", NULL
|
{
|
||||||
};
|
for (auto cmd : m_commands)
|
||||||
|
{
|
||||||
void completionHook(char const* prefix, linenoiseCompletions* lc) {
|
if (strncmp(prefix, cmd.first.c_str(), strlen(prefix)) == 0)
|
||||||
size_t i;
|
{
|
||||||
|
linenoiseAddCompletion(lc, cmd.first.c_str());
|
||||||
for (i = 0; commandList[i] != NULL; ++i) {
|
|
||||||
if (strncmp(prefix, commandList[i], strlen(prefix)) == 0) {
|
|
||||||
linenoiseAddCompletion(lc, commandList[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,6 +129,11 @@ void console_frontend::split_command(std::vector<std::string>& arg, std::string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void completionHook(char const* prefix, linenoiseCompletions* lc)
|
||||||
|
{
|
||||||
|
gConsole->completion(prefix, lc);
|
||||||
|
}
|
||||||
|
|
||||||
void console_frontend::start_console()
|
void console_frontend::start_console()
|
||||||
{
|
{
|
||||||
linenoiseInstallWindowChangeHandler();
|
linenoiseInstallWindowChangeHandler();
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
|
|
||||||
|
struct linenoiseCompletions;
|
||||||
|
|
||||||
class console_frontend
|
class console_frontend
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -22,6 +24,7 @@ public:
|
|||||||
~console_frontend();
|
~console_frontend();
|
||||||
|
|
||||||
void start_console();
|
void start_console();
|
||||||
|
void completion(char const* prefix, linenoiseCompletions* lc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void read_console(std::string &cmdLine);
|
void read_console(std::string &cmdLine);
|
||||||
|
Loading…
Reference in New Issue
Block a user