first
This commit is contained in:
158
source/editor.h
Normal file
158
source/editor.h
Normal file
@@ -0,0 +1,158 @@
|
||||
/*##############################################################################
|
||||
*
|
||||
*##############################################################################
|
||||
*/
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include <tart.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
char* text;
|
||||
int len;
|
||||
int stringCount;
|
||||
struct tart_cell cell;
|
||||
struct tart_cstring textBox[30];
|
||||
struct tart_vec2 size;
|
||||
struct tart_vec2 pos;
|
||||
} richTextBox;
|
||||
|
||||
void SetRichTextBox(richTextBox* rtb, char* text, int len,
|
||||
struct tart_cell cell) {
|
||||
int lineCount = 0;
|
||||
int textOffset = 0;
|
||||
char* p = text;
|
||||
unsigned char found = 0;
|
||||
rtb->stringCount = 5;
|
||||
int sizeOfString = 0;
|
||||
for(int i = 0; i < len; i++) {
|
||||
sizeOfString = i - textOffset;
|
||||
|
||||
if(p[i] == '\n') {
|
||||
// This means that it will start splitting strings
|
||||
found = 1;
|
||||
|
||||
//p[i] = '\0'; // Sets this to be the end of the string
|
||||
|
||||
//Add the address to the cstring
|
||||
if(lineCount == 5) {
|
||||
break;
|
||||
}
|
||||
|
||||
rtb->textBox[lineCount] = tart_cstring(p + textOffset,
|
||||
sizeOfString, rtb->cell);
|
||||
textOffset = i + 1; // Sets the start of the next string.
|
||||
lineCount++;
|
||||
}
|
||||
}
|
||||
tart_cstring_free(&rtb->textBox[lineCount]);
|
||||
rtb->textBox[lineCount] = tart_cstring(p + textOffset,
|
||||
strlen(p), rtb->cell);
|
||||
|
||||
}
|
||||
|
||||
void drawTextBox(struct tart_window* window, richTextBox* rtb, tart_byte id) {
|
||||
struct tart_buffer* sb = tart_get_buffer(window, id);
|
||||
// This makes sure that we dont go outside of memeery with the string count.
|
||||
for (int lineNo = 0; lineNo < rtb->stringCount; lineNo++) {
|
||||
tart_draw_cstring_position(sb,
|
||||
rtb->textBox[lineNo],
|
||||
(struct tart_vec2){rtb->pos.x,rtb->pos.y + lineNo});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Init Command Mode
|
||||
*
|
||||
* This will run when COMMAND_MODE is triggerd
|
||||
*/
|
||||
void InitCommandMode();
|
||||
/*
|
||||
* Init Insert Mode
|
||||
*
|
||||
* This will run when INSERT_MODE is triggerd
|
||||
*/
|
||||
void InitInsertMode();
|
||||
/*
|
||||
* Init Normal Mode
|
||||
*
|
||||
* This will run when NORMAL_MODE is triggerd
|
||||
*/
|
||||
void InitNormalMode();
|
||||
/*
|
||||
* Init Nomi Mode
|
||||
*
|
||||
* This will run when NOMI_MODE is triggerd
|
||||
*/
|
||||
void InitNomiMode();
|
||||
|
||||
/*
|
||||
* Command Mode
|
||||
*
|
||||
* This will run every frame when COMMAND_MODE is active
|
||||
*/
|
||||
void CommandMode();
|
||||
/*
|
||||
* Insert Mode
|
||||
*
|
||||
* This will run every frame when INSERT_MODE is active
|
||||
*/
|
||||
void InsertMode();
|
||||
/*
|
||||
* Normal Mode
|
||||
*
|
||||
* This will run every frame when NORMAL_MODE is active
|
||||
*/
|
||||
void NormalMode();
|
||||
/*
|
||||
* Nomi Mode
|
||||
*
|
||||
* This will run every frame when NOMI_MODE is active
|
||||
*/
|
||||
void NomiMode();
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Update
|
||||
*
|
||||
* This will run every frame.
|
||||
*/
|
||||
void Update();
|
||||
|
||||
|
||||
/*
|
||||
* Update Bigin
|
||||
*
|
||||
* This will run on the begining of every update.
|
||||
*/
|
||||
void UpdateBigin();
|
||||
/*
|
||||
* Update End
|
||||
*
|
||||
* This will run on the ending of every update.
|
||||
*/
|
||||
void UpdateEnd();
|
||||
|
||||
/*
|
||||
* On Quit
|
||||
*
|
||||
* This will run on the quitting of the program
|
||||
*/
|
||||
void OnQuit();
|
||||
/*
|
||||
* On Start
|
||||
*
|
||||
* This will run on the start of the program
|
||||
*/
|
||||
void OnStart();
|
||||
|
||||
/*
|
||||
* Draw
|
||||
*
|
||||
* This will Draw the screen
|
||||
*/
|
||||
void Draw();
|
||||
|
||||
#endif /* ifndef EDITOR_H */
|
||||
Reference in New Issue
Block a user