GotoForward
This commit is contained in:
@@ -89,17 +89,40 @@ void ToggleConsole() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckpointBeforeGoto() {
|
void CheckpointBeforeGoto(WindowID window_id) {
|
||||||
Window *window = GetWindow(GetLastActiveWindow());
|
Window *window = GetWindow(window_id);
|
||||||
View *view = GetView(window->active_view);
|
View *view = GetView(window->active_view);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
Add(&GotoCrumbs, {buffer->id, view->carets[0]});
|
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
||||||
|
window->goto_redo.len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoBackToLastCrumb() {
|
void GotoBackward(WindowID window_id) {
|
||||||
Window *window = GetWindow(GetLastActiveWindow());
|
Window *window = GetWindow(window_id);
|
||||||
if (GotoCrumbs.len <= 0) return;
|
if (window->goto_history.len <= 0) return;
|
||||||
GotoCrumb c = Pop(&GotoCrumbs);
|
{
|
||||||
|
Window *window = GetWindow(window_id);
|
||||||
|
View *view = GetView(window->active_view);
|
||||||
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
Add(&window->goto_redo, {buffer->id, view->carets[0]});
|
||||||
|
}
|
||||||
|
GotoCrumb c = Pop(&window->goto_history);
|
||||||
|
Buffer *buffer = GetBuffer(c.buffer_id);
|
||||||
|
View *view = WindowOpenBufferView(window, buffer->name);
|
||||||
|
view->carets[0] = c.caret;
|
||||||
|
UpdateScroll(window, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GotoForward(WindowID window_id) {
|
||||||
|
Window *window = GetWindow(window_id);
|
||||||
|
if (window->goto_redo.len <= 0) return;
|
||||||
|
{
|
||||||
|
Window *window = GetWindow(window_id);
|
||||||
|
View *view = GetView(window->active_view);
|
||||||
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
Add(&window->goto_history, {buffer->id, view->carets[0]});
|
||||||
|
}
|
||||||
|
GotoCrumb c = Pop(&window->goto_redo);
|
||||||
Buffer *buffer = GetBuffer(c.buffer_id);
|
Buffer *buffer = GetBuffer(c.buffer_id);
|
||||||
View *view = WindowOpenBufferView(window, buffer->name);
|
View *view = WindowOpenBufferView(window, buffer->name);
|
||||||
view->carets[0] = c.caret;
|
view->carets[0] = c.caret;
|
||||||
@@ -289,10 +312,12 @@ bool GlobalCommand(Event event) {
|
|||||||
|
|
||||||
if (event.ctrl && event.shift && Mouse(RIGHT)) {
|
if (event.ctrl && event.shift && Mouse(RIGHT)) {
|
||||||
MouseExecWord(event);
|
MouseExecWord(event);
|
||||||
|
} else if (event.alt && event.ctrl && Mouse(RIGHT)) {
|
||||||
|
GotoForward(GetLastActiveWindow());
|
||||||
} else if (event.ctrl && Mouse(RIGHT)) {
|
} else if (event.ctrl && Mouse(RIGHT)) {
|
||||||
MouseLoadWord(event);
|
MouseLoadWord(event);
|
||||||
} else if (event.alt && Mouse(RIGHT)) {
|
} else if (event.alt && Mouse(RIGHT)) {
|
||||||
GoBackToLastCrumb();
|
GotoBackward(GetLastActiveWindow());
|
||||||
} else if (Mouse(RIGHT)) {
|
} else if (Mouse(RIGHT)) {
|
||||||
Vec2I mouse = MouseVec2I();
|
Vec2I mouse = MouseVec2I();
|
||||||
Window *window = GetActiveWindow();
|
Window *window = GetActiveWindow();
|
||||||
|
|||||||
@@ -896,6 +896,8 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
String16 string = GetString(*buffer, range);
|
String16 string = GetString(*buffer, range);
|
||||||
|
|
||||||
Command_EvalLua(view, string);
|
Command_EvalLua(view, string);
|
||||||
|
} else if (CtrlAlt(SDLK_Q)) {
|
||||||
|
GotoForward(GetLastActiveWindow());
|
||||||
} else if (Ctrl(SDLK_Q)) {
|
} else if (Ctrl(SDLK_Q)) {
|
||||||
Caret caret = view->carets[0];
|
Caret caret = view->carets[0];
|
||||||
Range range = caret.range;
|
Range range = caret.range;
|
||||||
@@ -904,7 +906,7 @@ void WindowCommand(Event event, Window *window, View *view) {
|
|||||||
|
|
||||||
Open(string);
|
Open(string);
|
||||||
} else if (Alt(SDLK_Q)) {
|
} else if (Alt(SDLK_Q)) {
|
||||||
GoBackToLastCrumb();
|
GotoBackward(GetLastActiveWindow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ String GetUniqueBufferName(Allocator allocator, String working_dir, String p
|
|||||||
|
|
||||||
void ExecInNewBuffer(String cmd, String working_dir) {
|
void ExecInNewBuffer(String cmd, String working_dir) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
CheckpointBeforeGoto();
|
CheckpointBeforeGoto(GetLastActiveWindow());
|
||||||
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+CMD");
|
String buffer_name = GetUniqueBufferName(scratch, working_dir, "+CMD");
|
||||||
Window *window = GetWindow(GetLastActiveWindow());
|
Window *window = GetWindow(GetLastActiveWindow());
|
||||||
View *view = WindowOpenBufferView(window, buffer_name);
|
View *view = WindowOpenBufferView(window, buffer_name);
|
||||||
@@ -66,8 +66,9 @@ 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();
|
WindowID window_id = GetLastActiveWindow();
|
||||||
Window *window = GetWindow(GetLastActiveWindow());
|
CheckpointBeforeGoto(window_id);
|
||||||
|
Window *window = GetWindow(window_id);
|
||||||
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) {
|
||||||
@@ -192,6 +193,21 @@ int LuaGetCurrentBufferDir(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OpenFilesHereRecursive(Window *window, String path) {
|
||||||
|
Scratch scratch;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LuaOpenFilesHere(lua_State *L) {
|
||||||
|
Window *window = GetWindow(GetLastActiveWindow());
|
||||||
|
|
||||||
|
Scratch scratch;
|
||||||
|
for (FileIter it = IterateFiles(scratch, GetCurrentBufferDir()); IsValid(it); Advance(&it)) {
|
||||||
|
WindowOpenBufferView(window, it.absolute_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
int numkeys = 0;
|
int numkeys = 0;
|
||||||
@@ -213,6 +229,7 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{ "Kill", LuaKill},
|
{ "Kill", LuaKill},
|
||||||
{ "NewC", LuaNewCmd},
|
{ "NewC", LuaNewCmd},
|
||||||
{ "AppendC", LuaAppendCmd},
|
{ "AppendC", LuaAppendCmd},
|
||||||
|
{ "OpenFilesHere", LuaOpenFilesHere},
|
||||||
{ NULL, NULL},
|
{ NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ BufferID SearchBufferID;
|
|||||||
// Remember that WindowCommand works on window handed it down from HandleEvent
|
// Remember that WindowCommand works on window handed it down from HandleEvent
|
||||||
// just because we don't have NextActiveWindow doesn't mean that we work on new
|
// just because we don't have NextActiveWindow doesn't mean that we work on new
|
||||||
// window all of a sudden in that function call!
|
// window all of a sudden in that function call!
|
||||||
WindowID ActiveWindow;
|
WindowID ActiveWindow;
|
||||||
Array<WindowID> WindowSwitchHistory; // @todo: probably better as a circular buffer
|
Array<WindowID> WindowSwitchHistory; // @todo: probably better as a circular buffer
|
||||||
Array<GotoCrumb> GotoCrumbs;
|
Int CaretChangeID;
|
||||||
Int CaretChangeID;
|
|
||||||
|
|
||||||
WindowID ScrollbarSelected = {-1};
|
WindowID ScrollbarSelected = {-1};
|
||||||
WindowID DocumentSelected = {-1};
|
WindowID DocumentSelected = {-1};
|
||||||
@@ -267,7 +266,7 @@ Buffer *BufferOpenFile(String path) {
|
|||||||
path = GetAbsolutePath(scratch, path);
|
path = GetAbsolutePath(scratch, path);
|
||||||
path = Intern(&GlobalInternTable, path);
|
path = Intern(&GlobalInternTable, path);
|
||||||
String string = ReadFile(scratch, path);
|
String string = ReadFile(scratch, path);
|
||||||
buffer = CreateBuffer(sys_allocator, path, string.len * 4);
|
buffer = CreateBuffer(sys_allocator, path, string.len * 4 + 4096);
|
||||||
buffer->len = ConvertUTF8ToUTF16UnixLine(string, buffer->str, buffer->cap);
|
buffer->len = ConvertUTF8ToUTF16UnixLine(string, buffer->str, buffer->cap);
|
||||||
UpdateLines(buffer, {}, String16{(wchar_t *)buffer->data, buffer->len});
|
UpdateLines(buffer, {}, String16{(wchar_t *)buffer->data, buffer->len});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ alt mright - go back
|
|||||||
ctrl mright - load word
|
ctrl mright - load word
|
||||||
shift mright -
|
shift mright -
|
||||||
alt shift mright -
|
alt shift mright -
|
||||||
alt ctrl mright -
|
alt ctrl mright - go forward
|
||||||
ctrl shift mright - exec word
|
ctrl shift mright - exec word
|
||||||
mmiddle -
|
mmiddle -
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ struct View {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GotoCrumb {
|
||||||
|
BufferID buffer_id;
|
||||||
|
Caret caret;
|
||||||
|
};
|
||||||
|
|
||||||
struct Window {
|
struct Window {
|
||||||
WindowID id;
|
WindowID id;
|
||||||
ViewID active_view;
|
ViewID active_view;
|
||||||
@@ -69,6 +74,9 @@ struct Window {
|
|||||||
Rect2I line_numbers_rect;
|
Rect2I line_numbers_rect;
|
||||||
Rect2I document_rect;
|
Rect2I document_rect;
|
||||||
|
|
||||||
|
Array<GotoCrumb> goto_history;
|
||||||
|
Array<GotoCrumb> goto_redo;
|
||||||
|
|
||||||
double mouse_scroller_offset;
|
double mouse_scroller_offset;
|
||||||
int z;
|
int z;
|
||||||
|
|
||||||
@@ -94,11 +102,6 @@ struct Scroller {
|
|||||||
Int line_count;
|
Int line_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GotoCrumb {
|
|
||||||
BufferID buffer_id;
|
|
||||||
Caret caret;
|
|
||||||
};
|
|
||||||
|
|
||||||
// @WARNING: be careful about using this, should only be used for debugging
|
// @WARNING: be careful about using this, should only be used for debugging
|
||||||
// the problem with this is that we want events to be reproducible.
|
// the problem with this is that we want events to be reproducible.
|
||||||
// We eat as many events as we can in a frame, we abstract the frame and so on.
|
// We eat as many events as we can in a frame, we abstract the frame and so on.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
- jump history forward
|
||||||
- Remove pointers and use ViewIDs (enable array debug while doing this)
|
- Remove pointers and use ViewIDs (enable array debug while doing this)
|
||||||
- try using git grep for search for now, combine with fuzzy search buffer
|
- try using git grep for search for now, combine with fuzzy search buffer
|
||||||
- lua maybe try heuristic matching paths from left?
|
- lua maybe try heuristic matching paths from left?
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Windows
|
Windows
|
||||||
|
- better teminology then 'active' 'last active' 'current'
|
||||||
- switch to previous view (ctrl + tab)
|
- switch to previous view (ctrl + tab)
|
||||||
- shift + ctrl + click should open a new window and then with alt it probably should kill it
|
- shift + ctrl + click should open a new window and then with alt it probably should kill it
|
||||||
- layout using a tree!!
|
- layout using a tree!!
|
||||||
@@ -48,7 +50,6 @@ backlog
|
|||||||
- drop text into window
|
- drop text into window
|
||||||
- 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)
|
||||||
- ctrl + delete maybe should stop on new line but it keeps on going, sublime is much more careful with deleting
|
|
||||||
- text_editor --record events.txt text_editor --playback events.txt
|
- text_editor --record events.txt text_editor --playback events.txt
|
||||||
- make the editor replayable, store events and then replay, be careful about globals
|
- make the editor replayable, store events and then replay, be careful about globals
|
||||||
- maybe open should return multiple options if there are many more? (like in sublime if many symbols you get a window and you choose and it automatically jumps you to the symbol in the background)
|
- maybe open should return multiple options if there are many more? (like in sublime if many symbols you get a window and you choose and it automatically jumps you to the symbol in the background)
|
||||||
|
|||||||
Reference in New Issue
Block a user