summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Oram <dev@mitmaro.ca>2024-02-09 13:53:36 -0330
committerTim Oram <dev@mitmaro.ca>2024-02-15 20:27:06 -0330
commitcaf3d1169f70c2fff557b740f3ca577c0ec23fff (patch)
treed4af0add03383a0f020e6430ba4994ce12e6a407
parentbae935621588026c521849e986dd0f9a4feb37e6 (diff)
Move display crate into core
-rw-r--r--Cargo.lock15
-rw-r--r--Cargo.toml1
-rw-r--r--src/core/Cargo.toml5
-rw-r--r--src/core/src/application.rs6
-rw-r--r--src/core/src/components/choice.rs2
-rw-r--r--src/core/src/components/edit.rs2
-rw-r--r--src/core/src/components/help.rs2
-rw-r--r--src/core/src/components/shared/editable_line.rs3
-rw-r--r--src/core/src/display.rs (renamed from src/display/src/lib.rs)172
-rw-r--r--src/core/src/display/color_mode.rs (renamed from src/display/src/color_mode.rs)6
-rw-r--r--src/core/src/display/crossterm.rs (renamed from src/display/src/crossterm.rs)6
-rw-r--r--src/core/src/display/display_color.rs (renamed from src/display/src/display_color.rs)2
-rw-r--r--src/core/src/display/error.rs (renamed from src/display/src/error.rs)2
-rw-r--r--src/core/src/display/size.rs (renamed from src/display/src/size.rs)8
-rw-r--r--src/core/src/display/testutil.rs (renamed from src/display/src/testutil.rs)6
-rw-r--r--src/core/src/display/testutil/mockable_tui.rs (renamed from src/display/src/testutil/mockable_tui.rs)6
-rw-r--r--src/core/src/display/testutil/mockcrossterm.rs (renamed from src/display/src/testutil/mockcrossterm.rs)26
-rw-r--r--src/core/src/display/testutil/state.rs (renamed from src/display/src/testutil/state.rs)2
-rw-r--r--src/core/src/display/tui.rs (renamed from src/display/src/tui.rs)4
-rw-r--r--src/core/src/display/utils.rs (renamed from src/display/src/utils.rs)2
-rw-r--r--src/core/src/editor.rs8
-rw-r--r--src/core/src/lib.rs1
-rw-r--r--src/core/src/modules/error.rs2
-rw-r--r--src/core/src/modules/insert.rs2
-rw-r--r--src/core/src/modules/list.rs2
-rw-r--r--src/core/src/modules/list/utils.rs3
-rw-r--r--src/core/src/modules/show_commit/util.rs6
-rw-r--r--src/core/src/modules/show_commit/view_builder.rs2
-rw-r--r--src/core/src/process.rs2
-rw-r--r--src/core/src/testutil/process_test.rs2
-rw-r--r--src/core/src/view.rs2
-rw-r--r--src/core/src/view/line_segment.rs3
-rw-r--r--src/core/src/view/render_slice/tests.rs17
-rw-r--r--src/core/src/view/tests.rs6
-rw-r--r--src/core/src/view/testutil/render_view_line.rs6
-rw-r--r--src/core/src/view/thread.rs16
-rw-r--r--src/core/src/view/view_line.rs4
-rw-r--r--src/display/Cargo.toml27
-rw-r--r--src/display/Makefile.toml2
-rw-r--r--src/display/README.md3
-rw-r--r--src/display/build.rs11
-rw-r--r--src/main.rs2
42 files changed, 109 insertions, 298 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5c154f9..e2f2141 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -346,8 +346,8 @@ dependencies = [
"chrono",
"claims",
"crossbeam-channel",
+ "crossterm",
"girt-config",
- "girt-display",
"girt-git",
"girt-input",
"girt-runtime",
@@ -363,6 +363,7 @@ dependencies = [
"rstest",
"rustc_version",
"serial_test",
+ "thiserror",
"unicode-segmentation",
"unicode-width",
"uuid",
@@ -370,18 +371,6 @@ dependencies = [
]
[[package]]
-name = "girt-display"
-version = "2.3.0"
-dependencies = [
- "crossterm",
- "girt-config",
- "rstest",
- "rustc_version",
- "serial_test",
- "thiserror",
-]
-
-[[package]]
name = "girt-git"
version = "2.3.0"
dependencies = [
diff --git a/Cargo.toml b/Cargo.toml
index 9f22fa8..51ae1aa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,7 +27,6 @@ path = "src/main.rs"
members = [
"src/config",
"src/core",
- "src/display",
"src/git",
"src/input",
"src/runtime",
diff --git a/src/core/Cargo.toml b/src/core/Cargo.toml
index f21e4f8..f0617c9 100644
--- a/src/core/Cargo.toml
+++ b/src/core/Cargo.toml
@@ -12,15 +12,17 @@ categories = ["command-line-interface", "command-line-utilities", "text-editors"
readme = "README.md"
[lib]
-name = "core"
+name = "gcore"
[dependencies]
anyhow = "1.0.72"
bitflags = "2.4.2"
captur = "0.1.0"
+crossterm = "0.26.1"
crossbeam-channel = "0.5.8"
if_chain = "1.0.2"
lazy_static = "1.4.0"
+thiserror = "1.0.56"
num-format = "0.4.4"
parking_lot = "0.12.1"
pico-args = "0.5.0"
@@ -29,7 +31,6 @@ unicode-width = "0.1.10"
uuid = { version = "1.4.1", features = ["v4", "fast-rng"] }
xi-unicode = "0.3.0"
girt-config = {version = "2.3.0", path = "../../src/config"}
-girt-display = {version = "2.3.0", path = "../../src/display"}
girt-git = {version = "2.3.0", path = "../../src/git"}
girt-input = {version = "2.3.0", path = "../../src/input"}
girt-runtime = {version = "2.3.0", path = "../runtime"}
diff --git a/src/core/src/application.rs b/src/core/src/application.rs
index 8fc7b1c..f8f4a7e 100644
--- a/src/core/src/application.rs
+++ b/src/core/src/application.rs
@@ -2,7 +2,6 @@ use std::sync::Arc;
use anyhow::Result;
use config::Config;
-use display::Display;
use git::Repository;
use input::{Event, EventHandler, EventReaderFn};
use parking_lot::Mutex;
@@ -10,6 +9,7 @@ use runtime::{Runtime, ThreadStatuses, Threadable};
use todo_file::{TodoFile, TodoFileOptions};
use crate::{
+ display::Display,
events,
events::{KeyBindings, MetaEvent},
help::build_help,
@@ -38,7 +38,7 @@ where ModuleProvider: module::ModuleProvider + Send + 'static
pub(crate) fn new<EventProvider, Tui>(args: &Args, event_provider: EventProvider, tui: Tui) -> Result<Self, Exit>
where
EventProvider: EventReaderFn,
- Tui: display::Tui + Send + 'static,
+ Tui: crate::display::Tui + Send + 'static,
{
let filepath = Self::filepath_from_args(args)?;
let repository = Self::open_repository()?;
@@ -193,12 +193,12 @@ mod tests {
use std::ffi::OsString;
use claims::{assert_none, assert_ok};
- use display::{testutil::CrossTerm, Size};
use input::{KeyCode, KeyEvent, KeyModifiers};
use runtime::{Installer, RuntimeError};
use super::*;
use crate::{
+ display::{testutil::CrossTerm, Size},
events::Event,
module::Modules,
testutil::{create_event_reader, set_git_directory, DefaultTestModule, TestModuleProvider},
diff --git a/src/core/src/components/choice.rs b/src/core/src/components/choice.rs
index 880b9fc..8c119d4 100644
--- a/src/core/src/components/choice.rs
+++ b/src/core/src/components/choice.rs
@@ -3,11 +3,11 @@ mod tests;
use std::collections::HashMap;
-use display::DisplayColor;
use input::{InputOptions, KeyCode};
use lazy_static::lazy_static;
use crate::{
+ display::DisplayColor,
events::Event,
util::handle_view_data_scroll,
view::{LineSegment, ViewData, ViewLine},
diff --git a/src/core/src/components/edit.rs b/src/core/src/components/edit.rs
index 2f7241c..ae89c49 100644
--- a/src/core/src/components/edit.rs
+++ b/src/core/src/components/edit.rs
@@ -1,12 +1,12 @@
#[cfg(test)]
mod tests;
-use display::DisplayColor;
use input::{InputOptions, KeyCode, KeyEvent, KeyModifiers};
use lazy_static::lazy_static;
use crate::{
components::shared::EditableLine,
+ display::DisplayColor,
events::Event,
view::{LineSegment, ViewData, ViewDataUpdater, ViewLine},
};
diff --git a/src/core/src/components/help.rs b/src/core/src/components/help.rs
index d884394..e6c05be 100644
--- a/src/core/src/components/help.rs
+++ b/src/core/src/components/help.rs
@@ -1,11 +1,11 @@
#[cfg(test)]
mod tests;
-use display::DisplayColor;
use input::{InputOptions, StandardEvent};
use unicode_segmentation::UnicodeSegmentation;
use crate::{
+ display::DisplayColor,
events::Event,
first,
util::handle_view_data_scroll,
diff --git a/src/core/src/components/shared/editable_line.rs b/src/core/src/components/shared/editable_line.rs
index 4293a5f..68074b6 100644
--- a/src/core/src/components/shared/editable_line.rs
+++ b/src/core/src/components/shared/editable_line.rs
@@ -1,8 +1,7 @@
-use display::DisplayColor;
use input::{KeyCode, KeyEvent, KeyModifiers};
use unicode_segmentation::UnicodeSegmentation;
-use crate::{events::Event, view::LineSegment};
+use crate::{display::DisplayColor, events::Event, view::LineSegment};
#[derive(Debug, PartialEq, Eq)]
pub(crate) enum EditAction {
diff --git a/src/display/src/lib.rs b/src/core/src/display.rs
index a74de2e..b82afb6 100644
--- a/src/display/src/lib.rs
+++ b/src/core/src/display.rs
@@ -1,148 +1,8 @@
-// LINT-REPLACE-START
-// This section is autogenerated, do not modify directly
-// nightly sometimes removes/renames lints
-#![cfg_attr(allow_unknown_lints, allow(unknown_lints))]
-#![cfg_attr(allow_unknown_lints, allow(renamed_and_removed_lints))]
-// enable all rustc's built-in lints
-#![deny(
- future_incompatible,
- nonstandard_style,
- rust_2018_compatibility,
- rust_2018_idioms,
- rust_2021_compatibility,
- unused,
- warnings
-)]
-// rustc's additional allowed by default lints
-#![deny(
- absolute_paths_not_starting_with_crate,
- deprecated_in_future,
- elided_lifetimes_in_paths,
- explicit_outlives_requirements,
- ffi_unwind_calls,
- keyword_idents,
- let_underscore_drop,
- macro_use_extern_crate,
- meta_variable_misuse,
- missing_abi,
- missing_copy_implementations,
- missing_debug_implementations,
- missing_docs,
- non_ascii_idents,
- noop_method_call,
- pointer_structural_match,
- rust_2021_incompatible_closure_captures,
- rust_2021_incompatible_or_patterns,
- rust_2021_prefixes_incompatible_syntax,
- rust_2021_prelude_collisions,
- single_use_lifetimes,
- trivial_casts,
- trivial_numeric_casts,
- unreachable_pub,
- unsafe_code,
- unsafe_op_in_unsafe_fn,
- unused_crate_dependencies,
- unused_extern_crates,
- unused_import_braces,
- unused_lifetimes,
- unused_macro_rules,
- unused_qualifications,
- unused_results,
- unused_tuple_struct_fields,
- variant_size_differences
-)]
-// enable all of Clippy's lints
-#![deny(clippy::all, clippy::cargo, clippy::pedantic, clippy::restriction)]
-#![allow(
- clippy::absolute_paths,
- clippy::arithmetic_side_effects,
- clippy::arithmetic_side_effects,
- clippy::blanket_clippy_restriction_lints,
- clippy::bool_to_int_with_if,
- clippy::default_numeric_fallback,
- clippy::else_if_without_else,
- clippy::expect_used,
- clippy::float_arithmetic,
- clippy::implicit_return,
- clippy::indexing_slicing,
- clippy::map_err_ignore,
- clippy::min_ident_chars,
- clippy::missing_docs_in_private_items,
- clippy::missing_trait_methods,
- clippy::module_name_repetitions,
- clippy::needless_raw_string_hashes,
- clippy::needless_raw_strings,
- clippy::new_without_default,
- clippy::non_ascii_literal,
- clippy::option_if_let_else,
- clippy::pattern_type_mismatch,
- clippy::pub_use,
- clippy::pub_with_shorthand,
- clippy::question_mark_used,
- clippy::redundant_closure_call,
- clippy::redundant_pub_crate,
- clippy::ref_patterns,
- clippy::self_named_module_files,
- clippy::single_call_fn,
- clippy::std_instead_of_alloc,
- clippy::std_instead_of_core,
- clippy::tabs_in_doc_comments,
- clippy::tests_outside_test_module,
- clippy::too_many_lines,
- clippy::unwrap_used
-)]
-#![deny(
- rustdoc::bare_urls,
- rustdoc::broken_intra_doc_links,
- rustdoc::invalid_codeblock_attributes,
- rustdoc::invalid_html_tags,
- rustdoc::missing_crate_level_docs,
- rustdoc::private_doc_tests,
- rustdoc::private_intra_doc_links
-)]
-// allow some things in tests
-#![cfg_attr(
- test,
- allow(
- let_underscore_drop,
- clippy::cognitive_complexity,
- clippy::let_underscore_must_use,
- clippy::let_underscore_untyped,
- clippy::needless_pass_by_value,
- clippy::panic,
- clippy::shadow_reuse,
- clippy::shadow_unrelated,
- clippy::undocumented_unsafe_blocks,
- clippy::unimplemented,
- clippy::unreachable
- )
-)]
-// allowable upcoming nightly lints
-#![cfg_attr(include_nightly_lints, allow(clippy::absolute_paths, clippy::arc_with_non_send_sync))]
-// LINT-REPLACE-END
-
//! Git Interactive Rebase Tool - Display Module
//!
//! # Description
//! This module is used to handle working with the terminal display.
//!
-//! ```
-//! use config::Theme;
-//! use display::{CrossTerm, Display, DisplayColor};
-//! let theme = Theme::new();
-//! let tui = CrossTerm::new();
-//! let mut display = Display::new(tui, &theme);
-//!
-//! display.start();
-//! display.clear();
-//! display.draw_str("Hello world!");
-//! display.color(DisplayColor::IndicatorColor, false);
-//! display.set_style(false, true, false);
-//! display.draw_str("Hello colorful, underlined world!");
-//! display.refresh();
-//! display.end();
-//! ```
-//!
//! ## Test Utilities
//! To facilitate testing the usages of this crate, a set of testing utilities are provided. Since
//! these utilities are not tested, and often are optimized for developer experience than
@@ -155,7 +15,7 @@ mod display_color;
mod error;
mod size;
#[cfg(not(tarpaulin_include))]
-pub mod testutil;
+pub(crate) mod testutil;
mod tui;
mod utils;
@@ -163,7 +23,7 @@ use ::crossterm::style::{Color, Colors};
use config::Theme;
use self::utils::register_selectable_color_pairs;
-pub use self::{
+pub(crate) use self::{
color_mode::ColorMode,
crossterm::CrossTerm,
display_color::DisplayColor,
@@ -174,7 +34,7 @@ pub use self::{
/// A high level interface to the terminal display.
#[derive(Debug)]
-pub struct Display<T: Tui> {
+pub(crate) struct Display<T: Tui> {
action_break: (Colors, Colors),
action_drop: (Colors, Colors),
action_edit: (Colors, Colors),
@@ -200,7 +60,7 @@ pub struct Display<T: Tui> {
impl<T: Tui> Display<T> {
/// Create a new display instance.
#[inline]
- pub fn new(tui: T, theme: &Theme) -> Self {
+ pub(crate) fn new(tui: T, theme: &Theme) -> Self {
let color_mode = tui.get_color_mode();
let normal = register_selectable_color_pairs(
color_mode,
@@ -346,7 +206,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn draw_str(&mut self, s: &str) -> Result<(), DisplayError> {
+ pub(crate) fn draw_str(&mut self, s: &str) -> Result<(), DisplayError> {
self.tui.print(s)
}
@@ -355,7 +215,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn clear(&mut self) -> Result<(), DisplayError> {
+ pub(crate) fn clear(&mut self) -> Result<(), DisplayError> {
self.color(DisplayColor::Normal, false)?;
self.set_style(false, false, false)?;
self.tui.reset()
@@ -368,7 +228,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn refresh(&mut self) -> Result<(), DisplayError> {
+ pub(crate) fn refresh(&mut self) -> Result<(), DisplayError> {
self.tui.flush()
}
@@ -378,7 +238,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn color(&mut self, color: DisplayColor, selected: bool) -> Result<(), DisplayError> {
+ pub(crate) fn color(&mut self, color: DisplayColor, selected: bool) -> Result<(), DisplayError> {
self.tui.set_color(
if selected {
match color {
@@ -435,7 +295,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn set_style(&mut self, dim: bool, underline: bool, reverse: bool) -> Result<(), DisplayError> {
+ pub(crate) fn set_style(&mut self, dim: bool, underline: bool, reverse: bool) -> Result<(), DisplayError> {
self.set_dim(dim)?;
self.set_underline(underline)?;
self.set_reverse(reverse)
@@ -447,7 +307,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn get_window_size(&self) -> Size {
+ pub(crate) fn get_window_size(&self) -> Size {
self.tui.get_size()
}
@@ -456,7 +316,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn ensure_at_line_start(&mut self) -> Result<(), DisplayError> {
+ pub(crate) fn ensure_at_line_start(&mut self) -> Result<(), DisplayError> {
self.tui.move_to_column(0)
}
@@ -465,7 +325,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn move_from_end_of_line(&mut self, right: u16) -> Result<(), DisplayError> {
+ pub(crate) fn move_from_end_of_line(&mut self, right: u16) -> Result<(), DisplayError> {
let width = self.get_window_size().width().try_into().unwrap_or(u16::MAX);
self.tui.move_to_column(width - right)
}
@@ -475,7 +335,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn next_line(&mut self) -> Result<(), DisplayError> {
+ pub(crate) fn next_line(&mut self) -> Result<(), DisplayError> {
self.tui.move_next_line()
}
@@ -485,7 +345,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn start(&mut self) -> Result<(), DisplayError> {
+ pub(crate) fn start(&mut self) -> Result<(), DisplayError> {
self.tui.start()?;
self.tui.flush()
}
@@ -497,7 +357,7 @@ impl<T: Tui> Display<T> {
/// # Errors
/// Will error if the underlying terminal interface is in an error state.
#[inline]
- pub fn end(&mut self) -> Result<(), DisplayError> {
+ pub(crate) fn end(&mut self) -> Result<(), DisplayError> {
self.tui.end()?;
self.tui.flush()
}
@@ -521,7 +381,7 @@ mod tests {
use rstest::rstest;
use super::*;
- use crate::testutil::{CrossTerm, State};
+ use crate::display::testutil::{CrossTerm, State};
#[test]
fn draw_str() {
diff --git a/src/display/src/color_mode.rs b/src/core/src/display/color_mode.rs
index 1476521..5ac4596 100644
--- a/src/display/src/color_mode.rs
+++ b/src/core/src/display/color_mode.rs
@@ -1,7 +1,7 @@
/// Represents the color mode of a terminal interface.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[allow(clippy::exhaustive_enums)]
-pub enum ColorMode {
+pub(crate) enum ColorMode {
/// Supports 2 colors.
TwoTone,
/// Supports 8 colors.
@@ -18,14 +18,14 @@ impl ColorMode {
/// Supports 4 bit or more of color.
#[inline]
#[must_use]
- pub fn has_minimum_four_bit_color(self) -> bool {
+ pub(crate) fn has_minimum_four_bit_color(self) -> bool {
self == Self::FourBit || self == Self::EightBit || self == Self::TrueColor
}
/// Has true color support.
#[inline]
#[must_use]
- pub fn has_true_color(self) -> bool {
+ pub(crate) fn has_true_color(self) -> bool {
self == Self::TrueColor
}
}
diff --git a/src/display/src/crossterm.rs b/src/core/src/display/crossterm.rs
index e96a4e3..0a699ee 100644
--- a/src/display/src/crossterm.rs
+++ b/src/core/src/display/crossterm.rs
@@ -25,11 +25,11 @@ use crossterm::{
QueueableCommand,
};
-use crate::{color_mode::ColorMode, error::DisplayError, size::Size, tui::Tui, utils::detect_color_mode};
+use crate::display::{color_mode::ColorMode, error::DisplayError, size::Size, tui::Tui, utils::detect_color_mode};
/// A thin wrapper over the [Crossterm library](https://github.com/crossterm-rs/crossterm).
#[derive(Debug)]
-pub struct CrossTerm {
+pub(crate) struct CrossTerm {
color_mode: ColorMode,
window: BufWriter<Stdout>,
}
@@ -151,7 +151,7 @@ impl CrossTerm {
/// Create a new instance.
#[inline]
#[must_use]
- pub fn new() -> Self {
+ pub(crate) fn new() -> Self {
Self {
window: BufWriter::new(stdout()),
color_mode: detect_color_mode(available_color_count()),
diff --git a/src/display/src/display_color.rs b/src/core/src/display/display_color.rs
index 1207f6b..ae1fd46 100644
--- a/src/display/src/display_color.rs
+++ b/src/core/src/display/display_color.rs
@@ -1,7 +1,7 @@
/// An abstraction of colors to display.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[allow(clippy::exhaustive_enums)]
-pub enum DisplayColor {
+pub(crate) enum DisplayColor {
/// The color for the break action.
ActionBreak,
/// The color for the drop action.
diff --git a/src/display/src/error.rs b/src/core/src/display/error.rs
index 7f8e952..83605cc 100644
--- a/src/display/src/error.rs
+++ b/src/core/src/display/error.rs
@@ -5,7 +5,7 @@ use thiserror::Error;
/// A display error.
#[derive(Error, Debug)]
#[non_exhaustive]
-pub enum DisplayError {
+pub(crate) enum DisplayError {
/// An unexpected error occurred.
#[error("Unexpected error")]
Unexpected(io::Error),
diff --git a/src/display/src/size.rs b/src/core/src/display/size.rs
index ec67766..085c9f4 100644
--- a/src/display/src/size.rs
+++ b/src/core/src/display/size.rs
@@ -1,6 +1,6 @@
/// Represents a terminal window size.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
-pub struct Size {
+pub(crate) struct Size {
width: usize,
height: usize,
}
@@ -9,21 +9,21 @@ impl Size {
/// Create a new instance with a width and height.
#[inline]
#[must_use]
- pub const fn new(width: usize, height: usize) -> Self {
+ pub(crate) const fn new(width: usize, height: usize) -> Self {
Self { width, height }
}
/// Get the width.
#[inline]
#[must_use]
- pub const fn width(&self) -> usize {
+ pub(crate) const fn width(&self) -> usize {
self.width
}
/// Get the height.
#[inline]
#[must_use]
- pub const fn height(&self) -> usize {
+ pub(crate) const fn height(&self) -> usize {
self.height
}
}
diff --git a/src/display/src/testutil.rs b/src/core/src/display/testutil.rs
index a34dde4..aca2edf 100644
--- a/src/display/src/testutil.rs
+++ b/src/core/src/display/testutil.rs
@@ -3,12 +3,12 @@ mod mockable_tui;
mod mockcrossterm;
mod state;
-pub use self::{
+pub(crate) use self::{
mockable_tui::{create_unexpected_error, MockableTui},
mockcrossterm::CrossTerm,
state::State,
};
-use crate::Display;
+use crate::display::Display;
/// Assert the the content of the Display is an expected value.
///
@@ -17,6 +17,6 @@ use crate::Display;
/// Will panic is the expected output does not match the rendered output.
#[inline]
#[allow(clippy::missing_assert_message)] // not sure why this is triggering
-pub fn assert_output(display: &Display<CrossTerm>, expected: &[&str]) {
+pub(crate) fn assert_output(display: &Display<CrossTerm>, expected: &[&str]) {
assert_eq!(display.tui.get_output().join(""), format!("{}\n", expected.join("\n")));
}
diff --git a/src/display/src/testutil/mockable_tui.rs b/src/core/src/display/testutil/mockable_tui.rs
index 33a7485..57496f1 100644
--- a/src/display/src/testutil/mockable_tui.rs
+++ b/src/core/src/display/testutil/mockable_tui.rs
@@ -2,12 +2,12 @@ use std::io;
use crossterm::style::Colors;
-use crate::{ColorMode, DisplayError, Size, Tui};
+use crate::display::{ColorMode, DisplayError, Size, Tui};
/// Create an instance of a `DisplayError::Unexpected` error with an other IO error.
#[must_use]
#[inline]
-pub fn create_unexpected_error() -> DisplayError {
+pub(crate) fn create_unexpected_error() -> DisplayError {
DisplayError::Unexpected(io::Error::from(io::ErrorKind::Other))
}
@@ -15,7 +15,7 @@ pub fn create_unexpected_error() -> DisplayError {
/// mocked versions of the `TUI` interface, without needing to define all methods provided by the
/// interface.
#[allow(missing_docs, clippy::missing_errors_doc)]
-pub trait MockableTui: Tui {
+pub(crate) trait MockableTui: Tui {
#[inline]
fn get_color_mode(&self) -> ColorMode {
ColorMode::TwoTone
diff --git a/src/display/src/testutil/mockcrossterm.rs b/src/core/src/display/testutil/mockcrossterm.rs
index 9af0010..84bdfe8 100644
--- a/src/display/src/testutil/mockcrossterm.rs
+++ b/src/core/src/display/testutil/mockcrossterm.rs
@@ -1,6 +1,6 @@
-use crossterm::style::{Attribute, Attributes, Color, Colors};
+use ::crossterm::style::{Attribute, Attributes, Color, Colors};
-use crate::{
+use crate::display::{
testutil::{MockableTui, State},
ColorMode,
DisplayError,
@@ -9,7 +9,7 @@ use crate::{
/// A mocked version of `CrossTerm`, useful for testing.
#[derive(Debug)]
-pub struct CrossTerm {
+pub(crate) struct CrossTerm {
attributes: Attributes,
color_mode: ColorMode,
colors: Colors,