Reword ListBuffers
This commit is contained in:
@@ -30,7 +30,7 @@ bool IsWord(wchar_t w) {
|
||||
}
|
||||
|
||||
bool IsLoadWord(wchar_t w) {
|
||||
bool result = w == '/' || w == '\\' || w == ':' || w == '*' || w == '_' || w == '.' || w == '-';
|
||||
bool result = w == '/' || w == '\\' || w == ':' || w == '+' || w == '_' || w == '.' || w == '-';
|
||||
if (!result) {
|
||||
result = !(IsSymbol(w) || IsWhitespace(w));
|
||||
}
|
||||
|
||||
@@ -145,22 +145,26 @@ int Lua_Print(lua_State *L) {
|
||||
}
|
||||
|
||||
int Lua_ListBuffers(lua_State *L) {
|
||||
Window *window = GetWindow(ActiveWindow);
|
||||
Window *window = GetWindow(GetLastActiveWindow());
|
||||
View *view = GetView(window->active_view);
|
||||
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||
CheckpointBeforeGoto(window->id);
|
||||
|
||||
Scratch scratch;
|
||||
Array<String> strings = {scratch};
|
||||
For(Buffers) {
|
||||
if (StartsWith(it.name, "+titlebar")) continue;
|
||||
String string = Format(scratch, "%.*s", FmtString(it.name));
|
||||
Add(&strings, string);
|
||||
}
|
||||
String result = Merge(scratch, strings, "\n");
|
||||
String16 string16 = ToString16(scratch, result);
|
||||
|
||||
Command_SelectEntireBuffer(view);
|
||||
Command_Replace(view, string16);
|
||||
Command_SelectRangeOneCursor(view, {});
|
||||
String buffer_name = GetUniqueBufferName(scratch, GetDir(buffer), "+list_buffers-");
|
||||
View *new_view = WindowOpenBufferView(window, buffer_name);
|
||||
|
||||
Command_SelectEntireBuffer(new_view);
|
||||
Command_Replace(new_view, string16);
|
||||
Command_SelectRangeOneCursor(new_view, {});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -196,6 +196,11 @@ String GetCurrentBufferName() {
|
||||
return buffer->name;
|
||||
}
|
||||
|
||||
String GetDir(Buffer *buffer) {
|
||||
String name = buffer->is_directory ? buffer->name : ChopLastSlash(buffer->name);
|
||||
return name;
|
||||
}
|
||||
|
||||
String GetCurrentBufferDir() {
|
||||
Window *window = GetCurrentWindow();
|
||||
View *view = GetView(window->active_view);
|
||||
|
||||
Reference in New Issue
Block a user