Skip to content

Commit 7423ab5

Browse files
authored
Merge pull request #158 from xscriptor/update/core
update core
2 parents 30398bc + 065ee94 commit 7423ab5

3 files changed

Lines changed: 132 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<p>A cross-platform system information fetching tool inspired by fastfetch and neofetch, written in Rust.</p>
99

1010
<a href="https://imgur.com/iKGpg4h">
11-
<img src="https://i.imgur.com/ihNz93o.gif" width="900" alt="Demo" >
11+
<img src="https://i.imgur.com/DnqIaKB.gif" width="900" alt="Demo" >
1212
</a>
1313

1414

configs/fullconfig.jsonc

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"logo_animation": {
3+
"plugin": "animate-logo",
4+
"style": "frame",
5+
"fps": 60,
6+
"duration_ms": 7500,
7+
"loop": true,
8+
"frames_path": "~/.config/xfetch/logos/decryptfull.txt"
9+
},
10+
"logo_path": "~/.config/xfetch/logos/x.txt",
11+
"layout": "section",
12+
"info_plugins": [
13+
{
14+
"plugin": "github-stats",
15+
"args": {
16+
"username": "xscriptor",
17+
"max-lines": 4
18+
}
19+
},
20+
{
21+
"plugin": "docker"
22+
}
23+
],
24+
"modules": [
25+
{
26+
"type": "group",
27+
"title": "Hardware",
28+
"modules": [
29+
"hostname",
30+
"cpu",
31+
"gpu",
32+
"memory",
33+
"swap",
34+
"disk",
35+
"battery"
36+
]
37+
},
38+
{
39+
"type": "group",
40+
"title": "Software",
41+
"modules": [
42+
"os",
43+
"kernel",
44+
"packages",
45+
"shell",
46+
"wm",
47+
"terminal",
48+
"local_ip",
49+
"plugin:docker"
50+
]
51+
},
52+
{
53+
"type": "group",
54+
"title": "Session",
55+
"modules": [
56+
"user",
57+
"uptime",
58+
"datetime",
59+
"plugin:github-stats"
60+
]
61+
},
62+
"palette"
63+
],
64+
"show_colors": true,
65+
"icons": {
66+
"hostname": "",
67+
"cpu": "",
68+
"gpu": "󰍹",
69+
"memory": "",
70+
"swap": "󰓅",
71+
"disk": "󰋊",
72+
"battery": "",
73+
"os": "",
74+
"kernel": "",
75+
"packages": "",
76+
"shell": "",
77+
"wm": "",
78+
"terminal": "",
79+
"local_ip": "󰩟",
80+
"user": "",
81+
"uptime": "󰔛",
82+
"datetime": "",
83+
"palette": "󰨬",
84+
"hardware": "",
85+
"plugin:docker": "",
86+
"software": "",
87+
"session": "",
88+
"plugin:github-stats": ""
89+
},
90+
"colors": {
91+
"hostname": "Green",
92+
"cpu": "Green",
93+
"gpu": "Green",
94+
"memory": "Green",
95+
"swap": "Green",
96+
"disk": "Green",
97+
"battery": "Green",
98+
"os": "Yellow",
99+
"kernel": "Yellow",
100+
"packages": "Yellow",
101+
"shell": "Yellow",
102+
"wm": "Yellow",
103+
"terminal": "Yellow",
104+
"local_ip": "Yellow",
105+
"user": "Magenta",
106+
"uptime": "Magenta",
107+
"datetime": "Magenta",
108+
"palette": "Magenta",
109+
"plugin:github-stats": "Cyan",
110+
"plugin:docker": "Cyan"
111+
}
112+
}

src/ui/print.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::config::Config;
22
use crate::plugins::AnimationFrame;
33
use crossterm::cursor::{Hide, MoveUp, Show};
4+
use crossterm::terminal::size;
45
use crossterm::style::{Color, Print, ResetColor, SetForegroundColor};
56
use crossterm::terminal::{Clear, ClearType};
67
use crossterm::execute;
@@ -72,17 +73,33 @@ pub fn print_animated_output(
7273
let mut frame_index = 0;
7374
let mut first_frame = true;
7475

76+
let max_content_width = content_lines
77+
.iter()
78+
.map(|l| visible_width(l))
79+
.max()
80+
.unwrap_or(0);
81+
let line_physical_width = max_logo_width + LOGO_INFO_GAP.len() + max_content_width;
82+
let term_width = size().map(|(w, _)| w as usize).unwrap_or(80);
83+
let wraps = (line_physical_width + term_width - 1) / term_width;
84+
let physical_lines = max_lines * std::cmp::max(1, wraps);
85+
let scroll_margin = physical_lines + 4;
86+
7587
let _ = execute!(out, Hide);
7688

89+
for _ in 0..scroll_margin {
90+
let _ = execute!(out, Print("\n"));
91+
}
92+
let _ = execute!(out, MoveUp(scroll_margin as u16));
93+
7794
loop {
7895
let frame = &frames[frame_index];
7996

8097
if !first_frame {
81-
let _ = execute!(out, MoveUp(max_lines as u16));
98+
let _ = execute!(out, MoveUp(scroll_margin as u16));
99+
let _ = execute!(out, Clear(ClearType::FromCursorDown));
82100
}
83101

84102
for i in 0..max_lines {
85-
let _ = execute!(out, Clear(ClearType::CurrentLine));
86103
let ascii_line = frame.lines.get(i).map(|line| line.as_str()).unwrap_or("");
87104
print_logo_line(&mut out, ascii_line, max_logo_width, config, force_plain_logo);
88105
let _ = execute!(out, Print(LOGO_INFO_GAP));

0 commit comments

Comments
 (0)