aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
diff options
context:
space:
mode:
authornytpu <alex@nytpu.com>2021-05-23 11:52:58 -0600
committernytpu <alex@nytpu.com>2021-05-26 14:26:43 -0600
commit39f83ab9052dde848daf95be05b0b42b50cbb5b9 (patch)
treeb9372fe3e09a4c78df042b88cadb20604a524871 /common.h
parentadd get_width() to get terminal width (diff)
downloaded-39f83ab9052dde848daf95be05b0b42b50cbb5b9.tar.bz2
ed-39f83ab9052dde848daf95be05b0b42b50cbb5b9.zip
add row and buffer structs
Diffstat (limited to 'common.h')
-rw-r--r--common.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/common.h b/common.h
index 353af27..5392155 100644
--- a/common.h
+++ b/common.h
@@ -4,8 +4,39 @@
*/
#pragma once
-#ifndef COMMON_H
+#ifndef _COMMON_H
+#define _COMMON_H
+#include <stdbool.h>
+
+// ensure that regex.h and other headers follow POSIX 2008/2017
#define _POSIX_C_SOURCE 200809L
+// XXX: possibly stop mandating C11/C17. AFAIK the only C11 feature I'm using
+// is anonymous structs/unions, which seem to be supported in GCC's &
+// Clang's extensions to C99?
+#define _ISOC11_SOURCE
+
+// default to 80 columns
+#define DEFAULT_WIDTH 80
+
+struct Row {
+ int idx; // Row number (zero-based)
+ int size; // Size of row (excluding trailing \n\0)
+ char *chars; // Row content
+};
+
+// doubles as an editor state/editor config struct as well
+struct Buffer {
+ int crow; // current row address
+ int scols; // number of columns we can display on screen
+
+ char *filename;
+ bool dirty; // has the buffer been modified since last write?
+
+ int numrows;
+ struct row *rows;
+};
+
+extern struct Buffer B;
-#endif // COMMON_H
+#endif // _COMMON_H