summaryrefslogtreecommitdiff
path: root/src/winmsgcond.c
diff options
context:
space:
mode:
authorMike Gerwitz <mike@mikegerwitz.com>2013-12-09 00:01:56 -0500
committerAmadeusz Sławiński <amade@asmblr.net>2015-06-26 15:17:17 +0200
commitc78ea7a19d77f009d3a96553d5188a55e6b020cc (patch)
tree0220661704be7d78561b9ef5b5cb27c1b3ec850b /src/winmsgcond.c
parent52874e9fef2f0f047ce90d68a9f65b87172bc1e0 (diff)
downloadscreen-c78ea7a19d77f009d3a96553d5188a55e6b020cc.tar.gz
Began refactoring conditional escapes %? and %: to use WinMsgCond abstraction
Note that this retains use of omflag (see below) and qmnumrend; the latter is kept in tact beacuse that has nothing to do with conditions and should stick with rendition stuff. With regards to the flags---this was particularily difficult to understand at first; I'm still uncertain what `q' and `o' stand for, although I have determined that `q' is set to true when %? should be true and `o' is merely a flag used to keep track of whether or not %: has been encountered so that subsequent %:'s and the closing %? are handled properly. Truth be told, it's so confusing to work with that I'm going to separate the removal of omflag into another commit (to follow next) so that the diff is more easily followed.
Diffstat (limited to 'src/winmsgcond.c')
-rw-r--r--src/winmsgcond.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/winmsgcond.c b/src/winmsgcond.c
new file mode 100644
index 0000000..16f3120
--- /dev/null
+++ b/src/winmsgcond.c
@@ -0,0 +1,69 @@
+/* Copyright (c) 2013
+ * Mike Gerwitz (mike@mikegerwitz.com)
+ *
+ * This file is part of GNU screen.
+ *
+ * GNU screen is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program (see the file COPYING); if not, see
+ * <http://www.gnu.org/licenses>.
+ *
+ ****************************************************************
+ */
+
+#include "winmsgcond.h"
+
+
+/* Initialize new condition and set to false; can be used to re-initialize a
+ * condition for re-use */
+inline void wmc_init(WinMsgCond *cond, char *pos)
+{
+ cond->pos = pos;
+ wmc_clear(cond);
+}
+
+/* Mark condition as true */
+inline void wmc_set(WinMsgCond *cond)
+{
+ cond->state = true;
+}
+
+/* Clear condition (equivalent to non-match) */
+inline void wmc_clear(WinMsgCond *cond)
+{
+ cond->state = false;
+}
+
+/* Determine if condition is active (has been initialized and can be used) */
+inline bool wmc_is_active(const WinMsgCond *cond)
+{
+ return (cond->pos != NULL);
+}
+
+/* Determine if a condition is true; the result is undefined if
+ * !wmc_active(cond) */
+inline bool wmc_is_set(const WinMsgCond *cond)
+{
+ return cond->state;
+}
+
+/* Retrieve condition beginning position */
+inline char *wmc_get_pos(const WinMsgCond *cond)
+{
+ return cond->pos;
+}
+
+/* Deactivate a condition */
+inline void wmc_deinit(WinMsgCond *cond)
+{
+ cond->pos = NULL;
+}