eb05362005-11-05Henrik Grubbström (Grubba) /* -*- C -*- */
08367e2005-11-04Lance Dillon require gtksourceview; class GTK2.SourceLanguage; inherit G.Object; %{ #include "gtksourceview/gtksourceview.h" %} signal tag_style_changed; string get_name(); //! Returns the localized name of the language. string get_section(); //! Returns the localized section of the language. Each language belongs to a //! section (ex. HTML belongs to the Markup section).
b1f1782011-10-30Henrik Grubbström (Grubba) not gtksourceview20;
08367e2005-11-04Lance Dillon array(GTK2.SourceTag) get_tags() //! Returns a list of tags for this language. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
08367e2005-11-04Lance Dillon  { GSList *gsl,*gs2; int i=0; gsl=gs2=gtk_source_language_get_tags(GTK_SOURCE_LANGUAGE(THIS->obj)); while (gs2) {
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(gs2->data,pgtk2_source_tag_program);
08367e2005-11-04Lance Dillon  i++; gs2=g_slist_next(gs2); } f_aggregate(i); g_slist_free(gsl); } } int get_escape_char(); //! Gets the value of the ESC character in the given language. array(string) get_mime_types() //! Returns a list of mime types for this language. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
08367e2005-11-04Lance Dillon  { GSList *gsl,*gs2; int i=0; gsl=gs2=gtk_source_language_get_mime_types(GTK_SOURCE_LANGUAGE(THIS->obj)); while (gs2) {
74a5dd2010-09-19Marcus Comstedt  PGTK_PUSH_GCHAR(gs2->data);
08367e2005-11-04Lance Dillon  g_free(gs2->data); i++; gs2=g_slist_next(gs2); } f_aggregate(i); g_slist_free(gsl); } } void set_mime_types(?array(string) types) //! Sets a list of mime types for this language. If omitted, this function //! will use the default mime types from the language file. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
08367e2005-11-04Lance Dillon  if (args) { struct array *a; GSList *gsl=NULL; get_all_args("set_mime_types",args,"%A",&a); if (a==NULL || a->size<1) { gtk_source_language_set_mime_types(GTK_SOURCE_LANGUAGE(THIS->obj),NULL); } else { int i; for (i=0; i<a->size; i++) {
5a17b52011-10-30Henrik Grubbström (Grubba)  if (TYPEOF(ITEM(a)[i]) != PIKE_T_STRING)
08367e2005-11-04Lance Dillon  continue; gsl=g_slist_prepend(gsl,STR0((ITEM(a)+i)->u.string)); } gtk_source_language_set_mime_types(GTK_SOURCE_LANGUAGE(THIS->obj),gsl); g_slist_free(gsl); } } else { gtk_source_language_set_mime_types(GTK_SOURCE_LANGUAGE(THIS->obj),NULL); } RETURN_THIS(); } GTK2.SourceStyleScheme get_style_scheme() //! Gets the style scheme associated with this language. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited(); pgtk2_pop_n_elems(args);
08367e2005-11-04Lance Dillon  { GtkSourceStyleScheme *gss; gss=gtk_source_language_get_style_scheme(GTK_SOURCE_LANGUAGE(THIS->obj));
ba9e802006-02-27Martin Stjernholm  push_gobjectclass(gss,pgtk2_source_style_scheme_program);
08367e2005-11-04Lance Dillon  } } mapping(string:mixed) get_tag_style(string id) //! Gets the style of the tag id. If the style is not defined, then returns //! the default style. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
08367e2005-11-04Lance Dillon  { GtkSourceTagStyle *gs; GdkColor *fg,*bg; char *id; get_all_args("get_tag_style",args,"%s",&id); gs=gtk_source_language_get_tag_style(GTK_SOURCE_LANGUAGE(THIS->obj),id);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
08367e2005-11-04Lance Dillon  if (gs) {
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("default")); push_int(gs->is_default); ref_push_string(_STR("mask")); push_int(gs->mask);
08367e2005-11-04Lance Dillon  fg=(GdkColor *)g_malloc(sizeof(GdkColor));
32353e2005-12-30Martin Nilsson  if (fg==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_tag_style",sizeof(GdkColor));
08367e2005-11-04Lance Dillon  bg=(GdkColor *)g_malloc(sizeof(GdkColor));
32353e2005-12-30Martin Nilsson  if (bg==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_tag_style",sizeof(GdkColor));
08367e2005-11-04Lance Dillon  *fg=gs->foreground; *bg=gs->background;
e0b3b22008-01-30Per Hedbor  ref_push_string(_STR("foreground")); push_gdkobject(fg,color,1); ref_push_string(_STR("background")); push_gdkobject(bg,color,1);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("italic")); push_int(gs->italic); ref_push_string(_STR("bold")); push_int(gs->bold); ref_push_string(_STR("underline")); push_int(gs->underline); ref_push_string(_STR("strikethrough")); push_int(gs->strikethrough);
08367e2005-11-04Lance Dillon  f_aggregate_mapping(16); } else push_int(0); } } void set_tag_style(string id, ?mapping(string:mixed) style) //! Sets the style of the tag id. If style is omitted, this function will //! restore the default style. {
d01ab82005-12-28Martin Nilsson  char *id; struct mapping *m=NULL;
fc18fb2008-01-18Henrik Grubbström (Grubba)  GtkSourceTagStyle *sts = NULL;
d01ab82005-12-28Martin Nilsson 
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
d01ab82005-12-28Martin Nilsson  get_all_args("set_tag_style",args,"%s.%m",&id,&m); if (m) {
08367e2005-11-04Lance Dillon  struct svalue *sv; sts=gtk_source_tag_style_new(); if (sts==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("set_bracket_match_style",sizeof(GtkSourceTagStyle));
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("default"));
08367e2005-11-04Lance Dillon  if (sv) sts->is_default=PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("mask"));
08367e2005-11-04Lance Dillon  if (sv) sts->mask=PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("foreground"));
08367e2005-11-04Lance Dillon  if (sv) {
5a17b52011-10-30Henrik Grubbström (Grubba)  if (TYPEOF(*sv) == PIKE_T_OBJECT && get_gdkobject(sv->u.object,color))
08367e2005-11-04Lance Dillon  sts->foreground=*(GdkColor *)get_gdkobject(sv->u.object,color); }
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("background"));
08367e2005-11-04Lance Dillon  if (sv) {
5a17b52011-10-30Henrik Grubbström (Grubba)  if (TYPEOF(*sv) == PIKE_T_OBJECT && get_gdkobject(sv->u.object,color))
08367e2005-11-04Lance Dillon  sts->background=*(GdkColor *)get_gdkobject(sv->u.object,color); }
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("italic"));
08367e2005-11-04Lance Dillon  if (sv) sts->italic=PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("bold"));
08367e2005-11-04Lance Dillon  if (sv) sts->bold=PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("underline"));
08367e2005-11-04Lance Dillon  if (sv) sts->underline=PGTK_GETINT(sv);
f1ddfb2006-01-14Martin Nilsson  sv=low_mapping_string_lookup(m,_STR("strikethrough"));
08367e2005-11-04Lance Dillon  if (sv) sts->strikethrough=PGTK_GETINT(sv); }
d01ab82005-12-28Martin Nilsson 
fc18fb2008-01-18Henrik Grubbström (Grubba)  gtk_source_language_set_tag_style(GTK_SOURCE_LANGUAGE(THIS->obj), id, sts);
d01ab82005-12-28Martin Nilsson  if(sts) gtk_source_tag_style_free(sts);
08367e2005-11-04Lance Dillon  RETURN_THIS(); } mapping(string:mixed) get_tag_default_style(string id) //! Gets the default style of the tag id. {
ba9e802006-02-27Martin Stjernholm  pgtk2_verify_inited();
08367e2005-11-04Lance Dillon  { GtkSourceTagStyle *gs; GdkColor *fg,*bg; char *id; get_all_args("get_tag_default_style",args,"%s",&id); gs=gtk_source_language_get_tag_default_style(GTK_SOURCE_LANGUAGE(THIS->obj), id);
ba9e802006-02-27Martin Stjernholm  pgtk2_pop_n_elems(args);
08367e2005-11-04Lance Dillon  if (gs) {
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("default")); push_int(gs->is_default); ref_push_string(_STR("mask")); push_int(gs->mask);
08367e2005-11-04Lance Dillon  fg=(GdkColor *)g_malloc(sizeof(GdkColor));
32353e2005-12-30Martin Nilsson  if (fg==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_tag_default_style",sizeof(GdkColor));
08367e2005-11-04Lance Dillon  bg=(GdkColor *)g_malloc(sizeof(GdkColor));
32353e2005-12-30Martin Nilsson  if (bg==NULL) SIMPLE_OUT_OF_MEMORY_ERROR("get_tag_default_style",sizeof(GdkColor));
08367e2005-11-04Lance Dillon  *fg=gs->foreground; *bg=gs->background;
e0b3b22008-01-30Per Hedbor  ref_push_string(_STR("foreground")); push_gdkobject(fg,color,1); ref_push_string(_STR("background")); push_gdkobject(bg,color,1);
9fb5032006-01-14Martin Nilsson  ref_push_string(_STR("italic")); push_int(gs->italic); ref_push_string(_STR("bold")); push_int(gs->bold); ref_push_string(_STR("underline")); push_int(gs->underline); ref_push_string(_STR("strikethrough")); push_int(gs->strikethrough);
08367e2005-11-04Lance Dillon  f_aggregate_mapping(16); } else push_int(0); } }
b1f1782011-10-30Henrik Grubbström (Grubba)  endrequire;