diff --git a/src/backup/todo.txt b/src/backup/todo.txt index 291323b..2a73081 100644 --- a/src/backup/todo.txt +++ b/src/backup/todo.txt @@ -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 diff --git a/src/text_editor/buffer.cpp b/src/text_editor/buffer.cpp index 3db7cc9..b1078a1 100644 --- a/src/text_editor/buffer.cpp +++ b/src/text_editor/buffer.cpp @@ -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); diff --git a/src/text_editor/buffer.h b/src/text_editor/buffer.h index dec92b6..af9a8f1 100644 --- a/src/text_editor/buffer.h +++ b/src/text_editor/buffer.h @@ -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; }; }; diff --git a/src/text_editor/commands.cpp b/src/text_editor/commands.cpp index 23f2006..61f2e74 100644 --- a/src/text_editor/commands.cpp +++ b/src/text_editor/commands.cpp @@ -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"); diff --git a/src/text_editor/text_editor.cpp b/src/text_editor/text_editor.cpp index 4228faa..aca9486 100644 --- a/src/text_editor/text_editor.cpp +++ b/src/text_editor/text_editor.cpp @@ -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);