Buffer: add NewFile buffer type for buffer with an non existing yet file

This commit is contained in:
Maxime Coste 2012-01-31 14:01:48 +00:00
parent 959ec46a16
commit 830d96f7a1
3 changed files with 8 additions and 3 deletions

View File

@ -28,7 +28,11 @@ Buffer::Buffer(const std::string& name, Type type,
{
BufferManager::instance().register_buffer(this);
GlobalHooksManager::instance().run_hook("BufCreate", name, Context(*this));
if (type == Type::NewFile)
GlobalHooksManager::instance().run_hook("BufCreate", name, Context(*this));
else if (type == Type::File)
GlobalHooksManager::instance().run_hook("BufOpen", name, Context(*this));
compute_lines();
}

View File

@ -111,6 +111,7 @@ public:
enum class Type
{
File,
NewFile,
Scratch
};

View File

@ -515,7 +515,7 @@ Buffer* open_or_create(const std::string& filename)
catch (file_not_found& what)
{
print_status("new file " + filename);
buffer = new Buffer(filename, Buffer::Type::File);
buffer = new Buffer(filename, Buffer::Type::NewFile);
}
return buffer;
}
@ -554,7 +554,7 @@ void quit(const CommandParameters& params, const Context& context)
{
for (auto& buffer : BufferManager::instance())
{
if (buffer.type() == Buffer::Type::File and buffer.is_modified())
if (buffer.type() != Buffer::Type::Scratch and buffer.is_modified())
{
print_status("modified buffer remaining");
return;