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
******************************************************************************/
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
/* 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 };
/* 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
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
-};
/* 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;
#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;
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;
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);
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);