aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cmdline.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-01-23 18:44:26 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2013-01-23 18:44:26 +0100
commit4c37f988b68b35d2510de25a185e091e692d00d5 (patch)
tree9f8ee521d244f7d56f8646db964fc337ca1dce93 /src/cmdline.cpp
parentaea39acc84741eb2fa868865e9fdc0395fa94478 (diff)
downloadsciteco-4c37f988b68b35d2510de25a185e091e692d00d5.tar.gz
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
Diffstat (limited to 'src/cmdline.cpp')
-rw-r--r--src/cmdline.cpp25
1 files changed, 24 insertions, 1 deletions
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;
}
@@ -375,6 +383,21 @@ symbol_complete(SymbolList &list, const gchar *symbol, gchar completed)
}
/*
+ * 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
*/