📄 scintillaeditview.cpp.svn-base
字号:
cppInstrs = getCompleteKeywordList(instr1, langType, LANG_INDEX_INSTR);
std::string type1("");
if (pKwArray[LANG_INDEX_TYPE])
type1 = pKwArray[LANG_INDEX_TYPE];
cppTypes = getCompleteKeywordList(type1, langType, LANG_INDEX_TYPE);
execute(SCI_SETKEYWORDS, 0, (LPARAM)cppInstrs);
execute(SCI_SETKEYWORDS, 1, (LPARAM)cppTypes);
}
//used by Objective-C and Actionscript
void ScintillaEditView::setObjCLexer(LangType langType)
{
execute(SCI_SETLEXER, SCLEX_OBJC);
const char *doxygenKeyWords = _pParameter->getWordList(L_CPP, LANG_INDEX_TYPE2);
const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
const char *lexerName = "objc";
if (langType == L_FLASH)
lexerName = "actionscript";
makeStyle(lexerName, pKwArray);
std::string objcInstr1Kwl("");
if (pKwArray[LANG_INDEX_INSTR])
objcInstr1Kwl = pKwArray[LANG_INDEX_INSTR];
const char *objcInstrs = getCompleteKeywordList(objcInstr1Kwl, langType, LANG_INDEX_INSTR);
std::string objcInstr2Kwl("");
if (pKwArray[LANG_INDEX_INSTR2])
objcInstr2Kwl = pKwArray[LANG_INDEX_INSTR2];
const char *objCDirective = getCompleteKeywordList(objcInstr2Kwl, langType, LANG_INDEX_INSTR2);
std::string objcTypeKwl("");
if (pKwArray[LANG_INDEX_TYPE])
objcTypeKwl = pKwArray[LANG_INDEX_TYPE];
const char *objcTypes = getCompleteKeywordList(objcTypeKwl, langType, LANG_INDEX_TYPE);
std::string objcType2Kwl("");
if (pKwArray[LANG_INDEX_TYPE2])
objcType2Kwl = pKwArray[LANG_INDEX_TYPE2];
const char *objCQualifier = getCompleteKeywordList(objcType2Kwl, langType, LANG_INDEX_TYPE2);
execute(SCI_SETKEYWORDS, 0, (LPARAM)objcInstrs);
execute(SCI_SETKEYWORDS, 1, (LPARAM)objcTypes);
execute(SCI_SETKEYWORDS, 2, (LPARAM)(doxygenKeyWords?doxygenKeyWords:""));
execute(SCI_SETKEYWORDS, 3, (LPARAM)objCDirective);
execute(SCI_SETKEYWORDS, 4, (LPARAM)objCQualifier);
}
void ScintillaEditView::setKeywords(LangType langType, const char *keywords, int index)
{
std::string wordList;
wordList = (keywords)?keywords:"";
execute(SCI_SETKEYWORDS, index, (LPARAM)getCompleteKeywordList(wordList, langType, index));
}
void ScintillaEditView::setLexer(int lexerID, LangType langType, const char *lexerName, int whichList)
{
execute(SCI_SETLEXER, lexerID);
const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
makeStyle(lexerName, pKwArray);
if (whichList & LIST_0)
{
setKeywords(langType, pKwArray[LANG_INDEX_INSTR], LANG_INDEX_INSTR);
}
if (whichList & LIST_1)
{
setKeywords(langType, pKwArray[LANG_INDEX_INSTR2], LANG_INDEX_INSTR2);
}
if (whichList & LIST_2)
{
setKeywords(langType, pKwArray[LANG_INDEX_TYPE], LANG_INDEX_TYPE);
}
if (whichList & LIST_3)
{
setKeywords(langType, pKwArray[LANG_INDEX_TYPE2], LANG_INDEX_TYPE2);
}
if (whichList & LIST_4)
{
setKeywords(langType, pKwArray[LANG_INDEX_TYPE3], LANG_INDEX_TYPE3);
}
if (whichList & LIST_5)
{
setKeywords(langType, pKwArray[LANG_INDEX_TYPE4], LANG_INDEX_TYPE4);
}
if (whichList & LIST_6)
{
setKeywords(langType, pKwArray[LANG_INDEX_TYPE5], LANG_INDEX_TYPE5);
}
}
void ScintillaEditView::defineDocType(LangType typeDoc)
{
//setStyle(STYLE_DEFAULT, black, white, "Verdana", 0, 9);
StyleArray & stylers = _pParameter->getMiscStylerArray();
int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT);
if (iStyleDefault != -1)
{
Style & styleDefault = stylers.getStyler(iStyleDefault);
setStyle(styleDefault._styleID, styleDefault._fgColor, styleDefault._bgColor, styleDefault._fontName, styleDefault._fontStyle, styleDefault._fontSize);
}
execute(SCI_STYLECLEARALL);
int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE);
if (iFind != -1)
{
Style & styleFind = stylers.getStyler(iFind);
setStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize);
}
iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_SELECT_STYLE);
if (iFind != -1)
{
Style & styleFind = stylers.getStyler(iFind);
setStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize);
}
int caretWidth = 1;
// Il faut surtout faire un test ici avant d'ex閏uter SCI_SETCODEPAGE
// Sinon y'aura un soucis de performance!
if (isCJK())
{
if (getCurrentBuffer()._unicodeMode == uni8Bit)
execute(SCI_SETCODEPAGE, _codepage);
}
execute(SCI_SETSTYLEBITS, 5);
showMargin(_SC_MARGE_FOLDER, isNeededFolderMarge(typeDoc));
switch (typeDoc)
{
case L_C :
case L_CPP :
case L_JS:
case L_JAVA :
case L_RC :
case L_CS :
case L_TCL :
setCppLexer(typeDoc); break;
case L_FLASH :
case L_OBJC :
setObjCLexer(typeDoc); break;
case L_PHP :
case L_ASP :
case L_HTML :
case L_XML :
setXmlLexer(typeDoc); break;
case L_CSS :
setCssLexer(); break;
case L_LUA :
setLuaLexer(); break;
case L_MAKEFILE :
setMakefileLexer(); break;
case L_INI :
setIniLexer(); break;
case L_USER :
if (_buffers[_currentIndex]._userLangExt[0])
setUserLexer(_buffers[_currentIndex]._userLangExt);
else
setUserLexer();
break;
case L_NFO :
{
LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName("nfo");
COLORREF bg = black;
COLORREF fg = liteGrey;
if (pStyler)
{
int i = pStyler->getStylerIndexByName("DEFAULT");
if (i != -1)
{
Style & style = pStyler->getStyler(i);
bg = style._bgColor;
fg = style._fgColor;
}
}
setStyle(STYLE_DEFAULT, fg, bg, "MS LineDraw");
execute(SCI_STYLECLEARALL);
}
break;
case L_SQL :
setSqlLexer(); break;
case L_VB :
setVBLexer(); break;
case L_PASCAL :
setPascalLexer(); break;
case L_PERL :
setPerlLexer(); break;
case L_PYTHON :
setPythonLexer(); break;
case L_BATCH :
setBatchLexer(); break;
case L_TEX :
setTeXLexer(); break;
case L_NSIS :
setNsisLexer(); break;
case L_BASH :
setBashLexer(); break;
case L_FORTRAN :
setFortranLexer(); break;
case L_LISP :
setLispLexer(); break;
case L_SCHEME :
setShemeLexer(); break;
case L_ASM :
setAsmLexer(); break;
case L_DIFF :
setDiffLexer(); break;
case L_PROPS :
setPropsLexer(); break;
case L_PS :
setPostscriptLexer(); break;
case L_RUBY :
setRubyLexer(); break;
case L_SMALLTALK :
setSmalltalkLexer(); break;
case L_VHDL :
setVhdlLexer(); break;
case L_KIX :
setKixLexer(); break;
case L_CAML :
setCamlLexer(); break;
case L_ADA :
setAdaLexer(); break;
case L_VERILOG :
setVerilogLexer(); break;
case L_AU3 :
setAutoItLexer(); break;
case L_MATLAB :
setMatlabLexer(); break;
case L_HASKELL :
setHaskellLexer(); break;
case L_INNO :
setInnoLexer(); break;
case L_CMAKE :
setCmakeLexer(); break;
case L_TXT :
default :
execute(SCI_SETLEXER, (_codepage == CP_CHINESE_TRADITIONAL)?SCLEX_MAKEFILE:SCLEX_NULL); break;
}
//All the global styles should put here
static int indexOfIndentGuide = stylers.getStylerIndexByID(STYLE_INDENTGUIDE);
if (indexOfIndentGuide != -1)
{
static Style & styleIG = stylers.getStyler(indexOfIndentGuide);
setStyle(styleIG._styleID, styleIG._fgColor, styleIG._bgColor, styleIG._fontName, styleIG._fontStyle, styleIG._fontSize);
}
static int indexOfBraceLight = stylers.getStylerIndexByID(STYLE_BRACELIGHT);
if (indexOfBraceLight != -1)
{
static Style & styleBL = stylers.getStyler(indexOfBraceLight);
setStyle(styleBL._styleID, styleBL._fgColor, styleBL._bgColor, styleBL._fontName, styleBL._fontStyle, styleBL._fontSize);
}
//setStyle(STYLE_CONTROLCHAR, liteGrey);
static int indexBadBrace = stylers.getStylerIndexByID(STYLE_BRACEBAD);
if (indexBadBrace != -1)
{
static Style & styleBB = stylers.getStyler(indexBadBrace);
setStyle(styleBB._styleID, styleBB._fgColor, styleBB._bgColor, styleBB._fontName, styleBB._fontStyle, styleBB._fontSize);
}
static int indexLineNumber = stylers.getStylerIndexByID(STYLE_LINENUMBER);
if (indexLineNumber != -1)
{
static Style & styleLN = stylers.getStyler(indexLineNumber);
setStyle(styleLN._styleID, styleLN._fgColor, styleLN._bgColor, styleLN._fontName, styleLN._fontStyle, styleLN._fontSize);
}
execute(SCI_SETTABWIDTH, ((NppParameters::getInstance())->getNppGUI())._tabSize);
execute(SCI_SETUSETABS, !((NppParameters::getInstance())->getNppGUI())._tabReplacedBySpace);
execute(SCI_COLOURISE, 0, -1);
}
char * ScintillaEditView::attatchDefaultDoc(int nb)
{
char title[10];
char nb_str[4];
strcat(strcpy(title, UNTITLED_STR), _itoa(nb, nb_str, 10));
// get the doc pointer attached (by default) on the view Scintilla
Document doc = execute(SCI_GETDOCPOINTER, 0, 0);
// create the entry for our list
_buffers.push_back(Buffer(doc, title));
// set current index to 0
_currentIndex = 0;
return _buffers[_currentIndex]._fullPathName;
}
int ScintillaEditView::findDocIndexByName(const char *fn) const
{
int index = -1;
for (int i = 0 ; i < int(_buffers.size()) ; i++)
{
if (!stricmp(_buffers[i]._fullPathName, fn))
{
index = i;
break;
}
}
return index;
}
void ScintillaEditView::saveCurrentPos()
{
int displayedLine = static_cast<int>(execute(SCI_GETFIRSTVISIBLELINE));
int docLine = execute(SCI_DOCLINEFROMVISIBLE, displayedLine);
int nbInvisibleLine = 0;
//Calculate nb of invisible line
for (int i = 0 ; i < docLine ; i++)
if (execute(SCI_GETLINEVISIBLE, i) == FALSE)
nbInvisibleLine++;
Buffer & buf = _buffers[_currentIndex];
// the correct visible line number
buf._pos._firstVisibleLine = docLine - nbInvisibleLine;
buf._pos._startPos = static_cast<int>(execute(SCI_GETSELECTIONSTART));
buf._pos._endPos = static_cast<int>(execute(SCI_GETSELECTIONEND));
buf._pos._xOffset = static_cast<int>(execute(SCI_GETXOFFSET));
}
void ScintillaEditView::restoreCurrentPos(const Position & prevPos)
{
int scroll2Top = 0 - (int(execute(SCI_GETLINECOUNT)) + 1);
scroll(0, scroll2Top);
Buffer & buf = _buffers[_currentIndex];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -