]> git.mdlowis.com Git - projs/tide.git/commitdiff
added color, copy indent, and expand tab settings to config.h
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 26 May 2017 01:40:57 +0000 (21:40 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 26 May 2017 01:40:57 +0000 (21:40 -0400)
config.h
inc/edit.h
lib/buf.c
lib/view.c
lib/win.c

index 5ff5bfe4521609b27a23c90b4dc61b6301f2733c..925510f32f7160b31da781722c6aa501e145f4ed 100644 (file)
--- a/config.h
+++ b/config.h
@@ -2,6 +2,9 @@
 extern char *FontString, *DefaultTags;
 extern unsigned int ColorPalette[16];
 extern char *ShellCmd[], *SedCmd[], *PickFileCmd[], *PickTagCmd[], *OpenCmd[];
+extern int CLR_NormalText, CLR_SelectedText, CLR_TagsBkg, CLR_EditBkg,
+           CLR_HorBorder, CLR_VerBorder, CLR_Ruler, CLR_ScrollBkg, CLR_ThumbBkg,
+           CLR_Cursor;
 
 /* OS-Specific Config
  ******************************************************************************/
@@ -18,17 +21,19 @@ extern char *ShellCmd[], *SedCmd[], *PickFileCmd[], *PickTagCmd[], *OpenCmd[];
 enum {
     Width          = 640,     /* default window width */
     Height         = 480,     /* default window height */
+    ExpandTabs     = 1,       /* Tabs will be expanded to spaces */
     TabWidth       = 4,       /* maximum number of spaces used to represent a tab */
     ScrollLines    = 4,       /* number of lines to scroll by for mouse wheel scrolling */
     BufSize        = 8192,    /* default buffer size */
-    FontCacheSize  = 16,      /* Maximum number of fonts allowed in the font cache */
     EventTimeout   = 50,      /* Maximum blocking wait time for events */
     TrimOnSave     = 1,       /* Enable trimming of trailing whitespace on save */
     DefaultCRLF    = 0,       /* Default to Unix line endings */
     DefaultCharset = UTF_8,   /* We assume UTF-8 because nothing else matters */
+    FontCacheSize  = 16,      /* Maximum number of fonts allowed in the font cache */
     LineSpacing    = LNSPACE, /* Set the vertical spacing between lines */
     DblClickTime   = 250,     /* Millisecond time for detecting double clicks */
     RulePosition   = 80,      /* Column in which the vertical ruler appears */
+    CopyIndent     = 1,       /* New lines will inherit the indent of the preceding line */
 };
 
 #ifdef INCLUDE_DEFS
@@ -39,26 +44,6 @@ char* DefaultTags = "Quit Save Undo Redo Cut Copy Paste | Find ";
 /* Default font string */
 char* FontString = FONT;
 
-/* 16 color palette used for drawing */
-unsigned int ColorPalette[16] = {
-    0xff002b36,
-    0xff073642,
-    0xff586e75,
-    0xff657b83,
-    0xff839496,
-    0xff93a1a1,
-    0xffeee8d5,
-    0xfffdf6e3,
-    0xffb58900,
-    0xffcb4b16,
-    0xffdc322f,
-    0xffd33682,
-    0xff6c71c4,
-    0xff268bd2,
-    0xff2aa198,
-    0xff859900
-};
-
 /* The shell: Filled in with $SHELL. Used to execute commands */
 char* ShellCmd[] = { NULL, "-c", NULL, NULL };
 
@@ -74,5 +59,37 @@ char* PickTagCmd[] = { "xtagpick", NULL, "tags", NULL, NULL };
 /* Open a new instance of the editor */
 char* OpenCmd[] = { "xedit", NULL, NULL };
 
+/* Solarized Theme - 16 color palette used for drawing */
+unsigned int ColorPalette[16] = {
+    0xff002b36, // 00 - Base03
+    0xff073642, // 01 - Base02
+    0xff586e75, // 02 - Base01
+    0xff657b83, // 03 - Base00
+    0xff839496, // 04 - Base0
+    0xff93a1a1, // 05 - Base1
+    0xffeee8d5, // 06 - Base2
+    0xfffdf6e3, // 07 - Base3
+    0xffb58900, // 08 - Yellow
+    0xffcb4b16, // 09 - Orange
+    0xffdc322f, // 10 - Red
+    0xffd33682, // 11 - Magenta
+    0xff6c71c4, // 12 - Violet
+    0xff268bd2, // 13 - Blue
+    0xff2aa198, // 14 - Cyan
+    0xff859900  // 15 - Green
+};
+
+#define COLOR_PAIR(bg, fg) (((bg) << 8) | (fg))
+int CLR_NormalText   = COLOR_PAIR(0,4);
+int CLR_SelectedText = COLOR_PAIR(4,0);
+int CLR_TagsBkg      = 1; // Background color for the tags region
+int CLR_EditBkg      = 0; // Background color for the edit region
+int CLR_ScrollBkg    = 3; // Background color for the scroll region
+int CLR_ThumbBkg     = 0; // Background color of the scroll thumb
+int CLR_HorBorder    = 2; // Horizontal border color
+int CLR_VerBorder    = 2; // Vertical border color
+int CLR_Ruler        = 1; // Ruler color
+int CLR_Cursor       = 7; // Cursor color
+
 #undef INCLUDE_DEFS
 #endif
index 4a83fd391108984b6bad30e3af52a897498075d6..9e17422edc9d4368952fbfc4bb4e9db97773768f 100644 (file)
@@ -191,26 +191,3 @@ int cmdrun(char** cmd, char** err);
 char* cmdread(char** cmd, char** err);
 void cmdwrite(char** cmd, char* text, char** err);
 char* cmdwriteread(char** cmd, char* text, char** err);
-
-/* Color Scheme Handling
- *****************************************************************************/
-/* color indexes for the colorscheme */
-enum ColorId {
-    CLR_BASE03  = 0,
-    CLR_BASE02  = 1,
-    CLR_BASE01  = 2,
-    CLR_BASE00  = 3,
-    CLR_BASE0   = 4,
-    CLR_BASE1   = 5,
-    CLR_BASE2   = 6,
-    CLR_BASE3   = 7,
-    CLR_YELLOW  = 8,
-    CLR_ORANGE  = 9,
-    CLR_RED     = 10,
-    CLR_MAGENTA = 11,
-    CLR_VIOLET  = 12,
-    CLR_BLUE    = 13,
-    CLR_CYAN    = 14,
-    CLR_GREEN   = 15,
-    CLR_COUNT   = 16
-};
index f03f24d9451bd2b53bce49f15861a5e45fa79722..b8dca1dbc19d1e803249e93e7eda770f81337d2e 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -181,8 +181,8 @@ void buf_init(Buf* buf, void (*errfn)(char*)) {
 
     /* reset the state to defaults */
     buf->modified    = false;
-    buf->expand_tabs = true;
-    buf->copy_indent = true;
+    buf->expand_tabs = (ExpandTabs == 1);
+    buf->copy_indent = (CopyIndent == 1);
     buf->charset     = DefaultCharset;
     buf->crlf        = DefaultCRLF;
     buf->bufsize     = BufSize;
index ea60100d4e46dff4bec5876034f4d01bf5fa4f6d..50bdd2cf4657461087be4b34e74df41de02edb4f 100644 (file)
@@ -4,9 +4,6 @@
 #include <ctype.h>
 #include <config.h>
 
-#define ATTR_NORMAL   (CLR_BASE03 << 8 | CLR_BASE0)
-#define ATTR_SELECTED (CLR_BASE0  << 8 | CLR_BASE03)
-
 static void clearrow(View* view, size_t row) {
     Row* scrrow = view_getrow(view, row);
     if (!scrrow) return;
@@ -63,7 +60,7 @@ static size_t fill_row(View* view, unsigned row, size_t pos) {
     view_getrow(view, row)->off = pos;
     clearrow(view, row);
     for (size_t x = 0; x < view->ncols;) {
-        uint32_t attr = (selected(view, pos) ? ATTR_SELECTED : ATTR_NORMAL);
+        uint32_t attr = (selected(view, pos) ? CLR_SelectedText : CLR_NormalText);
         Rune r = buf_get(&(view->buffer), pos++);
         x += setcell(view, row, x, attr, r);
         if (buf_iseol(&(view->buffer), pos-1)) break;
index 2260bdda93245c47c2e9d0eaf3465c1179411912..84666837fe46f89abd7e98ed1f10ba9dcf1a4285 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -185,17 +185,17 @@ static void onredraw(int width, int height) {
     layout(width, height);
     onupdate(); // Let the user program update the status and other content
     view_update(win_view(STATUS), &(Regions[STATUS].csrx), &(Regions[STATUS].csry));
-    view_update(win_view(TAGS), &(Regions[TAGS].csrx), &(Regions[TAGS].csry));
-    view_update(win_view(EDIT), &(Regions[EDIT].csrx), &(Regions[EDIT].csry));
+    view_update(win_view(TAGS),   &(Regions[TAGS].csrx),   &(Regions[TAGS].csry));
+    view_update(win_view(EDIT),   &(Regions[EDIT].csrx),   &(Regions[EDIT].csry));
     onlayout(); // Let the user program update the scroll bar
 
     for (int i = 0; i < SCROLL; i++) {
         View* view = win_view(i);
-        x11_draw_rect((i == TAGS ? CLR_BASE02 : CLR_BASE03),
+        x11_draw_rect((i == TAGS ? CLR_TagsBkg : CLR_EditBkg),
             0, Regions[i].y - 3, width, Regions[i].height + 8);
-        x11_draw_rect(CLR_BASE01, 0, Regions[i].y - 3, width, 1);
+        x11_draw_rect(CLR_HorBorder, 0, Regions[i].y - 3, width, 1);
         if ((i == EDIT) && (Ruler != 0))
-            x11_draw_rect(CLR_BASE02, (Ruler+2) * fwidth, Regions[i].y-2, 1, Regions[i].height+7);
+            x11_draw_rect(CLR_Ruler, (Ruler+2) * fwidth, Regions[i].y-2, 1, Regions[i].height+7);
         for (size_t y = 0; y < view->nrows; y++) {
             Row* row = view_getrow(view, y);
             draw_glyphs(Regions[i].x, Regions[i].y + ((y+1) * fheight), row->cols, row->rlen, row->len);
@@ -207,13 +207,13 @@ static void onredraw(int width, int height) {
     size_t thumboff = (size_t)((thumbreg * ScrollOffset) + (Regions[SCROLL].y - 2));
     size_t thumbsz  = (size_t)(thumbreg * ScrollVisible);
     if (thumbsz < 5) thumbsz = 5;
-    x11_draw_rect(CLR_BASE01, Regions[SCROLL].width, Regions[SCROLL].y - 2, 1, Regions[SCROLL].height);
-    x11_draw_rect(CLR_BASE00, 0, Regions[SCROLL].y - 2, Regions[SCROLL].width, thumbreg);
-    x11_draw_rect(CLR_BASE03, 0, thumboff, Regions[SCROLL].width, thumbsz);
+    x11_draw_rect(CLR_VerBorder, Regions[SCROLL].width, Regions[SCROLL].y - 2, 1, Regions[SCROLL].height);
+    x11_draw_rect(CLR_ScrollBkg, 0, Regions[SCROLL].y - 2, Regions[SCROLL].width, thumbreg);
+    x11_draw_rect(CLR_ThumbBkg, 0, thumboff, Regions[SCROLL].width, thumbsz);
 
     /* place the cursor on screen */
     if (Regions[Focused].csrx != SIZE_MAX && Regions[Focused].csry != SIZE_MAX) {
-        x11_draw_rect(CLR_BASE3,
+        x11_draw_rect(CLR_Cursor,
             Regions[Focused].x + (Regions[Focused].csrx * fwidth),
             Regions[Focused].y + (Regions[Focused].csry * fheight),
             1, fheight);