Skip to main content

Printer

Struct Printer 

Source
pub struct Printer {
Show 17 fields pub selector: Selector, pub term_offset: usize, pub term_just_wrapped: bool, pub file_offset: usize, pub max_print_line: usize, pub log_slack: usize, pub term_quiet: bool, pub quiet_line: Vec<u8>, pub capture: Option<Vec<u8>>, pub error_line: usize, pub half_error_line: usize, pub tally: usize, pub trick_buf: Vec<Vec<u8>>, pub trick_count: usize, pub first_count: usize, pub cur_string: Vec<u8>, pub new_line_char: i32, /* private fields */
}
Expand description

The printer state.

Fields§

§selector: Selector

Current destination.

§term_offset: usize

Characters on the current terminal line.

§term_just_wrapped: bool

Whether the last terminal output was an automatic line break at max_print_line.

§file_offset: usize

Characters on the current log line.

§max_print_line: usize

Maximum line length for terminal and log.

§log_slack: usize

Extra characters allowed on a log line. LuaTeX lets text printed from Lua (texio) and its own warnings run one character past max_print_line in the log, but not on the terminal.

§term_quiet: bool

Default output mode: nothing is written to the terminal, but line positions are tracked as if it were, so the log is unchanged.

§quiet_line: Vec<u8>

While the terminal is quiet: the text of its current line (a prompt such as Enter file name: ), shown when the terminal is read.

§capture: Option<Vec<u8>>

While Some, the text printed to the terminal or log is also collected here (used to turn error messages into diagnostics).

§error_line: usize

Width of error context lines.

§half_error_line: usize

Width of the first half of an error context line.

§tally: usize

Characters printed so far in the current pseudo-print or other counted operation (TeX’s tally).

§trick_buf: Vec<Vec<u8>>

Buffer for pseudo printing: one entry per counted position, a byte or the bytes of an invalid input byte shown with its successors.

§trick_count: usize

Limit of pseudo-printed characters to keep.

§first_count: usize

The tally at the start of the second line of pseudo printing.

§cur_string: Vec<u8>

The string under construction (NewString).

§new_line_char: i32

The current \newlinechar (−1 for none).

Implementations§

Source§

impl Printer

Source

pub fn new(term: Box<dyn Write>) -> Self

A printer writing to term.

Source

pub fn set_log(&mut self, log: Box<dyn Write>)

Installs the log file.

Source

pub fn log_opened(&self) -> bool

Whether a log file is open.

Source

pub fn close_log(&mut self)

Flushes and closes the log file.

Source

pub fn log_raw(&mut self, bytes: &[u8])

Writes raw bytes to the log without bookkeeping (for banners).

Source

pub fn term_raw(&mut self, bytes: &[u8])

Writes raw bytes to the terminal without bookkeeping (nothing while the terminal is quiet).

Source

pub fn update_terminal(&mut self)

Flushes the terminal (TeX’s update_terminal).

Source

pub fn open_write(&mut self, n: u32, w: Box<dyn Write>)

Opens \write stream n on w.

Source

pub fn open_write_streams(&self) -> Vec<u32>

The \write streams that are open.

Source

pub fn close_write(&mut self, n: u32)

Closes \write stream n.

Source

pub fn write_open(&self, n: u32) -> bool

Whether \write stream n is open.

Source

pub fn print_ln(&mut self)

Ends the current line (TeX’s print_ln).

Source

pub fn print_char(&mut self, c: u32)

Prints character c, handling the new-line character and the printable representation for terminal and log.

Source

pub fn print_raw_byte(&mut self, b: u8)

Prints byte b as it is (a byte of invalid UTF-8 input).

Source

pub fn pseudo_unit(&mut self, bytes: &[u8])

Pseudo-prints bytes (possibly none) as they are, counted as one position: how LuaTeX shows an invalid byte of an input line.

Source

pub fn print_str(&mut self, s: &str)

Prints an ASCII string (e.g. a fixed message).

Source

pub fn print_callback_bytes(&mut self, s: &[u8])

Prints a string returned by a Lua callback (glyph_info): the log gets the bytes as they are, the terminal shows control characters in ^^ notation.

Source

pub fn print_plain(&mut self, s: &str)

Prints digits and other characters TeX prints one by one with print_char (no log slack).

Source

pub fn print_bytes(&mut self, s: &[u8])

Prints a byte string in extended UTF-8 (e.g. a control-sequence name or file name).

Source

pub fn print_lua_bytes(&mut self, s: &[u8])

Prints a byte string as text coming from Lua, with LuaTeX’s log line length for it (see log_slack).

Source

pub fn luatex_warning(&mut self, category: &str, msg: &str)

A LuaTeX warning, warning (category): message, on a line of its own.

Source

pub fn print_nl(&mut self, s: &str)

Starts a new line unless at the beginning of one (TeX’s print_nl).

Source

pub fn begin_line(&mut self)

The test-and-newline part of print_nl: ends the current terminal or log line if it is not empty.

Source

pub fn print_int(&mut self, n: i64)

Prints a decimal integer (TeX’s print_int).

Source

pub fn print_scaled(&mut self, s: i32)

Prints a scaled value (TeX’s print_scaled).

Source

pub fn print_hex(&mut self, n: i64)

Prints " followed by the uppercase hexadecimal value (TeX’s print_hex).

Source

pub fn print_roman_int(&mut self, n: i64)

Prints a positive integer in lowercase roman numerals (TeX’s print_roman_int).

Source

pub fn take_string(&mut self) -> Vec<u8> ⓘ

Takes the string built by NewString printing.

Source

pub fn flush(&mut self)

Flushes all outputs.

Trait Implementations§

Source§

impl Debug for Printer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.