Eval lua, fix ordering and fix caret overdraw

This commit is contained in:
Krzosa Karol
2024-07-26 08:09:19 +02:00
parent 4aa738fcc9
commit 48b918a551
2 changed files with 23 additions and 11 deletions

View File

@@ -174,7 +174,7 @@ void Command_EvalLua(View *view, String16 string) {
} }
} }
void Command_EvalLua(View *view) { void Command_EvalLuaLine(View *view) {
Buffer *buffer = GetBuffer(view->active_buffer); Buffer *buffer = GetBuffer(view->active_buffer);
Int line = PosToLine(*buffer, GetFront(view->carets[0])); Int line = PosToLine(*buffer, GetFront(view->carets[0]));
String16 string = GetLineStringWithoutNL(*buffer, line); String16 string = GetLineStringWithoutNL(*buffer, line);
@@ -195,7 +195,7 @@ void PrintDebugCarets(View *view, const char *msg) {
// mouse_selection_anchor is special case for mouse handling ! // mouse_selection_anchor is special case for mouse handling !
void MergeCarets(View *view, Range *mouse_selection_anchor) { void MergeCarets(View *view, Range *mouse_selection_anchor) {
ProfileFunction(); ProfileFunction();
PrintDebugCarets(view, "before"); // PrintDebugCarets(view, "before");
view->caret_change_id = CaretChangeID++; view->caret_change_id = CaretChangeID++;
Buffer *buffer = GetBuffer(view->active_buffer); Buffer *buffer = GetBuffer(view->active_buffer);
@@ -225,7 +225,7 @@ void MergeCarets(View *view, Range *mouse_selection_anchor) {
Swap(&view->carets[first_caret_index], &view->carets[0]); Swap(&view->carets[first_caret_index], &view->carets[0]);
PrintDebugCarets(view, "after"); // PrintDebugCarets(view, "after");
} }
void HandleActiveWindowBindings(Window *window, bool *update_scroll) { void HandleActiveWindowBindings(Window *window, bool *update_scroll) {
@@ -436,7 +436,7 @@ void HandleActiveWindowBindings(Window *window, bool *update_scroll) {
} }
if (AltPress(KEY_ENTER)) { if (AltPress(KEY_ENTER)) {
Command_SelectAll(seek_view, needle); Command_SelectAll(seek_view, needle);
SetActiveWindow(seek_window->id); // SetActiveWindow(seek_window->id);
} else if (Press(KEY_ENTER)) { } else if (Press(KEY_ENTER)) {
Caret caret = FindInBuffer(seek_buffer, needle, seek_view->carets[0], true); Caret caret = FindInBuffer(seek_buffer, needle, seek_view->carets[0], true);
if (Ctrl()) { if (Ctrl()) {
@@ -470,9 +470,19 @@ void HandleActiveWindowBindings(Window *window, bool *update_scroll) {
view.carets[0] = caret; view.carets[0] = caret;
} }
if (CtrlPress(KEY_Q) || IsMouseButtonPressed(MOUSE_BUTTON_MIDDLE)) {
// @todo: Consider applying this to all cursors
if (GetSize(view.carets[0].range) == 0) {
Command_EvalLuaLine(&view);
} else {
String16 string = GetString(*buffer, view.carets[0].range);
Command_EvalLua(&view, string);
}
}
if (window->execute_line) { if (window->execute_line) {
if (Press(KEY_ENTER)) { if (Press(KEY_ENTER)) {
Command_EvalLua(&view); Command_EvalLuaLine(&view);
} }
} else if (window->id.id == SearchWindowID.id) { } else if (window->id.id == SearchWindowID.id) {
} else { } else {
@@ -632,7 +642,10 @@ void ChangeActiveWindowAndScroll(Array<Int> &order) {
bool mouse_in_window = CheckCollisionPointRec(mouse, ToRectangle(window->total_rect)); bool mouse_in_window = CheckCollisionPointRec(mouse, ToRectangle(window->total_rect));
if (mouse_in_window) { if (mouse_in_window) {
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
SetActiveWindow(window->id); Window *active_window = GetWindow(ActiveWindow);
if (active_window->z <= window->z) {
SetActiveWindow(window->id);
}
} }
if (LastFrameIDWhenScrolled != FrameID) { if (LastFrameIDWhenScrolled != FrameID) {
if (IsKeyDown(KEY_F1)) { if (IsKeyDown(KEY_F1)) {

View File

@@ -175,11 +175,10 @@ void DrawWindow(Window &window) {
For(view.carets) { For(view.carets) {
Int front = GetFront(it); Int front = GetFront(it);
XY fxy = PosToXY(*buffer, front); XY fxy = PosToXY(*buffer, front);
// @todo: if (fxy.col >= visible.min.x && fxy.col < visible.max.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) {
// if (fxy.col >= visible.min.x && fxy.col < visible.min.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) { bool main_caret = &it == &view.carets.data[0];
bool main_caret = &it == &view.carets.data[0]; DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret);
DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret); }
// }
} }
EndProfileScope(); EndProfileScope();
EndScissorMode(); EndScissorMode();