aboutsummaryrefslogtreecommitdiffhomepage
path: root/qbuffers.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-16 14:42:47 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-16 14:42:47 +0100
commitf6ff327f0b7b50b74328e448ce862f7212dcae23 (patch)
tree4a773dcb9120d6a7fb96fce92422667e8702dbdf /qbuffers.cpp
parent0a8f940ffe1aaf77ba12ccc02d4e382be2118151 (diff)
downloadsciteco-f6ff327f0b7b50b74328e448ce862f7212dcae23.tar.gz
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
Diffstat (limited to 'qbuffers.cpp')
-rw-r--r--qbuffers.cpp15
1 files changed, 12 insertions, 3 deletions
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.