Add terminal inline assistant (#13638)

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Bennet Bo Fenner 2024-07-01 20:53:56 +02:00 committed by GitHub
parent c516b8f038
commit e243856559
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1587 additions and 141 deletions

View file

@ -945,6 +945,18 @@ impl Terminal {
&self.last_content
}
pub fn total_lines(&self) -> usize {
let term = self.term.clone();
let terminal = term.lock_unfair();
terminal.total_lines()
}
pub fn viewport_lines(&self) -> usize {
let term = self.term.clone();
let terminal = term.lock_unfair();
terminal.screen_lines()
}
//To test:
//- Activate match on terminal (scrolling and selection)
//- Editor search snapping behavior
@ -999,11 +1011,21 @@ impl Terminal {
.push_back(InternalEvent::Scroll(AlacScroll::Delta(1)));
}
pub fn scroll_up_by(&mut self, lines: usize) {
self.events
.push_back(InternalEvent::Scroll(AlacScroll::Delta(lines as i32)));
}
pub fn scroll_line_down(&mut self) {
self.events
.push_back(InternalEvent::Scroll(AlacScroll::Delta(-1)));
}
pub fn scroll_down_by(&mut self, lines: usize) {
self.events
.push_back(InternalEvent::Scroll(AlacScroll::Delta(-(lines as i32))));
}
pub fn scroll_page_up(&mut self) {
self.events
.push_back(InternalEvent::Scroll(AlacScroll::PageUp));
@ -1436,6 +1458,13 @@ impl Terminal {
})
}
pub fn working_directory(&self) -> Option<PathBuf> {
self.pty_info
.current
.as_ref()
.map(|process| process.cwd.clone())
}
pub fn title(&self, truncate: bool) -> String {
const MAX_CHARS: usize = 25;
match &self.task {