UX improvements

This commit is contained in:
krzosa
2025-12-29 13:07:28 +01:00
parent c1828a51c4
commit c5afe78b91
3 changed files with 23 additions and 13 deletions

View File

@@ -1545,6 +1545,15 @@ bool BufferIsReferenced(BufferID buffer_id) {
void ReopenBuffer(Buffer *buffer) {
Scratch scratch;
if (buffer->is_dir) {
ResetBuffer(buffer);
RawAppendf(buffer, "..\n");
for (FileIter it = IterateFiles(scratch, buffer->name); IsValid(it); Advance(&it)) {
RawAppendf(buffer, "%S\n", it.filename);
}
return;
}
String string = ReadFile(scratch, buffer->name);
if (string.len == 0) {
return;

View File

@@ -165,6 +165,7 @@ void UIMessagef(const char *fmt, ...) {
JumpTempBuffer(&main);
NextActiveWindowID = main.window->id;
RawAppendf(main.buffer, "\n %S\n :Close\n", string);
main.view->carets[0] = FindNext(main.buffer, u":Close", MakeCaret(0));
AddHook(&main.view->hooks, "Close", "escape", [](){
BSet active = GetBSet(ActiveWindowID);
Close(active.buffer->id);

View File

@@ -200,7 +200,6 @@ void DrawWindow(Window *window, Event &event) {
}
// Underline word under mouse cursor
if (Ctrl()) {
Caret caret = view->carets[0];
Vec2I mouse = MouseVec2I();
bool mouse_in_document = AreOverlapping(mouse, window->document_rect);
@@ -215,6 +214,7 @@ void DrawWindow(Window *window, Event &event) {
}
}
if (Ctrl()) {
if (is_active) {
if (GetSize(caret.range) == 0) {
Range range = EncloseLoadWord(buffer, caret.range.min);