]> git.mdlowis.com Git - projs/tide.git/commitdiff
General cleanup and commenting
authorMike Lowis <mike.lowis@gentex.com>
Thu, 6 Oct 2016 13:08:07 +0000 (09:08 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Thu, 6 Oct 2016 13:08:07 +0000 (09:08 -0400)
edit.h
screen.c
xedit.c

diff --git a/edit.h b/edit.h
index 2e15ea36548f995515fff327a308092248dcd129..038839708fd237a61a32b2a99466128d246b499f 100644 (file)
--- a/edit.h
+++ b/edit.h
@@ -4,28 +4,8 @@
 #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
@@ -107,12 +87,22 @@ enum MouseBtn {
     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 {
@@ -162,18 +152,40 @@ Rune screen_getcell(unsigned row, unsigned col);
  *****************************************************************************/
 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
  *****************************************************************************/
@@ -185,8 +197,6 @@ enum {
     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 },
@@ -207,8 +217,11 @@ static const Color Palette[][2] = {
     [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
index 742818f1d569fc5ea4cbafd73392c3d32c39ac07..55db8543f336ec2134f5248e48de385b3a9fd86b 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -19,10 +19,8 @@ void screen_reflow(Buf* buf) {
 }
 
 void screen_setsize(Buf* buf, unsigned nrows, unsigned ncols) {
-    unsigned pos = 0;
     /* free the old row data */
     if (Rows) {
-        pos = Rows[1]->off;
         for (unsigned i = 0; i < NumRows; i++)
             free(Rows[i]);
         free(Rows);
diff --git a/xedit.c b/xedit.c
index 9500a3057065dc4ed4feddf7ea3cd838009fc86b..27f21f4e7380457d7464669112e20d2a06733ea1 100644 (file)
--- a/xedit.c
+++ b/xedit.c
@@ -26,6 +26,7 @@ struct {
 } X;
 Buf Buffer;
 unsigned CursorPos = 0;
+enum ColorScheme ColorBase = DEFAULT_COLORSCHEME;
 
 void die(char* m) {
     fprintf(stderr, "dying, %s\n", m);
@@ -119,7 +120,7 @@ static Rune getkey(XEvent* e) {
         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;