mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 21:59:52 -07:00
Want a Matrix client that uses Vim keybindings (#1)
This commit is contained in:
parent
704f631d54
commit
262c96b62f
22 changed files with 9050 additions and 7 deletions
71
src/windows/welcome.rs
Normal file
71
src/windows/welcome.rs
Normal file
|
@ -0,0 +1,71 @@
|
|||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use modalkit::tui::{buffer::Buffer, layout::Rect};
|
||||
|
||||
use modalkit::{
|
||||
widgets::textbox::TextBoxState,
|
||||
widgets::WindowOps,
|
||||
widgets::{TermOffset, TerminalCursor},
|
||||
};
|
||||
|
||||
use modalkit::editing::base::{CloseFlags, WordStyle};
|
||||
|
||||
use crate::base::{IambBufferId, IambInfo, ProgramStore};
|
||||
|
||||
const WELCOME_TEXT: &str = include_str!("welcome.md");
|
||||
|
||||
pub struct WelcomeState {
|
||||
tbox: TextBoxState<IambInfo>,
|
||||
}
|
||||
|
||||
impl WelcomeState {
|
||||
pub fn new(store: &mut ProgramStore) -> Self {
|
||||
let buf = store.buffers.load_str(IambBufferId::Welcome, WELCOME_TEXT);
|
||||
|
||||
WelcomeState { tbox: TextBoxState::new(buf) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for WelcomeState {
|
||||
type Target = TextBoxState<IambInfo>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
return &self.tbox;
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for WelcomeState {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
return &mut self.tbox;
|
||||
}
|
||||
}
|
||||
|
||||
impl TerminalCursor for WelcomeState {
|
||||
fn get_term_cursor(&self) -> Option<TermOffset> {
|
||||
self.tbox.get_term_cursor()
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowOps<IambInfo> for WelcomeState {
|
||||
fn draw(&mut self, area: Rect, buf: &mut Buffer, focused: bool, store: &mut ProgramStore) {
|
||||
self.tbox.draw(area, buf, focused, store)
|
||||
}
|
||||
|
||||
fn dup(&self, store: &mut ProgramStore) -> Self {
|
||||
let tbox = self.tbox.dup(store);
|
||||
|
||||
WelcomeState { tbox }
|
||||
}
|
||||
|
||||
fn close(&mut self, flags: CloseFlags, store: &mut ProgramStore) -> bool {
|
||||
self.tbox.close(flags, store)
|
||||
}
|
||||
|
||||
fn get_cursor_word(&self, style: &WordStyle) -> Option<String> {
|
||||
self.tbox.get_cursor_word(style)
|
||||
}
|
||||
|
||||
fn get_selected_word(&self) -> Option<String> {
|
||||
self.tbox.get_selected_word()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue