meli: Move components/utilities -> utilities
parent
a5446975c2
commit
005bf3881e
|
@ -38,9 +38,6 @@ pub use mail::*;
|
|||
|
||||
pub mod notifications;
|
||||
|
||||
pub mod utilities;
|
||||
pub use utilities::*;
|
||||
|
||||
pub mod contacts;
|
||||
pub use contacts::*;
|
||||
|
||||
|
@ -119,9 +116,9 @@ pub enum PageMovement {
|
|||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ScrollContext {
|
||||
shown_lines: usize,
|
||||
total_lines: usize,
|
||||
has_more_lines: bool,
|
||||
pub shown_lines: usize,
|
||||
pub total_lines: usize,
|
||||
pub has_more_lines: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
@ -275,8 +272,8 @@ impl Default for ComponentAttr {
|
|||
|
||||
#[derive(Eq, PartialEq, Debug, Clone)]
|
||||
pub struct ComponentPath {
|
||||
id: ComponentId,
|
||||
tail: SmallVec<[ComponentId; 8]>,
|
||||
pub id: ComponentId,
|
||||
pub tail: SmallVec<[ComponentId; 8]>,
|
||||
}
|
||||
|
||||
impl ComponentPath {
|
||||
|
|
|
@ -121,7 +121,7 @@ pub enum ProgressSpinnerSequence {
|
|||
}
|
||||
|
||||
const fn interval_ms_val() -> u64 {
|
||||
crate::components::utilities::ProgressSpinner::INTERVAL_MS
|
||||
crate::utilities::ProgressSpinner::INTERVAL_MS
|
||||
}
|
||||
|
||||
impl DotAddressable for ProgressSpinnerSequence {}
|
||||
|
|
|
@ -74,6 +74,9 @@ pub use crate::state::*;
|
|||
pub mod components;
|
||||
pub use crate::components::*;
|
||||
|
||||
pub mod utilities;
|
||||
pub use crate::utilities::*;
|
||||
|
||||
#[macro_use]
|
||||
pub mod conf;
|
||||
pub use crate::conf::{
|
||||
|
|
|
@ -19,50 +19,17 @@
|
|||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern crate melib;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use melib::*;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate linkify;
|
||||
|
||||
extern crate meli;
|
||||
extern crate melib;
|
||||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
extern crate smallvec;
|
||||
extern crate termion;
|
||||
|
||||
use melib::{imap::managesieve::ManageSieveConnection, Result};
|
||||
|
||||
#[macro_use]
|
||||
pub mod types;
|
||||
use crate::types::*;
|
||||
|
||||
#[macro_use]
|
||||
pub mod terminal;
|
||||
use crate::terminal::*;
|
||||
|
||||
#[macro_use]
|
||||
pub mod command;
|
||||
use crate::command::*;
|
||||
|
||||
pub mod state;
|
||||
use crate::state::*;
|
||||
|
||||
pub mod components;
|
||||
use crate::components::*;
|
||||
|
||||
#[macro_use]
|
||||
pub mod conf;
|
||||
use crate::conf::*;
|
||||
|
||||
#[cfg(feature = "sqlite3")]
|
||||
pub mod sqlite3;
|
||||
|
||||
pub mod jobs;
|
||||
pub mod mailcap;
|
||||
//pub mod plugins;
|
||||
|
||||
use futures::executor::block_on;
|
||||
use meli::*;
|
||||
use melib::{imap::managesieve::ManageSieveConnection, Result, *};
|
||||
|
||||
/// Opens an interactive shell on a managesieve server. Suggested use is with
|
||||
/// rlwrap(1)
|
||||
|
@ -84,7 +51,7 @@ fn main() -> Result<()> {
|
|||
|
||||
let (config_path, account_name) = (std::mem::take(&mut args[0]), std::mem::take(&mut args[1]));
|
||||
std::env::set_var("MELI_CONFIG", config_path);
|
||||
let settings = conf::Settings::new()?;
|
||||
let settings = meli::conf::Settings::new()?;
|
||||
if !settings.accounts.contains_key(&account_name) {
|
||||
eprintln!(
|
||||
"Account not found. available accounts: {}",
|
||||
|
|
|
@ -1370,20 +1370,20 @@ impl RowIterator {
|
|||
pub use boundaries::create_box;
|
||||
pub mod boundaries {
|
||||
use super::*;
|
||||
pub(crate) const HORZ_BOUNDARY: char = '─';
|
||||
pub(crate) const VERT_BOUNDARY: char = '│';
|
||||
pub(crate) const _TOP_LEFT_CORNER: char = '┌';
|
||||
pub(crate) const _TOP_RIGHT_CORNER: char = '┐';
|
||||
pub(crate) const _BOTTOM_LEFT_CORNER: char = '└';
|
||||
pub(crate) const _BOTTOM_RIGHT_CORNER: char = '┘';
|
||||
pub(crate) const LIGHT_VERTICAL_AND_RIGHT: char = '├';
|
||||
pub(crate) const _LIGHT_VERTICAL_AND_LEFT: char = '┤';
|
||||
pub(crate) const _LIGHT_DOWN_AND_HORIZONTAL: char = '┬';
|
||||
pub(crate) const _LIGHT_UP_AND_HORIZONTAL: char = '┴';
|
||||
pub(crate) const _DOUBLE_DOWN_AND_RIGHT: char = '╔';
|
||||
pub(crate) const _DOUBLE_DOWN_AND_LEFT: char = '╗';
|
||||
pub(crate) const _DOUBLE_UP_AND_LEFT: char = '╝';
|
||||
pub(crate) const _DOUBLE_UP_AND_RIGHT: char = '╚';
|
||||
pub const HORZ_BOUNDARY: char = '─';
|
||||
pub const VERT_BOUNDARY: char = '│';
|
||||
pub const _TOP_LEFT_CORNER: char = '┌';
|
||||
pub const _TOP_RIGHT_CORNER: char = '┐';
|
||||
pub const _BOTTOM_LEFT_CORNER: char = '└';
|
||||
pub const _BOTTOM_RIGHT_CORNER: char = '┘';
|
||||
pub const LIGHT_VERTICAL_AND_RIGHT: char = '├';
|
||||
pub const _LIGHT_VERTICAL_AND_LEFT: char = '┤';
|
||||
pub const _LIGHT_DOWN_AND_HORIZONTAL: char = '┬';
|
||||
pub const _LIGHT_UP_AND_HORIZONTAL: char = '┴';
|
||||
pub const _DOUBLE_DOWN_AND_RIGHT: char = '╔';
|
||||
pub const _DOUBLE_DOWN_AND_LEFT: char = '╗';
|
||||
pub const _DOUBLE_UP_AND_LEFT: char = '╝';
|
||||
pub const _DOUBLE_UP_AND_RIGHT: char = '╚';
|
||||
|
||||
fn bin_to_ch(b: u32) -> char {
|
||||
match b {
|
||||
|
@ -1618,12 +1618,12 @@ pub mod boundaries {
|
|||
bin_set
|
||||
}
|
||||
|
||||
pub(crate) enum BoxBoundary {
|
||||
pub enum BoxBoundary {
|
||||
Horizontal,
|
||||
Vertical,
|
||||
}
|
||||
|
||||
pub(crate) fn set_and_join_box(grid: &mut CellBuffer, idx: Pos, ch: BoxBoundary) {
|
||||
pub fn set_and_join_box(grid: &mut CellBuffer, idx: Pos, ch: BoxBoundary) {
|
||||
/* Connected sides:
|
||||
*
|
||||
* 1
|
||||
|
|
|
@ -45,8 +45,10 @@ pub use self::dialogs::*;
|
|||
mod tables;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use indexmap::IndexMap;
|
||||
|
||||
pub use self::tables::*;
|
||||
use crate::jobs::JobId;
|
||||
use crate::{jobs::JobId, melib::text_processing::TextProcessing};
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct SearchPattern {
|
||||
|
@ -80,8 +82,8 @@ pub struct StatusBar {
|
|||
cmd_history: Vec<String>,
|
||||
}
|
||||
|
||||
impl fmt::Display for StatusBar {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for StatusBar {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "status bar")
|
||||
}
|
||||
}
|
||||
|
@ -947,8 +949,8 @@ impl Tabbed {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Tabbed {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for Tabbed {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "tabs")
|
||||
}
|
||||
}
|
||||
|
@ -1631,9 +1633,9 @@ pub struct RawBuffer {
|
|||
dirty: bool,
|
||||
}
|
||||
|
||||
impl fmt::Display for RawBuffer {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt("Raw buffer", f)
|
||||
impl std::fmt::Display for RawBuffer {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt("Raw buffer", f)
|
||||
}
|
||||
}
|
||||
|
|
@ -45,8 +45,10 @@ enum SelectorCursor {
|
|||
/// component, check Selector::is_done to see if the user has finalised their
|
||||
/// choices. Collect the choices by consuming the Selector with
|
||||
/// Selector::collect()
|
||||
pub struct Selector<T: 'static + PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send>
|
||||
{
|
||||
pub struct Selector<
|
||||
T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send,
|
||||
F: 'static + Sync + Send,
|
||||
> {
|
||||
/// allow only one selection
|
||||
single_only: bool,
|
||||
entries: Vec<(T, bool)>,
|
||||
|
@ -76,31 +78,31 @@ pub type UIDialog<T> = Selector<
|
|||
Option<Box<dyn FnOnce(ComponentId, &[T]) -> Option<UIEvent> + 'static + Sync + Send>>,
|
||||
>;
|
||||
|
||||
impl<T: 'static + PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> fmt::Debug
|
||||
for Selector<T, F>
|
||||
impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send, F: 'static + Sync + Send>
|
||||
std::fmt::Debug for Selector<T, F>
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt("Selector", f)
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt("Selector", f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static + PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> fmt::Display
|
||||
for Selector<T, F>
|
||||
impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send, F: 'static + Sync + Send>
|
||||
std::fmt::Display for Selector<T, F>
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt("Selector", f)
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt("Selector", f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static + PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> PartialEq
|
||||
for Selector<T, F>
|
||||
impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send, F: 'static + Sync + Send>
|
||||
PartialEq for Selector<T, F>
|
||||
{
|
||||
fn eq(&self, other: &Selector<T, F>) -> bool {
|
||||
self.entries == other.entries
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialog<T> {
|
||||
impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send> Component for UIDialog<T> {
|
||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||
Selector::draw(self, grid, area, context);
|
||||
}
|
||||
|
@ -752,7 +754,9 @@ impl Component for UIConfirmationDialog {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selector<T, F> {
|
||||
impl<T: PartialEq + std::fmt::Debug + Clone + Sync + Send, F: 'static + Sync + Send>
|
||||
Selector<T, F>
|
||||
{
|
||||
pub fn new(
|
||||
title: &str,
|
||||
mut entries: Vec<(T, String)>,
|
||||
|
@ -927,7 +931,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> UIDialog<T> {
|
||||
impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send> UIDialog<T> {
|
||||
fn done(&mut self) -> Option<UIEvent> {
|
||||
let Self {
|
||||
ref mut done_fn,
|
|
@ -20,6 +20,9 @@
|
|||
*/
|
||||
|
||||
use super::*;
|
||||
use crate::terminal::cells::boundaries::{
|
||||
HORZ_BOUNDARY, VERT_BOUNDARY, _LIGHT_DOWN_AND_HORIZONTAL, _LIGHT_UP_AND_HORIZONTAL,
|
||||
};
|
||||
|
||||
/// A horizontally split in half container.
|
||||
#[derive(Debug)]
|
||||
|
@ -31,9 +34,9 @@ pub struct HSplit {
|
|||
id: ComponentId,
|
||||
}
|
||||
|
||||
impl fmt::Display for HSplit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt(&self.top, f)
|
||||
impl std::fmt::Display for HSplit {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(&self.top, f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,10 +127,10 @@ pub struct VSplit {
|
|||
id: ComponentId,
|
||||
}
|
||||
|
||||
impl fmt::Display for VSplit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for VSplit {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
// [ref:TODO]: display focused component
|
||||
Display::fmt(&self.right, f)
|
||||
std::fmt::Display::fmt(&self.right, f)
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use melib::text_processing::LineBreakText;
|
||||
use melib::text_processing::{LineBreakText, Truncate};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -56,8 +56,8 @@ pub struct Pager {
|
|||
id: ComponentId,
|
||||
}
|
||||
|
||||
impl fmt::Display for Pager {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for Pager {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "pager")
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
use super::*;
|
||||
use crate::melib::text_processing::Truncate;
|
||||
|
||||
pub struct TextField {
|
||||
inner: UText,
|
||||
|
@ -27,8 +28,8 @@ pub struct TextField {
|
|||
id: ComponentId,
|
||||
}
|
||||
|
||||
impl Debug for TextField {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Debug for TextField {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fmt.debug_struct(stringify!(TextField))
|
||||
.field("id", &self.id)
|
||||
.field("inner", &self.inner)
|
||||
|
@ -320,8 +321,8 @@ impl Component for TextField {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for TextField {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for TextField {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{}", self.as_str(),)
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
use std::{borrow::Cow, collections::HashMap, time::Duration};
|
||||
|
||||
use super::*;
|
||||
use crate::melib::text_processing::TextProcessing;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Default)]
|
||||
enum FormFocus {
|
||||
|
@ -38,11 +39,11 @@ pub enum Field {
|
|||
Choice(Vec<Cow<'static, str>>, Cursor, ComponentId),
|
||||
}
|
||||
|
||||
impl Debug for Field {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Debug for Field {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Text(ref t) => fmt::Debug::fmt(t, f),
|
||||
k => fmt::Debug::fmt(k, f),
|
||||
Self::Text(ref t) => std::fmt::Debug::fmt(t, f),
|
||||
k => std::fmt::Debug::fmt(k, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,8 +182,8 @@ impl Component for Field {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Field {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for Field {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
|
@ -240,8 +241,10 @@ impl<T: 'static + std::fmt::Debug + Copy + Default + Send + Sync> Default for Fo
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: 'static + std::fmt::Debug + Copy + Default + Send + Sync> fmt::Display for FormWidget<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl<T: 'static + std::fmt::Debug + Copy + Default + Send + Sync> std::fmt::Display
|
||||
for FormWidget<T>
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "form")
|
||||
}
|
||||
}
|
||||
|
@ -588,12 +591,12 @@ where
|
|||
id: ComponentId,
|
||||
}
|
||||
|
||||
impl<T> fmt::Display for ButtonWidget<T>
|
||||
impl<T> std::fmt::Display for ButtonWidget<T>
|
||||
where
|
||||
T: 'static + std::fmt::Debug + Copy + Default + Send + Sync,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt("", f)
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt("", f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -763,9 +766,9 @@ pub struct AutoComplete {
|
|||
id: ComponentId,
|
||||
}
|
||||
|
||||
impl fmt::Display for AutoComplete {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
Display::fmt("AutoComplete", f)
|
||||
impl std::fmt::Display for AutoComplete {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt("AutoComplete", f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1232,8 +1235,8 @@ impl ProgressSpinner {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ProgressSpinner {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
impl std::fmt::Display for ProgressSpinner {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "progress bar")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue