mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Directly use crate::Vec2
This commit is contained in:
parent
cd26e40fcb
commit
4c00dd3b72
@ -1,5 +1,5 @@
|
|||||||
use cursive::traits::*;
|
use cursive::traits::*;
|
||||||
use cursive::vec::Vec2;
|
use cursive::Vec2;
|
||||||
use cursive::{Cursive, Printer};
|
use cursive::{Cursive, Printer};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use cursive::vec::Vec2;
|
use cursive::Vec2;
|
||||||
use rand::{thread_rng, Rng};
|
use rand::{thread_rng, Rng};
|
||||||
// use std::cmp::max;
|
// use std::cmp::max;
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ mod game;
|
|||||||
use cursive::direction::Direction;
|
use cursive::direction::Direction;
|
||||||
use cursive::event::{Event, EventResult, MouseButton, MouseEvent};
|
use cursive::event::{Event, EventResult, MouseButton, MouseEvent};
|
||||||
use cursive::theme::{BaseColor, Color, ColorStyle};
|
use cursive::theme::{BaseColor, Color, ColorStyle};
|
||||||
use cursive::vec::Vec2;
|
|
||||||
use cursive::views::{Button, Dialog, LinearLayout, Panel, SelectView};
|
use cursive::views::{Button, Dialog, LinearLayout, Panel, SelectView};
|
||||||
use cursive::Cursive;
|
use cursive::Cursive;
|
||||||
use cursive::Printer;
|
use cursive::Printer;
|
||||||
|
use cursive::Vec2;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut siv = Cursive::default();
|
let mut siv = Cursive::default();
|
||||||
|
@ -14,7 +14,7 @@ use self::bear_lib_terminal::Color as BltColor;
|
|||||||
use crate::backend;
|
use crate::backend;
|
||||||
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
||||||
use crate::theme::{BaseColor, Color, ColorPair, Effect};
|
use crate::theme::{BaseColor, Color, ColorPair, Effect};
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
|
|
||||||
// Use AHash instead of the slower SipHash
|
// Use AHash instead of the slower SipHash
|
||||||
type HashSet<K> = std::collections::HashSet<K, ahash::ABuildHasher>;
|
type HashSet<K> = std::collections::HashSet<K, ahash::ABuildHasher>;
|
||||||
|
@ -32,8 +32,7 @@ use crossterm::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
backend,
|
backend,
|
||||||
event::{Event, Key, MouseButton, MouseEvent},
|
event::{Event, Key, MouseButton, MouseEvent},
|
||||||
theme,
|
theme, Vec2,
|
||||||
vec::Vec2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -14,7 +14,7 @@ use crate::backend;
|
|||||||
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
||||||
use crate::theme::{Color, ColorPair, Effect};
|
use crate::theme::{Color, ColorPair, Effect};
|
||||||
use crate::utf8;
|
use crate::utf8;
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
|
|
||||||
use self::super::split_i32;
|
use self::super::split_i32;
|
||||||
use self::ncurses::mmask_t;
|
use self::ncurses::mmask_t;
|
||||||
|
@ -8,7 +8,7 @@ use std::io::{stdout, Write};
|
|||||||
use crate::backend;
|
use crate::backend;
|
||||||
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
||||||
use crate::theme::{Color, ColorPair, Effect};
|
use crate::theme::{Color, ColorPair, Effect};
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
|
|
||||||
use self::pancurses::mmask_t;
|
use self::pancurses::mmask_t;
|
||||||
use super::split_i32;
|
use super::split_i32;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use crate::backend;
|
use crate::backend;
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
|
|
||||||
/// Dummy backend that does nothing and immediately exits.
|
/// Dummy backend that does nothing and immediately exits.
|
||||||
///
|
///
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -7,7 +7,7 @@ use crate::backend::puppet::observed::ObservedScreen;
|
|||||||
use crate::backend::puppet::observed::ObservedStyle;
|
use crate::backend::puppet::observed::ObservedStyle;
|
||||||
use crate::event::Event;
|
use crate::event::Event;
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
@ -3,7 +3,7 @@ use lazy_static::lazy_static;
|
|||||||
|
|
||||||
use crate::theme::ColorPair;
|
use crate::theme::ColorPair;
|
||||||
use crate::theme::{Color, Effect};
|
use crate::theme::{Color, Effect};
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
use enumset::EnumSet;
|
use enumset::EnumSet;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ use crossbeam_channel::{self, select, Receiver};
|
|||||||
use crate::backend;
|
use crate::backend;
|
||||||
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
use crate::event::{Event, Key, MouseButton, MouseEvent};
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -11,9 +11,9 @@ use crate::direction;
|
|||||||
use crate::event::{Callback, Event, EventResult};
|
use crate::event::{Callback, Event, EventResult};
|
||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{self, Finder, IntoBoxedView, Position, View};
|
use crate::view::{self, Finder, IntoBoxedView, Position, View};
|
||||||
use crate::views::{self, LayerPosition};
|
use crate::views::{self, LayerPosition};
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
static DEBUG_VIEW_NAME: &str = "_cursive_debug_view";
|
static DEBUG_VIEW_NAME: &str = "_cursive_debug_view";
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
//! `Tab` key would usually cycle focus in the "front" direction, while
|
//! `Tab` key would usually cycle focus in the "front" direction, while
|
||||||
//! using the arrow keys would use absolute directions instead.
|
//! using the arrow keys would use absolute directions instead.
|
||||||
|
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
|
|
||||||
/// Describes a vertical or horizontal orientation for a view.
|
/// Describes a vertical or horizontal orientation for a view.
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
//! [`on_event`]: crate::View::on_event
|
//! [`on_event`]: crate::View::on_event
|
||||||
//! [global callback]: crate::Cursive::add_global_callback
|
//! [global callback]: crate::Cursive::add_global_callback
|
||||||
|
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
|
use crate::Vec2;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
@ -6,8 +6,8 @@ use crate::theme::{
|
|||||||
BorderStyle, ColorStyle, Effect, PaletteColor, Style, Theme,
|
BorderStyle, ColorStyle, Effect, PaletteColor, Style, Theme,
|
||||||
};
|
};
|
||||||
use crate::utils::lines::simple::{prefix, suffix};
|
use crate::utils::lines::simple::{prefix, suffix};
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::with::With;
|
use crate::with::With;
|
||||||
|
use crate::Vec2;
|
||||||
use enumset::EnumSet;
|
use enumset::EnumSet;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//! Rectangles on the 2D character grid.
|
//! Rectangles on the 2D character grid.
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
/// A non-empty rectangle on the 2D grid.
|
/// A non-empty rectangle on the 2D grid.
|
||||||
|
32
src/vec.rs
32
src/vec.rs
@ -38,7 +38,7 @@ impl XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// assert!(Vec2::new(9999, 9999) < Vec2::max_value());
|
/// assert!(Vec2::new(9999, 9999) < Vec2::max_value());
|
||||||
/// ```
|
/// ```
|
||||||
pub fn max_value() -> Self {
|
pub fn max_value() -> Self {
|
||||||
@ -52,7 +52,7 @@ impl XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let u = Vec2::new(1, 2);
|
/// let u = Vec2::new(1, 2);
|
||||||
/// let v = Vec2::new(2, 1);
|
/// let v = Vec2::new(2, 1);
|
||||||
/// assert_eq!(u.saturating_sub(v), Vec2::new(0, 1));
|
/// assert_eq!(u.saturating_sub(v), Vec2::new(0, 1));
|
||||||
@ -69,7 +69,7 @@ impl XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// # use cursive::XY;
|
/// # use cursive::XY;
|
||||||
/// let u = Vec2::new(1, 2);
|
/// let u = Vec2::new(1, 2);
|
||||||
/// let v = XY::<isize>::new(-2, 1);
|
/// let v = XY::<isize>::new(-2, 1);
|
||||||
@ -92,7 +92,7 @@ impl XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let u = Vec2::new(1, 6);
|
/// let u = Vec2::new(1, 6);
|
||||||
/// let v = Vec2::new(2, 3);
|
/// let v = Vec2::new(2, 3);
|
||||||
/// assert_eq!(u.div_up(v), Vec2::new(1, 2));
|
/// assert_eq!(u.div_up(v), Vec2::new(1, 2));
|
||||||
@ -113,7 +113,7 @@ impl XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let xy = Vec2::new(1, 2);
|
/// let xy = Vec2::new(1, 2);
|
||||||
/// assert_eq!(xy.checked_sub((1, 1)), Some(Vec2::new(0, 1)));
|
/// assert_eq!(xy.checked_sub((1, 1)), Some(Vec2::new(0, 1)));
|
||||||
/// assert_eq!(xy.checked_sub((2, 2)), None);
|
/// assert_eq!(xy.checked_sub((2, 2)), None);
|
||||||
@ -132,7 +132,7 @@ impl XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// # use cursive::XY;
|
/// # use cursive::XY;
|
||||||
/// let v: XY<isize> = Vec2::new(1, 2).signed().map(|i| i - 5);
|
/// let v: XY<isize> = Vec2::new(1, 2).signed().map(|i| i - 5);
|
||||||
/// assert_eq!(v, XY::new(-4, -3));
|
/// assert_eq!(v, XY::new(-4, -3));
|
||||||
@ -155,7 +155,7 @@ impl<T: Ord> XY<T> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let v = Vec2::new(1, 2);
|
/// let v = Vec2::new(1, 2);
|
||||||
/// assert!(v.fits_in((1, 2)));
|
/// assert!(v.fits_in((1, 2)));
|
||||||
/// assert!(v.fits_in((3, 3)));
|
/// assert!(v.fits_in((3, 3)));
|
||||||
@ -175,7 +175,7 @@ impl<T: Ord> XY<T> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let v = Vec2::new(1, 2);
|
/// let v = Vec2::new(1, 2);
|
||||||
/// assert!(v.fits((1, 2)));
|
/// assert!(v.fits((1, 2)));
|
||||||
/// assert!(v.fits((0, 0)));
|
/// assert!(v.fits((0, 0)));
|
||||||
@ -203,7 +203,7 @@ impl<T: Ord> XY<T> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// assert_eq!(Vec2::max((1, 2), (3, 1)), Vec2::new(3, 2));
|
/// assert_eq!(Vec2::max((1, 2), (3, 1)), Vec2::new(3, 2));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn max<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self {
|
pub fn max<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self {
|
||||||
@ -217,7 +217,7 @@ impl<T: Ord> XY<T> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// assert_eq!(Vec2::min((1, 2), (3, 1)), Vec2::new(1, 1));
|
/// assert_eq!(Vec2::min((1, 2), (3, 1)), Vec2::new(1, 1));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn min<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self {
|
pub fn min<A: Into<XY<T>>, B: Into<XY<T>>>(a: A, b: B) -> Self {
|
||||||
@ -315,7 +315,7 @@ impl<T: Zero + Clone> XY<T> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// assert_eq!(Vec2::zero(), Vec2::new(0, 0));
|
/// assert_eq!(Vec2::zero(), Vec2::new(0, 0));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn zero() -> Self {
|
pub fn zero() -> Self {
|
||||||
@ -350,7 +350,7 @@ where
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::XY;
|
/// # use cursive::XY;
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let u = Vec2::new(1, 2);
|
/// let u = Vec2::new(1, 2);
|
||||||
/// let v: XY<isize> = XY::from(u);
|
/// let v: XY<isize> = XY::from(u);
|
||||||
/// assert_eq!(v, XY::new(1, 2));
|
/// assert_eq!(v, XY::new(1, 2));
|
||||||
@ -378,7 +378,7 @@ impl From<(u32, u32)> for XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let v = Vec2::from((1u32, 2u32));
|
/// let v = Vec2::from((1u32, 2u32));
|
||||||
/// assert_eq!(v, Vec2::new(1, 2));
|
/// assert_eq!(v, Vec2::new(1, 2));
|
||||||
/// ```
|
/// ```
|
||||||
@ -391,7 +391,7 @@ impl From<(u8, u8)> for XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let v = Vec2::from((1u8, 2u8));
|
/// let v = Vec2::from((1u8, 2u8));
|
||||||
/// assert_eq!(v, Vec2::new(1, 2));
|
/// assert_eq!(v, Vec2::new(1, 2));
|
||||||
/// ```
|
/// ```
|
||||||
@ -404,7 +404,7 @@ impl From<(u16, u16)> for XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let v = Vec2::from((1u16, 2u16));
|
/// let v = Vec2::from((1u16, 2u16));
|
||||||
/// assert_eq!(v, Vec2::new(1, 2));
|
/// assert_eq!(v, Vec2::new(1, 2));
|
||||||
/// ```
|
/// ```
|
||||||
@ -473,7 +473,7 @@ impl Mul<usize> for XY<usize> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use cursive::vec::Vec2;
|
/// # use cursive::Vec2;
|
||||||
/// let v = Vec2::new(1, 2);
|
/// let v = Vec2::new(1, 2);
|
||||||
/// assert_eq!(v * 2, Vec2::new(2, 4));
|
/// assert_eq!(v * 2, Vec2::new(2, 4));
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use std::ops::{Add, Div, Mul, Sub};
|
use std::ops::{Add, Div, Mul, Sub};
|
||||||
|
|
||||||
/// Four values representing each direction.
|
/// Four values representing each direction.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ impl Offset {
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use super::Position;
|
use super::Position;
|
||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_center() {
|
fn test_center() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{SizeConstraint, View};
|
use crate::view::{SizeConstraint, View};
|
||||||
use crate::views::ResizedView;
|
use crate::views::ResizedView;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
/// Makes a view wrappable in a [`ResizedView`].
|
/// Makes a view wrappable in a [`ResizedView`].
|
||||||
pub trait Resizable: View + Sized {
|
pub trait Resizable: View + Sized {
|
||||||
|
@ -5,9 +5,9 @@ use crate::event::{AnyCb, Event, EventResult, Key, MouseButton, MouseEvent};
|
|||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{ScrollStrategy, Selector, SizeCache};
|
use crate::view::{ScrollStrategy, Selector, SizeCache};
|
||||||
use crate::with::With;
|
use crate::with::With;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
|
|
||||||
/// Describes an item with a scroll core.
|
/// Describes an item with a scroll core.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::div::div_up;
|
use crate::div::div_up;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
/// Provide scrolling functionalities to a view.
|
/// Provide scrolling functionalities to a view.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::vec::Vec2;
|
use crate::Vec2;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
|
|
||||||
/// Cache around a one-dimensional layout result.
|
/// Cache around a one-dimensional layout result.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::event::{AnyCb, Event, EventResult};
|
use crate::event::{AnyCb, Event, EventResult};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{AnyView, Selector};
|
use crate::view::{AnyView, Selector};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
|
||||||
/// Main trait defining a view behaviour.
|
/// Main trait defining a view behaviour.
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::event::{AnyCb, Event, EventResult};
|
use crate::event::{AnyCb, Event, EventResult};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Selector, View};
|
use crate::view::{Selector, View};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
/// Generic wrapper around a view.
|
/// Generic wrapper around a view.
|
||||||
///
|
///
|
||||||
|
@ -3,8 +3,8 @@ use crate::direction::Direction;
|
|||||||
use crate::event::*;
|
use crate::event::*;
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::{Cursive, Printer, With};
|
use crate::{Cursive, Printer, With};
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::event::{AnyCb, Event, EventResult};
|
use crate::event::{AnyCb, Event, EventResult};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Selector, View};
|
use crate::view::{Selector, View};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
|
|
||||||
// Define this type separately to appease the Clippy god
|
// Define this type separately to appease the Clippy god
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent};
|
use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent};
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::logger;
|
use crate::logger;
|
||||||
use crate::theme;
|
use crate::theme;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ use crate::direction::{Absolute, Direction, Relative};
|
|||||||
use crate::event::{AnyCb, Event, EventResult, Key};
|
use crate::event::{AnyCb, Event, EventResult, Key};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Margins, Selector, View};
|
use crate::view::{Margins, Selector, View};
|
||||||
use crate::views::{BoxedView, Button, DummyView, LastSizeView, TextView};
|
use crate::views::{BoxedView, Button, DummyView, LastSizeView, TextView};
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
|
@ -3,8 +3,8 @@ use crate::event::{Callback, Event, EventResult, Key, MouseEvent};
|
|||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::{ColorStyle, Effect};
|
use crate::theme::{ColorStyle, Effect};
|
||||||
use crate::utils::lines::simple::{simple_prefix, simple_suffix};
|
use crate::utils::lines::simple::{simple_prefix, simple_suffix};
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::{Cursive, Printer, With};
|
use crate::{Cursive, Printer, With};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::event::AnyCb;
|
use crate::event::AnyCb;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Selector, View, ViewWrapper};
|
use crate::view::{Selector, View, ViewWrapper};
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
|
|
||||||
/// Wrapper around another view that can be hidden at will.
|
/// Wrapper around another view that can be hidden at will.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
use crate::view::ViewWrapper;
|
use crate::view::ViewWrapper;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
/// Wrapper around a view that remembers its size.
|
/// Wrapper around a view that remembers its size.
|
||||||
pub struct LastSizeView<T> {
|
pub struct LastSizeView<T> {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::direction;
|
use crate::direction;
|
||||||
use crate::event::{AnyCb, Event, EventResult, Key};
|
use crate::event::{AnyCb, Event, EventResult, Key};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{IntoBoxedView, Selector, SizeCache, View};
|
use crate::view::{IntoBoxedView, Selector, SizeCache, View};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use crate::direction;
|
use crate::direction;
|
||||||
use crate::event::{AnyCb, Callback, Event, EventResult, Key};
|
use crate::event::{AnyCb, Callback, Event, EventResult, Key};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{IntoBoxedView, Selector, View};
|
use crate::view::{IntoBoxedView, Selector, View};
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -4,12 +4,12 @@ use crate::event::{
|
|||||||
};
|
};
|
||||||
use crate::menu::{MenuItem, MenuTree};
|
use crate::menu::{MenuItem, MenuTree};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::scroll;
|
use crate::view::scroll;
|
||||||
use crate::view::{Position, View};
|
use crate::view::{Position, View};
|
||||||
use crate::views::OnEventView;
|
use crate::views::OnEventView;
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -3,11 +3,11 @@ use crate::event::*;
|
|||||||
use crate::menu::{MenuItem, MenuTree};
|
use crate::menu::{MenuItem, MenuTree};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Position, View};
|
use crate::view::{Position, View};
|
||||||
use crate::views::{MenuPopup, OnEventView};
|
use crate::views::{MenuPopup, OnEventView};
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::event::{Event, EventResult};
|
use crate::event::{Event, EventResult};
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Margins, View, ViewWrapper};
|
use crate::view::{Margins, View, ViewWrapper};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
/// Adds padding to another view.
|
/// Adds padding to another view.
|
||||||
///
|
///
|
||||||
|
@ -2,9 +2,9 @@ use crate::align::*;
|
|||||||
use crate::event::{Event, EventResult};
|
use crate::event::{Event, EventResult};
|
||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{View, ViewWrapper};
|
use crate::view::{View, ViewWrapper};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent};
|
use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent};
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::{Printer, With};
|
use crate::{Printer, With};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::printer::Printer;
|
use crate::printer::Printer;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{SizeConstraint, View, ViewWrapper};
|
use crate::view::{SizeConstraint, View, ViewWrapper};
|
||||||
|
use crate::Vec2;
|
||||||
use crate::XY;
|
use crate::XY;
|
||||||
|
|
||||||
/// Wrapper around another view, with a controlled size.
|
/// Wrapper around another view, with a controlled size.
|
||||||
@ -230,9 +230,9 @@ impl<T: View> ViewWrapper for ResizedView<T> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Boxable, View};
|
use crate::view::{Boxable, View};
|
||||||
use crate::views::DummyView;
|
use crate::views::DummyView;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
// No need to test `draw()` method as it's directly forwarded.
|
// No need to test `draw()` method as it's directly forwarded.
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ use crate::menu::MenuTree;
|
|||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::utils::markup::StyledString;
|
use crate::utils::markup::StyledString;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{Position, View};
|
use crate::view::{Position, View};
|
||||||
use crate::views::MenuPopup;
|
use crate::views::MenuPopup;
|
||||||
use crate::Cursive;
|
use crate::Cursive;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::event::{Event, EventResult};
|
use crate::event::{Event, EventResult};
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{View, ViewWrapper};
|
use crate::view::{View, ViewWrapper};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
|
|
||||||
/// Wrapper view that adds a shadow.
|
/// Wrapper view that adds a shadow.
|
||||||
///
|
///
|
||||||
|
@ -3,8 +3,8 @@ use crate::event::{
|
|||||||
Callback, Event, EventResult, Key, MouseButton, MouseEvent,
|
Callback, Event, EventResult, Key, MouseButton, MouseEvent,
|
||||||
};
|
};
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::View;
|
use crate::view::View;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use crate::{Cursive, Printer};
|
use crate::{Cursive, Printer};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use crate::direction::Direction;
|
use crate::direction::Direction;
|
||||||
use crate::event::{AnyCb, Event, EventResult};
|
use crate::event::{AnyCb, Event, EventResult};
|
||||||
use crate::theme::ColorStyle;
|
use crate::theme::ColorStyle;
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{
|
use crate::view::{
|
||||||
IntoBoxedView, Offset, Position, Selector, View, ViewWrapper,
|
IntoBoxedView, Offset, Position, Selector, View, ViewWrapper,
|
||||||
};
|
};
|
||||||
use crate::views::{BoxedView, CircularFocus, Layer, ShadowView};
|
use crate::views::{BoxedView, CircularFocus, Layer, ShadowView};
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use crate::With;
|
use crate::With;
|
||||||
use std::cell;
|
use std::cell;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
@ -3,8 +3,8 @@ use crate::event::{Event, EventResult, Key, MouseButton, MouseEvent};
|
|||||||
use crate::rect::Rect;
|
use crate::rect::Rect;
|
||||||
use crate::theme::{ColorStyle, Effect};
|
use crate::theme::{ColorStyle, Effect};
|
||||||
use crate::utils::lines::simple::{prefix, simple_prefix, LinesIterator, Row};
|
use crate::utils::lines::simple::{prefix, simple_prefix, LinesIterator, Row};
|
||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{ScrollBase, SizeCache, View};
|
use crate::view::{ScrollBase, SizeCache, View};
|
||||||
|
use crate::Vec2;
|
||||||
use crate::{Printer, With, XY};
|
use crate::{Printer, With, XY};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::vec::Vec2;
|
|
||||||
use crate::view::{View, ViewWrapper};
|
use crate::view::{View, ViewWrapper};
|
||||||
use crate::views::NamedView;
|
use crate::views::NamedView;
|
||||||
use crate::Printer;
|
use crate::Printer;
|
||||||
|
use crate::Vec2;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
/// Wrapper around a view that remembers its position.
|
/// Wrapper around a view that remembers its position.
|
||||||
|
Loading…
Reference in New Issue
Block a user