Merge pull request #228 from itgonzo/text_area_disable

Adding disable/enable functionality to text_area
This commit is contained in:
Alexandre Bury 2018-03-28 15:48:50 -07:00 committed by GitHub
commit 8c64ea0101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,6 +107,37 @@ impl TextArea {
self.with(|s| s.set_content(content))
}
/// Disables this view.
///
/// A disabled view cannot be selected.
pub fn disable(&mut self) {
self.enabled = false;
}
/// Disables this view.
///
/// Chainable variant.
pub fn disabled(self) -> Self {
self.with(Self::disable)
}
/// Re-enables this view.
pub fn enable(&mut self) {
self.enabled = true;
}
/// Re-enables this view.
///
/// Chainable variant.
pub fn enabled(self) -> Self {
self.with(Self::enable)
}
/// Returns `true` if this view is enabled.
pub fn is_enabled(&self) -> bool {
self.enabled
}
/// Finds the row containing the grapheme at the given offset
fn row_at(&self, offset: usize) -> usize {
debug!("Offset: {}", offset);