Compare commits
2 Commits
830be12b24
...
930620a49e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
930620a49e | ||
|
|
8cb1b49cd8 |
@@ -73,10 +73,10 @@ static const char *glsl_fshader_es3 = R"==(#version 300 es
|
|||||||
}
|
}
|
||||||
)==";
|
)==";
|
||||||
|
|
||||||
void ReportWarningf(const char *fmt, ...);
|
void ReportErrorf(const char *fmt, ...);
|
||||||
void GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user) {
|
void GLDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *user) {
|
||||||
Unused(source); Unused(type); Unused(id); Unused(length); Unused(user);
|
Unused(source); Unused(type); Unused(id); Unused(length); Unused(user);
|
||||||
ReportWarningf("OpenGL message: %s", message);
|
ReportErrorf("OpenGL message: %s", message);
|
||||||
if (severity == GL_DEBUG_SEVERITY_HIGH || severity == GL_DEBUG_SEVERITY_MEDIUM) {
|
if (severity == GL_DEBUG_SEVERITY_HIGH || severity == GL_DEBUG_SEVERITY_MEDIUM) {
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL error", message, NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "OpenGL error", message, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1557,7 +1557,7 @@ void SaveBuffer(Buffer *buffer) {
|
|||||||
buffer->dirty = false;
|
buffer->dirty = false;
|
||||||
buffer->temp = false;
|
buffer->temp = false;
|
||||||
} else {
|
} else {
|
||||||
ReportWarningf("Failed to save file with name: %S", buffer->name);
|
ReportErrorf("Failed to save file with name: %S", buffer->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ void Appendf(View *view, const char *fmt, ...) {
|
|||||||
Append(view, string, true);
|
Append(view, string, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReportConsolef(const char *fmt, ...) {
|
||||||
|
Scratch scratch;
|
||||||
|
STRING_FORMAT(scratch, fmt, string);
|
||||||
|
Appendf(LogView, "%S\n", string);
|
||||||
|
}
|
||||||
|
|
||||||
void ReportErrorf(const char *fmt, ...) {
|
void ReportErrorf(const char *fmt, ...) {
|
||||||
ErrorCount += 1;
|
ErrorCount += 1;
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
@@ -77,28 +83,11 @@ void ReportErrorf(const char *fmt, ...) {
|
|||||||
|
|
||||||
if (LogView) {
|
if (LogView) {
|
||||||
Appendf(LogView, "%S\n", string);
|
Appendf(LogView, "%S\n", string);
|
||||||
ShowUIMessagef("%S", string);
|
|
||||||
} else {
|
} else {
|
||||||
printf("%.*s\n", (int)string.len, string.data);
|
printf("%.*s\n", (int)string.len, string.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportConsolef(const char *fmt, ...) {
|
|
||||||
Scratch scratch;
|
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
|
||||||
Appendf(LogView, "%S\n", string);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReportWarningf(const char *fmt, ...) {
|
|
||||||
ErrorCount += 1;
|
|
||||||
Scratch scratch;
|
|
||||||
STRING_FORMAT(scratch, fmt, string);
|
|
||||||
if (BreakOnError) {
|
|
||||||
BREAK();
|
|
||||||
}
|
|
||||||
Appendf(LogView, "%S\n", string);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMD_CenterView() {
|
void CMD_CenterView() {
|
||||||
CenterView(PrimaryWindowID);
|
CenterView(PrimaryWindowID);
|
||||||
} RegisterCommand(CMD_CenterView, "", "");
|
} RegisterCommand(CMD_CenterView, "", "");
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ struct Lexer {
|
|||||||
char *start;
|
char *start;
|
||||||
char *end;
|
char *end;
|
||||||
char *name;
|
char *name;
|
||||||
int line, column;
|
Int line, column;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TriggerKind {
|
enum TriggerKind {
|
||||||
@@ -34,6 +34,11 @@ struct CachedTrigger {
|
|||||||
};
|
};
|
||||||
Array<CachedTrigger> CachedTriggers;
|
Array<CachedTrigger> CachedTriggers;
|
||||||
|
|
||||||
|
Lexer MakeLexer(Allocator allocator, String string, char *file, Int line, Int column) {
|
||||||
|
Lexer lexer = {allocator, string.data, string.data, string.data + string.len, file, line, column};
|
||||||
|
return lexer;
|
||||||
|
}
|
||||||
|
|
||||||
void Advance(Lexer *lex) {
|
void Advance(Lexer *lex) {
|
||||||
if (lex->at < lex->end) {
|
if (lex->at < lex->end) {
|
||||||
if (lex->at[0] == '\n') {
|
if (lex->at[0] == '\n') {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ void UpdateCoroutines(Event *event) {
|
|||||||
_CoroutineContext = ⁢
|
_CoroutineContext = ⁢
|
||||||
mco_result ok = mco_resume(it.co);
|
mco_result ok = mco_resume(it.co);
|
||||||
if (ok != MCO_SUCCESS) {
|
if (ok != MCO_SUCCESS) {
|
||||||
ReportWarningf("failed to resume coroutine %d", ok);
|
ReportErrorf("failed to resume coroutine %d", ok);
|
||||||
DestroyCoroutine(&it);
|
DestroyCoroutine(&it);
|
||||||
remove_item = true;
|
remove_item = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ RegisterVariable(String, OpenCodePatterns, ".c .h .cpp .hpp .cc .cxx .rs .go .zi
|
|||||||
RegisterVariable(String, OpenCodeExcludePatterns, "");
|
RegisterVariable(String, OpenCodeExcludePatterns, "");
|
||||||
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||||
|
|
||||||
|
|
||||||
// PROJECT_MANAGEMENT
|
// PROJECT_MANAGEMENT
|
||||||
// Set at the beginning of the program to current directory
|
// Set at the beginning of the program to current directory
|
||||||
RegisterVariable(String, ProjectDirectory, "");
|
RegisterVariable(String, ProjectDirectory, "");
|
||||||
|
|||||||
@@ -56,17 +56,6 @@ void CMD_EvalCommandsLineByLine() {
|
|||||||
EvalCommandsLineByLine(set);
|
EvalCommandsLineByLine(set);
|
||||||
} RegisterCommand(CMD_EvalCommandsLineByLine, "", "Goes line by line over a buffer and evaluates every line as a command, ignores empty or lines starting with '//'");
|
} RegisterCommand(CMD_EvalCommandsLineByLine, "", "Goes line by line over a buffer and evaluates every line as a command, ignores empty or lines starting with '//'");
|
||||||
|
|
||||||
Variable *GetVariable(String name) {
|
|
||||||
Variable *var = NULL;
|
|
||||||
For (Variables) {
|
|
||||||
if (name == it.name) {
|
|
||||||
var = ⁢
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
|
|
||||||
BufferID LoadConfig(String config_path) {
|
BufferID LoadConfig(String config_path) {
|
||||||
ReportConsolef("Loading config %S...", config_path);
|
ReportConsolef("Loading config %S...", config_path);
|
||||||
Window *window = GetWindow(NullWindowID);
|
Window *window = GetWindow(NullWindowID);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
#if PLUGIN_CONFIG
|
#if PLUGIN_CONFIG
|
||||||
void Set(String string);
|
void Set(String string);
|
||||||
|
String InsertVariables(Allocator allocator, String string);
|
||||||
#endif
|
#endif
|
||||||
@@ -2133,7 +2133,7 @@ bool RDBG_InitConnection(mco_coro *co, bool create_session = true) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (file.len == 0) {
|
if (file.len == 0) {
|
||||||
ReportWarningf("Couldn't find neither .rdbg file, nor use the BinaryUnderDebug variable to locate the binary");
|
ReportErrorf("Couldn't find neither .rdbg file, nor use the BinaryUnderDebug variable to locate the binary");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ void CMD_FocusWindow4() {
|
|||||||
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
||||||
if (third) {
|
if (third) {
|
||||||
Window *fourth = GetOverlappingWindow(GetSideOfWindow(third, DIR_RIGHT));
|
Window *fourth = GetOverlappingWindow(GetSideOfWindow(third, DIR_RIGHT));
|
||||||
if (fourth) NextActiveWindowID = third->id;
|
if (fourth) NextActiveWindowID = fourth->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// MAAAAAAAAAAAAN I DONT LIKE THIS CODE, BUT HOPE IT WORKS
|
// MAAAAAAAAAAAAN I DONT LIKE THIS CODE, BUT HOPE IT WORKS
|
||||||
|
|
||||||
|
// @todo: potentially bad that we are not checking against end! lexer->at[0] == 0 check is not enough
|
||||||
struct Lexer2 {
|
struct Lexer2 {
|
||||||
char16_t *at;
|
char16_t *at;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -854,24 +854,14 @@ extern char **environ;
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
InitScratch();
|
|
||||||
InitOS(ReportErrorf);
|
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
int argc = __argc;
|
int argc = __argc;
|
||||||
char **argv = __argv;
|
char **argv = __argv;
|
||||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||||
#endif
|
#endif
|
||||||
|
InitScratch();
|
||||||
if (1) {
|
InitOS(ReportErrorf);
|
||||||
RunArenaTest();
|
ProjectDirectory = GetWorkingDir(Perm);
|
||||||
For (TestFunctions) {
|
|
||||||
it.function();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReportErrorf("Testing DONE\n");
|
|
||||||
// return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OS_WINDOWS
|
#if OS_WINDOWS
|
||||||
{
|
{
|
||||||
wchar_t *p = GetEnvironmentStringsW();
|
wchar_t *p = GetEnvironmentStringsW();
|
||||||
@@ -889,7 +879,16 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ProjectDirectory = GetWorkingDir(Perm);
|
if (1) {
|
||||||
|
RunArenaTest();
|
||||||
|
For (TestFunctions) {
|
||||||
|
it.function();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReportErrorf("Testing DONE\n");
|
||||||
|
// return 0;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
String sdl_config_path = SDL_GetPrefPath("krzosa", "text_editor");
|
String sdl_config_path = SDL_GetPrefPath("krzosa", "text_editor");
|
||||||
if (sdl_config_path.len && sdl_config_path.data[sdl_config_path.len - 1] == '\\') {
|
if (sdl_config_path.len && sdl_config_path.data[sdl_config_path.len - 1] == '\\') {
|
||||||
@@ -1009,7 +1008,7 @@ int main(int argc, char **argv)
|
|||||||
ReloadFont(PathToFont, (U32)FontSize);
|
ReloadFont(PathToFont, (U32)FontSize);
|
||||||
CreateWind();
|
CreateWind();
|
||||||
ReopenBuffer(GetBuffer(NullBufferID));
|
ReopenBuffer(GetBuffer(NullBufferID));
|
||||||
InitOS(ReportWarningf);
|
InitOS(ReportErrorf);
|
||||||
|
|
||||||
For (GlobalCommands) {
|
For (GlobalCommands) {
|
||||||
if (it.binding.len != 0) {
|
if (it.binding.len != 0) {
|
||||||
|
|||||||
@@ -217,11 +217,88 @@ bool IsOpenBoundary(char c) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Variable *GetVariable(String name) {
|
||||||
|
Variable *var = NULL;
|
||||||
|
For (Variables) {
|
||||||
|
if (name == it.name) {
|
||||||
|
var = ⁢
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
Variables that control the default shell for '!' commands
|
String InsertVariables(Allocator allocator, String string) {
|
||||||
DefaultShellWindows - "cmd"
|
Scratch scratch(allocator);
|
||||||
DefaultShellUnix - "bash | sh"
|
Array<String> parts = {scratch};
|
||||||
|
String it = string;
|
||||||
|
for (;;) {
|
||||||
|
int64_t idx = 0;
|
||||||
|
bool found = Seek(it, "@", &idx, SeekFlag_None);
|
||||||
|
if (!found) {
|
||||||
|
if (it.len > 0) {
|
||||||
|
Add(&parts, it);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String prev = GetPrefix(it, idx);
|
||||||
|
if (prev.len > 0) {
|
||||||
|
Add(&parts, prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
it = Skip(it, idx + 1);
|
||||||
|
char c = At(it, 0);
|
||||||
|
String name = {};
|
||||||
|
if (c == '@') {
|
||||||
|
Add(&parts, String{"@", 1});
|
||||||
|
it = Skip(it, 1);
|
||||||
|
continue;
|
||||||
|
} else if (c == '(') {
|
||||||
|
char *start = it.data + 1;
|
||||||
|
while (At(it, 0) && At(it, 0) != ')') {
|
||||||
|
it = Skip(it, 1);
|
||||||
|
}
|
||||||
|
Int len = it.data - start;
|
||||||
|
name = {start, len};
|
||||||
|
it = Skip(it, 1); // skip ')'
|
||||||
|
} else {
|
||||||
|
char *start = it.data;
|
||||||
|
while (IsAlphanumeric(At(it, 0))) {
|
||||||
|
it = Skip(it, 1);
|
||||||
|
}
|
||||||
|
Int len = it.data - start;
|
||||||
|
name = {start, len};
|
||||||
|
}
|
||||||
|
Variable *variable = GetVariable(name);
|
||||||
|
if (!variable) {
|
||||||
|
ReportErrorf("Variable: %S, not found", name);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
if (variable->type != VariableType_String) {
|
||||||
|
// @todo: this will not report - open will override
|
||||||
|
ReportErrorf("Variable: %S, not of type String", variable->type);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
Add(&parts, *variable->string);
|
||||||
|
}
|
||||||
|
|
||||||
|
String result = Merge(allocator, parts, "");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestInsertVariable() {
|
||||||
|
Scratch scratch;
|
||||||
|
|
||||||
|
String a = "Thing/@(ProjectDirectory)/Another";
|
||||||
|
String b = "Thing/@ProjectDirectory/Another";
|
||||||
|
Assert(InsertVariables(scratch, a) == InsertVariables(scratch, b));
|
||||||
|
int c = 10;
|
||||||
|
|
||||||
|
} RegisterFunction(&TestFunctions, TestInsertVariable);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
Variables:
|
Variables:
|
||||||
@ProjectDirectory/build/te
|
@ProjectDirectory/build/te
|
||||||
@@ -249,7 +326,13 @@ Otherwise it does filepath parsing:
|
|||||||
|
|
||||||
|
|
||||||
TODO: need to add '~', but where?
|
TODO: need to add '~', but where?
|
||||||
TODO: on linux find shell on first command and set as default
|
|
||||||
|
USECASE: Wouldn't it be cool to just select a part of codebase pipe that into a script
|
||||||
|
and get a result in a clipboard or capture the output and change the selection.
|
||||||
|
TODO: Data desc language
|
||||||
|
!{bash,Out:Sel} SCRIPT
|
||||||
|
!{bash,Out:Clip} SCRIPT
|
||||||
|
Use variables for injecting selection: @Sel
|
||||||
|
|
||||||
*/
|
*/
|
||||||
ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpenMeta meta) {
|
ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpenMeta meta) {
|
||||||
@@ -258,7 +341,7 @@ ResolvedOpen ResolveOpen(Allocator alo, Window *window, String path, ResolveOpen
|
|||||||
bool exec = !(ResolveOpenMeta_DontExec & meta);
|
bool exec = !(ResolveOpenMeta_DontExec & meta);
|
||||||
|
|
||||||
#if PLUGIN_CONFIG
|
#if PLUGIN_CONFIG
|
||||||
// @todo: variable substitution {{ProjectDirectory}}/build/te.exe
|
path = InsertVariables(alo, path);
|
||||||
|
|
||||||
if (exec && result.kind == OpenKind_Invalid && StartsWith(path, ":Set ")) {
|
if (exec && result.kind == OpenKind_Invalid && StartsWith(path, ":Set ")) {
|
||||||
result.kind = OpenKind_Set;
|
result.kind = OpenKind_Set;
|
||||||
|
|||||||
Reference in New Issue
Block a user