diff --git a/src/text_editor/commands_window.cpp b/src/text_editor/commands_window.cpp index 1465a71..702fbd0 100644 --- a/src/text_editor/commands_window.cpp +++ b/src/text_editor/commands_window.cpp @@ -586,6 +586,26 @@ void Command_Find(View *seek_view, String16 needle, bool forward = true) { seek_view->carets[0] = caret; } +void Command_GotoNextInList(Window *window, Int line_offset = 1) { + ViewID active_view = window->active_view; + CheckpointBeforeGoto(window->id); + + View *view_goto = GetView(window->active_goto_list); + window->active_view = view_goto->id; + + Buffer *buffer_goto = GetBuffer(view_goto->active_buffer); + int64_t pos = GetFront(view_goto->carets[0]); + Int line = PosToLine(*buffer_goto, pos); + if (line + line_offset < buffer_goto->line_starts.len) { + Range line_range = GetLineRangeWithoutNL(*buffer_goto, line + line_offset); + String16 line = GetString(*buffer_goto, line_range); + view_goto->carets[0] = MakeCaret(line_range.min); + Open(line); + } else { + window->active_view = active_view; + } +} + void WindowCommand(Event event, Window *window, View *view) { ProfileFunction(); Buffer *buffer = GetBuffer(view->active_buffer); @@ -767,11 +787,12 @@ void WindowCommand(Event event, Window *window, View *view) { Insert(&view->carets, caret, 0); MergeCarets(view); } else if (Press(SDLK_F3)) { - Scratch scratch; - String16 search_string = ToString16(scratch, window->search_string); - Caret caret = FindNext(buffer, search_string, view->carets[0]); - view->carets.len = 1; - view->carets[0] = caret; + // Scratch scratch; + // String16 search_string = ToString16(scratch, window->search_string); + // Caret caret = FindNext(buffer, search_string, view->carets[0]); + // view->carets.len = 1; + // view->carets[0] = caret; + Command_GotoNextInList(window); } if (view->fuzzy_search && search) { @@ -886,6 +907,7 @@ void WindowCommand(Event event, Window *window, View *view) { if (GetSize(caret.range) == 0) range = EncloseLoadWord(buffer, GetFront(caret)); String16 string = GetString(*buffer, range); + window->active_goto_list = view->id; Open(string); } else if (Alt(SDLK_Q)) { GotoBackward(GetLastActiveWindow()); diff --git a/src/text_editor/text_editor.h b/src/text_editor/text_editor.h index 392b03c..aefb14a 100644 --- a/src/text_editor/text_editor.h +++ b/src/text_editor/text_editor.h @@ -79,6 +79,7 @@ struct Window { // @todo: consider making this String16 String search_string; + ViewID active_goto_list; double mouse_scroller_offset; int z; diff --git a/src/text_editor/todo.txt b/src/text_editor/todo.txt index 142b600..bc7847b 100644 --- a/src/text_editor/todo.txt +++ b/src/text_editor/todo.txt @@ -1,9 +1,9 @@ - Remove pointers and use ViewIDs (enable array debug while doing this) - ctrl + f - should find Search and select content or add Search -- search backwards - some split selection commands - assign commands or lua functions to F1-F8 keys +- generate the lua function table for all functions prefixed with Lua_ - Cycle up and down through a list of filenames and jump to every filename listed and remember the last buffer which we jumped from which contains the list - A lister which is going to show project without the full path and sorted by recency