Move terminal cleanup to Drop implementation
[?]
Jan 17, 2022, 7:33 PM
272LZTVTE66SQ4BYDORDIBSQFKG3357ZYIUNPVOGUC47VFXOAKVQCDependencies
- [2]
QEKHTVB7Get most things semi-working except the final sort - [3]
LPVC545KGet the scraper part of this program working - [4]
5Y7ZXB53Start picker UI - [5]
CYDK6S5LFix bugs - [6]
G5YNDTPHCargo clippy - [7]
KUANIPWFAdd function for adding name to database - [8]
RNW6D777Minor tidy - [9]
YCWYAX6KFunctions for scraping names integrated enough to test (they don't work yet) - [10]
LLFG625IShould be all the database functions I need - [11]
AV73DYWQInitial functions for using sqlite in async environment - [12]
HMOBTVJ4Initialize crate and add expected dependencies
Change contents
- replacement in src/pick.rs at line 10
use futures::stream::{self, StreamExt};use futures::stream::StreamExt; - replacement in src/pick.rs at line 65
stderr.execute(cursor::Hide)?;terminal::enable_raw_mode()?;let (mut input, _done) = events();let mut comparator = CompareContext {db,events: &mut input,out: &mut stderr,needs_newline: false,};let mut comparator = CompareContext::new(&db, &mut stderr)?; - edit in src/pick.rs at line 106
stderr.execute(cursor::Show)?;terminal::disable_raw_mode()?; - replacement in src/pick.rs at line 112
struct CompareContext<'a, W> {struct CompareContext<'a, W: std::io::Write> { - replacement in src/pick.rs at line 114
events: &'a mut stream::Abortable<EventStream>,events: EventStream, - edit in src/pick.rs at line 117
}impl<'a, W: std::io::Write> std::ops::Drop for CompareContext<'a, W> {fn drop(&mut self) {self.out.execute(cursor::Show).ok();terminal::disable_raw_mode().ok();} - edit in src/pick.rs at line 127
fn new(db: &'a AsyncConnection, out: &'a mut W) -> DynResult<Self> {out.execute(cursor::Hide)?;terminal::enable_raw_mode()?;Ok(Self {db,events: EventStream::new(),out,needs_newline: false,})} - edit in src/pick.rs at line 238
pub fn events() -> (stream::Abortable<EventStream>, stream::AbortHandle) {stream::abortable(EventStream::new())} - replacement in src/main.rs at line 23[3.112]→[2.6750:7082](∅→∅),[3.168]→[3.1643:1653](∅→∅),[3.779]→[3.1643:1653](∅→∅),[3.1078]→[3.1643:1653](∅→∅),[3.5371]→[3.1643:1653](∅→∅),[2.7082]→[3.1643:1653](∅→∅),[3.1643]→[3.1643:1653](∅→∅),[3.1653]→[2.7083:7091](∅→∅)
match pick::pick(&db, args.count, args.gather).await {Ok(r) => Ok(r),Err(e) => {use crossterm::ExecutableCommand;let mut stderr = std::io::stderr();stderr.execute(crossterm::cursor::Show).ok();crossterm::terminal::disable_raw_mode().ok();Err(e)}}?;pick::pick(&db, args.count, args.gather).await?;