[−][src]Struct cnx::Cnx
The main object, used to instantiate an instance of Cnx.
The cnx_add_widget!()
macro can be used to add widgets to the Cnx
instance. Once configured, the run()
method will take ownership of the
instance and run it until the process is killed or an error is returned.
Examples
let attr = Attributes { font: Font::new("SourceCodePro 21"), fg_color: Color::white(), bg_color: None, padding: Padding::new(8.0, 8.0, 0.0, 0.0), }; let mut cnx = Cnx::new(Position::Top)?; cnx_add_widget!(cnx, ActiveWindowTitle::new(&cnx, attr.clone())); cnx_add_widget!(cnx, Clock::new(&cnx, attr.clone())); cnx.run()?;
Methods
impl Cnx
[src]
pub fn new(position: Position) -> Result<Cnx>
[src]
Creates a new Cnx
instance.
This creates a new Cnx
instance at either the top or bottom of the
screen, depending on the value of the Position
enum.
Examples
let mut cnx = Cnx::new(Position::Top);
let mut cnx = Cnx::new(Position::Bottom);
pub fn add_widget<W>(&mut self, widget: W) where
W: Widget + 'static,
[src]
W: Widget + 'static,
Adds a widget to the Cnx instance.
This method takes a Widget
and adds it to the current Cnx instance,
to the right of any existing widgets.
It is recommended that you instead use the cnx_add_widget!()
macro,
as this will eventually grow to have a more flexible syntax for
configuring widget attributes.
pub fn run(self) -> Result<()>
[src]
Runs the Cnx instance.
This method takes ownership of the Cnx instance and runs it until either the process is terminated, or an internal error is returned.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.