From 91ba202562b47245d17f78c7b597b851495b915a Mon Sep 17 00:00:00 2001 From: Krzosa Karol Date: Fri, 9 Aug 2024 07:50:03 +0200 Subject: [PATCH] Simplify mouse left --- src/text_editor/commands.cpp | 34 ++++------------------------------ src/text_editor/todo.txt | 4 ++-- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 8ea0b53..0883cb5 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -317,37 +317,11 @@ bool GlobalCommand(Event event) { caret.range.max = p; caret.ifront = 1; } - } else if (event.clicks >= 2) { + } else if (event.clicks >= 2 && InBounds({caret.range.min - 1, caret.range.max + 1}, p)) { view->carets.len = 1; - - // @todo: consider simplifying this, is enclosing a paren even useful? - // like it's pretty hard to actually hit with mouse... - if (InBounds({caret.range.min - 1, caret.range.max + 1}, p)) { - Range range = EncloseWord(buffer, p); - wchar_t scope = GetChar(buffer, p); - if (!IsParen(scope) && !IsBrace(scope)) { - scope = GetChar(buffer, p); - } - - if (IsBrace(scope)) { - range = EncloseScope(buffer, p, '{', '}'); - } else if (IsParen(scope)) { - range = EncloseScope(buffer, p, '(', ')'); - } else { - if (event.clicks == 3) { - Range load_word_range = EncloseLoadWord(buffer, p); - if (AreEqual(load_word_range, range)) { - load_word_range = EncloseFullLine(buffer, p); - } - range = load_word_range; - } - if (event.clicks >= 4) range = EncloseFullLine(buffer, p); - } - - caret = MakeCaret(range.max, range.min); - } else { - caret = MakeCaret(p); - } + Range range = EncloseWord(buffer, p); + if (event.clicks >= 3) range = EncloseLoadWord(buffer, p); + caret = MakeCaret(range.max, range.min); } else { view->carets.len = 1; caret = MakeCaret(p); diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index de64ba9..be6cd5f 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -1,6 +1,6 @@ - Remove pointers and use ViewIDs (enable array debug while doing this) - try using git grep for search for now, combine with fuzzy search buffer -- need to rewrite the path matching in lua +- lua maybe try heuristic matching paths from left? - prevent lua from infinite looping - Append to console and change console directory - win32: change all stack buffers to arena @@ -8,7 +8,6 @@ - search as a command to execute which is going to be in the title bar - search backwards - braces enclose should be performed even if we put the mouse out of bounds! -- select until - some split selection commands - assign commands or lua functions to F1-F12 keys @@ -47,6 +46,7 @@ BUG: there is a click hang when switching windows sometimes, you click after sel backlog +- expose a coroutine based scripting enviorment where user can execute shell commands wait for them and perform actions in very linear manner - Test stdin writing code - Implement shell interaction (last line should have a '$'' symbols, if you press enter it should send that line to stdin of a running shell) - drop text into window