summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--mixutils/mixvm_command.c58
1 files changed, 13 insertions, 45 deletions
diff --git a/mixutils/mixvm_command.c b/mixutils/mixvm_command.c
index e1c03bf..8030eed 100644
--- a/mixutils/mixvm_command.c
+++ b/mixutils/mixvm_command.c
@@ -47,8 +47,6 @@ static int cmd_##name (char *arg)
DEC_FUN (help_);
DEC_FUN (shell_);
-DEC_FUN (compile_);
-DEC_FUN (edit_);
DEC_FUN (quit_);
/* A structure which contains information on the commands this program
@@ -63,8 +61,6 @@ typedef struct {
COMMAND commands[] = {
{ "help", cmd_help_, N_("Display this text"), "help [COMMAND]" },
{ "shell", cmd_shell_, N_("Execute shell command"), "shell COMMAND" },
- { "compile", cmd_compile_, N_("Compile a source file"), "compile FILENAME"},
- { "edit", cmd_edit_, N_("Edit a source file"), "edit FILENAME"},
{ "quit", cmd_quit_, N_("Quit the program"), "quit" },
{ (char *)NULL, (Function *)NULL, (char *)NULL }
};
@@ -224,33 +220,17 @@ cmd_shell_ (char *arg)
return TRUE;
}
-static int
-cmd_compile_ (char *arg)
-{
- gchar *line;
-
- if ( strlen (arg) == 0 )
- return cmd_help_ ("compile");
-
- line = g_strconcat ("mixasm -g ", arg, NULL);
- if ( system (line) == EXIT_SUCCESS )
- fputs (_("Successful compilation\n"), stderr);
- g_free (line);
-
- return TRUE;
-}
-
-static int
-cmd_edit_ (char *arg)
+
+/* external interface */
+static void
+init_dis_ (mix_vm_cmd_dispatcher_t *dis)
{
static const gchar * envars[] = { "MDK_EDITOR", "X_EDITOR", "EDITOR",
"VISUAL" };
static const guint s = sizeof (envars) / sizeof (envars[0]);
static const gchar *editor = NULL;
-
- if ( strlen (arg) == 0 )
- return cmd_help_ ("edit");
+ gchar *edit = NULL;
if (!editor)
{
@@ -258,27 +238,13 @@ cmd_edit_ (char *arg)
for (k = 0; k < s; k++)
if ( (editor = getenv (envars[k])) != NULL ) break;
}
- if (!editor)
- {
- int k;
- fputs (_("Cannot find editor ("), stderr);
- for (k = 0; k < s; k++)
- fprintf (stderr, "%s ", envars[k]);
- fputs (_("undefined)\n"), stderr);
- }
- else
- {
- gchar *line = g_strconcat (editor, " ", arg, NULL);
- system (line);
- g_free (line);
- }
-
- return TRUE;
+ if (!editor) editor = "vi";
+ edit = g_strconcat (editor, " %s", NULL);
+ mix_vm_cmd_dispatcher_set_editor (dis, edit);
+ g_free (edit);
+ mix_vm_cmd_dispatcher_set_assembler (dis, "mixasm -g %s");
}
-
-
-/* external interface */
void
mixvm_cmd_init (char *arg, gboolean use_emacs)
{
@@ -302,6 +268,8 @@ mixvm_cmd_init (char *arg, gboolean use_emacs)
if ( dis_ == NULL)
g_error (_("Failed initialisation (no memory resources)"));
+ init_dis_ (dis_);
+
/* install post hook for emacs interaction */
if (use_emacs)
{
@@ -309,7 +277,7 @@ mixvm_cmd_init (char *arg, gboolean use_emacs)
mix_vm_cmd_dispatcher_post_hook (dis_, MIX_CMD_RUN, emacs_output_, NULL);
mix_vm_cmd_dispatcher_post_hook (dis_, MIX_CMD_NEXT, emacs_output_, NULL);
}
-
+
if (arg)
mix_vm_cmd_dispatcher_dispatch (dis_, MIX_CMD_LOAD, arg);
}