gi-gtksource-3.0.15: GtkSource bindings

CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria (garetxe@gmail.com)
Safe HaskellNone
LanguageHaskell2010

GI.GtkSource.Objects.LanguageManager

Contents

Description

 

Synopsis

Exported types

Methods

getDefault

languageManagerGetDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m LanguageManager

Returns: a LanguageManager. Return value is owned by GtkSourceView library and must not be unref'ed.

Returns the default LanguageManager instance.

getLanguage

languageManagerGetLanguage Source #

Arguments

:: (HasCallStack, MonadIO m, IsLanguageManager a) 
=> a

lm: a LanguageManager.

-> Text

id: a language id.

-> m (Maybe Language)

Returns: a Language, or Nothing if there is no language identified by the given id. Return value is owned by lm and should not be freed.

Gets the Language identified by the given id in the language manager.

getLanguageIds

languageManagerGetLanguageIds Source #

Arguments

:: (HasCallStack, MonadIO m, IsLanguageManager a) 
=> a

lm: a LanguageManager.

-> m (Maybe [Text])

Returns: a Nothing-terminated array of strings containing the ids of the available languages or Nothing if no language is available. The array is sorted alphabetically according to the language name. The array is owned by lm and must not be modified.

Returns the ids of the available languages.

getSearchPath

languageManagerGetSearchPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsLanguageManager a) 
=> a

lm: a LanguageManager.

-> m [Text]

Returns: Nothing-terminated array containg a list of language files directories. The array is owned by lm and must not be modified.

Gets the list directories where lm looks for language files.

guessLanguage

languageManagerGuessLanguage Source #

Arguments

:: (HasCallStack, MonadIO m, IsLanguageManager a) 
=> a

lm: a LanguageManager.

-> Maybe Text

filename: a filename in Glib filename encoding, or Nothing.

-> Maybe Text

contentType: a content type (as in GIO API), or Nothing.

-> m (Maybe Language)

Returns: a Language, or Nothing if there is no suitable language for given filename and/or contentType. Return value is owned by lm and should not be freed.

Picks a Language for given file name and content type, according to the information in lang files. Either filename or contentType may be Nothing. This function can be used as follows:

<informalexample><programlisting> GtkSourceLanguage *lang; lang = gtk_source_language_manager_guess_language (filename, NULL); gtk_source_buffer_set_language (buffer, lang); </programlisting></informalexample>

or

<informalexample><programlisting> GtkSourceLanguage *lang = NULL; 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; }

lang = gtk_source_language_manager_guess_language (manager, filename, content_type); gtk_source_buffer_set_language (buffer, lang);

g_free (content_type); </programlisting></informalexample>

etc. Use languageGetMimeTypes and languageGetGlobs if you need full control over file -> language mapping.

Since: 2.4

new

languageManagerNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m LanguageManager

Returns: a new LanguageManager.

Creates a new language manager. If you do not need more than one language manager or a private language manager instance then use languageManagerGetDefault instead.

setSearchPath

languageManagerSetSearchPath Source #

Arguments

:: (HasCallStack, MonadIO m, IsLanguageManager a) 
=> a

lm: a LanguageManager.

-> Maybe [Text]

dirs: a Nothing-terminated array of strings or Nothing.

-> m () 

Sets the list of directories where the lm looks for language files. If dirs is Nothing, the search path is reset to default.

<note> <para> 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 LanguageManager, you have to call this function right after creating it. </para> </note>

Properties

languageIds

searchPath