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 */
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;
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 */
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;
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);
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++)
Syntax = ON,
CopyIndent = ON,
TrimOnSave = ON,
- ExpandTabs = ON;
+ ExpandTabs = ON,
+ DosLineFeed = OFF;
int Palette[16] = {
0xFF1d2021,
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);
}
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) {
}
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) {