Struct Line

Source
pub struct Line { /* private fields */ }
Expand description

Line holds the content, styling and behaviour of a line in a Bitbar menu, both in the menu and submenus

Implementations§

Source§

impl Line

Source

pub fn new<T: Into<String>>(text: T) -> Self

Function to create empty line

Examples found in repository?
examples/simple.rs (line 5)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}
Source

pub fn set_text<T: Into<String>>(&mut self, text: T) -> &mut Self

Change text of the line

Source

pub fn set_style(&mut self, style: Style) -> &mut Self

Style provides a alternate method for setting the text style related options.

Source

pub fn set_command(&mut self, cmd: Cmd) -> &mut Self

command provides a alternate method for setting the bash script and params along with some related flags via a Cmd struct.

Source

pub fn set_href<T: Into<String>>(&mut self, href: T) -> &mut Self

href adds a URL to the line and makes it clickable.

Examples found in repository?
examples/simple.rs (line 6)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}
Source

pub fn set_color<T: Into<String>>(&mut self, color: T) -> &mut Self

Color sets the lines font color, can take a name or hex value.

Examples found in repository?
examples/simple.rs (line 6)
3fn main() {
4    let mut pl = Plugin::new();
5    let mut line = Line::new("first line");
6    line.set_color("red").set_href("http://google.com");
7
8    let mut sub_menu = SubMenu::new();
9    sub_menu.add_line(line);
10
11    let status_line = Line::new("🍺🍺🍺");
12    pl.set_status_line(status_line).set_sub_menu(sub_menu);
13
14    pl.render();
15}
Source

pub fn set_font<T: Into<String>>(&mut self, font: T) -> &mut Self

Font sets the lines font.

Source

pub fn set_size(&mut self, size: i64) -> &mut Self

Size sets the lines font size.

Source

pub fn set_bash<T: Into<String>>(&mut self, bash: T) -> &mut Self

Bash makes makes the line clickable and adds a script that will be run on click.

Source

pub fn set_params(&mut self, params: Vec<String>) -> &mut Self

Params adds arguments which are passed to the script specified by line.bash()

Source

pub fn set_terminal(&mut self, terminal: bool) -> &mut Self

Terminal sets a flag which controls whether a Terminal is opened when the bash script is run.

Source

pub fn set_refresh(&mut self, refresh: bool) -> &mut Self

Refresh controls whether clicking the line results in the plugin being refreshed. If the line has a bash script attached then the plugin is refreshed after the script finishes.

Source

pub fn set_drop_down(&mut self, drop_down: bool) -> &mut Self

DropDown sets a flag which controls whether the line only appears and cycles in the status bar but not in the dropdown.

Source

pub fn set_length(&mut self, length: i64) -> &mut Self

Length truncates the line after the specified number of characters. An elipsis will be added to any truncated strings, as well as a tooltip displaying the full string.

Source

pub fn set_trim(&mut self, trim: bool) -> &mut Self

Trim sets a flag to control whether leading/trailing whitespace is trimmed from the title. Defaults to true.

Source

pub fn set_alternate(&mut self, alternate: bool) -> &mut Self

Alternate sets a flag to mark a line as an alternate to the previous one for when the Option key is pressed in the dropdown.

Source

pub fn set_emojize(&mut self, emojize: bool) -> &mut Self

Emojize sets a flag to control parsing of github style :mushroom: into 🍄.

Source

pub fn set_ansi(&mut self, ansi: bool) -> &mut Self

Ansi sets a flag to control parsing of ANSI codes.

Trait Implementations§

Source§

impl Clone for Line

Source§

fn clone(&self) -> Line

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Line

Source§

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

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

impl Default for Line

Source§

fn default() -> Line

Returns the “default value” for a type. Read more
Source§

impl ToString for Line

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnwindSafe for Line

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.