Skip to content

Commit c8bf2c5

Browse files
authored
refactor: prefer WriteConsoleW for Windows console output (#2464)
1 parent 22980cf commit c8bf2c5

File tree

16 files changed

+283
-71
lines changed

16 files changed

+283
-71
lines changed

Cargo.lock

Lines changed: 12 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ parking_lot = "0.12.3"
3535
ratatui = { version = "0.29.0", features = [ "unstable-rendered-line-info" ] }
3636
regex = "1.11.1"
3737
scopeguard = "1.2.0"
38-
serde = { version = "1.0.218", features = [ "derive" ] }
38+
serde = { version = "1.0.219", features = [ "derive" ] }
3939
serde_json = "1.0.140"
4040
tokio = { version = "1.44.0", features = [ "full" ] }
4141
tokio-stream = "0.1.17"

cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"0.2","language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","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","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","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","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin"]}
1+
{"version":"0.2","language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","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","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","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","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition"],"flagWords":[]}

yazi-adapter/src/drivers/chafa.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ impl Chafa {
5555

5656
Adapter::Chafa.image_hide()?;
5757
Adapter::shown_store(area);
58-
Emulator::move_lock((max.x, max.y), |stderr| {
58+
Emulator::move_lock((max.x, max.y), |w| {
5959
for (i, line) in lines.into_iter().enumerate() {
60-
stderr.write_all(line)?;
61-
queue!(stderr, MoveTo(max.x, max.y + i as u16 + 1))?;
60+
w.write_all(line)?;
61+
queue!(w, MoveTo(max.x, max.y + i as u16 + 1))?;
6262
}
6363
Ok(area)
6464
})
6565
}
6666

6767
pub(crate) fn image_erase(area: Rect) -> Result<()> {
6868
let s = " ".repeat(area.width as usize);
69-
Emulator::move_lock((0, 0), |stderr| {
69+
Emulator::move_lock((0, 0), |w| {
7070
for y in area.top()..area.bottom() {
71-
queue!(stderr, MoveTo(area.x, y))?;
72-
write!(stderr, "{s}")?;
71+
queue!(w, MoveTo(area.x, y))?;
72+
write!(w, "{s}")?;
7373
}
7474
Ok(())
7575
})

yazi-adapter/src/drivers/iip.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ impl Iip {
1919

2020
Adapter::Iip.image_hide()?;
2121
Adapter::shown_store(area);
22-
Emulator::move_lock((max.x, max.y), |stderr| {
23-
stderr.write_all(&b)?;
22+
Emulator::move_lock((max.x, max.y), |w| {
23+
w.write_all(&b)?;
2424
Ok(area)
2525
})
2626
}
2727

2828
pub(crate) fn image_erase(area: Rect) -> Result<()> {
2929
let s = " ".repeat(area.width as usize);
30-
Emulator::move_lock((0, 0), |stderr| {
30+
Emulator::move_lock((0, 0), |w| {
3131
for y in area.top()..area.bottom() {
32-
queue!(stderr, MoveTo(area.x, y))?;
33-
write!(stderr, "{s}")?;
32+
queue!(w, MoveTo(area.x, y))?;
33+
write!(w, "{s}")?;
3434
}
3535
Ok(())
3636
})

yazi-adapter/src/drivers/kgp.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,22 +321,22 @@ impl Kgp {
321321

322322
Adapter::Kgp.image_hide()?;
323323
Adapter::shown_store(area);
324-
Emulator::move_lock((area.x, area.y), |stderr| {
325-
stderr.write_all(&b1)?;
326-
stderr.write_all(&b2)?;
324+
Emulator::move_lock((area.x, area.y), |w| {
325+
w.write_all(&b1)?;
326+
w.write_all(&b2)?;
327327
Ok(area)
328328
})
329329
}
330330

331331
pub(crate) fn image_erase(area: Rect) -> Result<()> {
332332
let s = " ".repeat(area.width as usize);
333-
Emulator::move_lock((0, 0), |stderr| {
333+
Emulator::move_lock((0, 0), |w| {
334334
for y in area.top()..area.bottom() {
335-
queue!(stderr, MoveTo(area.x, y))?;
336-
write!(stderr, "{s}")?;
335+
queue!(w, MoveTo(area.x, y))?;
336+
write!(w, "{s}")?;
337337
}
338338

339-
write!(stderr, "{START}_Gq=2,a=d,d=A{ESCAPE}\\{CLOSE}")?;
339+
write!(w, "{START}_Gq=2,a=d,d=A{ESCAPE}\\{CLOSE}")?;
340340
Ok(())
341341
})
342342
}

yazi-adapter/src/drivers/kgp_old.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ impl KgpOld {
1919

2020
Adapter::KgpOld.image_hide()?;
2121
Adapter::shown_store(area);
22-
Emulator::move_lock((area.x, area.y), |stderr| {
23-
stderr.write_all(&b)?;
22+
Emulator::move_lock((area.x, area.y), |w| {
23+
w.write_all(&b)?;
2424
Ok(area)
2525
})
2626
}

yazi-adapter/src/drivers/sixel.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ impl Sixel {
1919

2020
Adapter::Sixel.image_hide()?;
2121
Adapter::shown_store(area);
22-
Emulator::move_lock((area.x, area.y), |stderr| {
23-
stderr.write_all(&b)?;
22+
Emulator::move_lock((area.x, area.y), |w| {
23+
w.write_all(&b)?;
2424
Ok(area)
2525
})
2626
}
2727

2828
pub(crate) fn image_erase(area: Rect) -> Result<()> {
2929
let s = " ".repeat(area.width as usize);
30-
Emulator::move_lock((0, 0), |stderr| {
30+
Emulator::move_lock((0, 0), |w| {
3131
for y in area.top()..area.bottom() {
32-
queue!(stderr, MoveTo(area.x, y))?;
33-
write!(stderr, "{s}")?;
32+
queue!(w, MoveTo(area.x, y))?;
33+
write!(w, "{s}")?;
3434
}
3535
Ok(())
3636
})

yazi-codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ proc-macro = true
1313

1414
[dependencies]
1515
# External dependencies
16-
syn = { version = "2.0.99", features = [ "full" ] }
16+
syn = { version = "2.0.100", features = [ "full" ] }
1717
quote = "1.0.39"

yazi-core/src/mgr/commands/bulk_rename.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ impl Mgr {
6666

6767
{
6868
let mut w = TTY.lockout();
69-
for (o, n) in &todo {
70-
writeln!(w, "{} -> {}", o.display(), n.display())?;
69+
for (old, new) in &todo {
70+
writeln!(w, "{} -> {}", old.display(), new.display())?;
7171
}
7272
write!(w, "Continue to rename? (y/N): ")?;
7373
w.flush()?;

0 commit comments

Comments
 (0)