diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-08-10 11:26:26 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-08-12 20:02:11 +1000 |
| commit | 560e3631ec57d34c679e6b0faec1e0efdd18d915 (patch) | |
| tree | 4b4e00ab1fefaaa4a98b3d6a7c46fab50120fd8b /src/buffer_utils.cc | |
| parent | 6ed01f402b3a54495c8d9e462b7674864fbbe402 (diff) | |
Move debug utils to debug.hh/debug.cc
Lots of code includes buffer_utils.hh just for write_to_debug_buffer
which pulls many unnecessary dependencies. Reorganise to reduce
compile times.
Diffstat (limited to 'src/buffer_utils.cc')
| -rw-r--r-- | src/buffer_utils.cc | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index 6a66b000..28b2de05 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -271,36 +271,6 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, bool scroll return buffer; } -void write_to_debug_buffer(StringView str) -{ - if (not BufferManager::has_instance()) - { - write(2, str); - write(2, "\n"); - return; - } - - constexpr StringView debug_buffer_name = "*debug*"; - // Try to ensure we keep an empty line at the end of the debug buffer - // where the user can put its cursor to scroll with new messages - const bool eol_back = not str.empty() and str.back() == '\n'; - if (Buffer* buffer = BufferManager::instance().get_buffer_ifp(debug_buffer_name)) - { - buffer->flags() &= ~Buffer::Flags::ReadOnly; - auto restore = on_scope_end([buffer] { buffer->flags() |= Buffer::Flags::ReadOnly; }); - - buffer->insert(buffer->back_coord(), eol_back ? str : str + "\n"); - } - else - { - String line = str + (eol_back ? "\n" : "\n\n"); - create_buffer_from_string( - debug_buffer_name.str(), Buffer::Flags::NoUndo | Buffer::Flags::Debug | Buffer::Flags::ReadOnly, - line); - } -} - - auto to_string(Buffer::HistoryId id) { using Result = decltype(to_string(size_t{})); |
