From e0415fca385926b5e1bddcd4f8936ef49b9b4177 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Tue, 16 Oct 2012 15:25:29 +0800 Subject: [PATCH] Usermode/ATE - Stub edit code --- Usermode/Applications/gui_ate_src/edit.c | 45 +++++++++++++++++++ .../Applications/gui_ate_src/include/file.h | 35 +++++++++++++++ .../Applications/gui_ate_src/include/syntax.h | 12 +++++ 3 files changed, 92 insertions(+) create mode 100644 Usermode/Applications/gui_ate_src/edit.c create mode 100644 Usermode/Applications/gui_ate_src/include/file.h create mode 100644 Usermode/Applications/gui_ate_src/include/syntax.h diff --git a/Usermode/Applications/gui_ate_src/edit.c b/Usermode/Applications/gui_ate_src/edit.c new file mode 100644 index 00000000..8e1f01ee --- /dev/null +++ b/Usermode/Applications/gui_ate_src/edit.c @@ -0,0 +1,45 @@ +/* + * Acess Text Editor (ATE) + * - By John Hodge (thePowersGang) + * + * edit.c + * - File Loading / Manipulation + */ +#include +#include "include/file.h" +#include "include/syntax.h" + +// === CODE === +tFile *File_New(void) +{ + tFile *ret = malloc(sizeof(tFile) + 1); + ret->Handle = NULL; + ret->nLines = 0; + ret->Lines = NULL; + ret->NameOfs = 0; + ret->Path[0] = 0; + return ret; +} + +tFile *File_Load(const char *Path) +{ + return NULL; +} + +int File_Save(tFile *File) +{ + + //file->bIsDirty = 0; + return -1; +} + +int File_Close(tFile *File, int bDiscard) +{ + //if( file->bIsDirty && !bDiscard ) + // return 1; + if( file->Handle ) + fclose(File->Handle); + + return 0; +} + diff --git a/Usermode/Applications/gui_ate_src/include/file.h b/Usermode/Applications/gui_ate_src/include/file.h new file mode 100644 index 00000000..5eb15b05 --- /dev/null +++ b/Usermode/Applications/gui_ate_src/include/file.h @@ -0,0 +1,35 @@ +/* + * Acess Text Editor (ATE) + * - By John Hodge (thePowersGang) + * + * include/file.h + * - In-memory file structures + */ +#ifndef _ATE__FILE_H_ +#define _ATE__FILE_H_ +#include + +typedef struct sFileLine +{ + int Num; + + // State data for hilighting + int HilightState; + char *Rendered; + + int Space; + int Length; + char Data[]; +} tFileLine; + +typedef struct sFile +{ + FILE *Handle; + int nLines; + tFileLine **Lines; // TODO: Handle very large files? + int NameOfs; + const char Path[]; +} tFile; + +#endif + diff --git a/Usermode/Applications/gui_ate_src/include/syntax.h b/Usermode/Applications/gui_ate_src/include/syntax.h new file mode 100644 index 00000000..99b35ce0 --- /dev/null +++ b/Usermode/Applications/gui_ate_src/include/syntax.h @@ -0,0 +1,12 @@ +/* + * Acess Text Editor (ATE) + * - By John Hodge (thePowersGang) + * + * include/syntax.h + * - Syntax Hilighting / Rendering structures + */ +#ifndef _ATE__SYNTAX_H_ +#define _ATE__SYNTAX_H_ + +#endif + -- 2.20.1