From 3c395e56140c991ea776fedde0eaba230060c767 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Tue, 13 Nov 2012 09:46:41 +0100 Subject: added EW...$ command * EW$ saves file with its current filename * EW$ saves file with under the specified filename (Save As) * files are stored with absolute paths in the ring --- qbuffers.h | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'qbuffers.h') diff --git a/qbuffers.h b/qbuffers.h index 79cd6ea..ca1ec32 100644 --- a/qbuffers.h +++ b/qbuffers.h @@ -14,6 +14,20 @@ #include "rbtree.h" #include "parser.h" +/* + * Auxiliary functions + */ +static inline bool +is_glob_pattern(const gchar *str) +{ + return strchr(str, '*') || strchr(str, '?'); +} + +gchar *get_absolute_path(const gchar *path); + +/* + * Classes + */ class QRegister : public RBTree::RBEntry { public: gchar *name; @@ -164,7 +178,7 @@ public: set_filename(const gchar *filename) { g_free(Buffer::filename); - Buffer::filename = filename ? g_strdup(filename) : NULL; + Buffer::filename = get_absolute_path(filename); } inline void @@ -220,6 +234,8 @@ public: current->undo_edit(); } + bool save(const gchar *filename); + void close(void); inline void undo_close(void) @@ -232,7 +248,7 @@ public: * Command states */ -class StateFile : public StateExpectString { +class StateEditFile : public StateExpectString { private: void do_edit(const gchar *filename); @@ -240,6 +256,11 @@ private: State *done(const gchar *str); }; +class StateSaveFile : public StateExpectString { +private: + State *done(const gchar *str); +}; + class StateEQCommand : public StateExpectQReg { private: State *got_register(QRegister *reg); @@ -286,7 +307,9 @@ private: }; namespace States { - extern StateFile file; + extern StateEditFile editfile; + extern StateSaveFile savefile; + extern StateEQCommand eqcommand; extern StateLoadQReg loadqreg; extern StateCtlUCommand ctlucommand; @@ -298,13 +321,4 @@ namespace States { extern StateCopyToQReg copytoqreg; } -/* - * Auxiliary functions - */ -static inline bool -is_glob_pattern(const gchar *str) -{ - return strchr(str, '*') || strchr(str, '?'); -} - #endif -- cgit v1.2.3