gtksourceviewmm: gtksourceview::SourceLanguageManager Class Reference
Class which provides access to SourceLanguages. More...
#include <gtksourceviewmm/sourcelanguagemanager.h>

Public Member Functions | |
| GtkSourceLanguageManager* | gobj () |
| Provides access to the underlying C GObject. | |
| const GtkSourceLanguageManager* | gobj () const |
| Provides access to the underlying C GObject. | |
| GtkSourceLanguageManager* | gobj_copy () |
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
| Glib::StringArrayHandle | get_search_path () const |
| Gets the list directories where language manager looks for language files. | |
| void | set_search_path (const Glib::StringArrayHandle& dirs) |
| Sets the list of directories where the language manager looks for language files. | |
| void | reset_search_path () |
| Resets the list of directories where the language manager looks for language files to default. | |
| Glib::StringArrayHandle | get_language_ids () const |
| Returns the ids of the available languages. | |
| Glib::RefPtr< SourceLanguage > | get_language (const Glib::ustring& id) |
| Gets the SourceLanguage identified by the given id in the language manager. | |
| Glib::RefPtr< const SourceLanguage > | get_language (const Glib::ustring& id) const |
| Gets the SourceLanguage identified by the given id in the language manager. | |
| Glib::RefPtr< SourceLanguage > | guess_language (const Glib::ustring& filename, const Glib::ustring& content_type) |
| Picks a SourceLanguage for given file name and content type, according to the information in lang files. | |
| Glib::RefPtr< const SourceLanguage > | guess_language (const Glib::ustring& filename, const Glib::ustring& content_type) const |
| Picks a SourceLanguage for given file name and content type, according to the information in lang files. | |
Static Public Member Functions | |
| static Glib::RefPtr < SourceLanguageManager > | create () |
| Creates a new language manager. | |
| static Glib::RefPtr < SourceLanguageManager > | get_default () |
| Returns the default SourceLanguageManager instance. | |
Related Functions | |
(Note that these are not member functions.) | |
| Glib::RefPtr < gtksourceview::SourceLanguageManager > | wrap (GtkSourceLanguageManager* object, bool take_copy=false) |
| A Glib::wrap() method for this object. | |
Detailed Description
Class which provides access to SourceLanguages.
SourceLanguageManager is a class which processes language description files and creates and stores SourceLanguage objects, and provides API to access them.
Use get_default() to retrieve the default instance of SourceLanguageManager, and guess_language() to get a SourceLanguage for given file name and content type.
Member Function Documentation
| static Glib::RefPtr<SourceLanguageManager> gtksourceview::SourceLanguageManager::create | ( | ) | [static] |
Creates a new language manager.
If you do not need more than one language manager or a private language manager instance then use get_default() instead.
Returns: A SourceLanguageManager.
| static Glib::RefPtr<SourceLanguageManager> gtksourceview::SourceLanguageManager::get_default | ( | ) | [static] |
Returns the default SourceLanguageManager instance.
Returns: A SourceLanguageManager.
| Glib::RefPtr<SourceLanguage> gtksourceview::SourceLanguageManager::get_language | ( | const Glib::ustring & | id | ) |
Gets the SourceLanguage identified by the given id in the language manager.
- Parameters:
-
id A language id.
- Returns:
- A SourceLanguage, or empty Glib::RefPtr if there is no language identified by the given id.
| Glib::RefPtr<const SourceLanguage> gtksourceview::SourceLanguageManager::get_language | ( | const Glib::ustring & | id | ) | const |
Gets the SourceLanguage identified by the given id in the language manager.
- Parameters:
-
id A language id.
- Returns:
- A SourceLanguage, or empty Glib::RefPtr if there is no language identified by the given id.
| Glib::StringArrayHandle gtksourceview::SourceLanguageManager::get_language_ids | ( | ) | const |
Returns the ids of the available languages.
- Returns:
- An array of string containing the ids of the available languages.
| Glib::StringArrayHandle gtksourceview::SourceLanguageManager::get_search_path | ( | ) | const |
Gets the list directories where language manager looks for language files.
- Returns:
- An array containg a list of language files directories.
| Glib::RefPtr<SourceLanguage> gtksourceview::SourceLanguageManager::guess_language | ( | const Glib::ustring & | filename, |
| const Glib::ustring & | content_type | ||
| ) |
Picks a SourceLanguage for given file name and content type, according to the information in lang files.
Either filename or content_type may be an empty string. This function can be used as follows:
Glib::RefPtr<SourceLanguage> lang; lang = lm->guess_language(filename, Glib::ustring()); buffer->set_language(lang);
or
Glib::RefPtr<SourceLanguage> lang; bool result_uncertain = FALSE; Glib::ustring content_type; content_type = Gio::content_type_guess(filename, 0, 0, &result_uncertain); if (result_uncertain) { content_type.clear(); } lang = lm->guess_language(filename, content_type); buffer->set_language(lang);
etc. Use get_mime_types() and get_globs() if you need full control over file -> language mapping.
- Parameters:
-
filename A filename, or empty string. content_type A content type (as in GIO API), or empty string.
- Returns:
- A SourceLanguage, or empty Glib::RefPtr if there is no suitable language for given filename and/or content_type.
| Glib::RefPtr<const SourceLanguage> gtksourceview::SourceLanguageManager::guess_language | ( | const Glib::ustring & | filename, |
| const Glib::ustring & | content_type | ||
| ) | const |
Picks a SourceLanguage for given file name and content type, according to the information in lang files.
Either filename or content_type may be an empty string. This function can be used as follows:
Glib::RefPtr<SourceLanguageManager> lm = SourceLanguageManager::get_default(); Glib::RefPtr<SourceLanguage> lang; Glib::RefPtr<SourceBuffer> buffer = SourceBuffer::create(); lang = lm->guess_language(filename, Glib::ustring()); buffer->set_language(lang); // or just: // Glib::RefPtr<SourceBuffer> buffer = SourceBuffer::create(lang);
or
Glib::RefPtr<SourceLanguage> lang; Glib::RefPtr<SourceLanguageManager> lm = SourceLanguageManager::get_default(); Glib::RefPtr<SourceBuffer> buffer = SourceBuffer::create(); bool result_uncertain = FALSE; Glib::ustring content_type; content_type = Gio::content_type_guess(filename, 0, 0, &result_uncertain); if (result_uncertain) { content_type.clear(); } lang = lm->guess_language(filename, content_type); buffer->set_language(lang); // or just: // Glib::RefPtr<SourceBuffer> buffer = SourceBuffer::create(lang);
etc. Use SourceLanguage::get_mime_types() and SourceLanguage::get_globs() if you need full control over file -> language mapping.
- Parameters:
-
filename A filename, or empty string. content_type A content type (as in GIO API), or empty string.
- Returns:
- A SourceLanguage, or empty Glib::RefPtr if there is no suitable language for given filename and/or content_type.
| void gtksourceview::SourceLanguageManager::reset_search_path | ( | ) |
Resets the list of directories where the language manager looks for language files to default.
- Note:
- At the moment this function can be called only before the language files are loaded for the first time. In practice to set a custom search path for a SourceLanguageManager, you have to call this function right after creating it.
| void gtksourceview::SourceLanguageManager::set_search_path | ( | const Glib::StringArrayHandle & | dirs | ) |
Sets the list of directories where the language manager looks for language files.
- Note:
- At the moment this function can be called only before the language files are loaded for the first time. In practice to set a custom search path for a SourceLanguageManager, you have to call this function right after creating it.
- Parameters:
-
dirs An empty string terminated array of strings.
Friends And Related Function Documentation
| Glib::RefPtr< gtksourceview::SourceLanguageManager > wrap | ( | GtkSourceLanguageManager * | object, |
| bool | take_copy = false |
||
| ) | [related] |
A Glib::wrap() method for this object.
- Parameters:
-
object The C instance. take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
- Returns:
- A C++ instance that wraps this C instance.
