From f6ff327f0b7b50b74328e448ce862f7212dcae23 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 16 Nov 2012 14:42:47 +0100 Subject: keep a buffer dirty flag and display infos about the current buffer in the interfaces (including the dirty flag) * was a bit tricky because the Scintilla SAVEPOINTS cannot be (fully) used * when a file is loaded or saved, a Scintilla SAVEPOINT is set * SAVEPOINTLEFT notifications are used to set a buffer dirty * SAVEPOINTREACHED notifications are useless since Scintilla does not consider the saves themselves to be undoable * GTK interface displays infos in window title bar * NCURSES interface has also been updated and cleaned up a bit. Infos are displayed in a new info line. * NCURSES: fixed popup display after terminal resizing --- qbuffers.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'qbuffers.cpp') diff --git a/qbuffers.cpp b/qbuffers.cpp index 762566e..51bf65f 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -173,6 +173,9 @@ Buffer::load(const gchar *filename) interface.ssm(SCI_GOTOPOS, 0); interface.ssm(SCI_SETSAVEPOINT); + interface.undo_info_update(this); + undo.push_var(dirty); + dirty = false; set_filename(filename); @@ -231,7 +234,9 @@ Ring::edit(const gchar *filename) current_save_dot(); + qregisters.current = NULL; if (buffer) { + current = buffer; buffer->edit(); } else { new_in_ring = true; @@ -239,6 +244,8 @@ Ring::edit(const gchar *filename) buffer = new Buffer(); LIST_INSERT_HEAD(&head, buffer, buffers); + current = buffer; + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) { buffer->load(filename); @@ -258,9 +265,6 @@ Ring::edit(const gchar *filename) } } - qregisters.current = NULL; - current = buffer; - return new_in_ring; } @@ -377,6 +381,11 @@ Ring::save(const gchar *filename) if (!g_file_set_contents(filename, buffer, size, NULL)) return false; + interface.ssm(SCI_SETSAVEPOINT); + interface.undo_info_update(current); + undo.push_var(current->dirty); + current->dirty = false; + /* * FIXME: necessary also if the filename was not specified but the file * is (was) new, in order to canonicalize the filename. -- cgit v1.2.3