From 74a9600b2c318bb0285322a83c78553c8da1efaa Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 5 Dec 2016 09:37:32 -0500 Subject: [PATCH] buf_ins boolean flag should disable both copyindent *and* expand tabs. This ensures the file is loaded into the buffer unmodified. --- TODO.md | 14 ++++++-------- libedit/buf.c | 6 +++--- xedit.c | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/TODO.md b/TODO.md index 6d24c36..45b4a3f 100644 --- a/TODO.md +++ b/TODO.md @@ -1,19 +1,17 @@ # Implementation Tweaks and Bug Fixes +* add tag for toggling expand tabs +* add tag for toggling auto indent +* Expand tabs setting should be disabled if opened file contains tabs +* Add tag for ctags lookup and line number jump * add a shortcut to autocomplete ctag +* off by one error on scrolling up with wrapped lines +* block selection should handle brace-balancing * Use select to check for error strings in exec.c * Should not be able to undo initial tag line text insertion * track down double click bug for selecting whole line -* Add tag for ctags lookup * Implement minimal regex search (per Kernighan article) * Implement fuzzy file/buffer/tag picker -* Implement omnicomplete pop-up -* off by one error on scrolling up with wrapped lines -* block selection should handle brace-balancing - -# Internals and Miscellaneous - -* Calculate line numbers and keep up to date while editing # Auxillary Programs diff --git a/libedit/buf.c b/libedit/buf.c index f2f5e17..0e981e9 100644 --- a/libedit/buf.c +++ b/libedit/buf.c @@ -168,9 +168,9 @@ static unsigned getindent(Buf* buf, unsigned off) { return buf_getcol(buf, off) / TabWidth; } -unsigned buf_ins(Buf* buf, bool indent, unsigned off, Rune rune) { +unsigned buf_ins(Buf* buf, bool fmt, unsigned off, Rune rune) { buf->modified = true; - if (buf->expand_tabs && rune == '\t') { + if (fmt && 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++, ' '); @@ -178,7 +178,7 @@ unsigned buf_ins(Buf* buf, bool indent, unsigned off, Rune rune) { log_insert(&(buf->undo), off, off+1); insert(buf, off++, rune); } - if (indent && buf->copy_indent && (rune == '\n' || rune == RUNE_CRLF)) { + if (fmt && buf->copy_indent && (rune == '\n' || rune == RUNE_CRLF)) { unsigned indent = getindent(buf, off-1); for (; indent > 0; indent--) off = buf_ins(buf, indent, off, '\t'); diff --git a/xedit.c b/xedit.c index 81abc1c..11edeb4 100644 --- a/xedit.c +++ b/xedit.c @@ -113,6 +113,7 @@ static KeyBinding Bindings[] = { /* Standard Unix Shortcuts */ { ModCtrl, 'u', del_to_bol }, + //{ ModCtrl, 'k', del_to_eol }, { ModCtrl, 'w', del_to_bow }, { ModCtrl, 'h', backspace }, { ModCtrl, 'a', cursor_home }, -- 2.49.0