Merge pull request #158 from TheDarkBug/revert-157-revert-156-zeng-feat-responsive_width
Revert "Revert "feat: responsively print width"" because I am stupid
This commit is contained in:
commit
4724d1fac3
1 changed files with 48 additions and 24 deletions
70
uwufetch.c
70
uwufetch.c
|
@ -355,44 +355,65 @@ int uptime_freebsd()
|
||||||
|
|
||||||
void print_info()
|
void print_info()
|
||||||
{
|
{
|
||||||
|
#define responsively_printf(buf, format, ...) { \
|
||||||
|
sprintf(buf, format, __VA_ARGS__); \
|
||||||
|
printf("%.*s\n", win.ws_col-1, buf); \
|
||||||
|
}
|
||||||
|
char print_buf[255]; // for responsively print
|
||||||
|
|
||||||
// print collected info - from host to cpu info
|
// print collected info - from host to cpu info
|
||||||
printf("\033[9A"); // to align info text
|
printf("\033[9A"); // to align info text
|
||||||
if (show_user_info)
|
if (show_user_info) {
|
||||||
printf("\033[18C%s%s%s@%s\n", NORMAL, BOLD, user, host);
|
responsively_printf(print_buf, "\033[18C%s%s%s@%s", NORMAL, BOLD, user, host);
|
||||||
|
}
|
||||||
uwu_name();
|
uwu_name();
|
||||||
if (show_os)
|
if (show_os) {
|
||||||
printf("\033[18C%s%sOWOS %s%s\n", NORMAL, BOLD, NORMAL, version_name);
|
responsively_printf(print_buf, "\033[18C%s%sOWOS %s%s", NORMAL, BOLD, NORMAL, version_name);
|
||||||
if (show_host)
|
}
|
||||||
printf("\033[18C%s%sHOWOST %s%s\n", NORMAL, BOLD, NORMAL, host_model);
|
if (show_host) {
|
||||||
if (show_kernel)
|
responsively_printf(print_buf, "\033[18C%s%sHOWOST %s%s", NORMAL, BOLD, NORMAL, host_model);
|
||||||
printf("\033[18C%s%sKEWNEL %s%s\n", NORMAL, BOLD, NORMAL, kernel);
|
}
|
||||||
if (show_cpu)
|
if (show_kernel) {
|
||||||
printf("\033[18C%s%sCPUWU %s%s\n", NORMAL, BOLD, NORMAL, cpu_model);
|
responsively_printf(print_buf, "\033[18C%s%sKEWNEL %s%s", NORMAL, BOLD, NORMAL, kernel);
|
||||||
|
}
|
||||||
|
if (show_cpu) {
|
||||||
|
responsively_printf(print_buf, "\033[18C%s%sCPUWU %s%s", NORMAL, BOLD, NORMAL, cpu_model);
|
||||||
|
}
|
||||||
|
|
||||||
// print the gpus
|
// print the gpus
|
||||||
if (show_gpu)
|
if (show_gpu) {
|
||||||
for (int i = 0; gpu_model[i][0]; i++)
|
for (int i = 0; gpu_model[i][0]; i++)
|
||||||
printf("\033[18C%s%sGPUWU %s%s\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sGPUWU %s%s",
|
||||||
NORMAL, BOLD, NORMAL, gpu_model[i]);
|
NORMAL, BOLD, NORMAL, gpu_model[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// print ram to uptime and colors
|
// print ram to uptime and colors
|
||||||
if (show_ram)
|
if (show_ram) {
|
||||||
printf("\033[18C%s%sWAM %s%i MiB/%i MiB\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sWAM %s%i MiB/%i MiB",
|
||||||
NORMAL, BOLD, NORMAL, (ram_used), ram_total);
|
NORMAL, BOLD, NORMAL, (ram_used), ram_total);
|
||||||
|
}
|
||||||
if (show_resolution)
|
if (show_resolution)
|
||||||
if (screen_width != 0 || screen_height != 0)
|
if (screen_width != 0 || screen_height != 0) {
|
||||||
printf("\033[18C%s%sRESOWUTION%s %dx%d\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sRESOWUTION%s %dx%d",
|
||||||
NORMAL, BOLD, NORMAL, screen_width, screen_height);
|
NORMAL, BOLD, NORMAL, screen_width, screen_height);
|
||||||
if (show_shell)
|
}
|
||||||
printf("\033[18C%s%sSHEWW %s%s\n",
|
if (show_shell) {
|
||||||
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sSHEWW %s%s",
|
||||||
NORMAL, BOLD, NORMAL, shell);
|
NORMAL, BOLD, NORMAL, shell);
|
||||||
|
}
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
if (show_pkgs)
|
if (show_pkgs)
|
||||||
system("ls $(brew --cellar) | wc -l | awk -F' ' '{print \" \x1b[34mw w \x1b[0m\x1b[1mPKGS\x1b[0m \"$1 \" (brew)\"}'");
|
system("ls $(brew --cellar) | wc -l | awk -F' ' '{print \" \x1b[34mw w \x1b[0m\x1b[1mPKGS\x1b[0m \"$1 \" (brew)\"}'");
|
||||||
#else
|
#else
|
||||||
if (show_pkgs)
|
if (show_pkgs) {
|
||||||
printf("\033[18C%s%sPKGS %s%s%d: %s\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sPKGS %s%s%d: %s",
|
||||||
NORMAL, BOLD, NORMAL, NORMAL, pkgs, pkgman_name);
|
NORMAL, BOLD, NORMAL, NORMAL, pkgs, pkgman_name);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (show_uptime)
|
if (show_uptime)
|
||||||
{
|
{
|
||||||
|
@ -412,15 +433,18 @@ void print_info()
|
||||||
switch (uptime)
|
switch (uptime)
|
||||||
{
|
{
|
||||||
case 0 ... 3599:
|
case 0 ... 3599:
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lim\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sUWUPTIME %s%lim",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 60 % 60);
|
||||||
break;
|
break;
|
||||||
case 3600 ... 86399:
|
case 3600 ... 86399:
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sUWUPTIME %s%lih, %lim",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n",
|
responsively_printf(print_buf,
|
||||||
|
"\033[18C%s%sUWUPTIME %s%lid, %lih, %lim",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue