Corrige el rótulo de inicio en terminales
Ajusta el número de caracteres que se pueden mostrar en el rótulo de inicio según el número de columnas del terminal. Si es menor de 80 columnas mostrará directamente texto.
This commit is contained in:
parent
b02a92dbb0
commit
2476b2b9c8
3 changed files with 24 additions and 6 deletions
|
|
@ -27,6 +27,8 @@ downcast-rs = "1.2.0"
|
||||||
figlet-rs = "0.1.3"
|
figlet-rs = "0.1.3"
|
||||||
futures = "0.3.21"
|
futures = "0.3.21"
|
||||||
once_cell = "1.10.0"
|
once_cell = "1.10.0"
|
||||||
|
substring = "1.4.5"
|
||||||
|
term_size = "0.3.2"
|
||||||
url = "2.2.2"
|
url = "2.2.2"
|
||||||
|
|
||||||
config_rs = { package = "config", version = "0.11.0", features = ["toml"] }
|
config_rs = { package = "config", version = "0.11.0", features = ["toml"] }
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use crate::Lazy;
|
||||||
use crate::config::SETTINGS;
|
use crate::config::SETTINGS;
|
||||||
|
|
||||||
use figlet_rs::FIGfont;
|
use figlet_rs::FIGfont;
|
||||||
|
use substring::Substring;
|
||||||
|
|
||||||
static FIGFONT: Lazy<FIGfont> = Lazy::new(|| {
|
static FIGFONT: Lazy<FIGfont> = Lazy::new(|| {
|
||||||
let slant = include_str!("slant.flf");
|
let slant = include_str!("slant.flf");
|
||||||
|
|
@ -31,8 +32,23 @@ static FIGFONT: Lazy<FIGfont> = Lazy::new(|| {
|
||||||
|
|
||||||
pub fn print_on_startup() {
|
pub fn print_on_startup() {
|
||||||
if SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
if SETTINGS.app.startup_banner.to_lowercase() != "off" {
|
||||||
|
if let Some((term_width, _)) = term_size::dimensions() {
|
||||||
|
if term_width >= 80 {
|
||||||
|
let maxlen = (term_width / 10) - 2;
|
||||||
|
let mut app = SETTINGS.app.name.substring(0, maxlen).to_owned();
|
||||||
|
if SETTINGS.app.name.len() > maxlen {
|
||||||
|
app = format!("{}...", app);
|
||||||
|
}
|
||||||
println!("\n{} {}\n\n Powered by PageTop {}\n",
|
println!("\n{} {}\n\n Powered by PageTop {}\n",
|
||||||
FIGFONT.convert(&SETTINGS.app.name).unwrap(),
|
FIGFONT.convert(&app).unwrap(),
|
||||||
|
&SETTINGS.app.description,
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("\n{}\n{}\n\nPowered by PageTop {}\n",
|
||||||
|
&SETTINGS.app.name,
|
||||||
&SETTINGS.app.description,
|
&SETTINGS.app.description,
|
||||||
env!("CARGO_PKG_VERSION")
|
env!("CARGO_PKG_VERSION")
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Global.
|
// Local.
|
||||||
|
|
||||||
pub use doc_comment::doc_comment;
|
pub(crate) use doc_comment::doc_comment;
|
||||||
pub use once_cell::sync::Lazy;
|
pub(crate) use once_cell::sync::Lazy;
|
||||||
pub use futures::executor::block_on as run_now;
|
pub(crate) use futures::executor::block_on as run_now;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// APIs públicas.
|
// APIs públicas.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue