Skip to content

CharlesJQuarra/fredbuf

 
 

Repository files navigation

Project

This is the text buffer implementation described in Text Editor Data Structures.

API

Building:

using namespace PieceTree;
TreeBuilder builder;
builder.accept("ABC");
builder.accept("DEF");
auto tree = builder.create();
// Resulting total buffer: "ABCDEF"

Insertion:

tree.insert(CharOffset{ 0 }, "foo");
// Resulting total buffer: "fooABCDEF"

Deletion:

tree.remove(CharOffset{ 6 }, Length{ 3 });
// Resulting total buffer: "fooABC"

Line retrieval:

std::string buf;
tree.get_line_content(&buf, Line{ 1 });
// 'buf' contains "fooABC"

Iteration:

for (char c : buf)
{
    printf("%c", c);
}

Contributing

Feel free to open up a PR or issue but there's no guarantee it will get merged.

Building

If you're on Windows, open a developer command prompt and invoke b.bat. Do the same for essentially any other compiler except change the flags to be specific to your compiler. It's all standard C++ all the way down.

About

The textbuf which drives fred

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.7%
  • Other 0.3%