Rename WidthDB to WidthDb

This commit is contained in:
Joscha 2022-09-26 17:01:49 +02:00
parent f258c84094
commit 6ed47ad916
4 changed files with 10 additions and 10 deletions

View file

@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Neg, Range, Sub, SubAssign};
use crossterm::style::ContentStyle; use crossterm::style::ContentStyle;
use crate::styled::Styled; use crate::styled::Styled;
use crate::widthdb::WidthDB; use crate::widthdb::WidthDb;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Size { pub struct Size {
@ -362,7 +362,7 @@ impl Buffer {
/// ///
/// The initial x position is considered the first column for tab width /// The initial x position is considered the first column for tab width
/// calculations. /// calculations.
pub fn write(&mut self, widthdb: &mut WidthDB, pos: Pos, styled: &Styled) { pub fn write(&mut self, widthdb: &mut WidthDb, pos: Pos, styled: &Styled) {
let frame = self.current_frame(); let frame = self.current_frame();
let (xrange, yrange) = match frame.legal_ranges() { let (xrange, yrange) = match frame.legal_ranges() {
Some(ranges) => ranges, Some(ranges) => ranges,

View file

@ -3,12 +3,12 @@
use crate::buffer::Buffer; use crate::buffer::Buffer;
pub use crate::buffer::{Pos, Size}; pub use crate::buffer::{Pos, Size};
use crate::styled::Styled; use crate::styled::Styled;
use crate::widthdb::WidthDB; use crate::widthdb::WidthDb;
use crate::wrap; use crate::wrap;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct Frame { pub struct Frame {
pub(crate) widthdb: WidthDB, pub(crate) widthdb: WidthDb,
pub(crate) buffer: Buffer, pub(crate) buffer: Buffer,
} }
@ -45,7 +45,7 @@ impl Frame {
self.set_cursor(None); self.set_cursor(None);
} }
pub fn widthdb(&mut self) -> &mut WidthDB { pub fn widthdb(&mut self) -> &mut WidthDb {
&mut self.widthdb &mut self.widthdb
} }

View file

@ -12,14 +12,14 @@ use crate::wrap;
/// Measures and stores the with (in terminal coordinates) of graphemes. /// Measures and stores the with (in terminal coordinates) of graphemes.
#[derive(Debug)] #[derive(Debug)]
pub struct WidthDB { pub struct WidthDb {
pub(crate) active: bool, pub(crate) active: bool,
pub(crate) tab_width: u8, pub(crate) tab_width: u8,
known: HashMap<String, u8>, known: HashMap<String, u8>,
requested: HashSet<String>, requested: HashSet<String>,
} }
impl Default for WidthDB { impl Default for WidthDb {
fn default() -> Self { fn default() -> Self {
Self { Self {
active: false, active: false,
@ -30,7 +30,7 @@ impl Default for WidthDB {
} }
} }
impl WidthDB { impl WidthDb {
/// Determine the width of a tab character starting at the specified column. /// Determine the width of a tab character starting at the specified column.
fn tab_width_at_column(&self, col: usize) -> u8 { fn tab_width_at_column(&self, col: usize) -> u8 {
self.tab_width - (col % self.tab_width as usize) as u8 self.tab_width - (col % self.tab_width as usize) as u8

View file

@ -3,9 +3,9 @@
use unicode_linebreak::BreakOpportunity; use unicode_linebreak::BreakOpportunity;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use crate::widthdb::WidthDB; use crate::widthdb::WidthDb;
pub fn wrap(widthdb: &mut WidthDB, text: &str, width: usize) -> Vec<usize> { pub fn wrap(widthdb: &mut WidthDb, text: &str, width: usize) -> Vec<usize> {
let mut breaks = vec![]; let mut breaks = vec![];
let mut break_options = unicode_linebreak::linebreaks(text).peekable(); let mut break_options = unicode_linebreak::linebreaks(text).peekable();