]> git.mdlowis.com Git - projs/tide.git/commitdiff
moved from settings from buffer to config module
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 26 Mar 2018 20:20:15 +0000 (16:20 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 26 Mar 2018 20:20:15 +0000 (16:20 -0400)
inc/edit.h
lib/buf.c
lib/config.c
lib/view.c
tide.c

index 329b9eecb67722a3642edbf0009014ffbea6dcea..37c2854fc67c78376f4dbf5c5d515f447ec9389b 100644 (file)
@@ -46,8 +46,6 @@ typedef struct Log {
 typedef struct {
     char* path;           /* the path to the open file */
     uint64_t modtime;     /* modification time of the opened file */
-    int charset;          /* the character set of the buffer */
-    int crlf;             /* tracks whether the file uses dos style line endings */
     size_t bufsize;       /* size of the buffer in runes */
     char* bufstart;       /* start of the data buffer */
     char* bufend;         /* end of the data buffer */
@@ -56,8 +54,6 @@ typedef struct {
     Log* undo;            /* undo list */
     Log* redo;            /* redo list */
     bool modified;        /* tracks whether the buffer has been modified */
-    bool expand_tabs;     /* tracks current mode */
-    bool copy_indent;     /* copy the indent level from the previous line on new lines */
     uint transid;         /* tracks the last used transaction id for log entries */
     void (*errfn)(char*); /* callback for error messages */
 } Buf;
@@ -222,7 +218,7 @@ typedef struct { int fg, bg; } CPair;
 extern char TagString[], FontString[];
 extern int Palette[16];
 extern int WinWidth, WinHeight, LineSpacing, RulerPos, Timeout, TabWidth, ScrollBy,
-    ClickTime, MaxScanDist, Syntax, CopyIndent, TrimOnSave, ExpandTabs;
+    ClickTime, MaxScanDist, Syntax, CopyIndent, TrimOnSave, ExpandTabs, DosLineFeed;
 extern CPair Colors[28];
 
 enum { /* Color Variables */
index 1de1f3e46c48d5a801dcd4e58da375ba56384caf..9841950149e61747af673d0708292f0e48509ff5 100644 (file)
--- a/lib/buf.c
+++ b/lib/buf.c
@@ -27,13 +27,8 @@ void buf_init(Buf* buf, void (*errfn)(char*)) {
         buf->bufstart = NULL;
         buf_logclear(buf);
     }
-
     /* reset the state to defaults */
     buf->modified    = false;
-    buf->expand_tabs = ExpandTabs;
-    buf->copy_indent = CopyIndent;
-    buf->charset     = BINARY;
-    buf->crlf        = 0;
     buf->bufsize     = 8192;
     buf->bufstart    = (char*)malloc(buf->bufsize);
     buf->bufend      = buf->bufstart + buf->bufsize;
@@ -122,7 +117,7 @@ size_t buf_end(Buf* buf) {
 size_t buf_insert(Buf* buf, bool fmt, size_t off, Rune rune) {
     bool is_eol = (rune == '\n');
     buf->modified = true;
-    if (fmt && buf->expand_tabs && rune == '\t') {
+    if (fmt && ExpandTabs && rune == '\t') {
         size_t tabwidth = TabWidth;
         size_t n = (tabwidth - ((off - buf_bol(buf, off)) % tabwidth));
         log_insert(buf, &(buf->undo), off, off+n);
@@ -134,7 +129,7 @@ size_t buf_insert(Buf* buf, bool fmt, size_t off, Rune rune) {
             off += n;
         }
     }
-    if (fmt && buf->copy_indent && is_eol) {
+    if (fmt && CopyIndent && is_eol) {
         size_t beg = buf_bol(buf, off-1), end = beg;
         for (; end < buf_end(buf) && (' ' == buf_get(buf, end) || '\t' == buf_get(buf, end)); end++);
         for (; beg < end; beg++)
index 9cf651eb440a0e93b9739a9fbbc74641d60431ff..8cc764e4afc41708a9ea0ea97c365e48efdfcc7f 100644 (file)
@@ -30,7 +30,8 @@ int /* Integer config options */
     Syntax = ON,
     CopyIndent = ON,
     TrimOnSave = ON,
-    ExpandTabs = ON;
+    ExpandTabs = ON,
+    DosLineFeed = OFF;
 
 int Palette[16] = {
     0xFF1d2021,
index 3dc6f007f3128e33771e283fc5ec3984fd54ad4f..7449a58d20f1e244af4e2a5387ccf6c6f911da48 100644 (file)
@@ -354,7 +354,7 @@ void view_scrollpage(View* view, int move) {
 
 void view_indent(View* view, int dir) {
     Buf* buf = &(view->buffer);
-    unsigned indoff = (buf->expand_tabs ? TabWidth : 1);
+    unsigned indoff = (ExpandTabs ? TabWidth : 1);
     selswap(&(view->selection));
     view->selection.beg = buf_bol(buf, view->selection.beg);
     view->selection.end = buf_eol(buf, view->selection.end);
diff --git a/tide.c b/tide.c
index 39751c76ecc14c23bc199c79ae46b59c5d711b72..3291eab75a1582d2d6ab1ff1b3da7ceac2fbcace 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -479,15 +479,11 @@ static void goto_ctag(void) {
 }
 
 static void tabs(void) {
-    bool enabled = !(win_buf(EDIT)->expand_tabs);
-    win_buf(EDIT)->expand_tabs = enabled;
-    win_buf(TAGS)->expand_tabs = enabled;
+    ExpandTabs = !ExpandTabs;
 }
 
 static void indent(void) {
-    bool enabled = !(win_buf(EDIT)->copy_indent);
-    win_buf(EDIT)->copy_indent = enabled;
-    win_buf(TAGS)->copy_indent = enabled;
+    CopyIndent = !CopyIndent;
 }
 
 static void del_indent(void) {
@@ -499,10 +495,8 @@ static void add_indent(void) {
 }
 
 static void eol_mode(void) {
-    int crlf = win_buf(EDIT)->crlf;
-    win_buf(EDIT)->crlf = !crlf;
-    win_buf(TAGS)->crlf = !crlf;
-    cmd_exec(crlf ? CMD_TO_UNIX : CMD_TO_DOS);
+    DosLineFeed = !DosLineFeed;
+    cmd_exec(DosLineFeed ? CMD_TO_DOS : CMD_TO_UNIX);
 }
 
 static void new_win(void) {