[CLEAN] Remove C notion (void).

[BUG_FIXED] Fix a crash bug of docking manager
[ADD] Add LexMySQL.cxx

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@465 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/x64
Don Ho 2009-04-26 18:59:23 +00:00
parent 9b645c68d3
commit 83ac50e3dd
11 changed files with 413 additions and 42 deletions

View File

@ -60,7 +60,7 @@ static LRESULT CALLBACK hookProcMouse(UINT nCode, WPARAM wParam, LPARAM lParam)
} }
DockingCont::DockingCont(void) DockingCont::DockingCont()
{ {
_isMouseOver = FALSE; _isMouseOver = FALSE;
_isMouseClose = FALSE; _isMouseClose = FALSE;
@ -211,12 +211,12 @@ void DockingCont::setActiveTb(INT iItem)
} }
} }
INT DockingCont::getActiveTb(void) INT DockingCont::getActiveTb()
{ {
return ::SendMessage(_hContTab, TCM_GETCURSEL, 0, 0); return ::SendMessage(_hContTab, TCM_GETCURSEL, 0, 0);
} }
tTbData* DockingCont::getDataOfActiveTb(void) tTbData* DockingCont::getDataOfActiveTb()
{ {
tTbData* pTbData = NULL; tTbData* pTbData = NULL;
INT iItem = getActiveTb(); INT iItem = getActiveTb();
@ -233,7 +233,7 @@ tTbData* DockingCont::getDataOfActiveTb(void)
return pTbData; return pTbData;
} }
vector<tTbData*> DockingCont::getDataOfVisTb(void) vector<tTbData*> DockingCont::getDataOfVisTb()
{ {
vector<tTbData*> vTbData; vector<tTbData*> vTbData;
TCITEM tcItem = {0}; TCITEM tcItem = {0};
@ -988,7 +988,7 @@ BOOL CALLBACK DockingCont::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
return FALSE; return FALSE;
} }
void DockingCont::onSize(void) void DockingCont::onSize()
{ {
TCITEM tcItem = {0}; TCITEM tcItem = {0};
RECT rc = {0}; RECT rc = {0};
@ -1101,7 +1101,7 @@ void DockingCont::onSize(void)
} }
} }
void DockingCont::doClose(void) void DockingCont::doClose()
{ {
INT iItemOff = 0; INT iItemOff = 0;
INT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0); INT iItemCnt = ::SendMessage(_hContTab, TCM_GETITEMCOUNT, 0, 0);
@ -1349,21 +1349,23 @@ void DockingCont::SelectTab(INT iTab)
} }
} }
void DockingCont::updateCaption(void) bool DockingCont::updateCaption()
{ {
if (!_hContTab) if (!_hContTab)
return; return false;
TCITEM tcItem = {0}; TCITEM tcItem = {0};
INT iItem = getActiveTb(); INT iItem = getActiveTb();
if (iItem < 0) if (iItem < 0)
return; return false;
// get data of new active dialog // get data of new active dialog
tcItem.mask = TCIF_PARAM; tcItem.mask = TCIF_PARAM;
::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem);
if (!tcItem.lParam) return false;
// update caption text // update caption text
lstrcpy(_pszCaption, ((tTbData*)tcItem.lParam)->pszName); lstrcpy(_pszCaption, ((tTbData*)tcItem.lParam)->pszName);
@ -1383,9 +1385,10 @@ void DockingCont::updateCaption(void)
{ {
::SetWindowText(_hCaption, _pszCaption); ::SetWindowText(_hCaption, _pszCaption);
} }
return true;
} }
void DockingCont::focusClient(void) void DockingCont::focusClient()
{ {
TCITEM tcItem = {0}; TCITEM tcItem = {0};
INT iItem = getActiveTb(); INT iItem = getActiveTb();

View File

@ -61,10 +61,10 @@ public:
DockingCont(); DockingCont();
~DockingCont(); ~DockingCont();
HWND getTabWnd(void) { HWND getTabWnd() {
return _hContTab; return _hContTab;
}; };
HWND getCaptionWnd(void) { HWND getCaptionWnd() {
if (_isFloating == false) if (_isFloating == false)
return _hCaption; return _hCaption;
else else
@ -92,26 +92,26 @@ public:
void setActiveTb(tTbData* pTbData); void setActiveTb(tTbData* pTbData);
void setActiveTb(INT iItem); void setActiveTb(INT iItem);
INT getActiveTb(void); INT getActiveTb();
tTbData* getDataOfActiveTb(void); tTbData* getDataOfActiveTb();
vector<tTbData *> getDataOfAllTb(void) { vector<tTbData *> getDataOfAllTb() {
return _vTbData; return _vTbData;
}; };
vector<tTbData *> getDataOfVisTb(void); vector<tTbData *> getDataOfVisTb();
bool isTbVis(tTbData* data); bool isTbVis(tTbData* data);
void doDialog(bool willBeShown = true, bool isFloating = false); void doDialog(bool willBeShown = true, bool isFloating = false);
bool isFloating(void) { bool isFloating() {
return _isFloating; return _isFloating;
} }
INT getElementCnt(void) { INT getElementCnt() {
return _vTbData.size(); return _vTbData.size();
} }
// interface function for gripper // interface function for gripper
BOOL startMovingFromTab(void) { BOOL startMovingFromTab() {
BOOL dragFromTabTemp = _dragFromTab; BOOL dragFromTabTemp = _dragFromTab;
_dragFromTab = FALSE; _dragFromTab = FALSE;
return dragFromTabTemp; return dragFromTabTemp;
@ -122,7 +122,7 @@ public:
onSize(); onSize();
}; };
void focusClient(void); void focusClient();
void SetActive(BOOL bState) { void SetActive(BOOL bState) {
_isActive = bState; _isActive = bState;
@ -161,13 +161,13 @@ protected :
// drawing functions // drawing functions
void drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct); void drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct);
void drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct); void drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct);
void onSize(void); void onSize();
// functions for caption handling and drawing // functions for caption handling and drawing
eMousePos isInRect(HWND hwnd, INT x, INT y); eMousePos isInRect(HWND hwnd, INT x, INT y);
// handling of toolbars // handling of toolbars
void doClose(void); void doClose();
// return new item // return new item
INT SearchPosInTab(tTbData* pTbData); INT SearchPosInTab(tTbData* pTbData);
@ -179,7 +179,7 @@ protected :
return hideToolbar(pTbData, FALSE); return hideToolbar(pTbData, FALSE);
}; };
void updateCaption(void); bool updateCaption();
LPARAM NotifyParent(UINT message); LPARAM NotifyParent(UINT message);
private: private:

View File

@ -51,10 +51,6 @@ public:
// supported features by plugin // supported features by plugin
data->uMask = 0; data->uMask = 0;
// icons
//data->hIconBar = ::LoadIcon(hInst, IDB_CLOSE_DOWN);
//data->hIconTab = ::LoadIcon(hInst, IDB_CLOSE_DOWN);
// additional info // additional info
data->pszAddInfo = NULL; data->pszAddInfo = NULL;
@ -62,7 +58,7 @@ public:
}; };
virtual void updateDockingDlg(void) { virtual void updateDockingDlg() {
::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)_hSelf); ::SendMessage(_hParent, NPPM_DMMUPDATEDISPINFO, 0, (LPARAM)_hSelf);
} }

View File

@ -830,7 +830,7 @@ int DockingManager::GetContainer(DockingCont* pCont)
return iRet; return iRet;
} }
int DockingManager::FindEmptyContainer(void) int DockingManager::FindEmptyContainer()
{ {
int iRetCont = -1; int iRetCont = -1;
BOOL* pPrevDockList = (BOOL*) new BOOL[_vContainer.size()+1]; BOOL* pPrevDockList = (BOOL*) new BOOL[_vContainer.size()+1];

View File

@ -119,7 +119,7 @@ public :
int GetContainer(DockingCont* pCont); int GetContainer(DockingCont* pCont);
/* get all container in vector */ /* get all container in vector */
vector<DockingCont*> & getContainerInfo(void) { vector<DockingCont*> & getContainerInfo() {
return _vContainer; return _vContainer;
}; };
/* get dock data (sized areas) */ /* get dock data (sized areas) */
@ -167,13 +167,13 @@ private :
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); LRESULT runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
void onSize(void); void onSize();
void toggleTb(DockingCont* pContSrc, DockingCont* pContTgt, tTbData TbData); void toggleTb(DockingCont* pContSrc, DockingCont* pContTgt, tTbData TbData);
/* test if container exists */ /* test if container exists */
BOOL ContExists(size_t iCont); BOOL ContExists(size_t iCont);
int FindEmptyContainer(void); int FindEmptyContainer();
LRESULT SendNotify(HWND hWnd, UINT message) { LRESULT SendNotify(HWND hWnd, UINT message) {
NMHDR nmhdr; NMHDR nmhdr;

View File

@ -73,7 +73,7 @@ static LRESULT CALLBACK hookProcKeyboard(INT nCode, WPARAM wParam, LPARAM lParam
return ::CallNextHookEx(hookKeyboard, nCode, wParam, lParam); return ::CallNextHookEx(hookKeyboard, nCode, wParam, lParam);
} }
Gripper::Gripper(void) Gripper::Gripper()
{ {
_hInst = NULL; _hInst = NULL;
_hParent = NULL; _hParent = NULL;
@ -247,7 +247,7 @@ LRESULT Gripper::runProc(UINT message, WPARAM wParam, LPARAM lParam)
} }
void Gripper::create(void) void Gripper::create()
{ {
RECT rc = {0}; RECT rc = {0};
POINT pt = {0}; POINT pt = {0};
@ -301,7 +301,7 @@ void Gripper::create(void)
} }
void Gripper::onMove(void) void Gripper::onMove()
{ {
POINT pt = {0,0}; POINT pt = {0,0};
POINT ptBuf = {0,0}; POINT ptBuf = {0,0};
@ -324,7 +324,7 @@ void Gripper::onMove(void)
} }
void Gripper::onButtonUp(void) void Gripper::onButtonUp()
{ {
POINT pt = {0,0}; POINT pt = {0,0};
POINT ptBuf = {0,0}; POINT ptBuf = {0,0};

View File

@ -60,13 +60,13 @@ public:
protected : protected :
void create(void); void create();
static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK staticWinProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam); LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam);
void onMove(void); void onMove();
void onButtonUp(void); void onButtonUp();
void doTabReordering(POINT pt); void doTabReordering(POINT pt);
void drawRectangle(POINT pt); void drawRectangle(POINT pt);

View File

@ -115,7 +115,7 @@ void ShowVscroll(HWND,int);
void ShowHscroll(HWND,int); void ShowHscroll(HWND,int);
int BinarySearchListBox(HWND,TCHAR*); int BinarySearchListBox(HWND,TCHAR*);
void DisplayEditString(HWND ,int ,TCHAR*); void DisplayEditString(HWND ,int ,TCHAR*);
int CountGrids(void); int CountGrids();

View File

@ -34,7 +34,7 @@ class ToolTip : public Window
public : public :
ToolTip() : _bTrackMouse(FALSE) {}; ToolTip() : _bTrackMouse(FALSE) {};
void destroy(void){ void destroy(){
::DestroyWindow(_hSelf); ::DestroyWindow(_hSelf);
_hSelf = NULL; _hSelf = NULL;
}; };
@ -57,7 +57,7 @@ protected:
return (((ToolTip *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(Message, wParam, lParam)); return (((ToolTip *)(::GetWindowLongPtr(hwnd, GWL_USERDATA)))->runProc(Message, wParam, lParam));
}; };
LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam); LRESULT runProc(UINT Message, WPARAM wParam, LPARAM lParam);
void SendHitMessage(void); void SendHitMessage();
}; };
#endif // __TOOLTIP_H__ #endif // __TOOLTIP_H__

View File

@ -115,6 +115,11 @@
#define SCE_UNIVERSAL_FOUND_STYLE_INC 28 #define SCE_UNIVERSAL_FOUND_STYLE_INC 28
#define SCE_UNIVERSAL_TAGMATCH 27 #define SCE_UNIVERSAL_TAGMATCH 27
#define SCE_UNIVERSAL_TAGATTR 26 #define SCE_UNIVERSAL_TAGATTR 26
#define SCE_UNIVERSAL_FOUND_STYLE_EXT1 25
#define SCE_UNIVERSAL_FOUND_STYLE_EXT2 24
#define SCE_UNIVERSAL_FOUND_STYLE_EXT3 23
#define SCE_UNIVERSAL_FOUND_STYLE_EXT4 22
#define SCE_UNIVERSAL_FOUND_STYLE_EXT5 21
#define SCE_P_DEFAULT 0 #define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1 #define SCE_P_COMMENTLINE 1

367
scintilla/src/LexMySQL.cxx Normal file
View File

@ -0,0 +1,367 @@
// Scintilla source code edit control
/** @file LexMySQL.cxx
** Lexer for MySQL
**/
// Adopted from LexSQL.cxx by Anders Karlsson <anders@mysql.com>
// Original work by Neil Hodgson <neilh@scintilla.org>
// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "Platform.h"
#include "PropSet.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static inline bool IsAWordChar(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalpha(ch) || ch == '_');
}
static inline bool IsADoxygenChar(int ch) {
return (islower(ch) || ch == '$' || ch == '@' ||
ch == '\\' || ch == '&' || ch == '<' ||
ch == '>' || ch == '#' || ch == '{' ||
ch == '}' || ch == '[' || ch == ']');
}
static inline bool IsANumberChar(int ch) {
// Not exactly following number definition (several dots are seen as OK, etc.)
// but probably enough in most cases.
return (ch < 0x80) &&
(isdigit(ch) || toupper(ch) == 'E' ||
ch == '.' || ch == '-' || ch == '+');
}
static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &major_keywords = *keywordlists[0];
WordList &keywords = *keywordlists[1];
WordList &database_objects = *keywordlists[2];
WordList &functions = *keywordlists[3];
WordList &system_variables = *keywordlists[4];
WordList &procedure_keywords = *keywordlists[5];
WordList &kw_user1 = *keywordlists[6];
WordList &kw_user2 = *keywordlists[7];
WordList &kw_user3 = *keywordlists[8];
StyleContext sc(startPos, length, initStyle, styler);
for (; sc.More(); sc.Forward()) {
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_MYSQL_OPERATOR:
sc.SetState(SCE_MYSQL_DEFAULT);
break;
case SCE_MYSQL_NUMBER:
// We stop the number definition on non-numerical non-dot non-eE non-sign char
if (!IsANumberChar(sc.ch)) {
sc.SetState(SCE_MYSQL_DEFAULT);
}
break;
case SCE_MYSQL_IDENTIFIER:
if (!IsAWordChar(sc.ch)) {
int nextState = SCE_MYSQL_DEFAULT;
char s[1000];
sc.GetCurrentLowered(s, sizeof(s));
if (major_keywords.InList(s)) {
sc.ChangeState(SCE_MYSQL_MAJORKEYWORD);
} else if (keywords.InList(s)) {
sc.ChangeState(SCE_MYSQL_KEYWORD);
} else if (database_objects.InList(s)) {
sc.ChangeState(SCE_MYSQL_DATABASEOBJECT);
} else if (functions.InList(s)) {
sc.ChangeState(SCE_MYSQL_FUNCTION);
} else if (procedure_keywords.InList(s)) {
sc.ChangeState(SCE_MYSQL_PROCEDUREKEYWORD);
} else if (kw_user1.InList(s)) {
sc.ChangeState(SCE_MYSQL_USER1);
} else if (kw_user2.InList(s)) {
sc.ChangeState(SCE_MYSQL_USER2);
} else if (kw_user3.InList(s)) {
sc.ChangeState(SCE_MYSQL_USER3);
}
sc.SetState(nextState);
}
break;
case SCE_MYSQL_VARIABLE:
if (!IsAWordChar(sc.ch)) {
sc.SetState(SCE_MYSQL_DEFAULT);
}
break;
case SCE_MYSQL_SYSTEMVARIABLE:
if (!IsAWordChar(sc.ch)) {
char s[1000];
sc.GetCurrentLowered(s, sizeof(s));
// Check for known system variables here.
if (system_variables.InList(&s[2])) {
sc.ChangeState(SCE_MYSQL_KNOWNSYSTEMVARIABLE);
}
sc.SetState(SCE_MYSQL_DEFAULT);
}
break;
case SCE_MYSQL_QUOTEDIDENTIFIER:
if (sc.ch == 0x60) {
if (sc.chNext == 0x60) {
sc.Forward(); // Ignore it
} else {
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
}
}
break;
case SCE_MYSQL_COMMENT:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
}
break;
case SCE_MYSQL_COMMENTLINE:
if (sc.atLineStart) {
sc.SetState(SCE_MYSQL_DEFAULT);
}
break;
case SCE_MYSQL_SQSTRING:
if (sc.ch == '\\') {
// Escape sequence
sc.Forward();
} else if (sc.ch == '\'') {
if (sc.chNext == '\'') {
sc.Forward();
} else {
sc.ChangeState(SCE_MYSQL_STRING);
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
}
}
break;
case SCE_MYSQL_DQSTRING:
if (sc.ch == '\\') {
// Escape sequence
sc.Forward();
} else if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
sc.ChangeState(SCE_MYSQL_STRING);
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
}
}
break;
}
// Determine if a new state should be entered.
if (sc.state == SCE_MYSQL_DEFAULT) {
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
sc.SetState(SCE_MYSQL_NUMBER);
} else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_MYSQL_IDENTIFIER);
// Note that the order of SYSTEMVARIABLE and VARIABLE is important here.
} else if (sc.ch == 0x40 && sc.chNext == 0x40) {
sc.SetState(SCE_MYSQL_SYSTEMVARIABLE);
sc.Forward(); // Skip past the second at-sign.
} else if (sc.ch == 0x40) {
sc.SetState(SCE_MYSQL_VARIABLE);
} else if (sc.ch == 0x60) {
sc.SetState(SCE_MYSQL_QUOTEDIDENTIFIER);
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_MYSQL_COMMENT);
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('-', '-') || sc.Match('#')) {
sc.SetState(SCE_MYSQL_COMMENTLINE);
} else if (sc.ch == '\'') {
sc.SetState(SCE_MYSQL_SQSTRING);
} else if (sc.ch == '\"') {
sc.SetState(SCE_MYSQL_DQSTRING);
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_MYSQL_OPERATOR);
}
}
}
sc.Complete();
}
static bool IsStreamCommentStyle(int style) {
return style == SCE_MYSQL_COMMENT;
}
// Store both the current line's fold level and the next lines in the
// level store to make it easy to pick up with each increment.
static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
bool foldOnlyBegin = styler.GetPropertyInt("fold.sql.only.begin", 0) != 0;
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0) {
levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
}
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
bool endFound = false;
bool whenFound = false;
bool elseFound = false;
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev)) {
levelNext++;
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelNext--;
}
}
if (foldComment && (style == SCE_MYSQL_COMMENTLINE)) {
// MySQL needs -- comments to be followed by space or control char
if ((ch == '-') && (chNext == '-')) {
char chNext2 = styler.SafeGetCharAt(i + 2);
char chNext3 = styler.SafeGetCharAt(i + 3);
if (chNext2 == '{' || chNext3 == '{') {
levelNext++;
} else if (chNext2 == '}' || chNext3 == '}') {
levelNext--;
}
}
}
if (style == SCE_MYSQL_OPERATOR) {
if (ch == '(') {
levelNext++;
} else if (ch == ')') {
levelNext--;
}
}
// Style new keywords here.
if ((style == SCE_MYSQL_MAJORKEYWORD && stylePrev != SCE_MYSQL_MAJORKEYWORD)
|| (style == SCE_MYSQL_KEYWORD && stylePrev != SCE_MYSQL_KEYWORD)
|| (style == SCE_MYSQL_PROCEDUREKEYWORD && stylePrev != SCE_MYSQL_PROCEDUREKEYWORD)) {
const int MAX_KW_LEN = 6; // Maximum length of folding keywords
char s[MAX_KW_LEN + 2];
unsigned int j = 0;
for (; j < MAX_KW_LEN + 1; j++) {
if (!iswordchar(styler[i + j])) {
break;
}
s[j] = static_cast<char>(tolower(styler[i + j]));
}
if (j == MAX_KW_LEN + 1) {
// Keyword too long, don't test it
s[0] = '\0';
} else {
s[j] = '\0';
}
if (!foldOnlyBegin && endFound && (strcmp(s, "if") == 0 || strcmp(s, "while") == 0 || strcmp(s, "loop") == 0)) {
endFound = false;
levelNext--;
if (levelNext < SC_FOLDLEVELBASE) {
levelNext = SC_FOLDLEVELBASE;
}
// Note that else is special here. It may or may be followed by an if then, but in aly case the level stays the
// same. When followed by a if .. then, the level will be increased later, if not, at eol.
} else if (!foldOnlyBegin && strcmp(s, "else") == 0) {
levelNext--;
elseFound = true;
} else if (!foldOnlyBegin && strcmp(s, "then") == 0) {
if(whenFound) {
whenFound = false;
} else {
levelNext++;
}
} else if (strcmp(s, "if") == 0) {
elseFound = false;
} else if (strcmp(s, "when") == 0) {
whenFound = true;
} else if (strcmp(s, "begin") == 0) {
levelNext++;
} else if (!foldOnlyBegin && (strcmp(s, "loop") == 0 || strcmp(s, "repeat") == 0
|| strcmp(s, "while") == 0)) {
if(endFound) {
endFound = false;
} else {
levelNext++;
}
} else if (strcmp(s, "end") == 0) {
// Multiple END in a row are counted multiple times!
if (endFound) {
levelNext--;
if (levelNext < SC_FOLDLEVELBASE) {
levelNext = SC_FOLDLEVELBASE;
}
}
endFound = true;
whenFound = false;
}
}
// Handle this for a trailing end withiut an if / while etc, as in the case of a begin.
if (endFound) {
endFound = false;
levelNext--;
if (levelNext < SC_FOLDLEVELBASE) {
levelNext = SC_FOLDLEVELBASE;
}
}
if (atEOL) {
if(elseFound)
levelNext++;
elseFound = false;
int levelUse = levelCurrent;
int lev = levelUse | levelNext << 16;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if (levelUse < levelNext)
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelCurrent = levelNext;
visibleChars = 0;
endFound = false;
whenFound = false;
}
if (!isspacechar(ch)) {
visibleChars++;
}
}
}
static const char * const mysqlWordListDesc[] = {
"Major Keywords",
"Keywords",
"Database Objects",
"Functions",
"System Variables",
"Procedure keywords",
"User Keywords 1",
"User Keywords 2",
"User Keywords 3"
};
LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc);