summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/debug.cc27
-rw-r--r--src/debug.hh13
-rw-r--r--src/main.cc2
3 files changed, 42 insertions, 0 deletions
diff --git a/src/debug.cc b/src/debug.cc
new file mode 100644
index 00000000..2aa7b179
--- /dev/null
+++ b/src/debug.cc
@@ -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);
+}
+
+}
diff --git a/src/debug.hh b/src/debug.hh
new file mode 100644
index 00000000..7fdb226c
--- /dev/null
+++ b/src/debug.hh
@@ -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
diff --git a/src/main.cc b/src/main.cc
index 55d1a291..32a13508 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -7,6 +7,7 @@
#include "register_manager.hh"
#include "selectors.hh"
#include "assert.hh"
+#include "debug.hh"
#include <unordered_map>
#include <map>
@@ -568,6 +569,7 @@ int main(int argc, char* argv[])
try
{
char c = getch();
+ write_debug(std::string("key ") + c + '\n');
if (isdigit(c))
count = count * 10 + c - '0';