summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mixlib/mix_vm_command.c81
1 files changed, 68 insertions, 13 deletions
diff --git a/mixlib/mix_vm_command.c b/mixlib/mix_vm_command.c
index b3156c2..4f0295f 100644
--- a/mixlib/mix_vm_command.c
+++ b/mixlib/mix_vm_command.c
@@ -95,9 +95,13 @@ DEC_FUN (cbpa_);
DEC_FUN (cabp_);
DEC_FUN (weval_);
DEC_FUN (w2d_);
-DEC_FUN (trace_);
+DEC_FUN (tracing_);
DEC_FUN (edit_);
DEC_FUN (compile_);
+DEC_FUN (pedit_);
+DEC_FUN (sedit_);
+DEC_FUN (pasm_);
+DEC_FUN (sasm_);
/* internal command info struct */
typedef struct {
@@ -113,8 +117,14 @@ command_ commands_[] = {
{ "help", cmd_help_, N_("Display this text"), "help [COMMAND]"},
{ "load", cmd_load_, N_("Load a MIX code file"), "load FILENAME"},
{ "edit", cmd_edit_, N_("Edit a MIXAL source file"), "edit [FILENAME]"},
+ { "pedit", cmd_pedit_, N_("Print the external editor command"), "pedit"},
+ { "sedit", cmd_sedit_, N_("Set the external editor command"),
+ "sedit COMMAND (e.g. emacs %s)"},
{ "compile", cmd_compile_, N_("Compile a MIXAL source file"),
"compile [FILENAME]"},
+ { "pasm", cmd_pasm_, N_("Print the compile command"), "pasm"},
+ { "sasm", cmd_sasm_, N_("Set the compile command"),
+ "sasm COMMAND (e.g. mixasm -g -l %s)"},
{ "run", cmd_run_, N_("Run loaded or given MIX code file"),
"run [FILENAME]"},
{ "next", cmd_next_, N_("Execute next instruction(s)"),
@@ -145,13 +155,13 @@ command_ commands_[] = {
{ "weval", cmd_weval_, N_("Evaluate a given W-expression"), "weval WEXPR"},
{ "w2d", cmd_w2d_, N_("Convert a MIX word to its decimal value"),
"w2d WORD"},
- { "trace", cmd_trace_, N_("Turn on/off instruction tracing."),
- "trace on|off"},
+ { "tracing", cmd_tracing_, N_("Turn on/off instruction tracing"),
+ "tracing on|off"},
{ NULL, NULL, NULL, NULL},
};
/* configuration keys */
-static const gchar *TRACE_KEY_ = "Trace";
+static const gchar *TRACING_KEY_ = "Tracing";
static const gchar *EDITOR_KEY_ = "Editor";
static const gchar *ASM_KEY_ = "Assembler";
@@ -235,8 +245,8 @@ mix_vm_cmd_dispatcher_new_with_config (FILE *out, FILE *err,
mix_vm_cmd_dispatcher_t *result = mix_vm_cmd_dispatcher_new (out, err);
if (result != NULL && (result->config = config) != NULL)
{
- const gchar *val = mix_config_get (result->config, TRACE_KEY_);
- if (val) cmd_trace_ (result, val);
+ const gchar *val = mix_config_get (result->config, TRACING_KEY_);
+ if (val) cmd_tracing_ (result, val);
val = mix_config_get (result->config, EDITOR_KEY_);
if (val) mix_vm_cmd_dispatcher_set_editor (result, val);
val = mix_config_get (result->config, ASM_KEY_);
@@ -532,10 +542,17 @@ cmd_help_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
for (i = 0; commands_[i].name; i++)
{
- if (!*arg || (strcmp (arg, commands_[i].name) == 0))
+ if (!arg || !*arg)
{
- fprintf (dis->out ,_("%s\t\t%s. Usage: %s\n"), commands_[i].name,
- _(commands_[i].doc), commands_[i].usage);
+ fprintf (dis->out ,_("%s\t\t%s\n"), commands_[i].name,
+ _(commands_[i].doc));
+ printed++;
+ }
+ else if ((strcmp (arg, commands_[i].name) == 0))
+ {
+ fprintf (dis->out ,_("%s\t\t%s.\n\t\tUsage: %s\n"),
+ commands_[i].name, _(commands_[i].doc),
+ commands_[i].usage);
printed++;
}
}
@@ -1295,21 +1312,59 @@ cmd_w2d_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
}
static gboolean
-cmd_trace_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
+cmd_tracing_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
{
static const gchar *ON = "on";
static const gchar *OFF = "off";
if (arg && !strcmp (arg, ON))
{
dis->trace = TRUE;
- if (dis->config) mix_config_update (dis->config, TRACE_KEY_, ON);
+ if (dis->config) mix_config_update (dis->config, TRACING_KEY_, ON);
}
else if (arg && !strcmp (arg, OFF))
{
dis->trace = FALSE;
- if (dis->config) mix_config_update (dis->config, TRACE_KEY_, OFF);
+ if (dis->config) mix_config_update (dis->config, TRACING_KEY_, OFF);
}
else
- cmd_help_ (dis, "trace");
+ cmd_help_ (dis, "tracing");
+ return TRUE;
+}
+
+static gboolean
+cmd_pedit_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
+{
+ const gchar *ed = mix_vm_cmd_dispatcher_get_editor (dis);
+ if (dis)
+ fprintf (dis->out, "Edit command:%s\n", ed);
+ else
+ fprintf (dis->out, "Edit command not set (use sedit)\n");
+ return TRUE;
+}
+
+static gboolean
+cmd_sedit_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
+{
+ if (!arg || !strlen (arg)) return cmd_help_ (dis, "sedit");
+ mix_vm_cmd_dispatcher_set_editor (dis, arg);
+ return TRUE;
+}
+
+static gboolean
+cmd_pasm_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
+{
+ const gchar *ed = mix_vm_cmd_dispatcher_get_assembler (dis);
+ if (dis)
+ fprintf (dis->out, "Compile command:%s\n", ed);
+ else
+ fprintf (dis->out, "Compile command not set (use sasm)\n");
+ return TRUE;
+}
+
+static gboolean
+cmd_sasm_ (mix_vm_cmd_dispatcher_t *dis, const gchar *arg)
+{
+ if (!arg || !strlen (arg)) return cmd_help_ (dis, "sasm");
+ mix_vm_cmd_dispatcher_set_assembler (dis, arg);
return TRUE;
}