1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//! ## `EdTUI`
//!
//!<div align="center">
//!
//! [](https://github.com/preiter93/edtui/actions/workflows/ci.yml)
//!
//! </div>
//!
//! ### Overview
//! `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::{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
//! - Vim-like keybindings and editing modes for efficient text manipulation.
//! - Copy paste using the systems clipboard.
//! - Line wrapping.
//! - Syntax highlighting (experimental).
//! - Mouse support (experimental).
//!
//! ## Demo
//!
//!
//!
//! ## Keybindings
//! `EdTUI` offers a set of keybindings similar to Vim. Here are some of the most common keybindings:
//!
//! #### Normal Mode:
//!
//! | Keybinding | Description |
//! |---------------------------|----------------------------------------------|
//! | `i` | Enter Insert mode |
//! | `v` | Enter Visual mode |
//! | `h`, `j`, `k`, `l` | Navigate left, down, up, and right |
//! | `w`, `b` | Move forward or backward by word |
//! | `x` | Delete the character under the cursor |
//! | `u`, `<ctrl>+r` | Undo/Redo last action |
//! | `Esc` | Escape Visual mode |
//! | `0` | Move cursor to start of line |
//! | `^` | Move cursor to first non-blank character |
//! | `$` | Move cursor to end of line |
//! | `gg` | Move cursor to the first row |
//! | `G ` | Move cursor to the last row |
//! | `%` | Move cursor to closing/opening bracket |
//! | `a` | Append after the cursor |
//! | `A` | Append at the end of the line |
//! | `o` | Add a new line below and enter Insert mode |
//! | `O` | Add a new line above and enter Insert mode |
//! | `J` | Join current line with the line below |
//! | `d` | Delete the selection (Visual mode) |
//! | `dd` | Delete the current line |
//! | `D` | Delete to the end of the line |
//! | `viw` | Select between delimiters. Supported: [`"`] |
//! | `vi` + `", ', (, [ or {` | Select between delimiter `", ', (, [ or {` |
//! | `ci` + `", ', (, [ or {` | Change between delimiter `", ', (, [ or {` |
//! | `u` | Undo the last change |
//! | `r` | Redo the last undone action |
//! | `y` | Copy the selected text |
//! | `p` | Paste the copied text |
//!
//! #### Insert Mode:
//!
//! | Keybinding | Description |
//! |-------------|-----------------------------------------|
//! | `Esc` | Return to Normal mode |
//! | `Backspace` | Delete the previous character |
//! | `Enter` | Insert line break |
//! | `Arrows` | Navigation |
//!
//! For more keybindings and customization options, refer to the code.
//!
//! ## Experimental Mouse Support
//!
//! `Edtui` includes experimental mouse support:
//! ```ignore
//! let event_handler = EditorEvent::default();
//! event_handler.on_mouse_event(mouse_event, &mut state);
//! ```
//!
//! **Note**: This feature is experimental, so expect potential bugs and breaking changes. It does
//! currently not work correctly on wrapped lines.
//!
//! ## Syntax highlighting
//!
//! Syntax highlighting was added in version `0.8.4`. It is experimental, so expect breaking changes.
//!
//! `Edtui` offers a number of custom themes, see [`SyntaxHighlighter::theme`] for a complete list.
//! If you want to use a custom theme, see [`SyntaxHighlighter::custom_theme`]. Check [syntect](https://github.com/trishume/syntect)
//! for more details about themes and extensions.
//!
//!```ignore
//! use edtui::EditorState;
//! use edtui::EditorView;
//! use edtui::SyntaxHighlighter;
//!
//! let theme_name = "dracula";
//! let extension = "rs";
//! let syntax_highlighter = SyntaxHighlighter::new(theme_name, extension);
//! EditorView::new(&mut EditorState::default())
//! .syntax_highlighter(Some(syntax_highlighter))
//! .render(area, buf);
//!```
//!
//!
//!
//! ### Roadmap
//! - [ ] Support termwiz and termion
//! - [ ] Display line numbers
//! - [ ] Remap keybindings
pub use EditorInput;
pub use EditorEventHandler;
pub use ;
pub use ;
pub use SyntaxHighlighter;
pub use syntect;
/// A data structure that contains chars organized in rows and columns
pub type Lines = Jagged;
pub use RowIndex;
pub use Index2;