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