aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sciteco.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-04 17:29:01 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-12-04 22:07:08 +0100
commitd8a316514c03d85b771a9dce4a8a51b875d955b3 (patch)
tree8966c29db767a155848f6d90f76771ce5b9de32e /src/sciteco.h
parentb120616b6da52e951097f69ad267de06081d218a (diff)
downloadsciteco-d8a316514c03d85b771a9dce4a8a51b875d955b3.tar.gz
autoconf preparation: move everything into src/ subdir
Diffstat (limited to 'src/sciteco.h')
-rw-r--r--src/sciteco.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/sciteco.h b/src/sciteco.h
new file mode 100644
index 0000000..88ab109
--- /dev/null
+++ b/src/sciteco.h
@@ -0,0 +1,76 @@
+#ifndef __SCITECO_H
+#define __SCITECO_H
+
+#include <glib.h>
+
+#include "interface.h"
+
+/* Autoconf-like */
+#define PACKAGE_VERSION "0.1"
+#define PACKAGE_NAME "SciTECO"
+#define PACKAGE_STRING PACKAGE_NAME " " PACKAGE_VERSION
+
+namespace Flags {
+ enum {
+ ED_HOOKS = (1 << 5)
+ };
+
+ extern gint64 ed;
+}
+
+extern gchar *cmdline;
+extern bool quit_requested;
+
+void cmdline_keypress(gchar key);
+
+#define IS_CTL(C) ((C) < ' ')
+#define CTL_ECHO(C) ((C) | 0x40)
+#define CTL_KEY(C) ((C) & ~0x40)
+
+typedef gint64 tecoBool;
+
+#define SUCCESS (-1)
+#define FAILURE (0)
+#define TECO_BOOL(X) ((X) ? SUCCESS : FAILURE)
+
+#define IS_SUCCESS(X) ((X) < 0)
+#define IS_FAILURE(X) (!IS_SUCCESS(X))
+
+#define CHR2STR(X) ((gchar []){X, '\0'})
+
+namespace String {
+
+static inline void
+append(gchar *&str1, const gchar *str2)
+{
+ /* FIXME: optimize */
+ gchar *new_str = g_strconcat(str1 ? : "", str2, NULL);
+ g_free(str1);
+ str1 = new_str;
+}
+
+static inline void
+append(gchar *&str, gchar chr)
+{
+ append(str, CHR2STR(chr));
+}
+
+} /* namespace String */
+
+namespace Validate {
+
+static inline bool
+pos(gint n)
+{
+ return n >= 0 && n <= interface.ssm(SCI_GETLENGTH);
+}
+
+static inline bool
+line(gint n)
+{
+ return n >= 0 && n < interface.ssm(SCI_GETLINECOUNT);
+}
+
+} /* namespace Validate */
+
+#endif