From e9e06c8fe2ef291b04f6059a841ceb999455bea8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 24 Jul 2024 14:52:01 +0200 Subject: Add `placeholder` support to `text_editor` widget --- graphics/src/text/editor.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'graphics') diff --git a/graphics/src/text/editor.rs b/graphics/src/text/editor.rs index 3e6ef70c..80733bbb 100644 --- a/graphics/src/text/editor.rs +++ b/graphics/src/text/editor.rs @@ -82,6 +82,13 @@ impl editor::Editor for Editor { }))) } + fn is_empty(&self) -> bool { + let buffer = self.buffer(); + + buffer.lines.is_empty() + || (buffer.lines.len() == 1 && buffer.lines[0].text().is_empty()) + } + fn line(&self, index: usize) -> Option<&str> { self.buffer() .lines -- cgit