Small Command_Open fixes
This commit is contained in:
@@ -1119,7 +1119,8 @@ BSet Command_Open(Window *window, String path, String meta, bool set_active = tr
|
||||
CheckpointBeforeGoto(set.window);
|
||||
View *view = WindowOpenBufferView(set.window, ores.file_path);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
if (ores.line != -1 && ores.col != -1) {
|
||||
if (ores.line != -1) {
|
||||
if (ores.col == -1) ores.col = 1;
|
||||
Int pos = XYToPos(buffer, {ores.col - 1, ores.line - 1});
|
||||
view->carets[0] = MakeCaret(pos);
|
||||
}
|
||||
@@ -1143,6 +1144,7 @@ BSet Command_Open(Window *window, String path, String meta, bool set_active = tr
|
||||
set = GetBSet(window);
|
||||
return set;
|
||||
}
|
||||
|
||||
BSet Command_Open(String path, String meta) {
|
||||
BSet main = GetActiveMainSet();
|
||||
main = Command_Open(main.window, path, meta);
|
||||
@@ -1199,6 +1201,8 @@ int Lua_Cmd(lua_State *L) {
|
||||
ActiveWindow = main.window->id;
|
||||
} else {
|
||||
JumpGarbageBuffer(&main);
|
||||
main.window->active_goto_list = main.view->id;
|
||||
main.window->goto_list_pos = 0;
|
||||
Exec(main.view->id, true, cmd, working_dir);
|
||||
ActiveWindow = main.window->id;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,12 @@ int Lua_SplitSize(lua_State *L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Lua_KillWindow(lua_State *L) {
|
||||
BSet set = GetActiveMainSet();
|
||||
set.window->kill = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
||||
SDL_PumpEvents();
|
||||
int numkeys = 0;
|
||||
|
||||
@@ -12,6 +12,7 @@ luaL_Reg LuaFunctions[] = {
|
||||
{"GetWorkDir", Lua_GetWorkDir},
|
||||
{"GetMainDir", Lua_GetMainDir},
|
||||
{"SplitSize", Lua_SplitSize},
|
||||
{"KillWindow", Lua_KillWindow},
|
||||
{"Play", Lua_Play},
|
||||
{"TrimTrailingWhitespace", Lua_TrimTrailingWhitespace},
|
||||
{"ConvertLineEndingsToLF", Lua_ConvertLineEndingsToLF},
|
||||
|
||||
@@ -175,7 +175,6 @@ Buffer *CreateTempBuffer(Allocator allocator, Int size = 4096) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String WindowBufferName = "window_buffer";
|
||||
Window *CreateWindow(bool create_command_buffer = true) {
|
||||
Window *w = AllocType(Perm, Window);
|
||||
w->visible = true;
|
||||
@@ -187,6 +186,39 @@ Window *CreateWindow(bool create_command_buffer = true) {
|
||||
return w;
|
||||
}
|
||||
|
||||
// void DestroyWindow(Window *window) {
|
||||
// WindowSplit *split = window->split_ref;
|
||||
// if (split->parent == NULL) {
|
||||
// Assert(split->kind == WindowSplitKind_Window);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// WindowSplit *p = split->parent;
|
||||
// WindowSplit *valid_node = p->left == split ? p->right : p->left;
|
||||
// if (p->parent == NULL) {
|
||||
// // @todo:
|
||||
// } else {
|
||||
// valid_node->parent = p->parent;
|
||||
// *p = *valid_node;
|
||||
// }
|
||||
//
|
||||
// // @leak window
|
||||
// DLL_QUEUE_REMOVE(FirstWindow, LastWindow, window);
|
||||
// WindowCount -= 1;
|
||||
//
|
||||
// if (window->search_bar_window.id) {
|
||||
// Window *s = GetWindow(window->search_bar_window);
|
||||
// DLL_QUEUE_REMOVE(FirstWindow, LastWindow, s);
|
||||
// WindowCount -= 1;
|
||||
// }
|
||||
//
|
||||
// if (window->title_bar_window.id) {
|
||||
// Window *s = GetWindow(window->title_bar_window);
|
||||
// DLL_QUEUE_REMOVE(FirstWindow, LastWindow, s);
|
||||
// WindowCount -= 1;
|
||||
// }
|
||||
// }
|
||||
|
||||
View *CreateView(BufferID active_buffer) {
|
||||
Allocator al = GetSystemAllocator();
|
||||
View *view = AllocType(al, View);
|
||||
@@ -497,10 +529,6 @@ void GarbageCollect() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if (!ViewIsReferenced(it->id)) {
|
||||
// int a = 10;
|
||||
// }
|
||||
|
||||
bool ref = ViewIsReferenced(it->id);
|
||||
if (ref) {
|
||||
continue;
|
||||
@@ -518,10 +546,6 @@ void GarbageCollect() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if (!BufferIsReferenced(it->id)) {
|
||||
// int a = 10;
|
||||
// }
|
||||
|
||||
bool ref = BufferIsReferenced(it->id);
|
||||
if (ref) {
|
||||
continue;
|
||||
@@ -530,4 +554,11 @@ void GarbageCollect() {
|
||||
DeallocBuffer(it);
|
||||
DLL_QUEUE_REMOVE(FirstBuffer, LastBuffer, it);
|
||||
}
|
||||
|
||||
// for (Window *it = FirstWindow, *next = NULL; it; it = next) {
|
||||
// next = it->next;
|
||||
// if (it->kill) {
|
||||
// DestroyWindow(it);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ struct Window {
|
||||
bool is_search_bar : 1;
|
||||
|
||||
bool deactivate_on_escape : 1;
|
||||
|
||||
bool kill : 1;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user