Integrating github/staging through commit ab87ed9
This commit is contained in:
@@ -194,9 +194,6 @@ void CColorGradientCtrl::paintEvent(QPaintEvent* e)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CColorGradientCtrl::DrawGradient(QPaintEvent* e, QPainter* painter)
|
||||
{
|
||||
int cx = m_rcGradient.width();
|
||||
int cy = m_rcGradient.height();
|
||||
|
||||
//Draw Curve
|
||||
// create and select a thick, white pen
|
||||
painter->setPen(QPen(QColor(128, 255, 128), 1, Qt::SolidLine));
|
||||
|
||||
@@ -1210,7 +1210,6 @@ ConsoleVariableEditor::ConsoleVariableEditor(QWidget* parent)
|
||||
mainLayout->addWidget(m_tableView, 1);
|
||||
|
||||
// Set the console variables
|
||||
IConsole* console = GetIEditor()->GetSystem()->GetIConsole();
|
||||
m_varBlock = VarBlockFromConsoleVars();
|
||||
SetVarBlock(m_varBlock);
|
||||
}
|
||||
|
||||
@@ -243,8 +243,6 @@ void QBitmapPreviewDialogImp::refreshData()
|
||||
|
||||
int w = m_image->GetWidth();
|
||||
int h = m_image->GetHeight();
|
||||
bool hasAlpha = m_image->HasAlphaChannel();
|
||||
bool isLimitedHDR = m_image->IsLimitedHDR();
|
||||
|
||||
int multiplier = (m_showMode == ESHOW_RGB_ALPHA ? 2 : 1);
|
||||
int originalW = w * multiplier;
|
||||
|
||||
@@ -215,7 +215,6 @@ void QRollupCtrl::writeSettings(const QString& qSettingsGroup)
|
||||
|
||||
void QRollupCtrl::updateTabs()
|
||||
{
|
||||
QRollupCtrlButton* lastButton = 0;
|
||||
for (auto i = m_pageList.constBegin(); i != m_pageList.constEnd(); ++i)
|
||||
{
|
||||
QRollupCtrlButton* tB = (*i).button;
|
||||
|
||||
@@ -494,8 +494,6 @@ void QToolTipWidget::KeepTipOnScreen(QRect targetRect, ArrowDirection preferredA
|
||||
|
||||
QPolygonF QToolTipWidget::QArrow::CreateArrow()
|
||||
{
|
||||
int height = 10;
|
||||
|
||||
QVector<QPointF> vertex;
|
||||
//3 points in triangle
|
||||
vertex.reserve(3);
|
||||
@@ -645,4 +643,4 @@ void QToolTipWrapper::DestroyToolTip()
|
||||
{
|
||||
m_actualTooltip->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ CReflectedVarAnimation AnimationPropertyCtrl::value() const
|
||||
|
||||
void AnimationPropertyCtrl::OnApplyClicked()
|
||||
{
|
||||
CUIEnumerations &roGeneralProxy = CUIEnumerations::GetUIEnumerationsInstance();
|
||||
QStringList cSelectedAnimations;
|
||||
size_t nTotalAnimations(0);
|
||||
size_t nCurrentAnimation(0);
|
||||
|
||||
@@ -191,9 +191,6 @@ void CSplineCtrl::DrawGrid(QPainter* painter)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CSplineCtrl::DrawSpline(QPainter* painter)
|
||||
{
|
||||
int cx = m_rcSpline.width();
|
||||
int cy = m_rcSpline.height();
|
||||
|
||||
//Draw Curve
|
||||
// create and select a thick, white pen
|
||||
const QPen pOldPen = painter->pen();
|
||||
|
||||
@@ -2671,7 +2671,6 @@ void AbstractSplineWidget::SelectAll()
|
||||
for (int splineIndex = 0, splineCount = m_splines.size(); splineIndex < splineCount; ++splineIndex)
|
||||
{
|
||||
ISplineInterpolator* pSpline = m_splines[splineIndex].pSpline;
|
||||
ISplineInterpolator* pDetailSpline = m_splines[splineIndex].pDetailSpline;
|
||||
|
||||
for (int i = 0; i < (int)pSpline->GetKeyCount(); i++)
|
||||
{
|
||||
@@ -2721,7 +2720,6 @@ void SplineWidget::SetTimelineCtrl(TimelineWidget* pTimelineCtrl)
|
||||
m_pTimelineCtrl = pTimelineCtrl;
|
||||
if (m_pTimelineCtrl)
|
||||
{
|
||||
QWidget* pOwner = pTimelineCtrl->parentWidget();
|
||||
pTimelineCtrl->setParent(this);
|
||||
pTimelineCtrl->SetZoom(m_grid.zoom.x);
|
||||
pTimelineCtrl->SetOrigin(m_grid.origin.x);
|
||||
|
||||
@@ -1,461 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or
|
||||
* a third party where indicated.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// SyntaxColorizer.cpp: implementation of the CSyntaxColorizer class.
|
||||
//
|
||||
// Version: 1.0.0
|
||||
// Author: Jeff Schering jeffschering@hotmail.com
|
||||
// Date: Jan 2001
|
||||
// Copyright 2001 by Jeff Schering
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "EditorDefs.h"
|
||||
|
||||
#include "SyntaxColorizer.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CSyntaxColorizer::CSyntaxColorizer(QTextDocument *pParent)
|
||||
: QSyntaxHighlighter(pParent)
|
||||
{
|
||||
createDefaultCharFormat();
|
||||
SetCommentColor(CLR_COMMENT);
|
||||
SetStringColor(CLR_STRING);
|
||||
createTables();
|
||||
m_pskKeyword = NULL;
|
||||
createDefaultKeywordList();
|
||||
}
|
||||
|
||||
CSyntaxColorizer::~CSyntaxColorizer()
|
||||
{
|
||||
ClearKeywordList();
|
||||
deleteTables();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Member Functions
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
void CSyntaxColorizer::createDefaultCharFormat()
|
||||
{
|
||||
m_cfComment = m_cfDefault;
|
||||
m_cfString = m_cfDefault;
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::createDefaultKeywordList()
|
||||
{
|
||||
const char *sKeywords = "__asm,else,main,struct,__assume,enum,"
|
||||
"__multiple_inheritance,switch,auto,__except,__single_inheritance,"
|
||||
"template,__based,explicit,__virtual_inheritance,this,bool,extern,"
|
||||
"mutable,thread,break,false,naked,throw,case,__fastcall,namespace,"
|
||||
"true,catch,__finally,new,try,__cdecl,float,noreturn,__try,char,for,"
|
||||
"operator,typedef,class,friend,private,typeid,const,goto,protected,"
|
||||
"typename,const_cast,if,public,union,continue,inline,register,"
|
||||
"unsigned,__declspec,__inline,reinterpret_cast,using,declaration,"
|
||||
"directive,default,int,return,uuid,delete,__int8,short,"
|
||||
"__uuidof,dllexport,__int16,signed,virtual,dllimport,__int32,sizeof,"
|
||||
"void,do,__int64,static,volatile,double,__leave,static_cast,wmain,"
|
||||
"dynamic_cast,long,__stdcall,while";
|
||||
const char *sDirectives = "#define,#elif,#else,#endif,#error,#ifdef,"
|
||||
"#ifndef,#import,#include,#line,#pragma,#undef";
|
||||
const char *sPragmas = "alloc_text,comment,init_seg1,optimize,auto_inline,"
|
||||
"component,inline_depth,pack,bss_seg,data_seg,"
|
||||
"inline_recursion,pointers_to_members1,check_stack,"
|
||||
"function,intrinsic,setlocale,code_seg,hdrstop,message,"
|
||||
"vtordisp1,const_seg,include_alias,once,warning";
|
||||
|
||||
AddKeyword(sKeywords,CLR_KEYWORD,GRP_KEYWORD);
|
||||
AddKeyword(sDirectives,CLR_KEYWORD,GRP_KEYWORD);
|
||||
AddKeyword(sPragmas,CLR_KEYWORD,GRP_KEYWORD);
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::createTables()
|
||||
{
|
||||
m_pTableZero = new unsigned char[256]; m_pTableOne = new unsigned char[256];
|
||||
m_pTableTwo = new unsigned char[256]; m_pTableThree = new unsigned char[256];
|
||||
m_pTableFour = new unsigned char[256]; m_pAllowable = new unsigned char[256];
|
||||
|
||||
memset(m_pTableZero,SKIP,256); memset(m_pTableOne,SKIP,256);
|
||||
memset(m_pTableTwo,SKIP,256); memset(m_pTableThree,SKIP,256);
|
||||
memset(m_pTableFour,SKIP,256); memset(m_pAllowable,false,256);
|
||||
|
||||
*(m_pTableZero + int('"')) = DQSTART; *(m_pTableZero + int('\'')) = SQSTART;
|
||||
*(m_pTableZero + int('/')) = CMSTART; *(m_pTableOne + int('"')) = DQEND;
|
||||
*(m_pTableTwo + int('\'')) = SQEND;
|
||||
*(m_pTableFour + int('*')) = MLEND;
|
||||
|
||||
*(m_pAllowable + int('\n')) = true; *(m_pAllowable + int('\r')) = true;
|
||||
*(m_pAllowable + int('\t')) = true; *(m_pAllowable + int('\0')) = true;
|
||||
*(m_pAllowable + int(' ')) = true; *(m_pAllowable + int(';')) = true;
|
||||
*(m_pAllowable + int('(')) = true; *(m_pAllowable + int(')')) = true;
|
||||
*(m_pAllowable + int('{')) = true; *(m_pAllowable + int('}')) = true;
|
||||
*(m_pAllowable + int('[')) = true; *(m_pAllowable + int(']')) = true;
|
||||
*(m_pAllowable + int('*')) = true;
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::deleteTables()
|
||||
{
|
||||
delete m_pTableZero; delete m_pTableOne; delete m_pTableTwo;
|
||||
delete m_pTableThree; delete m_pTableFour; delete m_pAllowable;
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::AddKeyword(const char *Keyword, const QBrush &cr, int grp)
|
||||
{
|
||||
QTextCharFormat cf = m_cfDefault;
|
||||
cf.setForeground(cr);
|
||||
|
||||
for (auto token : QString(Keyword).split(","))
|
||||
{
|
||||
addKey(token,cf,grp);
|
||||
}
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::AddKeyword(const char *Keyword, const QTextCharFormat& cf, int grp)
|
||||
{
|
||||
for (auto token : QString(Keyword).split(","))
|
||||
{
|
||||
addKey(token,cf,grp);
|
||||
}
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::addKey(const QString& Keyword, const QTextCharFormat& cf, int grp) //add in ascending order
|
||||
{
|
||||
SKeyword* pskNewKey = new SKeyword;
|
||||
SKeyword* prev,*curr;
|
||||
|
||||
pskNewKey->keyword = Keyword;
|
||||
|
||||
m_keywords[pskNewKey->keyword] = pskNewKey;
|
||||
|
||||
pskNewKey->cf = cf;
|
||||
pskNewKey->group = grp;
|
||||
pskNewKey->pNext = NULL;
|
||||
*(m_pTableZero + pskNewKey->keyword[0].toLatin1()) = KEYWORD;
|
||||
|
||||
//if list is empty, add first node
|
||||
if(m_pskKeyword == NULL)
|
||||
m_pskKeyword = pskNewKey;
|
||||
else
|
||||
{
|
||||
//check to see if new node goes before first node
|
||||
if(Keyword.compare(m_pskKeyword->keyword) < 0)
|
||||
{
|
||||
pskNewKey->pNext = m_pskKeyword;
|
||||
m_pskKeyword = pskNewKey;
|
||||
}
|
||||
//check to see if new keyword already exists at the first node
|
||||
else if(Keyword == m_pskKeyword->keyword)
|
||||
{
|
||||
//the keyword exists, so replace the existing with the new
|
||||
pskNewKey->pNext = m_pskKeyword->pNext;
|
||||
delete m_pskKeyword;
|
||||
m_pskKeyword = pskNewKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev = m_pskKeyword;
|
||||
curr = m_pskKeyword->pNext;
|
||||
while(curr != NULL && curr->keyword.compare(Keyword) < 0)
|
||||
{
|
||||
prev = curr;
|
||||
curr = curr->pNext;
|
||||
}
|
||||
if(curr != NULL && curr->keyword == Keyword)
|
||||
{
|
||||
//the keyword exists, so replace the existing with the new
|
||||
prev->pNext = pskNewKey;
|
||||
pskNewKey->pNext = curr->pNext;
|
||||
delete curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
pskNewKey->pNext = curr;
|
||||
prev->pNext = pskNewKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::ClearKeywordList()
|
||||
{
|
||||
SKeyword* pTemp = m_pskKeyword;
|
||||
|
||||
m_keywords.clear();
|
||||
|
||||
while(m_pskKeyword != NULL)
|
||||
{
|
||||
*(m_pTableZero + m_pskKeyword->keyword[0].toLatin1()) = SKIP;
|
||||
pTemp = m_pskKeyword->pNext;
|
||||
delete m_pskKeyword;
|
||||
m_pskKeyword = pTemp;
|
||||
}
|
||||
}
|
||||
|
||||
QString CSyntaxColorizer::GetKeywordList()
|
||||
{
|
||||
QString sList;
|
||||
|
||||
SKeyword* pTemp = m_pskKeyword;
|
||||
|
||||
while(pTemp != NULL)
|
||||
{
|
||||
if(!sList.isEmpty())
|
||||
sList += QLatin1Char(',');
|
||||
sList += pTemp->keyword;
|
||||
pTemp = pTemp->pNext;
|
||||
}
|
||||
|
||||
return sList;
|
||||
}
|
||||
|
||||
QString CSyntaxColorizer::GetKeywordList(int grp)
|
||||
{
|
||||
QString sList;
|
||||
|
||||
SKeyword* pTemp = m_pskKeyword;
|
||||
|
||||
while(pTemp != NULL)
|
||||
{
|
||||
if(pTemp->group == grp)
|
||||
{
|
||||
if(!sList.isEmpty())
|
||||
sList += QLatin1Char(',');
|
||||
sList += pTemp->keyword;
|
||||
}
|
||||
pTemp = pTemp->pNext;
|
||||
}
|
||||
|
||||
return sList;
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::SetCommentColor(const QBrush& cr)
|
||||
{
|
||||
QTextCharFormat cf = m_cfComment;
|
||||
cf.setForeground(cr);
|
||||
|
||||
SetCommentStyle(cf);
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::SetStringColor(const QBrush& cr)
|
||||
{
|
||||
QTextCharFormat cf = m_cfString;
|
||||
|
||||
cf.setForeground(cr);
|
||||
|
||||
SetStringStyle(cf);
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::SetGroupStyle(int grp, const QTextCharFormat& cf)
|
||||
{
|
||||
SKeyword* pTemp = m_pskKeyword;
|
||||
|
||||
while(pTemp != NULL)
|
||||
{
|
||||
if(pTemp->group == grp)
|
||||
{
|
||||
pTemp->cf = cf;
|
||||
}
|
||||
pTemp = pTemp->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::GetGroupStyle(int grp, QTextCharFormat& cf)
|
||||
{
|
||||
SKeyword* pTemp = m_pskKeyword;
|
||||
|
||||
while(pTemp != NULL)
|
||||
{
|
||||
if(pTemp->group == grp)
|
||||
{
|
||||
cf = pTemp->cf;
|
||||
pTemp = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pTemp = pTemp->pNext;
|
||||
//if grp is not found, return default style
|
||||
if(pTemp == NULL) cf = m_cfDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::SetGroupColor(int grp, const QBrush& cr)
|
||||
{
|
||||
QTextCharFormat cf;
|
||||
GetGroupStyle(grp,cf);
|
||||
|
||||
cf.setForeground(cr);
|
||||
|
||||
SetGroupStyle(grp,cf);
|
||||
}
|
||||
|
||||
void CSyntaxColorizer::highlightBlock(const QString& text)
|
||||
{
|
||||
//setup some vars
|
||||
char sWord[4096];
|
||||
QTextCharFormat cf;
|
||||
const char *lpszTemp;
|
||||
long iStart = 0;
|
||||
long x = 0;
|
||||
SKeyword* pskTemp = m_pskKeyword;
|
||||
|
||||
QByteArray latin1Text = text.toLatin1();
|
||||
const char *lpszBuf = latin1Text.constData();
|
||||
|
||||
const unsigned char *ppTables[] = { m_pTableZero, m_pTableOne, m_pTableTwo, m_pTableThree, m_pTableFour };
|
||||
int iState = previousBlockState();
|
||||
if (iState == -1)
|
||||
iState = 0;
|
||||
|
||||
//do the work
|
||||
while(lpszBuf[x])
|
||||
{
|
||||
switch(ppTables[iState][int(lpszBuf[x])])
|
||||
{
|
||||
case DQSTART:
|
||||
iState = 1;
|
||||
iStart = x;
|
||||
break;
|
||||
case SQSTART:
|
||||
iState = 2;
|
||||
iStart = x;
|
||||
break;
|
||||
case CMSTART:
|
||||
if(lpszBuf[x+1] == '/')
|
||||
{
|
||||
iState = 3;
|
||||
iStart = x;
|
||||
x++;
|
||||
}
|
||||
else if(lpszBuf[x+1] == '*')
|
||||
{
|
||||
iState = 4;
|
||||
iStart = x;
|
||||
x++;
|
||||
}
|
||||
else if(lpszBuf[x] == '\'')
|
||||
{
|
||||
iState = 3;
|
||||
iStart = x;
|
||||
x++;
|
||||
}
|
||||
|
||||
break;
|
||||
case MLEND:
|
||||
if(lpszBuf[x+1] == '/')
|
||||
{
|
||||
x++;
|
||||
iState = 0;
|
||||
setFormat(iStart, x + 1 - iStart, m_cfComment);
|
||||
}
|
||||
break;
|
||||
case DQEND:
|
||||
iState = 0;
|
||||
setFormat(iStart, x + 1 - iStart, m_cfString);
|
||||
break;
|
||||
case SQEND:
|
||||
if(lpszBuf[x-1] == '\\' && lpszBuf[x+1] == '\'')
|
||||
break;
|
||||
iState = 0;
|
||||
setFormat(iStart, x + 1 - iStart, m_cfString);
|
||||
break;
|
||||
|
||||
case KEYWORD:
|
||||
// Extract whole word.
|
||||
lpszTemp = lpszBuf+x;
|
||||
{
|
||||
if (x > 0 && !m_pAllowable[int(lpszBuf[x-1])])
|
||||
break;
|
||||
|
||||
int i = 0;
|
||||
while (!m_pAllowable[int(lpszTemp[i])])
|
||||
{
|
||||
sWord[i] = lpszTemp[i];
|
||||
i++;
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
sWord[i] = 0;
|
||||
// Word extracted.
|
||||
// Find keyword.
|
||||
Keywords::iterator it = m_keywords.find( QString(sWord) );
|
||||
if (it != m_keywords.end())
|
||||
{
|
||||
int iStart2 = x;
|
||||
pskTemp = it->second;
|
||||
x += pskTemp->keyword.size();
|
||||
setFormat(iStart2, x - iStart2, pskTemp->cf);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
lpszTemp = lpszBuf+x;
|
||||
while(pskTemp != NULL)
|
||||
{
|
||||
if(pskTemp->keyword[0] == lpszTemp[0])
|
||||
{
|
||||
int x1=0,y1=0;iStart = iOffset + x;
|
||||
while(pskTemp->keyword[x1])
|
||||
{
|
||||
y1 += lpszTemp[x1] ^ pskTemp->keyword[x1];
|
||||
x1++;
|
||||
}
|
||||
if(y1 == 0 && (*(m_pAllowable + (lpszBuf[x-1])) &&
|
||||
*(m_pAllowable + (lpszBuf[x+pskTemp->keylen]))))
|
||||
{
|
||||
if(_stricmp(pskTemp->keyword,"rem") == 0)
|
||||
{
|
||||
pTable = m_pTableThree;
|
||||
}
|
||||
else
|
||||
{
|
||||
x += pskTemp->keylen;
|
||||
pCtrl->SetSel(iStart,iOffset + x);
|
||||
pCtrl->SetSelectionCharFormat(pskTemp->cf);
|
||||
}
|
||||
}
|
||||
}
|
||||
pskTemp = pskTemp->pNext;
|
||||
}
|
||||
*/
|
||||
pskTemp = m_pskKeyword;
|
||||
break;
|
||||
case SKIP:;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
//sometimes we get to the end of the file before the end of the string
|
||||
//or comment, so we deal with that situation here
|
||||
if(iState == 1)
|
||||
{
|
||||
setFormat(iStart, x + 1 - iStart, m_cfString);
|
||||
}
|
||||
else if(iState == 2)
|
||||
{
|
||||
setFormat(iStart, x + 1 - iStart, m_cfString);
|
||||
}
|
||||
else if(iState == 3)
|
||||
{
|
||||
setFormat(iStart, x + 1 - iStart, m_cfComment);
|
||||
if(lpszBuf[x-2] != '\\') // line continuation character
|
||||
iState = 0;
|
||||
}
|
||||
else if(iState == 4)
|
||||
{
|
||||
setFormat(iStart, x + 1 - iStart, m_cfComment);
|
||||
}
|
||||
|
||||
setCurrentBlockState(iState);
|
||||
}
|
||||
|
||||
#include <Controls/moc_SyntaxColorizer.cpp>
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : interface for the CSyntaxColorizer class.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_EDITOR_CONTROLS_SYNTAXCOLORIZER_H
|
||||
#define CRYINCLUDE_EDITOR_CONTROLS_SYNTAXCOLORIZER_H
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <QSyntaxHighlighter>
|
||||
#endif
|
||||
|
||||
#define CLR_STRING QColor(55, 0, 200)
|
||||
#define CLR_PLAIN QColor(0, 0, 0)
|
||||
#define CLR_COMMENT QColor(0, 170, 0)
|
||||
#define CLR_KEYWORD QColor(0, 0, 255)
|
||||
#define GRP_KEYWORD 0
|
||||
|
||||
class CSyntaxColorizer
|
||||
: public QSyntaxHighlighter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CSyntaxColorizer(QTextDocument* pParent = nullptr);
|
||||
virtual ~CSyntaxColorizer();
|
||||
|
||||
//protected vars
|
||||
protected:
|
||||
unsigned char* m_pTableZero, * m_pTableOne;
|
||||
unsigned char* m_pTableTwo, * m_pTableThree;
|
||||
unsigned char* m_pTableFour, * m_pAllowable;
|
||||
|
||||
enum Types
|
||||
{
|
||||
SKIP,
|
||||
DQSTART, //Double Quotes start
|
||||
DQEND, //Double Quotes end
|
||||
SQSTART, //Single Quotes start
|
||||
SQEND, //Single Quotes end
|
||||
CMSTART, //Comment start (both single and multi line)
|
||||
MLEND, //Multi line comment end
|
||||
KEYWORD //Keyword start
|
||||
} m_type;
|
||||
|
||||
struct SKeyword
|
||||
{
|
||||
QString keyword;
|
||||
int keylen;
|
||||
QTextCharFormat cf;
|
||||
int group;
|
||||
SKeyword* pNext;
|
||||
SKeyword() { pNext = NULL; }
|
||||
};
|
||||
|
||||
SKeyword* m_pskKeyword;
|
||||
QTextCharFormat m_cfComment;
|
||||
QTextCharFormat m_cfString;
|
||||
QTextCharFormat m_cfDefault;
|
||||
|
||||
//typedef std::map<LPCSTR,SKeyword*,> Keywords;
|
||||
//typedef std::hash_map<const char*,SKeyword*,stl::hash_strcmp<const char*> > Keywords;
|
||||
|
||||
//typedef std::map<const char*,SKeyword*,stl::hash_strcmp<const char*> > Keywords;
|
||||
typedef std::map<QString, SKeyword*> Keywords;
|
||||
|
||||
Keywords m_keywords;
|
||||
|
||||
//protected member functions
|
||||
protected:
|
||||
void addKey(const QString& Keyword, const QTextCharFormat& cf, int grp);
|
||||
void createTables();
|
||||
void deleteTables();
|
||||
void createDefaultKeywordList();
|
||||
void createDefaultCharFormat();
|
||||
|
||||
//public member functions
|
||||
public:
|
||||
void highlightBlock(const QString& text) override;
|
||||
|
||||
void GetCommentStyle(QTextCharFormat& cf) { cf = m_cfComment; };
|
||||
void GetStringStyle(QTextCharFormat& cf) { cf = m_cfString; };
|
||||
void GetGroupStyle(int grp, QTextCharFormat& cf);
|
||||
void GetDefaultStyle(QTextCharFormat& cf) { cf = m_cfDefault; };
|
||||
|
||||
void SetCommentStyle(const QTextCharFormat& cf) { m_cfComment = cf; };
|
||||
void SetCommentColor(const QBrush& cr);
|
||||
void SetStringStyle(const QTextCharFormat& cf) { m_cfString = cf; };
|
||||
void SetStringColor(const QBrush& cr);
|
||||
void SetGroupStyle(int grp, const QTextCharFormat& cf);
|
||||
void SetGroupColor(int grp, const QBrush& cr);
|
||||
void SetDefaultStyle(const QTextCharFormat& cf) { m_cfDefault = cf; };
|
||||
|
||||
void AddKeyword(const char* Keyword, const QTextCharFormat& cf, int grp = 0);
|
||||
void AddKeyword(const char* Keyword, const QBrush& cr, int grp = 0);
|
||||
void ClearKeywordList();
|
||||
QString GetKeywordList();
|
||||
QString GetKeywordList(int grp);
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_EDITOR_CONTROLS_SYNTAXCOLORIZER_H
|
||||
|
||||
@@ -15,69 +15,12 @@
|
||||
|
||||
#include "TextEditorCtrl.h"
|
||||
|
||||
#define GRP_KEYWORD 0
|
||||
#define GRP_CONSTANTS 1
|
||||
#define GRP_DIRECTIVE 2
|
||||
#define GRP_PRAGMA 3
|
||||
|
||||
|
||||
// CTextEditorCtrl
|
||||
|
||||
CTextEditorCtrl::CTextEditorCtrl(QWidget* pParent)
|
||||
: QTextEdit(pParent)
|
||||
, m_sc(document())
|
||||
{
|
||||
/*
|
||||
//reconfigure CSyntaxColorizer's default keyword groupings
|
||||
LPTSTR sKeywords = "for,for,else,main,struct,enum,switch,auto,"
|
||||
"template,explicit,this,bool,extern,thread,break,false,"
|
||||
"throw,case,namespace,true,catch,new,try,float,noreturn,"
|
||||
"char,operator,typedef,class,friend,private,const,goto,"
|
||||
"protected,typename,if,public,union,continue,inline,"
|
||||
"unsigned,using,directive,default,int,return,delete,short,"
|
||||
"signed,virtual,sizeof,void,do,static,double,long,while";
|
||||
LPTSTR sDirectives = "#define,#elif,#else,#endif,#error,#ifdef,"
|
||||
"#ifndef,#import,#include,#line,#pragma,#undef";
|
||||
LPTSTR sPragmas = "comment,optimize,auto_inline,once,warning,"
|
||||
"component,pack,function,intrinsic,setlocale,hdrstop,message";
|
||||
|
||||
m_sc.ClearKeywordList();
|
||||
m_sc.AddKeyword(sKeywords,QColor(0,0,255),GRP_KEYWORD);
|
||||
m_sc.AddKeyword(sDirectives,QColor(0,0,255),GRP_DIRECTIVE);
|
||||
m_sc.AddKeyword(sPragmas,QColor(0,0,255),GRP_PRAGMA);
|
||||
m_sc.AddKeyword("REM,Rem,rem",QColor(255,0,255),4);
|
||||
*/
|
||||
const char* sKeywords = "Shader,ShadeLayer,HW,LightStyle,ValueString,Orient,Origin,Params,Array,Template,Templates,"
|
||||
"Version,CGVProgram,CGVPParam,Name,"
|
||||
"DeclareLightMaterial,Side,Ambient,Diffuse,Specular,Emission,Shininess,"
|
||||
"Layer,Map,RGBGen,RgbGen,AlphaGen,NoDepthTest,Blend,TexCoordMod,Scale,UScale,VScale,ShiftNoise,Noise,SRange,TRange,"
|
||||
"Cull,Sort,State,NoCull,ShadowMapGen,Conditions,Vars,DepthWrite,NoColorMask,Portal,LMNoAlpha,"
|
||||
"TexColorOp,TexStage,TexType,TexFilter,TexGen,UpdateStyle,EvalLight,Style,TexDecal,Tex1Decal,TexBump,"
|
||||
"RCParam,RCombiner,RShader,TSParam,Reg,Comp,DepthMask,AlphaFunc,Light,LightType,ClipPlane,PlaneS,PlaneT,"
|
||||
"PolygonOffset,NoLightmap,ShineMap,Turbulence,tcMod,Procedure,TessSize,Spark,Sequence,Maps,Time,Loop,"
|
||||
"Mask,Public,float,RenderParams,User,"
|
||||
"rgbGen,blend,map,"
|
||||
"Translate,Identity,Rotate,RotateX,RotateY,RotateZ,Div,DeformGen,Scroll,UScroll,VScroll,Angle"
|
||||
"Type,Level,Amp,Phase,Freq,DeformVertexes,FlareSize,NoLight,Const,Start,"
|
||||
"Matrix,FLOAT,BYTE,Verts,Vertex,Normal,Normals,Color,Texture0,Texture1,Texture2,Texture3,Texture4,TNormals";
|
||||
|
||||
const char* sConstants = "Decal,None,Nearest,TwoSided,RCRGBToAlpha,OcclusionTest,NoSet,Replace,FromClient,"
|
||||
"Opaque,MonitorNoise,Point,Front,Back,Water,TriLinear,"
|
||||
"MuzzleFlash,FromObj,Modulate,Base,SphereMap,Add,Glare,Additive,Intensity,White,Sin,Cos,Tan,"
|
||||
"$Diffuse,$None,$Specular,$Whiteimage,$Environment,$Glare,$Opacity,$Flare";
|
||||
|
||||
const char* sDirectives = "#define,#elif,#else,#endif,#error,#ifdef,"
|
||||
"#ifndef,#import,#include,#line,#pragma,#undef";
|
||||
|
||||
m_sc.ClearKeywordList();
|
||||
m_sc.AddKeyword(sKeywords, QColor(0, 0, 255), GRP_KEYWORD);
|
||||
m_sc.AddKeyword(sConstants, QColor(180, 0, 110), GRP_CONSTANTS);
|
||||
m_sc.AddKeyword(sDirectives, QColor(160, 0, 160), GRP_DIRECTIVE);
|
||||
|
||||
m_sc.SetCommentColor(QColor(0, 128, 128));
|
||||
m_sc.SetStringColor(QColor(0, 128, 0));
|
||||
|
||||
m_bModified = true;
|
||||
m_bModified = true;
|
||||
|
||||
QFont font;
|
||||
font.setFamily("Courier New");
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
// CTextEditorCtrl
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include "SyntaxColorizer.h"
|
||||
|
||||
#include <QTextEdit>
|
||||
#endif
|
||||
|
||||
@@ -42,7 +40,6 @@ public:
|
||||
|
||||
protected:
|
||||
QString m_filename;
|
||||
CSyntaxColorizer m_sc;
|
||||
bool m_bModified;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user