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
//! Viewport component for scrollable text content
//!
//! A high-performance scrollable view for displaying large text content,
//! similar to Bubbles' viewport component.
//!
//! # Features
//!
//! - Vertical and horizontal scrolling
//! - Keyboard navigation (vim-style and arrow keys)
//! - Mouse wheel support
//! - Line numbers
//! - Scrollbar indicator
//! - Customizable key bindings
//!
//! # Example
//!
//! ```ignore
//! use rnk::components::viewport::{Viewport, ViewportState, ViewportKeyMap};
//! use rnk::hooks::{use_signal, use_input};
//!
//! fn app() -> Element {
//! let state = use_signal(|| {
//! let mut s = ViewportState::new(80, 20);
//! s.set_content(include_str!("long_file.txt"));
//! s
//! });
//!
//! let keymap = ViewportKeyMap::default();
//!
//! use_input({
//! let state = state.clone();
//! let keymap = keymap.clone();
//! move |input, key| {
//! let mut s = state.get();
//! if handle_viewport_input(&mut s, input, key, &keymap) {
//! state.set(s);
//! }
//! }
//! });
//!
//! Viewport::new(&state.get())
//! .line_numbers(true)
//! .scrollbar(true)
//! .into_element()
//! }
//! ```
//!
//! # Key Bindings
//!
//! Default key bindings:
//!
//! | Key | Action |
//! |-----|--------|
//! | `↑` / `k` | Scroll up one line |
//! | `↓` / `j` | Scroll down one line |
//! | `PageUp` / `Ctrl+B` | Page up |
//! | `PageDown` / `Ctrl+F` / `Space` | Page down |
//! | `Ctrl+U` | Half page up |
//! | `Ctrl+D` | Half page down |
//! | `Home` / `g` | Go to top |
//! | `End` / `G` | Go to bottom |
//! | `←` / `h` | Scroll left |
//! | `→` / `l` | Scroll right |
//! | `0` | Go to left edge |
//! | `$` | Go to right edge |
pub use ;
pub use ;
pub use ViewportState;