import dlib.aliases;
import dlib.platform;
import editor;
import std.stdio;
import dlib.alloc;
import dlib.util;

void main(string[] argv)
{
	u8[] buffer = null;
	u8[] buffer_name = null;
	if(argv.length > 1)
	{
		buffer_name = (cast(u8*)argv[1].ptr)[0 .. argv[1].length];
		File f = File(argv[1], "rb");
		buffer = Alloc!(u8)(f.size());
		f.rawRead(buffer);
		f.close();
	}

	PlatformWindow window = CreateWindow("Editor", 1920, 1080);
	StartPlatformThread(&window);

	EditorCtx ctx = InitEditorCtx(&window);

	while (true)
	{
		Inputs* inputs = GetEvents(&window);
		if(window.close) 
		{
			break;
		}

		Cycle(&ctx, inputs);
	}
}
