RegisterCoroutineCommand,
This commit is contained in:
@@ -136,7 +136,7 @@ void CMD_OpenLoadWord() {
|
||||
|
||||
void CMD_CenterView() {
|
||||
CenterView(PrimaryWindowID);
|
||||
} RegisterCommand(CMD_CenterView, "");
|
||||
} RegisterCommand(CMD_CenterView, "", "");
|
||||
|
||||
void TrimWhitespace(Buffer *buffer, bool trim_lines_with_caret) {
|
||||
Scratch scratch;
|
||||
@@ -210,7 +210,7 @@ void CMD_FormatSelection() {
|
||||
AddEdit(&edits, it.range, string16);
|
||||
}
|
||||
EndEdit(primary.buffer, &edits, &primary.view->carets, KILL_SELECTION);
|
||||
} RegisterCommand(CMD_FormatSelection, "");
|
||||
} RegisterCommand(CMD_FormatSelection, "", "");
|
||||
|
||||
void New(Window *window, String name = "") {
|
||||
View *view = GetView(window->active_view);
|
||||
@@ -229,6 +229,11 @@ void New(Window *window, String name = "") {
|
||||
WindowOpenBufferView(window, name);
|
||||
}
|
||||
|
||||
void CMD_New() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
New(main.window, "");
|
||||
} RegisterCommand(CMD_New, "ctrl-n", "Open a new buffer with automatically generated name, use :Rename");
|
||||
|
||||
void CMD_SaveAll() {
|
||||
For(Buffers) {
|
||||
// NOTE: file_mod_time is only set when buffer got read or written to disk already so should be saved
|
||||
@@ -236,7 +241,7 @@ void CMD_SaveAll() {
|
||||
SaveBuffer(it);
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_SaveAll, "ctrl-shift-s");
|
||||
} RegisterCommand(CMD_SaveAll, "ctrl-shift-s", "");
|
||||
|
||||
void CMD_Save() {
|
||||
BSet active = GetBSet(PrimaryWindowID);
|
||||
@@ -247,36 +252,14 @@ void CMD_Reopen() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
ReopenBuffer(main.buffer);
|
||||
NextActiveWindowID = main.window->id;
|
||||
} RegisterCommand(CMD_Reopen, "");
|
||||
|
||||
void CMD_New() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
New(main.window, "");
|
||||
} RegisterCommand(CMD_New, "ctrl-n", "Open a new buffer with automatically generated name, use :Rename");
|
||||
|
||||
void CMD_ToggleFullscreen() {
|
||||
if (IsInFullscreen) {
|
||||
SDL_SetWindowSize(SDLWindow, FullScreenSizeX, FullScreenSizeY);
|
||||
SDL_SetWindowPosition(SDLWindow, FullScreenPositionX, FullScreenPositionY);
|
||||
} else {
|
||||
SDL_GetWindowSize(SDLWindow, &FullScreenSizeX, &FullScreenSizeY);
|
||||
SDL_GetWindowPosition(SDLWindow, &FullScreenPositionX, &FullScreenPositionY);
|
||||
|
||||
SDL_DisplayID display = SDL_GetDisplayForWindow(SDLWindow);
|
||||
const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(display);
|
||||
SDL_SetWindowSize(SDLWindow, dm->w, dm->h);
|
||||
SDL_SetWindowPosition(SDLWindow, 0, 0);
|
||||
}
|
||||
|
||||
IsInFullscreen = !IsInFullscreen;
|
||||
} RegisterCommand(CMD_ToggleFullscreen, "f11");
|
||||
} RegisterCommand(CMD_Reopen, "", "Reads again from disk the current buffer");
|
||||
|
||||
void CMD_KillProcess() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
KillProcess(main.view);
|
||||
} RegisterCommand(CMD_KillProcess, "", "Kill process in the last active primary window");
|
||||
|
||||
void ShowRenameUI(mco_coro *co) {
|
||||
void CO_Rename(mco_coro *co) {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
Buffer *original_buffer = main.buffer;
|
||||
JumpTempBuffer(&main);
|
||||
@@ -301,15 +284,9 @@ void ShowRenameUI(mco_coro *co) {
|
||||
String16 string16 = GetString(main.buffer, {a.range.max + 1, b.range.max});
|
||||
String string = ToString(CoCurr->arena, string16);
|
||||
original_buffer->name = Intern(&GlobalInternTable, string);
|
||||
}
|
||||
} RegisterCoroutineCommand(CO_Rename, "", "Opens a UI asking for a new name of a buffer open in the last active primary window");
|
||||
|
||||
void CMD_Rename() {
|
||||
CoRemove("ShowRenameUI");
|
||||
CoData *data = CoAdd(ShowRenameUI);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_Rename, "", "Opens a UI asking for a new name of a buffer open in the last active primary window");
|
||||
|
||||
void ShowCloseViewUI(mco_coro *co) {
|
||||
void CO_Close(mco_coro *co) {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
if (main.buffer->special || main.buffer->temp) {
|
||||
Close(main.view->id);
|
||||
@@ -347,13 +324,7 @@ void ShowCloseViewUI(mco_coro *co) {
|
||||
} else if (ui_action == UIAction_Cancel) {
|
||||
return;
|
||||
} ElseInvalidCodepath();
|
||||
}
|
||||
|
||||
void CMD_Close() {
|
||||
CoRemove("ShowCloseViewUI");
|
||||
CoData *data = CoAdd(ShowCloseViewUI);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_Close, "ctrl-w", "Close open view in the last active primary window");
|
||||
} RegisterCoroutineCommand(CO_Close, "ctrl-w", "Close open view in the last active primary window");
|
||||
|
||||
void CMD_DeleteFile() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
@@ -396,29 +367,11 @@ UIAction ShowCloseAllUI(mco_coro *co) {
|
||||
return UIAction_Yes;
|
||||
}
|
||||
|
||||
void Coro_CloseAll(mco_coro *co) {
|
||||
void CO_CloseAll(mco_coro *co) {
|
||||
ShowCloseAllUI(co);
|
||||
}
|
||||
} RegisterCoroutineCommand(CO_CloseAll, "", "Ask user which files to save and close all open normal views and buffers");
|
||||
|
||||
void CMD_CloseAll() {
|
||||
CoRemove("Coro_CloseAll");
|
||||
CoData *data = CoAdd(Coro_CloseAll);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_CloseAll, "", "Ask user which files to save and close all open normal views and buffers");
|
||||
|
||||
void CMD_MakeFontLarger() {
|
||||
FontSize += 1;
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
} RegisterCommand(CMD_MakeFontLarger, "ctrl-equals", "Increase the font size");
|
||||
|
||||
void CMD_MakeFontSmaller() {
|
||||
if (FontSize > 4) {
|
||||
FontSize -= 1;
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
}
|
||||
} RegisterCommand(CMD_MakeFontSmaller, "ctrl-minus", "Decrease the font size");
|
||||
|
||||
void ShowReplaceAllUI(mco_coro *co) {
|
||||
void CO_ReplaceAll(mco_coro *co) {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
String16 string = FetchLoadWord(main.view);
|
||||
String string8 = ToString(CoCurr->arena, string);
|
||||
@@ -478,10 +431,31 @@ void ShowReplaceAllUI(mco_coro *co) {
|
||||
Replace(view, replace);
|
||||
}
|
||||
}
|
||||
}
|
||||
} RegisterCoroutineCommand(CO_ReplaceAll, "ctrl-shift-r", "Search and replace over the entire project, you need to select a text with format like this 'FindAnd@>ReplaceWith' and executing the command will change all occurences of FindAnd to ReplaceWith");
|
||||
|
||||
void CMD_ReplaceAll() {
|
||||
CoRemove("ShowReplaceAllUI");
|
||||
CoData *data = CoAdd(ShowReplaceAllUI);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_ReplaceAll, "ctrl-shift-r", "Search and replace over the entire project, you need to select a text with format like this 'FindAnd@>ReplaceWith' and executing the command will change all occurences of FindAnd to ReplaceWith");
|
||||
void CMD_MakeFontLarger() {
|
||||
FontSize += 1;
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
} RegisterCommand(CMD_MakeFontLarger, "ctrl-equals", "Increase the font size");
|
||||
|
||||
void CMD_MakeFontSmaller() {
|
||||
if (FontSize > 4) {
|
||||
FontSize -= 1;
|
||||
ReloadFont(PathToFont, (U32)FontSize);
|
||||
}
|
||||
} RegisterCommand(CMD_MakeFontSmaller, "ctrl-minus", "Decrease the font size");
|
||||
|
||||
void CMD_ToggleFullscreen() {
|
||||
if (IsInFullscreen) {
|
||||
SDL_SetWindowSize(SDLWindow, FullScreenSizeX, FullScreenSizeY);
|
||||
SDL_SetWindowPosition(SDLWindow, FullScreenPositionX, FullScreenPositionY);
|
||||
} else {
|
||||
SDL_GetWindowSize(SDLWindow, &FullScreenSizeX, &FullScreenSizeY);
|
||||
SDL_GetWindowPosition(SDLWindow, &FullScreenPositionX, &FullScreenPositionY);
|
||||
SDL_DisplayID display = SDL_GetDisplayForWindow(SDLWindow);
|
||||
const SDL_DisplayMode *dm = SDL_GetCurrentDisplayMode(display);
|
||||
SDL_SetWindowSize(SDLWindow, dm->w, dm->h);
|
||||
SDL_SetWindowPosition(SDLWindow, 0, 0);
|
||||
}
|
||||
IsInFullscreen = !IsInFullscreen;
|
||||
} RegisterCommand(CMD_ToggleFullscreen, "f11", "switches between the fullscreen and non-fulscreen mode");
|
||||
|
||||
@@ -90,16 +90,16 @@ void ClipboardPaste(View *view) {
|
||||
void CMD_Paste() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
ClipboardPaste(active.view);
|
||||
} RegisterCommand(CMD_Paste, "ctrl-v");
|
||||
} RegisterCommand(CMD_Paste, "ctrl-v", "Paste the content of system clipboard at caret");
|
||||
|
||||
void CMD_Copy() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
ClipboardCopy(active.view);
|
||||
} RegisterCommand(CMD_Copy, "ctrl-c");
|
||||
} RegisterCommand(CMD_Copy, "ctrl-c", "Copy currently selected content to system clipboard");
|
||||
|
||||
void CMD_Cut() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
||||
ClipboardCopy(active.view);
|
||||
Replace(active.view, u"");
|
||||
} RegisterCommand(CMD_Cut, "ctrl-x");
|
||||
} RegisterCommand(CMD_Cut, "ctrl-x", "Copy and delete currently selected content to system clipboard");
|
||||
|
||||
@@ -22,197 +22,197 @@ void CMD_SelectAll() {
|
||||
void CMD_KillSelectedLines() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
KillSelectedLines(active.view);
|
||||
} RegisterCommand(CMD_KillSelectedLines, "ctrl-shift-k");
|
||||
} RegisterCommand(CMD_KillSelectedLines, "ctrl-shift-k", "Delete the selected lines, don't put to clipboard");
|
||||
|
||||
void CMD_IndentSelectedLines() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
IndentSelectedLines(active.view);
|
||||
} RegisterCommand(CMD_IndentSelectedLines, "ctrl-rightbracket | tab");
|
||||
} RegisterCommand(CMD_IndentSelectedLines, "ctrl-rightbracket | tab", "");
|
||||
|
||||
void CMD_DedentSelectedLines() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
IndentSelectedLines(active.view, true);
|
||||
} RegisterCommand(CMD_DedentSelectedLines, "ctrl-leftbracket | shift-tab");
|
||||
} RegisterCommand(CMD_DedentSelectedLines, "ctrl-leftbracket | shift-tab", "");
|
||||
|
||||
void CMD_DuplicateLineDown() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
DuplicateLine(active.view, DIR_DOWN);
|
||||
} RegisterCommand(CMD_DuplicateLineDown, "ctrl-alt-down");
|
||||
} RegisterCommand(CMD_DuplicateLineDown, "ctrl-alt-down", "");
|
||||
|
||||
void CMD_CreateCursorDown() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
CreateCursorVertical(active.view, DIR_DOWN);
|
||||
} RegisterCommand(CMD_CreateCursorDown, "alt-shift-down");
|
||||
} RegisterCommand(CMD_CreateCursorDown, "alt-shift-down", "");
|
||||
|
||||
void CMD_SelectDownToEmptyLine() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_DOWN, CTRL_PRESSED, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectDownToEmptyLine, "ctrl-shift-down");
|
||||
} RegisterCommand(CMD_SelectDownToEmptyLine, "ctrl-shift-down", "");
|
||||
|
||||
void CMD_MoveLineDown() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCaretsLine(active.view, DIR_DOWN);
|
||||
} RegisterCommand(CMD_MoveLineDown, "alt-down");
|
||||
} RegisterCommand(CMD_MoveLineDown, "alt-down", "");
|
||||
|
||||
void CMD_MoveDownToEmptyLine() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_DOWN, CTRL_PRESSED);
|
||||
} RegisterCommand(CMD_MoveDownToEmptyLine, "ctrl-down");
|
||||
} RegisterCommand(CMD_MoveDownToEmptyLine, "ctrl-down", "");
|
||||
|
||||
void CMD_SelectDown() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_DOWN, false, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectDown, "shift-down");
|
||||
} RegisterCommand(CMD_SelectDown, "shift-down", "");
|
||||
|
||||
void CMD_MoveDown() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_DOWN);
|
||||
} RegisterCommand(CMD_MoveDown, "down");
|
||||
} RegisterCommand(CMD_MoveDown, "down", "");
|
||||
|
||||
void CMD_DuplicateLineUp() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
DuplicateLine(active.view, DIR_UP);
|
||||
} RegisterCommand(CMD_DuplicateLineUp, "ctrl-alt-up");
|
||||
} RegisterCommand(CMD_DuplicateLineUp, "ctrl-alt-up", "");
|
||||
|
||||
void CMD_CreateCursorUp() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
CreateCursorVertical(active.view, DIR_UP);
|
||||
} RegisterCommand(CMD_CreateCursorUp, "alt-shift-up");
|
||||
} RegisterCommand(CMD_CreateCursorUp, "alt-shift-up", "");
|
||||
|
||||
void CMD_SelectUpToEmptyLine() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_UP, CTRL_PRESSED, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectUpToEmptyLine, "ctrl-shift-up");
|
||||
} RegisterCommand(CMD_SelectUpToEmptyLine, "ctrl-shift-up", "");
|
||||
|
||||
void CMD_MoveLineUp() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCaretsLine(active.view, DIR_UP);
|
||||
} RegisterCommand(CMD_MoveLineUp, "alt-up");
|
||||
} RegisterCommand(CMD_MoveLineUp, "alt-up", "");
|
||||
|
||||
void CMD_MoveUpToEmptyLine() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_UP, CTRL_PRESSED);
|
||||
} RegisterCommand(CMD_MoveUpToEmptyLine, "ctrl-up");
|
||||
} RegisterCommand(CMD_MoveUpToEmptyLine, "ctrl-up", "");
|
||||
|
||||
void CMD_SelectUp() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_UP, false, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectUp, "shift-up");
|
||||
} RegisterCommand(CMD_SelectUp, "shift-up", "");
|
||||
|
||||
void CMD_MoveUp() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_UP);
|
||||
} RegisterCommand(CMD_MoveUp, "up");
|
||||
} RegisterCommand(CMD_MoveUp, "up", "");
|
||||
|
||||
void CMD_BoundarySelectLeft() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_LEFT, CTRL_PRESSED, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_BoundarySelectLeft, "ctrl-shift-left");
|
||||
} RegisterCommand(CMD_BoundarySelectLeft, "ctrl-shift-left", "");
|
||||
|
||||
void CMD_BoundaryMoveLeft() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_LEFT, CTRL_PRESSED);
|
||||
} RegisterCommand(CMD_BoundaryMoveLeft, "ctrl-left");
|
||||
} RegisterCommand(CMD_BoundaryMoveLeft, "ctrl-left", "");
|
||||
|
||||
void CMD_SelectLeft() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_LEFT, false, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectLeft, "shift-left");
|
||||
} RegisterCommand(CMD_SelectLeft, "shift-left", "");
|
||||
|
||||
void CMD_MoveLeft() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_LEFT);
|
||||
} RegisterCommand(CMD_MoveLeft, "left");
|
||||
} RegisterCommand(CMD_MoveLeft, "left", "");
|
||||
|
||||
void CMD_BoundarySelectRight() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_RIGHT, CTRL_PRESSED, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_BoundarySelectRight, "ctrl-shift-right");
|
||||
} RegisterCommand(CMD_BoundarySelectRight, "ctrl-shift-right", "");
|
||||
|
||||
void CMD_BoundaryMoveRight() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_RIGHT, CTRL_PRESSED);
|
||||
} RegisterCommand(CMD_BoundaryMoveRight, "ctrl-right");
|
||||
} RegisterCommand(CMD_BoundaryMoveRight, "ctrl-right", "");
|
||||
|
||||
void CMD_SelectRight() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_RIGHT, false, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectRight, "shift-right");
|
||||
} RegisterCommand(CMD_SelectRight, "shift-right", "");
|
||||
|
||||
void CMD_MoveRight() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCarets(active.view, DIR_RIGHT);
|
||||
} RegisterCommand(CMD_MoveRight, "right");
|
||||
} RegisterCommand(CMD_MoveRight, "right", "");
|
||||
|
||||
void CMD_MoveUpAPage() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorByPageSize(active.window, DIR_UP);
|
||||
} RegisterCommand(CMD_MoveUpAPage, "pageup");
|
||||
} RegisterCommand(CMD_MoveUpAPage, "pageup", "");
|
||||
|
||||
void CMD_SelectUpPage() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorByPageSize(active.window, DIR_UP, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectUpPage, "shift-pageup");
|
||||
} RegisterCommand(CMD_SelectUpPage, "shift-pageup", "");
|
||||
|
||||
void CMD_MoveToStart() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
SelectRange(active.view, MakeRange(0));
|
||||
} RegisterCommand(CMD_MoveToStart, "ctrl-pageup");
|
||||
} RegisterCommand(CMD_MoveToStart, "ctrl-pageup", "");
|
||||
|
||||
void CMD_SelectDownPage() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorByPageSize(active.window, DIR_DOWN, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectDownPage, "shift-pagedown");
|
||||
} RegisterCommand(CMD_SelectDownPage, "shift-pagedown", "");
|
||||
|
||||
void CMD_MoveToEnd() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
SelectRange(active.view, MakeRange(active.buffer->len));
|
||||
} RegisterCommand(CMD_MoveToEnd, "ctrl-pagedown");
|
||||
} RegisterCommand(CMD_MoveToEnd, "ctrl-pagedown", "");
|
||||
|
||||
void CMD_MoveDownPage() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorByPageSize(active.window, DIR_DOWN);
|
||||
} RegisterCommand(CMD_MoveDownPage, "pagedown");
|
||||
} RegisterCommand(CMD_MoveDownPage, "pagedown", "");
|
||||
|
||||
void CMD_SelectToLineStart() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorToSide(active.view, DIR_LEFT, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectToLineStart, "shift-home");
|
||||
} RegisterCommand(CMD_SelectToLineStart, "shift-home", "");
|
||||
|
||||
void CMD_MoveToLineStart() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorToSide(active.view, DIR_LEFT);
|
||||
} RegisterCommand(CMD_MoveToLineStart, "home");
|
||||
} RegisterCommand(CMD_MoveToLineStart, "home", "");
|
||||
|
||||
void CMD_MoveToLineEnd() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorToSide(active.view, DIR_RIGHT);
|
||||
} RegisterCommand(CMD_MoveToLineEnd, "end");
|
||||
} RegisterCommand(CMD_MoveToLineEnd, "end", "");
|
||||
|
||||
void CMD_SelectToLineEnd() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
MoveCursorToSide(active.view, DIR_RIGHT, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_SelectToLineEnd, "shift-end");
|
||||
} RegisterCommand(CMD_SelectToLineEnd, "shift-end", "");
|
||||
|
||||
void CMD_DeleteCharacter() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
Delete(active.view, DIR_LEFT);
|
||||
} RegisterCommand(CMD_DeleteCharacter, "shift-backspace | backspace");
|
||||
} RegisterCommand(CMD_DeleteCharacter, "shift-backspace | backspace", "");
|
||||
|
||||
void CMD_DeleteBoundary() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
Delete(active.view, DIR_LEFT, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_DeleteBoundary, "ctrl-backspace");
|
||||
} RegisterCommand(CMD_DeleteBoundary, "ctrl-backspace", "");
|
||||
|
||||
void CMD_DeleteForward() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
Delete(active.view, DIR_RIGHT);
|
||||
} RegisterCommand(CMD_DeleteForward, "shift-delete | delete");
|
||||
} RegisterCommand(CMD_DeleteForward, "shift-delete | delete", "");
|
||||
|
||||
void CMD_DeleteForwardBoundary() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
Delete(active.view, DIR_RIGHT, SHIFT_PRESS);
|
||||
} RegisterCommand(CMD_DeleteForwardBoundary, "ctrl-delete");
|
||||
} RegisterCommand(CMD_DeleteForwardBoundary, "ctrl-delete", "");
|
||||
|
||||
void CMD_InsertNewLineUp() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
@@ -220,19 +220,19 @@ void CMD_InsertNewLineUp() {
|
||||
MoveCursorToSide(active.view, DIR_LEFT);
|
||||
IndentedNewLine(active.view);
|
||||
MoveCarets(active.view, DIR_UP);
|
||||
} RegisterCommand(CMD_InsertNewLineUp, "ctrl-shift-enter");
|
||||
} RegisterCommand(CMD_InsertNewLineUp, "ctrl-shift-enter", "");
|
||||
|
||||
void CMD_InsertNewLineDown() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
||||
MoveCursorToSide(active.view, DIR_RIGHT);
|
||||
IndentedNewLine(active.view);
|
||||
} RegisterCommand(CMD_InsertNewLineDown, "ctrl-enter");
|
||||
} RegisterCommand(CMD_InsertNewLineDown, "ctrl-enter", "");
|
||||
|
||||
void CMD_NewLine() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
IndentedNewLine(active.view);
|
||||
} RegisterCommand(CMD_NewLine, "enter | shift-enter");
|
||||
} RegisterCommand(CMD_NewLine, "enter | shift-enter", "");
|
||||
|
||||
void CMD_CreateCaretOnNextFind() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
@@ -240,24 +240,10 @@ void CMD_CreateCaretOnNextFind() {
|
||||
Caret caret = FindNext(active.buffer, string, active.view->carets[0]);
|
||||
Insert(&active.view->carets, caret, 0);
|
||||
MergeCarets(active.buffer, &active.view->carets);
|
||||
} RegisterCommand(CMD_CreateCaretOnNextFind, "ctrl-d");
|
||||
} RegisterCommand(CMD_CreateCaretOnNextFind, "ctrl-d", "");
|
||||
|
||||
void CMD_ClearCarets() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
active.view->carets.len = 1;
|
||||
active.view->carets[0] = MakeCaret(GetFront(active.view->carets[0]));
|
||||
|
||||
if (active.window->lose_focus_on_escape && active.window->id == ActiveWindowID) {
|
||||
if (active.window->primary) {
|
||||
//
|
||||
} else {
|
||||
NextActiveWindowID = PrimaryWindowID;
|
||||
}
|
||||
}
|
||||
|
||||
For (Windows) {
|
||||
if (it->lose_visibility_on_escape && it->visible) {
|
||||
it->visible = false;
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_ClearCarets, "escape", "Clear all carets and reset to 1 caret, also do some windowing stuff that closes things on escape");
|
||||
|
||||
@@ -77,4 +77,4 @@ void CMD_ShowBuildWindow() {
|
||||
} else {
|
||||
main.window->visible = false;
|
||||
}
|
||||
} RegisterCommand(CMD_ShowBuildWindow, "ctrl-grave");
|
||||
} RegisterCommand(CMD_ShowBuildWindow, "ctrl-grave", "Toggles visibility of the build window");
|
||||
|
||||
@@ -27,6 +27,8 @@ void Windows_SetupVCVarsall(mco_coro *co) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LoadVCVars() {
|
||||
CoRemove("Windows_SetupVCVarsall");
|
||||
CoData *co_data = CoAdd(Windows_SetupVCVarsall);
|
||||
|
||||
@@ -14,12 +14,11 @@ void CMD_SetProjectDirectoryHere() {
|
||||
SetProjectDirectory(GetBufferDirectory(main.buffer));
|
||||
} RegisterCommand(CMD_SetProjectDirectoryHere, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new ProjectDirectory");
|
||||
|
||||
void Coro_OpenCode(mco_coro *co) {
|
||||
void CO_OpenCode(mco_coro *co) {
|
||||
Array<String> patterns = SplitWhitespace(CoCurr->arena, OpenCodePatterns);
|
||||
Array<String> exclude_patterns = SplitWhitespace(CoCurr->arena, OpenCodeExcludePatterns);
|
||||
Array<String> dirs = {CoCurr->arena};
|
||||
String *param_dir = (String *)CoCurr->user_ctx;
|
||||
Add(&dirs, *param_dir);
|
||||
Add(&dirs, Copy(CoCurr->arena, ProjectDirectory));
|
||||
for (int diri = 0; diri < dirs.len; diri += 1) {
|
||||
for (FileIter it = IterateFiles(CoCurr->arena, dirs[diri]); IsValid(it); Advance(&it)) {
|
||||
bool should_open = true;
|
||||
@@ -54,18 +53,9 @@ void Coro_OpenCode(mco_coro *co) {
|
||||
CoYield(co);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenCode(String dir) {
|
||||
CoRemove("Coro_OpenCode");
|
||||
CoData *data = CoAdd(Coro_OpenCode);
|
||||
String *string_param = AllocType(data->arena, String);
|
||||
*string_param = Copy(data->arena, dir);
|
||||
data->user_ctx = string_param;
|
||||
} RegisterCoroutineCommand(
|
||||
CO_OpenCode,
|
||||
"",
|
||||
"Open all code files in current ProjectDirectory, the code files are determined through NonCodePatterns_EndsWith config variable list",
|
||||
data->dont_wait_until_resolved = true;
|
||||
CoResume(data);
|
||||
}
|
||||
|
||||
void CMD_OpenCode() {
|
||||
OpenCode(ProjectDirectory);
|
||||
} RegisterCommand(CMD_OpenCode, "", "Open all code files in current ProjectDirectory, the code files are determined through NonCodePatterns_EndsWith config variable list");
|
||||
);
|
||||
|
||||
@@ -20,21 +20,21 @@ void CMD_Next() {
|
||||
|
||||
void CMD_FocusLeftWindow() {
|
||||
NextActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
||||
} RegisterCommand(CMD_FocusLeftWindow, "alt-left");
|
||||
} RegisterCommand(CMD_FocusLeftWindow, "alt-left", "Switch the window focus to the window on the left position of current one");
|
||||
|
||||
void CMD_FocusRightWindow() {
|
||||
NextActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
||||
} RegisterCommand(CMD_FocusRightWindow, "alt-right");
|
||||
} RegisterCommand(CMD_FocusRightWindow, "alt-right", "Switch the window focus to the window on the right position of current one");
|
||||
|
||||
void CMD_FocusWindow1() {
|
||||
NextActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
||||
} RegisterCommand(CMD_FocusWindow1, "ctrl-1");
|
||||
} RegisterCommand(CMD_FocusWindow1, "ctrl-1", "Select the left-most window");
|
||||
|
||||
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");
|
||||
} RegisterCommand(CMD_FocusWindow2, "ctrl-2", "Select the window to the right of left-most window");
|
||||
|
||||
void CMD_FocusWindow3() {
|
||||
Window *first = GetOverlappingWindow({0,0});
|
||||
@@ -47,11 +47,11 @@ void CMD_FocusWindow3() {
|
||||
}
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_FocusWindow3, "ctrl-3");
|
||||
} RegisterCommand(CMD_FocusWindow3, "ctrl-3", "Select the 3rd window, counting from left");
|
||||
|
||||
void CMD_NewWindow() {
|
||||
CreateWind();
|
||||
} RegisterCommand(CMD_NewWindow, "ctrl-backslash");
|
||||
} RegisterCommand(CMD_NewWindow, "ctrl-backslash", "Creates a new window");
|
||||
|
||||
void CMD_CloseWindow() {
|
||||
Close(PrimaryWindowID);
|
||||
|
||||
@@ -436,6 +436,22 @@ void OnCommand(Event event) {
|
||||
CMD_Quit();
|
||||
}
|
||||
|
||||
if (event.kind == EVENT_KEY_PRESS && event.key == SDLK_ESCAPE && event.ctrl == false && event.shift == false && event.alt == false && event.super == false) {
|
||||
if (active.window->lose_focus_on_escape && active.window->id == ActiveWindowID) {
|
||||
if (active.window->primary) {
|
||||
//
|
||||
} else {
|
||||
NextActiveWindowID = PrimaryWindowID;
|
||||
}
|
||||
}
|
||||
|
||||
For (Windows) {
|
||||
if (it->lose_visibility_on_escape && it->visible) {
|
||||
it->visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IF_DEBUG(AssertRanges(main.view->carets));
|
||||
IF_DEBUG(AssertRanges(active.view->carets));
|
||||
}
|
||||
|
||||
@@ -272,7 +272,6 @@ struct ResolvedOpen {
|
||||
};
|
||||
|
||||
void AddCommand(Array<Command> *arr, String name, struct Trigger *trigger, CMDFunction *function);
|
||||
#define RegisterCommand(name, ...) Register_Command RC__##name(&GlobalCommands, name, #name, __VA_ARGS__)
|
||||
struct Register_Command {
|
||||
Register_Command(Array<Command> *funcs, CMDFunction *function, String name, String binding, String docs = "") {
|
||||
int64_t pos = 0;
|
||||
@@ -288,6 +287,14 @@ struct Register_Command {
|
||||
Add(funcs, cmd);
|
||||
}
|
||||
};
|
||||
#define RegisterCommand(name, binding, docs) Register_Command RC__##name(&GlobalCommands, name, #name, binding, docs)
|
||||
#define RegisterCoroutineCommand(name, binding, docs, ...) void CMD_##name() {\
|
||||
CoRemove(#name);\
|
||||
CoData *data = CoAdd(name);\
|
||||
__VA_ARGS__\
|
||||
CoResume(data);\
|
||||
}\
|
||||
Register_Command RC__##name(&GlobalCommands, CMD_##name, #name, binding, docs)
|
||||
|
||||
#define RegisterFunction(functions, name) Register_Function RF__##name(functions, #name, name)
|
||||
struct Register_Function {
|
||||
|
||||
@@ -72,11 +72,21 @@ void ShowUIMessagef(const char *fmt, ...) {
|
||||
});
|
||||
}
|
||||
|
||||
String GetPrimaryDirectory() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
return GetBufferDirectory(main.buffer);
|
||||
String QueryUserFile(mco_coro *co) {
|
||||
return "todo";
|
||||
}
|
||||
|
||||
void Coro_TestQueryFile(mco_coro *co) {
|
||||
String file = QueryUserFile(co);
|
||||
ReportConsolef("%S", file);
|
||||
}
|
||||
|
||||
void CMD_TestQueryFile() {
|
||||
CoRemove("Coro_TestQueryFile");
|
||||
CoData *data = CoAdd(Coro_TestQueryFile);
|
||||
CoResume(data);
|
||||
} RegisterCommand(CMD_TestQueryFile, "", "");
|
||||
|
||||
void MouseLoadWord(Event event, ResolveOpenMeta meta = ResolveOpenMeta_Normal) {
|
||||
Vec2I mouse = MouseVec2I();
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
|
||||
@@ -391,6 +391,10 @@ BSet GetBSet(WindowID window_id) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String GetPrimaryDirectory() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
return GetBufferDirectory(main.buffer);
|
||||
}
|
||||
|
||||
void MoveCursorByPageSize(Window *window, int direction, bool shift = false) {
|
||||
Assert(direction == DIR_UP || direction == DIR_DOWN);
|
||||
|
||||
Reference in New Issue
Block a user