Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Provides access to [classlanguage
]s.
GtkSourceLanguageManager
is an object which processes language description
files and creates and stores [classlanguage
] objects, and provides API to
access them.
Use LanguageManager.get_default
to retrieve the default
instance of GtkSourceLanguageManager
, and
[methodlanguageManager
.guess_language] to get a [classlanguage
] for
given file name and content type.
Synopsis
- newtype LanguageManager = LanguageManager (ManagedPtr LanguageManager)
- class (GObject o, IsDescendantOf LanguageManager o) => IsLanguageManager o
- toLanguageManager :: (MonadIO m, IsLanguageManager o) => o -> m LanguageManager
- languageManagerAppendSearchPath :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> Text -> m ()
- languageManagerGetDefault :: (HasCallStack, MonadIO m) => m LanguageManager
- languageManagerGetLanguage :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> Text -> m (Maybe Language)
- languageManagerGetLanguageIds :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> m (Maybe [Text])
- languageManagerGetSearchPath :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> m [Text]
- languageManagerGuessLanguage :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> Maybe [Char] -> Maybe Text -> m (Maybe Language)
- languageManagerNew :: (HasCallStack, MonadIO m) => m LanguageManager
- languageManagerPrependSearchPath :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> Text -> m ()
- languageManagerSetSearchPath :: (HasCallStack, MonadIO m, IsLanguageManager a) => a -> Maybe [Text] -> m ()
- getLanguageManagerLanguageIds :: (MonadIO m, IsLanguageManager o) => o -> m (Maybe [Text])
- clearLanguageManagerSearchPath :: (MonadIO m, IsLanguageManager o) => o -> m ()
- constructLanguageManagerSearchPath :: (IsLanguageManager o, MonadIO m) => [Text] -> m (GValueConstruct o)
- getLanguageManagerSearchPath :: (MonadIO m, IsLanguageManager o) => o -> m [Text]
- setLanguageManagerSearchPath :: (MonadIO m, IsLanguageManager o) => o -> [Text] -> m ()
Exported types
newtype LanguageManager Source #
Memory-managed wrapper type.
LanguageManager (ManagedPtr LanguageManager) |
Instances
class (GObject o, IsDescendantOf LanguageManager o) => IsLanguageManager o Source #
Type class for types which can be safely cast to LanguageManager
, for instance with toLanguageManager
.
Instances
(GObject o, IsDescendantOf LanguageManager o) => IsLanguageManager o Source # | |
Defined in GI.GtkSource.Objects.LanguageManager |
toLanguageManager :: (MonadIO m, IsLanguageManager o) => o -> m LanguageManager Source #
Cast to LanguageManager
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
appendSearchPath, bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, guessLanguage, isFloating, notify, notifyByPspec, prependSearchPath, ref, refSink, runDispose, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getLanguage, getLanguageIds, getProperty, getQdata, getSearchPath.
Setters
appendSearchPath
languageManagerAppendSearchPath Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> Text |
|
-> m () |
Appends path
to the list of directories where the manager
looks for
language files.
See [methodlanguageManager
.set_search_path] for details.
Since: 5.4
getDefault
languageManagerGetDefault Source #
:: (HasCallStack, MonadIO m) | |
=> m LanguageManager | Returns: a |
Returns the default LanguageManager
instance.
getLanguage
languageManagerGetLanguage Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> Text |
|
-> m (Maybe Language) | Returns: a |
Gets the [classlanguage
] identified by the given id
in the language
manager.
getLanguageIds
languageManagerGetLanguageIds Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> m (Maybe [Text]) | Returns:
a |
Returns the ids of the available languages.
getSearchPath
languageManagerGetSearchPath Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> m [Text] | Returns: |
Gets the list directories where lm
looks for language files.
guessLanguage
languageManagerGuessLanguage Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> Maybe [Char] |
|
-> Maybe Text |
|
-> m (Maybe Language) | Returns: a |
Picks a [classlanguage
] 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:
c code
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
c code
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.
new
:: (HasCallStack, MonadIO m) | |
=> m LanguageManager | Returns: a new |
Creates a new language manager.
If you do not need more than one language manager or a private language manager
instance then use LanguageManager.get_default
instead.
prependSearchPath
languageManagerPrependSearchPath Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> Text |
|
-> m () |
Prepends path
to the list of directories where the manager
looks
for language files.
See [methodlanguageManager
.set_search_path] for details.
Since: 5.4
setSearchPath
languageManagerSetSearchPath Source #
:: (HasCallStack, MonadIO m, IsLanguageManager a) | |
=> a |
|
-> Maybe [Text] | |
-> m () |
Sets the list of directories where the lm
looks for
language files.
If dirs
is Nothing
, the search path is reset to default.
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 GtkSourceLanguageManager
,
you have to call this function right after creating it.
Since GtkSourceView 5.4 this function will allow you to provide
paths in the form of "resource:///" URIs to embedded GResource
s.
They must contain the path of a directory within the GResource
.
Properties
languageIds
No description available in the introspection data.
getLanguageManagerLanguageIds :: (MonadIO m, IsLanguageManager o) => o -> m (Maybe [Text]) Source #
Get the value of the “language-ids
” property.
When overloading is enabled, this is equivalent to
get
languageManager #languageIds
searchPath
No description available in the introspection data.
clearLanguageManagerSearchPath :: (MonadIO m, IsLanguageManager o) => o -> m () Source #
Set the value of the “search-path
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#searchPath
constructLanguageManagerSearchPath :: (IsLanguageManager o, MonadIO m) => [Text] -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “search-path
” property. This is rarely needed directly, but it is used by new
.
getLanguageManagerSearchPath :: (MonadIO m, IsLanguageManager o) => o -> m [Text] Source #
Get the value of the “search-path
” property.
When overloading is enabled, this is equivalent to
get
languageManager #searchPath
setLanguageManagerSearchPath :: (MonadIO m, IsLanguageManager o) => o -> [Text] -> m () Source #
Set the value of the “search-path
” property.
When overloading is enabled, this is equivalent to
set
languageManager [ #searchPath:=
value ]