2023-08-22 03:19:51 +00:00
|
|
|
WORKSPACE_COMMAND(W_Command_SplitPanelHorizontal)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-08-22 03:19:51 +00:00
|
|
|
workspace *Workspace = W_GetState();
|
|
|
|
W_SplitPanel(Workspace->CurrentPanel, Axis2_X);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-08-22 03:19:51 +00:00
|
|
|
WORKSPACE_COMMAND(W_Command_SplitPanelVertical)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-08-22 03:19:51 +00:00
|
|
|
workspace *Workspace = W_GetState();
|
|
|
|
W_SplitPanel(Workspace->CurrentPanel, Axis2_Y);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-08-22 03:19:51 +00:00
|
|
|
WORKSPACE_COMMAND(W_Command_ClosePanel)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-08-22 03:19:51 +00:00
|
|
|
workspace *Workspace = W_GetState();
|
2023-07-19 15:09:41 +00:00
|
|
|
|
2023-06-17 17:00:55 +00:00
|
|
|
workspace_panel *Panel = (workspace_panel *)Argument;
|
|
|
|
if(!Panel)
|
|
|
|
{
|
|
|
|
Panel = Workspace->CurrentPanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
workspace_panel *Parent = Panel->Parent;
|
|
|
|
|
|
|
|
Assert(Parent);
|
|
|
|
Assert(Panel != Workspace->RootPanel);
|
|
|
|
|
|
|
|
DLLRemove(Parent->First, Parent->Last, Panel);
|
|
|
|
|
|
|
|
b32 OneChildRemains = (Parent->First == Parent->Last);
|
|
|
|
if(OneChildRemains)
|
|
|
|
{
|
|
|
|
workspace_panel *Child = Parent->First;
|
|
|
|
Assert(DLLIsEmpty(Parent->FirstView));
|
|
|
|
|
|
|
|
Parent->FirstView = Child->FirstView;
|
|
|
|
Parent->LastView = Child->LastView;
|
|
|
|
Parent->First = Child->First;
|
|
|
|
Parent->Last = Child->Last;
|
|
|
|
Parent->SplitAxis = Child->SplitAxis;
|
|
|
|
|
|
|
|
// sixten: Update the parents of the children.
|
|
|
|
for(workspace_view *View = Parent->FirstView;
|
|
|
|
View != 0;
|
|
|
|
View = View->Next)
|
|
|
|
{
|
|
|
|
View->Parent = Parent;
|
|
|
|
}
|
|
|
|
for(workspace_panel *ParentChild = Parent->First;
|
|
|
|
ParentChild != 0;
|
|
|
|
ParentChild = ParentChild->Next)
|
|
|
|
{
|
|
|
|
ParentChild->Parent = Parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
DLLRemove(Parent->First, Parent->Last, Child);
|
2023-08-22 03:19:51 +00:00
|
|
|
W_DeletePanel(Child);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s32 ChildCount = 0;
|
|
|
|
for(workspace_panel *Child = Parent->First;
|
|
|
|
Child != 0;
|
|
|
|
Child = Child->Next)
|
|
|
|
{
|
|
|
|
++ChildCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
r32 ToAppend = Panel->PercentOfParent / ChildCount;
|
|
|
|
for(workspace_panel *Child = Parent->First;
|
|
|
|
Child != 0;
|
|
|
|
Child = Child->Next)
|
|
|
|
{
|
|
|
|
Child->PercentOfParent += ToAppend;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// sixten: Delete all child views.
|
2023-08-22 03:19:51 +00:00
|
|
|
workspace_view *NextChild = 0;
|
2023-06-17 17:00:55 +00:00
|
|
|
for(workspace_view *Child = Panel->FirstView;
|
|
|
|
Child != 0;
|
2023-08-22 03:19:51 +00:00
|
|
|
Child = NextChild)
|
2023-06-17 17:00:55 +00:00
|
|
|
{
|
2023-08-22 03:19:51 +00:00
|
|
|
NextChild = Child->Next;
|
|
|
|
W_DestroyView(Child);
|
2023-06-17 17:00:55 +00:00
|
|
|
}
|
|
|
|
|
2023-08-22 03:19:51 +00:00
|
|
|
W_DeletePanel(Panel);
|
2023-07-19 15:09:41 +00:00
|
|
|
}
|
|
|
|
|
2023-08-22 03:19:51 +00:00
|
|
|
WORKSPACE_COMMAND(W_Command_OpenView)
|
2023-08-06 10:35:09 +00:00
|
|
|
{
|
2023-08-22 03:19:51 +00:00
|
|
|
workspace *Workspace = W_GetState();
|
2023-12-07 15:50:57 +00:00
|
|
|
W_CreateNewView((workspace_view_kind)Argument, Workspace->CurrentPanel);
|
2023-08-22 03:19:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WORKSPACE_COMMAND(W_Command_CloseView)
|
|
|
|
{
|
|
|
|
workspace_view *View = (workspace_view *)U64ToPointer(Argument);
|
|
|
|
workspace_panel *Panel = View->Parent;
|
|
|
|
|
|
|
|
DLLRemove(Panel->FirstView, Panel->LastView, View);
|
|
|
|
if(Panel->CurrentView == View)
|
|
|
|
{
|
|
|
|
Panel->CurrentView = Panel->FirstView;
|
|
|
|
}
|
|
|
|
|
|
|
|
W_DestroyView(View);
|
2023-08-06 10:35:09 +00:00
|
|
|
}
|
|
|
|
|
2023-12-07 15:50:57 +00:00
|
|
|
WORKSPACE_COMMAND(W_Command_OpenFile)
|
|
|
|
{
|
|
|
|
temporary_memory Scratch = GetScratch();
|
|
|
|
|
|
|
|
workspace *Workspace = W_GetState();
|
|
|
|
workspace_file_lister_action *Action = (workspace_file_lister_action *)U64ToPointer(Argument);
|
|
|
|
|
|
|
|
string Filepath = PushFormat(Scratch.Arena, "%S/%S", Action->Path, Action->Name);
|
|
|
|
|
|
|
|
platform_file_handle File = Platform.OpenFile(Filepath, PlatformAccess_Read);
|
|
|
|
if(File.IsValid)
|
|
|
|
{
|
|
|
|
// sixten: retrieve file extension
|
|
|
|
string FileExtension = Substring(Action->Name, Range1S64(LastIndexOf(Action->Name, '.')+1, Action->Name.Count));
|
|
|
|
if(AreEqual(FileExtension, StrLit("vns")))
|
|
|
|
{
|
|
|
|
s64 FileSize = Platform.GetFileSize(File);
|
|
|
|
string ReplaceString = MakeString(PushArrayNoClear(Scratch.Arena, u8, FileSize+1), FileSize);
|
|
|
|
ReplaceString.Data[FileSize] = 0;
|
|
|
|
Platform.ReadFile(File, ReplaceString.Data, 0, FileSize);
|
|
|
|
|
|
|
|
ReplaceString = RemoveAll(Scratch.Arena, ReplaceString, '\r');
|
|
|
|
|
|
|
|
workspace_view *View = W_CreateNewView(W_ViewKind_TextEditor, Workspace->CurrentPanel);
|
|
|
|
workspace_view_text_editor *Editor = (workspace_view_text_editor *)View->Data;
|
|
|
|
|
|
|
|
MutableStringReplaceRange(&Editor->Text, ReplaceString, Range1S64(0, 0));
|
|
|
|
W_TextEditorApplyChanges(Editor);
|
|
|
|
Editor->FileName = PushString(View->Arena, Action->Name);
|
|
|
|
Editor->FilePath = PushString(View->Arena, Action->Path);
|
|
|
|
}
|
|
|
|
else if(AreEqual(FileExtension, StrLit("vnn")))
|
|
|
|
{
|
|
|
|
s64 FileSize = Platform.GetFileSize(File);
|
|
|
|
string Contents = MakeString(PushArrayNoClear(Scratch.Arena, u8, FileSize), FileSize);
|
|
|
|
Platform.ReadFile(File, Contents.Data, 0, Contents.Count);
|
|
|
|
|
|
|
|
workspace_view *View = W_CreateNewView(W_ViewKind_NavEditor, Workspace->CurrentPanel);
|
|
|
|
W_SetupNavEditor(View, Contents);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
workspace_view *View = W_CreateNewView(W_ViewKind_Error, Workspace->CurrentPanel);
|
|
|
|
workspace_view_error *Error = (workspace_view_error *)View->Data;
|
|
|
|
Error->Message = PushFormat(View->Arena, "Unknown file extension: %S", FileExtension);
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.CloseFile(File);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// sixten: what happens now??
|
|
|
|
}
|
|
|
|
|
|
|
|
ReleaseScratch(Scratch);
|
|
|
|
}
|
|
|
|
|
2023-07-19 15:09:41 +00:00
|
|
|
#if VN_INTERNAL
|
2023-08-22 03:19:51 +00:00
|
|
|
WORKSPACE_COMMAND(W_Command_ToggleRenderUIDebugRects)
|
2023-07-19 15:09:41 +00:00
|
|
|
{
|
|
|
|
DEBUG_DebugSettings->RenderUIDebugRects = !DEBUG_DebugSettings->RenderUIDebugRects;
|
|
|
|
}
|
2023-08-22 03:19:51 +00:00
|
|
|
#endif
|