Struct cursive::views::EditView [] [src]

pub struct EditView { /* fields omitted */ }

Input box where the user can enter and edit text.

Examples

From the edit example.

let mut siv = Cursive::new();

// Create a dialog with an edit text and a button.
// The user can either hit the <Ok> button,
// or press Enter on the edit text.
siv.add_layer(
    Dialog::new()
        .title("Enter your name")
        .padding((1, 1, 1, 0))
        .content(
            EditView::new()
                .on_submit(show_popup)
                .with_id("name")
                .fixed_width(20),
        )
        .button("Ok", |s| {
            let name = s.call_on_id(
                "name",
                |view: &mut EditView| view.get_content(),
            ).unwrap();
            show_popup(s, &name);
        }),
);

fn show_popup(s: &mut Cursive, name: &str) {
    if name.is_empty() {
        s.add_layer(Dialog::info("Please enter a name!"));
    } else {
        let content = format!("Hello {}!", name);
        s.pop_layer();
        s.add_layer(Dialog::around(TextView::new(content))
            .button("Quit", |s| s.quit()));
    }
}

Methods

impl EditView
[src]

[src]

Creates a new, empty edit view.

[src]

If secret is true, the content won't be displayed in clear.

Only * will be shown.

[src]

Hides the content of the view.

Only * will be shown.

[src]

Sets the character to fill in blank space.

Defaults to "_".

[src]

Sets the character to fill in blank space.

Chainable variant.

Examples

let edit = EditView::new().filler(" ");

[src]

Disables this view.

A disabled view cannot be selected.

[src]

Disables this view.

Chainable variant.

[src]

Re-enables this view.

[src]

Sets the style used for this view.

When the view is enabled, the style will be reversed.

Defaults to ColorStyle::Secondary.

[src]

Sets the style used for this view.

When the view is enabled, the style will be reversed.

Chainable variant.

[src]

Sets a mutable callback to be called whenever the content is modified.

callback will be called with the view content and the current cursor position.

Warning: this callback cannot be called recursively. If you somehow trigger this callback again in the given closure, it will be ignored.

If you don't need a mutable closure but want the possibility of recursive calls, see set_on_edit.

[src]

Sets a callback to be called whenever the content is modified.

callback will be called with the view content and the current cursor position.

This callback can safely trigger itself recursively if needed (for instance if you call on_event on this view from the callback).

If you need a mutable closure and don't care about the recursive aspect, see set_on_edit_mut.

[src]

Sets a mutable callback to be called whenever the content is modified.

Chainable variant. See set_on_edit_mut.

[src]

Sets a callback to be called whenever the content is modified.

Chainable variant. See set_on_edit.

[src]

Sets a mutable callback to be called when <Enter> is pressed.

callback will be given the content of the view.

Warning: this callback cannot be called recursively. If you somehow trigger this callback again in the given closure, it will be ignored.

If you don't need a mutable closure but want the possibility of recursive calls, see set_on_submit.

[src]

Sets a callback to be called when <Enter> is pressed.

callback will be given the content of the view.

This callback can safely trigger itself recursively if needed (for instance if you call on_event on this view from the callback).

If you need a mutable closure and don't care about the recursive aspect, see set_on_submit_mut.

[src]

Sets a mutable callback to be called when <Enter> is pressed.

Chainable variant.

[src]

Sets a callback to be called when <Enter> is pressed.

Chainable variant.

[src]

Enable or disable this view.

[src]

Returns true if this view is enabled.

[src]

Replace the entire content of the view with the given one.

[src]

Get the current text.

[src]

Sets the current content to the given value.

Convenient chainable method.

[src]

Sets the cursor position.

[src]

Insert ch at the current cursor position.

[src]

Remove the character at the current cursor position.

Trait Implementations

impl Default for EditView
[src]

[src]

Returns the "default value" for a type. Read more

impl View for EditView
[src]

[src]

Draws the view with the given printer (includes bounds) and focus.

[src]

Called once the size for this view has been decided, Read more

[src]

This view is offered focus. Will it take it? Read more

[src]

Called when a key was pressed. Read more

[src]

Returns the minimum size the view requires with the given restrictions. Read more

[src]

Returns true if the view content changed since last layout phase. Read more

[src]

Runs a closure on the view identified by the given selector. Read more

[src]

Moves the focus to the view identified by the given selector. Read more

Auto Trait Implementations

impl !Send for EditView

impl !Sync for EditView