2011-10-07 16:16:38 +02:00
|
|
|
#include "debug.hh"
|
|
|
|
|
|
|
|
#include "assert.hh"
|
|
|
|
#include "buffer_manager.hh"
|
2012-03-07 00:12:48 +01:00
|
|
|
#include "editor.hh"
|
2011-10-07 16:16:38 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
static Buffer& get_or_create_debug_buffer()
|
|
|
|
{
|
2012-04-14 03:17:09 +02:00
|
|
|
static const String debug_buffer_name("*debug*");
|
2013-03-21 19:09:31 +01:00
|
|
|
Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name);
|
2011-10-07 16:16:38 +02:00
|
|
|
|
|
|
|
if (not buffer)
|
2012-11-21 13:43:10 +01:00
|
|
|
buffer = new Buffer(debug_buffer_name, Buffer::Flags::NoUndo);
|
2011-10-07 16:16:38 +02:00
|
|
|
|
|
|
|
assert(buffer);
|
|
|
|
return *buffer;
|
|
|
|
}
|
|
|
|
|
2012-04-14 03:17:09 +02:00
|
|
|
void write_debug(const String& str)
|
2011-10-07 16:16:38 +02:00
|
|
|
{
|
|
|
|
Buffer& debug_buffer = get_or_create_debug_buffer();
|
2012-03-07 00:12:48 +01:00
|
|
|
Editor editor(debug_buffer);
|
2012-09-11 19:03:13 +02:00
|
|
|
editor.select(debug_buffer.end()-1);
|
2012-11-19 19:03:01 +01:00
|
|
|
editor.insert(str + "\n");
|
2011-10-07 16:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|