mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Don't expose single-item modules
Instead, pub-use it from the root.
This commit is contained in:
parent
d9e4512752
commit
7f17a4ff74
19
src/lib.rs
19
src/lib.rs
@ -1,8 +1,18 @@
|
||||
//! # Cursive
|
||||
//!
|
||||
//! Cursive is a TUI library built on top of ncurses-rs.
|
||||
//! [Cursive](https://github.com/gyscos/Cursive) is a TUI library built on top
|
||||
//! of ncurses-rs.
|
||||
//! It allows to easily build layouts for text-based applications.
|
||||
//!
|
||||
//! ## Getting started
|
||||
//!
|
||||
//! * Every application should start with a [`Cursive`](struct.Cursive.html)
|
||||
//! object. It is the main entry-point to the library.
|
||||
//! * A declarative phase then describes the structure of the UI by adding
|
||||
//! views and configuring their behaviours.
|
||||
//! * Finally, the event loop is started by calling
|
||||
//! [`Cursive::run(&mut self)`](struct.Cursive.html#method.run).
|
||||
//!
|
||||
//! ## Example
|
||||
//! ```no_run
|
||||
//! extern crate cursive;
|
||||
@ -38,16 +48,16 @@ macro_rules! println_stderr(
|
||||
|
||||
pub mod event;
|
||||
pub mod view;
|
||||
pub mod printer;
|
||||
pub mod vec;
|
||||
pub mod theme;
|
||||
pub mod align;
|
||||
pub mod orientation;
|
||||
pub mod menu;
|
||||
|
||||
// This probably doesn't need to be public?
|
||||
mod printer;
|
||||
mod menubar;
|
||||
mod xy;
|
||||
mod orientation;
|
||||
|
||||
mod div;
|
||||
mod utf8;
|
||||
@ -55,6 +65,8 @@ mod utf8;
|
||||
mod backend;
|
||||
|
||||
pub use xy::XY;
|
||||
pub use orientation::Orientation;
|
||||
pub use printer::Printer;
|
||||
|
||||
use backend::{Backend, NcursesBackend};
|
||||
|
||||
@ -64,7 +76,6 @@ use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
use vec::Vec2;
|
||||
use printer::Printer;
|
||||
use view::View;
|
||||
use view::{Selector, StackView};
|
||||
|
||||
|
24
src/vec.rs
24
src/vec.rs
@ -5,10 +5,16 @@ use orientation::Orientation;
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
use std::cmp::{Ordering, max, min};
|
||||
|
||||
/// Simple 2D size, in characters.
|
||||
/// Simple 2D size, in cells.
|
||||
///
|
||||
/// Note: due to a bug in rustdoc ([#32077]), the documentation for `Vec2` is
|
||||
/// currently shown on the [`XY`] page.
|
||||
///
|
||||
/// [#32077]: https://github.com/rust-lang/rust/issues/32077
|
||||
/// [`XY`]: ../struct.XY.html
|
||||
pub type Vec2 = XY<usize>;
|
||||
|
||||
impl PartialOrd for Vec2 {
|
||||
impl PartialOrd for XY<usize> {
|
||||
/// `a < b` <=> `a.x < b.x && a.y < b.y`
|
||||
fn partial_cmp(&self, other: &Vec2) -> Option<Ordering> {
|
||||
if self == other {
|
||||
@ -23,7 +29,7 @@ impl PartialOrd for Vec2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Vec2 {
|
||||
impl XY<usize> {
|
||||
/// Returns a new Vec2 that is a maximum per coordinate.
|
||||
pub fn max<A: Into<Vec2>, B: Into<Vec2>>(a: A, b: B) -> Self {
|
||||
let a = a.into();
|
||||
@ -89,20 +95,20 @@ impl Vec2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(i32, i32)> for Vec2 {
|
||||
impl From<(i32, i32)> for XY<usize> {
|
||||
fn from((x, y): (i32, i32)) -> Self {
|
||||
(x as usize, y as usize).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(u32, u32)> for Vec2 {
|
||||
impl From<(u32, u32)> for XY<usize> {
|
||||
fn from((x, y): (u32, u32)) -> Self {
|
||||
(x as usize, y as usize).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<T: Into<Vec2>> Add<T> for Vec2 {
|
||||
impl<T: Into<Vec2>> Add<T> for XY<usize> {
|
||||
type Output = Vec2;
|
||||
|
||||
fn add(self, other: T) -> Vec2 {
|
||||
@ -110,7 +116,7 @@ impl<T: Into<Vec2>> Add<T> for Vec2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Into<Vec2>> Sub<T> for Vec2 {
|
||||
impl<T: Into<Vec2>> Sub<T> for XY<usize> {
|
||||
type Output = Vec2;
|
||||
|
||||
fn sub(self, other: T) -> Vec2 {
|
||||
@ -118,7 +124,7 @@ impl<T: Into<Vec2>> Sub<T> for Vec2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Div<usize> for Vec2 {
|
||||
impl Div<usize> for XY<usize> {
|
||||
type Output = Vec2;
|
||||
|
||||
fn div(self, other: usize) -> Vec2 {
|
||||
@ -126,7 +132,7 @@ impl Div<usize> for Vec2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl Mul<usize> for Vec2 {
|
||||
impl Mul<usize> for XY<usize> {
|
||||
type Output = Vec2;
|
||||
|
||||
fn mul(self, other: usize) -> Vec2 {
|
||||
|
Loading…
Reference in New Issue
Block a user