Remove `Backend::get_cursor`

It is unused and cannot be used on some terminal hosts like `conhost`
that do not respond to VT queries. This doesn't have any affect on
behavior - I'm removing it so that we don't rely on it in the future.
termina
Michael Davis 2025-04-10 14:05:14 -04:00
parent 609a661207
commit 4dab0b5406
No known key found for this signature in database
4 changed files with 0 additions and 29 deletions

View File

@ -30,8 +30,6 @@ pub trait Backend {
fn hide_cursor(&mut self) -> Result<(), io::Error>; fn hide_cursor(&mut self) -> Result<(), io::Error>;
/// Sets the cursor to the given shape /// Sets the cursor to the given shape
fn show_cursor(&mut self, kind: CursorKind) -> Result<(), io::Error>; fn show_cursor(&mut self, kind: CursorKind) -> Result<(), io::Error>;
/// Gets the current position of the cursor
fn get_cursor(&mut self) -> Result<(u16, u16), io::Error>;
/// Sets the cursor to the given position /// Sets the cursor to the given position
fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), io::Error>; fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), io::Error>;
/// Clears the terminal /// Clears the terminal

View File

@ -513,25 +513,6 @@ impl Backend for TerminaBackend {
self.flush() self.flush()
} }
fn get_cursor(&mut self) -> Result<(u16, u16), io::Error> {
write!(
self.terminal,
"{}",
csi::Csi::Cursor(csi::Cursor::RequestActivePositionReport),
)?;
self.terminal.flush()?;
let event = self.terminal.read(|event| {
matches!(
event,
Event::Csi(Csi::Cursor(csi::Cursor::ActivePositionReport { .. }))
)
})?;
let Event::Csi(Csi::Cursor(csi::Cursor::ActivePositionReport { line, col })) = event else {
unreachable!();
};
Ok((line.get_zero_based(), col.get_zero_based()))
}
fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> { fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> {
let col = OneBased::from_zero_based(x); let col = OneBased::from_zero_based(x);
let line = OneBased::from_zero_based(y); let line = OneBased::from_zero_based(y);

View File

@ -139,10 +139,6 @@ impl Backend for TestBackend {
Ok(()) Ok(())
} }
fn get_cursor(&mut self) -> Result<(u16, u16), io::Error> {
Ok(self.pos)
}
fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), io::Error> { fn set_cursor(&mut self, x: u16, y: u16) -> Result<(), io::Error> {
self.pos = (x, y); self.pos = (x, y);
Ok(()) Ok(())

View File

@ -220,10 +220,6 @@ where
Ok(()) Ok(())
} }
pub fn get_cursor(&mut self) -> io::Result<(u16, u16)> {
self.backend.get_cursor()
}
pub fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> { pub fn set_cursor(&mut self, x: u16, y: u16) -> io::Result<()> {
self.backend.set_cursor(x, y) self.backend.set_cursor(x, y)
} }