mirror of https://github.com/KLayout/klayout.git
Fixed issue-1477 (Macro IDE: changing the colors does not have an effect)
This commit is contained in:
parent
5c0f810006
commit
d31a084748
|
|
@ -148,18 +148,18 @@ MacroEditorHighlighters::MacroEditorHighlighters (QObject *parent)
|
|||
|
||||
for (std::vector<std::pair<std::string, GenericSyntaxHighlighterAttributes> >::iterator a = m_attributes.begin (); a != m_attributes.end (); ++a) {
|
||||
// Note: this loads and initializes the attributes
|
||||
delete highlighter_for_scheme (parent, a->first, &a->second);
|
||||
delete highlighter_for_scheme (parent, a->first, &a->second, true);
|
||||
}
|
||||
}
|
||||
|
||||
QSyntaxHighlighter *
|
||||
MacroEditorHighlighters::highlighter_for (QObject *parent, lym::Macro::Interpreter lang, const std::string &dsl_name)
|
||||
MacroEditorHighlighters::highlighter_for (QObject *parent, lym::Macro::Interpreter lang, const std::string &dsl_name, bool initialize)
|
||||
{
|
||||
std::string scheme = scheme_for (lang, dsl_name);
|
||||
|
||||
for (std::vector<std::pair<std::string, GenericSyntaxHighlighterAttributes> >::iterator a = m_attributes.begin (); a != m_attributes.end (); ++a) {
|
||||
if (a->first == scheme) {
|
||||
return highlighter_for_scheme (parent, a->first, &a->second);
|
||||
return highlighter_for_scheme (parent, a->first, &a->second, initialize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ MacroEditorHighlighters::highlighter_for (QObject *parent, lym::Macro::Interpret
|
|||
}
|
||||
|
||||
lay::GenericSyntaxHighlighter *
|
||||
MacroEditorHighlighters::highlighter_for_scheme (QObject *parent, const std::string &scheme, GenericSyntaxHighlighterAttributes *attributes)
|
||||
MacroEditorHighlighters::highlighter_for_scheme (QObject *parent, const std::string &scheme, GenericSyntaxHighlighterAttributes *attributes, bool initialize)
|
||||
{
|
||||
if (! scheme.empty ()) {
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ MacroEditorHighlighters::highlighter_for_scheme (QObject *parent, const std::str
|
|||
|
||||
QBuffer input (&data);
|
||||
input.open (QIODevice::ReadOnly);
|
||||
lay::GenericSyntaxHighlighter *hl = new GenericSyntaxHighlighter (parent, input, attributes);
|
||||
lay::GenericSyntaxHighlighter *hl = new GenericSyntaxHighlighter (parent, input, attributes, initialize);
|
||||
input.close ();
|
||||
|
||||
return hl;
|
||||
|
|
@ -1096,7 +1096,7 @@ void MacroEditorPage::connect_macro (lym::Macro *macro)
|
|||
mp_text->setPlainText (tl::to_qstring (mp_macro->text ()));
|
||||
mp_text->setReadOnly (macro->is_readonly ());
|
||||
mp_readonly_label->setVisible (macro->is_readonly ());
|
||||
mp_highlighter = mp_highlighters->highlighter_for (mp_text, mp_macro->interpreter (), mp_macro->dsl_interpreter ());
|
||||
mp_highlighter = mp_highlighters->highlighter_for (mp_text, mp_macro->interpreter (), mp_macro->dsl_interpreter (), false);
|
||||
if (mp_highlighter) {
|
||||
mp_highlighter->setDocument (mp_text->document ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class MacroEditorHighlighters
|
|||
public:
|
||||
MacroEditorHighlighters (QObject *parent);
|
||||
|
||||
QSyntaxHighlighter *highlighter_for (QObject *parent, lym::Macro::Interpreter lang, const std::string &dsl_name);
|
||||
QSyntaxHighlighter *highlighter_for (QObject *parent, lym::Macro::Interpreter lang, const std::string &dsl_name, bool initialize);
|
||||
|
||||
GenericSyntaxHighlighterAttributes *attributes_for (lym::Macro::Interpreter lang, const std::string &dsl_name);
|
||||
GenericSyntaxHighlighterAttributes *basic_attributes ();
|
||||
|
|
@ -98,7 +98,7 @@ private:
|
|||
std::vector<std::pair<std::string, GenericSyntaxHighlighterAttributes> > m_attributes;
|
||||
GenericSyntaxHighlighterAttributes m_basic_attributes;
|
||||
|
||||
lay::GenericSyntaxHighlighter *highlighter_for_scheme (QObject *parent, const std::string &scheme, GenericSyntaxHighlighterAttributes *attributes);
|
||||
lay::GenericSyntaxHighlighter *highlighter_for_scheme (QObject *parent, const std::string &scheme, GenericSyntaxHighlighterAttributes *attributes, bool initialize);
|
||||
std::string scheme_for (lym::Macro::Interpreter lang, const std::string &dsl_name);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1095,7 +1095,7 @@ UserPropertiesForm::UserPropertiesForm (QWidget *parent)
|
|||
input.open (QIODevice::ReadOnly);
|
||||
mp_hl_basic_attributes.reset (new GenericSyntaxHighlighterAttributes ());
|
||||
mp_hl_attributes.reset (new GenericSyntaxHighlighterAttributes (mp_hl_basic_attributes.get ()));
|
||||
lay::GenericSyntaxHighlighter *hl = new GenericSyntaxHighlighter (mp_ui->text_edit, input, mp_hl_attributes.get ());
|
||||
lay::GenericSyntaxHighlighter *hl = new GenericSyntaxHighlighter (mp_ui->text_edit, input, mp_hl_attributes.get (), true);
|
||||
input.close ();
|
||||
|
||||
hl->setDocument (mp_ui->text_edit->document ());
|
||||
|
|
|
|||
|
|
@ -975,6 +975,12 @@ GenericSyntaxHighlighterAttributes::assign (const GenericSyntaxHighlighterAttrib
|
|||
m_ids = other.m_ids;
|
||||
}
|
||||
|
||||
bool
|
||||
GenericSyntaxHighlighterAttributes::has_attribute (const QString &name) const
|
||||
{
|
||||
return m_ids.find (name) != m_ids.end ();
|
||||
}
|
||||
|
||||
int
|
||||
GenericSyntaxHighlighterAttributes::id (const QString &name)
|
||||
{
|
||||
|
|
@ -1467,9 +1473,15 @@ parse_context (QDomElement e, const std::map<QString, QDomElement> &contexts_by_
|
|||
}
|
||||
|
||||
static void
|
||||
parse_item_data (QDomElement e, GenericSyntaxHighlighterAttributes &attributes)
|
||||
parse_item_data (QDomElement e, GenericSyntaxHighlighterAttributes &attributes, bool initialize)
|
||||
{
|
||||
QString name = e.attributeNode (QString::fromUtf8 ("name")).value ();
|
||||
|
||||
// skip attribute if already present so we don't overwrite specific settings
|
||||
if (! initialize && attributes.has_attribute (name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int attribute_id = attributes.id (name);
|
||||
|
||||
def_style ds = dsNormal;
|
||||
|
|
@ -1532,7 +1544,7 @@ parse_item_data (QDomElement e, GenericSyntaxHighlighterAttributes &attributes)
|
|||
attributes.set_styles (attribute_id, ds, format);
|
||||
}
|
||||
|
||||
GenericSyntaxHighlighter::GenericSyntaxHighlighter (QObject *parent, QIODevice &input, GenericSyntaxHighlighterAttributes *attributes)
|
||||
GenericSyntaxHighlighter::GenericSyntaxHighlighter (QObject *parent, QIODevice &input, GenericSyntaxHighlighterAttributes *attributes, bool initialize_attributes)
|
||||
: QSyntaxHighlighter (parent), mp_attributes (attributes), m_generation_id (0)
|
||||
{
|
||||
QDomDocument d;
|
||||
|
|
@ -1593,7 +1605,7 @@ GenericSyntaxHighlighter::GenericSyntaxHighlighter (QObject *parent, QIODevice &
|
|||
if (nn.isElement()) {
|
||||
QDomElement ee = nn.toElement ();
|
||||
if (ee.tagName () == QString::fromUtf8 ("itemData")) {
|
||||
parse_item_data (ee, *mp_attributes);
|
||||
parse_item_data (ee, *mp_attributes, initialize_attributes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -607,6 +607,11 @@ public:
|
|||
return m_ids.end ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the given name is present already
|
||||
*/
|
||||
bool has_attribute (const QString &name) const;
|
||||
|
||||
/**
|
||||
* @brief Get the attribute ID for a given name
|
||||
*
|
||||
|
|
@ -716,7 +721,14 @@ class LAYUI_PUBLIC GenericSyntaxHighlighter
|
|||
: public QSyntaxHighlighter
|
||||
{
|
||||
public:
|
||||
GenericSyntaxHighlighter (QObject *parent, QIODevice &input, GenericSyntaxHighlighterAttributes *attributes);
|
||||
/**
|
||||
* @brief Creates a GenericSyntaxHighlighter
|
||||
* @param parent The owner of the highlighter
|
||||
* @param input The stream from which to pull
|
||||
* @param attributes The attributes
|
||||
* @param initialize_attributes If true, the attributes are initialized from the itemData lines
|
||||
*/
|
||||
GenericSyntaxHighlighter (QObject *parent, QIODevice &input, GenericSyntaxHighlighterAttributes *attributes, bool initialize_attributes);
|
||||
|
||||
/**
|
||||
* @brief Implementation of the highlighter
|
||||
|
|
|
|||
Loading…
Reference in New Issue