// Copyright (C) 2021 Mathieu Duponchelle // // This Source Code Form is subject to the terms of the Mozilla Public License, v2.0. // If a copy of the MPL was not distributed with this file, You can obtain one at // . // // SPDX-License-Identifier: MPL-2.0 use serde::{Deserialize, Serialize}; use crate::cea608utils::*; // TODO allow indenting chunks #[derive(Clone, Serialize, Deserialize, Debug)] pub struct Chunk { pub style: TextStyle, pub underline: bool, pub text: String, } #[derive(Clone, Serialize, Deserialize, Debug)] pub struct Line { pub column: Option, pub row: Option, pub chunks: Vec, /* In roll-up modes, new lines don't introduce a carriage return by * default, but that can be overridden */ pub carriage_return: Option, } #[derive(Clone, Serialize, Deserialize, Debug)] pub struct Lines { pub lines: Vec, pub mode: Option, pub clear: Option, } impl Lines { pub fn new_empty() -> Self { Self { lines: vec![], mode: None, clear: None, } } } impl Cea608Mode { pub fn is_rollup(&self) -> bool { *self == Cea608Mode::RollUp2 || *self == Cea608Mode::RollUp3 || *self == Cea608Mode::RollUp4 } }