A simple CPU rendered GUI IDE experience.
Diffstat (limited to 'src/edi.rs')
| -rw-r--r-- | src/edi.rs | 45 |
1 files changed, 33 insertions, 12 deletions
@@ -31,7 +31,7 @@ use crate::bar::Bar; use crate::commands::Cmds; use crate::error::WDebug; use crate::gotolist::{At, GoTo}; -use crate::hov::{self, Hovr, Hovring, Rendered}; +use crate::hov::{self, HOV_HEIGHT, Hovr, Hovring, Rendered}; use crate::lsp::{ Anonymize, Client, Map_, PathURI, RequestError, Rq, tdpp, vsc_settings, }; @@ -390,17 +390,38 @@ impl Editor { } pub fn scroll(&mut self, rows: f32) { let rows = if alt() { rows * 8. } else { rows * 3. }; - let (vo, max) = lower::saturating::math! { if let State::Hovering(Rq {result: Some(Hovring { - rndr: Some(Rendered {scroll, .. }),.. - }), ..}) = &mut self.state && shift() { - // let n = x.item.l(); - // (&mut x.item.vo, n - 15) - todo!() - } else if let Some((_, ref mut vo, Some(max))) = self.requests.sig_help.result && shift(){ - (vo, max - 15) - } else { - let n =self. text.l() - 1; (&mut self.text.vo, n) - }}; + if let State::Hovering(Rq { + result: + Some(Hovring { + rndr: Some(Rendered { scroll: vo, image, .. }), + .. + }), + .. + }) = &mut self.state + && shift() + { + let max = image.height().saturating_sub(HOV_HEIGHT as _); + let rows = rows * 21.; + if rows < 0.0 { + let rows = rows.ceil().abs() as u32; + *vo = (*vo + rows).min(max); + } else { + let rows = rows.floor() as u32; + *vo = vo.saturating_sub(rows); + } + return; + }; + let (vo, max) = lower::saturating::math! { + if let Some((_, ref mut vo, Some(max))) = + self.requests.sig_help.result + && shift() + { + (vo, max - 15) + } else { + let n = self.text.l() - 1; + (&mut self.text.vo, n) + } + }; if rows < 0.0 { let rows = rows.ceil().abs() as usize; *vo = (*vo + rows).min(max); |