Fix improperly prompting about unused local in another modules, fix full recompile, Text editor: restructure

This commit is contained in:
Krzosa Karol
2024-06-09 12:04:38 +02:00
parent b08c7c9ce6
commit 39cb9cb4b4
22 changed files with 86 additions and 54 deletions

View File

@@ -37,12 +37,12 @@ bool add_instrumentation() {
}
LC_String code = LC_GenerateUnityBuild();
LC_LangEnd(lang);
S8_String path = "examples/add_instrumentation/add_instrumentation.c";
OS_MakeDir("examples");
OS_MakeDir("examples/add_instrumentation");
OS_WriteFile(path, code);
LC_LangEnd(lang);
if (!UseCL) return true;
S8_String cmd = Fmt("cl %.*s -Zi -std:c11 -nologo -FC -Fd:examples/add_instrumentation/a.pdb -Fe:examples/add_instrumentation/add_instrumentation.exe %.*s", S8_Expand(path), S8_Expand(RaylibLIB));

View File

@@ -34,10 +34,9 @@ bool add_source_location_macro() {
}
LC_String code = LC_GenerateUnityBuild();
LC_LangEnd(lang);
OS_MakeDir("examples/add_source_location_macro");
OS_WriteFile("examples/add_source_location_macro/add_source_location_macro.c", code);
LC_LangEnd(lang);
return true;
}

View File

@@ -16,10 +16,10 @@ bool hello_world() {
OS_MakeDir("examples/hello_world");
LC_ParseAndResolve(name);
LC_String code = LC_GenerateUnityBuild();
LC_LangEnd(lang);
S8_String path = "examples/hello_world/hello_world.c";
OS_WriteFile(path, code);
LC_LangEnd(lang);
if (UseCL) {
S8_String cmd = Fmt("cl %.*s -nologo -FC -Fd:examples/hello_world/hello_world.pdb -Fe:examples/hello_world/hello_world.exe", S8_Expand(path));
if (Run(cmd) != 0) return false;

View File

@@ -6,9 +6,9 @@ bool text_editor() {
defer { LC_LangEnd(lang); };
LC_RegisterPackageDir("../pkgs");
LC_RegisterPackageDir("../examples");
LC_RegisterPackageDir("../examples/text_editor");
LC_Intern name = LC_ILit("text_editor");
LC_Intern name = LC_ILit("entry_point");
LC_ParseAndResolve(name);
if (L->errors) return false;

View File

@@ -1,3 +1,6 @@
import "raylib";
import "std_types";
ClampInt :: proc(val: int, min: int, max: int): int {
result := val;
if (val < min) result = min;

View File

@@ -12,6 +12,9 @@ import "raylib";
import "std_types";
import "libc";
import "core";
import TE "text_editor";
InvalidCodepath :: proc() {
assert(:*char("invalid codepath") == :*char(""));
}
@@ -81,12 +84,13 @@ main :: proc(): int {
ClearBackground(RAYWHITE);
if sandbox_chosen == SANDBOX_TEXT_EDITOR {
UpdateTextEditor(screen_rect, font, font_size, font_spacing);
TE.UpdateTextEditor(screen_rect, font, font_size, font_spacing);
} else if sandbox_chosen == SANDBOX_PROTOTYPE {
UpdatePrototype(screen_rect);
}
DrawRect(top_bar_original, LIGHTGRAY);
TE.DrawRect(top_bar_original, LIGHTGRAY);
DrawRectangleRoundedLines(Rect2PToRectangle(button1), 0.3, 12, 2, BLACK);
if button1_hover DrawRectangleRounded(Rect2PToRectangle(button1), 0.3, 12, WHITE);
@@ -101,4 +105,5 @@ main :: proc(): int {
}
CloseWindow();
return 0;
}
}

View File

@@ -1,3 +1,9 @@
import "std_types";
import "raylib";
import "libc";
import "core";
TeInited := false;
TeFontSize: float = 14;
TeFontSpacing: float = 1;
@@ -91,7 +97,6 @@ UpdateAndDrawWindow :: proc(w: *Window, font: Font, font_size: float) {
}
}
if w == FocusedWindow {
if IsKeyPressed(KEY_LEFT) || IsKeyPressedRepeat(KEY_LEFT) {
if IsKeyDown(KEY_LEFT_SHIFT) {