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