/* NoteView.c generated by valac 0.56.19, the Vala compiler
 * generated from NoteView.vala, do not modify */

/*
* Copyright (c) 2017 Lains
*
* This program 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 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#include <glib-object.h>
#include <gtksourceview/gtksource.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
#include <glib/gstdio.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_COMPLETION_ITEM (completion_item_get_type ())
#define COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPLETION_ITEM, CompletionItem))
#define COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPLETION_ITEM, CompletionItemClass))
#define IS_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPLETION_ITEM))
#define IS_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPLETION_ITEM))
#define COMPLETION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPLETION_ITEM, CompletionItemClass))

typedef struct _CompletionItem CompletionItem;
typedef struct _CompletionItemClass CompletionItemClass;
typedef struct _CompletionItemPrivate CompletionItemPrivate;
enum  {
	COMPLETION_ITEM_0_PROPERTY,
	COMPLETION_ITEM_LABEL_PROPERTY,
	COMPLETION_ITEM_TEXT_PROPERTY,
	COMPLETION_ITEM_NUM_PROPERTIES
};
static GParamSpec* completion_item_properties[COMPLETION_ITEM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_COMPLETION_ITEM_FILTER (completion_item_filter_get_type ())
#define COMPLETION_ITEM_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPLETION_ITEM_FILTER, CompletionItemFilter))
#define COMPLETION_ITEM_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPLETION_ITEM_FILTER, CompletionItemFilterClass))
#define IS_COMPLETION_ITEM_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPLETION_ITEM_FILTER))
#define IS_COMPLETION_ITEM_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPLETION_ITEM_FILTER))
#define COMPLETION_ITEM_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPLETION_ITEM_FILTER, CompletionItemFilterClass))

typedef struct _CompletionItemFilter CompletionItemFilter;
typedef struct _CompletionItemFilterClass CompletionItemFilterClass;
typedef struct _CompletionItemFilterPrivate CompletionItemFilterPrivate;
enum  {
	COMPLETION_ITEM_FILTER_0_PROPERTY,
	COMPLETION_ITEM_FILTER_NUM_PROPERTIES
};
static GParamSpec* completion_item_filter_properties[COMPLETION_ITEM_FILTER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define TYPE_COMPLETION_PROVIDER (completion_provider_get_type ())
#define COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_COMPLETION_PROVIDER, CompletionProvider))
#define COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_COMPLETION_PROVIDER, CompletionProviderClass))
#define IS_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_COMPLETION_PROVIDER))
#define IS_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_COMPLETION_PROVIDER))
#define COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_COMPLETION_PROVIDER, CompletionProviderClass))

typedef struct _CompletionProvider CompletionProvider;
typedef struct _CompletionProviderClass CompletionProviderClass;
typedef struct _CompletionProviderPrivate CompletionProviderPrivate;

#define TYPE_MAIN_WINDOW (main_window_get_type ())
#define MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_WINDOW, MainWindow))
#define MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_WINDOW, MainWindowClass))
#define IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_WINDOW))
#define IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_WINDOW))
#define MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_WINDOW, MainWindowClass))

typedef struct _MainWindow MainWindow;
typedef struct _MainWindowClass MainWindowClass;
enum  {
	COMPLETION_PROVIDER_0_PROPERTY,
	COMPLETION_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* completion_provider_properties[COMPLETION_PROVIDER_NUM_PROPERTIES];
typedef struct _CompletionProviderPopulateAsyncData CompletionProviderPopulateAsyncData;

#define TYPE_NOTE_VIEW (note_view_get_type ())
#define NOTE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NOTE_VIEW, NoteView))
#define NOTE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NOTE_VIEW, NoteViewClass))
#define IS_NOTE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NOTE_VIEW))
#define IS_NOTE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NOTE_VIEW))
#define NOTE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NOTE_VIEW, NoteViewClass))

typedef struct _NoteView NoteView;
typedef struct _NoteViewClass NoteViewClass;
typedef struct _NoteViewPrivate NoteViewPrivate;

#define NOTE_VIEW_TYPE_URL_POS (note_view_url_pos_get_type ())
#define NOTE_VIEW_URL_POS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTE_VIEW_TYPE_URL_POS, NoteViewUrlPos))
#define NOTE_VIEW_URL_POS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NOTE_VIEW_TYPE_URL_POS, NoteViewUrlPosClass))
#define NOTE_VIEW_IS_URL_POS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTE_VIEW_TYPE_URL_POS))
#define NOTE_VIEW_IS_URL_POS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTE_VIEW_TYPE_URL_POS))
#define NOTE_VIEW_URL_POS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NOTE_VIEW_TYPE_URL_POS, NoteViewUrlPosClass))

typedef struct _NoteViewUrlPos NoteViewUrlPos;
typedef struct _NoteViewUrlPosClass NoteViewUrlPosClass;

#define NOTE_VIEW_TYPE_LINK_POS (note_view_link_pos_get_type ())
#define NOTE_VIEW_LINK_POS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NOTE_VIEW_TYPE_LINK_POS, NoteViewLinkPos))
#define NOTE_VIEW_LINK_POS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NOTE_VIEW_TYPE_LINK_POS, NoteViewLinkPosClass))
#define NOTE_VIEW_IS_LINK_POS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NOTE_VIEW_TYPE_LINK_POS))
#define NOTE_VIEW_IS_LINK_POS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NOTE_VIEW_TYPE_LINK_POS))
#define NOTE_VIEW_LINK_POS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NOTE_VIEW_TYPE_LINK_POS, NoteViewLinkPosClass))

typedef struct _NoteViewLinkPos NoteViewLinkPos;
typedef struct _NoteViewLinkPosClass NoteViewLinkPosClass;
enum  {
	NOTE_VIEW_0_PROPERTY,
	NOTE_VIEW_TEXT_PROPERTY,
	NOTE_VIEW_MODIFIED_PROPERTY,
	NOTE_VIEW_NUM_PROPERTIES
};
static GParamSpec* note_view_properties[NOTE_VIEW_NUM_PROPERTIES];
#define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
typedef struct _Block50Data Block50Data;
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
typedef struct _NoteViewUrlPosPrivate NoteViewUrlPosPrivate;
#define _note_view_url_pos_unref0(var) ((var == NULL) ? NULL : (var = (note_view_url_pos_unref (var), NULL)))
typedef struct _NoteViewLinkPosPrivate NoteViewLinkPosPrivate;
#define _note_view_link_pos_unref0(var) ((var == NULL) ? NULL : (var = (note_view_link_pos_unref (var), NULL)))

#define TYPE_UNICODE_INSERT (unicode_insert_get_type ())
#define UNICODE_INSERT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UNICODE_INSERT, UnicodeInsert))
#define UNICODE_INSERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UNICODE_INSERT, UnicodeInsertClass))
#define IS_UNICODE_INSERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UNICODE_INSERT))
#define IS_UNICODE_INSERT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UNICODE_INSERT))
#define UNICODE_INSERT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UNICODE_INSERT, UnicodeInsertClass))

typedef struct _UnicodeInsert UnicodeInsert;
typedef struct _UnicodeInsertClass UnicodeInsertClass;

#define TYPE_NODE_LINK (node_link_get_type ())
#define NODE_LINK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_LINK, NodeLink))
#define NODE_LINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE_LINK, NodeLinkClass))
#define IS_NODE_LINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_LINK))
#define IS_NODE_LINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE_LINK))
#define NODE_LINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE_LINK, NodeLinkClass))

typedef struct _NodeLink NodeLink;
typedef struct _NodeLinkClass NodeLinkClass;
typedef struct _NoteViewParamSpecUrlPos NoteViewParamSpecUrlPos;
typedef struct _NoteViewParamSpecLinkPos NoteViewParamSpecLinkPos;
enum  {
	NOTE_VIEW_NODE_LINK_ADDED_SIGNAL,
	NOTE_VIEW_NODE_LINK_CLICKED_SIGNAL,
	NOTE_VIEW_NODE_LINK_HOVER_SIGNAL,
	NOTE_VIEW_NUM_SIGNALS
};
static guint note_view_signals[NOTE_VIEW_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _CompletionItem {
	GObject parent_instance;
	CompletionItemPrivate * priv;
};

struct _CompletionItemClass {
	GObjectClass parent_class;
};

struct _CompletionItemPrivate {
	gchar* _label;
	gchar* _text;
};

struct _CompletionItemFilter {
	GtkFilter parent_instance;
	CompletionItemFilterPrivate * priv;
};

struct _CompletionItemFilterClass {
	GtkFilterClass parent_class;
};

struct _CompletionItemFilterPrivate {
	gchar* _match_str;
};

struct _CompletionProvider {
	GObject parent_instance;
	CompletionProviderPrivate * priv;
};

struct _CompletionProviderClass {
	GObjectClass parent_class;
};

struct _CompletionProviderPrivate {
	MainWindow* _win;
	gchar* _name;
	GList* _proposals;
	GtkSourceBuffer* _buffer;
};

struct _CompletionProviderPopulateAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	CompletionProvider* self;
	GtkSourceCompletionContext* context;
	GCancellable* cancellable;
	GListModel* result;
	GtkTextIter start_iter;
	GtkTextIter end_iter;
	GListStore* proposals;
	GListStore* _tmp0_;
	GtkTextIter _tmp1_;
	GtkTextIter _tmp2_;
	gboolean _tmp3_;
	GtkTextBuffer* buffer;
	GtkTextBuffer* _tmp4_;
	GtkTextBuffer* _tmp5_;
	GtkTextIter _tmp6_;
	GList* _tmp7_;
	GList* item_collection;
	GList* item_it;
	CompletionItem* _tmp8_;
	CompletionItem* item;
	GListStore* _tmp9_;
	CompletionItem* _tmp10_;
	CompletionItemFilter* filter;
	CompletionItemFilter* _tmp11_;
	CompletionItemFilter* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	GtkFilterListModel* filter_model;
	GListStore* _tmp17_;
	GListModel* _tmp18_;
	CompletionItemFilter* _tmp19_;
	GtkFilter* _tmp20_;
	GtkFilterListModel* _tmp21_;
};

struct _NoteView {
	GtkSourceView parent_instance;
	NoteViewPrivate * priv;
	GtkSourceStyle* _srcstyle;
	GtkSourceBuffer* _buffer;
};

struct _NoteViewClass {
	GtkSourceViewClass parent_class;
};

struct _NoteViewPrivate {
	MainWindow* _win;
	gint _last_lnum;
	gchar* _last_url;
	gint* _last_link;
	GArray* _last_urls;
	GArray* _last_links;
	gint _last_x;
	gint _last_y;
	GRegex* _url_re;
	GRegex* _link_re;
	GtkTooltip* _tooltip;
	gboolean _control;
	GSimpleActionGroup* _group;
};

struct _Block50Data {
	int _ref_count_;
	NoteView* self;
	GtkSourceStyleSchemeManager* style_manager;
};

struct _NoteViewUrlPos {
	GTypeInstance parent_instance;
	volatile int ref_count;
	NoteViewUrlPosPrivate * priv;
	gchar* url;
	gint start;
	gint end;
};

struct _NoteViewUrlPosClass {
	GTypeClass parent_class;
	void (*finalize) (NoteViewUrlPos *self);
};

struct _NoteViewLinkPos {
	GTypeInstance parent_instance;
	volatile int ref_count;
	NoteViewLinkPosPrivate * priv;
	gint id;
	gint start;
	gint end;
};

struct _NoteViewLinkPosClass {
	GTypeClass parent_class;
	void (*finalize) (NoteViewLinkPos *self);
};

struct _NoteViewParamSpecUrlPos {
	GParamSpec parent_instance;
};

struct _NoteViewParamSpecLinkPos {
	GParamSpec parent_instance;
};

static gint CompletionItem_private_offset;
static gpointer completion_item_parent_class = NULL;
static GtkSourceCompletionProposalInterface * completion_item_gtk_source_completion_proposal_parent_iface = NULL;
static gint CompletionItemFilter_private_offset;
static gpointer completion_item_filter_parent_class = NULL;
static gint CompletionProvider_private_offset;
static gpointer completion_provider_parent_class = NULL;
static GtkSourceCompletionProviderInterface * completion_provider_gtk_source_completion_provider_parent_iface = NULL;
static gint NoteView_private_offset;
static gpointer note_view_parent_class = NULL;
static gboolean note_view__path_init;
static gboolean note_view__path_init = FALSE;
VALA_EXTERN GSettings* minder_settings;
static gpointer note_view_url_pos_parent_class = NULL;
static gpointer note_view_link_pos_parent_class = NULL;

VALA_EXTERN GType completion_item_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CompletionItem, g_object_unref)
VALA_EXTERN CompletionItem* completion_item_new (const gchar* label,
                                     const gchar* text);
VALA_EXTERN CompletionItem* completion_item_construct (GType object_type,
                                           const gchar* label,
                                           const gchar* text);
static void completion_item_set_label (CompletionItem* self,
                                const gchar* value);
static void completion_item_set_text (CompletionItem* self,
                               const gchar* value);
VALA_EXTERN const gchar* completion_item_get_label (CompletionItem* self);
VALA_EXTERN const gchar* completion_item_get_text (CompletionItem* self);
static void completion_item_finalize (GObject * obj);
static GType completion_item_get_type_once (void);
static void _vala_completion_item_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_completion_item_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);
VALA_EXTERN GType completion_item_filter_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CompletionItemFilter, g_object_unref)
VALA_EXTERN CompletionItemFilter* completion_item_filter_new (void);
VALA_EXTERN CompletionItemFilter* completion_item_filter_construct (GType object_type);
static GtkFilterMatch completion_item_filter_real_get_strictness (GtkFilter* base);
VALA_EXTERN void completion_item_filter_set_search (CompletionItemFilter* self,
                                        const gchar* match_str);
static gboolean completion_item_filter_real_match (GtkFilter* base,
                                            GObject* item);
static void completion_item_filter_finalize (GObject * obj);
static GType completion_item_filter_get_type_once (void);
VALA_EXTERN GType completion_provider_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CompletionProvider, g_object_unref)
VALA_EXTERN GType main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MainWindow, g_object_unref)
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN CompletionProvider* completion_provider_new (MainWindow* win,
                                             GtkSourceBuffer* buffer,
                                             const gchar* name,
                                             GList* proposals);
VALA_EXTERN CompletionProvider* completion_provider_construct (GType object_type,
                                                   MainWindow* win,
                                                   GtkSourceBuffer* buffer,
                                                   const gchar* name,
                                                   GList* proposals);
static gchar* completion_provider_real_get_title (GtkSourceCompletionProvider* base);
static gint completion_provider_real_get_priority (GtkSourceCompletionProvider* base,
                                            GtkSourceCompletionContext* context);
static gboolean completion_provider_real_is_trigger (GtkSourceCompletionProvider* base,
                                              GtkTextIter* iter,
                                              gunichar ch);
VALA_EXTERN GSettings* main_window_get_settings (MainWindow* self);
static gboolean completion_provider_real_key_activates (GtkSourceCompletionProvider* base,
                                                 GtkSourceCompletionContext* context,
                                                 GtkSourceCompletionProposal* proposal,
                                                 guint keyval,
                                                 GdkModifierType state);
VALA_EXTERN GPtrArray* completion_provider_list_alternatives (CompletionProvider* self,
                                                  GtkSourceCompletionContext* context,
                                                  GtkSourceCompletionProposal* proposal);
static void completion_provider_real_populate_async_data_free (gpointer _data);
static void completion_provider_real_populate_async (GtkSourceCompletionProvider* base,
                                              GtkSourceCompletionContext* context,
                                              GCancellable* cancellable,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
static gboolean completion_provider_real_populate_async_co (CompletionProviderPopulateAsyncData* _data_);
static void completion_provider_real_refilter (GtkSourceCompletionProvider* base,
                                        GtkSourceCompletionContext* context,
                                        GListModel* model);
static void completion_provider_real_activate (GtkSourceCompletionProvider* base,
                                        GtkSourceCompletionContext* context,
                                        GtkSourceCompletionProposal* proposal);
static void completion_provider_real_display (GtkSourceCompletionProvider* base,
                                       GtkSourceCompletionContext* context,
                                       GtkSourceCompletionProposal* proposal,
                                       GtkSourceCompletionCell* cell);
static void completion_provider_finalize (GObject * obj);
static GType completion_provider_get_type_once (void);
VALA_EXTERN GType note_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NoteView, g_object_unref)
static gpointer note_view_url_pos_ref (gpointer instance);
static void note_view_url_pos_unref (gpointer instance);
static GParamSpec* note_view_param_spec_url_pos (const gchar* name,
                                          const gchar* nick,
                                          const gchar* blurb,
                                          GType object_type,
                                          GParamFlags flags) G_GNUC_UNUSED ;
static void note_view_value_set_url_pos (GValue* value,
                                  gpointer v_object) G_GNUC_UNUSED ;
static void note_view_value_take_url_pos (GValue* value,
                                   gpointer v_object) G_GNUC_UNUSED ;
static gpointer note_view_value_get_url_pos (const GValue* value) G_GNUC_UNUSED ;
static GType note_view_url_pos_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NoteViewUrlPos, note_view_url_pos_unref)
static gpointer note_view_link_pos_ref (gpointer instance);
static void note_view_link_pos_unref (gpointer instance);
static GParamSpec* note_view_param_spec_link_pos (const gchar* name,
                                           const gchar* nick,
                                           const gchar* blurb,
                                           GType object_type,
                                           GParamFlags flags) G_GNUC_UNUSED ;
static void note_view_value_set_link_pos (GValue* value,
                                   gpointer v_object) G_GNUC_UNUSED ;
static void note_view_value_take_link_pos (GValue* value,
                                    gpointer v_object) G_GNUC_UNUSED ;
static gpointer note_view_value_get_link_pos (const GValue* value) G_GNUC_UNUSED ;
static GType note_view_link_pos_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NoteViewLinkPos, note_view_link_pos_unref)
VALA_EXTERN NoteView* note_view_new (MainWindow* win);
VALA_EXTERN NoteView* note_view_construct (GType object_type,
                               MainWindow* win);
static Block50Data* block50_data_ref (Block50Data* _data50_);
static void block50_data_unref (void * _userdata_);
static gchar** _vala_array_dup4 (gchar** self,
                          gssize length);
static void _vala_array_add6 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static gchar* note_view_get_default_language (NoteView* self);
static gchar* note_view_get_default_scheme (NoteView* self);
VALA_EXTERN void note_view_set_modified (NoteView* self,
                             gboolean value);
static void __lambda38_ (NoteView* self);
static void ___lambda38__gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                           gpointer self);
VALA_EXTERN GMenu* main_window_make_markdown_menu (MainWindow* self);
static void note_view_on_focus (NoteView* self);
static void _note_view_on_focus_gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                           gpointer self);
static void note_view_on_motion (NoteView* self,
                          gdouble x,
                          gdouble y);
static void _note_view_on_motion_gtk_event_controller_motion_motion (GtkEventControllerMotion* _sender,
                                                              gdouble x,
                                                              gdouble y,
                                                              gpointer self);
static void note_view_on_press (NoteView* self,
                         gint n_press,
                         gdouble x,
                         gdouble y);
static void _note_view_on_press_gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                    gint n_press,
                                                    gdouble x,
                                                    gdouble y,
                                                    gpointer self);
static gboolean note_view_on_keypress (NoteView* self,
                                guint keyval,
                                guint keycode,
                                GdkModifierType state);
static gboolean _note_view_on_keypress_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                      guint keyval,
                                                                      guint keycode,
                                                                      GdkModifierType state,
                                                                      gpointer self);
static void note_view_on_keyrelease (NoteView* self,
                              guint keyval,
                              guint keycode,
                              GdkModifierType state);
static void _note_view_on_keyrelease_gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                     guint keyval,
                                                                     guint keycode,
                                                                     GdkModifierType state,
                                                                     gpointer self);
VALA_EXTERN gchar* utils_url_re (void);
static void _note_view_url_pos_unref0_ (gpointer var);
static void _vala_NoteViewUrlPos_free_function_content_of (gpointer data);
static void _note_view_link_pos_unref0_ (gpointer var);
static void _vala_NoteViewLinkPos_free_function_content_of (gpointer data);
static void __lambda129_ (Block50Data* _data50_);
static void ___lambda129__g_settings_changed (GSettings* _sender,
                                       const gchar* key,
                                       gpointer self);
static void note_view_clear (NoteView* self);
static gchar* note_view_current_line (NoteView* self,
                               GtkTextIter* cursor);
static void note_view_parse_line_for_urls (NoteView* self,
                                    const gchar* line);
static NoteViewUrlPos* note_view_url_pos_new (const gchar* u,
                                       gint s,
                                       gint e);
static NoteViewUrlPos* note_view_url_pos_construct (GType object_type,
                                             const gchar* u,
                                             gint s,
                                             gint e);
static void note_view_parse_line_for_node_links (NoteView* self,
                                          const gchar* line);
static NoteViewLinkPos* note_view_link_pos_new (gint i,
                                         gint s,
                                         gint e);
static NoteViewLinkPos* note_view_link_pos_construct (GType object_type,
                                               gint i,
                                               gint s,
                                               gint e);
static gboolean note_view_cursor_in_url (NoteView* self,
                                  GtkTextIter* cursor);
static gboolean note_view_cursor_in_node_link (NoteView* self,
                                        GtkTextIter* cursor);
static gint* _int_dup (gint* self);
static void note_view_enable_url_checking (NoteView* self,
                                    gint x,
                                    gint y);
static void note_view_disable_url_checking (NoteView* self);
VALA_EXTERN gpointer unicode_insert_ref (gpointer instance);
VALA_EXTERN void unicode_insert_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_unicode_insert (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_unicode_insert (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_unicode_insert (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_unicode_insert (const GValue* value);
VALA_EXTERN GType unicode_insert_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UnicodeInsert, unicode_insert_unref)
VALA_EXTERN void note_view_add_unicode_completion (NoteView* self,
                                       MainWindow* win,
                                       UnicodeInsert* unicoder);
VALA_EXTERN GList* unicode_insert_create_proposals (UnicodeInsert* self);
VALA_EXTERN void utils_open_url (const gchar* url);
static void note_view_real_paste_clipboard (GtkTextView* base);
VALA_EXTERN void minder_clipboard_paste_into_note (NoteView* note);
VALA_EXTERN void note_view_paste_text (NoteView* self,
                           const gchar* str);
VALA_EXTERN void note_view_paste_markdown (NoteView* self,
                               const gchar* pretext,
                               const gchar* midtext,
                               const gchar* posttext);
VALA_EXTERN gboolean utils_is_url (const gchar* str);
VALA_EXTERN gpointer node_link_ref (gpointer instance);
VALA_EXTERN void node_link_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_node_link (const gchar* name,
                                  const gchar* nick,
                                  const gchar* blurb,
                                  GType object_type,
                                  GParamFlags flags);
VALA_EXTERN void value_set_node_link (GValue* value,
                          gpointer v_object);
VALA_EXTERN void value_take_node_link (GValue* value,
                           gpointer v_object);
VALA_EXTERN gpointer value_get_node_link (const GValue* value);
VALA_EXTERN GType node_link_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeLink, node_link_unref)
VALA_EXTERN void note_view_paste_node_link (NoteView* self,
                                NodeLink* link);
VALA_EXTERN void note_view_show_tooltip (NoteView* self,
                             const gchar* tooltip);
VALA_EXTERN gchar* note_view_get_text (NoteView* self);
VALA_EXTERN void note_view_set_text (NoteView* self,
                         const gchar* value);
VALA_EXTERN gboolean note_view_get_modified (NoteView* self);
static void g_cclosure_user_marshal_INT__NODE_LINK_POINTER (GClosure * closure,
                                                     GValue * return_value,
                                                     guint n_param_values,
                                                     const GValue * param_values,
                                                     gpointer invocation_hint,
                                                     gpointer marshal_data);
static void note_view_url_pos_finalize (NoteViewUrlPos * obj);
static GType note_view_url_pos_get_type_once (void);
static void note_view_link_pos_finalize (NoteViewLinkPos * obj);
static GType note_view_link_pos_get_type_once (void);
static void note_view_finalize (GObject * obj);
static GType note_view_get_type_once (void);
static void _vala_note_view_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_note_view_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
completion_item_get_instance_private (CompletionItem* self)
{
	return G_STRUCT_MEMBER_P (self, CompletionItem_private_offset);
}

CompletionItem*
completion_item_construct (GType object_type,
                           const gchar* label,
                           const gchar* text)
{
	CompletionItem * self = NULL;
	g_return_val_if_fail (label != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	self = (CompletionItem*) g_object_new (object_type, NULL);
	completion_item_set_label (self, label);
	completion_item_set_text (self, text);
	return self;
}

CompletionItem*
completion_item_new (const gchar* label,
                     const gchar* text)
{
	return completion_item_construct (TYPE_COMPLETION_ITEM, label, text);
}

const gchar*
completion_item_get_label (CompletionItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_label;
	result = _tmp0_;
	return result;
}

static void
completion_item_set_label (CompletionItem* self,
                           const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = completion_item_get_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_label);
		self->priv->_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, completion_item_properties[COMPLETION_ITEM_LABEL_PROPERTY]);
	}
}

const gchar*
completion_item_get_text (CompletionItem* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_text;
	result = _tmp0_;
	return result;
}

static void
completion_item_set_text (CompletionItem* self,
                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = completion_item_get_text (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_text);
		self->priv->_text = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, completion_item_properties[COMPLETION_ITEM_TEXT_PROPERTY]);
	}
}

static void
completion_item_class_init (CompletionItemClass * klass,
                            gpointer klass_data)
{
	completion_item_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CompletionItem_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_completion_item_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_completion_item_set_property;
	G_OBJECT_CLASS (klass)->finalize = completion_item_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), COMPLETION_ITEM_LABEL_PROPERTY, completion_item_properties[COMPLETION_ITEM_LABEL_PROPERTY] = g_param_spec_string ("label", "label", "label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), COMPLETION_ITEM_TEXT_PROPERTY, completion_item_properties[COMPLETION_ITEM_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
completion_item_gtk_source_completion_proposal_interface_init (GtkSourceCompletionProposalInterface * iface,
                                                               gpointer iface_data)
{
	completion_item_gtk_source_completion_proposal_parent_iface = g_type_interface_peek_parent (iface);
}

static void
completion_item_instance_init (CompletionItem * self,
                               gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	self->priv = completion_item_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_label = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_text = _tmp1_;
}

static void
completion_item_finalize (GObject * obj)
{
	CompletionItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_COMPLETION_ITEM, CompletionItem);
	_g_free0 (self->priv->_label);
	_g_free0 (self->priv->_text);
	G_OBJECT_CLASS (completion_item_parent_class)->finalize (obj);
}

static GType
completion_item_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CompletionItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) completion_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CompletionItem), 0, (GInstanceInitFunc) completion_item_instance_init, NULL };
	static const GInterfaceInfo gtk_source_completion_proposal_info = { (GInterfaceInitFunc) completion_item_gtk_source_completion_proposal_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType completion_item_type_id;
	completion_item_type_id = g_type_register_static (G_TYPE_OBJECT, "CompletionItem", &g_define_type_info, 0);
	g_type_add_interface_static (completion_item_type_id, gtk_source_completion_proposal_get_type (), &gtk_source_completion_proposal_info);
	CompletionItem_private_offset = g_type_add_instance_private (completion_item_type_id, sizeof (CompletionItemPrivate));
	return completion_item_type_id;
}

GType
completion_item_get_type (void)
{
	static volatile gsize completion_item_type_id__once = 0;
	if (g_once_init_enter (&completion_item_type_id__once)) {
		GType completion_item_type_id;
		completion_item_type_id = completion_item_get_type_once ();
		g_once_init_leave (&completion_item_type_id__once, completion_item_type_id);
	}
	return completion_item_type_id__once;
}

static void
_vala_completion_item_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	CompletionItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_COMPLETION_ITEM, CompletionItem);
	switch (property_id) {
		case COMPLETION_ITEM_LABEL_PROPERTY:
		g_value_set_string (value, completion_item_get_label (self));
		break;
		case COMPLETION_ITEM_TEXT_PROPERTY:
		g_value_set_string (value, completion_item_get_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_completion_item_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	CompletionItem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_COMPLETION_ITEM, CompletionItem);
	switch (property_id) {
		case COMPLETION_ITEM_LABEL_PROPERTY:
		completion_item_set_label (self, g_value_get_string (value));
		break;
		case COMPLETION_ITEM_TEXT_PROPERTY:
		completion_item_set_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
completion_item_filter_get_instance_private (CompletionItemFilter* self)
{
	return G_STRUCT_MEMBER_P (self, CompletionItemFilter_private_offset);
}

CompletionItemFilter*
completion_item_filter_construct (GType object_type)
{
	CompletionItemFilter * self = NULL;
	self = (CompletionItemFilter*) g_object_new (object_type, NULL);
	return self;
}

CompletionItemFilter*
completion_item_filter_new (void)
{
	return completion_item_filter_construct (TYPE_COMPLETION_ITEM_FILTER);
}

static GtkFilterMatch
completion_item_filter_real_get_strictness (GtkFilter* base)
{
	CompletionItemFilter * self;
	GtkFilterMatch result;
	self = (CompletionItemFilter*) base;
	result = GTK_FILTER_MATCH_SOME;
	return result;
}

void
completion_item_filter_set_search (CompletionItemFilter* self,
                                   const gchar* match_str)
{
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (match_str != NULL);
	_tmp0_ = self->priv->_match_str;
	if (g_strcmp0 (_tmp0_, match_str) != 0) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup (match_str);
		_g_free0 (self->priv->_match_str);
		self->priv->_match_str = _tmp1_;
		gtk_filter_changed ((GtkFilter*) self, GTK_FILTER_CHANGE_DIFFERENT);
	}
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static gboolean
completion_item_filter_real_match (GtkFilter* base,
                                   GObject* item)
{
	CompletionItemFilter * self;
	gboolean result;
	self = (CompletionItemFilter*) base;
	if (item != NULL) {
		CompletionItem* comp_item = NULL;
		CompletionItem* _tmp0_;
		CompletionItem* _tmp1_;
		_tmp0_ = _g_object_ref0 (IS_COMPLETION_ITEM (item) ? ((CompletionItem*) item) : NULL);
		comp_item = _tmp0_;
		_tmp1_ = comp_item;
		if (_tmp1_ != NULL) {
			CompletionItem* _tmp2_;
			const gchar* _tmp3_;
			const gchar* _tmp4_;
			const gchar* _tmp5_;
			_tmp2_ = comp_item;
			_tmp3_ = completion_item_get_label (_tmp2_);
			_tmp4_ = _tmp3_;
			_tmp5_ = self->priv->_match_str;
			result = g_str_has_prefix (_tmp4_, _tmp5_);
			_g_object_unref0 (comp_item);
			return result;
		}
		_g_object_unref0 (comp_item);
	}
	result = FALSE;
	return result;
}

static void
completion_item_filter_class_init (CompletionItemFilterClass * klass,
                                   gpointer klass_data)
{
	completion_item_filter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CompletionItemFilter_private_offset);
	((GtkFilterClass *) klass)->get_strictness = (GtkFilterMatch (*) (GtkFilter*)) completion_item_filter_real_get_strictness;
	((GtkFilterClass *) klass)->match = (gboolean (*) (GtkFilter*, GObject*)) completion_item_filter_real_match;
	G_OBJECT_CLASS (klass)->finalize = completion_item_filter_finalize;
}

static void
completion_item_filter_instance_init (CompletionItemFilter * self,
                                      gpointer klass)
{
	gchar* _tmp0_;
	self->priv = completion_item_filter_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_match_str = _tmp0_;
}

static void
completion_item_filter_finalize (GObject * obj)
{
	CompletionItemFilter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_COMPLETION_ITEM_FILTER, CompletionItemFilter);
	_g_free0 (self->priv->_match_str);
	G_OBJECT_CLASS (completion_item_filter_parent_class)->finalize (obj);
}

static GType
completion_item_filter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CompletionItemFilterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) completion_item_filter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CompletionItemFilter), 0, (GInstanceInitFunc) completion_item_filter_instance_init, NULL };
	GType completion_item_filter_type_id;
	completion_item_filter_type_id = g_type_register_static (gtk_filter_get_type (), "CompletionItemFilter", &g_define_type_info, 0);
	CompletionItemFilter_private_offset = g_type_add_instance_private (completion_item_filter_type_id, sizeof (CompletionItemFilterPrivate));
	return completion_item_filter_type_id;
}

GType
completion_item_filter_get_type (void)
{
	static volatile gsize completion_item_filter_type_id__once = 0;
	if (g_once_init_enter (&completion_item_filter_type_id__once)) {
		GType completion_item_filter_type_id;
		completion_item_filter_type_id = completion_item_filter_get_type_once ();
		g_once_init_leave (&completion_item_filter_type_id__once, completion_item_filter_type_id);
	}
	return completion_item_filter_type_id__once;
}

static inline gpointer
completion_provider_get_instance_private (CompletionProvider* self)
{
	return G_STRUCT_MEMBER_P (self, CompletionProvider_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

CompletionProvider*
completion_provider_construct (GType object_type,
                               MainWindow* win,
                               GtkSourceBuffer* buffer,
                               const gchar* name,
                               GList* proposals)
{
	CompletionProvider * self = NULL;
	MainWindow* _tmp0_;
	GtkSourceBuffer* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (win != NULL, NULL);
	g_return_val_if_fail (buffer != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	self = (CompletionProvider*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (win);
	_g_object_unref0 (self->priv->_win);
	self->priv->_win = _tmp0_;
	_tmp1_ = _g_object_ref0 (buffer);
	_g_object_unref0 (self->priv->_buffer);
	self->priv->_buffer = _tmp1_;
	_tmp2_ = g_strdup (name);
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp2_;
	(self->priv->_proposals == NULL) ? NULL : (self->priv->_proposals = (_g_list_free__g_object_unref0_ (self->priv->_proposals), NULL));
	self->priv->_proposals = NULL;
	{
		GList* item_collection = NULL;
		GList* item_it = NULL;
		item_collection = proposals;
		for (item_it = item_collection; item_it != NULL; item_it = item_it->next) {
			CompletionItem* _tmp3_;
			CompletionItem* item = NULL;
			_tmp3_ = _g_object_ref0 ((CompletionItem*) item_it->data);
			item = _tmp3_;
			{
				CompletionItem* _tmp4_;
				CompletionItem* _tmp5_;
				_tmp4_ = item;
				_tmp5_ = _g_object_ref0 (_tmp4_);
				self->priv->_proposals = g_list_append (self->priv->_proposals, _tmp5_);
				_g_object_unref0 (item);
			}
		}
	}
	return self;
}

CompletionProvider*
completion_provider_new (MainWindow* win,
                         GtkSourceBuffer* buffer,
                         const gchar* name,
                         GList* proposals)
{
	return completion_provider_construct (TYPE_COMPLETION_PROVIDER, win, buffer, name, proposals);
}

static gchar*
completion_provider_real_get_title (GtkSourceCompletionProvider* base)
{
	CompletionProvider * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (CompletionProvider*) base;
	_tmp0_ = self->priv->_name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gint
completion_provider_real_get_priority (GtkSourceCompletionProvider* base,
                                       GtkSourceCompletionContext* context)
{
	CompletionProvider * self;
	gint result;
	self = (CompletionProvider*) base;
	g_return_val_if_fail (context != NULL, -1);
	result = 1;
	return result;
}

static gboolean
completion_provider_real_is_trigger (GtkSourceCompletionProvider* base,
                                     GtkTextIter* iter,
                                     gunichar ch)
{
	CompletionProvider * self;
	gboolean _tmp0_ = FALSE;
	MainWindow* _tmp1_;
	GSettings* _tmp2_;
	GSettings* _tmp3_;
	gboolean result;
	self = (CompletionProvider*) base;
	g_return_val_if_fail (iter != NULL, FALSE);
	_tmp1_ = self->priv->_win;
	_tmp2_ = main_window_get_settings (_tmp1_);
	_tmp3_ = _tmp2_;
	if (g_settings_get_boolean (_tmp3_, "enable-unicode-input")) {
		_tmp0_ = ch == ((gunichar) '\\');
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gboolean
completion_provider_real_key_activates (GtkSourceCompletionProvider* base,
                                        GtkSourceCompletionContext* context,
                                        GtkSourceCompletionProposal* proposal,
                                        guint keyval,
                                        GdkModifierType state)
{
	CompletionProvider * self;
	gboolean result;
	self = (CompletionProvider*) base;
	g_return_val_if_fail (context != NULL, FALSE);
	g_return_val_if_fail (proposal != NULL, FALSE);
	result = keyval == GDK_KEY_Return;
	return result;
}

GPtrArray*
completion_provider_list_alternatives (CompletionProvider* self,
                                       GtkSourceCompletionContext* context,
                                       GtkSourceCompletionProposal* proposal)
{
	GPtrArray* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (context != NULL, NULL);
	g_return_val_if_fail (proposal != NULL, NULL);
	result = NULL;
	return result;
}

static void
completion_provider_real_populate_async_data_free (gpointer _data)
{
	CompletionProviderPopulateAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->context);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (CompletionProviderPopulateAsyncData, _data_);
}

static void
completion_provider_real_populate_async (GtkSourceCompletionProvider* base,
                                         GtkSourceCompletionContext* context,
                                         GCancellable* cancellable,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_)
{
	CompletionProvider * self;
	CompletionProviderPopulateAsyncData* _data_;
	CompletionProvider* _tmp0_;
	GtkSourceCompletionContext* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (context != NULL);
	self = (CompletionProvider*) base;
	_data_ = g_slice_new0 (CompletionProviderPopulateAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, completion_provider_real_populate_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (context);
	_g_object_unref0 (_data_->context);
	_data_->context = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	completion_provider_real_populate_async_co (_data_);
}

static GListModel*
completion_provider_populate_finish (GtkSourceCompletionProvider* base,
                                     GAsyncResult* _res_,
                                     GError** error)
{
	GListModel* result;
	CompletionProviderPopulateAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static gboolean
completion_provider_real_populate_async_co (CompletionProviderPopulateAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_list_store_new (TYPE_COMPLETION_ITEM);
	_data_->proposals = _data_->_tmp0_;
	memset (&_data_->_tmp1_, 0, sizeof (GtkTextIter));
	memset (&_data_->_tmp2_, 0, sizeof (GtkTextIter));
	_data_->_tmp3_ = gtk_source_completion_context_get_bounds (_data_->context, &_data_->_tmp1_, &_data_->_tmp2_);
	_data_->start_iter = _data_->_tmp1_;
	_data_->end_iter = _data_->_tmp2_;
	if (_data_->_tmp3_) {
		_data_->_tmp4_ = gtk_text_iter_get_buffer (&_data_->start_iter);
		_data_->_tmp5_ = _g_object_ref0 (_data_->_tmp4_);
		_data_->buffer = _data_->_tmp5_;
		gtk_text_iter_backward_char (&_data_->start_iter);
		_data_->_tmp6_ = _data_->start_iter;
		if (gtk_source_completion_provider_is_trigger ((GtkSourceCompletionProvider*) _data_->self, &_data_->_tmp6_, gtk_text_iter_get_char (&_data_->start_iter))) {
			_data_->_tmp7_ = _data_->self->priv->_proposals;
			{
				_data_->item_collection = _data_->_tmp7_;
				for (_data_->item_it = _data_->item_collection; _data_->item_it != NULL; _data_->item_it = _data_->item_it->next) {
					_data_->_tmp8_ = _g_object_ref0 ((CompletionItem*) _data_->item_it->data);
					_data_->item = _data_->_tmp8_;
					{
						_data_->_tmp9_ = _data_->proposals;
						_data_->_tmp10_ = _data_->item;
						g_list_store_append (_data_->_tmp9_, (GObject*) _data_->_tmp10_);
						_g_object_unref0 (_data_->item);
					}
				}
			}
			_data_->_tmp11_ = completion_item_filter_new ();
			_data_->filter = _data_->_tmp11_;
			_data_->_tmp12_ = _data_->filter;
			_data_->_tmp13_ = gtk_source_completion_context_get_word (_data_->context);
			_data_->_tmp14_ = _data_->_tmp13_;
			_data_->_tmp15_ = g_strconcat ("\\", _data_->_tmp14_, NULL);
			_data_->_tmp16_ = _data_->_tmp15_;
			completion_item_filter_set_search (_data_->_tmp12_, _data_->_tmp16_);
			_g_free0 (_data_->_tmp16_);
			_g_free0 (_data_->_tmp14_);
			_data_->_tmp17_ = _data_->proposals;
			_data_->_tmp18_ = _g_object_ref0 ((GListModel*) _data_->_tmp17_);
			_data_->_tmp19_ = _data_->filter;
			_data_->_tmp20_ = _g_object_ref0 ((GtkFilter*) _data_->_tmp19_);
			_data_->_tmp21_ = gtk_filter_list_model_new (_data_->_tmp18_, _data_->_tmp20_);
			_data_->filter_model = _data_->_tmp21_;
			_data_->result = (GListModel*) _data_->filter_model;
			_g_object_unref0 (_data_->filter);
			_g_object_unref0 (_data_->buffer);
			_g_object_unref0 (_data_->proposals);
			g_task_return_pointer (_data_->_async_result, _data_, NULL);
			if (_data_->_state_ != 0) {
				while (!g_task_get_completed (_data_->_async_result)) {
					g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
				}
			}
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->buffer);
	}
	_data_->result = (GListModel*) _data_->proposals;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
completion_provider_real_refilter (GtkSourceCompletionProvider* base,
                                   GtkSourceCompletionContext* context,
                                   GListModel* model)
{
	CompletionProvider * self;
	GtkFilterListModel* list = NULL;
	GtkFilterListModel* _tmp0_;
	GtkFilterListModel* _tmp1_;
	self = (CompletionProvider*) base;
	g_return_if_fail (context != NULL);
	g_return_if_fail (model != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (model, gtk_filter_list_model_get_type ()) ? ((GtkFilterListModel*) model) : NULL);
	list = _tmp0_;
	_tmp1_ = list;
	if (_tmp1_ != NULL) {
		CompletionItemFilter* filter = NULL;
		GtkFilterListModel* _tmp2_;
		GtkFilter* _tmp3_;
		GtkFilter* _tmp4_;
		CompletionItemFilter* _tmp5_;
		CompletionItemFilter* _tmp6_;
		_tmp2_ = list;
		_tmp3_ = gtk_filter_list_model_get_filter (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = _g_object_ref0 (IS_COMPLETION_ITEM_FILTER (_tmp4_) ? ((CompletionItemFilter*) _tmp4_) : NULL);
		filter = _tmp5_;
		_tmp6_ = filter;
		if (_tmp6_ != NULL) {
			CompletionItemFilter* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			_tmp7_ = filter;
			_tmp8_ = gtk_source_completion_context_get_word (context);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_strconcat ("\\", _tmp9_, NULL);
			_tmp11_ = _tmp10_;
			completion_item_filter_set_search (_tmp7_, _tmp11_);
			_g_free0 (_tmp11_);
			_g_free0 (_tmp9_);
		}
		_g_object_unref0 (filter);
	}
	_g_object_unref0 (list);
}

static void
completion_provider_real_activate (GtkSourceCompletionProvider* base,
                                   GtkSourceCompletionContext* context,
                                   GtkSourceCompletionProposal* proposal)
{
	CompletionProvider * self;
	CompletionItem* item = NULL;
	CompletionItem* _tmp0_;
	CompletionItem* _tmp1_;
	self = (CompletionProvider*) base;
	g_return_if_fail (context != NULL);
	g_return_if_fail (proposal != NULL);
	_tmp0_ = _g_object_ref0 (IS_COMPLETION_ITEM (proposal) ? ((CompletionItem*) proposal) : NULL);
	item = _tmp0_;
	_tmp1_ = item;
	if (_tmp1_ != NULL) {
		GtkTextIter start_iter = {0};
		GtkTextIter end_iter = {0};
		GtkTextIter _tmp2_ = {0};
		GtkTextIter _tmp3_ = {0};
		GtkTextBuffer* buffer = NULL;
		GtkTextBuffer* _tmp4_;
		GtkTextBuffer* _tmp5_;
		GtkTextBuffer* _tmp6_;
		GtkTextBuffer* _tmp7_;
		GtkTextBuffer* _tmp8_;
		CompletionItem* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		CompletionItem* _tmp12_;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		GtkTextBuffer* _tmp17_;
		gtk_source_completion_context_get_bounds (context, &_tmp2_, &_tmp3_);
		start_iter = _tmp2_;
		end_iter = _tmp3_;
		gtk_text_iter_backward_char (&start_iter);
		_tmp4_ = gtk_text_iter_get_buffer (&start_iter);
		_tmp5_ = _g_object_ref0 (_tmp4_);
		buffer = _tmp5_;
		_tmp6_ = buffer;
		gtk_text_buffer_begin_user_action (_tmp6_);
		_tmp7_ = buffer;
		gtk_text_buffer_delete (_tmp7_, &start_iter, &end_iter);
		_tmp8_ = buffer;
		_tmp9_ = item;
		_tmp10_ = completion_item_get_text (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = item;
		_tmp13_ = completion_item_get_text (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = strlen (_tmp14_);
		_tmp16_ = _tmp15_;
		g_signal_emit_by_name (_tmp8_, "insert-text", &start_iter, _tmp11_, _tmp16_);
		_tmp17_ = buffer;
		gtk_text_buffer_end_user_action (_tmp17_);
		_g_object_unref0 (buffer);
	}
	_g_object_unref0 (item);
}

static void
completion_provider_real_display (GtkSourceCompletionProvider* base,
                                  GtkSourceCompletionContext* context,
                                  GtkSourceCompletionProposal* proposal,
                                  GtkSourceCompletionCell* cell)
{
	CompletionProvider * self;
	CompletionItem* item = NULL;
	CompletionItem* _tmp0_;
	CompletionItem* _tmp1_;
	self = (CompletionProvider*) base;
	g_return_if_fail (context != NULL);
	g_return_if_fail (proposal != NULL);
	g_return_if_fail (cell != NULL);
	_tmp0_ = _g_object_ref0 (IS_COMPLETION_ITEM (proposal) ? ((CompletionItem*) proposal) : NULL);
	item = _tmp0_;
	_tmp1_ = item;
	if (_tmp1_ != NULL) {
		switch (gtk_source_completion_cell_get_column (cell)) {
			case GTK_SOURCE_COMPLETION_COLUMN_TYPED_TEXT:
			{
				CompletionItem* _tmp2_;
				const gchar* _tmp3_;
				const gchar* _tmp4_;
				_tmp2_ = item;
				_tmp3_ = completion_item_get_text (_tmp2_);
				_tmp4_ = _tmp3_;
				g_object_set (cell, "text", _tmp4_, NULL);
				break;
			}
			case GTK_SOURCE_COMPLETION_COLUMN_COMMENT:
			{
				CompletionItem* _tmp5_;
				const gchar* _tmp6_;
				const gchar* _tmp7_;
				_tmp5_ = item;
				_tmp6_ = completion_item_get_label (_tmp5_);
				_tmp7_ = _tmp6_;
				g_object_set (cell, "text", _tmp7_, NULL);
				break;
			}
			default:
			{
				break;
			}
		}
	}
	_g_object_unref0 (item);
}

static void
completion_provider_class_init (CompletionProviderClass * klass,
                                gpointer klass_data)
{
	completion_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CompletionProvider_private_offset);
	G_OBJECT_CLASS (klass)->finalize = completion_provider_finalize;
}

static void
completion_provider_gtk_source_completion_provider_interface_init (GtkSourceCompletionProviderInterface * iface,
                                                                   gpointer iface_data)
{
	completion_provider_gtk_source_completion_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_title = (gchar* (*) (GtkSourceCompletionProvider*)) completion_provider_real_get_title;
	iface->get_priority = (gint (*) (GtkSourceCompletionProvider*, GtkSourceCompletionContext*)) completion_provider_real_get_priority;
	iface->is_trigger = (gboolean (*) (GtkSourceCompletionProvider*, GtkTextIter*, gunichar)) completion_provider_real_is_trigger;
	iface->key_activates = (gboolean (*) (GtkSourceCompletionProvider*, GtkSourceCompletionContext*, GtkSourceCompletionProposal*, guint, GdkModifierType)) completion_provider_real_key_activates;
	iface->populate_async = (void (*) (GtkSourceCompletionProvider*, GtkSourceCompletionContext*, GCancellable*, GAsyncReadyCallback, gpointer)) completion_provider_real_populate_async;
	iface->populate_finish = (GListModel* (*) (GtkSourceCompletionProvider*, GAsyncResult*, GError**)) completion_provider_populate_finish;
	iface->refilter = (void (*) (GtkSourceCompletionProvider*, GtkSourceCompletionContext*, GListModel*)) completion_provider_real_refilter;
	iface->activate = (void (*) (GtkSourceCompletionProvider*, GtkSourceCompletionContext*, GtkSourceCompletionProposal*)) completion_provider_real_activate;
	iface->display = (void (*) (GtkSourceCompletionProvider*, GtkSourceCompletionContext*, GtkSourceCompletionProposal*, GtkSourceCompletionCell*)) completion_provider_real_display;
}

static void
completion_provider_instance_init (CompletionProvider * self,
                                   gpointer klass)
{
	self->priv = completion_provider_get_instance_private (self);
}

static void
completion_provider_finalize (GObject * obj)
{
	CompletionProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_COMPLETION_PROVIDER, CompletionProvider);
	_g_object_unref0 (self->priv->_win);
	_g_free0 (self->priv->_name);
	(self->priv->_proposals == NULL) ? NULL : (self->priv->_proposals = (_g_list_free__g_object_unref0_ (self->priv->_proposals), NULL));
	_g_object_unref0 (self->priv->_buffer);
	G_OBJECT_CLASS (completion_provider_parent_class)->finalize (obj);
}

static GType
completion_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CompletionProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) completion_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CompletionProvider), 0, (GInstanceInitFunc) completion_provider_instance_init, NULL };
	static const GInterfaceInfo gtk_source_completion_provider_info = { (GInterfaceInitFunc) completion_provider_gtk_source_completion_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType completion_provider_type_id;
	completion_provider_type_id = g_type_register_static (G_TYPE_OBJECT, "CompletionProvider", &g_define_type_info, 0);
	g_type_add_interface_static (completion_provider_type_id, gtk_source_completion_provider_get_type (), &gtk_source_completion_provider_info);
	CompletionProvider_private_offset = g_type_add_instance_private (completion_provider_type_id, sizeof (CompletionProviderPrivate));
	return completion_provider_type_id;
}

GType
completion_provider_get_type (void)
{
	static volatile gsize completion_provider_type_id__once = 0;
	if (g_once_init_enter (&completion_provider_type_id__once)) {
		GType completion_provider_type_id;
		completion_provider_type_id = completion_provider_get_type_once ();
		g_once_init_leave (&completion_provider_type_id__once, completion_provider_type_id);
	}
	return completion_provider_type_id__once;
}

static inline gpointer
note_view_get_instance_private (NoteView* self)
{
	return G_STRUCT_MEMBER_P (self, NoteView_private_offset);
}

static Block50Data*
block50_data_ref (Block50Data* _data50_)
{
	g_atomic_int_inc (&_data50_->_ref_count_);
	return _data50_;
}

static void
block50_data_unref (void * _userdata_)
{
	Block50Data* _data50_;
	_data50_ = (Block50Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data50_->_ref_count_)) {
		NoteView* self;
		self = _data50_->self;
		_g_object_unref0 (_data50_->style_manager);
		_g_object_unref0 (self);
		g_slice_free (Block50Data, _data50_);
	}
}

static gchar**
_vala_array_dup4 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
_vala_array_add6 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda38_ (NoteView* self)
{
	note_view_set_modified (self, TRUE);
}

static void
___lambda38__gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                      gpointer self)
{
	__lambda38_ ((NoteView*) self);
}

static void
_note_view_on_focus_gtk_event_controller_focus_enter (GtkEventControllerFocus* _sender,
                                                      gpointer self)
{
	note_view_on_focus ((NoteView*) self);
}

static void
_note_view_on_motion_gtk_event_controller_motion_motion (GtkEventControllerMotion* _sender,
                                                         gdouble x,
                                                         gdouble y,
                                                         gpointer self)
{
	note_view_on_motion ((NoteView*) self, x, y);
}

static void
_note_view_on_press_gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                               gint n_press,
                                               gdouble x,
                                               gdouble y,
                                               gpointer self)
{
	note_view_on_press ((NoteView*) self, n_press, x, y);
}

static gboolean
_note_view_on_keypress_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self)
{
	gboolean result;
	result = note_view_on_keypress ((NoteView*) self, keyval, keycode, state);
	return result;
}

static void
_note_view_on_keyrelease_gtk_event_controller_key_key_released (GtkEventControllerKey* _sender,
                                                                guint keyval,
                                                                guint keycode,
                                                                GdkModifierType state,
                                                                gpointer self)
{
	note_view_on_keyrelease ((NoteView*) self, keyval, keycode, state);
}

static void
_note_view_url_pos_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (note_view_url_pos_unref (var), NULL));
}

static void
_vala_NoteViewUrlPos_free_function_content_of (gpointer data)
{
	NoteViewUrlPos* self;
	self = *((NoteViewUrlPos**) data);
	_note_view_url_pos_unref0_ (self);
}

static void
_note_view_link_pos_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (note_view_link_pos_unref (var), NULL));
}

static void
_vala_NoteViewLinkPos_free_function_content_of (gpointer data)
{
	NoteViewLinkPos* self;
	self = *((NoteViewLinkPos**) data);
	_note_view_link_pos_unref0_ (self);
}

static void
__lambda129_ (Block50Data* _data50_)
{
	NoteView* self;
	GtkSourceStyleScheme* s = NULL;
	GtkSourceStyleSchemeManager* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkSourceStyleScheme* _tmp3_;
	GtkSourceStyleScheme* _tmp4_;
	GtkSourceStyleScheme* _tmp5_;
	GtkSourceBuffer* _tmp6_;
	self = _data50_->self;
	_tmp0_ = _data50_->style_manager;
	_tmp1_ = note_view_get_default_scheme (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_source_style_scheme_manager_get_scheme (_tmp0_, _tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp2_);
	s = _tmp5_;
	_tmp6_ = self->_buffer;
	gtk_source_buffer_set_style_scheme (_tmp6_, s);
	_g_object_unref0 (s);
}

static void
___lambda129__g_settings_changed (GSettings* _sender,
                                  const gchar* key,
                                  gpointer self)
{
	__lambda129_ (self);
}

NoteView*
note_view_construct (GType object_type,
                     MainWindow* win)
{
	NoteView * self = NULL;
	Block50Data* _data50_;
	MainWindow* _tmp0_;
	GtkSourceCompletion* _tmp1_;
	GtkSourceCompletion* _tmp2_;
	gchar* sourceview_path = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gchar* lang_path = NULL;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* style_path = NULL;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar** lang_paths = NULL;
	gchar** _tmp15_;
	gint lang_paths_length1;
	gint _lang_paths_size_;
	GtkStyleContext* _tmp16_;
	GtkSourceLanguageManager* manager = NULL;
	GtkSourceLanguageManager* _tmp17_;
	GtkSourceLanguageManager* _tmp18_;
	GtkSourceStyleSchemeManager* _tmp27_;
	GtkSourceStyleSchemeManager* _tmp28_;
	GtkSourceLanguage* language = NULL;
	GtkSourceLanguageManager* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	GtkSourceLanguage* _tmp34_;
	GtkSourceLanguage* _tmp35_;
	GtkSourceLanguage* _tmp36_;
	GtkSourceStyleScheme* style = NULL;
	GtkSourceStyleSchemeManager* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	GtkSourceStyleScheme* _tmp40_;
	GtkSourceStyleScheme* _tmp41_;
	GtkSourceStyleScheme* _tmp42_;
	GtkSourceLanguage* _tmp43_;
	GtkSourceBuffer* _tmp44_ = NULL;
	GtkSourceBuffer* _tmp45_;
	GtkSourceStyleScheme* _tmp46_;
	GtkSourceBuffer* _tmp47_;
	GtkSourceBuffer* _tmp48_;
	GSimpleActionGroup* _tmp49_;
	GSimpleActionGroup* _tmp50_;
	GMenu* md_menu = NULL;
	GMenu* _tmp51_;
	GMenu* extra = NULL;
	GMenu* _tmp52_;
	GMenu* _tmp53_;
	GMenu* _tmp54_;
	GMenu* _tmp55_;
	GtkEventControllerFocus* focus = NULL;
	GtkEventControllerFocus* _tmp56_;
	GtkEventControllerFocus* _tmp57_;
	GtkEventController* _tmp58_;
	GtkEventControllerFocus* _tmp59_;
	GtkEventControllerMotion* motion = NULL;
	GtkEventControllerMotion* _tmp60_;
	GtkEventControllerMotion* _tmp61_;
	GtkEventController* _tmp62_;
	GtkEventControllerMotion* _tmp63_;
	GtkGestureClick* click = NULL;
	GtkGestureClick* _tmp64_;
	GtkGestureClick* _tmp65_;
	GtkEventController* _tmp66_;
	GtkGestureClick* _tmp67_;
	GtkEventControllerKey* key = NULL;
	GtkEventControllerKey* _tmp68_;
	GtkEventControllerKey* _tmp69_;
	GtkEventController* _tmp70_;
	GtkEventControllerKey* _tmp71_;
	GtkEventControllerKey* _tmp72_;
	GArray* _tmp82_;
	GArray* _tmp83_;
	GSettings* _tmp84_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (win != NULL, NULL);
	_data50_ = g_slice_new0 (Block50Data);
	_data50_->_ref_count_ = 1;
	self = (NoteView*) g_object_new (object_type, NULL);
	_data50_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (win);
	_g_object_unref0 (self->priv->_win);
	self->priv->_win = _tmp0_;
	_tmp1_ = gtk_source_view_get_completion ((GtkSourceView*) self);
	_tmp2_ = _tmp1_;
	g_object_set (_tmp2_, "select-on-show", TRUE, NULL);
	_tmp3_ = g_get_user_data_dir ();
	_tmp4_ = g_build_filename (_tmp3_, "minder", "gtksourceview-4", NULL);
	sourceview_path = _tmp4_;
	_tmp6_ = _tmp5_ = g_get_system_data_dirs ();
	{
		gchar** data_dir_collection = NULL;
		gint data_dir_collection_length1 = 0;
		gint _data_dir_collection_size_ = 0;
		gint data_dir_it = 0;
		data_dir_collection = _tmp6_;
		data_dir_collection_length1 = _vala_array_length (_tmp5_);
		for (data_dir_it = 0; data_dir_it < data_dir_collection_length1; data_dir_it = data_dir_it + 1) {
			gchar* _tmp7_;
			gchar* data_dir = NULL;
			_tmp7_ = g_strdup (data_dir_collection[data_dir_it]);
			data_dir = _tmp7_;
			{
				const gchar* _tmp8_;
				gchar* _tmp9_;
				const gchar* _tmp10_;
				_tmp8_ = data_dir;
				_tmp9_ = g_build_filename (_tmp8_, "minder", "gtksourceview-4", NULL);
				_g_free0 (sourceview_path);
				sourceview_path = _tmp9_;
				_tmp10_ = sourceview_path;
				if (g_file_test (_tmp10_, G_FILE_TEST_EXISTS)) {
					_g_free0 (data_dir);
					break;
				}
				_g_free0 (data_dir);
			}
		}
	}
	_tmp11_ = sourceview_path;
	_tmp12_ = g_build_filename (_tmp11_, "language-specs", NULL);
	lang_path = _tmp12_;
	_tmp13_ = sourceview_path;
	_tmp14_ = g_build_filename (_tmp13_, "styles", NULL);
	style_path = _tmp14_;
	_tmp15_ = g_new0 (gchar*, 0 + 1);
	lang_paths = _tmp15_;
	lang_paths_length1 = 0;
	_lang_paths_size_ = lang_paths_length1;
	_tmp16_ = gtk_widget_get_style_context ((GtkWidget*) self);
	gtk_style_context_add_class (_tmp16_, "textfield");
	_tmp17_ = gtk_source_language_manager_get_default ();
	_tmp18_ = _g_object_ref0 (_tmp17_);
	manager = _tmp18_;
	if (!note_view__path_init) {
		GtkSourceLanguageManager* _tmp19_;
		gchar** _tmp20_;
		gchar** _tmp21_;
		gchar** _tmp22_;
		gint _tmp22__length1;
		const gchar* _tmp23_;
		gchar* _tmp24_;
		GtkSourceLanguageManager* _tmp25_;
		gchar** _tmp26_;
		gint _tmp26__length1;
		_tmp19_ = manager;
		_tmp21_ = _tmp20_ = gtk_source_language_manager_get_search_path (_tmp19_);
		_tmp22_ = (_tmp21_ != NULL) ? _vala_array_dup4 (_tmp21_, _vala_array_length (_tmp20_)) : _tmp21_;
		_tmp22__length1 = _vala_array_length (_tmp20_);
		lang_paths = (_vala_array_free (lang_paths, lang_paths_length1, (GDestroyNotify) g_free), NULL);
		lang_paths = _tmp22_;
		lang_paths_length1 = _tmp22__length1;
		_lang_paths_size_ = lang_paths_length1;
		_tmp23_ = lang_path;
		_tmp24_ = g_strdup (_tmp23_);
		_vala_array_add6 (&lang_paths, &lang_paths_length1, &_lang_paths_size_, _tmp24_);
		_tmp25_ = manager;
		_tmp26_ = lang_paths;
		_tmp26__length1 = lang_paths_length1;
		gtk_source_language_manager_set_search_path (_tmp25_, _tmp26_);
	}
	_tmp27_ = gtk_source_style_scheme_manager_get_default ();
	_tmp28_ = _g_object_ref0 (_tmp27_);
	_data50_->style_manager = _tmp28_;
	if (!note_view__path_init) {
		GtkSourceStyleSchemeManager* _tmp29_;
		const gchar* _tmp30_;
		_tmp29_ = _data50_->style_manager;
		_tmp30_ = style_path;
		gtk_source_style_scheme_manager_prepend_search_path (_tmp29_, _tmp30_);
	}
	note_view__path_init = TRUE;
	_tmp31_ = manager;
	_tmp32_ = note_view_get_default_language (self);
	_tmp33_ = _tmp32_;
	_tmp34_ = gtk_source_language_manager_get_language (_tmp31_, _tmp33_);
	_tmp35_ = _g_object_ref0 (_tmp34_);
	_tmp36_ = _tmp35_;
	_g_free0 (_tmp33_);
	language = _tmp36_;
	_tmp37_ = _data50_->style_manager;
	_tmp38_ = note_view_get_default_scheme (self);
	_tmp39_ = _tmp38_;
	_tmp40_ = gtk_source_style_scheme_manager_get_scheme (_tmp37_, _tmp39_);
	_tmp41_ = _g_object_ref0 (_tmp40_);
	_tmp42_ = _tmp41_;
	_g_free0 (_tmp39_);
	style = _tmp42_;
	_tmp43_ = language;
	_tmp44_ = gtk_source_buffer_new_with_language (_tmp43_);
	gtk_source_buffer_set_highlight_syntax (_tmp44_, TRUE);
	gtk_text_buffer_set_enable_undo ((GtkTextBuffer*) _tmp44_, TRUE);
	_g_object_unref0 (self->_buffer);
	self->_buffer = _tmp44_;
	_tmp45_ = self->_buffer;
	_tmp46_ = style;
	gtk_source_buffer_set_style_scheme (_tmp45_, _tmp46_);
	_tmp47_ = self->_buffer;
	gtk_text_view_set_buffer ((GtkTextView*) self, (GtkTextBuffer*) _tmp47_);
	note_view_set_modified (self, FALSE);
	_tmp48_ = self->_buffer;
	g_signal_connect_object ((GtkTextBuffer*) _tmp48_, "changed", (GCallback) ___lambda38__gtk_text_buffer_changed, self, 0);
	_tmp49_ = g_simple_action_group_new ();
	_g_object_unref0 (self->priv->_group);
	self->priv->_group = _tmp49_;
	_tmp50_ = self->priv->_group;
	gtk_widget_insert_action_group ((GtkWidget*) self, "noteview", (GActionGroup*) _tmp50_);
	_tmp51_ = main_window_make_markdown_menu (win);
	md_menu = _tmp51_;
	_tmp52_ = g_menu_new ();
	extra = _tmp52_;
	_tmp53_ = extra;
	_tmp54_ = md_menu;
	g_menu_append_submenu (_tmp53_, _ ("Markdown"), (GMenuModel*) _tmp54_);
	_tmp55_ = extra;
	gtk_text_view_set_extra_menu ((GtkTextView*) self, (GMenuModel*) _tmp55_);
	_tmp56_ = (GtkEventControllerFocus*) gtk_event_controller_focus_new ();
	focus = _tmp56_;
	_tmp57_ = focus;
	_tmp58_ = _g_object_ref0 ((GtkEventController*) _tmp57_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp58_);
	_tmp59_ = focus;
	g_signal_connect_object (_tmp59_, "enter", (GCallback) _note_view_on_focus_gtk_event_controller_focus_enter, self, 0);
	_tmp60_ = (GtkEventControllerMotion*) gtk_event_controller_motion_new ();
	motion = _tmp60_;
	_tmp61_ = motion;
	_tmp62_ = _g_object_ref0 ((GtkEventController*) _tmp61_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp62_);
	_tmp63_ = motion;
	g_signal_connect_object (_tmp63_, "motion", (GCallback) _note_view_on_motion_gtk_event_controller_motion_motion, self, 0);
	_tmp64_ = (GtkGestureClick*) gtk_gesture_click_new ();
	click = _tmp64_;
	_tmp65_ = click;
	_tmp66_ = _g_object_ref0 ((GtkEventController*) _tmp65_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp66_);
	_tmp67_ = click;
	g_signal_connect_object (_tmp67_, "pressed", (GCallback) _note_view_on_press_gtk_gesture_click_pressed, self, 0);
	_tmp68_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	key = _tmp68_;
	_tmp69_ = key;
	_tmp70_ = _g_object_ref0 ((GtkEventController*) _tmp69_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp70_);
	_tmp71_ = key;
	g_signal_connect_object (_tmp71_, "key-pressed", (GCallback) _note_view_on_keypress_gtk_event_controller_key_key_pressed, self, 0);
	_tmp72_ = key;
	g_signal_connect_object (_tmp72_, "key-released", (GCallback) _note_view_on_keyrelease_gtk_event_controller_key_key_released, self, 0);
	gtk_source_view_set_auto_indent ((GtkSourceView*) self, TRUE);
	gtk_text_view_set_wrap_mode ((GtkTextView*) self, GTK_WRAP_WORD);
	gtk_source_view_set_tab_width ((GtkSourceView*) self, (guint) 4);
	gtk_source_view_set_insert_spaces_instead_of_tabs ((GtkSourceView*) self, TRUE);
	{
		GRegex* _tmp73_ = NULL;
		gchar* _tmp74_;
		gchar* _tmp75_;
		GRegex* _tmp76_;
		GRegex* _tmp77_;
		GRegex* _tmp78_;
		GRegex* _tmp79_ = NULL;
		GRegex* _tmp80_;
		GRegex* _tmp81_;
		_tmp74_ = utils_url_re ();
		_tmp75_ = _tmp74_;
		_tmp76_ = g_regex_new (_tmp75_, 0, 0, &_inner_error0_);
		_tmp77_ = _tmp76_;
		_g_free0 (_tmp75_);
		_tmp73_ = _tmp77_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_object_unref0 (key);
			_g_object_unref0 (click);
			_g_object_unref0 (motion);
			_g_object_unref0 (focus);
			_g_object_unref0 (extra);
			_g_object_unref0 (md_menu);
			_g_object_unref0 (style);
			_g_object_unref0 (language);
			_g_object_unref0 (manager);
			lang_paths = (_vala_array_free (lang_paths, lang_paths_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (style_path);
			_g_free0 (lang_path);
			_g_free0 (sourceview_path);
			block50_data_unref (_data50_);
			_data50_ = NULL;
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp78_ = _tmp73_;
		_tmp73_ = NULL;
		_g_regex_unref0 (self->priv->_url_re);
		self->priv->_url_re = _tmp78_;
		_tmp80_ = g_regex_new ("@Node-(\\d+)", 0, 0, &_inner_error0_);
		_tmp79_ = _tmp80_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (_tmp73_);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_object_unref0 (key);
			_g_object_unref0 (click);
			_g_object_unref0 (motion);
			_g_object_unref0 (focus);
			_g_object_unref0 (extra);
			_g_object_unref0 (md_menu);
			_g_object_unref0 (style);
			_g_object_unref0 (language);
			_g_object_unref0 (manager);
			lang_paths = (_vala_array_free (lang_paths, lang_paths_length1, (GDestroyNotify) g_free), NULL);
			_g_free0 (style_path);
			_g_free0 (lang_path);
			_g_free0 (sourceview_path);
			block50_data_unref (_data50_);
			_data50_ = NULL;
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp81_ = _tmp79_;
		_tmp79_ = NULL;
		_g_regex_unref0 (self->priv->_link_re);
		self->priv->_link_re = _tmp81_;
		_g_regex_unref0 (_tmp79_);
		_g_regex_unref0 (_tmp73_);
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		_g_regex_unref0 (self->priv->_url_re);
		self->priv->_url_re = NULL;
		_g_regex_unref0 (self->priv->_link_re);
		self->priv->_link_re = NULL;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (key);
		_g_object_unref0 (click);
		_g_object_unref0 (motion);
		_g_object_unref0 (focus);
		_g_object_unref0 (extra);
		_g_object_unref0 (md_menu);
		_g_object_unref0 (style);
		_g_object_unref0 (language);
		_g_object_unref0 (manager);
		lang_paths = (_vala_array_free (lang_paths, lang_paths_length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (style_path);
		_g_free0 (lang_path);
		_g_free0 (sourceview_path);
		block50_data_unref (_data50_);
		_data50_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp82_ = g_array_new (TRUE, TRUE, sizeof (NoteViewUrlPos*));
	g_array_set_clear_func (_tmp82_, (GDestroyNotify) _vala_NoteViewUrlPos_free_function_content_of);
	_g_array_unref0 (self->priv->_last_urls);
	self->priv->_last_urls = _tmp82_;
	_tmp83_ = g_array_new (TRUE, TRUE, sizeof (NoteViewLinkPos*));
	g_array_set_clear_func (_tmp83_, (GDestroyNotify) _vala_NoteViewLinkPos_free_function_content_of);
	_g_array_unref0 (self->priv->_last_links);
	self->priv->_last_links = _tmp83_;
	_tmp84_ = minder_settings;
	g_signal_connect_data (_tmp84_, "changed::colorize-notes", (GCallback) ___lambda129__g_settings_changed, block50_data_ref (_data50_), (GClosureNotify) block50_data_unref, 0);
	_g_object_unref0 (key);
	_g_object_unref0 (click);
	_g_object_unref0 (motion);
	_g_object_unref0 (focus);
	_g_object_unref0 (extra);
	_g_object_unref0 (md_menu);
	_g_object_unref0 (style);
	_g_object_unref0 (language);
	_g_object_unref0 (manager);
	lang_paths = (_vala_array_free (lang_paths, lang_paths_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (style_path);
	_g_free0 (lang_path);
	_g_free0 (sourceview_path);
	block50_data_unref (_data50_);
	_data50_ = NULL;
	return self;
}

NoteView*
note_view_new (MainWindow* win)
{
	return note_view_construct (TYPE_NOTE_VIEW, win);
}

static gchar*
note_view_get_default_language (NoteView* self)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("markdown-minder");
	result = _tmp0_;
	return result;
}

static gchar*
note_view_get_default_scheme (NoteView* self)
{
	const gchar* _tmp0_ = NULL;
	GSettings* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = minder_settings;
	if (g_settings_get_boolean (_tmp1_, "colorize-notes")) {
		_tmp0_ = "minder.color";
	} else {
		_tmp0_ = "minder.none";
	}
	_tmp2_ = g_strdup (_tmp0_);
	result = _tmp2_;
	return result;
}

static void
note_view_clear (NoteView* self)
{
	g_return_if_fail (self != NULL);
	self->priv->_last_lnum = -1;
	_g_free0 (self->priv->_last_url);
	self->priv->_last_url = NULL;
	_g_free0 (self->priv->_last_link);
	self->priv->_last_link = NULL;
}

static gchar*
string_chomp (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strchomp (_result_);
	result = _result_;
	return result;
}

static gchar*
note_view_current_line (NoteView* self,
                        GtkTextIter* cursor)
{
	GtkTextIter start = {0};
	GtkTextIter _tmp0_;
	GtkTextIter end = {0};
	GtkTextIter _tmp1_;
	GtkTextIter _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (cursor != NULL, NULL);
	_tmp0_ = *cursor;
	start = _tmp0_;
	_tmp1_ = *cursor;
	end = _tmp1_;
	gtk_text_iter_set_line (&start, gtk_text_iter_get_line (&start));
	gtk_text_iter_forward_line (&end);
	_tmp2_ = end;
	_tmp3_ = gtk_text_iter_get_text (&start, &_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = string_chomp (_tmp4_);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	result = _tmp6_;
	return result;
}

static gpointer*
vala_g_array_remove_range (GArray* self,
                           guint index,
                           guint length,
                           gint* result_length1)
{
	gpointer* ga = NULL;
	gpointer* _tmp0_;
	gint ga_length1;
	gint _ga_size_;
	gpointer* _tmp6_;
	gint _tmp6__length1;
	gpointer* result;
	g_return_val_if_fail (self != NULL, NULL);
	_vala_assert (self->len >= (index + length), "this.length >= index + length");
	_tmp0_ = g_new0 (gpointer, length);
	ga = _tmp0_;
	ga_length1 = length;
	_ga_size_ = ga_length1;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gpointer* _tmp3_;
				gint _tmp3__length1;
				gpointer* _tmp4_;
				gint _tmp4__length1;
				gpointer _tmp5_;
				if (!_tmp1_) {
					guint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < length)) {
					break;
				}
				_tmp3_ = ga;
				_tmp3__length1 = ga_length1;
				_tmp4_ = self->data;
				_tmp4__length1 = self->len;
				_tmp5_ = _tmp4_[i + index];
				_tmp4_[i + index] = NULL;
				_tmp3_[i] = _tmp5_;
			}
		}
	}
	g_array_remove_range (self, index, length);
	_tmp6_ = ga;
	_tmp6__length1 = ga_length1;
	if (result_length1) {
		*result_length1 = _tmp6__length1;
	}
	result = _tmp6_;
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static void
note_view_parse_line_for_urls (NoteView* self,
                               const gchar* line)
{
	GRegex* _tmp0_;
	GMatchInfo* match_info = NULL;
	gint start = 0;
	GArray* _tmp1_;
	GArray* _tmp2_;
	gint _tmp3_ = 0;
	gpointer* _tmp4_;
	NoteViewUrlPos** _tmp5_;
	gint _tmp5__length1;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (line != NULL);
	_tmp0_ = self->priv->_url_re;
	if (_tmp0_ == NULL) {
		return;
	}
	start = 0;
	_tmp1_ = self->priv->_last_urls;
	_tmp2_ = self->priv->_last_urls;
	_tmp4_ = vala_g_array_remove_range (_tmp1_, (guint) 0, _tmp2_->len, &_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _tmp3_;
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) note_view_url_pos_unref), NULL);
	{
		while (TRUE) {
			gboolean _tmp6_ = FALSE;
			GRegex* _tmp7_;
			GMatchInfo* _tmp8_ = NULL;
			gboolean _tmp9_;
			gint s = 0;
			gint e = 0;
			GMatchInfo* _tmp10_;
			gint _tmp11_ = 0;
			gint _tmp12_ = 0;
			GArray* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			NoteViewUrlPos* _tmp16_;
			_tmp7_ = self->priv->_url_re;
			_tmp9_ = g_regex_match_all_full (_tmp7_, line, (gssize) -1, start, 0, &_tmp8_, &_inner_error0_);
			_g_match_info_unref0 (match_info);
			match_info = _tmp8_;
			_tmp6_ = _tmp9_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == G_REGEX_ERROR) {
					goto __catch0_g_regex_error;
				}
				_g_match_info_unref0 (match_info);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
			if (!_tmp6_) {
				break;
			}
			_tmp10_ = match_info;
			g_match_info_fetch_pos (_tmp10_, 0, &_tmp11_, &_tmp12_);
			s = _tmp11_;
			e = _tmp12_;
			_tmp13_ = self->priv->_last_urls;
			_tmp14_ = string_substring (line, (glong) s, (glong) (e - s));
			_tmp15_ = _tmp14_;
			_tmp16_ = note_view_url_pos_new (_tmp15_, s, e);
			g_array_append_val (_tmp13_, _tmp16_);
			_g_free0 (_tmp15_);
			start = e;
		}
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_match_info_unref0 (match_info);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_match_info_unref0 (match_info);
}

static void
note_view_parse_line_for_node_links (NoteView* self,
                                     const gchar* line)
{
	GRegex* _tmp0_;
	GMatchInfo* match_info = NULL;
	gint start = 0;
	GArray* _tmp1_;
	GArray* _tmp2_;
	gint _tmp3_ = 0;
	gpointer* _tmp4_;
	NoteViewLinkPos** _tmp5_;
	gint _tmp5__length1;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (line != NULL);
	_tmp0_ = self->priv->_link_re;
	if (_tmp0_ == NULL) {
		return;
	}
	start = 0;
	_tmp1_ = self->priv->_last_links;
	_tmp2_ = self->priv->_last_links;
	_tmp4_ = vala_g_array_remove_range (_tmp1_, (guint) 0, _tmp2_->len, &_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _tmp3_;
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) note_view_link_pos_unref), NULL);
	{
		while (TRUE) {
			gboolean _tmp6_ = FALSE;
			GRegex* _tmp7_;
			GMatchInfo* _tmp8_ = NULL;
			gboolean _tmp9_;
			gint s = 0;
			gint e = 0;
			GMatchInfo* _tmp10_;
			gint _tmp11_ = 0;
			gint _tmp12_ = 0;
			gchar* id = NULL;
			GMatchInfo* _tmp13_;
			gchar* _tmp14_;
			GArray* _tmp15_;
			const gchar* _tmp16_;
			NoteViewLinkPos* _tmp17_;
			_tmp7_ = self->priv->_link_re;
			_tmp9_ = g_regex_match_full (_tmp7_, line, (gssize) -1, start, 0, &_tmp8_, &_inner_error0_);
			_g_match_info_unref0 (match_info);
			match_info = _tmp8_;
			_tmp6_ = _tmp9_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == G_REGEX_ERROR) {
					goto __catch0_g_regex_error;
				}
				_g_match_info_unref0 (match_info);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
			if (!_tmp6_) {
				break;
			}
			_tmp10_ = match_info;
			g_match_info_fetch_pos (_tmp10_, 0, &_tmp11_, &_tmp12_);
			s = _tmp11_;
			e = _tmp12_;
			_tmp13_ = match_info;
			_tmp14_ = g_match_info_fetch (_tmp13_, 1);
			id = _tmp14_;
			_tmp15_ = self->priv->_last_links;
			_tmp16_ = id;
			_tmp17_ = note_view_link_pos_new (atoi (_tmp16_), s, e);
			g_array_append_val (_tmp15_, _tmp17_);
			start = e;
			_g_free0 (id);
		}
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_match_info_unref0 (match_info);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_match_info_unref0 (match_info);
}

static gpointer
_note_view_url_pos_ref0 (gpointer self)
{
	return self ? note_view_url_pos_ref (self) : NULL;
}

static gboolean
note_view_cursor_in_url (NoteView* self,
                         GtkTextIter* cursor)
{
	gint offset = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (cursor != NULL, FALSE);
	offset = gtk_text_iter_get_line_offset (cursor);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				NoteViewUrlPos* link = NULL;
				GArray* _tmp3_;
				NoteViewUrlPos* _tmp4_;
				NoteViewUrlPos* _tmp5_;
				gboolean _tmp6_ = FALSE;
				NoteViewUrlPos* _tmp7_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_last_urls;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_last_urls;
				_tmp4_ = g_array_index (_tmp3_, NoteViewUrlPos*, (guint) i);
				_tmp5_ = _note_view_url_pos_ref0 (_tmp4_);
				link = _tmp5_;
				_tmp7_ = link;
				if (_tmp7_->start <= offset) {
					NoteViewUrlPos* _tmp8_;
					_tmp8_ = link;
					_tmp6_ = offset < _tmp8_->end;
				} else {
					_tmp6_ = FALSE;
				}
				if (_tmp6_) {
					NoteViewUrlPos* _tmp9_;
					const gchar* _tmp10_;
					gchar* _tmp11_;
					_tmp9_ = link;
					_tmp10_ = _tmp9_->url;
					_tmp11_ = g_strdup (_tmp10_);
					_g_free0 (self->priv->_last_url);
					self->priv->_last_url = _tmp11_;
					result = TRUE;
					_note_view_url_pos_unref0 (link);
					return result;
				}
				_note_view_url_pos_unref0 (link);
			}
		}
	}
	_g_free0 (self->priv->_last_url);
	self->priv->_last_url = NULL;
	result = FALSE;
	return result;
}

static gpointer
_note_view_link_pos_ref0 (gpointer self)
{
	return self ? note_view_link_pos_ref (self) : NULL;
}

static gint*
_int_dup (gint* self)
{
	gint* dup;
	dup = g_new0 (gint, 1);
	memcpy (dup, self, sizeof (gint));
	return dup;
}

static gpointer
__int_dup0 (gpointer self)
{
	return self ? _int_dup (self) : NULL;
}

static gboolean
note_view_cursor_in_node_link (NoteView* self,
                               GtkTextIter* cursor)
{
	gint offset = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (cursor != NULL, FALSE);
	offset = gtk_text_iter_get_line_offset (cursor);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GArray* _tmp2_;
				NoteViewLinkPos* link = NULL;
				GArray* _tmp3_;
				NoteViewLinkPos* _tmp4_;
				NoteViewLinkPos* _tmp5_;
				gboolean _tmp6_ = FALSE;
				NoteViewLinkPos* _tmp7_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->_last_links;
				if (!(((guint) i) < _tmp2_->len)) {
					break;
				}
				_tmp3_ = self->priv->_last_links;
				_tmp4_ = g_array_index (_tmp3_, NoteViewLinkPos*, (guint) i);
				_tmp5_ = _note_view_link_pos_ref0 (_tmp4_);
				link = _tmp5_;
				_tmp7_ = link;
				if (_tmp7_->start <= offset) {
					NoteViewLinkPos* _tmp8_;
					_tmp8_ = link;
					_tmp6_ = offset < _tmp8_->end;
				} else {
					_tmp6_ = FALSE;
				}
				if (_tmp6_) {
					NoteViewLinkPos* _tmp9_;
					gint* _tmp10_;
					_tmp9_ = link;
					_tmp10_ = __int_dup0 (&_tmp9_->id);
					_g_free0 (self->priv->_last_link);
					self->priv->_last_link = _tmp10_;
					result = TRUE;
					_note_view_link_pos_unref0 (link);
					return result;
				}
				_note_view_link_pos_unref0 (link);
			}
		}
	}
	_g_free0 (self->priv->_last_link);
	self->priv->_last_link = NULL;
	result = FALSE;
	return result;
}

static void
note_view_enable_url_checking (NoteView* self,
                               gint x,
                               gint y)
{
	GtkTextIter cursor = {0};
	GtkTextIter _tmp0_ = {0};
	gboolean in_node_link = FALSE;
	GtkTextIter _tmp5_;
	gboolean _tmp7_ = FALSE;
	GtkTextIter _tmp8_;
	g_return_if_fail (self != NULL);
	gtk_text_view_get_iter_at_location ((GtkTextView*) self, &_tmp0_, x, y);
	cursor = _tmp0_;
	if (self->priv->_last_lnum != gtk_text_iter_get_line (&cursor)) {
		gchar* line = NULL;
		GtkTextIter _tmp1_;
		gchar* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp1_ = cursor;
		_tmp2_ = note_view_current_line (self, &_tmp1_);
		line = _tmp2_;
		_tmp3_ = line;
		note_view_parse_line_for_urls (self, _tmp3_);
		_tmp4_ = line;
		note_view_parse_line_for_node_links (self, _tmp4_);
		self->priv->_last_lnum = gtk_text_iter_get_line (&cursor);
		_g_free0 (line);
	}
	_tmp5_ = cursor;
	in_node_link = note_view_cursor_in_node_link (self, &_tmp5_);
	if (in_node_link) {
		gint* _tmp6_;
		_tmp6_ = self->priv->_last_link;
		g_signal_emit (self, note_view_signals[NOTE_VIEW_NODE_LINK_HOVER_SIGNAL], 0, *_tmp6_);
	} else {
		gtk_widget_set_tooltip_text ((GtkWidget*) self, "");
	}
	_tmp8_ = cursor;
	if (note_view_cursor_in_url (self, &_tmp8_)) {
		_tmp7_ = TRUE;
	} else {
		_tmp7_ = in_node_link;
	}
	if (_tmp7_) {
		GdkCursor* _tmp9_;
		GdkCursor* _tmp10_;
		_tmp9_ = gdk_cursor_new_from_name ("pointer", NULL);
		_tmp10_ = _tmp9_;
		gtk_widget_set_cursor ((GtkWidget*) self, _tmp10_);
		_g_object_unref0 (_tmp10_);
	} else {
		gtk_widget_set_cursor ((GtkWidget*) self, NULL);
	}
}

static void
note_view_disable_url_checking (NoteView* self)
{
	g_return_if_fail (self != NULL);
	gtk_widget_set_cursor ((GtkWidget*) self, NULL);
	self->priv->_last_lnum = -1;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, "");
}

void
note_view_add_unicode_completion (NoteView* self,
                                  MainWindow* win,
                                  UnicodeInsert* unicoder)
{
	CompletionProvider* provider = NULL;
	GtkSourceBuffer* _tmp0_;
	GList* _tmp1_;
	GList* _tmp2_;
	CompletionProvider* _tmp3_;
	CompletionProvider* _tmp4_;
	GtkSourceCompletion* _tmp5_;
	GtkSourceCompletion* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (win != NULL);
	g_return_if_fail (unicoder != NULL);
	_tmp0_ = self->_buffer;
	_tmp1_ = unicode_insert_create_proposals (unicoder);
	_tmp2_ = _tmp1_;
	_tmp3_ = completion_provider_new (win, _tmp0_, "Unicode", _tmp2_);
	_tmp4_ = _tmp3_;
	(_tmp2_ == NULL) ? NULL : (_tmp2_ = (_g_list_free__g_object_unref0_ (_tmp2_), NULL));
	provider = _tmp4_;
	_tmp5_ = gtk_source_view_get_completion ((GtkSourceView*) self);
	_tmp6_ = _tmp5_;
	gtk_source_completion_add_provider (_tmp6_, (GtkSourceCompletionProvider*) provider);
	_g_object_unref0 (provider);
}

static void
note_view_on_motion (NoteView* self,
                     gdouble x,
                     gdouble y)
{
	g_return_if_fail (self != NULL);
	self->priv->_last_x = (gint) x;
	self->priv->_last_y = (gint) y;
	if (self->priv->_control) {
		note_view_enable_url_checking (self, self->priv->_last_x, self->priv->_last_y);
	} else {
		note_view_disable_url_checking (self);
	}
}

static void
note_view_on_press (NoteView* self,
                    gint n_press,
                    gdouble x,
                    gdouble y)
{
	g_return_if_fail (self != NULL);
	if (self->priv->_control) {
		gint int_x = 0;
		gint int_y = 0;
		const gchar* _tmp0_;
		int_x = (gint) x;
		int_y = (gint) y;
		note_view_enable_url_checking (self, int_x, int_y);
		_tmp0_ = self->priv->_last_url;
		if (_tmp0_ != NULL) {
			const gchar* _tmp1_;
			_tmp1_ = self->priv->_last_url;
			utils_open_url (_tmp1_);
		} else {
			gint* _tmp2_;
			_tmp2_ = self->priv->_last_link;
			if (_tmp2_ != NULL) {
				gint* _tmp3_;
				_tmp3_ = self->priv->_last_link;
				g_signal_emit (self, note_view_signals[NOTE_VIEW_NODE_LINK_CLICKED_SIGNAL], 0, *_tmp3_);
			}
		}
	}
}

static gboolean
note_view_on_keypress (NoteView* self,
                       guint keyval,
                       guint keycode,
                       GdkModifierType state)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (keyval == ((guint) 65507)) {
		self->priv->_control = TRUE;
		note_view_enable_url_checking (self, self->priv->_last_x, self->priv->_last_y);
	}
	result = FALSE;
	return result;
}

static void
note_view_on_keyrelease (NoteView* self,
                         guint keyval,
                         guint keycode,
                         GdkModifierType state)
{
	g_return_if_fail (self != NULL);
	if (keyval == ((guint) 65507)) {
		self->priv->_control = FALSE;
		note_view_disable_url_checking (self);
	}
}

static void
note_view_on_focus (NoteView* self)
{
	g_return_if_fail (self != NULL);
	note_view_clear (self);
}

static void
note_view_real_paste_clipboard (GtkTextView* base)
{
	NoteView * self;
	self = (NoteView*) base;
	minder_clipboard_paste_into_note (self);
}

void
note_view_paste_text (NoteView* self,
                      const gchar* str)
{
	GtkTextBuffer* _tmp0_;
	GtkTextBuffer* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (str != NULL);
	_tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = strlen (str);
	_tmp3_ = _tmp2_;
	gtk_text_buffer_insert_at_cursor (_tmp1_, str, _tmp3_);
}

void
note_view_paste_markdown (NoteView* self,
                          const gchar* pretext,
                          const gchar* midtext,
                          const gchar* posttext)
{
	GtkTextIter selstart = {0};
	GtkTextIter selend = {0};
	GtkTextIter cursor = {0};
	GtkTextBuffer* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextIter _tmp2_ = {0};
	GtkTextIter _tmp3_ = {0};
	gboolean _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pretext != NULL);
	g_return_if_fail (midtext != NULL);
	g_return_if_fail (posttext != NULL);
	_tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp1_ = _tmp0_;
	_tmp4_ = gtk_text_buffer_get_selection_bounds (_tmp1_, &_tmp2_, &_tmp3_);
	selstart = _tmp2_;
	selend = _tmp3_;
	if (_tmp4_) {
		gchar* str = NULL;
		GtkTextBuffer* _tmp5_;
		GtkTextBuffer* _tmp6_;
		GtkTextIter _tmp7_;
		GtkTextIter _tmp8_;
		gchar* _tmp9_;
		GtkTextBuffer* _tmp10_;
		GtkTextBuffer* _tmp11_;
		_tmp5_ = gtk_text_view_get_buffer ((GtkTextView*) self);
		_tmp6_ = _tmp5_;
		_tmp7_ = selstart;
		_tmp8_ = selend;
		_tmp9_ = gtk_text_buffer_get_text (_tmp6_, &_tmp7_, &_tmp8_, TRUE);
		str = _tmp9_;
		_tmp10_ = gtk_text_view_get_buffer ((GtkTextView*) self);
		_tmp11_ = _tmp10_;
		gtk_text_buffer_delete (_tmp11_, &selstart, &selend);
		if (g_strcmp0 (midtext, "") != 0) {
			gchar* istr = NULL;
			const gchar* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			gchar* _tmp15_;
			gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			gint back_chars = 0;
			const gchar* _tmp19_;
			GtkTextBuffer* _tmp27_;
			GtkTextBuffer* _tmp28_;
			const gchar* _tmp29_;
			const gchar* _tmp30_;
			gint _tmp31_;
			gint _tmp32_;
			GtkTextBuffer* _tmp33_;
			GtkTextBuffer* _tmp34_;
			GtkTextBuffer* _tmp35_;
			GtkTextBuffer* _tmp36_;
			GtkTextMark* _tmp37_;
			GtkTextIter _tmp38_ = {0};
			GtkTextBuffer* _tmp39_;
			GtkTextBuffer* _tmp40_;
			GtkTextIter _tmp41_;
			_tmp12_ = str;
			_tmp13_ = g_strconcat (pretext, _tmp12_, NULL);
			_tmp14_ = _tmp13_;
			_tmp15_ = g_strconcat (_tmp14_, midtext, NULL);
			_tmp16_ = _tmp15_;
			_tmp17_ = g_strconcat (_tmp16_, posttext, NULL);
			_tmp18_ = _tmp17_;
			_g_free0 (_tmp16_);
			_g_free0 (_tmp14_);
			istr = _tmp18_;
			back_chars = g_utf8_strlen (posttext, (gssize) -1);
			_tmp19_ = str;
			if (utils_is_url (_tmp19_)) {
				gchar* _tmp20_;
				gchar* _tmp21_;
				const gchar* _tmp22_;
				gchar* _tmp23_;
				gchar* _tmp24_;
				gchar* _tmp25_;
				const gchar* _tmp26_;
				_tmp20_ = g_strconcat (pretext, midtext, NULL);
				_tmp21_ = _tmp20_;
				_tmp22_ = str;
				_tmp23_ = g_strconcat (_tmp21_, _tmp22_, NULL);
				_tmp24_ = _tmp23_;
				_tmp25_ = g_strconcat (_tmp24_, posttext, NULL);
				_g_free0 (istr);
				istr = _tmp25_;
				_g_free0 (_tmp24_);
				_g_free0 (_tmp21_);
				_tmp26_ = str;
				back_chars = (g_utf8_strlen (midtext, (gssize) -1) + g_utf8_strlen (_tmp26_, (gssize) -1)) + g_utf8_strlen (posttext, (gssize) -1);
			}
			_tmp27_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp28_ = _tmp27_;
			_tmp29_ = istr;
			_tmp30_ = istr;
			_tmp31_ = strlen (_tmp30_);
			_tmp32_ = _tmp31_;
			gtk_text_buffer_insert (_tmp28_, &selstart, _tmp29_, _tmp32_);
			_tmp33_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp34_ = _tmp33_;
			_tmp35_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp36_ = _tmp35_;
			_tmp37_ = gtk_text_buffer_get_insert (_tmp36_);
			gtk_text_buffer_get_iter_at_mark (_tmp34_, &_tmp38_, _tmp37_);
			cursor = _tmp38_;
			gtk_text_iter_backward_chars (&cursor, back_chars);
			_tmp39_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp40_ = _tmp39_;
			_tmp41_ = cursor;
			gtk_text_buffer_place_cursor (_tmp40_, &_tmp41_);
			_g_free0 (istr);
		} else {
			gchar* istr = NULL;
			const gchar* _tmp42_;
			gchar* _tmp43_;
			gchar* _tmp44_;
			gchar* _tmp45_;
			gchar* _tmp46_;
			GtkTextBuffer* _tmp47_;
			GtkTextBuffer* _tmp48_;
			const gchar* _tmp49_;
			const gchar* _tmp50_;
			gint _tmp51_;
			gint _tmp52_;
			_tmp42_ = str;
			_tmp43_ = g_strconcat (pretext, _tmp42_, NULL);
			_tmp44_ = _tmp43_;
			_tmp45_ = g_strconcat (_tmp44_, posttext, NULL);
			_tmp46_ = _tmp45_;
			_g_free0 (_tmp44_);
			istr = _tmp46_;
			_tmp47_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp48_ = _tmp47_;
			_tmp49_ = istr;
			_tmp50_ = istr;
			_tmp51_ = strlen (_tmp50_);
			_tmp52_ = _tmp51_;
			gtk_text_buffer_insert (_tmp48_, &selstart, _tmp49_, _tmp52_);
			_g_free0 (istr);
		}
		_g_free0 (str);
	} else {
		if (g_strcmp0 (posttext, "") == 0) {
			GtkTextBuffer* _tmp53_;
			GtkTextBuffer* _tmp54_;
			GtkTextBuffer* _tmp55_;
			GtkTextBuffer* _tmp56_;
			GtkTextMark* _tmp57_;
			GtkTextIter _tmp58_ = {0};
			GtkTextBuffer* _tmp59_;
			GtkTextBuffer* _tmp60_;
			GtkTextIter _tmp61_;
			GtkTextBuffer* _tmp62_;
			GtkTextBuffer* _tmp63_;
			gint _tmp64_;
			gint _tmp65_;
			_tmp53_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp54_ = _tmp53_;
			_tmp55_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp56_ = _tmp55_;
			_tmp57_ = gtk_text_buffer_get_insert (_tmp56_);
			gtk_text_buffer_get_iter_at_mark (_tmp54_, &_tmp58_, _tmp57_);
			cursor = _tmp58_;
			gtk_text_iter_set_line_offset (&cursor, 0);
			_tmp59_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp60_ = _tmp59_;
			_tmp61_ = cursor;
			gtk_text_buffer_place_cursor (_tmp60_, &_tmp61_);
			_tmp62_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp63_ = _tmp62_;
			_tmp64_ = strlen (pretext);
			_tmp65_ = _tmp64_;
			gtk_text_buffer_insert_at_cursor (_tmp63_, pretext, _tmp65_);
		} else {
			gchar* str = NULL;
			gchar* _tmp66_;
			gchar* _tmp67_;
			gchar* _tmp68_;
			gchar* _tmp69_;
			GtkTextBuffer* _tmp70_;
			GtkTextBuffer* _tmp71_;
			const gchar* _tmp72_;
			const gchar* _tmp73_;
			gint _tmp74_;
			gint _tmp75_;
			GtkTextBuffer* _tmp76_;
			GtkTextBuffer* _tmp77_;
			GtkTextBuffer* _tmp78_;
			GtkTextBuffer* _tmp79_;
			GtkTextMark* _tmp80_;
			GtkTextIter _tmp81_ = {0};
			GtkTextBuffer* _tmp82_;
			GtkTextBuffer* _tmp83_;
			GtkTextIter _tmp84_;
			_tmp66_ = g_strconcat (pretext, midtext, NULL);
			_tmp67_ = _tmp66_;
			_tmp68_ = g_strconcat (_tmp67_, posttext, NULL);
			_tmp69_ = _tmp68_;
			_g_free0 (_tmp67_);
			str = _tmp69_;
			_tmp70_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp71_ = _tmp70_;
			_tmp72_ = str;
			_tmp73_ = str;
			_tmp74_ = strlen (_tmp73_);
			_tmp75_ = _tmp74_;
			gtk_text_buffer_insert_at_cursor (_tmp71_, _tmp72_, _tmp75_);
			_tmp76_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp77_ = _tmp76_;
			_tmp78_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp79_ = _tmp78_;
			_tmp80_ = gtk_text_buffer_get_insert (_tmp79_);
			gtk_text_buffer_get_iter_at_mark (_tmp77_, &_tmp81_, _tmp80_);
			cursor = _tmp81_;
			gtk_text_iter_backward_chars (&cursor, g_utf8_strlen (midtext, (gssize) -1) + g_utf8_strlen (posttext, (gssize) -1));
			_tmp82_ = gtk_text_view_get_buffer ((GtkTextView*) self);
			_tmp83_ = _tmp82_;
			_tmp84_ = cursor;
			gtk_text_buffer_place_cursor (_tmp83_, &_tmp84_);
			_g_free0 (str);
		}
	}
	gtk_widget_grab_focus ((GtkWidget*) self);
}

void
note_view_paste_node_link (NoteView* self,
                           NodeLink* link)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	gint id = 0;
	gchar* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	gchar* str = NULL;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	GtkTextBuffer* _tmp5_;
	GtkTextBuffer* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (link != NULL);
	_tmp0_ = g_strdup ("");
	text = _tmp0_;
	g_signal_emit (self, note_view_signals[NOTE_VIEW_NODE_LINK_ADDED_SIGNAL], 0, link, &_tmp1_, &_tmp2_);
	_g_free0 (text);
	text = _tmp1_;
	id = _tmp2_;
	_tmp3_ = text;
	_tmp4_ = g_strdup_printf ("[%s](@Node-%d)", _tmp3_, id);
	str = _tmp4_;
	_tmp5_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp6_ = _tmp5_;
	_tmp7_ = strlen (str);
	_tmp8_ = _tmp7_;
	gtk_text_buffer_insert_at_cursor (_tmp6_, str, _tmp8_);
	_g_free0 (str);
	_g_free0 (text);
}

void
note_view_show_tooltip (NoteView* self,
                        const gchar* tooltip)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (tooltip != NULL);
	gtk_widget_set_tooltip_text ((GtkWidget*) self, tooltip);
}

gchar*
note_view_get_text (NoteView* self)
{
	gchar* result;
	GtkTextBuffer* _tmp0_;
	GtkTextBuffer* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp1_ = _tmp0_;
	g_object_get (_tmp1_, "text", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	result = _tmp3_;
	return result;
}

void
note_view_set_text (NoteView* self,
                    const gchar* value)
{
	GtkTextBuffer* _tmp0_;
	GtkTextBuffer* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp1_ = _tmp0_;
	g_object_set (_tmp1_, "text", value, NULL);
	g_object_notify_by_pspec ((GObject *) self, note_view_properties[NOTE_VIEW_TEXT_PROPERTY]);
}

gboolean
note_view_get_modified (NoteView* self)
{
	gboolean result;
	GtkTextBuffer* _tmp0_;
	GtkTextBuffer* _tmp1_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp1_ = _tmp0_;
	result = gtk_text_buffer_get_modified (_tmp1_);
	return result;
}

void
note_view_set_modified (NoteView* self,
                        gboolean value)
{
	GtkTextBuffer* _tmp0_;
	GtkTextBuffer* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_text_view_get_buffer ((GtkTextView*) self);
	_tmp1_ = _tmp0_;
	gtk_text_buffer_set_modified (_tmp1_, value);
	note_view_clear (self);
	g_object_notify_by_pspec ((GObject *) self, note_view_properties[NOTE_VIEW_MODIFIED_PROPERTY]);
}

static void
g_cclosure_user_marshal_INT__NODE_LINK_POINTER (GClosure * closure,
                                                GValue * return_value,
                                                guint n_param_values,
                                                const GValue * param_values,
                                                gpointer invocation_hint,
                                                gpointer marshal_data)
{
	typedef gint (*GMarshalFunc_INT__NODE_LINK_POINTER) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_INT__NODE_LINK_POINTER callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	gint v_return;
	cc = (GCClosure *) closure;
	g_return_if_fail (return_value != NULL);
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_INT__NODE_LINK_POINTER) (marshal_data ? marshal_data : cc->callback);
	v_return = callback (data1, value_get_node_link (param_values + 1), g_value_get_pointer (param_values + 2), data2);
	g_value_set_int (return_value, v_return);
}

static NoteViewUrlPos*
note_view_url_pos_construct (GType object_type,
                             const gchar* u,
                             gint s,
                             gint e)
{
	NoteViewUrlPos* self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (u != NULL, NULL);
	self = (NoteViewUrlPos*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (u);
	_g_free0 (self->url);
	self->url = _tmp0_;
	self->start = s;
	self->end = e;
	return self;
}

static NoteViewUrlPos*
note_view_url_pos_new (const gchar* u,
                       gint s,
                       gint e)
{
	return note_view_url_pos_construct (NOTE_VIEW_TYPE_URL_POS, u, s, e);
}

static void
note_view_value_url_pos_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
note_view_value_url_pos_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		note_view_url_pos_unref (value->data[0].v_pointer);
	}
}

static void
note_view_value_url_pos_copy_value (const GValue* src_value,
                                    GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = note_view_url_pos_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
note_view_value_url_pos_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
note_view_value_url_pos_collect_value (GValue* value,
                                       guint n_collect_values,
                                       GTypeCValue* collect_values,
                                       guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		NoteViewUrlPos * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = note_view_url_pos_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
note_view_value_url_pos_lcopy_value (const GValue* value,
                                     guint n_collect_values,
                                     GTypeCValue* collect_values,
                                     guint collect_flags)
{
	NoteViewUrlPos ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = note_view_url_pos_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
note_view_param_spec_url_pos (const gchar* name,
                              const gchar* nick,
                              const gchar* blurb,
                              GType object_type,
                              GParamFlags flags)
{
	NoteViewParamSpecUrlPos* spec;
	g_return_val_if_fail (g_type_is_a (object_type, NOTE_VIEW_TYPE_URL_POS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
note_view_value_get_url_pos (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NOTE_VIEW_TYPE_URL_POS), NULL);
	return value->data[0].v_pointer;
}

static void
note_view_value_set_url_pos (GValue* value,
                             gpointer v_object)
{
	NoteViewUrlPos * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NOTE_VIEW_TYPE_URL_POS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, NOTE_VIEW_TYPE_URL_POS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		note_view_url_pos_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		note_view_url_pos_unref (old);
	}
}

static void
note_view_value_take_url_pos (GValue* value,
                              gpointer v_object)
{
	NoteViewUrlPos * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NOTE_VIEW_TYPE_URL_POS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, NOTE_VIEW_TYPE_URL_POS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		note_view_url_pos_unref (old);
	}
}

static void
note_view_url_pos_class_init (NoteViewUrlPosClass * klass,
                              gpointer klass_data)
{
	note_view_url_pos_parent_class = g_type_class_peek_parent (klass);
	((NoteViewUrlPosClass *) klass)->finalize = note_view_url_pos_finalize;
}

static void
note_view_url_pos_instance_init (NoteViewUrlPos * self,
                                 gpointer klass)
{
	self->ref_count = 1;
}

static void
note_view_url_pos_finalize (NoteViewUrlPos * obj)
{
	NoteViewUrlPos * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTE_VIEW_TYPE_URL_POS, NoteViewUrlPos);
	g_signal_handlers_destroy (self);
	_g_free0 (self->url);
}

static GType
note_view_url_pos_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { note_view_value_url_pos_init, note_view_value_url_pos_free_value, note_view_value_url_pos_copy_value, note_view_value_url_pos_peek_pointer, "p", note_view_value_url_pos_collect_value, "p", note_view_value_url_pos_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (NoteViewUrlPosClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) note_view_url_pos_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NoteViewUrlPos), 0, (GInstanceInitFunc) note_view_url_pos_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType note_view_url_pos_type_id;
	note_view_url_pos_type_id = g_type_register_fundamental (g_type_fundamental_next (), "NoteViewUrlPos", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return note_view_url_pos_type_id;
}

static GType
note_view_url_pos_get_type (void)
{
	static volatile gsize note_view_url_pos_type_id__once = 0;
	if (g_once_init_enter (&note_view_url_pos_type_id__once)) {
		GType note_view_url_pos_type_id;
		note_view_url_pos_type_id = note_view_url_pos_get_type_once ();
		g_once_init_leave (&note_view_url_pos_type_id__once, note_view_url_pos_type_id);
	}
	return note_view_url_pos_type_id__once;
}

static gpointer
note_view_url_pos_ref (gpointer instance)
{
	NoteViewUrlPos * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
note_view_url_pos_unref (gpointer instance)
{
	NoteViewUrlPos * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		NOTE_VIEW_URL_POS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static NoteViewLinkPos*
note_view_link_pos_construct (GType object_type,
                              gint i,
                              gint s,
                              gint e)
{
	NoteViewLinkPos* self = NULL;
	self = (NoteViewLinkPos*) g_type_create_instance (object_type);
	self->id = i;
	self->start = s;
	self->end = e;
	return self;
}

static NoteViewLinkPos*
note_view_link_pos_new (gint i,
                        gint s,
                        gint e)
{
	return note_view_link_pos_construct (NOTE_VIEW_TYPE_LINK_POS, i, s, e);
}

static void
note_view_value_link_pos_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
note_view_value_link_pos_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		note_view_link_pos_unref (value->data[0].v_pointer);
	}
}

static void
note_view_value_link_pos_copy_value (const GValue* src_value,
                                     GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = note_view_link_pos_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
note_view_value_link_pos_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
note_view_value_link_pos_collect_value (GValue* value,
                                        guint n_collect_values,
                                        GTypeCValue* collect_values,
                                        guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		NoteViewLinkPos * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = note_view_link_pos_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
note_view_value_link_pos_lcopy_value (const GValue* value,
                                      guint n_collect_values,
                                      GTypeCValue* collect_values,
                                      guint collect_flags)
{
	NoteViewLinkPos ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = note_view_link_pos_ref (value->data[0].v_pointer);
	}
	return NULL;
}

static GParamSpec*
note_view_param_spec_link_pos (const gchar* name,
                               const gchar* nick,
                               const gchar* blurb,
                               GType object_type,
                               GParamFlags flags)
{
	NoteViewParamSpecLinkPos* spec;
	g_return_val_if_fail (g_type_is_a (object_type, NOTE_VIEW_TYPE_LINK_POS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

static gpointer
note_view_value_get_link_pos (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NOTE_VIEW_TYPE_LINK_POS), NULL);
	return value->data[0].v_pointer;
}

static void
note_view_value_set_link_pos (GValue* value,
                              gpointer v_object)
{
	NoteViewLinkPos * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NOTE_VIEW_TYPE_LINK_POS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, NOTE_VIEW_TYPE_LINK_POS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		note_view_link_pos_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		note_view_link_pos_unref (old);
	}
}

static void
note_view_value_take_link_pos (GValue* value,
                               gpointer v_object)
{
	NoteViewLinkPos * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, NOTE_VIEW_TYPE_LINK_POS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, NOTE_VIEW_TYPE_LINK_POS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		note_view_link_pos_unref (old);
	}
}

static void
note_view_link_pos_class_init (NoteViewLinkPosClass * klass,
                               gpointer klass_data)
{
	note_view_link_pos_parent_class = g_type_class_peek_parent (klass);
	((NoteViewLinkPosClass *) klass)->finalize = note_view_link_pos_finalize;
}

static void
note_view_link_pos_instance_init (NoteViewLinkPos * self,
                                  gpointer klass)
{
	self->ref_count = 1;
}

static void
note_view_link_pos_finalize (NoteViewLinkPos * obj)
{
	NoteViewLinkPos * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, NOTE_VIEW_TYPE_LINK_POS, NoteViewLinkPos);
	g_signal_handlers_destroy (self);
}

static GType
note_view_link_pos_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { note_view_value_link_pos_init, note_view_value_link_pos_free_value, note_view_value_link_pos_copy_value, note_view_value_link_pos_peek_pointer, "p", note_view_value_link_pos_collect_value, "p", note_view_value_link_pos_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (NoteViewLinkPosClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) note_view_link_pos_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NoteViewLinkPos), 0, (GInstanceInitFunc) note_view_link_pos_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType note_view_link_pos_type_id;
	note_view_link_pos_type_id = g_type_register_fundamental (g_type_fundamental_next (), "NoteViewLinkPos", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return note_view_link_pos_type_id;
}

static GType
note_view_link_pos_get_type (void)
{
	static volatile gsize note_view_link_pos_type_id__once = 0;
	if (g_once_init_enter (&note_view_link_pos_type_id__once)) {
		GType note_view_link_pos_type_id;
		note_view_link_pos_type_id = note_view_link_pos_get_type_once ();
		g_once_init_leave (&note_view_link_pos_type_id__once, note_view_link_pos_type_id);
	}
	return note_view_link_pos_type_id__once;
}

static gpointer
note_view_link_pos_ref (gpointer instance)
{
	NoteViewLinkPos * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
note_view_link_pos_unref (gpointer instance)
{
	NoteViewLinkPos * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		NOTE_VIEW_LINK_POS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
note_view_class_init (NoteViewClass * klass,
                      gpointer klass_data)
{
	note_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &NoteView_private_offset);
	((GtkTextViewClass *) klass)->paste_clipboard = (void (*) (GtkTextView*)) note_view_real_paste_clipboard;
	G_OBJECT_CLASS (klass)->get_property = _vala_note_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_note_view_set_property;
	G_OBJECT_CLASS (klass)->finalize = note_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTE_VIEW_TEXT_PROPERTY, note_view_properties[NOTE_VIEW_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), NOTE_VIEW_MODIFIED_PROPERTY, note_view_properties[NOTE_VIEW_MODIFIED_PROPERTY] = g_param_spec_boolean ("modified", "modified", "modified", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	note_view_signals[NOTE_VIEW_NODE_LINK_ADDED_SIGNAL] = g_signal_new ("node-link-added", TYPE_NOTE_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_INT__NODE_LINK_POINTER, G_TYPE_INT, 2, TYPE_NODE_LINK, G_TYPE_POINTER);
	note_view_signals[NOTE_VIEW_NODE_LINK_CLICKED_SIGNAL] = g_signal_new ("node-link-clicked", TYPE_NOTE_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
	note_view_signals[NOTE_VIEW_NODE_LINK_HOVER_SIGNAL] = g_signal_new ("node-link-hover", TYPE_NOTE_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
}

static void
note_view_instance_init (NoteView * self,
                         gpointer klass)
{
	self->priv = note_view_get_instance_private (self);
	self->priv->_last_lnum = -1;
	self->priv->_last_url = NULL;
	self->priv->_last_link = NULL;
	self->priv->_control = FALSE;
	self->_srcstyle = NULL;
}

static void
note_view_finalize (GObject * obj)
{
	NoteView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NOTE_VIEW, NoteView);
	_g_object_unref0 (self->priv->_win);
	_g_free0 (self->priv->_last_url);
	_g_free0 (self->priv->_last_link);
	_g_array_unref0 (self->priv->_last_urls);
	_g_array_unref0 (self->priv->_last_links);
	_g_regex_unref0 (self->priv->_url_re);
	_g_regex_unref0 (self->priv->_link_re);
	_g_object_unref0 (self->priv->_tooltip);
	_g_object_unref0 (self->priv->_group);
	_g_object_unref0 (self->_srcstyle);
	_g_object_unref0 (self->_buffer);
	G_OBJECT_CLASS (note_view_parent_class)->finalize (obj);
}

static GType
note_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (NoteViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) note_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NoteView), 0, (GInstanceInitFunc) note_view_instance_init, NULL };
	GType note_view_type_id;
	note_view_type_id = g_type_register_static (gtk_source_view_get_type (), "NoteView", &g_define_type_info, 0);
	NoteView_private_offset = g_type_add_instance_private (note_view_type_id, sizeof (NoteViewPrivate));
	return note_view_type_id;
}

GType
note_view_get_type (void)
{
	static volatile gsize note_view_type_id__once = 0;
	if (g_once_init_enter (&note_view_type_id__once)) {
		GType note_view_type_id;
		note_view_type_id = note_view_get_type_once ();
		g_once_init_leave (&note_view_type_id__once, note_view_type_id);
	}
	return note_view_type_id__once;
}

static void
_vala_note_view_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	NoteView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_NOTE_VIEW, NoteView);
	switch (property_id) {
		case NOTE_VIEW_TEXT_PROPERTY:
		g_value_take_string (value, note_view_get_text (self));
		break;
		case NOTE_VIEW_MODIFIED_PROPERTY:
		g_value_set_boolean (value, note_view_get_modified (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_note_view_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	NoteView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_NOTE_VIEW, NoteView);
	switch (property_id) {
		case NOTE_VIEW_TEXT_PROPERTY:
		note_view_set_text (self, g_value_get_string (value));
		break;
		case NOTE_VIEW_MODIFIED_PROPERTY:
		note_view_set_modified (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

