2020-01-11 10:02:46 -06:00
|
|
|
use crate::pp::Printer;
|
2019-12-22 16:42:04 -06:00
|
|
|
use std::borrow::Cow;
|
2019-07-09 08:26:50 -05:00
|
|
|
|
|
|
|
impl Printer {
|
|
|
|
pub fn word_space<W: Into<Cow<'static, str>>>(&mut self, w: W) {
|
|
|
|
self.word(w);
|
|
|
|
self.space();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn popen(&mut self) {
|
|
|
|
self.word("(");
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn pclose(&mut self) {
|
|
|
|
self.word(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn hardbreak_if_not_bol(&mut self) {
|
|
|
|
if !self.is_beginning_of_line() {
|
|
|
|
self.hardbreak()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn space_if_not_bol(&mut self) {
|
2019-12-22 16:42:04 -06:00
|
|
|
if !self.is_beginning_of_line() {
|
|
|
|
self.space();
|
|
|
|
}
|
2019-07-09 08:26:50 -05:00
|
|
|
}
|
|
|
|
|
2019-12-22 16:42:04 -06:00
|
|
|
pub fn nbsp(&mut self) {
|
|
|
|
self.word(" ")
|
|
|
|
}
|
2019-07-09 08:26:50 -05:00
|
|
|
|
|
|
|
pub fn word_nbsp<S: Into<Cow<'static, str>>>(&mut self, w: S) {
|
|
|
|
self.word(w);
|
|
|
|
self.nbsp()
|
|
|
|
}
|
2021-12-05 13:56:43 -06:00
|
|
|
|
|
|
|
// Synthesizes a comment that was not textually present in the original
|
|
|
|
// source file.
|
|
|
|
pub fn synth_comment(&mut self, text: impl Into<Cow<'static, str>>) {
|
|
|
|
self.word("/*");
|
|
|
|
self.space();
|
|
|
|
self.word(text);
|
|
|
|
self.space();
|
|
|
|
self.word("*/")
|
|
|
|
}
|
2019-07-09 08:26:50 -05:00
|
|
|
}
|