74 lines
1.6 KiB
C
74 lines
1.6 KiB
C
|
/* date = July 11th 2023 0:34 pm */
|
||
|
|
||
|
#ifndef VN_WORKSPACE_TEXT_EDITOR_H
|
||
|
#define VN_WORKSPACE_TEXT_EDITOR_H
|
||
|
|
||
|
////////////////////////////////
|
||
|
//~ sixten: Mutable String Types
|
||
|
|
||
|
struct mutable_string
|
||
|
{
|
||
|
memory_arena *Arena;
|
||
|
string String;
|
||
|
};
|
||
|
|
||
|
struct history_node
|
||
|
{
|
||
|
range1_s64 Range;
|
||
|
string ReplaceString;
|
||
|
history_node *Next;
|
||
|
};
|
||
|
|
||
|
struct history_list
|
||
|
{
|
||
|
memory_arena *HistoryArena;
|
||
|
|
||
|
history_node *First;
|
||
|
history_node *Last;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////
|
||
|
//~ sixten: Workspace Text Editor Types
|
||
|
|
||
|
struct workspace_text_data
|
||
|
{
|
||
|
token_array Tokens;
|
||
|
range1_s64_array Lines;
|
||
|
};
|
||
|
|
||
|
struct workspace_view_text_editor
|
||
|
{
|
||
|
//- sixten: processed text
|
||
|
memory_arena *ProcessingArena;
|
||
|
token_array Tokens;
|
||
|
range1_s64_array Lines;
|
||
|
|
||
|
//- sixten: text being edited
|
||
|
mutable_string Text;
|
||
|
|
||
|
//- sixten: text editing
|
||
|
text_edit_state EditState;
|
||
|
text_point LastTextPoint;
|
||
|
|
||
|
//- sixten: ui building & rendering
|
||
|
ui_box *ContainerBox;
|
||
|
v2 TextDim;
|
||
|
v2 Offset;
|
||
|
};
|
||
|
|
||
|
////////////////////////////////
|
||
|
//~ sixten: Mutable String Functions
|
||
|
|
||
|
static mutable_string MutableStringAllocate(u64 Size);
|
||
|
static void MutableStringRelease(mutable_string *String);
|
||
|
static void MutableStringReplaceRange(mutable_string *String, string ReplaceString, range1_s64 Range);
|
||
|
|
||
|
////////////////////////////////
|
||
|
//~ sixten: Workspace Text Editor Functions
|
||
|
|
||
|
static workspace_text_data Workspace_TextDataFromStringChunkList(memory_arena *Arena, string Text);
|
||
|
static UI_CUSTOM_DRAW_CALLBACK(Workspace_TextEditorDrawCallback);
|
||
|
static void Workspace_BuildTextEditor(workspace_view *View);
|
||
|
|
||
|
#endif //VN_WORKSPACE_TEXT_EDITOR_H
|