~ntgg/zosh

f82c385b928d7e25a5fdac04e34d68a3b8b81fe2 — Noah Graff 4 years ago 07f7aa4
added dump method to TextBuffer.
1 files changed, 7 insertions(+), 0 deletions(-)

M src/text_buffer.zig
M src/text_buffer.zig => src/text_buffer.zig +7 -0
@@ 56,6 56,7 @@ pub const TextBuffer = struct {
        return buf.bytes[buf.pos.offset + idx];
    }

    // Invalidates all slices into the TextBuffer.
    pub fn append(buf: *TextBuffer, text: []const u8) !void {
        const old_end = buf.bytes.len;
        buf.bytes = try buf.allocator.realloc(buf.bytes, buf.bytes.len + text.len);


@@ 107,6 108,12 @@ pub const TextBuffer = struct {
            }
        }
    }

    /// Dump info about the text buffer to standard error.
    pub fn dump(buf: TextBuffer) void {
        std.debug.warn("pos: {}\n", buf.pos);
        std.debug.warn("bytes:\n{}\n", buf.bytes);
    }
};

test "TextBuffer tests" {