mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +02:00
temp 2
This commit is contained in:
parent
c002a3fa3a
commit
7e4139fcd4
10
src/app.rs
10
src/app.rs
@ -29,7 +29,7 @@ use frozen_state::FrozenState;
|
|||||||
use crate::{
|
use crate::{
|
||||||
canvas::Painter,
|
canvas::Painter,
|
||||||
constants,
|
constants,
|
||||||
tuice::{Application, Element, Flex},
|
tuine::{Application, Element, Flex},
|
||||||
units::data_units::DataUnit,
|
units::data_units::DataUnit,
|
||||||
Pid,
|
Pid,
|
||||||
};
|
};
|
||||||
@ -235,8 +235,8 @@ impl Application for AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn view(&mut self) -> Element<'static, Self::Message> {
|
fn view(&mut self) -> Element<'static, Self::Message> {
|
||||||
use crate::tuice::FlexElement;
|
use crate::tuine::FlexElement;
|
||||||
use crate::tuice::TextTable;
|
use crate::tuine::TextTable;
|
||||||
|
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_flex_child(
|
.with_flex_child(
|
||||||
@ -261,9 +261,9 @@ impl Application for AppState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn global_event_handler(
|
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 {
|
match event {
|
||||||
Event::Keyboard(_) => {}
|
Event::Keyboard(_) => {}
|
||||||
Event::Mouse(_) => {}
|
Event::Mouse(_) => {}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
use bottom::{app::AppMessages, options::*, tuice::RuntimeEvent, *};
|
use bottom::{app::AppMessages, options::*, tuine::RuntimeEvent, *};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -102,7 +102,7 @@ fn main() -> Result<()> {
|
|||||||
// TODO: [Threads, Panic] Make this close all the child threads too!
|
// TODO: [Threads, Panic] Make this close all the child threads too!
|
||||||
panic::set_hook(Box::new(|info| panic_hook(info)));
|
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...
|
// I think doing it in this order is safe...
|
||||||
*thread_termination_lock.lock().unwrap() = true;
|
*thread_termination_lock.lock().unwrap() = true;
|
||||||
|
@ -29,7 +29,7 @@ use crossterm::{
|
|||||||
use app::{data_harvester, AppMessages, UsedWidgets};
|
use app::{data_harvester, AppMessages, UsedWidgets};
|
||||||
use constants::*;
|
use constants::*;
|
||||||
use options::*;
|
use options::*;
|
||||||
use tuice::{Event, RuntimeEvent};
|
use tuine::{Event, RuntimeEvent};
|
||||||
use utils::error;
|
use utils::error;
|
||||||
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
@ -43,7 +43,7 @@ pub mod clap;
|
|||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod data_conversion;
|
pub mod data_conversion;
|
||||||
pub mod options;
|
pub mod options;
|
||||||
pub mod tuice;
|
pub mod tuine;
|
||||||
pub(crate) mod units;
|
pub(crate) mod units;
|
||||||
|
|
||||||
// FIXME: Use newtype pattern for PID
|
// FIXME: Use newtype pattern for PID
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
/// A trait that the properties of a [`Component`](super::Component)
|
|
||||||
/// should implement.
|
|
||||||
pub trait Properties: PartialEq {}
|
|
@ -34,7 +34,7 @@ pub trait Application: Sized {
|
|||||||
fn global_event_handler(&mut self, event: Event, messages: &mut Vec<Self::Message>) {}
|
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>(
|
pub fn launch_with_application<A, B>(
|
||||||
application: A, receiver: Receiver<RuntimeEvent<A::Message>>, terminal: &mut Terminal<B>,
|
application: A, receiver: Receiver<RuntimeEvent<A::Message>>, terminal: &mut Terminal<B>,
|
||||||
) -> anyhow::Result<()>
|
) -> anyhow::Result<()>
|
@ -4,9 +4,6 @@ pub use base::*;
|
|||||||
pub mod widget;
|
pub mod widget;
|
||||||
pub use widget::*;
|
pub use widget::*;
|
||||||
|
|
||||||
pub mod properties;
|
|
||||||
pub use properties::*;
|
|
||||||
|
|
||||||
use enum_dispatch::enum_dispatch;
|
use enum_dispatch::enum_dispatch;
|
||||||
use tui::{layout::Rect, Frame};
|
use tui::{layout::Rect, Frame};
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
use tui::{backend::Backend, layout::Rect, Frame};
|
use tui::{backend::Backend, layout::Rect, Frame};
|
||||||
|
|
||||||
use crate::tuice::{DrawContext, Event, Status, TmpComponent};
|
use crate::tuine::{DrawContext, Event, Status, TmpComponent};
|
||||||
|
|
||||||
pub struct Block {}
|
pub struct Block {}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
use tui::{backend::Backend, layout::Rect, Frame};
|
use tui::{backend::Backend, layout::Rect, Frame};
|
||||||
|
|
||||||
use crate::tuice::{DrawContext, Event, Status, TmpComponent};
|
use crate::tuine::{DrawContext, Event, Status, TmpComponent};
|
||||||
|
|
||||||
pub struct Carousel {}
|
pub struct Carousel {}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
use tui::{backend::Backend, layout::Rect, Frame};
|
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.
|
/// A [`Container`] just contains a child, as well as being able to be sized.
|
||||||
///
|
///
|
@ -3,7 +3,7 @@ use tui::{backend::Backend, layout::Rect, Frame};
|
|||||||
pub mod flex_element;
|
pub mod flex_element;
|
||||||
pub use flex_element::FlexElement;
|
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)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub enum Axis {
|
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 {
|
fn on_event(&mut self, area: Rect, event: Event, messages: &mut Vec<Message>) -> Status {
|
||||||
// for child in self.children.iter_mut() {
|
// FIXME: On event for flex
|
||||||
// if let Status::Captured = child.on_event() {
|
|
||||||
// return Status::Captured;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
Status::Ignored
|
Status::Ignored
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
use tui::{backend::Backend, layout::Rect, Frame};
|
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;
|
use super::Axis;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
use tui::{backend::Backend, layout::Rect, Frame};
|
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.
|
/// A [`Component`] to handle keyboard shortcuts and assign actions to them.
|
||||||
///
|
///
|
@ -14,7 +14,7 @@ use unicode_segmentation::UnicodeSegmentation;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
constants::TABLE_GAP_HEIGHT_LIMIT,
|
constants::TABLE_GAP_HEIGHT_LIMIT,
|
||||||
tuice::{DrawContext, Event, Status, TmpComponent},
|
tuine::{DrawContext, Event, Status, TmpComponent},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use self::table_column::{TextColumn, TextColumnConstraint};
|
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 {
|
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};
|
use crossterm::event::{MouseButton, MouseEventKind};
|
||||||
|
|
||||||
match event {
|
match event {
|
@ -1,7 +1,7 @@
|
|||||||
use std::cmp::{min, Ordering};
|
use std::cmp::{min, Ordering};
|
||||||
use tui::{layout::Rect, widgets::TableState};
|
use tui::{layout::Rect, widgets::TableState};
|
||||||
|
|
||||||
use crate::tuice::Status;
|
use crate::tuine::Status;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
enum ScrollDirection {
|
enum ScrollDirection {
|
||||||
@ -197,7 +197,7 @@ impl ScrollState {
|
|||||||
mod test {
|
mod test {
|
||||||
use tui::layout::Rect;
|
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;
|
use super::ScrollState;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
use crate::tuice::Size;
|
use crate::tuine::Size;
|
||||||
|
|
||||||
/// [`Bounds`] represent minimal and maximal widths/height constraints while laying things out.
|
/// [`Bounds`] represent minimal and maximal widths/height constraints while laying things out.
|
||||||
///
|
///
|
@ -1,6 +1,6 @@
|
|||||||
use tui::layout::Rect;
|
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 {
|
pub fn build_layout_tree<Message>(rect: Rect, root: &Element<'_, Message>) -> LayoutNode {
|
||||||
let mut root_layout_node = LayoutNode::from_rect(rect);
|
let mut root_layout_node = LayoutNode::from_rect(rect);
|
@ -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.
|
//! 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
|
//! - Iced
|
||||||
//! - [crochet](https://github.com/raphlinus/crochet)
|
//! - [crochet](https://github.com/raphlinus/crochet)
|
||||||
//! - Flutter
|
//! - Flutter
|
@ -2,7 +2,7 @@ use std::sync::mpsc::Receiver;
|
|||||||
|
|
||||||
use tui::{backend::Backend, layout::Rect, Terminal};
|
use tui::{backend::Backend, layout::Rect, Terminal};
|
||||||
|
|
||||||
use crate::tuice::Status;
|
use crate::tuine::Status;
|
||||||
|
|
||||||
use super::{build_layout_tree, Application, Element, Event, TmpComponent};
|
use super::{build_layout_tree, Application, Element, Event, TmpComponent};
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
use std::any::Any;
|
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 {
|
pub trait State {
|
||||||
fn as_any(&self) -> &dyn Any;
|
fn as_any(&self) -> &dyn Any;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user