[6s] Break out builtin commands into a list of structs
The 6s builtin commands are now in a separate file, with a list of name, description, and function pointers.
This commit is contained in:
31
src/user/6s/commands.h
Normal file
31
src/user/6s/commands.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace edit {
|
||||
class source;
|
||||
}
|
||||
|
||||
|
||||
class builtin
|
||||
{
|
||||
public:
|
||||
using runf = void (*)(edit::source &);
|
||||
|
||||
builtin(const char *name, const char *desc, runf func) :
|
||||
m_name {name}, m_desc {desc}, m_func {func} {}
|
||||
|
||||
const char * name() const { return m_name; }
|
||||
const char * description() const { return m_desc; }
|
||||
|
||||
void run(edit::source &s) { m_func(s); }
|
||||
|
||||
private:
|
||||
const char *m_name;
|
||||
const char *m_desc;
|
||||
runf m_func;
|
||||
};
|
||||
|
||||
|
||||
extern builtin g_builtins[];
|
||||
extern size_t g_builtins_count;
|
||||
Reference in New Issue
Block a user