Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cdacamar/fredbuf
The textbuf which drives fred
https://github.com/cdacamar/fredbuf
Last synced: about 1 month ago
JSON representation
The textbuf which drives fred
- Host: GitHub
- URL: https://github.com/cdacamar/fredbuf
- Owner: cdacamar
- License: mit
- Created: 2023-06-05T06:11:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-12T07:41:24.000Z (about 1 year ago)
- Last Synced: 2024-01-12T20:04:31.233Z (about 1 year ago)
- Language: C++
- Size: 145 KB
- Stars: 99
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Project
This is the text buffer implementation described in [Text Editor Data Structures](https://cdacamar.github.io/data%20structures/algorithms/benchmarking/text%20editors/c++/editor-data-structures/?fbclid=IwAR1KPqHQU-torrzSq7LKWgK3uUZsTaoEpiAQeDT8XlvlOD3MCSt3sEl2YXc).
## API
Building:
```c++
using namespace PieceTree;
TreeBuilder builder;
builder.accept("ABC");
builder.accept("DEF");
auto tree = builder.create();
// Resulting total buffer: "ABCDEF"
```Insertion:
```c++
tree.insert(CharOffset{ 0 }, "foo");
// Resulting total buffer: "fooABCDEF"
```Deletion:
```c++
tree.remove(CharOffset{ 6 }, Length{ 3 });
// Resulting total buffer: "fooABC"
```Line retrieval:
```c++
std::string buf;
tree.get_line_content(&buf, Line{ 1 });
// 'buf' contains "fooABC"
```Iteration:
```c++
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.