Class: GtkSource::LanguageManager
- Inherits:
-
Object
- Object
- GtkSource::LanguageManager
- Defined in:
- (unknown)
Class Method Summary collapse
-
.default ⇒ GtkSource::LanguageManager
Returns the default Gtk::SourceLanguageManager instance.
Instance Method Summary collapse
-
#append_search_path(path) ⇒ nil
Appends path to the list of directories where the manager looks for language files.
-
#get_language(id) ⇒ GtkSource::Language
Gets the [classLanguage] identified by the given id in the language manager.
-
#guess_language(filename, content_type) ⇒ GtkSource::Language
Picks a [classLanguage] for given file name and content type, according to the information in lang files.
-
#initialize ⇒ GtkSource::LanguageManager
constructor
Creates a new language manager.
-
#language_ids ⇒ GtkSource::
Language-ids.
- #language_ids=(language_ids) ⇒ GtkSource::
-
#prepend_search_path(path) ⇒ nil
Prepends path to the list of directories where the manager looks for language files.
-
#search_path ⇒ GtkSource::
Search-path.
- #search_path=(search_path) ⇒ GtkSource::
Constructor Details
#initialize ⇒ GtkSource::LanguageManager
Creates a new language manager.
If you do not need more than one language manager or a private language manager instance then use [funcLanguageManager.get_default] instead.
Class Method Details
.default ⇒ GtkSource::LanguageManager
Returns the default Gtk::SourceLanguageManager instance. Return value is owned by GtkSourceView library and must not be unref'ed.
Instance Method Details
#append_search_path(path) ⇒ nil
Appends path to the list of directories where the manager looks for language files.
See [methodLanguageManager.set_search_path] for details.
#get_language(id) ⇒ GtkSource::Language
Gets the [classLanguage] identified by the given id in the language manager. if there is no language identified by the given id. Return value is owned by lm and should not be freed.
#guess_language(filename, content_type) ⇒ GtkSource::Language
Picks a [classLanguage] for given file name and content type, according to the information in lang files.
Either filename or content_type may be nil. This function can be used as follows:
GtkSourceLanguage *lang;
GtkSourceLanguageManager *manager;
lm = gtk_source_language_manager_get_default ();
lang = gtk_source_language_manager_guess_language (manager, filename, NULL);
gtk_source_buffer_set_language (buffer, lang);
or
GtkSourceLanguage *lang = NULL;
GtkSourceLanguageManager *manager;
gboolean result_uncertain;
gchar *content_type;
content_type = g_content_type_guess (filename, NULL, 0, &result_uncertain);
if (result_uncertain)
{
g_free (content_type);
content_type = NULL;
}
manager = gtk_source_language_manager_get_default ();
lang = gtk_source_language_manager_guess_language (manager, filename, content_type);
gtk_source_buffer_set_language (buffer, lang);
g_free (content_type);
etc. Use [methodLanguage.get_mime_types] and [methodLanguage.get_globs] if you need full control over file -> language mapping. is no suitable language for given filename and/or content_type. Return value is owned by lm and should not be freed.
#language_ids ⇒ GtkSource::
Returns language-ids.
#language_ids=(language_ids) ⇒ GtkSource::
#prepend_search_path(path) ⇒ nil
Prepends path to the list of directories where the manager looks for language files.
See [methodLanguageManager.set_search_path] for details.
#search_path ⇒ GtkSource::
Returns search-path.