<commit_before>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
/* gtksourcebuffer.c
 * This file is part of GtkSourceView
 *
 * Copyright (C) 1999-2002 - <NAME> <<EMAIL>>,
 *                           <NAME> <<EMAIL>> and
 *                           <NAME> <<EMAIL>>
 * Copyright (C) 2003 - <NAME> <<EMAIL>> and
 *                      <NAME> <<EMAIL>>
 *
 * GtkSourceView 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 2.1 of the License, or (at your option) any later version.
 *
 * GtkSourceView 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <gtk/gtk.h>

#include "gtksourcebuffer.h"
#include "gtksourcebuffer-private.h"
#include "gtksourcelanguage.h"
#include "gtksourcelanguage-private.h"
#include "gtksourceundomanager.h"
#include "gtksourceundomanagerdefault.h"
#include "gtksourcestylescheme.h"
#include "gtksourcestyleschememanager.h"
#include "gtksourcestyle-private.h"
#include "gtksourcemark.h"
#include "gtksourcemarkssequence.h"
#include "gtksourcesearchcontext.h"
#include "gtksourceview-i18n.h"
#include "gtksourceview-marshal.h"
#include "gtksourceview-typebuiltins.h"

/**
 * SECTION:buffer
 * @Short_description: Buffer object for #GtkSourceView
 * @Title: GtkSourceBuffer
 * @See_also: #GtkTextBuffer, #GtkSourceView
 *
 * <para>
 *   The #GtkSourceBuffer object is the model for #GtkSourceView widgets.
 *   It extends the #GtkTextBuffer object by adding features useful to display
 *   and edit source code such as syntax highlighting and bracket matching. It
 *   also implements support for undo/redo operations, and for the search and
 *   replace.
 * </para>
 * <para>
 *   To create a #GtkSourceBuffer use gtk_source_buffer_new() or
 *   gtk_source_buffer_new_with_language(). The second form is just a convenience
 *   function which allows you to initially set a #GtkSourceLanguage.
 * </para>
 * <para>
 *   By default highlighting is enabled, but you can disable it with
 *   gtk_source_buffer_set_highlight_syntax().
 * </para>
 * <refsect2>
 *   <title>Undo and Redo</title>
 *   <para>
 *     A custom #GtkSourceUndoManager can be implemented and set with
 *     gtk_source_buffer_set_undo_manager(). However the default implementation
 *     should be suitable for most uses. By default, actions that can be undone or
 *     redone are defined as groups of operations between a call to
 *     gtk_text_buffer_begin_user_action() and gtk_text_buffer_end_user_action(). In
 *     general, this happens whenever the user presses any key which modifies the
 *     buffer. But the default undo manager will try to merge similar consecutive
 *     actions, such as multiple character insertions on the same line, into one
 *     action. But, inserting a newline starts a new action.
 *   </para>
 *   <para>
 *     The default undo manager remembers the "modified" state of the buffer, and
 *     restore it when an action is undone or redone. It can be useful in a text
 *     editor to know whether the file is saved. See gtk_text_buffer_get_modified()
 *     and gtk_text_buffer_set_modified().
 *   </para>
 * </refsect2>
 * <refsect2>
 *   <title>Context Classes</title>
 *   <para>
 *     It is possible to retrieve some information from the syntax highlighting
 *     engine. There are currently three default context classes that are
 *     applied to regions of a #GtkSourceBuffer:
 *   </para>
 *   <itemizedlist>
 *     <listitem>
 *       <para>
 *         <emphasis>comment</emphasis>: the region delimits a comment;
 *       </para>
 *     </listitem>
 *     <listitem>
 *       <para>
 *         <emphasis>string</emphasis>: the region delimits a string;
 *       </para>
 *     </listitem>
 *     <listitem>
 *       <para>
 *         <emphasis>no-spell-check</emphasis>: the region should not be spell
 *         checked.
 *       </para>
 *     </listitem>
 *   </itemizedlist>
 *   <para>
 *     Custom language definition files can create their own context classes,
 *     since the functions like gtk_source_buffer_iter_has_context_class() take
 *     a string parameter as the context class.
 *   </para>
 * </refsect2>
 */

/*
#define ENABLE_DEBUG
#define ENABLE_PROFILE
*/
#undef ENABLE_DEBUG
#undef ENABLE_PROFILE

#ifdef ENABLE_DEBUG
#define DEBUG(x) (x)
#else
#define DEBUG(x)
#endif

#ifdef ENABLE_PROFILE
#define PROFILE(x) (x)
#else
#define PROFILE(x)
#endif

/* For bracket matching */
#define MAX_CHARS_BEFORE_FINDING_A_MATCH    10000
<commit_msg>Doc: replace DocBook tags with markdown syntax<commit_after>/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*- */
/* gtksourcebuffer.c
 * This file is part of GtkSourceView
 *
 * Copyright (C) 1999-2002 - <NAME> <<EMAIL>>,
 *                           <NAME> <<EMAIL>> and
 *                           <NAME> <<EMAIL>>
 * Copyright (C) 2003 - <NAME> <<EMAIL>> and
 *                      <NAME> <<EMAIL>>
 *
 * GtkSourceView 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 2.1 of the License, or (at your option) any later version.
 *
 * GtkSourceView 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string.h>
#include <gtk/gtk.h>

#include "gtksourcebuffer.h"
#include "gtksourcebuffer-private.h"
#include "gtksourcelanguage.h"
#include "gtksourcelanguage-private.h"
#include "gtksourceundomanager.h"
#include "gtksourceundomanagerdefault.h"
#include "gtksourcestylescheme.h"
#include "gtksourcestyleschememanager.h"
#include "gtksourcestyle-private.h"
#include "gtksourcemark.h"
#include "gtksourcemarkssequence.h"
#include "gtksourcesearchcontext.h"
#include "gtksourceview-i18n.h"
#include "gtksourceview-marshal.h"
#include "gtksourceview-typebuiltins.h"

/**
 * SECTION:buffer
 * @Short_description: Buffer object for #GtkSourceView
 * @Title: GtkSourceBuffer
 * @See_also: #GtkTextBuffer, #GtkSourceView
 *
 * The #GtkSourceBuffer object is the model for #GtkSourceView widgets.
 * It extends the #GtkTextBuffer object by adding features useful to display
 * and edit source code such as syntax highlighting and bracket matching. It
 * also implements support for undo/redo operations, and for the search and
 * replace.
 *
 * To create a #GtkSourceBuffer use gtk_source_buffer_new() or
 * gtk_source_buffer_new_with_language(). The second form is just a convenience
 * function which allows you to initially set a #GtkSourceLanguage.
 *
 * By default highlighting is enabled, but you can disable it with
 * gtk_source_buffer_set_highlight_syntax().
 *
 * # Undo and Redo #
 *
 * A custom #GtkSourceUndoManager can be implemented and set with
 * gtk_source_buffer_set_undo_manager(). However the default implementation
 * should be suitable for most uses. By default, actions that can be undone or
 * redone are defined as groups of operations between a call to
 * gtk_text_buffer_begin_user_action() and gtk_text_buffer_end_user_action(). In
 * general, this happens whenever the user presses any key which modifies the
 * buffer. But the default undo manager will try to merge similar consecutive
 * actions, such as multiple character insertions on the same line, into one
 * action. But, inserting a newline starts a new action.
 *
 * The default undo manager remembers the "modified" state of the buffer, and
 * restore it when an action is undone or redone. It can be useful in a text
 * editor to know whether the file is saved. See gtk_text_buffer_get_modified()
 * and gtk_text_buffer_set_modified().
 *
 * # Context Classes #
 *
 * It is possible to retrieve some information from the syntax highlighting
 * engine. There are currently three default context classes that are
 * applied to regions of a #GtkSourceBuffer:
 *  - <emphasis>comment</emphasis>: the region delimits a comment;
 *  - <emphasis>string</emphasis>: the region delimits a string;
 *  - <emphasis>no-spell-check</emphasis>: the region should not be spell checked.
 *
 * Custom language definition files can create their own context classes,
 * since the functions like gtk_source_buffer_iter_has_context_class() take
 * a string parameter as the context class.
 */

/*
#define ENABLE_DEBUG
#define ENABLE_PROFILE
*/
#undef ENABLE_DEBUG
#undef ENABLE_PROFILE

#ifdef ENABLE_DEBUG
#define DEBUG(x) (x)
#else
#define DEBUG(x)
#endif

#ifdef ENABLE_PROFILE
#define PROFILE(x) (x)
#else
#define PROFILE(x)
#endif

/* For bracket matching */
#define MAX_CHARS_BEFORE_FINDING_A_MATCH    10000

{'fraction_non_alphanumeric': 0.0898303320495472, 'fraction_numerical': 0.007702716769022588, 'mean_word_length': 3.808808808808809, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6622617', 'n_tokens_mistral': 2951, 'n_tokens_neox': 2852, 'n_words': 1068}