1use oma_console::{
2 pager::{OmaPager, Pager, PagerUIText},
3 print::OmaColorFormat,
4};
5use ratatui::crossterm::style::Stylize;
6use std::{io, time::Duration};
7
8struct OmaPagerUIText;
9
10impl PagerUIText for OmaPagerUIText {
11 fn normal_tips(&self) -> String {
12 "QAQ".to_string()
13 }
14
15 fn search_tips_with_result(&self) -> String {
16 "Press Esc to exit search, press N or n to jump to the prev or next match.".to_string()
17 }
18
19 fn searct_tips_with_query(&self, query: &str) -> String {
20 format!("Search: {}", query)
21 }
22
23 fn search_tips_with_empty(&self) -> String {
24 "Search pattern cannot be empty (Press /)".to_string()
25 }
26
27 fn search_tips_not_found(&self) -> String {
28 "Pattern not found (Press /)".to_string()
29 }
30}
31
32fn main() -> io::Result<()> {
33 let cf = OmaColorFormat::new(true, Duration::from_millis(100));
34 let pager = OmaPager::new(Some("QAQ".to_string()), &cf, Box::new(OmaPagerUIText));
35 let mut p = Pager::External(Box::new(pager));
36 let mut w = p.get_writer()?;
37 w.write_all("QAQ\n".cyan().to_string().as_bytes()).ok();
38 w.write_all(b"PAP").ok();
39
40 drop(w);
41 p.wait_for_exit()?;
42
43 Ok(())
44}