diff --git a/src/text_editor/commands_window.cpp b/src/text_editor/commands_window.cpp index c0408c9..6ae250a 100644 --- a/src/text_editor/commands_window.cpp +++ b/src/text_editor/commands_window.cpp @@ -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); Int line = PosToLine(*buffer, GetFront(view->carets[0])); 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 ! void MergeCarets(View *view, Range *mouse_selection_anchor) { ProfileFunction(); - PrintDebugCarets(view, "before"); + // PrintDebugCarets(view, "before"); view->caret_change_id = CaretChangeID++; 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]); - PrintDebugCarets(view, "after"); + // PrintDebugCarets(view, "after"); } void HandleActiveWindowBindings(Window *window, bool *update_scroll) { @@ -436,7 +436,7 @@ void HandleActiveWindowBindings(Window *window, bool *update_scroll) { } if (AltPress(KEY_ENTER)) { Command_SelectAll(seek_view, needle); - SetActiveWindow(seek_window->id); + // SetActiveWindow(seek_window->id); } else if (Press(KEY_ENTER)) { Caret caret = FindInBuffer(seek_buffer, needle, seek_view->carets[0], true); if (Ctrl()) { @@ -470,9 +470,19 @@ void HandleActiveWindowBindings(Window *window, bool *update_scroll) { 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 (Press(KEY_ENTER)) { - Command_EvalLua(&view); + Command_EvalLuaLine(&view); } } else if (window->id.id == SearchWindowID.id) { } else { @@ -632,7 +642,10 @@ void ChangeActiveWindowAndScroll(Array &order) { bool mouse_in_window = CheckCollisionPointRec(mouse, ToRectangle(window->total_rect)); if (mouse_in_window) { 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 (IsKeyDown(KEY_F1)) { diff --git a/src/text_editor/window_draw.cpp b/src/text_editor/window_draw.cpp index c1774ce..b7162a9 100644 --- a/src/text_editor/window_draw.cpp +++ b/src/text_editor/window_draw.cpp @@ -175,11 +175,10 @@ void DrawWindow(Window &window) { For(view.carets) { Int front = GetFront(it); XY fxy = PosToXY(*buffer, front); - // @todo: - // 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]; - DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret); - // } + if (fxy.col >= visible.min.x && fxy.col < visible.max.x && fxy.line >= visible.min.y && fxy.line <= visible.max.y) { + bool main_caret = &it == &view.carets.data[0]; + DrawCaret(window, fxy, 0.3f, main_caret ? ColorMainCaret : ColorSubCaret); + } } EndProfileScope(); EndScissorMode();