# Implementation Tweaks and Bug Fixes
+* Auto indent mode
* Should not be able to undo initial tag line text insertion
* Disallow scrolling past end of buffer
* track down double click bug for selecting whole line
* Implement minimal regex search (per Kernighan article)
* Implement fuzzy file/buffer/tag picker
* Implement omnicomplete pop-up
-* Mode to expand tabs to spaces
-* Auto indent mode
* off by one error on scrolling up with wrapped lines
* block selection should handle brace-balancing
-* Right click should fetch file if it exists, search otherwise
- * directories in browse?
# Internals and Miscellaneous
void buf_load(Buf* buf, char* path);
void buf_save(Buf* buf);
void buf_init(Buf* buf);
-void buf_ins(Buf* buf, unsigned pos, Rune);
+unsigned buf_ins(Buf* buf, unsigned pos, Rune);
void buf_del(Buf* buf, unsigned pos);
unsigned buf_undo(Buf* buf, unsigned pos);
unsigned buf_redo(Buf* buf, unsigned pos);
}
void buf_init(Buf* buf) {
- buf->modified = false;
- buf->charset = DEFAULT_CHARSET;
- buf->crlf = DEFAULT_CRLF;
- buf->bufsize = BufSize;
- buf->bufstart = (Rune*)malloc(buf->bufsize * sizeof(Rune));
- buf->bufend = buf->bufstart + buf->bufsize;
- buf->gapstart = buf->bufstart;
- buf->gapend = buf->bufend;
- buf->undo = NULL;
- buf->redo = NULL;
+ buf->modified = false;
+ buf->expand_tabs = true;
+ buf->charset = DEFAULT_CHARSET;
+ buf->crlf = DEFAULT_CRLF;
+ buf->bufsize = BufSize;
+ buf->bufstart = (Rune*)malloc(buf->bufsize * sizeof(Rune));
+ buf->bufend = buf->bufstart + buf->bufsize;
+ buf->gapstart = buf->bufstart;
+ buf->gapend = buf->bufend;
+ buf->undo = NULL;
+ buf->redo = NULL;
}
static void log_insert(Log** list, unsigned beg, unsigned end) {
buf->redo = NULL;
}
-void buf_ins(Buf* buf, unsigned off, Rune rune) {
+unsigned buf_ins(Buf* buf, unsigned off, Rune rune) {
buf->modified = true;
- log_insert(&(buf->undo), off, off+1);
+ if (buf->expand_tabs && rune == '\t') {
+ size_t n = (TabWidth - ((off - buf_bol(buf, off)) % TabWidth));
+ log_insert(&(buf->undo), off, off+n);
+ for(; n > 0; n--) insert(buf, off++, ' ');
+ } else {
+ log_insert(&(buf->undo), off, off+1);
+ insert(buf, off++, rune);
+ }
clear_redo(buf);
- insert(buf, off, rune);
+ return off;
}
static void delete(Buf* buf, unsigned off) {
return;
if (num_selected(view->selection))
view_delete(view, RIGHT, false);
- buf_ins(&(view->buffer), view->selection.end++, rune);
+ view->selection.end = buf_ins(&(view->buffer), view->selection.end, rune);
view->selection.beg = view->selection.end;
view->selection.col = buf_getcol(&(view->buffer), view->selection.end);
- view->sync_needed = true;
+ view->sync_needed = true;
}
void view_delete(View* view, int dir, bool byword) {