SetWorkDirAt, OpenCodeAt, fix bug there, fill more doc strings
This commit is contained in:
@@ -2,21 +2,18 @@
|
||||
! From a user (novice) point of view, how does it look like?
|
||||
|
||||
Use session 4
|
||||
- ":OpenAt C:/Work"
|
||||
- :OpenCodeAt C:/Work
|
||||
- :SetWorkDirAt C:/Work or :Set WorkDir "." ? or :Set WorkDir "C:/text_editor"
|
||||
- SkipLoadWord
|
||||
- Delete file command
|
||||
- :Close Fuzzy search exact match doesn't match with Close
|
||||
- Maybe search everything window should have a special buffer
|
||||
- Setting variables maybe should create and modify config, commit these changes immediately? So user can change keybindings in command window and commit immediately
|
||||
- Make the special view hooks also available for modification and registered but maybe under different name or something
|
||||
|
||||
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
||||
- Make the equivalent of SearchProject but for cmds like !@git grep -n "@>"
|
||||
- Add Bool variable
|
||||
|
||||
- Initialize all keybindings at the start and refer using global variables?
|
||||
- RegisterCommand should_appear_in_listing variable
|
||||
- RegisterCommand docs
|
||||
- Maybe one list for all variables including the commands etc?
|
||||
|
||||
Use session 3:
|
||||
|
||||
@@ -479,6 +479,22 @@ String16 SkipIdent(String16 *string) {
|
||||
return begin;
|
||||
}
|
||||
|
||||
String16 SkipString(String16 *string) {
|
||||
String16 saved_string = *string;
|
||||
char16_t c = At(*string, 0);
|
||||
String16 q = {&c, 1};
|
||||
if (c == u'"' || c == u'\'') {
|
||||
*string = Skip(*string, 1);
|
||||
String16 quote = SkipUntil(string, q);
|
||||
if (At(*string, 0) != c) {
|
||||
*string = saved_string;
|
||||
return {};
|
||||
}
|
||||
return quote;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
bool MatchIdent(String16 *string, String16 expect) {
|
||||
String16 copy = *string;
|
||||
String16 ident = SkipIdent(©);
|
||||
|
||||
@@ -463,17 +463,17 @@ void CMD_Build() {
|
||||
#endif
|
||||
BSet main = GetBSet(BuildWindowID);
|
||||
main.window->visible = true;
|
||||
} RegisterCommand(CMD_Build, "f1");
|
||||
} RegisterCommand(CMD_Build, "f1", "Run build.sh or build.bat in working directory, output is printed in a popup console and a special build buffer");
|
||||
|
||||
void CMD_GotoNextInList() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
GotoNextInList(main.window, 1);
|
||||
} RegisterCommand(CMD_GotoNextInList, "ctrl-e");
|
||||
} RegisterCommand(CMD_GotoNextInList, "ctrl-e", "For example: when jumping from build panel to build error, a jump point is setup, user can click this button to go over to the next compiler error");
|
||||
|
||||
void CMD_GotoPrevInList() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
GotoNextInList(main.window, -1);
|
||||
} RegisterCommand(CMD_GotoPrevInList, "alt-e");
|
||||
} RegisterCommand(CMD_GotoPrevInList, "alt-e", "For example: when jumping from build panel to build error, a jump point is setup, user can click this button to go over to the previous compiler error");
|
||||
|
||||
bool IsOpenBoundary(char c) {
|
||||
bool result = c == 0 || IsParen(c) || IsBrace(c) || c == ':' || c == '\t' || c == '\n' || c == '"' || c == '\'';
|
||||
@@ -678,7 +678,7 @@ BSet Open(String16 path, ResolveOpenMeta meta) {
|
||||
void CMD_Save() {
|
||||
BSet active = GetBSet(PrimaryWindowID);
|
||||
SaveBuffer(active.buffer);
|
||||
} RegisterCommand(CMD_Save, "ctrl-s");
|
||||
} RegisterCommand(CMD_Save, "ctrl-s", "Save buffer currently open in the last primary window");
|
||||
|
||||
void CMD_Reopen() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
@@ -689,7 +689,7 @@ void CMD_Reopen() {
|
||||
void CMD_New() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
New(main.window, "");
|
||||
} RegisterCommand(CMD_New, "ctrl-n");
|
||||
} RegisterCommand(CMD_New, "ctrl-n", "Open a new buffer with automatically generated name, use :Rename");
|
||||
|
||||
void CMD_ToggleFullscreen() {
|
||||
if (IsInFullscreen) {
|
||||
@@ -708,23 +708,51 @@ void CMD_ToggleFullscreen() {
|
||||
IsInFullscreen = !IsInFullscreen;
|
||||
} RegisterCommand(CMD_ToggleFullscreen, "f11");
|
||||
|
||||
void CMD_SetWorkDir() {
|
||||
String16 FetchStringForCommandParsing() {
|
||||
BSet set = GetBSet(ActiveWindowID);
|
||||
Range range = set.view->carets[0].range;
|
||||
range.max = range.min; // We only scan for :Set
|
||||
if (GetSize(range) == 0) {
|
||||
range = EncloseLoadWord(set.buffer, range.min);
|
||||
}
|
||||
Int line_end = GetLineEnd(set.buffer, range.min);
|
||||
String16 string = GetString(set.buffer, {range.min, line_end});
|
||||
return string;
|
||||
}
|
||||
|
||||
void SetWorkDir(String string) {
|
||||
Scratch scratch;
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
WorkDir = GetDir(main.buffer);
|
||||
WorkDir = Intern(&GlobalInternTable, string);
|
||||
For (Buffers) {
|
||||
if (it->special) {
|
||||
String name = SkipToLastSlash(it->name);
|
||||
it->name = Intern(&GlobalInternTable, Format(scratch, "%S/%S", WorkDir, name));
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_SetWorkDir, "");
|
||||
}
|
||||
|
||||
void CMD_SetWorkDir() {
|
||||
Scratch scratch;
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
SetWorkDir(GetDir(main.buffer));
|
||||
} RegisterCommand(CMD_SetWorkDir, "", "Sets work directory to the directory of the current buffer, it also renames couple special buffers to make them accomodate the new WorkDir");
|
||||
|
||||
void CMD_SetWorkDirAt() {
|
||||
String16 string = FetchStringForCommandParsing();
|
||||
string = Skip(string, 1);
|
||||
SkipIdent(&string);
|
||||
SkipWhitespace(&string);
|
||||
Scratch scratch;
|
||||
String16 arg = SkipString(&string);
|
||||
String arg8 = ToString(scratch, arg);
|
||||
SetWorkDir(arg8);
|
||||
} RegisterCommand(CMD_SetWorkDirAt, "", "Sets work directory using the argument string passed here, it also renames couple special buffers to make them accomodate the new WorkDir");
|
||||
|
||||
String Coro_OpenCodeDir;
|
||||
void Coro_OpenCode(mco_coro *co) {
|
||||
Array<String> patterns = Split(CoCurr->arena, Coro_OpenCodeDir, "|");
|
||||
Array<String> patterns = Split(CoCurr->arena, NonCodePatterns_EndsWith, "|");
|
||||
Array<String> dirs = {CoCurr->arena};
|
||||
Add(&dirs, Coro_OpenCodeDir);
|
||||
String *param_dir = (String *)CoCurr->user_ctx;
|
||||
Add(&dirs, *param_dir);
|
||||
for (int diri = 0; diri < dirs.len; diri += 1) {
|
||||
for (FileIter it = IterateFiles(CoCurr->arena, dirs[diri]); IsValid(it); Advance(&it)) {
|
||||
bool match = false;
|
||||
@@ -749,9 +777,11 @@ void Coro_OpenCode(mco_coro *co) {
|
||||
}
|
||||
|
||||
void OpenCode(String dir) {
|
||||
Coro_OpenCodeDir = 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;
|
||||
data->dont_wait_until_resolved = true;
|
||||
CoResume(data);
|
||||
}
|
||||
@@ -760,6 +790,17 @@ void CMD_OpenCode() {
|
||||
OpenCode(WorkDir);
|
||||
} RegisterCommand(CMD_OpenCode, "", "Open all code files in current WorkDir, the code files are determined through NonCodePatterns_EndsWith config variable list");
|
||||
|
||||
void CMD_OpenCodeAt() {
|
||||
String16 string = FetchStringForCommandParsing();
|
||||
string = Skip(string, 1);
|
||||
SkipIdent(&string);
|
||||
SkipWhitespace(&string);
|
||||
Scratch scratch;
|
||||
String16 arg = SkipString(&string);
|
||||
String arg8 = ToString(scratch, arg);
|
||||
OpenCode(arg8);
|
||||
} RegisterCommand(CMD_OpenCodeAt, "", "Open all code files pointed to by string argument following the command");
|
||||
|
||||
void CMD_KillProcess() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
KillProcess(main.view);
|
||||
@@ -1300,7 +1341,7 @@ void CMD_ClearCarets() {
|
||||
it->visible = false;
|
||||
}
|
||||
}
|
||||
} RegisterCommand(CMD_ClearCarets, "escape");
|
||||
} RegisterCommand(CMD_ClearCarets, "escape", "Clear all carets and reset to 1 caret, also do some windowing stuff that closes things on escape");
|
||||
|
||||
void Set(String16 string) {
|
||||
Scratch scratch;
|
||||
@@ -1432,17 +1473,9 @@ void Set(String16 string) {
|
||||
}
|
||||
|
||||
void CMD_Set() {
|
||||
BSet set = GetBSet(ActiveWindowID);
|
||||
Range range = set.view->carets[0].range;
|
||||
range.max = range.min; // We only scan for :Set
|
||||
if (GetSize(range) == 0) {
|
||||
range = EncloseLoadWord(set.buffer, range.min);
|
||||
}
|
||||
Int line_end = GetLineEnd(set.buffer, range.min);
|
||||
|
||||
String16 string = GetString(set.buffer, {range.min, line_end});
|
||||
String16 string = FetchStringForCommandParsing();
|
||||
Set(string);
|
||||
} RegisterCommand(CMD_Set, "");
|
||||
} RegisterCommand(CMD_Set, "", "Sets a named editor variable to the text argument following the command, the format is ':Set FormatCode 0'");
|
||||
|
||||
void EvalCommandsLineByLine(BSet set) {
|
||||
WindowID save_last = PrimaryWindowID;
|
||||
@@ -1475,7 +1508,7 @@ void EvalCommandsLineByLine(BSet set) {
|
||||
void CMD_EvalCommandsLineByLine() {
|
||||
BSet set = GetBSet(PrimaryWindowID);
|
||||
EvalCommandsLineByLine(set);
|
||||
} RegisterCommand(CMD_EvalCommandsLineByLine, "");
|
||||
} RegisterCommand(CMD_EvalCommandsLineByLine, "", "Goes line by line over a buffer and evaluates every line as a command, ignores empty or lines starting with '//'");
|
||||
|
||||
void GenerateConfig(View *view) {
|
||||
For (Variables) {
|
||||
|
||||
@@ -82,4 +82,4 @@ void DebugWindowUpdate() {
|
||||
void CMD_ToggleDebug() {
|
||||
Window *window = GetWindow(DebugWindowID);
|
||||
window->visible = !window->visible;
|
||||
} RegisterCommand(CMD_ToggleDebug, "ctrl-0");
|
||||
} RegisterCommand(CMD_ToggleDebug, "ctrl-0", "Open a floating window that might become useful for debugging");
|
||||
|
||||
@@ -12,7 +12,7 @@ void CMD_Search() {
|
||||
Replace(set.view, string);
|
||||
SelectEntireBuffer(set.view);
|
||||
}
|
||||
} RegisterCommand(CMD_Search, "ctrl-f");
|
||||
} RegisterCommand(CMD_Search, "ctrl-f", "Open up a search window");
|
||||
|
||||
void SearchWindowFindNext(bool forward = true) {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
@@ -33,11 +33,11 @@ void CMD_SearchPrevInSearch() {
|
||||
|
||||
void CMD_SearchNext() {
|
||||
SearchWindowFindNext(true);
|
||||
} RegisterCommand(CMD_SearchNext, "f3");
|
||||
} RegisterCommand(CMD_SearchNext, "f3", "Go to the next occurence of the search window needle");
|
||||
|
||||
void CMD_SearchPrev() {
|
||||
SearchWindowFindNext(false);
|
||||
} RegisterCommand(CMD_SearchPrev, "shift-f3");
|
||||
} RegisterCommand(CMD_SearchPrev, "shift-f3", "Go to the previous occurence of the search window needle");
|
||||
|
||||
void CMD_SearchAll() {
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
@@ -45,15 +45,15 @@ void CMD_SearchAll() {
|
||||
String16 needle = GetString(set.buffer, GetRange(set.buffer));
|
||||
SelectAllOccurences(main.view, needle);
|
||||
set.window->visible = false;
|
||||
} RegisterCommand(CMD_SearchAll, "alt-f3");
|
||||
} RegisterCommand(CMD_SearchAll, "alt-f3", "Use the search window needle and seek all the possible occurences in current buffer");
|
||||
|
||||
void CMD_ToggleCaseSensitiveSearch() {
|
||||
SearchCaseSensitive = !SearchCaseSensitive;
|
||||
} RegisterCommand(CMD_ToggleCaseSensitiveSearch, "alt-c");
|
||||
} RegisterCommand(CMD_ToggleCaseSensitiveSearch, "alt-c", "Text editor wide search toggle, should apply to most search things");
|
||||
|
||||
void CMD_ToggleSearchWordBoundary() {
|
||||
SearchWordBoundary = !SearchWordBoundary;
|
||||
} RegisterCommand(CMD_ToggleSearchWordBoundary, "alt-w");
|
||||
} RegisterCommand(CMD_ToggleSearchWordBoundary, "alt-w", "Text editor wide search toggle, should apply to most search things");
|
||||
|
||||
void SearchWindowUpdate() {
|
||||
BSet active = GetBSet(ActiveWindowID);
|
||||
|
||||
Reference in New Issue
Block a user