third_party/rust/lalrpop-snap/src/message/indent.rs
author David Teller <dteller@mozilla.com>
Wed, 04 Apr 2018 14:14:26 +0200
changeset 412088 a97cccaa866a0fbd5721842ad8d8e862cd26ea65
permissions -rw-r--r--
Bug 1437004 - Vendored Rust dependencies;r=froydnj MozReview-Commit-ID: Grf1bKIx2iT

use ascii_canvas::AsciiView;
use super::*;

#[derive(Debug)]
pub struct Indent {
    amount: usize,
    content: Box<Content>,
}

impl Indent {
    pub fn new(amount: usize, content: Box<Content>) -> Self {
        Indent {
            amount: amount,
            content: content,
        }
    }
}

impl Content for Indent {
    fn min_width(&self) -> usize {
        self.content.min_width() + self.amount
    }

    fn emit(&self, view: &mut AsciiView) {
        let mut subview = view.shift(0, self.amount);
        self.content.emit(&mut subview);
    }

    fn into_wrap_items(self: Box<Self>, wrap_items: &mut Vec<Box<Content>>) {
        wrap_items.push(self);
    }
}