use crate::input::{
command::RunCommand,
config::ConfigError,
layout::{Layout, PaneLayout, Run, RunPlugin, RunPluginLocation, SplitDirection, SplitSize},
};
use kdl::*;
use std::collections::{HashMap, HashSet};
use std::str::FromStr;
use crate::{
kdl_child_with_name, kdl_children_nodes, kdl_get_bool_property_or_child_value,
kdl_get_bool_property_or_child_value_with_error, kdl_get_child,
kdl_get_int_property_or_child_value, kdl_get_property_or_child, kdl_get_string_entry,
kdl_get_string_property_or_child_value, kdl_get_string_property_or_child_value_with_error,
kdl_name, kdl_parsing_error, kdl_property_names, kdl_property_or_child_value_node,
kdl_string_arguments,
};
use std::convert::TryFrom;
use std::path::PathBuf;
use std::vec::Vec;
use url::Url;
pub struct KdlLayoutParser<'a> {
raw_layout: &'a str,
tab_templates: HashMap<String, (PaneLayout, KdlNode)>,
pane_templates: HashMap<String, (PaneLayout, KdlNode)>,
default_tab_template: Option<(PaneLayout, KdlNode)>,
}
impl<'a> KdlLayoutParser<'a> {
pub fn new(raw_layout: &'a str) -> Self {
KdlLayoutParser {
raw_layout,
tab_templates: HashMap::new(),
pane_templates: HashMap::new(),
default_tab_template: None,
}
}
fn is_a_reserved_word(&self, word: &str) -> bool {
word == "pane"
|| word == "layout"
|| word == "pane_template"
|| word == "tab_template"
|| word == "default_tab_template"
|| word == "command"
|| word == "plugin"
|| word == "children"
|| word == "tab"
|| word == "args"
|| word == "borderless"
|| word == "focus"
|| word == "name"
|| word == "size"