Buffer: add NewFile buffer type for buffer with an non existing yet file
This commit is contained in:
parent
959ec46a16
commit
830d96f7a1
|
@ -28,7 +28,11 @@ Buffer::Buffer(const std::string& name, Type type,
|
||||||
{
|
{
|
||||||
BufferManager::instance().register_buffer(this);
|
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();
|
compute_lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ public:
|
||||||
enum class Type
|
enum class Type
|
||||||
{
|
{
|
||||||
File,
|
File,
|
||||||
|
NewFile,
|
||||||
Scratch
|
Scratch
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,7 @@ Buffer* open_or_create(const std::string& filename)
|
||||||
catch (file_not_found& what)
|
catch (file_not_found& what)
|
||||||
{
|
{
|
||||||
print_status("new file " + filename);
|
print_status("new file " + filename);
|
||||||
buffer = new Buffer(filename, Buffer::Type::File);
|
buffer = new Buffer(filename, Buffer::Type::NewFile);
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ void quit(const CommandParameters& params, const Context& context)
|
||||||
{
|
{
|
||||||
for (auto& buffer : BufferManager::instance())
|
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");
|
print_status("modified buffer remaining");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user