From 8a4596bea9d85c86d03efa129c41530faa2a34a7 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 20 Jul 2016 20:45:50 +0300 Subject: Implement a `readonly` mode This commit introduces the `readonly` variable as well as the `-ro` command line option which prevent buffers from being overwritten on disk when the `write` command is used without arguments. Some buffers can selectively be put in readonly mode by setting the `readonly` variable on the `buffer` scope, the `global` mode will affect all buffers (even those who will be open subsequently), using the `window` scope will have no effect. Closes #685 --- src/buffer_manager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/buffer_manager.cc') diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index e743bff0..688e864a 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -78,7 +78,8 @@ void BufferManager::backup_modified_buffers() { for (auto& buf : m_buffers) { - if ((buf->flags() & Buffer::Flags::File) and buf->is_modified()) + if ((buf->flags() & Buffer::Flags::File) and buf->is_modified() + and !(buf->flags() & Buffer::Flags::ReadOnly)) write_buffer_to_backup_file(*buf); } } -- cgit v1.2.3 From e3bf01d1f9063fa25ae0f0b104eb1539d0e941b6 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sun, 24 Jul 2016 08:34:49 +0300 Subject: Replace C-style operators with their alphabetical equivalent --- src/buffer_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/buffer_manager.cc') diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index 688e864a..9826de13 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -79,7 +79,7 @@ void BufferManager::backup_modified_buffers() for (auto& buf : m_buffers) { if ((buf->flags() & Buffer::Flags::File) and buf->is_modified() - and !(buf->flags() & Buffer::Flags::ReadOnly)) + and not (buf->flags() & Buffer::Flags::ReadOnly)) write_buffer_to_backup_file(*buf); } } -- cgit v1.2.3