RunFile python, open scratch buffer what ever is already there
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,3 +18,4 @@ te_debug
|
|||||||
text_editor.js
|
text_editor.js
|
||||||
*.map
|
*.map
|
||||||
*.exe
|
*.exe
|
||||||
|
scratch
|
||||||
@@ -10,25 +10,6 @@ bool SearchCaseSensitive = false;
|
|||||||
bool SearchWordBoundary = false;
|
bool SearchWordBoundary = false;
|
||||||
bool BreakOnError = false;
|
bool BreakOnError = false;
|
||||||
Int ErrorCount;
|
Int ErrorCount;
|
||||||
#if DEBUG_BUILD
|
|
||||||
String16 InitialScratchContent = uR"==(:OpenProject
|
|
||||||
C:/text_editor/src/text_editor/text_editor.cpp
|
|
||||||
:Set FontSize 70
|
|
||||||
/*
|
|
||||||
!python {{TEMP}}
|
|
||||||
for it in i:
|
|
||||||
memes
|
|
||||||
*/
|
|
||||||
0
|
|
||||||
1
|
|
||||||
2
|
|
||||||
3
|
|
||||||
4
|
|
||||||
5
|
|
||||||
6)==";
|
|
||||||
#else
|
|
||||||
String16 InitialScratchContent;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Allocator SysAllocator = {SystemAllocatorProc};
|
Allocator SysAllocator = {SystemAllocatorProc};
|
||||||
String ConfigDir;
|
String ConfigDir;
|
||||||
|
|||||||
@@ -67,8 +67,15 @@ void CMD_Build4() {
|
|||||||
void CMD_RunFile() {
|
void CMD_RunFile() {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
BSet primary = GetBSet(PrimaryWindowID);
|
BSet primary = GetBSet(PrimaryWindowID);
|
||||||
String windows_command = Format(scratch, "cl %S -Fe:cfile.exe /Zi /FC /nologo /WX /W3 /wd4200 /wd4334 /diagnostics:column && cfile.exe && del cfile.*", primary.buffer->name);
|
// @todo: this calls for language_cpp, language_c, language_python etc.
|
||||||
String unix_command = Format(scratch, "bash <<EOF\nclang %S -o cfile.exe -g -Wall -Wno-missing-braces -Wno-writable-strings -Wno-writable-strings -fsanitize=address -fdiagnostics-absolute-paths -lm \n./cfile.exe \nrm cfile.exe\nEOF", primary.buffer->name);
|
String windows_command = "";
|
||||||
|
String unix_command = "";
|
||||||
|
if (EndsWith(primary.buffer->name, ".py")) {
|
||||||
|
unix_command = windows_command = Format(scratch, "python %S", primary.buffer->name);
|
||||||
|
} else {
|
||||||
|
windows_command = Format(scratch, "cl %S -Fe:cfile.exe /Zi /FC /nologo /WX /W3 /wd4200 /wd4334 /diagnostics:column && cfile.exe && del cfile.*", primary.buffer->name);
|
||||||
|
unix_command = Format(scratch, "bash <<EOF\nclang %S -o cfile.exe -g -Wall -Wno-missing-braces -Wno-writable-strings -Wno-writable-strings -fsanitize=address -fdiagnostics-absolute-paths -lm \n./cfile.exe \nrm cfile.exe\nEOF", primary.buffer->name);
|
||||||
|
}
|
||||||
ExecBuild(windows_command, unix_command, GetDirectory(primary.buffer));
|
ExecBuild(windows_command, unix_command, GetDirectory(primary.buffer));
|
||||||
} RegisterCommand(CMD_RunFile, "", "Run and build current file, currently only C/C++ supported");
|
} RegisterCommand(CMD_RunFile, "", "Run and build current file, currently only C/C++ supported");
|
||||||
|
|
||||||
|
|||||||
@@ -966,14 +966,11 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
Allocator sys_allocator = GetSystemAllocator();
|
Allocator sys_allocator = GetSystemAllocator();
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
Buffer *null_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "scratch", ""));
|
Buffer *null_buffer = CreateBuffer(sys_allocator, Format(scratch, "%S/scratch", ProjectDirectory));
|
||||||
null_buffer->special = true;
|
null_buffer->special = true;
|
||||||
View *null_view = CreateView(null_buffer->id);
|
View *null_view = CreateView(null_buffer->id);
|
||||||
null_view->special = true;
|
null_view->special = true;
|
||||||
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
Assert(null_buffer->id == NullBufferID && null_view->id == NullViewID);
|
||||||
if (InitialScratchContent.len) {
|
|
||||||
RawAppend(null_buffer, InitialScratchContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Buffer *logs_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", ""));
|
Buffer *logs_buffer = CreateBuffer(sys_allocator, GetUniqueBufferName(ProjectDirectory, "logs", ""));
|
||||||
logs_buffer->special = true;
|
logs_buffer->special = true;
|
||||||
@@ -998,6 +995,7 @@ int main(int argc, char **argv)
|
|||||||
InitRender();
|
InitRender();
|
||||||
ReloadFont(PathToFont, (U32)FontSize);
|
ReloadFont(PathToFont, (U32)FontSize);
|
||||||
CreateWind();
|
CreateWind();
|
||||||
|
ReopenBuffer(GetBuffer(NullBufferID));
|
||||||
InitOS(ReportWarningf);
|
InitOS(ReportWarningf);
|
||||||
|
|
||||||
For (GlobalCommands) {
|
For (GlobalCommands) {
|
||||||
|
|||||||
Reference in New Issue
Block a user