Skip to main content

Share

Struct Share 

Source
pub struct Share(/* private fields */);
Expand description

How much of the width an arrangement’s first region takes.

e0fd485e. Nothing said how much room a region got, so every renderer invented its own number and two hosts showing one screen disagreed about its proportions. A webview never noticed, because the stylesheet answered once for every consumer; a terminal has no stylesheet to inherit from, so quasi-tui picked 24 columns for a sidebar and 40% for a list pane and neither had anything behind it.

§A proportion, never a unit

Held as a percentage, and that is the only form it comes in. A description carrying columns would be describing a terminal and one carrying pixels a webview, and the whole point is that both honour the same fact: a terminal resolves it against a column count, a webview writes it into a grid, and neither has to know what the other did.

It is not makeover_geometry::Ratio’s job either, which was the first guess. Geometry is scales that answer the same for every screen and takes no input that would let a sidebar screen differ from a list-detail one.

Implementations§

Source§

impl Share

Source

pub const SIDEBAR: Self

What a sidebar takes, when nobody says otherwise.

A quarter. quasi-tui drew 24 columns, which is a quarter of a 96-column terminal and about a fifth of a wide one; a quarter is that number said in the form a webview can honour too.

Source

pub const LIST: Self

What the list side of a list-detail takes, when nobody says otherwise.

quasi-tui’s 40%, which was already a proportion and is the one number this member did not have to invent.

Source

pub const fn percent(percent: u8) -> Self

A share of the width, as a percentage.

Clamped to 5..=95 rather than refused. A description that asked for a region of nothing is a bug in the app, and a renderer drawing a region zero cells wide reports it as a region that vanished, which is the hardest kind of bug to find from what is on the screen.

Source

pub const fn as_percent(self) -> u8

The share as a percentage.

Source

pub const fn of(self, whole: u16) -> u16

This share of a width, rounded to the nearest whole unit.

What a terminal calls to turn the proportion into columns. At least one, because a region the description named should be visible: a screen 3 columns wide is unusable either way, and a sidebar that is there is a truer picture of the description than a sidebar that is not.

Trait Implementations§

Source§

impl Clone for Share

Source§

fn clone(&self) -> Share

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Share

Source§

impl Debug for Share

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Share

Source§

impl Hash for Share

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Share

Source§

fn cmp(&self, other: &Share) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Share

Source§

fn eq(&self, other: &Share) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Share

Source§

fn partial_cmp(&self, other: &Share) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Share

Auto Trait Implementations§

§

impl Freeze for Share

§

impl RefUnwindSafe for Share

§

impl Send for Share

§

impl Sync for Share

§

impl Unpin for Share

§

impl UnsafeUnpin for Share

§

impl UnwindSafe for Share

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.