Go to last bread crumb but mouse is bugging
This commit is contained in:
@@ -84,6 +84,7 @@ bool GlobalCommand(Event event) {
|
||||
{
|
||||
Vec2I mouse = MouseVec2I();
|
||||
Window *window = GetActiveWindow();
|
||||
View *view = GetView(window->active_view);
|
||||
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
||||
bool mouse_in_total = CheckCollisionPointRec(mouse, window->total_rect);
|
||||
bool mouse_in_line_numbers = CheckCollisionPointRec(mouse, window->line_numbers_rect);
|
||||
@@ -93,7 +94,7 @@ bool GlobalCommand(Event event) {
|
||||
static SDL_Cursor *SDL_MouseCursor;
|
||||
if (SDL_MouseCursor) SDL_DestroyCursor(SDL_MouseCursor);
|
||||
|
||||
if (window->mouse_selecting || mouse_in_document) {
|
||||
if (view->mouse_selecting || mouse_in_document) {
|
||||
SDL_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT);
|
||||
SDL_SetCursor(SDL_MouseCursor);
|
||||
} else if (mouse_in_scrollbar || window->mouse_selecting_scrollbar || mouse_in_line_numbers) {
|
||||
|
||||
@@ -503,6 +503,29 @@ Array<Range> FindAllInBuffer(Allocator allocator, Buffer *buffer, String16 needl
|
||||
return result;
|
||||
}
|
||||
|
||||
struct GotoCrumb {
|
||||
BufferID buffer_id;
|
||||
Caret caret;
|
||||
};
|
||||
Array<GotoCrumb> GotoCrumbs;
|
||||
|
||||
void CheckpointBeforeGoto() {
|
||||
Window *window = GetWindow(GetLastActiveWindow());
|
||||
View *view = GetView(window->active_view);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Add(&GotoCrumbs, {buffer->id, view->carets[0]});
|
||||
}
|
||||
|
||||
void GoBackToLastCrumb() {
|
||||
Window *window = GetWindow(ActiveWindow);
|
||||
if (GotoCrumbs.len <= 0) return;
|
||||
GotoCrumb c = Pop(&GotoCrumbs);
|
||||
Buffer *buffer = GetBuffer(c.buffer_id);
|
||||
View *view = WindowOpenBufferView(window, buffer->name);
|
||||
view->carets[0] = c.caret;
|
||||
UpdateScroll(window, true);
|
||||
}
|
||||
|
||||
void Command_IdentedNewLine(View *view) {
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
Scratch scratch;
|
||||
@@ -823,6 +846,10 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
}
|
||||
}
|
||||
|
||||
if (event.ctrl && Mouse(RIGHT)) {
|
||||
GoBackToLastCrumb();
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Vec2I mouse = MouseVec2I();
|
||||
@@ -845,7 +872,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
bool document_action = false;
|
||||
{
|
||||
bool a = mouse_in_document && IsMouseEvent(event.kind);
|
||||
bool b = window->mouse_selecting && !mouse_in_document;
|
||||
bool b = view->mouse_selecting && !mouse_in_document;
|
||||
document_action = a || b;
|
||||
}
|
||||
|
||||
@@ -876,12 +903,12 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
}
|
||||
|
||||
if (mouse_in_document && Mouse(LEFT)) {
|
||||
window->mouse_selecting = true;
|
||||
view->mouse_selecting = true;
|
||||
}
|
||||
|
||||
if (window->mouse_selecting) {
|
||||
if (view->mouse_selecting) {
|
||||
if (Mouse(LEFT_UP)) {
|
||||
window->mouse_selecting = false;
|
||||
view->mouse_selecting = false;
|
||||
}
|
||||
|
||||
MergeCarets(view, &view->selection_anchor);
|
||||
@@ -895,7 +922,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
||||
}
|
||||
MergeCarets(view, &view->selection_anchor);
|
||||
}
|
||||
} else if (!(mouse_in_document || window->mouse_selecting) && mouse_in_scrollbar || window->mouse_selecting_scrollbar) {
|
||||
} else if (!(mouse_in_document || view->mouse_selecting) && mouse_in_scrollbar || window->mouse_selecting_scrollbar) {
|
||||
Vec2 mouse_vec2 = MouseVec2();
|
||||
Scroller s = ComputeScrollerRect(window);
|
||||
double size_y = (double)GetSize(window->scrollbar_rect).y;
|
||||
|
||||
@@ -47,16 +47,18 @@ void Open(String path) {
|
||||
String col_string = FieldString(LuaState, "col");
|
||||
Int col = strtoll(col_string.data, NULL, 10);
|
||||
|
||||
CheckpointBeforeGoto();
|
||||
Window *window = GetWindow(GetLastActiveWindow());
|
||||
View *view = WindowOpenBufferView(window, file_path);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
if (line != -1 && col != -1) {
|
||||
view->carets[0] = MakeCaret(XYToPos(*buffer, {col - 1, line - 1}));
|
||||
Int pos = XYToPos(*buffer, {col - 1, line - 1});
|
||||
view->carets[0] = MakeCaret(pos);
|
||||
}
|
||||
UpdateScroll(window, true);
|
||||
SetActiveWindow(window->id);
|
||||
} else {
|
||||
ReportWarningf("Failed to match any of ApplyRules results!");
|
||||
ReportWarningf("Failed to match any of ApplyRules results!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,9 +140,10 @@ void HandleEvent(Event event) {
|
||||
WindowCommand(event, window, view);
|
||||
MergeCarets(view);
|
||||
}
|
||||
For(Windows) if (it.is_title_bar) ReplaceTitleBarData(&it);
|
||||
}
|
||||
|
||||
void Update(const Event &event) {
|
||||
void Update(Event event) {
|
||||
WindowSize = {(float)event.xwindow, (float)event.ywindow};
|
||||
LayoutWindows();
|
||||
|
||||
@@ -160,26 +161,33 @@ void Update(const Event &event) {
|
||||
|
||||
HandleEvent(event);
|
||||
|
||||
ReloadLuaConfig();
|
||||
For(Windows) if (it.is_title_bar) ReplaceTitleBarData(&it);
|
||||
ReplaceDebugData();
|
||||
|
||||
// Switch active window
|
||||
{
|
||||
if (ActiveWindow.id != NextActiveWindow.id) {
|
||||
bool active_window_changed = ActiveWindow.id != NextActiveWindow.id;
|
||||
if (active_window_changed) {
|
||||
Window *window = GetWindow(ActiveWindow);
|
||||
window->mouse_selecting = false;
|
||||
window->mouse_selecting_scrollbar = false;
|
||||
View *view = GetView(window->active_view);
|
||||
view->underline_count = 0;
|
||||
}
|
||||
ActiveWindow = NextActiveWindow;
|
||||
Window *w = GetWindow(ActiveWindow);
|
||||
if (!w->dont_save_in_active_window_history) {
|
||||
Add(&WindowSwitchHistory, ActiveWindow);
|
||||
view->mouse_selecting = false;
|
||||
ActiveWindow = NextActiveWindow;
|
||||
{
|
||||
Window *w = GetWindow(ActiveWindow);
|
||||
if (!w->dont_save_in_active_window_history) {
|
||||
Add(&WindowSwitchHistory, ActiveWindow);
|
||||
}
|
||||
}
|
||||
|
||||
// @todo: maybe move some of the mouse events to global comamnds?
|
||||
// the problem here is that we don't want to click twice etc when
|
||||
// window is inactive, we kind of also don't want to rerun events twice
|
||||
// because it seems to be buggy and problematic
|
||||
}
|
||||
}
|
||||
|
||||
ReloadLuaConfig();
|
||||
ReplaceDebugData();
|
||||
|
||||
For(IterateInReverse(&order)) {
|
||||
Window *window = &Windows[it];
|
||||
{
|
||||
@@ -318,7 +326,8 @@ int main()
|
||||
|
||||
WaitForEvents = true;
|
||||
Window *window = GetActiveWindow();
|
||||
if (window->mouse_selecting || window->mouse_selecting_scrollbar) {
|
||||
View *view = GetView(window->active_view);
|
||||
if (view->mouse_selecting || window->mouse_selecting_scrollbar) {
|
||||
WaitForEvents = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ struct View {
|
||||
|
||||
struct {
|
||||
bool fuzzy_search : 1;
|
||||
bool mouse_selecting : 1;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -77,7 +78,6 @@ struct Window {
|
||||
|
||||
struct {
|
||||
bool mouse_selecting_scrollbar : 1;
|
||||
bool mouse_selecting : 1;
|
||||
bool mouse_in_scrollbar : 1;
|
||||
|
||||
bool draw_scrollbar : 1;
|
||||
@@ -124,6 +124,7 @@ void Command_SelectEntireBuffer(View *view);
|
||||
void Command_Replace(View *view, String16 string);
|
||||
void Open(String path);
|
||||
void Open(String16 path);
|
||||
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
||||
|
||||
void ReportErrorf(const char *fmt, ...);
|
||||
void ReportWarningf(const char *fmt, ...);
|
||||
@@ -2,8 +2,14 @@
|
||||
- page up and down should also scroll and leave you in exactly same scroll
|
||||
- I think the way sublime text and we display line highlights is confusing with multiple cursors (line highlight can be confused with selection)
|
||||
|
||||
- mouse needs a rewrite
|
||||
- you should be able to scroll another window without focusing it
|
||||
- for now get rid of anchor maybe and do the - word select, line select
|
||||
- make clicks global so that they work without needing another click to activate
|
||||
- fix the bug where when we create a new view the anchor value on new view is compromised because and incongruent with position so we select from start of buffer
|
||||
- hand cursor on hover over underlined word
|
||||
|
||||
- ctrl + q to open, alt + q to go back
|
||||
- when switching to inactive window pass it the mouse click
|
||||
- delete multiple spaces (based on indent size) on delete instead one by one
|
||||
- switch to previous view (ctrl + tab)
|
||||
- save location on open and allow for revert (buffer id? or buffer name? - buffer name can change, buffer id is harder to serialize, I guess if internal only then buffer id)
|
||||
|
||||
@@ -240,7 +240,7 @@ void DrawWindow(Window *window) {
|
||||
Scroller scroller = ComputeScrollerRect(window);
|
||||
Rect2 rect = Shrink(scroller.rect, 2);
|
||||
Color color = ColorScrollbarScroller;
|
||||
if (!window->mouse_selecting && (window->mouse_selecting_scrollbar || window->mouse_in_scrollbar)) {
|
||||
if (!view->mouse_selecting && (window->mouse_selecting_scrollbar || window->mouse_in_scrollbar)) {
|
||||
if (is_active) color = ColorScrollbarScrollerSelected;
|
||||
}
|
||||
DrawRect(rect, color);
|
||||
|
||||
Reference in New Issue
Block a user