Small Command_Open fixes
This commit is contained in:
@@ -10,4 +10,5 @@ function OnInit()
|
|||||||
Open("src/text_editor/todo.txt")
|
Open("src/text_editor/todo.txt")
|
||||||
Split(HORIZONTAL)
|
Split(HORIZONTAL)
|
||||||
Open("src/text_editor/commands.cpp")
|
Open("src/text_editor/commands.cpp")
|
||||||
|
SplitSize(0.15)
|
||||||
end
|
end
|
||||||
@@ -1119,7 +1119,8 @@ BSet Command_Open(Window *window, String path, String meta, bool set_active = tr
|
|||||||
CheckpointBeforeGoto(set.window);
|
CheckpointBeforeGoto(set.window);
|
||||||
View *view = WindowOpenBufferView(set.window, ores.file_path);
|
View *view = WindowOpenBufferView(set.window, ores.file_path);
|
||||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
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});
|
Int pos = XYToPos(buffer, {ores.col - 1, ores.line - 1});
|
||||||
view->carets[0] = MakeCaret(pos);
|
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);
|
set = GetBSet(window);
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
BSet Command_Open(String path, String meta) {
|
BSet Command_Open(String path, String meta) {
|
||||||
BSet main = GetActiveMainSet();
|
BSet main = GetActiveMainSet();
|
||||||
main = Command_Open(main.window, path, meta);
|
main = Command_Open(main.window, path, meta);
|
||||||
@@ -1199,6 +1201,8 @@ int Lua_Cmd(lua_State *L) {
|
|||||||
ActiveWindow = main.window->id;
|
ActiveWindow = main.window->id;
|
||||||
} else {
|
} else {
|
||||||
JumpGarbageBuffer(&main);
|
JumpGarbageBuffer(&main);
|
||||||
|
main.window->active_goto_list = main.view->id;
|
||||||
|
main.window->goto_list_pos = 0;
|
||||||
Exec(main.view->id, true, cmd, working_dir);
|
Exec(main.view->id, true, cmd, working_dir);
|
||||||
ActiveWindow = main.window->id;
|
ActiveWindow = main.window->id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ int Lua_SplitSize(lua_State *L) {
|
|||||||
return 0;
|
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) {
|
static void HookLuaForceExit(lua_State *L, lua_Debug *debug) {
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
int numkeys = 0;
|
int numkeys = 0;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ luaL_Reg LuaFunctions[] = {
|
|||||||
{"GetWorkDir", Lua_GetWorkDir},
|
{"GetWorkDir", Lua_GetWorkDir},
|
||||||
{"GetMainDir", Lua_GetMainDir},
|
{"GetMainDir", Lua_GetMainDir},
|
||||||
{"SplitSize", Lua_SplitSize},
|
{"SplitSize", Lua_SplitSize},
|
||||||
|
{"KillWindow", Lua_KillWindow},
|
||||||
{"Play", Lua_Play},
|
{"Play", Lua_Play},
|
||||||
{"TrimTrailingWhitespace", Lua_TrimTrailingWhitespace},
|
{"TrimTrailingWhitespace", Lua_TrimTrailingWhitespace},
|
||||||
{"ConvertLineEndingsToLF", Lua_ConvertLineEndingsToLF},
|
{"ConvertLineEndingsToLF", Lua_ConvertLineEndingsToLF},
|
||||||
|
|||||||
@@ -175,7 +175,6 @@ Buffer *CreateTempBuffer(Allocator allocator, Int size = 4096) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String WindowBufferName = "window_buffer";
|
|
||||||
Window *CreateWindow(bool create_command_buffer = true) {
|
Window *CreateWindow(bool create_command_buffer = true) {
|
||||||
Window *w = AllocType(Perm, Window);
|
Window *w = AllocType(Perm, Window);
|
||||||
w->visible = true;
|
w->visible = true;
|
||||||
@@ -187,6 +186,39 @@ Window *CreateWindow(bool create_command_buffer = true) {
|
|||||||
return w;
|
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) {
|
View *CreateView(BufferID active_buffer) {
|
||||||
Allocator al = GetSystemAllocator();
|
Allocator al = GetSystemAllocator();
|
||||||
View *view = AllocType(al, View);
|
View *view = AllocType(al, View);
|
||||||
@@ -497,10 +529,6 @@ void GarbageCollect() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!ViewIsReferenced(it->id)) {
|
|
||||||
// int a = 10;
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool ref = ViewIsReferenced(it->id);
|
bool ref = ViewIsReferenced(it->id);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
continue;
|
continue;
|
||||||
@@ -518,10 +546,6 @@ void GarbageCollect() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!BufferIsReferenced(it->id)) {
|
|
||||||
// int a = 10;
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool ref = BufferIsReferenced(it->id);
|
bool ref = BufferIsReferenced(it->id);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
continue;
|
continue;
|
||||||
@@ -530,4 +554,11 @@ void GarbageCollect() {
|
|||||||
DeallocBuffer(it);
|
DeallocBuffer(it);
|
||||||
DLL_QUEUE_REMOVE(FirstBuffer, LastBuffer, 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 is_search_bar : 1;
|
||||||
|
|
||||||
bool deactivate_on_escape : 1;
|
bool deactivate_on_escape : 1;
|
||||||
|
|
||||||
|
bool kill : 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user