#include "cvector.h"
#include "cvectorvector.h"

#if VTE_CHECK_VERSION(0, 48, 0)
void
mlton_vte_pty_spawn_async (VtePty* pty,
                           SML_CVECTOR_VAL(const char, working_directory),
                           SML_CVECTORVECTOR_VAL(char, argv),
                           SML_CVECTORVECTOR_VAL(char, envv),
                           GSpawnFlags spawn_flags,
                           GSpawnChildSetupFunc child_setup,
                           gpointer child_setup_data,
                           GDestroyNotify child_setup_data_destroy,
                           int timeout,
                           GCancellable* cancellable,
                           GAsyncReadyCallback callback,
                           gpointer user_data)
{
  vte_pty_spawn_async (pty,
                       GET_SML_CVECTOR_VAL(const char, working_directory),
                       GET_SML_CVECTORVECTOR_VAL(char, argv),
                       GET_SML_CVECTORVECTOR_VAL(char, envv),
                       spawn_flags,
                       child_setup,
                       child_setup_data,
                       child_setup_data_destroy,
                       timeout,
                       cancellable,
                       callback,
                       user_data);
}
#endif

#if VTE_CHECK_VERSION(0, 62, 0)
void
mlton_vte_pty_spawn_with_fds_async (VtePty* pty,
                                    SML_CVECTOR_VAL(const char, working_directory),
                                    SML_CVECTORVECTOR_VAL(const char, argv),
                                    SML_CVECTORVECTOR_VAL(const char, envv),
                                    SML_CVECTOR_VAL(const int, fds),
                                    int n_fds,
                                    SML_CVECTOR_VAL(const int, map_fds),
                                    int n_map_fds,
                                    GSpawnFlags spawn_flags,
                                    GSpawnChildSetupFunc child_setup,
                                    gpointer child_setup_data,
                                    GDestroyNotify child_setup_data_destroy,
                                    int timeout,
                                    GCancellable* cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data)
{
  vte_pty_spawn_with_fds_async (pty,
                                GET_SML_CVECTOR_VAL(const char, working_directory),
                                GET_SML_CVECTORVECTOR_VAL(const char, argv),
                                GET_SML_CVECTORVECTOR_VAL(const char, envv),
                                GET_SML_CVECTOR_VAL(const int, fds),
                                n_fds,
                                GET_SML_CVECTOR_VAL(const int, map_fds),
                                n_map_fds,
                                spawn_flags,
                                child_setup,
                                child_setup_data,
                                child_setup_data_destroy,
                                timeout,
                                cancellable,
                                callback,
                                user_data);
}
#endif

VteRegex*
mlton_vte_regex_new_for_match (SML_CVECTOR_VAL(const char, pattern),
                               gssize pattern_length,
                               guint32 flags,
                               GError** error)
{
  return vte_regex_new_for_match (GET_SML_CVECTOR_VAL(const char, pattern),
                                  pattern_length,
                                  flags,
                                  error);
}

VteRegex*
mlton_vte_regex_new_for_search (SML_CVECTOR_VAL(const char, pattern),
                                gssize pattern_length,
                                guint32 flags,
                                GError** error)
{
  return vte_regex_new_for_search (GET_SML_CVECTOR_VAL(const char, pattern),
                                   pattern_length,
                                   flags,
                                   error);
}

#if VTE_CHECK_VERSION(0, 56, 0)
char*
mlton_vte_regex_substitute (VteRegex* regex,
                            SML_CVECTOR_VAL(const char, subject),
                            SML_CVECTOR_VAL(const char, replacement),
                            guint32 flags,
                            GError** error)
{
  return vte_regex_substitute (regex,
                               GET_SML_CVECTOR_VAL(const char, subject),
                               GET_SML_CVECTOR_VAL(const char, replacement),
                               flags,
                               error);
}
#endif

#if VTE_CHECK_VERSION(0, 44, 0)
gboolean
mlton_vte_terminal_event_check_gregex_simple (VteTerminal* terminal,
                                              GdkEvent* event,
                                              SML_CVECTOR_VAL(GRegex*, regexes),
                                              gsize n_regexes,
                                              GRegexMatchFlags match_flags,
                                              SML_CVECTORVECTOR_VAL(char, matches))
{
  return vte_terminal_event_check_gregex_simple (terminal,
                                                 event,
                                                 GET_SML_CVECTOR_VAL(GRegex*, regexes),
                                                 n_regexes,
                                                 match_flags,
                                                 GET_SML_CVECTORVECTOR_VAL(char, matches));
}
#endif

#if VTE_CHECK_VERSION(0, 62, 0)
char**
mlton_vte_terminal_event_check_regex_array (VteTerminal* terminal,
                                            GdkEvent* event,
                                            SML_CVECTOR_VAL(VteRegex*, regexes),
                                            gsize n_regexes,
                                            guint32 match_flags,
                                            gsize* n_matches)
{
  return vte_terminal_event_check_regex_array (terminal,
                                               event,
                                               GET_SML_CVECTOR_VAL(VteRegex*, regexes),
                                               n_regexes,
                                               match_flags,
                                               n_matches);
}
#endif

void
mlton_vte_terminal_feed (VteTerminal* terminal,
                         SML_CVECTOR_VAL(const char, data),
                         gssize length)
{
  vte_terminal_feed (terminal,
                     GET_SML_CVECTOR_VAL(const char, data),
                     length);
}

void
mlton_vte_terminal_feed_child (VteTerminal* terminal,
                               SML_CVECTOR_VAL(const char, text),
                               gssize length)
{
  vte_terminal_feed_child (terminal,
                           GET_SML_CVECTOR_VAL(const char, text),
                           length);
}

void
mlton_vte_terminal_feed_child_binary (VteTerminal* terminal,
                                      SML_CVECTOR_VAL(const guint8, data),
                                      gsize length)
{
  vte_terminal_feed_child_binary (terminal,
                                  GET_SML_CVECTOR_VAL(const guint8, data),
                                  length);
}

void
mlton_vte_terminal_match_set_cursor_name (VteTerminal* terminal,
                                          int tag,
                                          SML_CVECTOR_VAL(const char, cursor_name))
{
  vte_terminal_match_set_cursor_name (terminal,
                                      tag,
                                      GET_SML_CVECTOR_VAL(const char, cursor_name));
}

void
mlton_vte_terminal_set_colors (VteTerminal* terminal,
                               const GdkRGBA* foreground,
                               const GdkRGBA* background,
                               SML_CVECTOR_VAL(const GdkRGBA, palette),
                               gsize palette_size)
{
  vte_terminal_set_colors (terminal,
                           foreground,
                           background,
                           GET_SML_CVECTOR_VAL(const GdkRGBA, palette),
                           palette_size);
}

gboolean
mlton_vte_terminal_set_encoding (VteTerminal* terminal,
                                 SML_CVECTOR_VAL(const char, codeset),
                                 GError** error)
{
  return vte_terminal_set_encoding (terminal,
                                    GET_SML_CVECTOR_VAL(const char, codeset),
                                    error);
}

#if VTE_CHECK_VERSION(0, 40, 0)
void
mlton_vte_terminal_set_word_char_exceptions (VteTerminal* terminal,
                                             SML_CVECTOR_VAL(const char, exceptions))
{
  vte_terminal_set_word_char_exceptions (terminal,
                                         GET_SML_CVECTOR_VAL(const char, exceptions));
}
#endif

#if VTE_CHECK_VERSION(0, 48, 0)
void
mlton_vte_terminal_spawn_async (VteTerminal* terminal,
                                VtePtyFlags pty_flags,
                                SML_CVECTOR_VAL(const char, working_directory),
                                SML_CVECTORVECTOR_VAL(char, argv),
                                SML_CVECTORVECTOR_VAL(char, envv),
                                GSpawnFlags spawn_flags,
                                GSpawnChildSetupFunc child_setup,
                                gpointer child_setup_data,
                                GDestroyNotify child_setup_data_destroy,
                                int timeout,
                                GCancellable* cancellable,
                                VteTerminalSpawnAsyncCallback callback,
                                gpointer user_data)
{
  vte_terminal_spawn_async (terminal,
                            pty_flags,
                            GET_SML_CVECTOR_VAL(const char, working_directory),
                            GET_SML_CVECTORVECTOR_VAL(char, argv),
                            GET_SML_CVECTORVECTOR_VAL(char, envv),
                            spawn_flags,
                            child_setup,
                            child_setup_data,
                            child_setup_data_destroy,
                            timeout,
                            cancellable,
                            callback,
                            user_data);
}
#endif

gboolean
mlton_vte_terminal_spawn_sync (VteTerminal* terminal,
                               VtePtyFlags pty_flags,
                               SML_CVECTOR_VAL(const char, working_directory),
                               SML_CVECTORVECTOR_VAL(char, argv),
                               SML_CVECTORVECTOR_VAL(char, envv),
                               GSpawnFlags spawn_flags,
                               GSpawnChildSetupFunc child_setup,
                               gpointer child_setup_data,
                               GPid* child_pid,
                               GCancellable* cancellable,
                               GError** error)
{
  return vte_terminal_spawn_sync (terminal,
                                  pty_flags,
                                  GET_SML_CVECTOR_VAL(const char, working_directory),
                                  GET_SML_CVECTORVECTOR_VAL(char, argv),
                                  GET_SML_CVECTORVECTOR_VAL(char, envv),
                                  spawn_flags,
                                  child_setup,
                                  child_setup_data,
                                  child_pid,
                                  cancellable,
                                  error);
}

#if VTE_CHECK_VERSION(0, 62, 0)
void
mlton_vte_terminal_spawn_with_fds_async (VteTerminal* terminal,
                                         VtePtyFlags pty_flags,
                                         SML_CVECTOR_VAL(const char, working_directory),
                                         SML_CVECTORVECTOR_VAL(const char, argv),
                                         SML_CVECTORVECTOR_VAL(const char, envv),
                                         SML_CVECTOR_VAL(const int, fds),
                                         int n_fds,
                                         SML_CVECTOR_VAL(const int, map_fds),
                                         int n_map_fds,
                                         GSpawnFlags spawn_flags,
                                         GSpawnChildSetupFunc child_setup,
                                         gpointer child_setup_data,
                                         GDestroyNotify child_setup_data_destroy,
                                         int timeout,
                                         GCancellable* cancellable,
                                         VteTerminalSpawnAsyncCallback callback,
                                         gpointer user_data)
{
  vte_terminal_spawn_with_fds_async (terminal,
                                     pty_flags,
                                     GET_SML_CVECTOR_VAL(const char, working_directory),
                                     GET_SML_CVECTORVECTOR_VAL(const char, argv),
                                     GET_SML_CVECTORVECTOR_VAL(const char, envv),
                                     GET_SML_CVECTOR_VAL(const int, fds),
                                     n_fds,
                                     GET_SML_CVECTOR_VAL(const int, map_fds),
                                     n_map_fds,
                                     spawn_flags,
                                     child_setup,
                                     child_setup_data,
                                     child_setup_data_destroy,
                                     timeout,
                                     cancellable,
                                     callback,
                                     user_data);
}
#endif

#if VTE_CHECK_VERSION(0, 60, 0)
gboolean
mlton_vte_get_encoding_supported (SML_CVECTOR_VAL(const char, encoding))
{
  return vte_get_encoding_supported (GET_SML_CVECTOR_VAL(const char, encoding));
}
#endif
