mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Automatically grow textarea
This commit is contained in:
parent
5edc6fc163
commit
14cfe3604a
@ -13,8 +13,8 @@ use view::{ScrollBase, SizeCache, View};
|
|||||||
|
|
||||||
/// Multi-lines text editor.
|
/// Multi-lines text editor.
|
||||||
///
|
///
|
||||||
/// A `TextArea` by itself doesn't have a well-defined size.
|
/// A `TextArea` will attempt to grow vertically dependent on the content.
|
||||||
/// You should wrap it in a `BoxView` to control its size.
|
/// Wrap it in a `BoxView` to constrain its size.
|
||||||
pub struct TextArea {
|
pub struct TextArea {
|
||||||
// TODO: use a smarter data structure (rope?)
|
// TODO: use a smarter data structure (rope?)
|
||||||
content: String,
|
content: String,
|
||||||
@ -362,6 +362,11 @@ impl TextArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl View for TextArea {
|
impl View for TextArea {
|
||||||
|
fn required_size(&mut self, constraint: Vec2) -> Vec2 {
|
||||||
|
self.compute_rows(constraint);
|
||||||
|
Vec2::new(1, self.rows.len())
|
||||||
|
}
|
||||||
|
|
||||||
fn draw(&self, printer: &Printer) {
|
fn draw(&self, printer: &Printer) {
|
||||||
printer.with_color(ColorStyle::Secondary, |printer| {
|
printer.with_color(ColorStyle::Secondary, |printer| {
|
||||||
let effect = if self.enabled {
|
let effect = if self.enabled {
|
||||||
|
Loading…
Reference in New Issue
Block a user