mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
feat: add new scrolloff option to [manager] (#679)
This commit is contained in:
parent
b027487d12
commit
b55c5dc9a1
4 changed files with 12 additions and 5 deletions
|
|
@ -1 +1 @@
|
|||
{"version":"0.2","language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank"]}
|
||||
{"language":"en","flagWords":[],"version":"0.2","words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","️ Überzug","️ Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","imagesize","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff"]}
|
||||
|
|
@ -11,6 +11,7 @@ sort_dir_first = false
|
|||
linemode = "none"
|
||||
show_hidden = false
|
||||
show_symlink = true
|
||||
scrolloff = 5
|
||||
|
||||
[preview]
|
||||
tab_size = 2
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ pub struct Manager {
|
|||
pub linemode: String,
|
||||
pub show_hidden: bool,
|
||||
pub show_symlink: bool,
|
||||
pub scrolloff: u8,
|
||||
}
|
||||
|
||||
impl Default for Manager {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::{mem, time::SystemTime};
|
||||
|
||||
use ratatui::layout::Rect;
|
||||
use yazi_config::LAYOUT;
|
||||
use yazi_config::{LAYOUT, MANAGER};
|
||||
use yazi_shared::fs::{File, FilesOp, Url};
|
||||
|
||||
use super::FolderStage;
|
||||
|
|
@ -108,8 +108,10 @@ impl Folder {
|
|||
let len = self.files.len();
|
||||
|
||||
let limit = LAYOUT.load().current.height as usize;
|
||||
let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize);
|
||||
|
||||
self.cursor = step.add(self.cursor, limit).min(len.saturating_sub(1));
|
||||
self.offset = if self.cursor >= (self.offset + limit).min(len).saturating_sub(5) {
|
||||
self.offset = if self.cursor >= (self.offset + limit).min(len).saturating_sub(scrolloff) {
|
||||
len.saturating_sub(limit).min(self.offset + self.cursor - old.0)
|
||||
} else {
|
||||
self.offset.min(len.saturating_sub(1))
|
||||
|
|
@ -122,8 +124,11 @@ impl Folder {
|
|||
let old = (self.cursor, self.offset);
|
||||
let max = self.files.len().saturating_sub(1);
|
||||
|
||||
self.cursor = step.add(self.cursor, LAYOUT.load().current.height as usize).min(max);
|
||||
self.offset = if self.cursor < self.offset + 5 {
|
||||
let limit = LAYOUT.load().current.height as usize;
|
||||
let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize);
|
||||
|
||||
self.cursor = step.add(self.cursor, limit).min(max);
|
||||
self.offset = if self.cursor < self.offset + scrolloff {
|
||||
self.offset.saturating_sub(old.0 - self.cursor)
|
||||
} else {
|
||||
self.offset.min(max)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue