build/api-examples/CodeBuffer.cpp¶
Complete program from the CodeBuffer API reference. Save it at the path shown above and use the build command in the reference page.
Source files · Download CodeBuffer.cpp
#include "code_buffer.hpp"
#include <cstdio>
#include <cstring>
int main()
{
gaspardos::desktop::CodeBuffer buffer;
std::string error;
if (!buffer.load("hello\r\n", error))
return 1;
buffer.place(0, 5);
if (!buffer.key('!'))
return 1;
std::printf("%s", buffer.serialize().c_str());
return buffer.dirty() && buffer.undo() && !buffer.dirty() ? 0 : 1;
}