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*");
|
2011-10-07 16:16:38 +02:00
|
|
|
Buffer* buffer = BufferManager::instance().get_buffer(debug_buffer_name);
|
|
|
|
|
|
|
|
if (not buffer)
|
2012-11-20 19:47:56 +01:00
|
|
|
buffer = new Buffer(debug_buffer_name, Buffer::Flags::None, "");
|
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");
|
2012-09-11 19:03:13 +02:00
|
|
|
debug_buffer.reset_undo_data();
|
2011-10-07 16:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|