|
|
|
|
@@ -1085,12 +1085,12 @@ String16 FetchLoadWord(BSet set) {
|
|
|
|
|
return string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Command_Save(CommandContext *ctx) {
|
|
|
|
|
void Command_Save() {
|
|
|
|
|
BSet active = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
SaveBuffer(active.buffer);
|
|
|
|
|
} RegisterCommand(Command_Save, "ctrl-s");
|
|
|
|
|
|
|
|
|
|
void Command_SaveAll(CommandContext *ctx) {
|
|
|
|
|
void Command_SaveAll() {
|
|
|
|
|
For(Buffers) {
|
|
|
|
|
if (it->file_mod_time) {
|
|
|
|
|
SaveBuffer(it);
|
|
|
|
|
@@ -1098,18 +1098,18 @@ void Command_SaveAll(CommandContext *ctx) {
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_SaveAll, "ctrl-shift-s");
|
|
|
|
|
|
|
|
|
|
void Command_Reopen(CommandContext *ctx) {
|
|
|
|
|
void Command_Reopen() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
ReopenBuffer(main.buffer);
|
|
|
|
|
ActiveWindowID = main.window->id;
|
|
|
|
|
} RegisterCommand(Command_Reopen, "");
|
|
|
|
|
|
|
|
|
|
void Command_New(CommandContext *ctx) {
|
|
|
|
|
void Command_New() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
New(main.window, "");
|
|
|
|
|
} RegisterCommand(Command_New, "ctrl-n");
|
|
|
|
|
|
|
|
|
|
void Command_ToggleFullscreen(CommandContext *ctx) {
|
|
|
|
|
void Command_ToggleFullscreen() {
|
|
|
|
|
if (IsInFullscreen) {
|
|
|
|
|
SDL_SetWindowSize(SDLWindow, FullScreenSizeX, FullScreenSizeY);
|
|
|
|
|
SDL_SetWindowPosition(SDLWindow, FullScreenPositionX, FullScreenPositionY);
|
|
|
|
|
@@ -1126,7 +1126,7 @@ void Command_ToggleFullscreen(CommandContext *ctx) {
|
|
|
|
|
IsInFullscreen = !IsInFullscreen;
|
|
|
|
|
} RegisterCommand(Command_ToggleFullscreen, "f11");
|
|
|
|
|
|
|
|
|
|
void Command_ListCode(CommandContext *ctx) {
|
|
|
|
|
void Command_ListCode() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
JumpGarbageBuffer(&main);
|
|
|
|
|
ListFilesRecursive(main.buffer, WorkDir);
|
|
|
|
|
@@ -1135,7 +1135,7 @@ void Command_ListCode(CommandContext *ctx) {
|
|
|
|
|
SelectRange(main.view, GetBufferEndAsRange(main.buffer));
|
|
|
|
|
} RegisterCommand(Command_ListCode, "");
|
|
|
|
|
|
|
|
|
|
void Command_ShowBufferList(CommandContext *ctx) {
|
|
|
|
|
void Command_ShowBufferList() {
|
|
|
|
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
|
|
|
|
command_bar.window->visible = true;
|
|
|
|
|
command_bar.window->eval_command = false;
|
|
|
|
|
@@ -1148,7 +1148,7 @@ void Command_ShowBufferList(CommandContext *ctx) {
|
|
|
|
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
|
|
|
|
} RegisterCommand(Command_ShowBufferList, "ctrl-p");
|
|
|
|
|
|
|
|
|
|
void Command_ListViews(CommandContext *ctx) {
|
|
|
|
|
void Command_ListViews() {
|
|
|
|
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
|
|
|
|
command_bar.window->visible = true;
|
|
|
|
|
command_bar.window->eval_command = false;
|
|
|
|
|
@@ -1163,12 +1163,12 @@ void Command_ListViews(CommandContext *ctx) {
|
|
|
|
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
|
|
|
|
} RegisterCommand(Command_ListViews, "");
|
|
|
|
|
|
|
|
|
|
void Command_SetProjectFile(CommandContext *ctx) {
|
|
|
|
|
void Command_SetProjectFile() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
SetProjectFile(main.buffer);
|
|
|
|
|
} RegisterCommand(Command_SetProjectFile, "");
|
|
|
|
|
|
|
|
|
|
void Command_SetWorkDir(CommandContext *ctx) {
|
|
|
|
|
void Command_SetWorkDir() {
|
|
|
|
|
String dir = lua_tostring(LuaState, -1);
|
|
|
|
|
if (dir.len == 0) {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
@@ -1178,27 +1178,27 @@ void Command_SetWorkDir(CommandContext *ctx) {
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_SetWorkDir, "");
|
|
|
|
|
|
|
|
|
|
void Command_SetProject(CommandContext *ctx) {
|
|
|
|
|
Command_SetWorkDir(ctx);
|
|
|
|
|
Command_SetProjectFile(ctx);
|
|
|
|
|
void Command_SetProject() {
|
|
|
|
|
Command_SetWorkDir();
|
|
|
|
|
Command_SetProjectFile();
|
|
|
|
|
} RegisterCommand(Command_SetProject, "");
|
|
|
|
|
|
|
|
|
|
void Command_ToggleDebug(CommandContext *ctx) {
|
|
|
|
|
void Command_ToggleDebug() {
|
|
|
|
|
Window *window = GetWindow(DebugWindowID);
|
|
|
|
|
window->visible = !window->visible;
|
|
|
|
|
} RegisterCommand(Command_ToggleDebug, "ctrl-0");
|
|
|
|
|
|
|
|
|
|
void Command_KillProcess(CommandContext *ctx) {
|
|
|
|
|
void Command_KillProcess() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
KillProcess(main.view);
|
|
|
|
|
} RegisterCommand(Command_KillProcess, "");
|
|
|
|
|
|
|
|
|
|
void Command_KillWindow(CommandContext *ctx) {
|
|
|
|
|
void Command_KillWindow() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
main.window->kill = true;
|
|
|
|
|
} RegisterCommand(Command_KillWindow, "ctrl-w");
|
|
|
|
|
|
|
|
|
|
void Command_ShowCommands(CommandContext *ctx) {
|
|
|
|
|
void Command_ShowCommands() {
|
|
|
|
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
|
|
|
|
command_bar.window->visible = true;
|
|
|
|
|
command_bar.window->eval_command = true;
|
|
|
|
|
@@ -1211,7 +1211,7 @@ void Command_ShowCommands(CommandContext *ctx) {
|
|
|
|
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
|
|
|
|
} RegisterCommand(Command_ShowCommands, "ctrl-shift-p");
|
|
|
|
|
|
|
|
|
|
void Command_ShowLuaFunctions(CommandContext *ctx) {
|
|
|
|
|
void Command_ShowLuaFunctions() {
|
|
|
|
|
BSet command_bar = GetBSet(CommandBarWindowID);
|
|
|
|
|
command_bar.window->visible = true;
|
|
|
|
|
command_bar.window->eval_command = false;
|
|
|
|
|
@@ -1224,17 +1224,17 @@ void Command_ShowLuaFunctions(CommandContext *ctx) {
|
|
|
|
|
SelectRange(command_bar.view, GetBufferEndAsRange(command_bar.buffer));
|
|
|
|
|
} RegisterCommand(Command_ShowLuaFunctions, "");
|
|
|
|
|
|
|
|
|
|
void Command_GotoBackward(CommandContext *ctx) {
|
|
|
|
|
void Command_GotoBackward() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
GotoBackward(main.window);
|
|
|
|
|
} RegisterCommand(Command_GotoBackward, "alt-q | mousex1");
|
|
|
|
|
|
|
|
|
|
void Command_GotoForward(CommandContext *ctx) {
|
|
|
|
|
void Command_GotoForward() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
GotoForward(main.window);
|
|
|
|
|
} RegisterCommand(Command_GotoForward, "mousex2");
|
|
|
|
|
|
|
|
|
|
void Command_OpenUpFolder(CommandContext *ctx) {
|
|
|
|
|
void Command_OpenUpFolder() {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
String name = ChopLastSlash(main.buffer->name);
|
|
|
|
|
if (EndsWith(main.buffer->name, "dirlisting")) {
|
|
|
|
|
@@ -1243,59 +1243,59 @@ void Command_OpenUpFolder(CommandContext *ctx) {
|
|
|
|
|
Open(name);
|
|
|
|
|
} RegisterCommand(Command_OpenUpFolder, "ctrl-period");
|
|
|
|
|
|
|
|
|
|
void Command_EncloseLine(CommandContext *ctx) {
|
|
|
|
|
void Command_EncloseLine() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
EncloseLine(active.view);
|
|
|
|
|
} RegisterCommand(Command_EncloseLine, "ctrl-l");
|
|
|
|
|
|
|
|
|
|
void Command_SelectAll(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectAll() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
SelectEntireBuffer(active.view);
|
|
|
|
|
active.view->update_scroll = false;
|
|
|
|
|
} RegisterCommand(Command_SelectAll, "ctrl-a");
|
|
|
|
|
|
|
|
|
|
void Command_Redo(CommandContext *ctx) {
|
|
|
|
|
void Command_Redo() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
RedoEdit(active.buffer, &active.view->carets);
|
|
|
|
|
} RegisterCommand(Command_Redo, "ctrl-shift-z");
|
|
|
|
|
|
|
|
|
|
void Command_Undo(CommandContext *ctx) {
|
|
|
|
|
void Command_Undo() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
UndoEdit(active.buffer, &active.view->carets);
|
|
|
|
|
} RegisterCommand(Command_Undo, "ctrl-z");
|
|
|
|
|
|
|
|
|
|
void Command_MakeFontLarger(CommandContext *ctx) {
|
|
|
|
|
void Command_MakeFontLarger() {
|
|
|
|
|
StyleFontSize += 1;
|
|
|
|
|
ReloadFont(StyleFont, (U32)StyleFontSize);
|
|
|
|
|
} RegisterCommand(Command_MakeFontLarger, "ctrl-equals");
|
|
|
|
|
|
|
|
|
|
void Command_MakeFontSmaller(CommandContext *ctx) {
|
|
|
|
|
void Command_MakeFontSmaller() {
|
|
|
|
|
if (StyleFontSize > 4) {
|
|
|
|
|
StyleFontSize -= 1;
|
|
|
|
|
ReloadFont(StyleFont, (U32)StyleFontSize);
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_MakeFontSmaller, "ctrl-minus");
|
|
|
|
|
|
|
|
|
|
void Command_Search(CommandContext *ctx) {
|
|
|
|
|
void Command_Search() {
|
|
|
|
|
Window *window = GetWindow(SearchBarWindowID);
|
|
|
|
|
window->visible = !window->visible;
|
|
|
|
|
} RegisterCommand(Command_Search, "ctrl-f");
|
|
|
|
|
|
|
|
|
|
void EvalCommand(CommandContext *ctx, String command) {
|
|
|
|
|
void EvalCommand(String command) {
|
|
|
|
|
For (CommandFunctions) {
|
|
|
|
|
if (it.name == command) {
|
|
|
|
|
it.function(ctx);
|
|
|
|
|
it.function();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EvalCommand(CommandContext *ctx, String16 command) {
|
|
|
|
|
void EvalCommand(String16 command) {
|
|
|
|
|
Scratch scratch;
|
|
|
|
|
EvalCommand(ctx, ToString(scratch, command));
|
|
|
|
|
EvalCommand(ToString(scratch, command));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FuzzySearchOpen(CommandContext *ctx, BSet active) {
|
|
|
|
|
void FuzzySearchOpen(BSet active) {
|
|
|
|
|
Range range = active.view->carets[0].range;
|
|
|
|
|
String16 string = FetchLoadWord(active);
|
|
|
|
|
if (GetSize(range) == 0) {
|
|
|
|
|
@@ -1313,28 +1313,28 @@ void FuzzySearchOpen(CommandContext *ctx, BSet active) {
|
|
|
|
|
if (active.window->eval_command) {
|
|
|
|
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
ActiveWindowID = main.window->id;
|
|
|
|
|
EvalCommand(ctx, string);
|
|
|
|
|
EvalCommand(string);
|
|
|
|
|
} else {
|
|
|
|
|
Open(string);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Command_Open(CommandContext *ctx) {
|
|
|
|
|
void Command_Open() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
if (active.view->fuzzy_search) {
|
|
|
|
|
FuzzySearchOpen(ctx, active);
|
|
|
|
|
FuzzySearchOpen(active);
|
|
|
|
|
} else {
|
|
|
|
|
BSet active = GetBSet(LastActiveLayoutWindowID);
|
|
|
|
|
Open(FetchLoadWord(active));
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_Open, "ctrl-q");
|
|
|
|
|
|
|
|
|
|
void Command_KillSelectedLines(CommandContext *ctx) {
|
|
|
|
|
void Command_KillSelectedLines() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
KillSelectedLines(active.view);
|
|
|
|
|
} RegisterCommand(Command_KillSelectedLines, "ctrl-shift-k");
|
|
|
|
|
|
|
|
|
|
void Command_IndentSelectedLines(CommandContext *ctx) {
|
|
|
|
|
void Command_IndentSelectedLines() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
Event event = *OnCommandEvent;
|
|
|
|
|
bool left = false;
|
|
|
|
|
@@ -1344,226 +1344,226 @@ void Command_IndentSelectedLines(CommandContext *ctx) {
|
|
|
|
|
IndentSelectedLines(active.view, left);
|
|
|
|
|
} RegisterCommand(Command_IndentSelectedLines, "ctrl-leftbracket | ctrl-rightbracket | tab | shift-tab");
|
|
|
|
|
|
|
|
|
|
void Command_DuplicateLineDown(CommandContext *ctx) {
|
|
|
|
|
void Command_DuplicateLineDown() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
DuplicateLine(active.view, DIR_DOWN);
|
|
|
|
|
} RegisterCommand(Command_DuplicateLineDown, "ctrl-alt-down");
|
|
|
|
|
|
|
|
|
|
void Command_CreateCursorDown(CommandContext *ctx) {
|
|
|
|
|
void Command_CreateCursorDown() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
CreateCursorVertical(active.view, DIR_DOWN);
|
|
|
|
|
} RegisterCommand(Command_CreateCursorDown, "alt-shift-down");
|
|
|
|
|
|
|
|
|
|
void Command_SelectDownToEmptyLine(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectDownToEmptyLine() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_DOWN, CTRL_PRESSED, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectDownToEmptyLine, "ctrl-shift-down");
|
|
|
|
|
|
|
|
|
|
void Command_MoveLineDown(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveLineDown() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCaretsLine(active.view, DIR_DOWN);
|
|
|
|
|
} RegisterCommand(Command_MoveLineDown, "alt-down");
|
|
|
|
|
|
|
|
|
|
void Command_MoveDownToEmptyLine(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveDownToEmptyLine() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_DOWN, CTRL_PRESSED);
|
|
|
|
|
} RegisterCommand(Command_MoveDownToEmptyLine, "ctrl-down");
|
|
|
|
|
|
|
|
|
|
void Command_SelectDown(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectDown() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_DOWN, false, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectDown, "shift-down");
|
|
|
|
|
|
|
|
|
|
void Command_MoveDown(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveDown() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_DOWN);
|
|
|
|
|
} RegisterCommand(Command_MoveDown, "down");
|
|
|
|
|
|
|
|
|
|
void Command_DuplicateLineUp(CommandContext *ctx) {
|
|
|
|
|
void Command_DuplicateLineUp() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
DuplicateLine(active.view, DIR_UP);
|
|
|
|
|
} RegisterCommand(Command_DuplicateLineUp, "ctrl-alt-up");
|
|
|
|
|
|
|
|
|
|
void Command_CreateCursorUp(CommandContext *ctx) {
|
|
|
|
|
void Command_CreateCursorUp() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
CreateCursorVertical(active.view, DIR_UP);
|
|
|
|
|
} RegisterCommand(Command_CreateCursorUp, "alt-shift-up");
|
|
|
|
|
|
|
|
|
|
void Command_SelectUpToEmptyLine(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectUpToEmptyLine() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_UP, CTRL_PRESSED, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectUpToEmptyLine, "ctrl-shift-up");
|
|
|
|
|
|
|
|
|
|
void Command_MoveLineUp(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveLineUp() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCaretsLine(active.view, DIR_UP);
|
|
|
|
|
} RegisterCommand(Command_MoveLineUp, "alt-up");
|
|
|
|
|
|
|
|
|
|
void Command_MoveUpToEmptyLine(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveUpToEmptyLine() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_UP, CTRL_PRESSED);
|
|
|
|
|
} RegisterCommand(Command_MoveUpToEmptyLine, "ctrl-up");
|
|
|
|
|
|
|
|
|
|
void Command_SelectUp(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectUp() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_UP, false, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectUp, "shift-up");
|
|
|
|
|
|
|
|
|
|
void Command_MoveUp(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveUp() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_UP);
|
|
|
|
|
} RegisterCommand(Command_MoveUp, "up");
|
|
|
|
|
|
|
|
|
|
void Command_BoundarySelectLeft(CommandContext *ctx) {
|
|
|
|
|
void Command_BoundarySelectLeft() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_LEFT, CTRL_PRESSED, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_BoundarySelectLeft, "ctrl-shift-left");
|
|
|
|
|
|
|
|
|
|
void Command_BoundaryMoveLeft(CommandContext *ctx) {
|
|
|
|
|
void Command_BoundaryMoveLeft() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_LEFT, CTRL_PRESSED);
|
|
|
|
|
} RegisterCommand(Command_BoundaryMoveLeft, "ctrl-left");
|
|
|
|
|
|
|
|
|
|
void Command_SelectLeft(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectLeft() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_LEFT, false, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectLeft, "shift-left");
|
|
|
|
|
|
|
|
|
|
void Command_FocusLeftWindow(CommandContext *ctx) {
|
|
|
|
|
void Command_FocusLeftWindow() {
|
|
|
|
|
ActiveWindowID = SwitchWindow(DIR_LEFT)->id;
|
|
|
|
|
} RegisterCommand(Command_FocusLeftWindow, "alt-left");
|
|
|
|
|
|
|
|
|
|
void Command_MoveLeft(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveLeft() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_LEFT);
|
|
|
|
|
} RegisterCommand(Command_MoveLeft, "left");
|
|
|
|
|
|
|
|
|
|
void Command_BoundarySelectRight(CommandContext *ctx) {
|
|
|
|
|
void Command_BoundarySelectRight() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_RIGHT, CTRL_PRESSED, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_BoundarySelectRight, "ctrl-shift-right");
|
|
|
|
|
|
|
|
|
|
void Command_BoundaryMoveRight(CommandContext *ctx) {
|
|
|
|
|
void Command_BoundaryMoveRight() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_RIGHT, CTRL_PRESSED);
|
|
|
|
|
} RegisterCommand(Command_BoundaryMoveRight, "ctrl-right");
|
|
|
|
|
|
|
|
|
|
void Command_SelectRight(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectRight() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_RIGHT, false, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectRight, "shift-right");
|
|
|
|
|
|
|
|
|
|
void Command_FocusRightWindow(CommandContext *ctx) {
|
|
|
|
|
void Command_FocusRightWindow() {
|
|
|
|
|
ActiveWindowID = SwitchWindow(DIR_RIGHT)->id;
|
|
|
|
|
} RegisterCommand(Command_FocusRightWindow, "alt-right");
|
|
|
|
|
|
|
|
|
|
void Command_MoveRight(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveRight() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCarets(active.view, DIR_RIGHT);
|
|
|
|
|
} RegisterCommand(Command_MoveRight, "right");
|
|
|
|
|
|
|
|
|
|
void Command_MoveUpAPage(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveUpAPage() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorByPageSize(active.window, DIR_UP, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_MoveUpAPage, "pageup");
|
|
|
|
|
|
|
|
|
|
void Command_SelectDownPage(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectDownPage() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorByPageSize(active.window, DIR_DOWN, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectDownPage, "shift-pagedown");
|
|
|
|
|
|
|
|
|
|
void Command_MoveToEnd(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveToEnd() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
SelectRange(active.view, MakeRange(active.buffer->len));
|
|
|
|
|
} RegisterCommand(Command_MoveToEnd, "pagedown");
|
|
|
|
|
|
|
|
|
|
void Command_MoveDownPage(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveDownPage() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
SelectRange(active.view, MakeRange(active.buffer->len));
|
|
|
|
|
} RegisterCommand(Command_MoveDownPage, "ctrl-pagedown");
|
|
|
|
|
|
|
|
|
|
void Command_SelectUpPage(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectUpPage() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorByPageSize(active.window, DIR_UP, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectUpPage, "shift-pageup");
|
|
|
|
|
|
|
|
|
|
void Command_MoveToStart(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveToStart() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
SelectRange(active.view, MakeRange(0));
|
|
|
|
|
} RegisterCommand(Command_MoveToStart, "ctrl-pageup");
|
|
|
|
|
|
|
|
|
|
void Command_MoveUpPage(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveUpPage() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorByPageSize(active.window, DIR_UP);
|
|
|
|
|
} RegisterCommand(Command_MoveUpPage, "pageup");
|
|
|
|
|
|
|
|
|
|
void Command_SelectToLineStart(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectToLineStart() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorToSide(active.view, DIR_LEFT, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectToLineStart, "shift-home");
|
|
|
|
|
|
|
|
|
|
void Command_MoveToLineStart(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveToLineStart() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorToSide(active.view, DIR_LEFT);
|
|
|
|
|
} RegisterCommand(Command_MoveToLineStart, "home");
|
|
|
|
|
|
|
|
|
|
void Command_MoveToLineEnd(CommandContext *ctx) {
|
|
|
|
|
void Command_MoveToLineEnd() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorToSide(active.view, DIR_RIGHT);
|
|
|
|
|
} RegisterCommand(Command_MoveToLineEnd, "end");
|
|
|
|
|
|
|
|
|
|
void Command_SelectToLineEnd(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectToLineEnd() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorToSide(active.view, DIR_RIGHT, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_SelectToLineEnd, "shift-end");
|
|
|
|
|
|
|
|
|
|
void Command_Delete(CommandContext *ctx) {
|
|
|
|
|
void Command_Delete() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
Delete(active.view, DIR_LEFT);
|
|
|
|
|
} RegisterCommand(Command_Delete, "backspace");
|
|
|
|
|
|
|
|
|
|
void Command_DeleteBoundary(CommandContext *ctx) {
|
|
|
|
|
void Command_DeleteBoundary() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
Delete(active.view, DIR_LEFT, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_DeleteBoundary, "ctrl-backspace");
|
|
|
|
|
|
|
|
|
|
void Command_DeleteForward(CommandContext *ctx) {
|
|
|
|
|
void Command_DeleteForward() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
Delete(active.view, DIR_RIGHT);
|
|
|
|
|
} RegisterCommand(Command_DeleteForward, "delete");
|
|
|
|
|
|
|
|
|
|
void Command_DeleteForwardBoundary(CommandContext *ctx) {
|
|
|
|
|
void Command_DeleteForwardBoundary() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
Delete(active.view, DIR_RIGHT, SHIFT_PRESS);
|
|
|
|
|
} RegisterCommand(Command_DeleteForwardBoundary, "ctrl-delete");
|
|
|
|
|
|
|
|
|
|
void Command_InsertNewLineUp(CommandContext *ctx) {
|
|
|
|
|
void Command_InsertNewLineUp() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorToSide(active.view, DIR_LEFT);
|
|
|
|
|
IdentedNewLine(active.view);
|
|
|
|
|
MoveCarets(active.view, DIR_UP);
|
|
|
|
|
} RegisterCommand(Command_InsertNewLineUp, "ctrl-shift-enter");
|
|
|
|
|
|
|
|
|
|
void Command_InsertNewLineDown(CommandContext *ctx) {
|
|
|
|
|
void Command_InsertNewLineDown() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
MoveCursorToSide(active.view, DIR_RIGHT);
|
|
|
|
|
IdentedNewLine(active.view);
|
|
|
|
|
} RegisterCommand(Command_InsertNewLineDown, "ctrl-enter");
|
|
|
|
|
|
|
|
|
|
void Command_SelectFuzzySearchEntry(CommandContext *ctx) {
|
|
|
|
|
void Command_SelectFuzzySearchEntry() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
if (active.view->fuzzy_search) {
|
|
|
|
|
FuzzySearchOpen(ctx, active);
|
|
|
|
|
ctx->out_skip_rem_cmds = true;
|
|
|
|
|
FuzzySearchOpen(active);
|
|
|
|
|
SkipRemainingCommands = true;
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_SelectFuzzySearchEntry, "enter");
|
|
|
|
|
|
|
|
|
|
void Command_NewLine(CommandContext *ctx) {
|
|
|
|
|
void Command_NewLine() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
IdentedNewLine(active.view);
|
|
|
|
|
} RegisterCommand(Command_NewLine, "enter");
|
|
|
|
|
|
|
|
|
|
void Command_CreateCaretOnNextFind(CommandContext *ctx) {
|
|
|
|
|
void Command_CreateCaretOnNextFind() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
String16 string = GetString(active.buffer, active.view->carets[0].range);
|
|
|
|
|
Caret caret = FindNext(active.buffer, string, active.view->carets[0]);
|
|
|
|
|
@@ -1571,17 +1571,17 @@ void Command_CreateCaretOnNextFind(CommandContext *ctx) {
|
|
|
|
|
MergeCarets(active.buffer, &active.view->carets);
|
|
|
|
|
} RegisterCommand(Command_CreateCaretOnNextFind, "ctrl-d");
|
|
|
|
|
|
|
|
|
|
void Command_FocusWindow1(CommandContext *ctx) {
|
|
|
|
|
void Command_FocusWindow1() {
|
|
|
|
|
ActiveWindowID = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID))->id;
|
|
|
|
|
} RegisterCommand(Command_FocusWindow1, "ctrl-1");
|
|
|
|
|
|
|
|
|
|
void Command_FocusWindow2(CommandContext *ctx) {
|
|
|
|
|
void Command_FocusWindow2() {
|
|
|
|
|
Window *first = GetOverlappingWindow({0,0}, GetWindow(ActiveWindowID));
|
|
|
|
|
Vec2I p = GetSideOfWindow(first, DIR_RIGHT);
|
|
|
|
|
ActiveWindowID = GetOverlappingWindow(p, GetWindow(ActiveWindowID))->id;
|
|
|
|
|
} RegisterCommand(Command_FocusWindow2, "ctrl-2");
|
|
|
|
|
|
|
|
|
|
void Command_FocusWindow3(CommandContext *ctx) {
|
|
|
|
|
void Command_FocusWindow3() {
|
|
|
|
|
Window *first = GetOverlappingWindow({0,0});
|
|
|
|
|
if (first) {
|
|
|
|
|
Window *second = GetOverlappingWindow(GetSideOfWindow(first, DIR_RIGHT));
|
|
|
|
|
@@ -1594,7 +1594,7 @@ void Command_FocusWindow3(CommandContext *ctx) {
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_FocusWindow3, "ctrl-3");
|
|
|
|
|
|
|
|
|
|
void Command_ClearCarets(CommandContext *ctx) {
|
|
|
|
|
void Command_ClearCarets() {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
active.view->carets.len = 1;
|
|
|
|
|
active.view->carets[0] = MakeCaret(GetFront(active.view->carets[0]));
|
|
|
|
|
@@ -1608,3 +1608,44 @@ void Command_ClearCarets(CommandContext *ctx) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} RegisterCommand(Command_ClearCarets, "escape");
|
|
|
|
|
|
|
|
|
|
void Hook_OnDropFile(String *text) {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
WindowOpenBufferView(active.window, *text);
|
|
|
|
|
} RegisterHook(&OnDropFileHooks, Hook_OnDropFile);
|
|
|
|
|
|
|
|
|
|
void Hook_OnTextInput(String *text) {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
Scratch scratch;
|
|
|
|
|
String16 string16 = ToString16(scratch, *text);
|
|
|
|
|
Replace(active.view, string16);
|
|
|
|
|
} RegisterHook(&OnTextInputHooks, Hook_OnTextInput);
|
|
|
|
|
|
|
|
|
|
void Hook_PostCommandFuzzySearchUpdate(void *param) {
|
|
|
|
|
BSet active = GetBSet(ActiveWindowID);
|
|
|
|
|
if (active.view->fuzzy_search) {
|
|
|
|
|
if (!ProcessIsActive(active.view->id)) {
|
|
|
|
|
Scratch scratch;
|
|
|
|
|
String16 last_line_string = GetLineStringWithoutNL(active.buffer, active.buffer->line_starts.len - 1);
|
|
|
|
|
if (active.view->prev_search_line != last_line_string) {
|
|
|
|
|
active.view->prev_search_line = last_line_string;
|
|
|
|
|
Array<FuzzyPair> ratings = FuzzySearchLines(scratch, active.buffer, 0, active.buffer->line_starts.len - 1, last_line_string);
|
|
|
|
|
|
|
|
|
|
Buffer *temp_buffer = CreateTempBuffer(scratch, active.buffer->cap);
|
|
|
|
|
For(IterateInReverse(&ratings)) {
|
|
|
|
|
String16 s = GetLineStringWithoutNL(active.buffer, it.index);
|
|
|
|
|
if (s.len == 0) continue;
|
|
|
|
|
RawReplaceText(temp_buffer, GetBufferEndAsRange(temp_buffer), s);
|
|
|
|
|
RawReplaceText(temp_buffer, GetBufferEndAsRange(temp_buffer), u"\n");
|
|
|
|
|
}
|
|
|
|
|
RawReplaceText(temp_buffer, GetBufferEndAsRange(temp_buffer), last_line_string);
|
|
|
|
|
|
|
|
|
|
Caret caret = active.view->carets[0];
|
|
|
|
|
SaveCaretHistoryBeforeBeginEdit(active.buffer, active.view->carets);
|
|
|
|
|
SelectEntireBuffer(active.view);
|
|
|
|
|
Replace(active.view, GetString(temp_buffer));
|
|
|
|
|
active.view->carets[0] = caret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} RegisterHook(&PostCommandHooks, Hook_PostCommandFuzzySearchUpdate);
|