This commit is contained in:
Krzosa Karol
2024-07-23 17:02:25 +02:00
parent 0ebfedbf4d
commit 5864b060a9
5 changed files with 40 additions and 31 deletions

View File

@@ -214,4 +214,35 @@ void HandleGlobalCommands() {
} }
window->visible = !window->visible; window->visible = !window->visible;
} }
if (CtrlPress(KEY_ONE)) {
SetActiveWindow({1});
} else if (CtrlPress(KEY_TWO)) {
SetActiveWindow({2});
} else if (CtrlPress(KEY_THREE)) {
SetActiveWindow({3});
}
}
void ChangeActiveWindowAndScroll(Array<Int> &order) {
For(order) {
Window *window = &Windows[it];
View *view = GetActiveView(window);
Vec2 mouse = GetMousePosition();
bool mouse_in_window = CheckCollisionPointRec(mouse, ToRectangle(window->total_rect));
if (mouse_in_window) {
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
SetActiveWindow(window->id);
}
if (LastFrameIDWhenSwitchedActiveWindow != FrameID) {
if (IsKeyDown(KEY_F1)) {
view->scroll.x -= (Int)(GetMouseWheelMove() * 48);
} else {
view->scroll.y -= (Int)(GetMouseWheelMove() * 48);
}
LastFrameIDWhenSwitchedActiveWindow = FrameID;
}
}
}
} }

View File

@@ -25,8 +25,8 @@ void EvalString(String16 string16) {
Scratch scratch; Scratch scratch;
String string = ToString(scratch, string16); String string = ToString(scratch, string16);
if (luaL_dostring(LuaState, string.data) != LUA_OK) { if (luaL_dostring(LuaState, string.data) != LUA_OK) {
// @todo:
const char *text = lua_tostring(LuaState, -1); const char *text = lua_tostring(LuaState, -1);
printf("lua error: %s", text); printf("lua error: %s", text);
} }
// @todo: send error or data to some buffer
} }

View File

@@ -1,5 +1,3 @@
void Test() { void Test() {
{ {
Array<int> array = {}; Array<int> array = {};

View File

@@ -35,12 +35,14 @@
- command window - command window
- maybe use lua and have there be lua commands that you choose with cursor - maybe use lua and have there be lua commands that you choose with cursor
- open "asd/asd/asd/asd" - open "asd/asd/asd/asd"
- list "directory" and since it returns strings we can fill up the command buffer with files to open
- file dock on left side - file dock on left side
- We can actually combine this with command window and lua, it's just going to be a buffer of - We can actually combine this with command window and lua, it's just going to be a buffer of
- open "asd/asd/asd/asd" - open "asd/asd/asd/asd"
- Make only one infobar!!
- Ctrl + F - Ctrl + F
- Better enclosure and word hopping
- word completion - word completion
- Colored strings - Colored strings
@@ -109,7 +111,8 @@ int main(void) {
} }
{ {
Window *w = CreateWindow(); Window *w = CreateWindow();
Buffer *b = OpenFile("C:/Work/text_editor/src/text_editor/text_editor.cpp"); Buffer *b = CreateBuffer(sys_allocator);
LoadLine(b);
View *v = CreateView(b->id); View *v = CreateView(b->id);
AddView(w, v->id); AddView(w, v->id);
} }
@@ -121,7 +124,7 @@ int main(void) {
w->visible = false; w->visible = false;
Buffer *b = CreateBuffer(sys_allocator); Buffer *b = CreateBuffer(sys_allocator);
View *v = CreateView(b->id); View *v = CreateView(b->id);
LoadLine(b); ReplaceText(b, {}, L"open \"C:/Work/text_editor/src/text_editor/text_editor.cpp\"");
AddView(w, v->id); AddView(w, v->id);
CommandWindowID = w->id; CommandWindowID = w->id;
} }

View File

@@ -54,26 +54,3 @@ void SetActiveWindow(WindowID window) {
LastFrameIDWhenSwitchedActiveWindow = FrameID; LastFrameIDWhenSwitchedActiveWindow = FrameID;
} }
} }
void ChangeActiveWindowAndScroll(Array<Int> &order) {
For(order) {
Window *window = &Windows[it];
View *view = GetActiveView(window);
Vec2 mouse = GetMousePosition();
bool mouse_in_window = CheckCollisionPointRec(mouse, ToRectangle(window->total_rect));
if (mouse_in_window) {
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
SetActiveWindow(window->id);
}
if (LastFrameIDWhenSwitchedActiveWindow != FrameID) {
if (IsKeyDown(KEY_F1)) {
view->scroll.x -= (Int)(GetMouseWheelMove() * 48);
} else {
view->scroll.y -= (Int)(GetMouseWheelMove() * 48);
}
LastFrameIDWhenSwitchedActiveWindow = FrameID;
}
}
}
}