NextActiveWindowID to fix the bug where ctrl+q would trigger for 2 registered commands and it would work on 2 different active windows
This commit is contained in:
@@ -221,7 +221,7 @@ void ReportErrorf(const char *fmt, ...) {
|
|||||||
View *view = GetView(NullViewID);
|
View *view = GetView(NullViewID);
|
||||||
if (view) {
|
if (view) {
|
||||||
Appendf(view, "%S\n", string);
|
Appendf(view, "%S\n", string);
|
||||||
ActiveWindowID = NullWindowID;
|
NextActiveWindowID = NullWindowID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +432,7 @@ View *ExecHidden(String buffer_name, String cmd, String working_dir) {
|
|||||||
BSet Exec(String cmd, String working_dir, bool set_active = true) {
|
BSet Exec(String cmd, String working_dir, bool set_active = true) {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
ActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
}
|
}
|
||||||
JumpGarbageBuffer(&main);
|
JumpGarbageBuffer(&main);
|
||||||
Exec(main.view->id, true, cmd, working_dir);
|
Exec(main.view->id, true, cmd, working_dir);
|
||||||
@@ -441,7 +441,7 @@ BSet Exec(String cmd, String working_dir, bool set_active = true) {
|
|||||||
|
|
||||||
BSet ExecBuild(String cmd) {
|
BSet ExecBuild(String cmd) {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
ActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
View *view = WindowOpenBufferView(main.window, BuildBuffer->name);
|
View *view = WindowOpenBufferView(main.window, BuildBuffer->name);
|
||||||
ResetBuffer(BuildBuffer);
|
ResetBuffer(BuildBuffer);
|
||||||
Exec(view->id, true, cmd, WorkDir);
|
Exec(view->id, true, cmd, WorkDir);
|
||||||
@@ -608,7 +608,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
|
|||||||
ResolvedOpen o = ResolveOpen(scratch, path, meta);
|
ResolvedOpen o = ResolveOpen(scratch, path, meta);
|
||||||
if (o.kind == OpenKind_Goto) {
|
if (o.kind == OpenKind_Goto) {
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
ActiveWindowID = set.window->id;
|
NextActiveWindowID = set.window->id;
|
||||||
}
|
}
|
||||||
if (IsDir(o.path)) {
|
if (IsDir(o.path)) {
|
||||||
View *view = WindowOpenBufferView(set.window, o.path);
|
View *view = WindowOpenBufferView(set.window, o.path);
|
||||||
@@ -630,7 +630,7 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
|
|||||||
UpdateScroll(set.window, true);
|
UpdateScroll(set.window, true);
|
||||||
} else if (o.kind == OpenKind_Exec) {
|
} else if (o.kind == OpenKind_Exec) {
|
||||||
if (set_active) {
|
if (set_active) {
|
||||||
ActiveWindowID = set.window->id;
|
NextActiveWindowID = set.window->id;
|
||||||
}
|
}
|
||||||
JumpGarbageBuffer(&set);
|
JumpGarbageBuffer(&set);
|
||||||
Exec(set.view->id, true, o.path, GetMainDir());
|
Exec(set.view->id, true, o.path, GetMainDir());
|
||||||
@@ -674,7 +674,7 @@ void Command_SaveAll() {
|
|||||||
void Command_Reopen() {
|
void Command_Reopen() {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
ReopenBuffer(main.buffer);
|
ReopenBuffer(main.buffer);
|
||||||
ActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
} RegisterCommand(Command_Reopen, "");
|
} RegisterCommand(Command_Reopen, "");
|
||||||
|
|
||||||
void Command_New() {
|
void Command_New() {
|
||||||
@@ -998,7 +998,7 @@ void Command_SelectLeft() {
|
|||||||
} RegisterCommand(Command_SelectLeft, "shift-left");
|
} RegisterCommand(Command_SelectLeft, "shift-left");
|
||||||
|
|
||||||
void Command_FocusLeftWindow() {
|
void Command_FocusLeftWindow() {
|
||||||
ActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
NextActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||||
} RegisterCommand(Command_FocusLeftWindow, "alt-left");
|
} RegisterCommand(Command_FocusLeftWindow, "alt-left");
|
||||||
|
|
||||||
void Command_MoveLeft() {
|
void Command_MoveLeft() {
|
||||||
@@ -1022,7 +1022,7 @@ void Command_SelectRight() {
|
|||||||
} RegisterCommand(Command_SelectRight, "shift-right");
|
} RegisterCommand(Command_SelectRight, "shift-right");
|
||||||
|
|
||||||
void Command_FocusRightWindow() {
|
void Command_FocusRightWindow() {
|
||||||
ActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
NextActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||||
} RegisterCommand(Command_FocusRightWindow, "alt-right");
|
} RegisterCommand(Command_FocusRightWindow, "alt-right");
|
||||||
|
|
||||||
void Command_MoveRight() {
|
void Command_MoveRight() {
|
||||||
@@ -1130,13 +1130,13 @@ void Command_CreateCaretOnNextFind() {
|
|||||||
} RegisterCommand(Command_CreateCaretOnNextFind, "ctrl-d");
|
} RegisterCommand(Command_CreateCaretOnNextFind, "ctrl-d");
|
||||||
|
|
||||||
void Command_FocusWindow1() {
|
void Command_FocusWindow1() {
|
||||||
ActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
NextActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||||
} RegisterCommand(Command_FocusWindow1, "ctrl-1");
|
} RegisterCommand(Command_FocusWindow1, "ctrl-1");
|
||||||
|
|
||||||
void Command_FocusWindow2() {
|
void Command_FocusWindow2() {
|
||||||
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
||||||
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
||||||
ActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
NextActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
||||||
} RegisterCommand(Command_FocusWindow2, "ctrl-2");
|
} RegisterCommand(Command_FocusWindow2, "ctrl-2");
|
||||||
|
|
||||||
void Command_FocusWindow3() {
|
void Command_FocusWindow3() {
|
||||||
@@ -1146,7 +1146,7 @@ void Command_FocusWindow3() {
|
|||||||
if (second) {
|
if (second) {
|
||||||
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
||||||
if (third) {
|
if (third) {
|
||||||
ActiveWindowID = third->id;
|
NextActiveWindowID = third->id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1165,15 +1165,12 @@ void Command_ClearCarets() {
|
|||||||
if (active.window->layout) {
|
if (active.window->layout) {
|
||||||
//
|
//
|
||||||
} else {
|
} else {
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
NextActiveWindowID = LastActiveLayoutWindowID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
For (Windows) {
|
For (Windows) {
|
||||||
if (it->lose_visibility_on_escape && it->visible) {
|
if (it->lose_visibility_on_escape && it->visible) {
|
||||||
if (ActiveWindowID == it->id) {
|
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
|
||||||
}
|
|
||||||
it->visible = false;
|
it->visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ WindowID SearchWindowID;
|
|||||||
ViewID SearchViewID;
|
ViewID SearchViewID;
|
||||||
BufferID SearchBufferID;
|
BufferID SearchBufferID;
|
||||||
|
|
||||||
|
WindowID NextActiveWindowID;
|
||||||
WindowID ActiveWindowID;
|
WindowID ActiveWindowID;
|
||||||
WindowID LastActiveLayoutWindowID;
|
WindowID LastActiveLayoutWindowID;
|
||||||
WindowID ScrollbarSelected = {-1};
|
WindowID ScrollbarSelected = {-1};
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ void OnCommand(Event event) {
|
|||||||
}
|
}
|
||||||
bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
|
bool mouse_in_document = AreOverlapping(mouse, it->document_rect);
|
||||||
if (mouse_in_document) {
|
if (mouse_in_document) {
|
||||||
ActiveWindowID = it->id;
|
NextActiveWindowID = ActiveWindowID = it->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -525,6 +525,12 @@ void Update(Event event) {
|
|||||||
UpdateProcesses();
|
UpdateProcesses();
|
||||||
CoUpdate(&event);
|
CoUpdate(&event);
|
||||||
|
|
||||||
|
For(IterateInReverse(&order)) {
|
||||||
|
if (!it->visible) continue;
|
||||||
|
View *view = GetView(it->active_view);
|
||||||
|
UpdateScroll(it, !AreEqual(view->main_caret_on_begin_frame, view->carets[0]) && view->update_scroll);
|
||||||
|
}
|
||||||
|
|
||||||
// We update it here despite the name to make it sure that all the possible changes are
|
// We update it here despite the name to make it sure that all the possible changes are
|
||||||
// included albeit with delayed response. If we did this at the beginning of the frame
|
// included albeit with delayed response. If we did this at the beginning of the frame
|
||||||
// and the DebugWindowUpdated we wouldnt get to know that in the OnCommand.
|
// and the DebugWindowUpdated we wouldnt get to know that in the OnCommand.
|
||||||
@@ -533,7 +539,7 @@ void Update(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
ProfileScope(WindowEndOfFrameVisibilityAndLastActive);
|
ProfileScope(UpdateWindows);
|
||||||
For (Windows) {
|
For (Windows) {
|
||||||
if (it->jump_history) {
|
if (it->jump_history) {
|
||||||
View *view = GetView(it->active_view);
|
View *view = GetView(it->active_view);
|
||||||
@@ -556,7 +562,7 @@ void Update(Event event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (it->sync_visibility_with_focus) {
|
if (it->sync_visibility_with_focus) {
|
||||||
if (it->id == ActiveWindowID) {
|
if (it->id == NextActiveWindowID) {
|
||||||
it->visible = true;
|
it->visible = true;
|
||||||
} else {
|
} else {
|
||||||
it->visible = false;
|
it->visible = false;
|
||||||
@@ -564,22 +570,20 @@ void Update(Event event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Window *window = GetWindow(ActiveWindowID);
|
ActiveWindowID = NextActiveWindowID;
|
||||||
if (ActiveWindowID.id != LastActiveLayoutWindowID.id) {
|
Window *window = GetWindow(ActiveWindowID, NULL);
|
||||||
|
if (window == NULL || window->visible == false) {
|
||||||
|
ActiveWindowID = NextActiveWindowID = LastActiveLayoutWindowID;
|
||||||
|
window = GetWindow(ActiveWindowID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ActiveWindowID != LastActiveLayoutWindowID) {
|
||||||
if (window->layout) {
|
if (window->layout) {
|
||||||
LastActiveLayoutWindowID = ActiveWindowID;
|
LastActiveLayoutWindowID = ActiveWindowID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
For(IterateInReverse(&order)) {
|
|
||||||
if (!it->visible) continue;
|
|
||||||
|
|
||||||
View *view = GetView(it->active_view);
|
|
||||||
UpdateScroll(it, !AreEqual(view->main_caret_on_begin_frame, view->carets[0]) && view->update_scroll);
|
|
||||||
}
|
|
||||||
|
|
||||||
GarbageCollect();
|
GarbageCollect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ void CommandWindowUpdate() {
|
|||||||
|
|
||||||
void Command_ShowCommands() {
|
void Command_ShowCommands() {
|
||||||
if (ActiveWindowID == CommandWindowID && LastExecutedCommand == Command_ShowCommands) {
|
if (ActiveWindowID == CommandWindowID && LastExecutedCommand == Command_ShowCommands) {
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
NextActiveWindowID = LastActiveLayoutWindowID;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
@@ -119,7 +119,7 @@ void Command_ShowCommands() {
|
|||||||
BSet command_bar = GetBSet(CommandWindowID);
|
BSet command_bar = GetBSet(CommandWindowID);
|
||||||
command_bar.window->visible = true;
|
command_bar.window->visible = true;
|
||||||
command_bar.window->eval_command = true;
|
command_bar.window->eval_command = true;
|
||||||
ActiveWindowID = command_bar.window->id;
|
NextActiveWindowID = command_bar.window->id;
|
||||||
ResetBuffer(command_bar.buffer);
|
ResetBuffer(command_bar.buffer);
|
||||||
For(CommandFunctions) {
|
For(CommandFunctions) {
|
||||||
RawAppendf(command_bar.buffer, "\n%S", it.name);
|
RawAppendf(command_bar.buffer, "\n%S", it.name);
|
||||||
@@ -130,7 +130,7 @@ void Command_ShowCommands() {
|
|||||||
|
|
||||||
void Command_ShowDebugBufferList() {
|
void Command_ShowDebugBufferList() {
|
||||||
if (ActiveWindowID == CommandWindowID && LastExecutedCommand == Command_ShowDebugBufferList) {
|
if (ActiveWindowID == CommandWindowID && LastExecutedCommand == Command_ShowDebugBufferList) {
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
NextActiveWindowID = LastActiveLayoutWindowID;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
@@ -138,7 +138,7 @@ void Command_ShowDebugBufferList() {
|
|||||||
BSet command_bar = GetBSet(CommandWindowID);
|
BSet command_bar = GetBSet(CommandWindowID);
|
||||||
command_bar.window->visible = true;
|
command_bar.window->visible = true;
|
||||||
command_bar.window->eval_command = false;
|
command_bar.window->eval_command = false;
|
||||||
ActiveWindowID = command_bar.window->id;
|
NextActiveWindowID = command_bar.window->id;
|
||||||
ResetBuffer(command_bar.buffer);
|
ResetBuffer(command_bar.buffer);
|
||||||
For (Buffers) {
|
For (Buffers) {
|
||||||
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
RawAppendf(command_bar.buffer, "\n%S", it->name);
|
||||||
@@ -149,7 +149,7 @@ void Command_ShowDebugBufferList() {
|
|||||||
|
|
||||||
void Command_ShowBufferList() {
|
void Command_ShowBufferList() {
|
||||||
if (ActiveWindowID == CommandWindowID && LastExecutedCommand == Command_ShowBufferList) {
|
if (ActiveWindowID == CommandWindowID && LastExecutedCommand == Command_ShowBufferList) {
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
NextActiveWindowID = LastActiveLayoutWindowID;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProfileFunction();
|
ProfileFunction();
|
||||||
@@ -157,7 +157,7 @@ void Command_ShowBufferList() {
|
|||||||
BSet command_bar = GetBSet(CommandWindowID);
|
BSet command_bar = GetBSet(CommandWindowID);
|
||||||
command_bar.window->visible = true;
|
command_bar.window->visible = true;
|
||||||
command_bar.window->eval_command = false;
|
command_bar.window->eval_command = false;
|
||||||
ActiveWindowID = command_bar.window->id;
|
NextActiveWindowID = command_bar.window->id;
|
||||||
ResetBuffer(command_bar.buffer);
|
ResetBuffer(command_bar.buffer);
|
||||||
For (Buffers) {
|
For (Buffers) {
|
||||||
if (it->special || it->garbage || it->is_dir) {
|
if (it->special || it->garbage || it->is_dir) {
|
||||||
@@ -202,7 +202,7 @@ void OpenCommand(BSet active) {
|
|||||||
}
|
}
|
||||||
if (active.window->eval_command) {
|
if (active.window->eval_command) {
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
ActiveWindowID = main.window->id;
|
NextActiveWindowID = main.window->id;
|
||||||
EvalCommand(string);
|
EvalCommand(string);
|
||||||
} else {
|
} else {
|
||||||
Open(string);
|
Open(string);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void Command_Search() {
|
|||||||
}
|
}
|
||||||
BSet set = GetBSet(SearchWindowID);
|
BSet set = GetBSet(SearchWindowID);
|
||||||
set.window->visible = true;
|
set.window->visible = true;
|
||||||
ActiveWindowID = SearchWindowID;
|
NextActiveWindowID = SearchWindowID;
|
||||||
SelectEntireBuffer(set.view);
|
SelectEntireBuffer(set.view);
|
||||||
if (string.len > 0) {
|
if (string.len > 0) {
|
||||||
Replace(set.view, string);
|
Replace(set.view, string);
|
||||||
@@ -98,7 +98,6 @@ void Command_SearchAll() {
|
|||||||
SearchAll();
|
SearchAll();
|
||||||
BSet set = GetBSet(SearchWindowID);
|
BSet set = GetBSet(SearchWindowID);
|
||||||
set.window->visible = false;
|
set.window->visible = false;
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
|
||||||
} RegisterCommand(Command_SearchAll, "alt-f3");
|
} RegisterCommand(Command_SearchAll, "alt-f3");
|
||||||
|
|
||||||
|
|
||||||
@@ -109,7 +108,6 @@ void Command_SearchAllInSearch() {
|
|||||||
SearchAll();
|
SearchAll();
|
||||||
BSet set = GetBSet(SearchWindowID);
|
BSet set = GetBSet(SearchWindowID);
|
||||||
set.window->visible = false;
|
set.window->visible = false;
|
||||||
ActiveWindowID = LastActiveLayoutWindowID;
|
|
||||||
} RegisterCommand(Command_SearchAllInSearch, "alt-enter");
|
} RegisterCommand(Command_SearchAllInSearch, "alt-enter");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user