|
|
|
@ -84,6 +84,7 @@ pub struct ContentRendererArg {
|
|
|
|
|
pub app: app::LuaContextLight,
|
|
|
|
|
pub screen_size: Rect,
|
|
|
|
|
pub layout_size: Rect,
|
|
|
|
|
pub scrolltop: u16,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
|
|
|
@ -743,7 +744,7 @@ pub fn block<'a>(config: PanelUiConfig, default_title: String) -> Block<'a> {
|
|
|
|
|
pub struct UI<'lua> {
|
|
|
|
|
pub lua: &'lua Lua,
|
|
|
|
|
pub screen_size: TuiRect,
|
|
|
|
|
pub scrolltop: usize,
|
|
|
|
|
pub scrolltop: u16,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<'lua> UI<'lua> {
|
|
|
|
@ -764,8 +765,7 @@ impl UI<'_> {
|
|
|
|
|
let config = panel_config.default.clone().extend(&panel_config.table);
|
|
|
|
|
let app_config = app.config.clone();
|
|
|
|
|
let header_height = app_config.general.table.header.height.unwrap_or(1);
|
|
|
|
|
let height: usize =
|
|
|
|
|
(layout_size.height.max(header_height + 2) - (header_height + 2)).into();
|
|
|
|
|
let height: usize = layout_size.height.saturating_sub(header_height + 2).into();
|
|
|
|
|
let row_style = app_config.general.table.row.style.clone();
|
|
|
|
|
|
|
|
|
|
let rows = app
|
|
|
|
@ -773,16 +773,17 @@ impl UI<'_> {
|
|
|
|
|
.as_ref()
|
|
|
|
|
.map(|dir| {
|
|
|
|
|
// Scroll
|
|
|
|
|
let padding = app.config.general.scroll_padding;
|
|
|
|
|
if app.config.general.paginated_scrolling {
|
|
|
|
|
// Paginated scrolling
|
|
|
|
|
self.scrolltop = height * (dir.focus / height.max(1))
|
|
|
|
|
} else {
|
|
|
|
|
// vim-like-scrolling
|
|
|
|
|
// Vim-like-scrolling
|
|
|
|
|
self.scrolltop = match dir.focus.cmp(&self.scrolltop) {
|
|
|
|
|
Ordering::Greater => {
|
|
|
|
|
// Scrolling down
|
|
|
|
|
if dir.focus >= self.scrolltop + height {
|
|
|
|
|
dir.focus - height + 1
|
|
|
|
|
dir.focus.saturating_sub(height + 1)
|
|
|
|
|
} else {
|
|
|
|
|
self.scrolltop
|
|
|
|
|
}
|
|
|
|
@ -792,7 +793,6 @@ impl UI<'_> {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Add padding if possible
|
|
|
|
|
let padding = app.config.general.scroll_padding;
|
|
|
|
|
if padding != 0 {
|
|
|
|
|
if dir.focus < self.scrolltop + padding {
|
|
|
|
|
self.scrolltop = dir.focus.saturating_sub(padding);
|
|
|
|
@ -1326,6 +1326,7 @@ impl UI<'_> {
|
|
|
|
|
app: app.to_lua_ctx_light(),
|
|
|
|
|
layout_size: layout_size.into(),
|
|
|
|
|
screen_size: self.screen_size.into(),
|
|
|
|
|
scrolltop: self.scrolltop,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let panel: CustomPanel = lua::serialize(self.lua, &ctx)
|
|
|
|
|