⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qsteproper.cpp

📁 porting scintilla to qt
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	m_showdegree = 0;	for(int i = 0;i < importMax;i++){		if(!importFiles[i].IsSet()){			continue;		}else{			char *tn = StringDup(importFiles[i].Name().AsFileSystem());			char *tchar = tn;			while(*tchar){if(*tchar == '.'){*tchar = '\0';break;}tchar++;}			std::string name = getWorkDir() + importFiles[i].AsFileSystem();			QSteLexProper *lexer = new QSteLexProper(name.c_str());			if(lexer != NULL && lexer->isInitialized()){				lexer->setLanguageType(tn);				lexer->setSuperPs(this);				lexPointer[i] = lexer;			}			free(tn);		}	}//init abbrev	SString name = getWorkDir().c_str();	name += "abbrev.";	name += "properties";	m_abbv = new QSteAbbrevProper(name.c_str());}void QSteGlobalProper::addEditorToList(QSteEditor *editor){	if(editor == NULL)		return;	std::list<QSteEditor*>::iterator i_index;	for(i_index = m_steeditorlist.begin();i_index != m_steeditorlist.end();i_index++){		if(editor == *i_index)			return;	}	m_steeditorlist.push_back(editor);}void QSteGlobalProper::delEditorToList(QSteEditor *editor){	if(editor == NULL)		return;	std::list<QSteEditor*>::iterator i_index;	for(i_index = m_steeditorlist.begin();i_index != m_steeditorlist.end();i_index++){		if(editor == *i_index){			m_steeditorlist.erase(i_index);			return;		}	}}QSteLexProper *QSteGlobalProper::getLexFromName(const char *name){	if(name == NULL || !isInitialized())		return NULL;	QSteLexProper *lexer = NULL;	for(int i = 0;i < importMax;i++){		lexer = lexPointer[i];		if(lexer == NULL)			continue;		else{			if(strcmp(name,lexer->getLanguageType()) == 0)				return lexer;		}	}	return NULL;}QSteLexProper *QSteGlobalProper::getLexFromPostfix(const char *fix){	if(fix == NULL || !isInitialized())		return NULL;	QSteLexProper *lexer = NULL;	for(int i = 0;i < importMax;i++){		lexer = lexPointer[i];		if(lexer == NULL)			continue;		else{			SString type = lexer->GetNewExpand("lexer.",fix);			if(type.length() != 0)				return lexer;		}	}	return NULL;}QSteLexProper *QSteGlobalProper::getLexFromIndex(int index){	if(index < 0 || index >= importMax)		return NULL;	else		return lexPointer[index];}QSteAbbrevProper *QSteGlobalProper::getAbbvFromPostfix(const char *fix){	return m_abbv;}QSteAbbrevProper *QSteGlobalProper::getAbbvFromName(const char *name){	return m_abbv;}QSteStyleDefinition::QSteStyleDefinition(const char *definition) :size(0),fore("#000000"),back("#FFFFFF"),bold(false), italics(false), eolfilled(false), underlined(false),	caseForce(SC_CASE_MIXED),visible(true), changeable(true),specified(sdNone){	parseStyleDefinition(definition);}bool QSteStyleDefinition::parseStyleDefinition(const char *definition){	if (definition == 0 || *definition == '\0') {		return false;	}	char *val = StringDup(definition);	char *opt = val;	while (opt) {		// Find attribute separator		char *cpComma = strchr(opt, ',');		if (cpComma) {			// If found, we terminate the current attribute (opt) string			*cpComma = '\0';		}		// Find attribute name/value separator		char *colon = strchr(opt, ':');		if (colon) {			// If found, we terminate the current attribute name and point on the value			*colon++ = '\0';		}		if (0 == strcmp(opt, "italics")) {			specified = static_cast<flags>(specified | sdItalics);			italics = true;		}		if (0 == strcmp(opt, "notitalics")) {			specified = static_cast<flags>(specified | sdItalics);			italics = false;		}		if (0 == strcmp(opt, "bold")) {			specified = static_cast<flags>(specified | sdBold);			bold = true;		}		if (0 == strcmp(opt, "notbold")) {			specified = static_cast<flags>(specified | sdBold);			bold = false;		}		if (0 == strcmp(opt, "font")) {			specified = static_cast<flags>(specified | sdFont);			font = colon;			font.substitute('|', ',');		}		if (0 == strcmp(opt, "fore")) {			specified = static_cast<flags>(specified | sdFore);			fore = colon;		}		if (0 == strcmp(opt, "back")) {			specified = static_cast<flags>(specified | sdBack);			back = colon;		}		if (0 == strcmp(opt, "size")) {			specified = static_cast<flags>(specified | sdSize);			size = atoi(colon);		}		if (0 == strcmp(opt, "eolfilled")) {			specified = static_cast<flags>(specified | sdEOLFilled);			eolfilled = true;		}		if (0 == strcmp(opt, "noteolfilled")) {			specified = static_cast<flags>(specified | sdEOLFilled);			eolfilled = false;		}		if (0 == strcmp(opt, "underlined")) {			specified = static_cast<flags>(specified | sdUnderlined);			underlined = true;		}		if (0 == strcmp(opt, "notunderlined")) {			specified = static_cast<flags>(specified | sdUnderlined);			underlined = false;		}		if (0 == strcmp(opt, "case")) {			specified = static_cast<flags>(specified | sdCaseForce);			caseForce = SC_CASE_MIXED;			if (colon) {				if (*colon == 'u')					caseForce = SC_CASE_UPPER;				else if (*colon == 'l')					caseForce = SC_CASE_LOWER;			}		}		if (0 == strcmp(opt, "visible")) {			specified = static_cast<flags>(specified | sdVisible);			visible = true;		}		if (0 == strcmp(opt, "notvisible")) {			specified = static_cast<flags>(specified | sdVisible);			visible = false;		}		if (0 == strcmp(opt, "changeable")) {			specified = static_cast<flags>(specified | sdChangeable);			changeable = true;		}		if (0 == strcmp(opt, "notchangeable")) {			specified = static_cast<flags>(specified | sdChangeable);			changeable = false;		}		if (cpComma)			opt = cpComma + 1;		else			opt = 0;	}	delete []val;	return true;}int IntFromHexDigit(int ch) {	if ((ch >= '0') && (ch <= '9')) {		return ch - '0';	} else if (ch >= 'A' && ch <= 'F') {		return ch - 'A' + 10;	} else if (ch >= 'a' && ch <= 'f') {		return ch - 'a' + 10;	} else {		return 0;	}}int IntFromHexByte(const char *hexByte) {	return IntFromHexDigit(hexByte[0]) * 16 + IntFromHexDigit(hexByte[1]);}long ColourFromString(const SString &s){	if (s.length()) {		int r = IntFromHexByte(s.c_str() + 1);		int g = IntFromHexByte(s.c_str() + 3);		int b = IntFromHexByte(s.c_str() + 5);		return ColourDesired(r, g, b).AsLong();	} else {		return ColourDesired().AsLong();	}}long QSteStyleDefinition::foreAsLong() const{	return ColourFromString(fore);}long QSteStyleDefinition::backAsLong() const{	return ColourFromString(back);}bool IsBrace(char ch) {	return ch == '<' || ch == '>' || ch == '[' || ch == ']' || ch == '(' || ch == ')' || ch == '{' || ch == '}';}bool includes(const StyleAndWords &symbols, const SString value){	if (symbols.words.length() == 0) {		return false;	} else if (IsAlphabetic(symbols.words[0])) {		// Set of symbols separated by spaces		size_t lenVal = value.length();		const char *symbol = symbols.words.c_str();		while (symbol) {			const char *symbolEnd = strchr(symbol, ' ');			size_t lenSymbol = strlen(symbol);			if (symbolEnd)				lenSymbol = symbolEnd - symbol;			if (lenSymbol == lenVal) {				if (strncmp(symbol, value.c_str(), lenSymbol) == 0) {					return true;				}			}			symbol = symbolEnd;			if (symbol)				symbol++;		}	} else {		// Set of individual characters. Only one character allowed for now		char ch = symbols.words[0];		return strchr(value.c_str(), ch) != 0;	}	return false;}//copy from SciTEconst char *propertiesToForward[] = {//++Autogenerated -- run src/LexGen.py to regenerate//**\(\t"\*",\n\)	"asp.default.language",	"fold",	"fold.at.else",	"fold.comment",	"fold.comment.yaml",	"fold.compact",	"fold.directive",	"fold.html",	"fold.html.preprocessor",	"fold.perl.package",	"fold.perl.pod",	"fold.preprocessor",	"fold.quotes.python",	"fold.sql.only.begin",	"fold.verilog.flags",	"html.tags.case.sensitive",	"lexer.caml.magic",	"lexer.cpp.allow.dollars",	"lexer.d.fold.at.else",	"lexer.errorlist.value.separate",	"lexer.metapost.comment.process",	"lexer.metapost.interface.default",	"lexer.sql.backticks.identifier",	"lexer.tex.auto.if",	"lexer.tex.comment.process",	"lexer.tex.interface.default",	"lexer.tex.use.keywords",	"nsis.ignorecase",	"nsis.uservars",	"ps.level",	"ps.tokenize",	"sql.backslash.escapes",	"styling.within.preprocessor",	"tab.timmy.whinge.level",//--Autogenerated -- end of automatically generated section	0,};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -