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();
|
Vec2I mouse = MouseVec2I();
|
||||||
Window *window = GetActiveWindow();
|
Window *window = GetActiveWindow();
|
||||||
|
View *view = GetView(window->active_view);
|
||||||
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
bool mouse_in_document = CheckCollisionPointRec(mouse, window->document_rect);
|
||||||
bool mouse_in_total = CheckCollisionPointRec(mouse, window->total_rect);
|
bool mouse_in_total = CheckCollisionPointRec(mouse, window->total_rect);
|
||||||
bool mouse_in_line_numbers = CheckCollisionPointRec(mouse, window->line_numbers_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;
|
static SDL_Cursor *SDL_MouseCursor;
|
||||||
if (SDL_MouseCursor) SDL_DestroyCursor(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_MouseCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_TEXT);
|
||||||
SDL_SetCursor(SDL_MouseCursor);
|
SDL_SetCursor(SDL_MouseCursor);
|
||||||
} else if (mouse_in_scrollbar || window->mouse_selecting_scrollbar || mouse_in_line_numbers) {
|
} 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;
|
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) {
|
void Command_IdentedNewLine(View *view) {
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
@@ -823,6 +846,10 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.ctrl && Mouse(RIGHT)) {
|
||||||
|
GoBackToLastCrumb();
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
@@ -845,7 +872,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
bool document_action = false;
|
bool document_action = false;
|
||||||
{
|
{
|
||||||
bool a = mouse_in_document && IsMouseEvent(event.kind);
|
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;
|
document_action = a || b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,12 +903,12 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mouse_in_document && Mouse(LEFT)) {
|
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)) {
|
if (Mouse(LEFT_UP)) {
|
||||||
window->mouse_selecting = false;
|
view->mouse_selecting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MergeCarets(view, &view->selection_anchor);
|
MergeCarets(view, &view->selection_anchor);
|
||||||
@@ -895,7 +922,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
}
|
}
|
||||||
MergeCarets(view, &view->selection_anchor);
|
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();
|
Vec2 mouse_vec2 = MouseVec2();
|
||||||
Scroller s = ComputeScrollerRect(window);
|
Scroller s = ComputeScrollerRect(window);
|
||||||
double size_y = (double)GetSize(window->scrollbar_rect).y;
|
double size_y = (double)GetSize(window->scrollbar_rect).y;
|
||||||
|
|||||||
@@ -47,11 +47,13 @@ void Open(String path) {
|
|||||||
String col_string = FieldString(LuaState, "col");
|
String col_string = FieldString(LuaState, "col");
|
||||||
Int col = strtoll(col_string.data, NULL, 10);
|
Int col = strtoll(col_string.data, NULL, 10);
|
||||||
|
|
||||||
|
CheckpointBeforeGoto();
|
||||||
Window *window = GetWindow(GetLastActiveWindow());
|
Window *window = GetWindow(GetLastActiveWindow());
|
||||||
View *view = WindowOpenBufferView(window, file_path);
|
View *view = WindowOpenBufferView(window, file_path);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
if (line != -1 && col != -1) {
|
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);
|
UpdateScroll(window, true);
|
||||||
SetActiveWindow(window->id);
|
SetActiveWindow(window->id);
|
||||||
|
|||||||
@@ -140,9 +140,10 @@ void HandleEvent(Event event) {
|
|||||||
WindowCommand(event, window, view);
|
WindowCommand(event, window, view);
|
||||||
MergeCarets(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};
|
WindowSize = {(float)event.xwindow, (float)event.ywindow};
|
||||||
LayoutWindows();
|
LayoutWindows();
|
||||||
|
|
||||||
@@ -160,26 +161,33 @@ void Update(const Event &event) {
|
|||||||
|
|
||||||
HandleEvent(event);
|
HandleEvent(event);
|
||||||
|
|
||||||
ReloadLuaConfig();
|
|
||||||
For(Windows) if (it.is_title_bar) ReplaceTitleBarData(&it);
|
|
||||||
ReplaceDebugData();
|
|
||||||
|
|
||||||
// Switch active window
|
// 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 *window = GetWindow(ActiveWindow);
|
||||||
window->mouse_selecting = false;
|
|
||||||
window->mouse_selecting_scrollbar = false;
|
window->mouse_selecting_scrollbar = false;
|
||||||
View *view = GetView(window->active_view);
|
View *view = GetView(window->active_view);
|
||||||
view->underline_count = 0;
|
view->underline_count = 0;
|
||||||
}
|
view->mouse_selecting = false;
|
||||||
ActiveWindow = NextActiveWindow;
|
ActiveWindow = NextActiveWindow;
|
||||||
|
{
|
||||||
Window *w = GetWindow(ActiveWindow);
|
Window *w = GetWindow(ActiveWindow);
|
||||||
if (!w->dont_save_in_active_window_history) {
|
if (!w->dont_save_in_active_window_history) {
|
||||||
Add(&WindowSwitchHistory, ActiveWindow);
|
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)) {
|
For(IterateInReverse(&order)) {
|
||||||
Window *window = &Windows[it];
|
Window *window = &Windows[it];
|
||||||
{
|
{
|
||||||
@@ -318,7 +326,8 @@ int main()
|
|||||||
|
|
||||||
WaitForEvents = true;
|
WaitForEvents = true;
|
||||||
Window *window = GetActiveWindow();
|
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;
|
WaitForEvents = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ struct View {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool fuzzy_search : 1;
|
bool fuzzy_search : 1;
|
||||||
|
bool mouse_selecting : 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,7 +78,6 @@ struct Window {
|
|||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool mouse_selecting_scrollbar : 1;
|
bool mouse_selecting_scrollbar : 1;
|
||||||
bool mouse_selecting : 1;
|
|
||||||
bool mouse_in_scrollbar : 1;
|
bool mouse_in_scrollbar : 1;
|
||||||
|
|
||||||
bool draw_scrollbar : 1;
|
bool draw_scrollbar : 1;
|
||||||
@@ -124,6 +124,7 @@ void Command_SelectEntireBuffer(View *view);
|
|||||||
void Command_Replace(View *view, String16 string);
|
void Command_Replace(View *view, String16 string);
|
||||||
void Open(String path);
|
void Open(String path);
|
||||||
void Open(String16 path);
|
void Open(String16 path);
|
||||||
|
void UpdateScroll(Window *window, bool update_caret_scrolling);
|
||||||
|
|
||||||
void ReportErrorf(const char *fmt, ...);
|
void ReportErrorf(const char *fmt, ...);
|
||||||
void ReportWarningf(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
|
- 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)
|
- 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
|
- 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
|
- delete multiple spaces (based on indent size) on delete instead one by one
|
||||||
- switch to previous view (ctrl + tab)
|
- 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)
|
- 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);
|
Scroller scroller = ComputeScrollerRect(window);
|
||||||
Rect2 rect = Shrink(scroller.rect, 2);
|
Rect2 rect = Shrink(scroller.rect, 2);
|
||||||
Color color = ColorScrollbarScroller;
|
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;
|
if (is_active) color = ColorScrollbarScrollerSelected;
|
||||||
}
|
}
|
||||||
DrawRect(rect, color);
|
DrawRect(rect, color);
|
||||||
|
|||||||
Reference in New Issue
Block a user