Begin mouse mode

This commit is contained in:
Mikayla Maki 2022-08-15 19:16:42 -07:00 committed by Mikayla Maki
parent 0fef72ac5f
commit a0d0c84eee

View file

@ -607,11 +607,6 @@ impl Terminal {
f(content, cursor_text) f(content, cursor_text)
} }
///Scroll the terminal
pub fn scroll(&mut self, scroll: Scroll) {
self.events.push(InternalEvent::Scroll(scroll));
}
pub fn focus_in(&self) { pub fn focus_in(&self) {
if self.last_mode.contains(TermMode::FOCUS_IN_OUT) { if self.last_mode.contains(TermMode::FOCUS_IN_OUT) {
self.write_to_pty("\x1b[I".to_string()); self.write_to_pty("\x1b[I".to_string());
@ -624,34 +619,60 @@ impl Terminal {
} }
} }
///Scroll the terminal
pub fn scroll(&mut self, scroll: Scroll) {
if self.last_mode.intersects(TermMode::MOUSE_MODE) {
//TODE: MOUSE MODE
}
self.events.push(InternalEvent::Scroll(scroll));
}
pub fn click(&mut self, point: Point, side: Direction, clicks: usize) { pub fn click(&mut self, point: Point, side: Direction, clicks: usize) {
let selection_type = match clicks { if self.last_mode.intersects(TermMode::MOUSE_MODE) {
0 => return, //This is a release //TODE: MOUSE MODE
1 => Some(SelectionType::Simple), } else {
2 => Some(SelectionType::Semantic), let selection_type = match clicks {
3 => Some(SelectionType::Lines), 0 => return, //This is a release
_ => None, 1 => Some(SelectionType::Simple),
}; 2 => Some(SelectionType::Semantic),
3 => Some(SelectionType::Lines),
_ => None,
};
let selection = let selection =
selection_type.map(|selection_type| Selection::new(selection_type, point, side)); selection_type.map(|selection_type| Selection::new(selection_type, point, side));
self.events.push(InternalEvent::SetSelection(selection)); self.events.push(InternalEvent::SetSelection(selection));
}
}
pub fn mouse_move(&mut self, point: Point, side: Direction, clicks: usize) {
if self.last_mode.intersects(TermMode::MOUSE_MODE) {
//TODE: MOUSE MODE
}
} }
pub fn drag(&mut self, point: Point, side: Direction) { pub fn drag(&mut self, point: Point, side: Direction) {
self.events if self.last_mode.intersects(TermMode::MOUSE_MODE) {
.push(InternalEvent::UpdateSelection((point, side))); //TODE: MOUSE MODE
} else {
self.events
.push(InternalEvent::UpdateSelection((point, side)));
}
} }
///TODO: Check if the mouse_down-then-click assumption holds, so this code works as expected
pub fn mouse_down(&mut self, point: Point, side: Direction) { pub fn mouse_down(&mut self, point: Point, side: Direction) {
self.events if self.last_mode.intersects(TermMode::MOUSE_MODE) {
.push(InternalEvent::SetSelection(Some(Selection::new( //TODE: MOUSE MODE
SelectionType::Simple, } else {
point, self.events
side, .push(InternalEvent::SetSelection(Some(Selection::new(
)))); SelectionType::Simple,
point,
side,
))));
}
} }
} }