window_management_commands
This commit is contained in:
@@ -684,10 +684,6 @@ void CMD_KillProcess() {
|
||||
KillProcess(main.view);
|
||||
} RegisterCommand(CMD_KillProcess, "", "Kill process in the last active primary window");
|
||||
|
||||
void CMD_CloseWindow() {
|
||||
Close(PrimaryWindowID);
|
||||
} RegisterCommand(CMD_CloseWindow, "", "Close the last active primary window");
|
||||
|
||||
void AddCommand(Array<Command> *arr, String name, String binding, CMDFunction *function) {
|
||||
Command cmd = {};
|
||||
cmd.name = name;
|
||||
@@ -860,26 +856,6 @@ String Coro_CloseAllEx(mco_coro *co) {
|
||||
return "Yes";
|
||||
}
|
||||
|
||||
void CMD_QuitWithoutSaving() {
|
||||
#ifdef PLUGIN_REMEDYBG
|
||||
QuitDebugger();
|
||||
#endif
|
||||
AppIsRunning = false;
|
||||
} RegisterCommand(CMD_QuitWithoutSaving, "", "Self explanatory");
|
||||
|
||||
void Coro_Quit(mco_coro *co) {
|
||||
String res = Coro_CloseAllEx(co);
|
||||
if (res != "Cancel") {
|
||||
CMD_QuitWithoutSaving();
|
||||
}
|
||||
}
|
||||
|
||||
void CMD_Quit() {
|
||||
CoRemove("Coro_Quit");
|
||||
CoData *data = CoAdd(Coro_Quit);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_Quit, "", "Ask user which files he would like to save and exit");
|
||||
|
||||
void Coro_CloseAll(mco_coro *co) {
|
||||
Coro_CloseAllEx(co);
|
||||
}
|
||||
@@ -890,26 +866,6 @@ void CMD_CloseAll() {
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_CloseAll, "", "Ask user which files to save and close all open normal views and buffers");
|
||||
|
||||
void CMD_JumpPrev() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
JumpToLastValidView(main.window);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_JumpPrev, "ctrl-tab", "Go to the previous open view in primary window");
|
||||
|
||||
void CMD_Prev() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
main.window->skip_checkpoint = true;
|
||||
JumpBack(main.window);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_Prev, "alt-q | mousex1", "Go to previous position (either previous view that was open or caret position) in the primary window");
|
||||
|
||||
void CMD_Next() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
main.window->skip_checkpoint = true;
|
||||
JumpForward(main.window);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_Next, "alt-shift-q | mousex2", "Go to next position, after backtracking, in the primary window");
|
||||
|
||||
void CMD_MakeFontLarger() {
|
||||
FontSize += 1;
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
@@ -929,41 +885,6 @@ void CMD_OpenLoadWord() {
|
||||
Open(load_word);
|
||||
} RegisterCommand(CMD_OpenLoadWord, "ctrl-q | f12", "Open a link under the caret (file link, url, command) or open the selection");
|
||||
|
||||
void CMD_FocusLeftWindow() {
|
||||
NextActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||
} RegisterCommand(CMD_FocusLeftWindow, "alt-left");
|
||||
|
||||
void CMD_FocusRightWindow() {
|
||||
NextActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||
} RegisterCommand(CMD_FocusRightWindow, "alt-right");
|
||||
|
||||
void CMD_FocusWindow1() {
|
||||
NextActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||
} RegisterCommand(CMD_FocusWindow1, "ctrl-1");
|
||||
|
||||
void CMD_FocusWindow2() {
|
||||
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
||||
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
||||
NextActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
||||
} RegisterCommand(CMD_FocusWindow2, "ctrl-2");
|
||||
|
||||
void CMD_FocusWindow3() {
|
||||
Window *first = GetOverlappingWindow({0,0});
|
||||
if (first) {
|
||||
Window *second = GetOverlappingWindow(GetSideOfWindow(first, DIR_RIGHT));
|
||||
if (second) {
|
||||
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
||||
if (third) {
|
||||
NextActiveWindowID = third->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_FocusWindow3, "ctrl-3");
|
||||
|
||||
void CMD_NewWindow() {
|
||||
CreateWind();
|
||||
} RegisterCommand(CMD_NewWindow, "ctrl-backslash");
|
||||
|
||||
void Coro_ReplaceAll(mco_coro *co) {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
String16 string = FetchLoadWord(main.view);
|
||||
|
||||
58
src/text_editor/commands_window_management.cpp
Normal file
58
src/text_editor/commands_window_management.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
void CMD_JumpPrev() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
JumpToLastValidView(main.window);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_JumpPrev, "ctrl-tab", "Go to the previous open view in primary window");
|
||||
|
||||
void CMD_Prev() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
main.window->skip_checkpoint = true;
|
||||
JumpBack(main.window);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_Prev, "alt-q | mousex1", "Go to previous position (either previous view that was open or caret position) in the primary window");
|
||||
|
||||
void CMD_Next() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
main.window->skip_checkpoint = true;
|
||||
JumpForward(main.window);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_Next, "alt-shift-q | mousex2", "Go to next position, after backtracking, in the primary window");
|
||||
|
||||
void CMD_FocusLeftWindow() {
|
||||
NextActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||
} RegisterCommand(CMD_FocusLeftWindow, "alt-left");
|
||||
|
||||
void CMD_FocusRightWindow() {
|
||||
NextActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||
} RegisterCommand(CMD_FocusRightWindow, "alt-right");
|
||||
|
||||
void CMD_FocusWindow1() {
|
||||
NextActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||
} RegisterCommand(CMD_FocusWindow1, "ctrl-1");
|
||||
|
||||
void CMD_FocusWindow2() {
|
||||
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
||||
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
||||
NextActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
||||
} RegisterCommand(CMD_FocusWindow2, "ctrl-2");
|
||||
|
||||
void CMD_FocusWindow3() {
|
||||
Window *first = GetOverlappingWindow({0,0});
|
||||
if (first) {
|
||||
Window *second = GetOverlappingWindow(GetSideOfWindow(first, DIR_RIGHT));
|
||||
if (second) {
|
||||
Window *third = GetOverlappingWindow(GetSideOfWindow(second, DIR_RIGHT));
|
||||
if (third) {
|
||||
NextActiveWindowID = third->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_FocusWindow3, "ctrl-3");
|
||||
|
||||
void CMD_NewWindow() {
|
||||
CreateWind();
|
||||
} RegisterCommand(CMD_NewWindow, "ctrl-backslash");
|
||||
|
||||
void CMD_CloseWindow() {
|
||||
Close(PrimaryWindowID);
|
||||
} RegisterCommand(CMD_CloseWindow, "", "Close the last active primary window");
|
||||
@@ -1,4 +1,4 @@
|
||||
// @todo: On save rename files, delete files etc ...
|
||||
// @todo: On save rename files, delete files it should apply the changes
|
||||
// Instead of toying with Reopen maybe it should actually detect changes in directory etc. on update
|
||||
|
||||
void CMD_OpenUpFolder() {
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "draw.cpp"
|
||||
#include "test/tests.cpp"
|
||||
|
||||
#include "commands_window_management.cpp"
|
||||
#include "commands_clipboard.cpp"
|
||||
#include "plugin_directory_navigation.cpp"
|
||||
#include "plugin_search_open_buffers.cpp"
|
||||
@@ -185,6 +186,26 @@ void UpdateScroll(Window *window, bool update_caret_scrolling) {
|
||||
}
|
||||
}
|
||||
|
||||
void CMD_QuitWithoutSaving() {
|
||||
#ifdef PLUGIN_REMEDYBG
|
||||
QuitDebugger();
|
||||
#endif
|
||||
AppIsRunning = false;
|
||||
} RegisterCommand(CMD_QuitWithoutSaving, "", "Self explanatory");
|
||||
|
||||
void Coro_Quit(mco_coro *co) {
|
||||
String res = Coro_CloseAllEx(co);
|
||||
if (res != "Cancel") {
|
||||
CMD_QuitWithoutSaving();
|
||||
}
|
||||
}
|
||||
|
||||
void CMD_Quit() {
|
||||
CoRemove("Coro_Quit");
|
||||
CoData *data = CoAdd(Coro_Quit);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_Quit, "", "Ask user which files he would like to save and exit");
|
||||
|
||||
void OnCommand(Event event) {
|
||||
ProfileFunction();
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user