Documentation
/*
==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

Dia-Args

Copyright (C) 2018-2019, 2021-2025  Anonymous

There are several releases over multiple years,
they are listed as ranges, such as: "2018-2019".

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--
*/

//! # Configuration

/// # Configuration
///
/// ## Default values
///
/// | Name       | Value
/// | ---------- | -----
/// | Tab length | `4`
/// | Tab level  | `0`
/// | Columns    | `128`
#[derive(Debug)]
pub struct Cfg {
    tab_len: usize,
    tab_level: u8,
    columns: usize,
}

impl Default for Cfg {

    fn default() -> Self {
        Self::new(4, 0, 128)
    }

}

impl Cfg {

    /// # Makes new instance
    pub const fn new(tab_len: usize, tab_level: u8, columns: usize) -> Self {
        Self {
            tab_len,
            tab_level,
            columns,
        }
    }

    /// # Length of a tab
    pub fn tab_len(&self) -> usize {
        self.tab_len
    }

    /// # Tab level
    pub fn tab_level(&self) -> u8 {
        self.tab_level
    }

    /// # Increments level
    ///
    /// This function uses `saturating_add()` while incrementing level.
    pub fn increment_level(&self) -> Self {
        Self::new(self.tab_len, self.tab_level.saturating_add(1), self.columns)
    }

    /// # Columns
    pub fn columns(&self) -> usize {
        self.columns
    }

}