Derive more traits for widgets
This commit is contained in:
parent
77e72de9ad
commit
007493f136
6 changed files with 10 additions and 1 deletions
|
|
@ -90,7 +90,7 @@ impl StackFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct Buffer {
|
pub struct Buffer {
|
||||||
size: Size,
|
size: Size,
|
||||||
data: Vec<Cell>,
|
data: Vec<Cell>,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ fn wrap(widthdb: &mut WidthDb, text: &str, width: usize) -> Vec<usize> {
|
||||||
// State //
|
// State //
|
||||||
///////////
|
///////////
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct EditorState {
|
pub struct EditorState {
|
||||||
text: String,
|
text: String,
|
||||||
|
|
||||||
|
|
@ -339,6 +340,7 @@ impl Default for EditorState {
|
||||||
// Widget //
|
// Widget //
|
||||||
////////////
|
////////////
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Editor<'a> {
|
pub struct Editor<'a> {
|
||||||
state: &'a mut EditorState,
|
state: &'a mut EditorState,
|
||||||
highlighted: Styled,
|
highlighted: Styled,
|
||||||
|
|
|
||||||
|
|
@ -229,6 +229,7 @@ fn shrink(mut segments: Vec<&mut Segment>, mut available: u16) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct JoinSegment<I> {
|
pub struct JoinSegment<I> {
|
||||||
pub inner: I,
|
pub inner: I,
|
||||||
weight: f32,
|
weight: f32,
|
||||||
|
|
@ -353,6 +354,7 @@ fn sum_major_max_minor(segments: &[Segment]) -> (u16, u16) {
|
||||||
(major, minor)
|
(major, minor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Join<I> {
|
pub struct Join<I> {
|
||||||
horizontal: bool,
|
horizontal: bool,
|
||||||
segments: Vec<JoinSegment<I>>,
|
segments: Vec<JoinSegment<I>>,
|
||||||
|
|
@ -511,6 +513,7 @@ macro_rules! mk_join {
|
||||||
$( pub $arg:ident: $type:ident [$n:expr], )+
|
$( pub $arg:ident: $type:ident [$n:expr], )+
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct $name< $($type),+ >{
|
pub struct $name< $($type),+ >{
|
||||||
horizontal: bool,
|
horizontal: bool,
|
||||||
$( pub $arg: JoinSegment<$type>, )+
|
$( pub $arg: JoinSegment<$type>, )+
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use async_trait::async_trait;
|
||||||
|
|
||||||
use crate::{AsyncWidget, Frame, Size, Widget, WidthDb};
|
use crate::{AsyncWidget, Frame, Size, Widget, WidthDb};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Layer<I> {
|
pub struct Layer<I> {
|
||||||
layers: Vec<I>,
|
layers: Vec<I>,
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +74,7 @@ macro_rules! mk_layer {
|
||||||
$( pub $arg:ident: $type:ident, )+
|
$( pub $arg:ident: $type:ident, )+
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct $name< $($type),+ >{
|
pub struct $name< $($type),+ >{
|
||||||
$( pub $arg: $type, )+
|
$( pub $arg: $type, )+
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use async_trait::async_trait;
|
||||||
use crate::buffer::Buffer;
|
use crate::buffer::Buffer;
|
||||||
use crate::{AsyncWidget, Frame, Pos, Size, Style, Styled, Widget, WidthDb};
|
use crate::{AsyncWidget, Frame, Pos, Size, Style, Styled, Widget, WidthDb};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Predrawn {
|
pub struct Predrawn {
|
||||||
buffer: Buffer,
|
buffer: Buffer,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use async_trait::async_trait;
|
||||||
|
|
||||||
use crate::{AsyncWidget, Frame, Size, Widget, WidthDb};
|
use crate::{AsyncWidget, Frame, Size, Widget, WidthDb};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct Resize<I> {
|
pub struct Resize<I> {
|
||||||
pub inner: I,
|
pub inner: I,
|
||||||
pub min_width: Option<u16>,
|
pub min_width: Option<u16>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue