/*
 * Ibis - IRCv3 Library
 * Copyright (C) 2022-2024 Ibis Developers
 *
 * Ibis is the legal property of its developers, whose names are too numerous
 * to list here.  Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This library 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#if !defined(IBIS_GLOBAL_HEADER_INSIDE) && !defined(IBIS_COMPILATION)
# error "only <ibis.h> may be included directly"
#endif

#ifndef IBIS_FORMATTING_H
#define IBIS_FORMATTING_H

#include <glib.h>

#include <pango/pango.h>

#include "ibisversion.h"

G_BEGIN_DECLS

/**
 * IBIS_FORMAT_BOLD:
 *
 * A constant for the bold formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_BOLD (0x02) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_COLOR:
 *
 * A constant for the color formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_COLOR (0x03) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_HEX_COLOR:
 *
 * A constant for the hex color formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_HEX_COLOR (0x04) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_ITALIC:
 *
 * A constant for the italic formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_ITALIC (0x1d) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_MONOSPACE:
 *
 * A constant for the monospace formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_MONOSPACE (0x11) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_RESET:
 *
 * A constant for the reset formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_RESET (0x0f) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_REVERSE:
 *
 * A constant for the revert color formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_REVERSE (0x16) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_STRIKETHROUGH:
 *
 * A constant for the strike-through formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_STRIKETHROUGH (0x1e) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * IBIS_FORMAT_UNDERLINE:
 *
 * A constant for the underline formatting character.
 *
 * See the [formatting specification](https://modern.ircdocs.horse/formatting)
 * for more information.
 *
 * Since: 0.14
 */
#define IBIS_FORMAT_UNDERLINE (0x1f) IBIS_AVAILABLE_MACRO_IN_0_14

/**
 * ibis_formatting_parse:
 * @text: (nullable): the text to parse
 * @attrs: (out) (optional): a return address for the formatting attributes
 *
 * Separates the raw text and its formatting.
 *
 * Returns: (nullable): The raw text.
 *
 * Since: 0.13
 */
IBIS_AVAILABLE_IN_0_13
char *ibis_formatting_parse(const char *text, PangoAttrList **attrs);

/**
 * ibis_formatting_strip:
 * @text: (nullable): the text to strip
 *
 * Removes all formatting from @text and returns the result.
 *
 * Returns: (transfer full) (nullable): The result of stripping @text.
 *
 * Since: 0.1
 */
IBIS_AVAILABLE_IN_0_1
char *ibis_formatting_strip(const char *text);

G_END_DECLS

#endif /* IBIS_FORMATTING_H */
