Buffer directories design change

This commit is contained in:
Krzosa Karol
2025-12-25 12:08:49 +01:00
parent 2f638c731a
commit 5c46844747
5 changed files with 18 additions and 20 deletions

View File

@@ -1,8 +1,8 @@
- What precise workflow do I need for me to be viable to use this?
- From a user (novice) point of view, how does it look like?
- build console window
- Use WorkDir (raname to Workspace?) to shorten file names
- Show what process/coroutines are running and allow to kill (active process buffer?)
- Database idea: use special buffers to store information
- Editing the buffer doesn't seem to be the slow part rather, accessing the data and putting it into the buffer (potentially hitting many different memory locations) I have a crazy idea to use buffers in order to store the names in a serialized format
@@ -19,10 +19,11 @@ Commands TODO:
- CONSIDER AUTOMATING: CheckpointBeforeGoto
- GotoBackward how to handle that in case we want to automate and create on every move?
- Add jump checkpoints
- Make sure the timing window works forward and backward in undo and jump
backlog
ISSUE Ctrl+Alt+Down (DuplicateLine) doesn't work on ubuntu
FEATURE Search whole words, case sensitive etc.
FEATURE Select all searched occurences
FEATURE commands for scrolling: center, cursor_at_bottom_of_screen, cursor_at_top

View File

@@ -1505,8 +1505,8 @@ Buffer *BufferOpenFile(String path) {
if (!FileExists(path)) {
buffer = CreateBuffer(sys_allocator, path);
} else if (IsDir(path)) {
ReportWarningf("failed to open, it's a directory: %S", path);
return GetBuffer(NullBufferID);
buffer = CreateBuffer(sys_allocator, path);
buffer->is_dir = true;
} else {
String string = ReadFile(scratch, path);
buffer = CreateBuffer(sys_allocator, path, string.len * 4 + 4096);

View File

@@ -43,6 +43,7 @@ struct Buffer {
unsigned dont_try_to_save_in_bulk_ops : 1;
unsigned close : 1;
unsigned special : 1;
unsigned is_dir : 1;
};
};

View File

@@ -19,20 +19,17 @@ BSet GetConsoleSet() {
return result;
}
String GetCurrentFilename() {
BSet main = GetBSet(LastActiveLayoutWindowID);
return main.buffer->name;
}
String GetDir(Buffer *buffer) {
String name = ChopLastSlash(buffer->name);
return name;
if (buffer->is_dir) {
return buffer->name;
} else {
return ChopLastSlash(buffer->name);
}
}
String GetMainDir() {
BSet main = GetBSet(LastActiveLayoutWindowID);
String name = ChopLastSlash(main.buffer->name);
return name;
return GetDir(main.buffer);
}
void JumpGarbageBuffer(BSet *set, String buffer_name = "") {
@@ -618,10 +615,13 @@ BSet Open(Window *window, String path, String meta, bool set_active = true) {
ActiveWindowID = set.window->id;
}
if (IsDir(o.path)) {
JumpGarbageBuffer(&set, GetUniqueBufferName(o.path, "temp", ".dirlisting"));
Appendf(set.view, "..\n");
CheckpointBeforeGoto(set.window);
View *view = WindowOpenBufferView(set.window, o.path);
Buffer *buffer = GetBuffer(view->active_buffer);
ResetBuffer(buffer);
RawAppendf(buffer, "..\n");
for (FileIter it = IterateFiles(scratch, o.path); IsValid(it); Advance(&it)) {
Appendf(set.view, "%S\n", it.filename);
RawAppendf(buffer, "%S\n", it.filename);
}
} else {
CheckpointBeforeGoto(set.window);
@@ -857,9 +857,6 @@ void Command_GotoForward() {
void Command_OpenUpFolder() {
BSet main = GetBSet(LastActiveLayoutWindowID);
String name = ChopLastSlash(main.buffer->name);
if (EndsWith(main.buffer->name, "dirlisting")) {
name = ChopLastSlash(name);
}
Open(name);
} RegisterCommand(Command_OpenUpFolder, "ctrl-period");

View File

@@ -42,7 +42,6 @@
#include "draw.cpp"
#include "test/tests.cpp"
#if OS_WASM
EM_JS(void, JS_SetMouseCursor, (const char *cursor_str), {
document.getElementById("canvas").style.cursor = UTF8ToString(cursor_str);