~leon_plickat/nfm

nfm: Rename UIMode.nav to UIMode.normal v2 PROPOSED

Hugo Machet: 1
 Rename UIMode.nav to UIMode.normal

 6 files changed, 33 insertions(+), 34 deletions(-)
#915054 alpine.yml failed
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~leon_plickat/nfm/patches/37888/mbox | git am -3
Learn more about email & git

[PATCH nfm v2] Rename UIMode.nav to UIMode.normal Export this patch

Rename UIMode.setNav() to UIMode.setNormal();
---
v1 -> v2:
  Rebase against master

 src/Context.zig               | 28 ++++++++++++++--------------
 src/UserInterface.zig         |  2 +-
 src/key-operations/cursor.zig |  8 ++++----
 src/key-operations/marks.zig  |  6 +++---
 src/key-operations/misc.zig   | 12 ++++++------
 src/mode.zig                  | 11 +++++------
 6 files changed, 33 insertions(+), 34 deletions(-)

diff --git a/src/Context.zig b/src/Context.zig
index 4f2342628e43..05a17f0758f7 100644
--- a/src/Context.zig
+++ b/src/Context.zig
@@ -47,7 +47,7 @@ dirmap: DirMap = undefined,
initial_cwd_path: []const u8 = undefined,

view: View = .nav,
ui_mode: UIMode = .nav,
ui_mode: UIMode = .normal,
completion_count: ?usize = null,
selector_mode: bool = false,
dump_cwd: bool = false,
@@ -136,7 +136,7 @@ pub fn run(self: *Self, command: [:0]const u8, comptime name: []const u8) !void
            self.ui_mode.setMessage(.err, "Invalid command");
            return;
        }) orelse {
            self.ui_mode.setNav();
            self.ui_mode.setNormal();
            self.ui.list_dirty = true;
            return;
        };
@@ -158,7 +158,7 @@ pub fn run(self: *Self, command: [:0]const u8, comptime name: []const u8) !void
            }

            try self.setCwd(arg);
            if (self.ui_mode != .message) self.ui_mode.setNav();
            if (self.ui_mode != .message) self.ui_mode.setNormal();
            self.ui.list_dirty = true;
            return;
        } else if (mem.eql(u8, token, "quit")) {
@@ -179,7 +179,7 @@ pub fn run(self: *Self, command: [:0]const u8, comptime name: []const u8) !void

    const ret = system.execForeground(command);

    self.ui_mode.setNav();
    self.ui_mode.setNormal();
    try self.ui.start();

    ret catch |err| switch (err) {
@@ -265,7 +265,7 @@ pub fn select(self: *Self, str: []const u8) !void {
        }
    }
    if (mark) {
        self.ui_mode.setNav();
        self.ui_mode.setNormal();
    } else {
        self.ui_mode.setMessage(.err, "No match");
    }
@@ -301,7 +301,7 @@ pub fn keep(self: *Self, str: []const u8) !void {
        }
    }
    if (mark) {
        self.ui_mode.setNav();
        self.ui_mode.setNormal();
    } else {
        self.ui_mode.setMessage(.err, "No marked files in this directory");
    }
@@ -337,7 +337,7 @@ pub fn discard(self: *Self, str: []const u8) !void {
        }
    }
    if (mark) {
        self.ui_mode.setNav();
        self.ui_mode.setNormal();
    } else {
        self.ui_mode.setMessage(.err, "No marked files in this directory");
    }
@@ -365,7 +365,7 @@ pub fn search(self: *Self, str: []const u8) !void {
/// Called by event loop implementation.
pub fn handleSpoonInput(self: *Self, in: spoon.Input) !void {
    switch (self.ui_mode) {
        .nav, .message => try self.handleSpoonInputNav(in),
        .normal, .message => try self.handleSpoonInputNav(in),
        .user_input => try self.handleSpoonInputUserInput(in),
    }
}
@@ -417,7 +417,7 @@ fn handleSpoonInputUserInput(self: *Self, in: spoon.Input) !void {
            try self.handleReturnUserInput();
            return;
        } else if (in.eqlDescription("escape")) {
            self.ui_mode.setNav();
            self.ui_mode.setNormal();
            return;
        }

@@ -442,7 +442,7 @@ fn handleSpoonInputUserInput(self: *Self, in: spoon.Input) !void {
    } else if (in.eqlDescription("C-n")) {
        self.history.indexDown();
    } else if (in.eqlDescription("C-c") or in.eqlDescription("C-g")) {
        self.ui_mode.setNav();
        self.ui_mode.setNormal();
    } else if (in.eqlDescription("C-a")) {
        buffer.moveCursorToStart();
    } else if (in.eqlDescription("C-e")) {
@@ -490,7 +490,7 @@ fn handleSpoonInputUserInput(self: *Self, in: spoon.Input) !void {
            else => {},
        }
    } else if (in.eqlDescription("escape")) {
        self.ui_mode.setNav();
        self.ui_mode.setNormal();
    } else if (in.eqlDescription("arrow-left")) {
        buffer.moveCursorOneBackward();
    } else if (in.eqlDescription("arrow-right")) {
@@ -615,7 +615,7 @@ fn handleMouseClickNav(self: *Self, in: spoon.Input) !void {
            }
        } else {
            fdv.setCursor(selected_cursor);
            if (self.ui_mode != .user_input) self.ui_mode.setNav();
            if (self.ui_mode != .user_input) self.ui_mode.setNormal();
        }
    } else {
        const scroll_offset = dv.getScrollOffset(dv.height);
@@ -632,7 +632,7 @@ fn handleMouseClickNav(self: *Self, in: spoon.Input) !void {
        } else {
            dv.setCursor(selected_cursor);
            try self.dirmap.setCwdRaw(dv.dir.name);
            self.ui_mode.setNav();
            self.ui_mode.setNormal();
        }
    }

@@ -660,7 +660,7 @@ fn handleMouseClickFs(self: *Self, in: spoon.Input) !void {
        }
    } else {
        self.view.setCursor(selected_cursor);
        if (self.ui_mode != .user_input) self.ui_mode.setNav();
        if (self.ui_mode != .user_input) self.ui_mode.setNormal();
    }

    self.ui.list_dirty = true;
diff --git a/src/UserInterface.zig b/src/UserInterface.zig
index 2d8660a78724..ab748ae0e1c5 100644
--- a/src/UserInterface.zig
+++ b/src/UserInterface.zig
@@ -353,7 +353,7 @@ fn drawTitle(self: *Self, rc: *spoon.Term.RenderContext, title: []const u8) !voi
            try writer.writeAll(context.ui_mode.message.message);
            try rpw.pad();
        },
        .nav => {
        .normal => {
            try rc.setAttribute(context.config.theme.getAttribute("title", .{}));
            if (indicator) |indctr| {
                debug.assert(indctr.len < min_width);
diff --git a/src/key-operations/cursor.zig b/src/key-operations/cursor.zig
index dada4615b6a4..c9f748ab05b7 100644
--- a/src/key-operations/cursor.zig
+++ b/src/key-operations/cursor.zig
@@ -53,7 +53,7 @@ pub fn cursorMoveToNextMatch(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();

    const search = blk: {
        if (context.active_search) |*search| break :blk search;
@@ -105,7 +105,7 @@ pub fn cursorMoveToNextMark(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();

    const fdv = context.dirmap.focusedDirView() orelse {
        context.ui_mode.setMessage(.err, "No files");
@@ -164,7 +164,7 @@ fn moveCursor(i: isize) void {
    // We need to take some care here, because cursor movement can also be
    // caused while in user input mode.
    if (context.ui_mode != .user_input) {
        context.ui_mode.setNav();
        context.ui_mode.setNormal();
    }
    switch (context.view) {
        .nav => if (context.dirmap.focusedDirView()) |fdv| fdv.moveCursor(i),
@@ -174,7 +174,7 @@ fn moveCursor(i: isize) void {
}

fn setCursor(i: usize) void {
    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    switch (context.view) {
        .nav => if (context.dirmap.focusedDirView()) |fdv| fdv.setCursor(i),
        else => context.view.setCursor(i),
diff --git a/src/key-operations/marks.zig b/src/key-operations/marks.zig
index 1e424a166a98..e80e00ea823c 100644
--- a/src/key-operations/marks.zig
+++ b/src/key-operations/marks.zig
@@ -28,7 +28,7 @@ pub fn markFileAtCursor(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    const file = context.dirmap.getCursorSelectedFile() orelse return;
    file.mark = !file.mark;
    context.ui.list_dirty = true;
@@ -40,7 +40,7 @@ pub fn invertMarks(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    const fdv = context.dirmap.focusedDirView() orelse return;
    for (fdv.visible_files.items) |file| file.mark = !file.mark;
    context.ui.list_dirty = true;
@@ -52,7 +52,7 @@ pub fn clearMarks(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();

    // If this has been called two times with a delay of less than a second,
    // clear all marks.
diff --git a/src/key-operations/misc.zig b/src/key-operations/misc.zig
index f35f4f4ec1f6..6c3374ed8b6e 100644
--- a/src/key-operations/misc.zig
+++ b/src/key-operations/misc.zig
@@ -37,7 +37,7 @@ pub fn enterParentDir(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    try context.setCwd("..");
}

@@ -47,7 +47,7 @@ pub fn jumpBack(_: *const KeyOperation) !void {
        return;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    try context.setCwd(context.initial_cwd_path);
    context.ui.list_dirty = true;
}
@@ -75,7 +75,7 @@ fn run(op: *const KeyOperation, foreground: bool) !void {
}

pub fn toggleViewFileSystems(_: *const KeyOperation) !void {
    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    switch (context.view) {
        .fs => context.view.setNav(),
        else => try context.view.setFs(),
@@ -83,7 +83,7 @@ pub fn toggleViewFileSystems(_: *const KeyOperation) !void {
}

pub fn toggleViewBookmarks(_: *const KeyOperation) !void {
    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    switch (context.view) {
        .bm => context.view.setNav(),
        else => context.view.setBm(),
@@ -91,7 +91,7 @@ pub fn toggleViewBookmarks(_: *const KeyOperation) !void {
}

pub fn setViewFiles(_: *const KeyOperation) !void {
    context.ui_mode.setNav();
    context.ui_mode.setNormal();
    if (context.view != .nav) context.view.setNav();
}

@@ -125,7 +125,7 @@ fn getFormattedBuffer(op: *const KeyOperation) !?[:0]const u8 {
        return null;
    }

    context.ui_mode.setNav();
    context.ui_mode.setNormal();

    return format.ownedSliceZFromFormat(op.payload.fmt.?) catch |err| switch (err) {
        error.NoSelection => {
diff --git a/src/mode.zig b/src/mode.zig
index 3a5dab3322fe..55154dc07e37 100644
--- a/src/mode.zig
+++ b/src/mode.zig
@@ -44,8 +44,7 @@ pub const UIMode = union(enum) {
    const Self = @This();

    /// Nav mode: Normal title bar, keys map to user defined keybinds.
    /// TODO rename to "normal", because nav is also taken in View
    nav: void,
    normal: void,

    /// Message mode: Message in title bar, keys map to user defined keybinds.
    message: struct {
@@ -61,11 +60,11 @@ pub const UIMode = union(enum) {
        history_index: ?usize,
    },

    pub fn setNav(self: *Self) void {
        if (self.* == .nav) return;
        logger.debug("nav mode", .{});
    pub fn setNormal(self: *Self) void {
        if (self.* == .normal) return;
        logger.debug("normal mode", .{});
        self.reset();
        self.* = .nav;
        self.* = .normal;
    }

    pub fn setMessage(self: *Self, comptime level: MessageLevel, comptime message: []const u8) void {
-- 
2.39.0
nfm/patches/alpine.yml: FAILED in 21s

[Rename UIMode.nav to UIMode.normal][0] v2 from [Hugo Machet][1]

[0]: https://lists.sr.ht/~leon_plickat/nfm/patches/37888
[1]: mailto:mail@hmachet.com

✗ #915054 FAILED nfm/patches/alpine.yml https://builds.sr.ht/~leon_plickat/job/915054