From 671087528b9c309724662c0de92a96a7441a4ea3 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Sun, 27 Nov 2016 11:37:39 -0500 Subject: [PATCH] Added error message for quit appended to tags view --- inc/edit.h | 1 + libedit/view.c | 8 ++++++++ xedit.c | 3 +++ 3 files changed, 12 insertions(+) diff --git a/inc/edit.h b/inc/edit.h index b8dced6..562f593 100644 --- a/inc/edit.h +++ b/inc/edit.h @@ -168,6 +168,7 @@ void view_eol(View* view); void view_undo(View* view); void view_redo(View* view); void view_putstr(View* view, char* str); +void view_append(View* view, char* str); char* view_getstr(View* view, Sel* sel); void view_scroll(View* view, int move); void view_scrollpage(View* view, int move); diff --git a/libedit/view.c b/libedit/view.c index 422f963..198d533 100644 --- a/libedit/view.c +++ b/libedit/view.c @@ -425,6 +425,14 @@ void view_putstr(View* view, char* str) { buf_loglock(&(view->buffer)); } +void view_append(View* view, char* str) { + size_t end = buf_end(&(view->buffer)); + if (view->selection.end != end) + view->selection = (Sel){ .beg = end, .end = end }; + view_putstr(view, str); + view_selprev(view); +} + char* view_getstr(View* view, Sel* range) { Buf* buf = &(view->buffer); Sel sel = (range ? *range : view->selection); diff --git a/xedit.c b/xedit.c index ece8de7..38458a7 100644 --- a/xedit.c +++ b/xedit.c @@ -376,6 +376,9 @@ static void quit(void) { prevtime = now; if (!getbuf(EDIT)->modified || num_clicks >= 2) exit(0); + else + view_append(getview(TAGS), + "File is modified. Double click Quit tag or press Ctrl+Q twice to discard changes."); } static void save(void) { -- 2.52.0