Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Reiter committed Oct 13, 2024
1 parent 06b9074 commit 151caac
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@
`EdTUI` is a text editor widget for the [Ratatui](https://github.com/ratatui-org/ratatui) ecosystem.
It is designed to provide a light-weight user experience inspired by Vim.

Instantiate the state and render the view:
```rust
use edtui::{EditorState, EditorTheme, EditorView};
use edtui::{EditorEventHandler, EditorState, EditorTheme, EditorView};
use ratatui::widgets::Widget;

let mut state = EditorState::default();
EditorView::new(&mut state)
.theme(EditorTheme::default())
.wrap(true) // line wrapping
.render(area, buf);

```

Handle events:
```rust
let mut event_handler = EditorEventHandler::default();

// or handle only key events
event_handler.on_key_event(key_event, &mut state);

// has experimental support for mouse events
event_handler.on_mouse_event(mouse_event, &mut state);

// handles both key and mouse events
event_handler.on_event(event, &mut state);
```

### Features
Expand Down
18 changes: 17 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,31 @@
//! `EdTUI` is a text editor widget for the [Ratatui](https://github.com/ratatui-org/ratatui) ecosystem.
//! It is designed to provide a light-weight user experience inspired by Vim.
//!
//! Instantiate the state and render the view:
//! ```ignore
//! use edtui::{EditorState, EditorTheme, EditorView};
//! use edtui::{EditorEventHandler, EditorState, EditorTheme, EditorView};
//! use ratatui::widgets::Widget;
//!
//! let mut state = EditorState::default();
//! EditorView::new(&mut state)
//! .theme(EditorTheme::default())
//! .wrap(true) // line wrapping
//! .render(area, buf);
//!
//! ```
//!
//! Handle events:
//! ```ignore
//! let mut event_handler = EditorEventHandler::default();
//!
//! // or handle only key events
//! event_handler.on_key_event(key_event, &mut state);
//!
//! // has experimental support for mouse events
//! event_handler.on_mouse_event(mouse_event, &mut state);
//!
//! // handles both key and mouse events
//! event_handler.on_event(event, &mut state);
//! ```
//!
//! ## Features
Expand Down

0 comments on commit 151caac

Please sign in to comment.