Mouse rewrite

This commit is contained in:
Krzosa Karol
2024-08-04 14:00:42 +02:00
parent edff7a4267
commit c6a415f642

View File

@@ -93,7 +93,7 @@ void CheckpointBeforeGoto() {
}
void GoBackToLastCrumb() {
Window *window = GetWindow(ActiveWindow);
Window *window = GetWindow(GetLastActiveWindow());
if (GotoCrumbs.len <= 0) return;
GotoCrumb c = Pop(&GotoCrumbs);
Buffer *buffer = GetBuffer(c.buffer_id);
@@ -186,11 +186,11 @@ bool GlobalCommand(Event event) {
View *view = GetView(window->active_view);
Buffer *buffer = GetBuffer(view->active_buffer);
Vec2I mouse = MouseVec2I();
Int p = ScreenSpaceToBufferPos(window, view, buffer, mouse);
Vec2I mouse = MouseVec2I();
Int p = ScreenSpaceToBufferPos(window, view, buffer, mouse);
Caret &caret = view->carets[0];
caret = SetFrontWithAnchor(caret, DocumentRangeAnchor, p);
caret = SetFrontWithAnchor(caret, DocumentRangeAnchor, p);
}
// Set active window on click
@@ -242,6 +242,8 @@ bool GlobalCommand(Event event) {
Buffer *buffer = GetBuffer(view->active_buffer);
Int p = ScreenSpaceToBufferPosErrorOutOfBounds(window, view, buffer, mouse);
if (p != -1) {
view->carets.len = 1;
view->carets[0] = MakeCaret(p);
Range enclose = EncloseLoadWord(buffer, p);
String16 string = GetString(*buffer, enclose);
Open(string);
@@ -253,9 +255,10 @@ bool GlobalCommand(Event event) {
Assert(ScrollbarSelected == NULL);
Assert(DocumentSelected == NULL);
Window *window = GetActiveWindow();
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
if (mouse_in_document) {
Window *window = GetActiveWindow();
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
bool mouse_in_line_numbers = CheckCollisionPointRec(mouse, window->line_numbers_rect);
if (mouse_in_document || mouse_in_line_numbers) {
View *view = GetView(window->active_view);
Buffer *buffer = GetBuffer(view->active_buffer);
DocumentSelected = window;
@@ -287,7 +290,6 @@ bool GlobalCommand(Event event) {
}
// Figure out scrollbar click
// @todo: probably need to refactor scrolling too :(
For(order) {
Window *window = &Windows[it];
if (!window->visible) continue;