|
132 | 132 | //! methods called `Printer::scan_*`, and the 'PRINT' process is the |
133 | 133 | //! method called `Printer::print`. |
134 | 134 |
|
| 135 | +mod convenience; |
135 | 136 | mod ring; |
136 | 137 |
|
137 | 138 | use ring::RingBuffer; |
@@ -186,12 +187,6 @@ pub enum Token { |
186 | 187 | End, |
187 | 188 | } |
188 | 189 |
|
189 | | -impl Token { |
190 | | - pub fn is_hardbreak_tok(&self) -> bool { |
191 | | - matches!(self, Token::Break(BreakToken { offset: 0, blank_space: SIZE_INFINITY })) |
192 | | - } |
193 | | -} |
194 | | - |
195 | 190 | #[derive(Copy, Clone)] |
196 | 191 | enum PrintFrame { |
197 | 192 | Fits, |
@@ -441,73 +436,4 @@ impl Printer { |
441 | 436 | self.out.push_str(string); |
442 | 437 | self.space -= string.len() as isize; |
443 | 438 | } |
444 | | - |
445 | | - // Convenience functions to talk to the printer. |
446 | | - |
447 | | - /// "raw box" |
448 | | - pub fn rbox(&mut self, indent: usize, breaks: Breaks) { |
449 | | - self.scan_begin(BeginToken { |
450 | | - indent: IndentStyle::Block { offset: indent as isize }, |
451 | | - breaks, |
452 | | - }) |
453 | | - } |
454 | | - |
455 | | - /// Inconsistent breaking box |
456 | | - pub fn ibox(&mut self, indent: usize) { |
457 | | - self.rbox(indent, Breaks::Inconsistent) |
458 | | - } |
459 | | - |
460 | | - /// Consistent breaking box |
461 | | - pub fn cbox(&mut self, indent: usize) { |
462 | | - self.rbox(indent, Breaks::Consistent) |
463 | | - } |
464 | | - |
465 | | - pub fn visual_align(&mut self) { |
466 | | - self.scan_begin(BeginToken { indent: IndentStyle::Visual, breaks: Breaks::Consistent }); |
467 | | - } |
468 | | - |
469 | | - pub fn break_offset(&mut self, n: usize, off: isize) { |
470 | | - self.scan_break(BreakToken { offset: off, blank_space: n as isize }) |
471 | | - } |
472 | | - |
473 | | - pub fn end(&mut self) { |
474 | | - self.scan_end() |
475 | | - } |
476 | | - |
477 | | - pub fn eof(mut self) -> String { |
478 | | - self.scan_eof(); |
479 | | - self.out |
480 | | - } |
481 | | - |
482 | | - pub fn word<S: Into<Cow<'static, str>>>(&mut self, wrd: S) { |
483 | | - let string = wrd.into(); |
484 | | - self.scan_string(string) |
485 | | - } |
486 | | - |
487 | | - fn spaces(&mut self, n: usize) { |
488 | | - self.break_offset(n, 0) |
489 | | - } |
490 | | - |
491 | | - pub fn zerobreak(&mut self) { |
492 | | - self.spaces(0) |
493 | | - } |
494 | | - |
495 | | - pub fn space(&mut self) { |
496 | | - self.spaces(1) |
497 | | - } |
498 | | - |
499 | | - pub fn hardbreak(&mut self) { |
500 | | - self.spaces(SIZE_INFINITY as usize) |
501 | | - } |
502 | | - |
503 | | - pub fn is_beginning_of_line(&self) -> bool { |
504 | | - match self.last_token() { |
505 | | - Some(last_token) => last_token.is_hardbreak_tok(), |
506 | | - None => true, |
507 | | - } |
508 | | - } |
509 | | - |
510 | | - pub fn hardbreak_tok_offset(off: isize) -> Token { |
511 | | - Token::Break(BreakToken { offset: off, blank_space: SIZE_INFINITY }) |
512 | | - } |
513 | 439 | } |
0 commit comments