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.hh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/buffer.hh') diff --git a/src/buffer.hh b/src/buffer.hh index 2b118c89..1ed88cf7 100644 --- a/src/buffer.hh +++ b/src/buffer.hh @@ -101,12 +101,13 @@ class Buffer : public SafeCountable, public OptionManagerWatcher, public Scope public: enum class Flags { - None = 0, - File = 1 << 0, - New = 1 << 1, - Fifo = 1 << 2, - NoUndo = 1 << 3, - Debug = 1 << 4 + None = 0, + File = 1 << 0, + New = 1 << 1, + Fifo = 1 << 2, + NoUndo = 1 << 3, + Debug = 1 << 4, + ReadOnly = 1 << 5, }; Buffer(String name, Flags flags, StringView data = {}, -- cgit v1.2.3