Debug: add a write_debug function
write_debug writes in a Scratch buffer named '*debug*', so that debug messages are accessibles from within kakoune
This commit is contained in:
parent
9db4aa9691
commit
a19f4f059d
27
src/debug.cc
Normal file
27
src/debug.cc
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include "debug.hh"
|
||||||
|
|
||||||
|
#include "assert.hh"
|
||||||
|
#include "buffer_manager.hh"
|
||||||
|
|
||||||
|
namespace Kakoune
|
||||||
|
{
|
||||||
|
|
||||||
|
static Buffer& get_or_create_debug_buffer()
|
||||||
|
{
|
||||||
|
static const std::string debug_buffer_name("*debug*");
|
||||||
|
Buffer* buffer = BufferManager::instance().get_buffer(debug_buffer_name);
|
||||||
|
|
||||||
|
if (not buffer)
|
||||||
|
buffer = new Buffer(debug_buffer_name, Buffer::Type::Scratch);
|
||||||
|
|
||||||
|
assert(buffer);
|
||||||
|
return *buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_debug(const std::string& str)
|
||||||
|
{
|
||||||
|
Buffer& debug_buffer = get_or_create_debug_buffer();
|
||||||
|
debug_buffer.insert(debug_buffer.end(), str);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
src/debug.hh
Normal file
13
src/debug.hh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef debug_hh_INCLUDED
|
||||||
|
#define debug_hh_INCLUDED
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Kakoune
|
||||||
|
{
|
||||||
|
|
||||||
|
void write_debug(const std::string& str);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // debug_hh_INCLUDED
|
|
@ -7,6 +7,7 @@
|
||||||
#include "register_manager.hh"
|
#include "register_manager.hh"
|
||||||
#include "selectors.hh"
|
#include "selectors.hh"
|
||||||
#include "assert.hh"
|
#include "assert.hh"
|
||||||
|
#include "debug.hh"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -568,6 +569,7 @@ int main(int argc, char* argv[])
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
char c = getch();
|
char c = getch();
|
||||||
|
write_debug(std::string("key ") + c + '\n');
|
||||||
|
|
||||||
if (isdigit(c))
|
if (isdigit(c))
|
||||||
count = count * 10 + c - '0';
|
count = count * 10 + c - '0';
|
||||||
|
|
Loading…
Reference in New Issue
Block a user