QCodeEdit  2.2
Classes | Public Member Functions | List of all members
QLanguageFactory Class Reference

A class managing language definitions. More...

Inheritance diagram for QLanguageFactory:
Inheritance graph
[legend]

Classes

struct  LangData
 

Public Member Functions

QFormatSchemedefaultFormatScheme () const
 
 QLanguageFactory (QFormatScheme *fmt, QObject *p=0)
 Empty constructor.
 
virtual ~QLanguageFactory ()
 Empty destructor.
 
QStringList languages () const
 
QStringList fileFilters () const
 
const LangDatalanguageData (const QString &lang)
 Lookup language data for a matching language. More...
 
void addDefinitionPath (const QString &path)
 Fetches syntax definitions from files in path.
 
void addLanguage (const LangData &d)
 Adds a language to the factory. More...
 
void addLanguageDefinition (QLanguageDefinition *l)
 Registers a new completion engine. More...
 
void addCompletionEngine (QCodeCompletionEngine *e)
 Registers a new completion engine. More...
 
virtual void setLanguage (QEditor *e, const QString &f)
 

Detailed Description

A class managing language definitions.

It stores language definitions, added programmatically or found in XML files, in specified locations and only if generic components are built-in. From these definitions, QLanguageFactory generates matchers, indenters and highlighters for a text editor, according to a file name.

See also
QLanguageDefinition

Member Function Documentation

◆ addCompletionEngine

void QLanguageFactory::addCompletionEngine ( QCodeCompletionEngine e)
slot

Registers a new completion engine.

Note
This engine will NOT be used if there are no language definition for the language it supports...

◆ addLanguage

void QLanguageFactory::addLanguage ( const LangData d)
slot

Adds a language to the factory.

Parameters
dlanguage data
Note
The language data will overwrite any existing one for the same language

Referenced by addDefinitionPath().

◆ addLanguageDefinition

void QLanguageFactory::addLanguageDefinition ( QLanguageDefinition l)
slot

Registers a new completion engine.

Note
This engine will NOT be used if there are no language definition for the language it supports...

◆ fileFilters()

QStringList QLanguageFactory::fileFilters ( ) const
Returns
a list of file filters supported by this factory
Note
This list is NEVER empty and the last item is always "All files (*)"

◆ languageData()

const QLanguageFactory::LangData & QLanguageFactory::languageData ( const QString &  lang)

Lookup language data for a matching language.

The primary purpose of this function is to make it easy to create configuration dialogs (mainly for format schemes). Beware though : some language may use the default format scheme. It is recommended to check for that before modifying a format scheme or users might be surprised...

Warning
This function will lead to crashes if you pass it a language name not contained in languages().

◆ languages()

QStringList QLanguageFactory::languages ( ) const
Returns
a list of languages supported by this factory

◆ setLanguage

void QLanguageFactory::setLanguage ( QEditor e,
const QString &  file 
)
virtualslot
Parameters
etarget editor
filefilename displayed by the editor

The file parameter may actuall be either a filename, an extension or the name of the language, checked in that order.

If it is a filename, complete extension as higher priority than simple extension (see QFileInfo suffix() and completeSuffix()).

Matches are first done case-sensitively.

If no matching language definition is found for all three possible interpretations of the file parameter, the same search is done case-insensitively.

If no matching language is found the previous language definition/completion engine of the editor are removed, leaving it blank, and the format scheme of the document is set to the defaultFormatScheme()

References QEditor::languageDefinition().


The documentation for this class was generated from the following files: