mirror of https://gitee.com/cxasm/notepad--.git
118 lines
2.1 KiB
C++
118 lines
2.1 KiB
C++
|
#include "userlexdef.h"
|
|||
|
#include "rcglobal.h"
|
|||
|
#include <QSettings>
|
|||
|
|
|||
|
|
|||
|
UserLexDef::UserLexDef(QObject *parent):QObject(parent)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
UserLexDef::~UserLexDef()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
//<2F>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ȡ<EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĽӿ<C4BD>
|
|||
|
|
|||
|
bool UserLexDef::readUserSettings(QString langTagName)
|
|||
|
{
|
|||
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD>ʽ<EFBFBD><CABD>
|
|||
|
//mz:ndd
|
|||
|
//name:xxx
|
|||
|
//mother:xxx none/cpp/html <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//keword:xxx
|
|||
|
|
|||
|
QString userLangFile = QString("notepad/userlang/%1").arg(langTagName);
|
|||
|
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
|
|||
|
qs.setIniCodec("UTF-8");
|
|||
|
|
|||
|
if (!qs.contains(QString("mz")))
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>MzΪNdd<64>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
return false;
|
|||
|
}
|
|||
|
if (qs.value("mz").toString() != QString("ndd"))
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
m_motherLang = qs.value("mother").toString();
|
|||
|
m_keyword = qs.value("keword").toString().toUtf8();
|
|||
|
/*m_keyword.append("\0");*/
|
|||
|
|
|||
|
return true;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void UserLexDef::setKeyword(QString words)
|
|||
|
{
|
|||
|
m_keyword = words.toUtf8();
|
|||
|
if (!m_keyword.endsWith('\0'))
|
|||
|
{
|
|||
|
m_keyword.append('\0');
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void UserLexDef::setExtFileTypes(QString extType)
|
|||
|
{
|
|||
|
m_extTypes = extType;
|
|||
|
}
|
|||
|
|
|||
|
QString UserLangMotherToName(UserLangMother words)
|
|||
|
{
|
|||
|
QString name;
|
|||
|
|
|||
|
switch (words)
|
|||
|
{
|
|||
|
case MOTHER_NONE:
|
|||
|
name = "None";
|
|||
|
break;
|
|||
|
case MOTHER_CPP:
|
|||
|
name = "Cpp";
|
|||
|
break;
|
|||
|
default:
|
|||
|
name = "None";
|
|||
|
break;
|
|||
|
}
|
|||
|
return name;
|
|||
|
}
|
|||
|
|
|||
|
void UserLexDef::setMotherLang(UserLangMother words)
|
|||
|
{
|
|||
|
m_motherLang = UserLangMotherToName(words);
|
|||
|
}
|
|||
|
|
|||
|
bool UserLexDef::writeUserSettings(QString langTagName)
|
|||
|
{
|
|||
|
//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ը<EFBFBD>ʽ<EFBFBD><CABD>
|
|||
|
//mz:ndd
|
|||
|
//name:xxx
|
|||
|
//mother:xxx none/cpp/html <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//ext:xx xx xx <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BA>
|
|||
|
//keyword:xxx
|
|||
|
|
|||
|
QString userLangFile = QString("notepad/userlang/%1").arg(langTagName);
|
|||
|
QSettings qs(QSettings::IniFormat, QSettings::UserScope, userLangFile);
|
|||
|
qs.setIniCodec("UTF-8");
|
|||
|
qs.clear();
|
|||
|
|
|||
|
qs.setValue("mz", langTagName);
|
|||
|
qs.setValue("mother", m_motherLang);
|
|||
|
qs.setValue("ext", m_extTypes);
|
|||
|
qs.setValue("keyword", m_keyword.data());
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
const char * UserLexDef::keywords(int set) const
|
|||
|
{
|
|||
|
if (m_keyword.isEmpty())
|
|||
|
{
|
|||
|
return nullptr;
|
|||
|
}
|
|||
|
|
|||
|
return m_keyword.data();
|
|||
|
}
|
|||
|
|
|||
|
|