/*
* meli
*
* Copyright 2017-2018 Manos Pitsidianakis
*
* This file is part of meli.
*
* meli is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* meli is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
use super::*;
use crate::components::PageMovement;
use std::cmp;
use std::convert::TryInto;
macro_rules! row_attr {
($color_cache:expr, $even: expr, $unseen:expr, $highlighted:expr, $selected:expr $(,)*) => {{
ThemeAttribute {
fg: if $highlighted {
if $even {
$color_cache.even_highlighted.fg
} else {
$color_cache.odd_highlighted.fg
}
} else if $selected {
if $even {
$color_cache.even_selected.fg
} else {
$color_cache.odd_selected.fg
}
} else if $unseen {
if $even {
$color_cache.even_unseen.fg
} else {
$color_cache.odd_unseen.fg
}
} else if $even {
$color_cache.even.fg
} else {
$color_cache.odd.fg
},
bg: if $highlighted {
if $even {
$color_cache.even_highlighted.bg
} else {
$color_cache.odd_highlighted.bg
}
} else if $selected {
if $even {
$color_cache.even_selected.bg
} else {
$color_cache.odd_selected.bg
}
} else if $unseen {
if $even {
$color_cache.even_unseen.bg
} else {
$color_cache.odd_unseen.bg
}
} else if $even {
$color_cache.even.bg
} else {
$color_cache.odd.bg
},
attrs: if $highlighted {
if $even {
$color_cache.even_highlighted.attrs
} else {
$color_cache.odd_hi