Better click behaviour

This commit is contained in:
Joshua Barretto 2025-09-24 11:25:25 +01:00
parent 30fea7233d
commit f2a9876b81
3 changed files with 15 additions and 10 deletions

View file

@ -14,10 +14,10 @@
- [x] Search in buffer switcher
- [x] File saving
- [x] Syntax highlighting
- [x] Project search
- [x] Auto-indent (and related features)
- [x] Undo/redo
## Todo
- [ ] Replace
- [ ] Project search
- [ ] Auto-indent (and related features)
- [ ] Undo/redo
- [ ] Replace

View file

@ -88,7 +88,7 @@ impl Default for Theme {
option_new: Color::AnsiValue(148),
hl_token_whitespace: Color::Reset,
hl_token_ident: Color::AnsiValue(7),
hl_token_ident: Color::AnsiValue(15),
hl_token_keyword: Color::AnsiValue(112),
hl_token_number: Color::AnsiValue(45),
hl_token_type: Color::AnsiValue(210),

View file

@ -131,11 +131,16 @@ impl Input {
Ok(Resp::handled(None))
}
Some(Action::Mouse(MouseAction::Click, pos, false)) => {
buffer.goto_cursor(
cursor_id,
[self.focus[0] + pos[0], self.focus[1] + pos[1]],
true,
);
let pos = [self.focus[0] + pos[0], self.focus[1] + pos[1]];
// If we're already in the right place, select the token instead
if let Some(cursor) = buffer.cursors.get(cursor_id)
&& cursor.selection().is_none()
&& buffer.text.to_coord(cursor.pos) == pos
{
buffer.select_token_cursor(cursor_id);
} else {
buffer.goto_cursor(cursor_id, pos, true);
}
Ok(Resp::handled(None))
}
Some(