<commit_before>use crate::direction::Direction;
use crate::event::{Callback, Event, EventResult, Key, MouseEvent};
use crate::rect::Rect;
use crate::theme::{ColorStyle, Effect};
use crate::utils::lines::simple::{simple_prefix, simple_suffix};
use crate::view::View;
use crate::Vec2;
use crate::{Cursive, Printer, With};
use std::cell::RefCell;
use std::rc::Rc;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};

/// Closure type for callbacks when the content is modified.
///
/// Arguments are the `Cursive`, current content of the input and cursor
/// position
pub type OnEdit = dyn Fn(&mut Cursive, &str, usize);

/// Closure type for callbacks when Enter is pressed.
///
/// Arguments are the `Cursive` and the content of the input.
pub type OnSubmit = dyn Fn(&mut Cursive, &str);

/// Input box where the user can enter and edit text.
///
/// # Examples
///
/// From the [edit example][1].
///
/// [1]: https://github.com/gyscos/cursive/blob/master/examples/edit.rs
///
/// ```rust
/// # use cursive_core::Cursive;
/// # use cursive_core::traits::*;
/// # use cursive_core::views::{Dialog, EditView, TextView};
/// let mut siv = Cursive::dummy();
///
/// // 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_lrtb(1, 1, 1, 0)
///         .content(
///             EditView::new()
///                 .on_submit(show_popup)
///                 .with_name("name")
///                 .fixed_width(20),
///         )
///         .button("Ok", |s| {
///             let name = s.call_on_name(
///                 "name",
///                 |view: &mut EditView| view.get_content(),
///             ).unwrap();
///             show_popup(s, &name);
///         }),
/// );
///<commit_msg>Fix link to `edit` example on github<commit_after>use crate::direction::Direction;
use crate::event::{Callback, Event, EventResult, Key, MouseEvent};
use crate::rect::Rect;
use crate::theme::{ColorStyle, Effect};
use crate::utils::lines::simple::{simple_prefix, simple_suffix};
use crate::view::View;
use crate::Vec2;
use crate::{Cursive, Printer, With};
use std::cell::RefCell;
use std::rc::Rc;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};

/// Closure type for callbacks when the content is modified.
///
/// Arguments are the `Cursive`, current content of the input and cursor
/// position
pub type OnEdit = dyn Fn(&mut Cursive, &str, usize);

/// Closure type for callbacks when Enter is pressed.
///
/// Arguments are the `Cursive` and the content of the input.
pub type OnSubmit = dyn Fn(&mut Cursive, &str);

/// Input box where the user can enter and edit text.
///
/// # Examples
///
/// From the [edit example][1].
///
/// [1]: https://github.com/gyscos/cursive/blob/master/examples/src/bin/edit.rs
///
/// ```rust
/// # use cursive_core::Cursive;
/// # use cursive_core::traits::*;
/// # use cursive_core::views::{Dialog, EditView, TextView};
/// let mut siv = Cursive::dummy();
///
/// // 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_lrtb(1, 1, 1, 0)
///         .content(
///             EditView::new()
///                 .on_submit(show_popup)
///                 .with_name("name")
///                 .fixed_width(20),
///         )
///         .button("Ok", |s| {
///             let name = s.call_on_name(
///                 "name",
///                 |view: &mut EditView| view.get_content(),
///             ).unwrap();
///             show_popup(s, &name);
///         }),
/// );
///
{'fraction_non_alphanumeric': 0.18902910121040434, 'fraction_numerical': 0.004635591037857327, 'mean_word_length': 2.3686036426712924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5377253', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1206, 'n_words': 344}