Open and navigate directories
This commit is contained in:
@@ -172,9 +172,13 @@ String GetCurrentBufferName() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String GetCurrentBufferDir() {
|
String GetCurrentBufferDir() {
|
||||||
String buffer_name = GetCurrentBufferName();
|
Window *window = GetWindow(ActiveWindow);
|
||||||
String name = ChopLastSlash(buffer_name);
|
if (window->is_title_bar) {
|
||||||
if (name.len == buffer_name.len) return {};
|
window = GetWindow(window->title_bar_window);
|
||||||
|
}
|
||||||
|
View *view = GetView(window->active_view);
|
||||||
|
Buffer *buffer = GetBuffer(view->active_buffer);
|
||||||
|
String name = buffer->is_directory ? buffer->name : ChopLastSlash(buffer->name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,10 +200,22 @@ Buffer *BufferOpenFile(String path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!FileExists(path)) {
|
if (!FileExists(path)) {
|
||||||
path = Copy(sys_allocator, path);
|
path = GetAbsolutePath(sys_allocator, path);
|
||||||
buffer = CreateBuffer(sys_allocator, path);
|
buffer = CreateBuffer(sys_allocator, path);
|
||||||
|
} else if (IsDir(path)) {
|
||||||
|
path = GetAbsolutePath(sys_allocator, path);
|
||||||
|
buffer = CreateBuffer(sys_allocator, path, 4096 * 2);
|
||||||
|
buffer->is_directory = true;
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
for (FileIter it = IterateFiles(scratch, path); IsValid(it); Advance(&it)) {
|
||||||
|
Appendf(buffer, "%.*s", FmtString(it.filename));
|
||||||
|
if ((i % 8) == 0) Append(buffer, L"\n");
|
||||||
|
else Append(buffer, L" ");
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
path = Copy(sys_allocator, path);
|
path = GetAbsolutePath(sys_allocator, path);
|
||||||
String string = ReadFile(scratch, path);
|
String string = ReadFile(scratch, path);
|
||||||
buffer = CreateBuffer(sys_allocator, path, string.len * 4);
|
buffer = CreateBuffer(sys_allocator, path, string.len * 4);
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ struct Buffer {
|
|||||||
int edit_phase;
|
int edit_phase;
|
||||||
bool no_history;
|
bool no_history;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
|
bool is_directory;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct View {
|
struct View {
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
- search as a command to execute which is going to be in the title bar
|
- search as a command to execute which is going to be in the title bar
|
||||||
- each buffer needs a directory even the special ones: C:\a\b\c\+errors?
|
|
||||||
- open directories - resulting in buffer with dir listing and proper buffer name
|
|
||||||
|
|
||||||
- clean \r\n into \n on trim and load
|
- clean \r\n into \n on trim and load
|
||||||
- search backwards
|
- search backwards
|
||||||
|
|||||||
Reference in New Issue
Block a user