From 4c37f988b68b35d2510de25a185e091e692d00d5 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 23 Jan 2013 18:44:26 +0100 Subject: implemented special save last commandline command ("*" at beginning of commandline macro) * only works as part of commandline macro, * at the beginning of other macros, it is treated like an arithmetic asterisk * variables defined in cmdline.cpp are now declared by new cmdline.h --- src/cmdline.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/cmdline.cpp') diff --git a/src/cmdline.cpp b/src/cmdline.cpp index f36aab5..483b011 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -35,6 +35,7 @@ #include "goto.h" #include "undo.h" #include "symbols.h" +#include "cmdline.h" static inline const gchar *process_edit_cmd(gchar key); static gchar *macro_echo(const gchar *macro); @@ -48,9 +49,14 @@ static const gchar *last_occurrence(const gchar *str, static inline gboolean filename_is_dir(const gchar *filename); gchar *cmdline = NULL; +static gchar *last_cmdline = NULL; bool quit_requested = false; +namespace States { + StateSaveCmdline save_cmdline; +} + void cmdline_keypress(gchar key) { @@ -195,7 +201,9 @@ process_edit_cmd(gchar key) Goto::table->clear(); expressions.clear(); - *cmdline = '\0'; + g_free(last_cmdline); + last_cmdline = cmdline; + cmdline = NULL; macro_pc = 0; break; } @@ -374,6 +382,21 @@ symbol_complete(SymbolList &list, const gchar *symbol, gchar completed) return insert; } +/* + * Command states + */ + +State * +StateSaveCmdline::got_register(QRegister *reg) throw (Error) +{ + BEGIN_EXEC(&States::start); + + reg->undo_set_string(); + reg->set_string(last_cmdline); + + return &States::start; +} + /* * Auxiliary functions */ -- cgit v1.2.3