Address remaining review feedback

This commit is contained in:
Leonard Hecker 2025-05-17 20:21:19 +02:00
parent 3a27086b76
commit 6122013b2d
4 changed files with 17 additions and 21 deletions

View file

@ -226,7 +226,6 @@ fn run() -> apperr::Result<()> {
);
last_latency_width = cols;
sys::write_stdout(&output);
}
sys::write_stdout(&output);
@ -517,7 +516,7 @@ fn setup_terminal(tui: &mut Tui, vt_parser: &mut vt::Parser) -> RestoreModes {
let mut done = false;
let mut osc_buffer = String::new();
let mut indexed_colors = framebuffer::DEFAULT_THEME;
let mut responses = 0;
let mut color_responses = 0;
while !done {
let scratch = scratch_arena(None);
@ -577,7 +576,7 @@ fn setup_terminal(tui: &mut Tui, vt_parser: &mut vt::Parser) -> RestoreModes {
}
*color = rgb | 0xff000000;
responses += 1;
color_responses += 1;
osc_buffer.clear();
}
_ => {}
@ -585,7 +584,7 @@ fn setup_terminal(tui: &mut Tui, vt_parser: &mut vt::Parser) -> RestoreModes {
}
}
if responses == indexed_colors.len() {
if color_responses == indexed_colors.len() {
tui.setup_indexed_colors(indexed_colors);
}

View file

@ -56,7 +56,7 @@ pub enum IndexedColor {
/// Number of indices used by [`IndexedColor`].
pub const INDEXED_COLORS_COUNT: usize = 18;
/// Fallback theme.
/// Fallback theme. Matches Windows Terminal's Ottosson theme.
pub const DEFAULT_THEME: [u32; INDEXED_COLORS_COUNT] = [
0xff000000, 0xff212cbe, 0xff3aae3f, 0xff4a9abe, 0xffbe4d20, 0xffbe54bb, 0xffb2a700, 0xffbebebe,
0xff808080, 0xff303eff, 0xff51ea58, 0xff44c9ff, 0xffff6a2f, 0xffff74fc, 0xfff0e100, 0xffffffff,

View file

@ -77,7 +77,7 @@
//! current node? Each node needs to be constructed with a "classname".
//! The classname is hashed with the parent node ID as the seed. This derived
//! hash is then used as the new child node ID. Under the assumption that the
//! collision likelihood of the hash function is low, this services as true IDs.
//! collision likelihood of the hash function is low, this serves as true IDs.
//!
//! This has the nice added property that finding a node with the same ID
//! guarantees that all of the parent nodes must have equivalent IDs as well.
@ -99,7 +99,7 @@
//! }
//!
//! fn main() {
//! arena::init().unwrap();
//! arena::init(128 * 1024 * 1024).unwrap();
//!
//! // Create a `Tui` instance which holds state across frames.
//! let mut tui = Tui::new().unwrap();
@ -1229,7 +1229,7 @@ impl Tui {
// Figure out if we're inside a focus void (a container that doesn't
// allow tabbing inside), and in that case, toss the focus to it.
//
// Also, figure out the container within which the focuse must be contained.
// Also, figure out the container within which the focus must be contained.
// This way, tab/shift-tab only moves within the same window.
// The ROOT_ID node has no parent, and the others have a float attribute.
// If the root is the focused node, it should of course not move upward.
@ -2415,7 +2415,7 @@ impl<'a> Context<'a, '_> {
let mut x = tc.preferred_column;
let mut y = tb.cursor_visual_pos().y - 1;
// If there's a selection we the cursor above the start of the selection.
// If there's a selection we put the cursor above it.
if let Some((beg, _)) = tb.selection_range() {
x = beg.visual_pos.x;
y = beg.visual_pos.y - 1;
@ -2472,7 +2472,7 @@ impl<'a> Context<'a, '_> {
let mut x = tc.preferred_column;
let mut y = tb.cursor_visual_pos().y + 1;
// If there's a selection we the cursor below the end of the selection.
// If there's a selection we put the cursor below it.
if let Some((_, end)) = tb.selection_range() {
x = end.visual_pos.x;
y = end.visual_pos.y + 1;
@ -2749,7 +2749,7 @@ impl<'a> Context<'a, '_> {
}
}
/// Creates a list where exactly one items is selected.
/// Creates a list where exactly one item is selected.
pub fn list_begin(&mut self, classname: &'static str) {
self.block_begin(classname);
self.attr_focusable();
@ -3116,14 +3116,14 @@ impl<'a> Context<'a, '_> {
}
if off < text.len() {
// Highlight the accelerator in red.
// Add an underline to the accelerator.
self.styled_label_add_text(&text[..off]);
self.styled_label_set_attributes(Attributes::Underlined);
self.styled_label_add_text(&text[off..off + 1]);
self.styled_label_set_attributes(Attributes::None);
self.styled_label_add_text(&text[off + 1..]);
} else {
// Add the accelerator in parentheses (still in red).
// Add the accelerator in parentheses and underline it.
let ch = accelerator as u8;
self.styled_label_add_text(text);
self.styled_label_add_text("(");

View file

@ -229,9 +229,8 @@ impl<'doc> MeasurementConfig<'doc> {
};
// Get the properties of the next cluster.
let props_lead = props_next_cluster;
props_next_cluster = ucd_grapheme_cluster_lookup(ch);
state = ucd_grapheme_cluster_joins(state, props_lead, props_next_cluster);
state = ucd_grapheme_cluster_joins(state, props_last_char, props_next_cluster);
// Stop if the next character does not join.
if ucd_grapheme_cluster_joins_done(state) {
@ -253,7 +252,7 @@ impl<'doc> MeasurementConfig<'doc> {
// Tabs require special handling because they can have a variable width.
if props_last_char == ucd_tab_properties() {
// SAFETY: `tab_size` is clamped to >= 1 at the start of this method.
// SAFETY: `tab_size` is clamped to >= 1 in `with_tab_size`.
// This assert ensures that Rust doesn't insert panicking null checks.
unsafe { std::hint::assert_unchecked(tab_size >= 1) };
width = tab_size - (column % tab_size);
@ -356,8 +355,6 @@ impl<'doc> MeasurementConfig<'doc> {
// If we're here, we hit our target. Now the only question is:
// Is the word we're currently on so wide that it will be wrapped further down the document?
// This only applies if we already had a wrap opportunity on this line,
// because if there was none yet, the start column of the word is 0 and it can't be wrapped.
if word_wrap_column > 0 {
if !wrap_opp {
// If the current layouted line had no wrap opportunities, it means we had an input
@ -410,9 +407,9 @@ impl<'doc> MeasurementConfig<'doc> {
};
// Get the properties of the next cluster.
let props_lead = props_next_cluster;
props_next_cluster = ucd_grapheme_cluster_lookup(ch);
state = ucd_grapheme_cluster_joins(state, props_lead, props_next_cluster);
state =
ucd_grapheme_cluster_joins(state, props_last_char, props_next_cluster);
// Stop if the next character does not join.
if ucd_grapheme_cluster_joins_done(state) {
@ -434,7 +431,7 @@ impl<'doc> MeasurementConfig<'doc> {
// Tabs require special handling because they can have a variable width.
if props_last_char == ucd_tab_properties() {
// SAFETY: `tab_size` is clamped to >= 1 at the start of this method.
// SAFETY: `tab_size` is clamped to >= 1 in `with_tab_size`.
// This assert ensures that Rust doesn't insert panicking null checks.
unsafe { std::hint::assert_unchecked(tab_size >= 1) };
width = tab_size - (column % tab_size);