sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
12.43k stars 289 forks source link

theme.toml: No reserved words for `[status] information = { fg = "", bg = "" }` #952

Closed Zeioth closed 2 weeks ago

Zeioth commented 2 months ago

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

foot version: 1.17.2 +pgo +ime +graphemes -assertions

Did you try the latest code to see if this problem got fixed?

Tried, but the problem still

yazi --debug output

debug ```sh Yazi Version: 0.2.5 (Arch Linux 2024-04-24) OS: linux-x86_64 (unix) Debug: false Emulator Emulator.via_env: ("xterm-256color", "") Emulator.via_csi: Ok(Foot) Emulator.detect: Foot Adaptor Adaptor.matches: Sixel Desktop XDG_SESSION_TYPE: Some("wayland") WAYLAND_DISPLAY: Some("wayland-1") DISPLAY: Some(":0") SSH shared.in_ssh_connection: false WSL /proc/sys/fs/binfmt_misc/WSLInterop: false Variables SHELL: Some("/usr/bin/zsh") EDITOR: Some("nvim") ZELLIJ_SESSION_NAME: None YAZI_FILE_ONE: None YAZI_CONFIG_HOME: None file(1) Version: Ok(Output { status: ExitStatus(unix_wait_status(0)), stdout: "file-5.45\nmagic file from /usr/share/file/misc/magic\nseccomp support included\n", stderr: "" }) Text Opener default: Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true }) block: Some(Opener { run: "${EDITOR:=vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true }) tmux TMUX: false Ueberzug++ Version: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" }) ```
log ``` 2024-04-25T17:40:02.462545Z WARN yazi_adaptor::emulator: [Adaptor] No special environment variables detected at yazi-adaptor/src/emulator.rs:66 2024-04-25T17:40:02.462556Z WARN yazi_adaptor::emulator: [Adaptor] Unknown TERM_PROGRAM: at yazi-adaptor/src/emulator.rs:80 2024-04-25T17:40:02.462557Z WARN yazi_adaptor::emulator: [Adaptor] Unknown TERM: xterm-256color at yazi-adaptor/src/emulator.rs:87 2024-04-25T17:40:02.499731Z ERROR yazi_plugin::utils::log: "spawn `ffmpegthumbnailer` command returns 2" at yazi-plugin/src/utils/log.rs:20 2024-04-25T17:40:02.499784Z ERROR yazi_scheduler::preload::preload: Preload task `video` returned 0 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.500318Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.501297Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.502996Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.504028Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.504738Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.504991Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.505315Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.506029Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.506379Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 2024-04-25T17:40:02.506532Z ERROR yazi_scheduler::preload::preload: Preload task `image` returned 2 at yazi-scheduler/src/preload/preload.rs:42 ```

Describe the bug

The foreground color of theme.toml > separator_style seems to be ignored.

 [status]
 separator_style = { fg = "#ffffff" }

If we try to set it to red screenshot_2024-04-25_19-37-49_094409845

Only the background is affected, the foreground is ignored. screenshot_2024-04-25_19-37-31_407510390

Expected Behavior

The foreground color specified in theme.toml is applied.

To Reproduce

Copy this on theme.toml

[status]
separator_style = { fg = "red", bg = "red" }

Configuration

No response

Anything else?

No response

sxyazi commented 2 months ago

Hi, this is the expected behavior.

The bg of separator_style is used to control the "inner" area, while fg is used to control the "outer" area:

CleanShot 2024-04-26 at 14 50 17

https://github.com/sxyazi/yazi/blob/2febbee59555178f9d00315b3f1bba81b0af3165/yazi-plugin/preset/components/status.lua#L35-L38

Perhaps we can explore changing this behavior, but I'm not sure if there's a better way to achieve the current effect while also providing greater flexibility. Curious your thoughts!

Zeioth commented 2 months ago

Thank you for referencing the lua code. I've been able to fix it by changing the lines with style.bg by THEME.status.separator_style.fg

screenshot_2024-04-29_19-36-03_420718881

Because I'm not using separators, in my case this is a good solution.

Zeioth commented 2 months ago

But yeah we probably want to have reserved words for this in yazi.toml instead of reusing existing ones such as

[status]
size = { fg = "#c6d0f5", bg = "#414868" }
percentage = { fg = "#c6d0f5", bg = "#414868" }

or alternatively just

[status]
information = { fg = "#c6d0f5", bg = "#414868" }
sxyazi commented 2 months ago

I don't really want to use specific names like "size" or "percentage" to name them, because some users don't need to display size and percentage, and instead replace them with other content by rewriting the UI. At this point, "size" is no longer applicable. Is there a more abstract name available?

Zeioth commented 2 months ago

Then I would suggest grouping both (size and %) like

[status]
# this line would control the colors of the inner pills (by default, size and %)
information = { fg = "#c6d0f5", bg = "#414868" }

In the same way we currently group mode and line_number under mode_normal = { fg = "", bg = "" }.

Zeioth commented 2 months ago

Maybe you prefer another most descriptive name instead like inner_pills. That's up to your criteria.

kohane27 commented 2 months ago

@Zeioth Apologies for the noise. But how did you make the border work for 2 panes? The code at full-border only works for 3 borders and I can't make it work for 2 panes. Thanks in advance!

Zeioth commented 1 month ago

@kohane27 is just a modified version of the example you have in the docs

Paste this on your init.lua and you will see the borders optimized for 2 columns:

function Manager:render(area)
    local chunks = self:layout(area)

    local bar = function(c, x, y)
        x, y = math.max(0, x), math.max(0, y)
        return ui.Bar(ui.Rect({ x = x, y = y, w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) }), ui.Bar.TOP)
                :symbol(c)
    end

    return ya.flat({
        -- Borders
        ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED),
        ui.Bar(chunks[1], ui.Bar.RIGHT),
        ui.Bar(chunks[3], ui.Bar.LEFT),

        -- Left vertical bar
        bar("┌", chunks[1].right - 1, chunks[1].y),
        bar("└", chunks[1].right - 1, chunks[1].bottom - 1),

        -- Central vertical bar
        bar("┬", chunks[2].right, chunks[2].y),
        bar("┴", chunks[2].right, chunks[1].bottom - 1),

        -- Right vertical bar
        bar("┐", chunks[3].right - 1, chunks[3].y),
        bar("┘", chunks[3].right - 1, chunks[1].bottom - 1),

        -- Parent
        Parent:render(chunks[1]:padding(ui.Padding.xy(1))),
        -- Current
        Current:render(chunks[2]:padding(ui.Padding.xy(1))),
        -- Preview
        Preview:render(chunks[3]:padding(ui.Padding.xy(1))),
    })
end

You also need this on your yazi.toml

[manager]
ratio          = [ 0, 4, 8 ]
imsi32 commented 2 weeks ago

I think I misunderstand the place for the discussion thus I am recommenting things in https://github.com/sxyazi/yazi/issues/1228#issuecomment-2196192386 and https://github.com/sxyazi/yazi/issues/1228#issuecomment-2196248087:

I will be glad if I can be any help. I think it will be good to divide that secondary area from mode area. Because it is connected with the mode area, adding normal, set and unset properties for that secondary area will be necessary.

Moreover, I think the main issue is with the separators as it has not already been using its style in separator close to the mode area. There are few things that can be done: """

  1. Straightforward option, adding each and every possible to its own style which means for 3 mode, 2 area and 2 side, there will be total of 12 style.
  1. If sides (open and close) considered as a one in style section, it will reduce the total of styles to 6.

  2. If mode area's separators left as it is, there wouldn't need for that area's separator with styles. Thus, it will reduce the total of styles to 3. More specifically, secondary area's normal, set and unset mode's separators.

  3. If secondary area's separators styles works like the current mode area's separators style, separators will not need style properties.

  4. Another approach is adding properties for separator. If some properties like separator_follow_mode and separator_follow_secondary which are take boolean values exist, they can be used as a bridge between 4th option and 1st or 2nd option.

  5. If the modes are not considered it can greatly reduce the number of styles needed. Which means the other options can be applied without considering following modes styles.

    """ In the end, I would recommend 4th because it is simplest one and will fill the needs for nearly all users. For comparing with lualine, I couldn't find a way to specifically set a unique color to separators. From what I understand it uses the component which are connected with it similar to the 4th option.

And for the color choosing, I would recommend using black as in terminal 16 colors in main area's foreground color and secondary area's background color as default. That's because unless user use light theme, it will be really best option. However, if the user selected their background color as black, the secondary area will mixed with the background. Also, it cannot have bright blue color because I checked some color schemes in here and I saw that most of the bright black color is not good with colors. Thus, I tried some colors in lualine with gruvbox color scheme and I think using black in both area's foreground, bright white in secondary area's background and mode area's background color as currently mode colors. It will be similar to this:

blue_white_black

sxyazi commented 2 weeks ago

Let's reopen that issue and close this since that has a better description.