other: temporarily revert 2024 changes + hardcode some ratatui things (#1921)

* Revert "refactor: migrate to Rust 2024 edition (#1678)"

This reverts commit b07eb646ce.

* other: temporarily revert 2024 changes

* additionally work around some issues
This commit is contained in:
Clement Tsang
2025-12-25 11:10:32 -05:00
committed by GitHub
parent 76527e114d
commit b96aa55a90
7 changed files with 35 additions and 17 deletions
Generated
+5 -5
View File
@@ -595,7 +595,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.60.2",
"windows-sys 0.61.0",
]
[[package]]
@@ -662,7 +662,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys 0.61.0",
]
[[package]]
@@ -1669,7 +1669,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.60.2",
"windows-sys 0.61.0",
]
[[package]]
@@ -1977,7 +1977,7 @@ dependencies = [
"fastrand",
"once_cell",
"rustix",
"windows-sys 0.60.2",
"windows-sys 0.61.0",
]
[[package]]
@@ -2467,7 +2467,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.0",
]
[[package]]
+2 -2
View File
@@ -38,9 +38,9 @@ exclude = [
"profile.json.gz",
"rustfmt.toml",
]
edition = "2024"
edition = "2021"
# The oldest version I've tested that should still build - note this is not an official MSRV!
rust-version = "1.85"
rust-version = "1.81"
[lib]
test = true
+4 -2
View File
@@ -196,11 +196,13 @@ fn create_dataset(data: GraphData<'_>) -> Dataset<'_> {
.data(time, values)
.graph_type(GraphType::Line);
if let Some(name) = name {
let dataset = if let Some(name) = name {
dataset.name(name)
} else {
dataset
}
};
dataset
}
#[cfg(test)]
@@ -188,12 +188,16 @@ impl<'a> Context<'a> {
pub fn new(
width: u16, height: u16, x_bounds: [f64; 2], y_bounds: [f64; 2], marker: symbols::Marker,
) -> Context<'a> {
// FIXME: Temporarily added due to ratatui things
#[allow(unreachable_patterns)]
let grid: Box<dyn Grid> = match marker {
symbols::Marker::Dot => Box::new(CharGrid::new(width, height, '•')),
symbols::Marker::Block => Box::new(CharGrid::new(width, height, '█')),
symbols::Marker::Bar => Box::new(CharGrid::new(width, height, '▄')),
symbols::Marker::Braille => Box::new(BrailleGrid::new(width, height)),
symbols::Marker::HalfBlock => Box::new(HalfBlockGrid::new(width, height)),
// FIXME: Fall back to braille for now.
_ => Box::new(BrailleGrid::new(width, height)),
};
Context {
x_bounds,
@@ -3,6 +3,15 @@ use std::{fmt::Debug, iter::zip};
use itertools::Itertools;
use tui::{style::Color, symbols};
// FIXME: These are temporary while people are having issues with ratatui.
const BLANK: u16 = 0x2800;
const DOTS: [[u16; 2]; 4] = [
[0x0001, 0x0008],
[0x0002, 0x0010],
[0x0004, 0x0020],
[0x0040, 0x0080],
];
#[derive(Debug, Clone)]
pub(super) struct Layer {
pub(super) string: String,
@@ -63,7 +72,7 @@ impl BrailleGrid {
Self {
width,
height,
utf16_code_points: vec![symbols::braille::BLANK; length],
utf16_code_points: vec![BLANK; length],
colors: vec![Color::Reset; length],
}
}
@@ -82,7 +91,7 @@ impl Grid for BrailleGrid {
}
fn reset(&mut self) {
self.utf16_code_points.fill(symbols::braille::BLANK);
self.utf16_code_points.fill(BLANK);
self.colors.fill(Color::Reset);
}
@@ -99,7 +108,7 @@ impl Grid for BrailleGrid {
// look but it also makes it a bit harder to read in some cases.
// if let Some(c) = self.utf16_code_points.get_mut(index) {
// *c |= symbols::braille::DOTS[y % 4][x % 2];
// *c |= DOTS[y % 4][x % 2];
// }
// if let Some(c) = self.colors.get_mut(index) {
// *c = color;
@@ -110,10 +119,10 @@ impl Grid for BrailleGrid {
if *curr_color != color {
*curr_color = color;
if let Some(cell) = self.utf16_code_points.get_mut(index) {
*cell = symbols::braille::BLANK | symbols::braille::DOTS[y % 4][x % 2];
*cell = BLANK | DOTS[y % 4][x % 2];
}
} else if let Some(cell) = self.utf16_code_points.get_mut(index) {
*cell |= symbols::braille::DOTS[y % 4][x % 2];
*cell |= DOTS[y % 4][x % 2];
}
}
}
+2 -1
View File
@@ -288,7 +288,8 @@ impl Painter {
f.render_widget(
Table::new(
total_network,
&((std::iter::repeat_n(draw_loc.width.saturating_sub(2) / 4, 4))
&((std::iter::repeat(draw_loc.width.saturating_sub(2) / 4))
.take(4)
.map(Constraint::Length)
.collect::<Vec<_>>()),
)
+4 -2
View File
@@ -756,11 +756,13 @@ fn get_default_cpu_selection(args: &BottomArgs, config: &Config) -> config::cpu:
}
fn get_dedicated_avg_row(config: &Config) -> bool {
config
let conf = config
.flags
.as_ref()
.and_then(|flags| flags.average_cpu_row)
.unwrap_or(false)
.unwrap_or(false);
conf
}
#[inline]