From 3056e083d78b6edec6bab1ebac3fa9e3708644d7 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 20 Aug 2015 22:37:23 +0200 Subject: Initial commit --- firmware/src/editor.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 firmware/src/editor.h (limited to 'firmware/src/editor.h') diff --git a/firmware/src/editor.h b/firmware/src/editor.h new file mode 100644 index 0000000..4d5cac2 --- /dev/null +++ b/firmware/src/editor.h @@ -0,0 +1,50 @@ +/* + * File: editor.h + * Author: camilstaps + * + * Created on August 18, 2015, 11:25 PM + */ + +#ifndef EDITOR_H +#define EDITOR_H + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct { + unsigned char* start; + unsigned char* end; +} EditorArea; + +typedef struct { + EditorArea front; + EditorArea back; +} Editor; + +Editor newEditor(unsigned int size); +inline void freeEditor(Editor editor); + +inline unsigned int getFreeSpace(Editor editor); +inline unsigned isFull(Editor editor); + +unsigned char* getNearCursor(Editor editor, signed int start, signed int end); +void moveCursor(Editor editor, signed int change); + +inline void writeAtCursor(Editor editor, unsigned char character); +void writeStringAtCursor(Editor editor, unsigned char* string); +inline void writeAfterCursor(Editor editor, unsigned char character); +void writeStringAfterCursor(Editor editor, unsigned char* string); + +inline void deleteAtCursor(Editor editor); +inline void deleteNAtCursor(Editor editor, unsigned int length); +inline void deleteAfterCursor(Editor editor); +inline void deleteNAfterCursor(Editor editor, unsigned int length); + +#ifdef __cplusplus +} +#endif + +#endif /* EDITOR_H */ + -- cgit v1.2.3