This commit is contained in:
ClementTsang 2021-12-18 22:25:42 -05:00
parent c002a3fa3a
commit 7e4139fcd4
34 changed files with 27 additions and 37 deletions

View File

@ -29,7 +29,7 @@ use frozen_state::FrozenState;
use crate::{
canvas::Painter,
constants,
tuice::{Application, Element, Flex},
tuine::{Application, Element, Flex},
units::data_units::DataUnit,
Pid,
};
@ -235,8 +235,8 @@ impl Application for AppState {
}
fn view(&mut self) -> Element<'static, Self::Message> {
use crate::tuice::FlexElement;
use crate::tuice::TextTable;
use crate::tuine::FlexElement;
use crate::tuine::TextTable;
Flex::column()
.with_flex_child(
@ -261,9 +261,9 @@ impl Application for AppState {
}
fn global_event_handler(
&mut self, event: crate::tuice::Event, _messages: &mut Vec<Self::Message>,
&mut self, event: crate::tuine::Event, _messages: &mut Vec<Self::Message>,
) {
use crate::tuice::Event;
use crate::tuine::Event;
match event {
Event::Keyboard(_) => {}
Event::Mouse(_) => {}

View File

@ -4,7 +4,7 @@
#[macro_use]
extern crate log;
use bottom::{app::AppMessages, options::*, tuice::RuntimeEvent, *};
use bottom::{app::AppMessages, options::*, tuine::RuntimeEvent, *};
use std::{
boxed::Box,
@ -102,7 +102,7 @@ fn main() -> Result<()> {
// TODO: [Threads, Panic] Make this close all the child threads too!
panic::set_hook(Box::new(|info| panic_hook(info)));
tuice::launch_with_application(app, receiver, &mut terminal)?; // FIXME: Move terminal construction INSIDE
tuine::launch_with_application(app, receiver, &mut terminal)?; // FIXME: Move terminal construction INSIDE
// I think doing it in this order is safe...
*thread_termination_lock.lock().unwrap() = true;

View File

@ -29,7 +29,7 @@ use crossterm::{
use app::{data_harvester, AppMessages, UsedWidgets};
use constants::*;
use options::*;
use tuice::{Event, RuntimeEvent};
use tuine::{Event, RuntimeEvent};
use utils::error;
pub mod app;
@ -43,7 +43,7 @@ pub mod clap;
pub mod constants;
pub mod data_conversion;
pub mod options;
pub mod tuice;
pub mod tuine;
pub(crate) mod units;
// FIXME: Use newtype pattern for PID

View File

@ -1,3 +0,0 @@
/// A trait that the properties of a [`Component`](super::Component)
/// should implement.
pub trait Properties: PartialEq {}

View File

@ -34,7 +34,7 @@ pub trait Application: Sized {
fn global_event_handler(&mut self, event: Event, messages: &mut Vec<Self::Message>) {}
}
/// Launches some application with tuice. Note this will take over the calling thread.
/// Launches some application with tuine. Note this will take over the calling thread.
pub fn launch_with_application<A, B>(
application: A, receiver: Receiver<RuntimeEvent<A::Message>>, terminal: &mut Terminal<B>,
) -> anyhow::Result<()>

View File

@ -4,9 +4,6 @@ pub use base::*;
pub mod widget;
pub use widget::*;
pub mod properties;
pub use properties::*;
use enum_dispatch::enum_dispatch;
use tui::{layout::Rect, Frame};

View File

@ -1,6 +1,6 @@
use tui::{backend::Backend, layout::Rect, Frame};
use crate::tuice::{DrawContext, Event, Status, TmpComponent};
use crate::tuine::{DrawContext, Event, Status, TmpComponent};
pub struct Block {}

View File

@ -1,6 +1,6 @@
use tui::{backend::Backend, layout::Rect, Frame};
use crate::tuice::{DrawContext, Event, Status, TmpComponent};
use crate::tuine::{DrawContext, Event, Status, TmpComponent};
pub struct Carousel {}

View File

@ -1,6 +1,6 @@
use tui::{backend::Backend, layout::Rect, Frame};
use crate::tuice::{Bounds, DrawContext, Element, Event, LayoutNode, Size, Status, TmpComponent};
use crate::tuine::{Bounds, DrawContext, Element, Event, LayoutNode, Size, Status, TmpComponent};
/// A [`Container`] just contains a child, as well as being able to be sized.
///

View File

@ -3,7 +3,7 @@ use tui::{backend::Backend, layout::Rect, Frame};
pub mod flex_element;
pub use flex_element::FlexElement;
use crate::tuice::{Bounds, DrawContext, Element, Event, LayoutNode, Size, Status, TmpComponent};
use crate::tuine::{Bounds, DrawContext, Element, Event, LayoutNode, Size, Status, TmpComponent};
#[derive(Clone, Copy, Debug)]
pub enum Axis {
@ -99,11 +99,7 @@ impl<'a, Message> TmpComponent<Message> for Flex<'a, Message> {
}
fn on_event(&mut self, area: Rect, event: Event, messages: &mut Vec<Message>) -> Status {
// for child in self.children.iter_mut() {
// if let Status::Captured = child.on_event() {
// return Status::Captured;
// }
// }
// FIXME: On event for flex
Status::Ignored
}

View File

@ -1,6 +1,6 @@
use tui::{backend::Backend, layout::Rect, Frame};
use crate::tuice::{Bounds, DrawContext, Element, Event, LayoutNode, Size, Status, TmpComponent};
use crate::tuine::{Bounds, DrawContext, Element, Event, LayoutNode, Size, Status, TmpComponent};
use super::Axis;

View File

@ -1,6 +1,6 @@
use tui::{backend::Backend, layout::Rect, Frame};
use crate::tuice::{DrawContext, Event, Status, TmpComponent};
use crate::tuine::{DrawContext, Event, Status, TmpComponent};
/// A [`Component`] to handle keyboard shortcuts and assign actions to them.
///

View File

@ -14,7 +14,7 @@ use unicode_segmentation::UnicodeSegmentation;
use crate::{
constants::TABLE_GAP_HEIGHT_LIMIT,
tuice::{DrawContext, Event, Status, TmpComponent},
tuine::{DrawContext, Event, Status, TmpComponent},
};
pub use self::table_column::{TextColumn, TextColumnConstraint};
@ -220,7 +220,7 @@ impl<'a, Message> TmpComponent<Message> for TextTable<'a, Message> {
}
fn on_event(&mut self, area: Rect, event: Event, messages: &mut Vec<Message>) -> Status {
use crate::tuice::MouseBoundIntersect;
use crate::tuine::MouseBoundIntersect;
use crossterm::event::{MouseButton, MouseEventKind};
match event {

View File

@ -1,7 +1,7 @@
use std::cmp::{min, Ordering};
use tui::{layout::Rect, widgets::TableState};
use crate::tuice::Status;
use crate::tuine::Status;
#[derive(Debug, PartialEq, Eq)]
enum ScrollDirection {
@ -197,7 +197,7 @@ impl ScrollState {
mod test {
use tui::layout::Rect;
use crate::tuice::{text_table::table_scroll_state::ScrollDirection, Status};
use crate::tuine::{text_table::table_scroll_state::ScrollDirection, Status};
use super::ScrollState;

View File

@ -1,4 +1,4 @@
use crate::tuice::Size;
use crate::tuine::Size;
/// [`Bounds`] represent minimal and maximal widths/height constraints while laying things out.
///

View File

@ -1,6 +1,6 @@
use tui::layout::Rect;
use crate::tuice::{Bounds, Element, LayoutNode, TmpComponent};
use crate::tuine::{Bounds, Element, LayoutNode, TmpComponent};
pub fn build_layout_tree<Message>(rect: Rect, root: &Element<'_, Message>) -> LayoutNode {
let mut root_layout_node = LayoutNode::from_rect(rect);

View File

@ -1,7 +1,7 @@
//! tuice is a wrapper around tui-rs that expands upon state management and
//! tuine is a wrapper around tui-rs that expands upon state management and
//! event handling.
//!
//! tuice is inspired by a **ton** of other libraries and frameworks, like:
//! tuine is inspired by a **ton** of other libraries and frameworks, like:
//! - Iced
//! - [crochet](https://github.com/raphlinus/crochet)
//! - Flutter

View File

@ -2,7 +2,7 @@ use std::sync::mpsc::Receiver;
use tui::{backend::Backend, layout::Rect, Terminal};
use crate::tuice::Status;
use crate::tuine::Status;
use super::{build_layout_tree, Application, Element, Event, TmpComponent};

View File

@ -3,7 +3,7 @@
use std::any::Any;
/// A trait that any sort of [`Component`](crate::tuice::Component) state should implement.
/// A trait that any sort of [`Component`](crate::tuine::Component) state should implement.
pub trait State {
fn as_any(&self) -> &dyn Any;