diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-16 15:16:48 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-11-16 15:16:48 +0100 |
commit | 00ab4e59a8e812986c17fbc09275cfe0583286dc (patch) | |
tree | 3759020420e0e6756e9791281e5942f8ea3e723d | |
parent | 47c7925ca36cbb078391aea90aa2714bdeea949c (diff) | |
download | sciteco-00ab4e59a8e812986c17fbc09275cfe0583286dc.tar.gz |
support EF and EX arguments. FALSE (>= 0) means to refuse closing/exiting if the current file / any file is dirty (modified)
-EF and -EX may be used to enforce a close/quit without saving
-rw-r--r-- | parser.cpp | 10 | ||||
-rw-r--r-- | qbuffers.cpp | 12 | ||||
-rw-r--r-- | qbuffers.h | 2 |
3 files changed, 24 insertions, 0 deletions
@@ -1058,11 +1058,21 @@ StateECommand::custom(gchar chr) BEGIN_EXEC(&States::start); if (!ring.current) return NULL; /* FIXME */ + + if (IS_FAILURE(expressions.pop_num_calc()) && + ring.current->dirty) + return NULL; /* FIXME */ + ring.close(); break; case 'X': BEGIN_EXEC(&States::start); + + if (IS_FAILURE(expressions.pop_num_calc()) && + ring.is_any_dirty()) + return NULL; /* FIXME */ + undo.push_var<bool>(quit_requested); quit_requested = true; break; diff --git a/qbuffers.cpp b/qbuffers.cpp index 51bf65f..28b54dc 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -227,6 +227,18 @@ Ring::find(const gchar *filename) } bool +Ring::is_any_dirty(void) +{ + Buffer *cur; + + LIST_FOREACH(cur, &head, buffers) + if (cur->dirty) + return true; + + return false; +} + +bool Ring::edit(const gchar *filename) { bool new_in_ring = false; @@ -275,6 +275,8 @@ public: Buffer *find(const gchar *filename); + bool is_any_dirty(void); + bool edit(const gchar *filename); inline void undo_edit(void) |