Merge pull request #153 from forkgull/more-debug

Add more Debug implementations
This commit is contained in:
Jeremy Soller 2023-07-24 09:45:58 -06:00 committed by GitHub
commit bd58940c42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 38 additions and 1 deletions

View file

@ -206,7 +206,7 @@ impl AttrsOwned {
/// List of text attributes to apply to a line
//TODO: have this clean up the spans when changes are made
#[derive(Eq, PartialEq)]
#[derive(Debug, Eq, PartialEq)]
pub struct AttrsList {
defaults: AttrsOwned,
spans: RangeMap<usize, AttrsOwned>,

View file

@ -4,6 +4,7 @@ use unicode_bidi::{bidi_class, BidiClass, BidiInfo, ParagraphInfo};
/// An iterator over the paragraphs in the input text.
/// It is equivalent to [`core::str::Lines`] but follows `unicode-bidi` behaviour.
#[derive(Debug)]
pub struct BidiParagraphs<'text> {
text: &'text str,
info: alloc::vec::IntoIter<ParagraphInfo>,

View file

@ -93,6 +93,7 @@ impl Default for Affinity {
}
/// The position of a cursor within a [`Buffer`].
#[derive(Debug)]
pub struct LayoutCursor {
pub line: usize,
pub layout: usize,
@ -110,6 +111,7 @@ impl LayoutCursor {
}
/// A line of visible text for rendering
#[derive(Debug)]
pub struct LayoutRun<'a> {
/// The index of the original text line
pub line_i: usize,
@ -184,6 +186,7 @@ impl<'a> LayoutRun<'a> {
}
/// An iterator of visible text lines, see [`LayoutRun`]
#[derive(Debug)]
pub struct LayoutRunIter<'b> {
buffer: &'b Buffer,
line_i: usize,
@ -316,6 +319,7 @@ impl fmt::Display for Metrics {
}
/// A buffer of text that is shaped and laid out
#[derive(Debug)]
pub struct Buffer {
/// [BufferLine]s (or paragraphs) of text in the buffer
pub lines: Vec<BufferLine>,

View file

@ -4,6 +4,7 @@ use alloc::{string::String, vec::Vec};
use crate::{Align, AttrsList, FontSystem, LayoutLine, ShapeLine, Shaping, Wrap};
/// A line (or paragraph) of text that is shaped and laid out
#[derive(Debug)]
pub struct BufferLine {
//TODO: make this not pub(crate)
text: String,

View file

@ -16,6 +16,7 @@ use crate::{
};
/// A wrapper of [`Buffer`] for easy editing
#[derive(Debug)]
pub struct Editor {
buffer: Buffer,
cursor: Cursor,

View file

@ -12,6 +12,7 @@ use crate::{
Shaping, Style, Weight, Wrap,
};
#[derive(Debug)]
pub struct SyntaxSystem {
pub syntax_set: SyntaxSet,
pub theme_set: ThemeSet,
@ -29,6 +30,7 @@ impl SyntaxSystem {
}
/// A wrapper of [`Editor`] with syntax highlighting provided by [`SyntaxSystem`]
#[derive(Debug)]
pub struct SyntaxEditor<'a> {
editor: Editor,
syntax_system: &'a SyntaxSystem,

View file

@ -16,6 +16,7 @@ enum Mode {
SearchBackwards,
}
#[derive(Debug)]
pub struct ViEditor<'a> {
editor: SyntaxEditor<'a>,
mode: Mode,

View file

@ -14,6 +14,7 @@ pub use font_inner::Font;
mod font_inner {
use super::*;
use aliasable::boxed::AliasableBox;
use core::fmt;
/// A font
//
@ -31,6 +32,14 @@ mod font_inner {
id: fontdb::ID,
}
impl fmt::Debug for Font {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Font")
.field("id", &self.id)
.finish_non_exhaustive()
}
}
pub(super) struct FontTryBuilder<
RustybuzzBuilder: for<'this> FnOnce(
&'this Arc<dyn AsRef<[u8]> + Send + Sync>,

View file

@ -15,6 +15,7 @@ pub use fontdb;
pub use rustybuzz;
/// A value borrowed together with an [`FontSystem`]
#[derive(Debug)]
pub struct BorrowedWithFontSystem<'a, T> {
pub(crate) inner: &'a mut T,
pub(crate) font_system: &'a mut FontSystem,

View file

@ -9,6 +9,7 @@ use alloc::{
use crate::{Attrs, Font};
/// Access system fonts
#[derive(Debug)]
pub struct FontSystem {
locale: String,
db: fontdb::Database,

View file

@ -5,6 +5,7 @@ use std::{collections::HashMap, sync::Arc};
use crate::{Attrs, AttrsOwned, Font};
/// Access system fonts
#[derive(Debug)]
pub struct FontSystem {
locale: String,
db: fontdb::Database,

View file

@ -52,6 +52,7 @@ pub struct LayoutGlyph {
pub metadata: usize,
}
#[derive(Debug)]
pub struct PhysicalGlyph {
/// Cache key, see [CacheKey]
pub cache_key: CacheKey,
@ -81,6 +82,7 @@ impl LayoutGlyph {
}
/// A line of laid out glyphs
#[derive(Debug)]
pub struct LayoutLine {
/// Width of the line
pub w: f32,

View file

@ -71,6 +71,8 @@
#![deny(clippy::cast_ptr_alignment)]
// Avoid panicking in without information about the panic. Use expect
#![deny(clippy::unwrap_used)]
// Ensure all types have a debug impl
#![deny(missing_debug_implementations)]
// This is usually a serious issue - a missing import of a define where it is interpreted
// as a catch-all variable in a match, for example
#![deny(unreachable_patterns)]

View file

@ -308,6 +308,7 @@ fn shape_skip(
}
/// A shaped glyph
#[derive(Debug)]
pub struct ShapeGlyph {
pub start: usize,
pub end: usize,
@ -351,6 +352,7 @@ impl ShapeGlyph {
}
/// A shaped word (for word wrapping)
#[derive(Debug)]
pub struct ShapeWord {
pub blank: bool,
pub glyphs: Vec<ShapeGlyph>,
@ -428,6 +430,7 @@ impl ShapeWord {
}
/// A shaped span (for bidirectional processing)
#[derive(Debug)]
pub struct ShapeSpan {
pub level: unicode_bidi::Level,
pub words: Vec<ShapeWord>,
@ -510,6 +513,7 @@ impl ShapeSpan {
}
/// A shaped line (or paragraph)
#[derive(Debug)]
pub struct ShapeLine {
pub rtl: bool,
pub spans: Vec<ShapeSpan>,

View file

@ -4,6 +4,7 @@
use alloc::collections::BTreeMap as Map;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use core::fmt;
#[cfg(feature = "std")]
use std::collections::HashMap as Map;
use swash::scale::{image::Content, ScaleContext};
@ -96,6 +97,12 @@ pub struct SwashCache {
pub outline_command_cache: Map<CacheKey, Option<Vec<swash::zeno::Command>>>,
}
impl fmt::Debug for SwashCache {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.pad("SwashCache { .. }")
}
}
impl SwashCache {
/// Create a new swash cache
pub fn new() -> Self {