2011-10-07 16:16:38 +02:00
|
|
|
#include "debug.hh"
|
|
|
|
|
|
|
|
#include "assert.hh"
|
2013-12-20 21:10:08 +01:00
|
|
|
#include "buffer.hh"
|
2011-10-07 16:16:38 +02:00
|
|
|
#include "buffer_manager.hh"
|
2014-11-12 22:27:07 +01:00
|
|
|
#include "string.hh"
|
2011-10-07 16:16:38 +02:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2014-04-30 20:27:38 +02:00
|
|
|
void write_debug(StringView str)
|
2011-10-07 16:16:38 +02:00
|
|
|
{
|
2014-01-23 20:21:00 +01:00
|
|
|
if (not BufferManager::has_instance())
|
|
|
|
{
|
2014-04-30 20:27:38 +02:00
|
|
|
fprintf(stderr, "%s\n", (const char*)str.zstr());
|
2014-01-23 20:21:00 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-02 12:55:15 +01:00
|
|
|
const StringView debug_buffer_name = "*debug*";
|
2015-01-05 10:38:40 +01:00
|
|
|
if (Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name))
|
|
|
|
buffer->insert(buffer->end(), str);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
String line = str + ((str.empty() or str.back() != '\n') ? "\n" : "");
|
|
|
|
new Buffer(debug_buffer_name, Buffer::Flags::NoUndo, { line });
|
|
|
|
}
|
2011-10-07 16:16:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|