120 lines
2.8 KiB
C
120 lines
2.8 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
|
|
{
|
|
arena *Arena;
|
|
string String;
|
|
};
|
|
|
|
////////////////////////////////
|
|
//~ sixten: History & Undo Types
|
|
|
|
struct history_entry
|
|
{
|
|
range1_s64 Range;
|
|
string ReplaceString;
|
|
};
|
|
|
|
struct history_node
|
|
{
|
|
history_node *Next;
|
|
history_node *Prev;
|
|
history_entry Forward;
|
|
history_entry Backward;
|
|
};
|
|
|
|
struct history_list
|
|
{
|
|
history_node *At;
|
|
history_node Sentinel;
|
|
};
|
|
|
|
////////////////////////////////
|
|
//~ sixten: Workspace Text Editor Types
|
|
|
|
struct workspace_text_data
|
|
{
|
|
token_array Tokens;
|
|
range1_s64_array Lines;
|
|
s64 MaxLineCount;
|
|
};
|
|
|
|
struct workspace_view_text_editor
|
|
{
|
|
// sixten: processed text
|
|
arena *ProcessingArena;
|
|
token_array Tokens;
|
|
range1_s64_array Lines;
|
|
s64 MaxLineCount;
|
|
compiled_scene2 Compiled;
|
|
|
|
// sixten: text being edited
|
|
string FileName;
|
|
string FilePath;
|
|
mutable_string Text;
|
|
|
|
// sixten: text editing
|
|
text_edit_state EditState;
|
|
text_point LastTextPoint;
|
|
|
|
// sixten: text rendering
|
|
r32 FontSize;
|
|
|
|
// sixten: history
|
|
arena *HistoryArena;
|
|
history_list History;
|
|
history_node *SavePoint;
|
|
|
|
// sixten: ui building & rendering
|
|
v2_r32 Offset;
|
|
v2_r32 AnimatedOffset;
|
|
};
|
|
|
|
////////////////////////////////
|
|
//~ 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: History & Undo Functions
|
|
|
|
static history_entry HistoryEntry(arena *Arena, string ReplaceString, range1_s64 Range);
|
|
static void AppendToHistory(arena *Arena, history_list *List, history_entry Forward, history_entry Backward);
|
|
|
|
|
|
////////////////////////////////
|
|
//~ sixten: Workspace Text Editing Functions
|
|
|
|
static workspace_text_data W_TextDataFromString(arena *Arena, string Text);
|
|
static void W_TextEditorApplyChanges(workspace_view_text_editor *Editor);
|
|
static void W_SaveTextEditorToFile(workspace_view_text_editor *Editor);
|
|
static b32 W_ProcessTextEditorEvent(workspace_view_text_editor *Editor, platform_event *Event);
|
|
static b32 W_ProcessDigitalKeyEvent(workspace_view_text_editor *Editor, platform_event_type Type, u32 Data);
|
|
|
|
|
|
////////////////////////////////
|
|
//~ sixten: Workspace Text Editor Draw Callbacks
|
|
|
|
static UI_CUSTOM_DRAW_CALLBACK(W_TextEditorDrawCallback);
|
|
static UI_CUSTOM_DRAW_CALLBACK(W_TextEditorLinesBarDrawCallback);
|
|
|
|
|
|
////////////////////////////////
|
|
//~ sixten: Workspace Text Editor Builder Functions
|
|
|
|
static void W_BuildTextEditorInfoBar(workspace_view_text_editor *Editor);
|
|
static void W_BuildTextEditorErrorList(workspace_view_text_editor *Editor);
|
|
static void W_BuildTextEditor(workspace_view *View);
|
|
|
|
|
|
#endif //VN_WORKSPACE_TEXT_EDITOR_H
|