#include <stdbool.h>
#include <string.h>
-/* Definitons
+/* Input Handling
*****************************************************************************/
-/* color indexes for the colorscheme */
-enum ColorId {
- CLR_BASE03 = 0,
- CLR_BASE02,
- CLR_BASE01,
- CLR_BASE00,
- CLR_BASE0,
- CLR_BASE1,
- CLR_BASE2,
- CLR_BASE3,
- CLR_YELLOW,
- CLR_ORANGE,
- CLR_RED,
- CLR_MAGENTA,
- CLR_VIOLET,
- CLR_BLUE,
- CLR_CYAN,
- CLR_GREEN,
-};
-
/* key definitions */
enum Keys {
/* Define some runes in the private use area of unicode to represent
MOUSE_WHEELDOWN
};
-/* Represents an ARGB color value */
-typedef uint32_t Color;
+/* UTF-8 Handling
+ *****************************************************************************/
+enum {
+ UTF_MAX = 6u, /* maximum number of bytes that make up a rune */
+ RUNE_SELF = 0x80, /* byte values larger than this are *not* ascii */
+ RUNE_ERR = 0xFFFD, /* rune value representing an error */
+ RUNE_MAX = 0x10FFFF, /* Maximum decodable rune value */
+ RUNE_EOF = EOF /* ruen value representing end of file */
+};
/* Represents a unicode code point */
typedef uint32_t Rune;
+size_t utf8encode(char str[UTF_MAX], Rune rune);
+bool utf8decode(Rune* rune, size_t* length, int byte);
+
/* Buffer management functions
*****************************************************************************/
typedef struct buf {
*****************************************************************************/
void die(char* msg);
-/* UTF-8 Handling
+/* Color Scheme Handling
*****************************************************************************/
-enum {
- UTF_MAX = 6u, /* maximum number of bytes that make up a rune */
- RUNE_SELF = 0x80, /* byte values larger than this are *not* ascii */
- RUNE_ERR = 0xFFFD, /* rune value representing an error */
- RUNE_MAX = 0x10FFFF, /* Maximum decodable rune value */
- RUNE_EOF = EOF /* ruen value representing end of file */
+
+/* color indexes for the colorscheme */
+enum ColorId {
+ CLR_BASE03 = 0,
+ CLR_BASE02,
+ CLR_BASE01,
+ CLR_BASE00,
+ CLR_BASE0,
+ CLR_BASE1,
+ CLR_BASE2,
+ CLR_BASE3,
+ CLR_YELLOW,
+ CLR_ORANGE,
+ CLR_RED,
+ CLR_MAGENTA,
+ CLR_VIOLET,
+ CLR_BLUE,
+ CLR_CYAN,
+ CLR_GREEN,
};
-size_t utf8encode(char str[UTF_MAX], Rune rune);
-bool utf8decode(Rune* rune, size_t* length, int byte);
+/* Represents an ARGB color value */
+typedef uint32_t Color;
+
+/* two colorscheme variants are supported, a light version and a dark version */
+enum ColorScheme {
+ DARK = 0,
+ LIGHT = 1
+};
+
+/* variable for holding the currently selected color scheme */
+enum ColorScheme ColorBase;
/* Configuration
*****************************************************************************/
BufSize = 8192, /* default buffer size */
};
-static enum { DARK = 0, LIGHT = 1 } ColorBase = DARK;
-
static const Color Palette[][2] = {
/* Color Name = Dark Light */
[CLR_BASE03] = { 0x002b36, 0xfdf6e3 },
[CLR_GREEN] = { 0x859900, 0x859900 },
};
+/* choose the font to use for xft */
#ifdef __MACH__
#define FONTNAME "Inconsolata:pixelsize=14:antialias=true:autohint=true"
#else
#define FONTNAME "Liberation Mono:pixelsize=14:antialias=true:autohint=true"
#endif
+
+#define DEFAULT_COLORSCHEME DARK
} X;
Buf Buffer;
unsigned CursorPos = 0;
+enum ColorScheme ColorBase = DEFAULT_COLORSCHEME;
void die(char* m) {
fprintf(stderr, "dying, %s\n", m);
if (buf[0] == '\r') buf[0] = '\n';
for(int i = 0; i < 8 && !utf8decode(&rune, &len, buf[i]); i++);
}
- printf("key: 0x%#x\n", rune);
+ printf("key: %#x\n", rune);
/* translate the key code into a unicode codepoint */
switch (key) {
case XK_F1: return KEY_F1;