Module modalkit_ratatui::textbox

source ·
Expand description

§Text box

§Overview

This text box provides a view of a shared editing buffer, and, on top of passing operations through to an EditBuffer, is capable of doing the following:

  • Toggling wrapped and non-wrapped views of the buffer’s
  • Scrolling through the buffer’s contents
  • Rendering line annotations in left and right gutters

§Example

use modalkit::editing::application::EmptyInfo;
use modalkit::editing::store::Store;
use modalkit_ratatui::textbox::TextBoxState;

use ratatui::layout::Rect;

let mut store = Store::<EmptyInfo>::default();
let buffer = store.load_buffer(String::from("*scratch*"));
let mut tbox = TextBoxState::new(buffer);

tbox.set_term_info(Rect::new(0, 0, 6, 4));

tbox.set_text("a\nb\nc\nd\ne\nf\n");
assert_eq!(tbox.get_text(), "a\nb\nc\nd\ne\nf\n");
assert_eq!(tbox.get_lines(), 6);
assert_eq!(tbox.has_lines(4), 4);
assert_eq!(tbox.has_lines(6), 6);
assert_eq!(tbox.has_lines(8), 6);

Structs§