Rename WidthDB to WidthDb
This commit is contained in:
parent
f258c84094
commit
6ed47ad916
4 changed files with 10 additions and 10 deletions
|
|
@ -3,7 +3,7 @@ use std::ops::{Add, AddAssign, Neg, Range, Sub, SubAssign};
|
|||
use crossterm::style::ContentStyle;
|
||||
|
||||
use crate::styled::Styled;
|
||||
use crate::widthdb::WidthDB;
|
||||
use crate::widthdb::WidthDb;
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Size {
|
||||
|
|
@ -362,7 +362,7 @@ impl Buffer {
|
|||
///
|
||||
/// The initial x position is considered the first column for tab width
|
||||
/// 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 (xrange, yrange) = match frame.legal_ranges() {
|
||||
Some(ranges) => ranges,
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
use crate::buffer::Buffer;
|
||||
pub use crate::buffer::{Pos, Size};
|
||||
use crate::styled::Styled;
|
||||
use crate::widthdb::WidthDB;
|
||||
use crate::widthdb::WidthDb;
|
||||
use crate::wrap;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Frame {
|
||||
pub(crate) widthdb: WidthDB,
|
||||
pub(crate) widthdb: WidthDb,
|
||||
pub(crate) buffer: Buffer,
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ impl Frame {
|
|||
self.set_cursor(None);
|
||||
}
|
||||
|
||||
pub fn widthdb(&mut self) -> &mut WidthDB {
|
||||
pub fn widthdb(&mut self) -> &mut WidthDb {
|
||||
&mut self.widthdb
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ use crate::wrap;
|
|||
|
||||
/// Measures and stores the with (in terminal coordinates) of graphemes.
|
||||
#[derive(Debug)]
|
||||
pub struct WidthDB {
|
||||
pub struct WidthDb {
|
||||
pub(crate) active: bool,
|
||||
pub(crate) tab_width: u8,
|
||||
known: HashMap<String, u8>,
|
||||
requested: HashSet<String>,
|
||||
}
|
||||
|
||||
impl Default for WidthDB {
|
||||
impl Default for WidthDb {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
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.
|
||||
fn tab_width_at_column(&self, col: usize) -> u8 {
|
||||
self.tab_width - (col % self.tab_width as usize) as u8
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
use unicode_linebreak::BreakOpportunity;
|
||||
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 break_options = unicode_linebreak::linebreaks(text).peekable();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue