2016-01-15 11:19:24 -08:00
|
|
|
#ifndef HELPERS_SPY_INPUT_H_
|
|
|
|
|
#define HELPERS_SPY_INPUT_H_
|
2014-03-10 13:25:31 -07:00
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "tree_sitter/runtime.h"
|
|
|
|
|
|
2015-09-19 14:46:14 -07:00
|
|
|
struct SpyInputEdit {
|
|
|
|
|
size_t position;
|
|
|
|
|
size_t chars_removed;
|
|
|
|
|
std::string text_inserted;
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-16 17:32:19 -07:00
|
|
|
class SpyInput {
|
2015-09-18 23:20:06 -07:00
|
|
|
size_t chars_per_chunk;
|
|
|
|
|
size_t buffer_size;
|
|
|
|
|
char *buffer;
|
|
|
|
|
size_t byte_offset;
|
2015-09-19 14:46:14 -07:00
|
|
|
std::vector<SpyInputEdit> undo_stack;
|
2015-09-18 23:20:06 -07:00
|
|
|
|
2015-09-19 13:29:30 -07:00
|
|
|
static const char * read(void *, size_t *);
|
2015-12-03 23:06:01 -08:00
|
|
|
static int seek(void *, size_t, size_t);
|
2015-09-19 14:46:14 -07:00
|
|
|
std::string swap_substr(size_t, size_t, std::string);
|
2015-09-19 13:29:30 -07:00
|
|
|
|
2014-08-06 13:00:35 -07:00
|
|
|
public:
|
2015-07-16 17:32:19 -07:00
|
|
|
SpyInput(std::string content, size_t chars_per_chunk);
|
|
|
|
|
~SpyInput();
|
2014-03-10 13:25:31 -07:00
|
|
|
|
2014-09-30 14:57:57 -07:00
|
|
|
TSInput input();
|
2015-09-19 13:29:30 -07:00
|
|
|
void clear();
|
2015-09-19 14:46:14 -07:00
|
|
|
TSInputEdit replace(size_t start_char, size_t chars_removed, std::string text);
|
|
|
|
|
TSInputEdit undo();
|
2014-09-03 07:09:15 -07:00
|
|
|
|
2014-08-06 13:00:35 -07:00
|
|
|
std::string content;
|
2015-12-28 10:40:53 -08:00
|
|
|
TSInputEncoding encoding;
|
2014-08-06 13:00:35 -07:00
|
|
|
std::vector<std::string> strings_read;
|
2014-03-10 13:25:31 -07:00
|
|
|
};
|
|
|
|
|
|
2016-01-15 11:19:24 -08:00
|
|
|
#endif // HELPERS_SPY_INPUT_H_
|