aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/parser.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-02 15:38:00 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-02 15:38:00 +0200
commit02d414b3ab447e637fef776e387aa5a07293738a (patch)
tree60d5db01e9e0cc15f1f8e84abb14138cb0ca54a3 /src/parser.h
parent6c62ccc436d972a872616c187d460ed61c8bc0d2 (diff)
downloadsciteco-02d414b3ab447e637fef776e387aa5a07293738a.tar.gz
added <FG> command and special Q-Register "$" to set and get the current working directory
* FG stands for "Folder Go" * FG behaves similar to a Unix shell `cd`. Without arguments, it changes to the $HOME directory. * The $HOME directory was previously only used by $SCITECOCONFIG on Unix. Now it is documented on its own, since the HOME directory should also be configurable on Windows - e.g. to adapt SciTECO to a MinGW or Cygwin installation. HOME is initialized just like the other environment variables. This also means that now, the $HOME Q-Register is always defined and can be used by platform-agnostic macros. * FG uses a new kind of tab-completion: for directories only. It would be annoying to complete the FG command after every directory, so this tab-completion does not close the command automatically. Theoretically, it would be possible to close the command after completing a directory with no subdirectories, but this is not supported currently. * Filename arguments are no longer completed with " " if {} escaping is in place as this brings no benefit. Instead no completion character is inserted for this escape mode. * "$" was mapped to the current directory to support an elegant way to insert/get the current directory. Also this allows the idiom "[$ FG...new_dir...$ ]$" for changing the current directory temporarily. * The Q-Register stack was extended to support restoring the string part of special Q-Registers (that overwrite the default functionality) when using the "[$" and "]$" commands. * fixed minor typos (american spelling)
Diffstat (limited to 'src/parser.h')
-rw-r--r--src/parser.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/parser.h b/src/parser.h
index a6a18bb..605c1a5 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -18,6 +18,8 @@
#ifndef __PARSER_H
#define __PARSER_H
+#include <string.h>
+
#include <glib.h>
#include "sciteco.h"
@@ -160,6 +162,12 @@ public:
: StateExpectString(_building, _last) {}
};
+class StateExpectDir : public StateExpectFile {
+public:
+ StateExpectDir(bool _building = true, bool _last = true)
+ : StateExpectFile(_building, _last) {}
+};
+
class StateStart : public State {
public:
StateStart();
@@ -200,6 +208,37 @@ private:
State *custom(gchar chr);
};
+class UndoTokenChangeDir : public UndoToken {
+ gchar *dir;
+
+public:
+ /**
+ * Construct undo token.
+ *
+ * This passes ownership of the directory string
+ * to the undo token object.
+ */
+ UndoTokenChangeDir(gchar *_dir) : dir(_dir) {}
+ ~UndoTokenChangeDir()
+ {
+ g_free(dir);
+ }
+
+ void run(void);
+
+ gsize
+ get_size(void) const
+ {
+ return dir ? sizeof(*this) + strlen(dir)
+ : sizeof(*this);
+ }
+};
+
+class StateChangeDir : public StateExpectDir {
+private:
+ State *done(const gchar *str);
+};
+
class StateCondCommand : public State {
public:
StateCondCommand();
@@ -253,6 +292,7 @@ namespace States {
extern StateControl control;
extern StateASCII ascii;
extern StateFCommand fcommand;
+ extern StateChangeDir changedir;
extern StateCondCommand condcommand;
extern StateECommand ecommand;
extern StateScintilla_symbols scintilla_symbols;
@@ -280,6 +320,12 @@ namespace States {
{
return dynamic_cast<StateExpectFile *>(current);
}
+
+ static inline bool
+ is_dir()
+ {
+ return dynamic_cast<StateExpectDir *>(current);
+ }
}
extern enum Mode {