ListCode with ||
This commit is contained in:
@@ -1055,21 +1055,26 @@ void ListFilesRecursive(Buffer *buffer, String dir) {
|
||||
if (!good) {
|
||||
continue;
|
||||
}
|
||||
RawAppendf(buffer, "%-100.*s %.*s\n", FmtString(it.absolute_path), FmtString(it.filename));
|
||||
RawAppendf(buffer, "%-80.*s || %.*s\n", FmtString(it.filename), FmtString(it.absolute_path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Command_ListCode(void) {
|
||||
void Command_ListCode(String dir = WorkDir) {
|
||||
BSet main = GetActiveMainSet();
|
||||
JumpGarbageBuffer(&main);
|
||||
ListFilesRecursive(main.buffer, WorkDir);
|
||||
ListFilesRecursive(main.buffer, dir);
|
||||
main.view->fuzzy_search = true;
|
||||
Command_SelectRangeOneCursor(main.view, GetEndAsRange(main.buffer));
|
||||
}
|
||||
|
||||
int Lua_ListCode(lua_State *L) {
|
||||
Command_ListCode();
|
||||
String string = lua_tostring(L, 1);
|
||||
lua_pop(L, 1);
|
||||
if (string.len == 0) {
|
||||
string = WorkDir;
|
||||
}
|
||||
Command_ListCode(string);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -615,11 +615,31 @@ void OnCommand(Event event) {
|
||||
if (CtrlShiftPress(SDLK_Q)) {
|
||||
Command_Open(FetchLoadWord(), "exec");
|
||||
} else if (CtrlPress(SDLK_Q)) {
|
||||
Command_Open(FetchLoadWord());
|
||||
if (active.view->fuzzy_search) {
|
||||
bool success = false;
|
||||
Range range = active.view->carets[0].range;
|
||||
if (GetSize(range) == 0) {
|
||||
Int line = PosToLine(active.buffer, range.min);
|
||||
String16 string = GetLineStringWithoutNL(active.buffer, line);
|
||||
Int idx = 0;
|
||||
if (Seek(string, u"||", &idx)) {
|
||||
string = Skip(string, idx + 3);
|
||||
Command_Open(string);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
Command_Open(FetchLoadWord());
|
||||
}
|
||||
|
||||
{
|
||||
Range rng = GetLineRangeWithoutNL(active.buffer, active.buffer->line_starts.len - 1);
|
||||
GetLast(active.window->goto_history)->caret = MakeCaret(rng.max, rng.min);
|
||||
}
|
||||
} else {
|
||||
Command_Open(FetchLoadWord());
|
||||
}
|
||||
}
|
||||
|
||||
if (Press(SDLK_ESCAPE)) {
|
||||
|
||||
Reference in New Issue
Block a user