Remove NextActiveWindowID
This commit is contained in:
@@ -36,7 +36,7 @@ Commands TODO:
|
||||
- Console: OK concept but constrain
|
||||
- Turned off by default
|
||||
- Special: non editable, hotkeys don't work etc.
|
||||
|
||||
- I'M SETTING ACTIVE WINDOW AFTER COMMAND!!! DO WE CONTINUE WITH THIS?
|
||||
- RegisterCommand(Command_ShowCommands, KEY_P | KEY_CTRL)
|
||||
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ void ReportErrorf(const char *fmt, ...) {
|
||||
View *view = GetView(NullViewID);
|
||||
if (view) {
|
||||
Appendf(view, "%S\n", string);
|
||||
NextActiveWindowID = NullWindowID;
|
||||
ActiveWindowID = NullWindowID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,7 +956,7 @@ void ReopenBuffer(Buffer *buffer) {
|
||||
void Command_Reopen() {
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
ReopenBuffer(main.buffer);
|
||||
NextActiveWindowID = main.window->id;
|
||||
ActiveWindowID = main.window->id;
|
||||
} RegisterCommand(Command_Reopen);
|
||||
|
||||
void New(Window *window, String name = "") {
|
||||
@@ -1053,7 +1053,7 @@ View *ExecHidden(String buffer_name, String cmd, String working_dir) {
|
||||
BSet Exec(String cmd, String working_dir, bool set_active = true) {
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
if (set_active) {
|
||||
NextActiveWindowID = main.window->id;
|
||||
ActiveWindowID = main.window->id;
|
||||
}
|
||||
JumpGarbageBuffer(&main);
|
||||
Exec(main.view->id, true, cmd, working_dir);
|
||||
@@ -1067,7 +1067,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
|
||||
OnOpenResult ores = CallOnOpen(scratch, path, meta);
|
||||
if (ores.kind == "text") {
|
||||
if (set_active) {
|
||||
NextActiveWindowID = set.window->id;
|
||||
ActiveWindowID = set.window->id;
|
||||
}
|
||||
if (IsDir(ores.file_path)) {
|
||||
JumpGarbageBuffer(&set, GetUniqueBufferName(ores.file_path, "temp", ".dirlisting"));
|
||||
@@ -1088,7 +1088,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
|
||||
UpdateScroll(set.window, true);
|
||||
} else if (ores.kind == "exec") {
|
||||
if (set_active) {
|
||||
NextActiveWindowID = set.window->id;
|
||||
ActiveWindowID = set.window->id;
|
||||
}
|
||||
JumpGarbageBuffer(&set);
|
||||
Exec(set.view->id, true, ores.cmd, ores.working_dir);
|
||||
@@ -1121,7 +1121,7 @@ void Command_ShowBufferList() {
|
||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||
command_bar.window->visible = true;
|
||||
command_bar.window->eval_command = false;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For(Buffers) {
|
||||
RawAppendf(command_bar.buffer, "%-80S || %S\n", SkipToLastSlash(it->name), it->name);
|
||||
@@ -1134,7 +1134,7 @@ void Command_ShowCommandList() {
|
||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||
command_bar.window->visible = true;
|
||||
command_bar.window->eval_command = false;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For(LuaFunctions) {
|
||||
Appendf(command_bar.view, "%S()\n ", it.name);
|
||||
@@ -1147,7 +1147,7 @@ void Command_ListViews() {
|
||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||
command_bar.window->visible = true;
|
||||
command_bar.window->eval_command = false;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For(Views) {
|
||||
Buffer *buffer = GetBuffer(it->active_buffer);
|
||||
@@ -1225,7 +1225,7 @@ void Command_ShowCommands() {
|
||||
BSet command_bar = GetBSet(CommandBarWindowID);
|
||||
command_bar.window->visible = true;
|
||||
command_bar.window->eval_command = true;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
ActiveWindowID = command_bar.window->id;
|
||||
ResetBuffer(command_bar.buffer);
|
||||
For(CommandFunctions) {
|
||||
Appendf(command_bar.view, "%S\n", it.name);
|
||||
|
||||
@@ -77,7 +77,6 @@ void FuzzySearchOpen(BSet active) {
|
||||
}
|
||||
if (active.window->eval_command) {
|
||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||
NextActiveWindowID = main.window->id;
|
||||
ActiveWindowID = main.window->id;
|
||||
EvalCommand(string);
|
||||
} else {
|
||||
@@ -195,7 +194,7 @@ void OnCommand(Event event) {
|
||||
}
|
||||
bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
|
||||
if (mouse_in_document) {
|
||||
NextActiveWindowID = it->id;
|
||||
ActiveWindowID = it->id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -253,7 +252,7 @@ void OnCommand(Event event) {
|
||||
Assert(ScrollbarSelected.id == -1);
|
||||
Assert(DocumentSelected.id == -1);
|
||||
|
||||
BSet active = GetBSet(NextActiveWindowID); // using next to make sure mouse works on first click after switching the window
|
||||
BSet active = GetBSet(ActiveWindowID); // using next to make sure mouse works on first click after switching the window
|
||||
bool mouse_in_document = AreOverlapping(mouse, active.window->document_rect);
|
||||
bool mouse_in_line_numbers = AreOverlapping(mouse, active.window->line_numbers_rect);
|
||||
if (mouse_in_document || mouse_in_line_numbers) {
|
||||
@@ -330,12 +329,12 @@ void OnCommand(Event event) {
|
||||
}
|
||||
|
||||
if (CtrlPress(SDLK_1)) {
|
||||
NextActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||
ActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||
}
|
||||
if (CtrlPress(SDLK_2)) {
|
||||
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
||||
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
||||
NextActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
||||
ActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
||||
}
|
||||
if (CtrlPress(SDLK_3)) {
|
||||
Window *first = GetOverlappingWindow({0,0});
|
||||
@@ -344,7 +343,7 @@ void OnCommand(Event event) {
|
||||
if (second) {
|
||||
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
||||
if (third) {
|
||||
NextActiveWindowID = third->id;
|
||||
ActiveWindowID = third->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,6 +364,9 @@ void OnCommand(Event event) {
|
||||
if (active.view->fuzzy_search) {
|
||||
if (Press(SDLK_RETURN)) {
|
||||
FuzzySearchOpen(active);
|
||||
// :OnCommandEnding
|
||||
MergeCarets(active.buffer, &active.view->carets);
|
||||
IF_DEBUG(AssertRanges(active.view->carets));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -416,7 +418,7 @@ void OnCommand(Event event) {
|
||||
} else if (ShiftPress(SDLK_LEFT)) {
|
||||
MoveCarets(active.view, DIR_LEFT, false, SHIFT_PRESS);
|
||||
} else if (AltPress(SDLK_LEFT)) {
|
||||
NextActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||
ActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||
} else if (Press(SDLK_LEFT)) {
|
||||
MoveCarets(active.view, DIR_LEFT);
|
||||
}
|
||||
@@ -428,7 +430,7 @@ void OnCommand(Event event) {
|
||||
} else if (ShiftPress(SDLK_RIGHT)) {
|
||||
MoveCarets(active.view, DIR_RIGHT, false, SHIFT_PRESS);
|
||||
} else if (AltPress(SDLK_RIGHT)) {
|
||||
NextActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||
ActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||
} else if (Press(SDLK_RIGHT)) {
|
||||
MoveCarets(active.view, DIR_RIGHT);
|
||||
}
|
||||
@@ -627,6 +629,10 @@ void OnCommand(Event event) {
|
||||
if (CtrlPress(SDLK_Q)) {
|
||||
if (active.view->fuzzy_search) {
|
||||
FuzzySearchOpen(active);
|
||||
// :OnCommandEnding
|
||||
MergeCarets(active.buffer, &active.view->carets);
|
||||
IF_DEBUG(AssertRanges(active.view->carets));
|
||||
return;
|
||||
} else {
|
||||
Open(FetchLoadWord());
|
||||
}
|
||||
@@ -640,7 +646,7 @@ void OnCommand(Event event) {
|
||||
if (active.window->layout) {
|
||||
//
|
||||
} else {
|
||||
NextActiveWindowID = LastActiveLayoutWindowID;
|
||||
ActiveWindowID = LastActiveLayoutWindowID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ ViewID SearchViewID;
|
||||
BufferID SearchBufferID;
|
||||
|
||||
WindowID ActiveWindowID;
|
||||
WindowID NextActiveWindowID;
|
||||
WindowID LastActiveLayoutWindowID;
|
||||
WindowID ScrollbarSelected = {-1};
|
||||
WindowID DocumentSelected = {-1};
|
||||
|
||||
@@ -142,7 +142,7 @@ int Lua_ListCommands(lua_State *L) {
|
||||
i += 1;
|
||||
}
|
||||
EndJump(main);
|
||||
NextActiveWindowID = main.window->id;
|
||||
ActiveWindowID = main.window->id;
|
||||
return 0;
|
||||
} RegisterLua(Lua_ListCommands);
|
||||
|
||||
@@ -286,13 +286,13 @@ int Lua_Cmd(lua_State *L) {
|
||||
JumpGarbageBuffer(&main);
|
||||
Exec(main.view->id, true, cmd, working_dir);
|
||||
main.view->fuzzy_search = true;
|
||||
NextActiveWindowID = main.window->id;
|
||||
ActiveWindowID = 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);
|
||||
NextActiveWindowID = main.window->id;
|
||||
ActiveWindowID = main.window->id;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -38,9 +38,6 @@ String GetMainDir() {
|
||||
void GarbageCollect() {
|
||||
Allocator sys_allocator = GetSystemAllocator();
|
||||
|
||||
|
||||
ActiveWindowID = NextActiveWindowID;
|
||||
|
||||
For (Windows) {
|
||||
if (it->sync_visibility_with_focus) {
|
||||
if (it->id == ActiveWindowID) {
|
||||
@@ -51,8 +48,8 @@ void GarbageCollect() {
|
||||
}
|
||||
}
|
||||
|
||||
if (ActiveWindowID.id != LastActiveLayoutWindowID.id) {
|
||||
Window *window = GetWindow(ActiveWindowID);
|
||||
if (ActiveWindowID.id != LastActiveLayoutWindowID.id) {
|
||||
if (window->layout) {
|
||||
LastActiveLayoutWindowID = ActiveWindowID;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user