unspecial directory buffer

This commit is contained in:
krzosa
2025-04-29 22:41:44 +02:00
parent a5d99ffb9a
commit 46dcd1cc4e
4 changed files with 5 additions and 7 deletions

View File

@@ -36,7 +36,6 @@ struct Buffer {
int no_history : 1; int no_history : 1;
int no_line_starts : 1; int no_line_starts : 1;
int dirty : 1; int dirty : 1;
int is_directory : 1;
int gc : 1; int gc : 1;
int changed_on_disk : 1; int changed_on_disk : 1;
}; };

View File

@@ -83,7 +83,7 @@ void Command_ListBuffers() {
Scratch scratch; Scratch scratch;
Array<String> strings = {scratch}; Array<String> strings = {scratch};
For(Buffers) { For(Buffers) {
String string = Format(scratch, "%.*s id=%d is_dir=%d", FmtString(it.o->name), (int)it.id, it.o->is_directory); String string = Format(scratch, "%.*s id=%d", FmtString(it.o->name), (int)it.id);
Add(&strings, string); Add(&strings, string);
} }
String result = Merge(scratch, strings, "\n"); String result = Merge(scratch, strings, "\n");

View File

@@ -244,13 +244,13 @@ String GetActiveMainWindowBufferName() {
} }
String GetDir(Buffer *buffer) { String GetDir(Buffer *buffer) {
String name = buffer->is_directory ? buffer->name : ChopLastSlash(buffer->name); String name = ChopLastSlash(buffer->name);
return name; return name;
} }
String GetActiveMainWindowBufferDir() { String GetActiveMainWindowBufferDir() {
BSet set = GetActiveMainSet(); BSet set = GetActiveMainSet();
String name = set.buffer->is_directory ? set.buffer->name : ChopLastSlash(set.buffer->name); String name = ChopLastSlash(set.buffer->name);
return name; return name;
} }
@@ -330,8 +330,8 @@ Buffer *BufferOpenFile(String path) {
if (!FileExists(path)) { if (!FileExists(path)) {
buffer = CreateBuffer(sys_allocator, path); buffer = CreateBuffer(sys_allocator, path);
} else if (IsDir(path)) { } else if (IsDir(path)) {
buffer = CreateBuffer(sys_allocator, path, 4096 * 2); String buffer_name = GetUniqueBufferName(scratch, path, "+dir-");
buffer->is_directory = true; buffer = CreateBuffer(sys_allocator, buffer_name, 4096 * 2);
for (FileIter it = IterateFiles(scratch, path); IsValid(it); Advance(&it)) { for (FileIter it = IterateFiles(scratch, path); IsValid(it); Advance(&it)) {
RawAppendf(buffer, "%.*s\n", FmtString(it.filename)); RawAppendf(buffer, "%.*s\n", FmtString(it.filename));

View File

@@ -1,5 +1,4 @@
- maybe we could allow user to change window titles which would make them special in some way. - maybe we could allow user to change window titles which would make them special in some way.
- decouple buffer magic and directory listing, we want names for directory listers
- dump text editor state to file, restore state - dump text editor state to file, restore state
- help menu popup when for example in process buffer, on tile bar buffer and stuff like that - help menu popup when for example in process buffer, on tile bar buffer and stuff like that