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