2021-04-06 23:10:57 +08:00
|
|
|
#include "editor.h"
|
|
|
|
|
|
|
|
#include <QtCore/QFileInfo>
|
2021-04-09 17:48:25 +08:00
|
|
|
#include <QFont>
|
2021-04-08 10:29:21 +08:00
|
|
|
#include <QTextCodec>
|
2021-04-07 22:44:08 +08:00
|
|
|
#include <QVariant>
|
2021-04-09 17:48:25 +08:00
|
|
|
#include <QWheelEvent>
|
2021-04-07 21:13:15 +08:00
|
|
|
#include <memory>
|
2021-04-08 10:29:21 +08:00
|
|
|
#include "settings.h"
|
|
|
|
#include "mainwindow.h"
|
2021-04-11 21:33:08 +08:00
|
|
|
#include "systemconsts.h"
|
2021-04-11 12:39:22 +08:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QDebug>
|
2021-06-12 22:36:23 +08:00
|
|
|
#include <QMimeData>
|
2021-05-24 00:41:00 +08:00
|
|
|
#include "qsynedit/highlighter/cpp.h"
|
2021-05-26 00:04:20 +08:00
|
|
|
#include "HighlighterManager.h"
|
2021-06-12 22:36:23 +08:00
|
|
|
#include "qsynedit/exporter/synrtfexporter.h"
|
|
|
|
#include "qsynedit/exporter/synhtmlexporter.h"
|
2021-06-19 22:58:35 +08:00
|
|
|
#include "qsynedit/Constants.h"
|
2021-06-12 22:36:23 +08:00
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QClipboard>
|
2021-06-24 16:05:19 +08:00
|
|
|
#include <QPainter>
|
|
|
|
#include "iconsmanager.h"
|
2021-05-24 00:41:00 +08:00
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
|
|
|
|
using namespace std;
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-04-11 21:33:08 +08:00
|
|
|
SaveException::SaveException(const QString& reason) {
|
|
|
|
mReason = reason;
|
|
|
|
}
|
|
|
|
SaveException::SaveException(const QString&& reason) {
|
|
|
|
mReason = reason;
|
|
|
|
}
|
|
|
|
const QString& SaveException::reason() const noexcept{
|
|
|
|
return mReason;
|
|
|
|
}
|
|
|
|
const char *SaveException::what() const noexcept {
|
|
|
|
return mReason.toLocal8Bit();
|
|
|
|
}
|
|
|
|
|
2021-05-26 00:04:20 +08:00
|
|
|
int Editor::newfileCount=0;
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-06-19 22:58:35 +08:00
|
|
|
Editor::Editor(QWidget *parent):
|
|
|
|
Editor(parent,QObject::tr("untitled"),ENCODING_SYSTEM_DEFAULT,false,true,nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-04-09 17:48:25 +08:00
|
|
|
Editor::Editor(QWidget *parent, const QString& filename,
|
2021-04-08 10:29:21 +08:00
|
|
|
const QByteArray& encoding,
|
2021-04-06 23:10:57 +08:00
|
|
|
bool inProject, bool isNew,
|
|
|
|
QTabWidget* parentPageControl):
|
2021-05-24 00:41:00 +08:00
|
|
|
SynEdit(parent),
|
2021-04-08 10:29:21 +08:00
|
|
|
mEncodingOption(encoding),
|
2021-06-20 14:30:47 +08:00
|
|
|
mFilename(filename),
|
|
|
|
mParentPageControl(parentPageControl),
|
2021-04-06 23:10:57 +08:00
|
|
|
mInProject(inProject),
|
2021-06-24 16:05:19 +08:00
|
|
|
mIsNew(isNew),
|
|
|
|
mSyntaxErrorColor(QColorConstants::Red),
|
2021-06-24 20:43:09 +08:00
|
|
|
mSyntaxWaringColor("orange"),
|
|
|
|
mLineCount(0)
|
2021-04-06 23:10:57 +08:00
|
|
|
{
|
2021-04-07 21:13:15 +08:00
|
|
|
if (mFilename.isEmpty()) {
|
2021-05-26 00:04:20 +08:00
|
|
|
newfileCount++;
|
2021-06-07 21:34:48 +08:00
|
|
|
mFilename = tr("untitled%1").arg(newfileCount);
|
2021-04-07 21:13:15 +08:00
|
|
|
}
|
2021-04-06 23:10:57 +08:00
|
|
|
QFileInfo fileInfo(mFilename);
|
2021-06-19 22:58:35 +08:00
|
|
|
if (mParentPageControl!=nullptr) {
|
2021-04-11 12:39:22 +08:00
|
|
|
mParentPageControl->addTab(this,QString());
|
|
|
|
updateCaption();
|
|
|
|
}
|
2021-05-27 01:05:49 +08:00
|
|
|
PSynHighlighter highlighter;
|
2021-04-06 23:10:57 +08:00
|
|
|
if (!isNew) {
|
|
|
|
loadFile();
|
2021-06-07 11:02:03 +08:00
|
|
|
highlighter = highlighterManager.getHighlighter(mFilename);
|
2021-04-06 23:10:57 +08:00
|
|
|
} else {
|
2021-04-08 10:29:21 +08:00
|
|
|
if (mEncodingOption == ENCODING_AUTO_DETECT)
|
|
|
|
mFileEncoding = ENCODING_ASCII;
|
2021-04-07 21:13:15 +08:00
|
|
|
else
|
2021-04-08 10:29:21 +08:00
|
|
|
mFileEncoding = mEncodingOption;
|
2021-06-07 11:02:03 +08:00
|
|
|
highlighter=highlighterManager.getCppHighlighter();
|
2021-05-27 01:05:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (highlighter) {
|
|
|
|
setHighlighter(highlighter);
|
|
|
|
setUseCodeFolding(true);
|
|
|
|
} else {
|
|
|
|
setUseCodeFolding(false);
|
2021-04-06 23:10:57 +08:00
|
|
|
}
|
2021-04-09 17:48:25 +08:00
|
|
|
|
2021-06-07 11:02:03 +08:00
|
|
|
applySettings();
|
2021-06-20 14:30:47 +08:00
|
|
|
applyColorScheme(pSettings->editor().colorScheme());
|
2021-06-10 09:34:59 +08:00
|
|
|
|
|
|
|
connect(this,&SynEdit::statusChanged,this,&Editor::onStatusChanged);
|
2021-04-07 22:44:08 +08:00
|
|
|
}
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-04-07 22:44:08 +08:00
|
|
|
Editor::~Editor() {
|
2021-06-19 22:58:35 +08:00
|
|
|
if (mParentPageControl!=nullptr) {
|
2021-04-09 17:48:25 +08:00
|
|
|
int index = mParentPageControl->indexOf(this);
|
|
|
|
mParentPageControl->removeTab(index);
|
|
|
|
}
|
|
|
|
this->setParent(0);
|
|
|
|
|
2021-04-06 23:10:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::loadFile() {
|
|
|
|
QFile file(mFilename);
|
2021-05-24 00:41:00 +08:00
|
|
|
this->lines()->LoadFromFile(file,mEncodingOption,mFileEncoding);
|
2021-05-24 18:11:07 +08:00
|
|
|
this->setModified(false);
|
|
|
|
updateCaption();
|
2021-06-12 22:36:23 +08:00
|
|
|
pMainWindow->updateForEncodingInfo();
|
2021-06-25 12:40:11 +08:00
|
|
|
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
|
|
|
|
pMainWindow->checkSyntaxInBack(this);
|
2021-04-07 21:13:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::saveFile(const QString &filename) {
|
|
|
|
QFile file(filename);
|
2021-05-24 00:41:00 +08:00
|
|
|
this->lines()->SaveToFile(file,mEncodingOption,mFileEncoding);
|
2021-06-12 22:36:23 +08:00
|
|
|
pMainWindow->updateForEncodingInfo();
|
2021-06-25 12:40:11 +08:00
|
|
|
if (pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenSave())
|
|
|
|
pMainWindow->checkSyntaxInBack(this);
|
2021-06-12 22:36:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::convertToEncoding(const QByteArray &encoding)
|
|
|
|
{
|
|
|
|
mEncodingOption = encoding;
|
|
|
|
setModified(true);
|
|
|
|
save();
|
2021-04-06 23:10:57 +08:00
|
|
|
}
|
|
|
|
|
2021-04-09 10:08:05 +08:00
|
|
|
bool Editor::save(bool force, bool reparse) {
|
2021-04-11 12:39:22 +08:00
|
|
|
if (this->mIsNew) {
|
|
|
|
return saveAs();
|
|
|
|
}
|
|
|
|
QFileInfo info(mFilename);
|
2021-04-11 21:33:08 +08:00
|
|
|
//is this file writable;
|
2021-04-11 12:39:22 +08:00
|
|
|
if (!force && !info.isWritable()) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-06-20 22:54:16 +08:00
|
|
|
tr("File %1 is not writable!").arg(mFilename));
|
2021-04-11 12:39:22 +08:00
|
|
|
return false;
|
|
|
|
}
|
2021-05-24 00:41:00 +08:00
|
|
|
if (this->modified()|| force) {
|
2021-04-11 21:33:08 +08:00
|
|
|
try {
|
|
|
|
saveFile(mFilename);
|
|
|
|
setModified(false);
|
2021-06-12 22:36:23 +08:00
|
|
|
mIsNew = false;
|
|
|
|
this->updateCaption();
|
2021-04-11 21:33:08 +08:00
|
|
|
} catch (SaveException& exception) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-04-11 21:33:08 +08:00
|
|
|
exception.reason());
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-11 12:39:22 +08:00
|
|
|
}
|
2021-04-08 10:29:21 +08:00
|
|
|
|
2021-04-11 12:39:22 +08:00
|
|
|
if (reparse) {
|
|
|
|
//todo: reparse the file
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::saveAs(){
|
2021-04-11 21:33:08 +08:00
|
|
|
QString selectedFileFilter = pSystemConsts->defaultFileFilter();
|
2021-04-11 12:39:22 +08:00
|
|
|
QString newName = QFileDialog::getSaveFileName(pMainWindow,
|
2021-04-11 21:33:08 +08:00
|
|
|
tr("Save As"), QString(), pSystemConsts->defaultFileFilters().join(";;"),
|
|
|
|
&selectedFileFilter);
|
2021-04-11 12:39:22 +08:00
|
|
|
if (newName.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-11 21:33:08 +08:00
|
|
|
try {
|
|
|
|
mFilename = newName;
|
2021-06-12 22:36:23 +08:00
|
|
|
saveFile(mFilename);
|
2021-04-11 21:33:08 +08:00
|
|
|
mIsNew = false;
|
|
|
|
setModified(false);
|
2021-06-12 22:36:23 +08:00
|
|
|
this->updateCaption();
|
2021-04-11 21:33:08 +08:00
|
|
|
} catch (SaveException& exception) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-04-11 21:33:08 +08:00
|
|
|
exception.reason());
|
|
|
|
return false;
|
|
|
|
}
|
2021-04-11 12:39:22 +08:00
|
|
|
|
|
|
|
//todo: update (reassign highlighter)
|
|
|
|
//todo: remove old file from parser and reparse file
|
|
|
|
//todo: unmoniter/ monitor file
|
|
|
|
//todo: update windows caption
|
|
|
|
//todo: update class browser;
|
2021-04-08 10:29:21 +08:00
|
|
|
return true;
|
2021-04-06 23:10:57 +08:00
|
|
|
}
|
2021-04-08 10:29:21 +08:00
|
|
|
|
2021-04-12 00:00:29 +08:00
|
|
|
void Editor::activate()
|
|
|
|
{
|
2021-06-19 22:58:35 +08:00
|
|
|
if (mParentPageControl!=nullptr)
|
|
|
|
mParentPageControl->setCurrentWidget(this);
|
|
|
|
setFocus();
|
2021-04-12 00:00:29 +08:00
|
|
|
}
|
|
|
|
|
2021-04-11 21:33:08 +08:00
|
|
|
const QByteArray& Editor::encodingOption() const noexcept{
|
2021-04-08 10:29:21 +08:00
|
|
|
return mEncodingOption;
|
2021-04-06 23:10:57 +08:00
|
|
|
}
|
2021-04-11 21:33:08 +08:00
|
|
|
void Editor::setEncodingOption(const QByteArray& encoding) noexcept{
|
2021-04-08 10:29:21 +08:00
|
|
|
mEncodingOption = encoding;
|
2021-06-20 09:27:37 +08:00
|
|
|
if (!isNew())
|
|
|
|
loadFile();
|
2021-06-12 22:36:23 +08:00
|
|
|
else
|
|
|
|
pMainWindow->updateForEncodingInfo();
|
2021-04-08 10:29:21 +08:00
|
|
|
}
|
2021-04-11 21:33:08 +08:00
|
|
|
const QByteArray& Editor::fileEncoding() const noexcept{
|
2021-04-06 23:10:57 +08:00
|
|
|
return mFileEncoding;
|
|
|
|
}
|
2021-04-11 21:33:08 +08:00
|
|
|
const QString& Editor::filename() const noexcept{
|
2021-04-06 23:10:57 +08:00
|
|
|
return mFilename;
|
|
|
|
}
|
2021-04-11 21:33:08 +08:00
|
|
|
bool Editor::inProject() const noexcept{
|
2021-04-06 23:10:57 +08:00
|
|
|
return mInProject;
|
|
|
|
}
|
2021-04-11 21:33:08 +08:00
|
|
|
bool Editor::isNew() const noexcept {
|
2021-04-06 23:10:57 +08:00
|
|
|
return mIsNew;
|
|
|
|
}
|
2021-04-09 17:48:25 +08:00
|
|
|
|
2021-04-11 21:33:08 +08:00
|
|
|
QTabWidget* Editor::pageControl() noexcept{
|
2021-04-09 17:48:25 +08:00
|
|
|
return mParentPageControl;
|
|
|
|
}
|
|
|
|
|
2021-06-23 08:55:56 +08:00
|
|
|
void Editor::undoSymbolCompletion(int pos)
|
|
|
|
{
|
|
|
|
PSynHighlighterAttribute Attr;
|
|
|
|
QString Token;
|
|
|
|
bool tokenFinished;
|
|
|
|
SynHighlighterTokenType tokenType;
|
|
|
|
|
|
|
|
if (!highlighter())
|
|
|
|
return;
|
|
|
|
if (!pSettings->editor().removeSymbolPairs())
|
|
|
|
return;
|
|
|
|
if (!GetHighlighterAttriAtRowCol(caretXY(), Token, tokenFinished, tokenType, Attr))
|
|
|
|
return;
|
|
|
|
if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished))
|
|
|
|
return ;
|
|
|
|
//convert caret x to string index;
|
|
|
|
pos--;
|
|
|
|
|
|
|
|
if (pos<0 || pos+1>=lineText().length())
|
|
|
|
return;
|
|
|
|
QChar DeletedChar = lineText()[pos];
|
|
|
|
QChar NextChar = lineText()[pos+1];
|
|
|
|
if ((tokenType == SynHighlighterTokenType::Character) && (DeletedChar != '\''))
|
|
|
|
return;
|
|
|
|
if (tokenType == SynHighlighterTokenType::StringEscapeSequence)
|
|
|
|
return;
|
|
|
|
if (tokenType == SynHighlighterTokenType::String) {
|
|
|
|
if ((DeletedChar!='"') && (DeletedChar!='('))
|
|
|
|
return;
|
|
|
|
if ((DeletedChar=='"') && (Token!="\"\""))
|
|
|
|
return;
|
|
|
|
if ((DeletedChar=='(') && (!Token.startsWith("R\"")))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((DeletedChar == '\'') && (tokenType == SynHighlighterTokenType::Number))
|
|
|
|
return;
|
|
|
|
if ((DeletedChar == '<') &&
|
|
|
|
((tokenType != SynHighlighterTokenType::PreprocessDirective)
|
|
|
|
|| !lineText().startsWith("#include")))
|
|
|
|
return;
|
|
|
|
if ( (pSettings->editor().completeBracket() && (DeletedChar == '[') && (NextChar == ']')) ||
|
|
|
|
(pSettings->editor().completeParenthese() && (DeletedChar == '(') && (NextChar == ')')) ||
|
|
|
|
(pSettings->editor().completeGlobalInclude() && (DeletedChar == '<') && (NextChar == '>')) ||
|
|
|
|
(pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) ||
|
|
|
|
(pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) ||
|
|
|
|
(pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) {
|
|
|
|
CommandProcessor(SynEditorCommand::ecDeleteChar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-09 17:48:25 +08:00
|
|
|
void Editor::wheelEvent(QWheelEvent *event) {
|
|
|
|
if ( (event->modifiers() & Qt::ControlModifier)!=0) {
|
2021-06-12 22:36:23 +08:00
|
|
|
int size = pSettings->editor().fontSize();
|
2021-04-09 17:48:25 +08:00
|
|
|
if (event->angleDelta().y()>0) {
|
2021-06-12 22:36:23 +08:00
|
|
|
size = std::min(99,size+1);
|
|
|
|
pSettings->editor().setFontSize(size);
|
|
|
|
pMainWindow->updateEditorSettings();
|
2021-06-09 17:12:23 +08:00
|
|
|
event->accept();
|
|
|
|
return;
|
2021-07-01 19:44:38 +08:00
|
|
|
} else if (event->angleDelta().y()<0) {
|
2021-06-12 22:36:23 +08:00
|
|
|
size = std::max(2,size-1);
|
|
|
|
pSettings->editor().setFontSize(size);
|
|
|
|
pMainWindow->updateEditorSettings();
|
2021-06-09 17:12:23 +08:00
|
|
|
event->accept();
|
|
|
|
return;
|
2021-04-09 17:48:25 +08:00
|
|
|
}
|
|
|
|
}
|
2021-06-09 17:12:23 +08:00
|
|
|
SynEdit::wheelEvent(event);
|
2021-04-08 10:29:21 +08:00
|
|
|
}
|
2021-04-11 12:39:22 +08:00
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void Editor::focusInEvent(QFocusEvent *event)
|
|
|
|
{
|
|
|
|
SynEdit::focusInEvent(event);
|
|
|
|
pMainWindow->updateEditorActions();
|
|
|
|
pMainWindow->updateStatusbarForLineCol();
|
|
|
|
pMainWindow->updateForStatusbarModeInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::focusOutEvent(QFocusEvent *event)
|
|
|
|
{
|
|
|
|
SynEdit::focusOutEvent(event);
|
|
|
|
pMainWindow->updateEditorActions();
|
|
|
|
pMainWindow->updateStatusbarForLineCol();
|
|
|
|
pMainWindow->updateForStatusbarModeInfo();
|
|
|
|
}
|
|
|
|
|
2021-06-21 16:25:21 +08:00
|
|
|
void Editor::keyPressEvent(QKeyEvent *event)
|
|
|
|
{
|
|
|
|
bool handled = false;
|
2021-06-23 08:55:56 +08:00
|
|
|
switch (event->key()) {
|
|
|
|
case Qt::Key_Delete:
|
|
|
|
// remove completed character
|
|
|
|
//fLastIdCharPressed:=0;
|
|
|
|
undoSymbolCompletion(caretX());
|
|
|
|
break;;
|
|
|
|
case Qt::Key_Backspace:
|
|
|
|
// remove completed character
|
|
|
|
//fLastIdCharPressed:=0;
|
|
|
|
undoSymbolCompletion(caretX()-1);
|
|
|
|
break;;
|
|
|
|
default: {
|
|
|
|
QString t = event->text();
|
|
|
|
if (!t.isEmpty()) {
|
|
|
|
QChar ch = t[0];
|
|
|
|
switch (ch.unicode()) {
|
|
|
|
case '"':
|
|
|
|
case '\'':
|
|
|
|
case '(':
|
|
|
|
case ')':
|
|
|
|
case '{':
|
|
|
|
case '}':
|
|
|
|
case '[':
|
|
|
|
case ']':
|
|
|
|
case '<':
|
|
|
|
case '>':
|
|
|
|
case '*':
|
|
|
|
handled = handleSymbolCompletion(ch);
|
|
|
|
}
|
2021-06-21 16:25:21 +08:00
|
|
|
}
|
|
|
|
}
|
2021-06-23 08:55:56 +08:00
|
|
|
}
|
2021-06-21 16:25:21 +08:00
|
|
|
if (!handled) {
|
|
|
|
SynEdit::keyPressEvent(event);
|
|
|
|
} else {
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-24 16:05:19 +08:00
|
|
|
void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
|
|
|
|
{
|
|
|
|
// Get point where to draw marks
|
|
|
|
//X := (fText.Gutter.RealGutterWidth(fText.CharWidth) - fText.Gutter.RightOffset) div 2 - 3;
|
|
|
|
X = 5;
|
|
|
|
Y += (this->textHeight() - 16) / 2;
|
|
|
|
|
|
|
|
PSyntaxIssueList lst = getSyntaxIssuesAtLine(aLine);
|
|
|
|
if (lst) {
|
|
|
|
bool hasError=false;
|
|
|
|
for (PSyntaxIssue issue : *lst) {
|
|
|
|
if (issue->issueType == CompileIssueType::Error) {
|
|
|
|
hasError = true;
|
|
|
|
break;;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasError) {
|
|
|
|
painter.drawPixmap(X,Y,*(pIconsManager->syntaxError()));
|
|
|
|
} else {
|
|
|
|
painter.drawPixmap(X,Y,*(pIconsManager->syntaxWarning()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if fActiveLine = Line then begin // prefer active line over breakpoints
|
|
|
|
// dmMain.GutterImages.Draw(ACanvas, X, Y, 1);
|
|
|
|
// drawn:=True;
|
|
|
|
// end else if HasBreakpoint(Line) <> -1 then begin
|
|
|
|
// dmMain.GutterImages.Draw(ACanvas, X, Y, 0);
|
|
|
|
// drawn:=True;
|
|
|
|
// end else if fErrorLine = Line then begin
|
|
|
|
// dmMain.GutterImages.Draw(ACanvas, X, Y, 2);
|
|
|
|
// drawn:=True;
|
|
|
|
// end;
|
|
|
|
// idx := CBUtils.FastIndexOf(fErrorList, Line);
|
|
|
|
// if idx>=0 then begin
|
|
|
|
// isError := False;
|
|
|
|
// lst:=TList(fErrorList.Objects[idx]);
|
|
|
|
// for j:=0 to lst.Count-1 do begin
|
|
|
|
// if PSyntaxError(lst[j])^.errorType = setError then begin
|
|
|
|
// isError := True;
|
|
|
|
// break;
|
|
|
|
// end;
|
|
|
|
// end;
|
|
|
|
// if isError then
|
|
|
|
// dmMain.GutterImages.Draw(ACanvas, X, Y, 2)
|
|
|
|
// else if not drawn then
|
|
|
|
// dmMain.GutterImages.Draw(ACanvas, X, Y, 3);
|
|
|
|
// end;
|
|
|
|
|
|
|
|
// Inc(Y, fText.LineHeight);
|
|
|
|
// end;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList)
|
|
|
|
{
|
|
|
|
areaList.clear();
|
|
|
|
// if (fTabStopBegin >=0) and (fTabStopY=Line) then begin
|
|
|
|
// areaType:=eatEditing;
|
|
|
|
// System.new(p);
|
|
|
|
// spaceCount := fText.LeftSpacesEx(fLineBeforeTabStop,True);
|
|
|
|
// spaceBefore := Length(fLineBeforeTabStop) - Length(TrimLeft(fLineBeforeTabStop));
|
|
|
|
// p.beginX := fTabStopBegin + spaceCount - spaceBefore ;
|
|
|
|
// p.endX := fTabStopEnd + spaceCount - spaceBefore ;
|
|
|
|
// p.color := dmMain.Cpp.StringAttri.Foreground;
|
|
|
|
// areaList.Add(p);
|
|
|
|
// ColBorder := dmMain.Cpp.StringAttri.Foreground;
|
|
|
|
// Exit;
|
|
|
|
// end;
|
|
|
|
// StrToThemeColor(tc,devEditor.Syntax.Values[cWN]);
|
|
|
|
PSyntaxIssueList lst = getSyntaxIssuesAtLine(Line);
|
|
|
|
if (lst) {
|
|
|
|
for (PSyntaxIssue issue: *lst) {
|
|
|
|
PSynEditingArea p=std::make_shared<SynEditingArea>();
|
|
|
|
p->beginX = issue->col;
|
|
|
|
p->endX = issue->endCol;
|
|
|
|
if (issue->issueType == CompileIssueType::Error) {
|
|
|
|
p->color = mSyntaxErrorColor;
|
|
|
|
} else {
|
|
|
|
p->color = mSyntaxWaringColor;
|
|
|
|
}
|
|
|
|
p->type = SynEditingAreaType::eatWaveUnderLine;
|
|
|
|
areaList.append(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void Editor::copyToClipboard()
|
|
|
|
{
|
|
|
|
if (pSettings->editor().copySizeLimit()) {
|
|
|
|
if (lines()->count() > pSettings->editor().copyLineLimits()) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-06-12 22:36:23 +08:00
|
|
|
tr("The text to be copied exceeds count limit!"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (lines()->getTextLength() > pSettings->editor().copyCharLimits() * 1000) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-06-12 22:36:23 +08:00
|
|
|
tr("The text to be copied exceeds character limit!"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch(pSettings->editor().copyWithFormatAs()) {
|
|
|
|
case 1: //HTML
|
|
|
|
copyAsHTML();
|
|
|
|
break;;
|
|
|
|
default:
|
|
|
|
SynEdit::copyToClipboard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::cutToClipboard()
|
|
|
|
{
|
|
|
|
if (pSettings->editor().copySizeLimit()) {
|
|
|
|
if (lines()->count() > pSettings->editor().copyLineLimits()) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-06-12 22:36:23 +08:00
|
|
|
tr("The text to be cut exceeds count limit!"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (lines()->getTextLength() > pSettings->editor().copyCharLimits() * 1000) {
|
2021-06-21 11:21:26 +08:00
|
|
|
QMessageBox::critical(pMainWindow,tr("Error"),
|
2021-06-12 22:36:23 +08:00
|
|
|
tr("The text to be cut exceeds character limit!"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SynEdit::cutToClipboard();
|
2021-04-11 12:39:22 +08:00
|
|
|
}
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void Editor::copyAsHTML()
|
|
|
|
{
|
|
|
|
if (!selAvail())
|
|
|
|
return;
|
|
|
|
SynHTMLExporter SynExporterHTML;
|
|
|
|
|
|
|
|
SynExporterHTML.setTitle(QFileInfo(mFilename).fileName());
|
|
|
|
SynExporterHTML.setExportAsText(false);
|
2021-06-20 22:54:16 +08:00
|
|
|
SynExporterHTML.setUseBackground(pSettings->editor().copyHTMLUseBackground());
|
2021-06-12 22:36:23 +08:00
|
|
|
SynExporterHTML.setFont(font());
|
2021-06-20 22:54:16 +08:00
|
|
|
PSynHighlighter hl = highlighter();
|
|
|
|
if (!pSettings->editor().copyHTMLUseEditorColor()) {
|
|
|
|
hl = highlighterManager.copyHighlighter(highlighter());
|
|
|
|
highlighterManager.applyColorScheme(hl,pSettings->editor().copyHTMLColorScheme());
|
|
|
|
}
|
|
|
|
SynExporterHTML.setHighlighter(hl);
|
2021-06-12 22:36:23 +08:00
|
|
|
SynExporterHTML.setCreateHTMLFragment(true);
|
|
|
|
|
|
|
|
SynExporterHTML.ExportRange(lines(),blockBegin(),blockEnd());
|
|
|
|
|
|
|
|
QMimeData * mimeData = new QMimeData;
|
|
|
|
|
|
|
|
//sethtml will convert buffer to QString , which will cause encoding trouble
|
|
|
|
mimeData->setData(SynExporterHTML.clipboardFormat(),SynExporterHTML.buffer());
|
|
|
|
mimeData->setText(selText());
|
|
|
|
|
|
|
|
QGuiApplication::clipboard()->clear();
|
|
|
|
QGuiApplication::clipboard()->setMimeData(mimeData);
|
2021-04-11 13:55:31 +08:00
|
|
|
}
|
|
|
|
|
2021-06-24 16:05:19 +08:00
|
|
|
void Editor::setCaretPosition(int line, int col)
|
|
|
|
{
|
|
|
|
this->uncollapseAroundLine(line);
|
|
|
|
this->setCaretXYCentered(true,BufferCoord{col,line});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::setCaretPositionAndActivate(int line, int col)
|
|
|
|
{
|
|
|
|
this->uncollapseAroundLine(line);
|
|
|
|
if (!this->hasFocus())
|
|
|
|
this->activate();
|
|
|
|
this->setCaretXYCentered(true,BufferCoord{col,line});
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueType errorType, const QString &hint)
|
2021-06-23 22:38:02 +08:00
|
|
|
{
|
|
|
|
PSyntaxIssue pError;
|
|
|
|
BufferCoord p;
|
|
|
|
QString token;
|
|
|
|
SynHighlighterTokenType tokenType;
|
|
|
|
int tokenKind,start;
|
|
|
|
PSynHighlighterAttribute attr;
|
|
|
|
PSyntaxIssueList lst;
|
|
|
|
if ((line<1) || (line>lines()->count()))
|
|
|
|
return;
|
|
|
|
pError = std::make_shared<SyntaxIssue>();
|
|
|
|
p.Char = startChar;
|
|
|
|
p.Line = line;
|
|
|
|
if (startChar >= lines()->getString(line-1).length()) {
|
|
|
|
start = 1;
|
|
|
|
token = lines()->getString(line-1);
|
2021-06-24 16:05:19 +08:00
|
|
|
} else if (endChar < 1) {
|
2021-06-23 22:38:02 +08:00
|
|
|
if (!GetHighlighterAttriAtRowColEx(p,token,tokenType,tokenKind,start,attr))
|
|
|
|
return;
|
2021-06-24 16:05:19 +08:00
|
|
|
} else {
|
|
|
|
start = startChar;
|
|
|
|
token = lines()->getString(line-1).mid(start-1,endChar-startChar);
|
2021-06-23 22:38:02 +08:00
|
|
|
}
|
|
|
|
pError->startChar = start;
|
|
|
|
pError->endChar = start + token.length();
|
|
|
|
pError->col = charToColumn(line,pError->startChar);
|
|
|
|
pError->endCol = charToColumn(line,pError->endChar);
|
|
|
|
pError->hint = hint;
|
|
|
|
pError->token = token;
|
|
|
|
pError->issueType = errorType;
|
|
|
|
if (mSyntaxIssues.contains(line)) {
|
|
|
|
lst = mSyntaxIssues[line];
|
|
|
|
} else {
|
|
|
|
lst = std::make_shared<SyntaxIssueList>();
|
|
|
|
mSyntaxIssues[line] = lst;
|
|
|
|
}
|
|
|
|
lst->append(pError);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::clearSyntaxIssues()
|
|
|
|
{
|
|
|
|
mSyntaxIssues.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::gotoNextSyntaxIssue()
|
|
|
|
{
|
|
|
|
auto iter = mSyntaxIssues.find(caretY());
|
|
|
|
if (iter==mSyntaxIssues.end())
|
|
|
|
return;
|
|
|
|
iter++;
|
|
|
|
if (iter==mSyntaxIssues.end())
|
|
|
|
return;
|
|
|
|
BufferCoord p;
|
|
|
|
p.Char = (*iter)->at(0)->startChar;
|
|
|
|
p.Line = iter.key();
|
|
|
|
setCaretXY(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Editor::gotoPrevSyntaxIssue()
|
|
|
|
{
|
|
|
|
auto iter = mSyntaxIssues.find(caretY());
|
|
|
|
if (iter==mSyntaxIssues.end())
|
|
|
|
return;
|
|
|
|
if (iter==mSyntaxIssues.begin())
|
|
|
|
return;
|
|
|
|
iter--;
|
|
|
|
BufferCoord p;
|
|
|
|
p.Char = (*iter)->at(0)->startChar;
|
|
|
|
p.Line = iter.key();
|
|
|
|
setCaretXY(p);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::hasNextSyntaxIssue() const
|
|
|
|
{
|
|
|
|
auto iter = mSyntaxIssues.find(caretY());
|
|
|
|
if (iter==mSyntaxIssues.end())
|
|
|
|
return false;
|
|
|
|
iter++;
|
|
|
|
if (iter==mSyntaxIssues.end())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::hasPrevSyntaxIssue() const
|
|
|
|
{
|
|
|
|
auto iter = mSyntaxIssues.find(caretY());
|
|
|
|
if (iter==mSyntaxIssues.end())
|
|
|
|
return true;
|
|
|
|
if (iter==mSyntaxIssues.begin())
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-24 16:05:19 +08:00
|
|
|
Editor::PSyntaxIssueList Editor::getSyntaxIssuesAtLine(int line)
|
2021-06-23 22:38:02 +08:00
|
|
|
{
|
|
|
|
if (mSyntaxIssues.contains(line))
|
|
|
|
return mSyntaxIssues[line];
|
|
|
|
return PSyntaxIssueList();
|
|
|
|
}
|
|
|
|
|
2021-06-24 16:05:19 +08:00
|
|
|
Editor::PSyntaxIssue Editor::getSyntaxIssueAtPosition(const BufferCoord &pos)
|
2021-06-23 22:38:02 +08:00
|
|
|
{
|
2021-06-24 16:05:19 +08:00
|
|
|
PSyntaxIssueList lst = getSyntaxIssuesAtLine(pos.Line);
|
2021-06-23 22:38:02 +08:00
|
|
|
for (PSyntaxIssue issue: *lst) {
|
|
|
|
if (issue->startChar<=pos.Char && pos.Char<=issue->endChar)
|
|
|
|
return issue;
|
|
|
|
}
|
|
|
|
return PSyntaxIssue();
|
|
|
|
}
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
void Editor::onModificationChanged(bool) {
|
|
|
|
updateCaption();
|
2021-04-11 13:55:31 +08:00
|
|
|
}
|
|
|
|
|
2021-06-10 09:34:59 +08:00
|
|
|
void Editor::onStatusChanged(SynStatusChanges changes)
|
|
|
|
{
|
2021-07-02 10:32:29 +08:00
|
|
|
if (!changes.testFlag(SynStatusChange::scOpenFile)
|
|
|
|
&& !changes.testFlag(SynStatusChange::scReadOnly)
|
|
|
|
&& !changes.testFlag(SynStatusChange::scInsertMode)
|
|
|
|
&& (lines()->count()!=mLineCount)
|
2021-06-24 20:43:09 +08:00
|
|
|
&& (lines()->count()!=0) && ((mLineCount>0) || (lines()->count()>1))) {
|
2021-07-02 10:32:29 +08:00
|
|
|
if (!readOnly() && pSettings->editor().syntaxCheck() && pSettings->editor().syntaxCheckWhenLineChanged())
|
2021-06-25 12:40:11 +08:00
|
|
|
pMainWindow->checkSyntaxInBack(this);
|
2021-06-24 20:43:09 +08:00
|
|
|
}
|
|
|
|
mLineCount = lines()->count();
|
2021-06-10 09:34:59 +08:00
|
|
|
// if (not (scOpenFile in Changes)) and (fText.Lines.Count <> fLineCount)
|
|
|
|
// and (fText.Lines.Count <> 0) and ((fLineCount>0) or (fText.Lines.Count>1)) then begin
|
|
|
|
// if devCodeCompletion.Enabled
|
|
|
|
// and SameStr(mainForm.ClassBrowser.CurrentFile,FileName) // Don't reparse twice
|
|
|
|
// then begin
|
|
|
|
// Reparse;
|
|
|
|
// end;
|
|
|
|
// if fText.Focused and devEditor.AutoCheckSyntax and devEditor.CheckSyntaxWhenReturn
|
|
|
|
// and (fText.Highlighter = dmMain.Cpp) then begin
|
|
|
|
// mainForm.CheckSyntaxInBack(self);
|
|
|
|
// end;
|
|
|
|
// end;
|
|
|
|
// fLineCount := fText.Lines.Count;
|
|
|
|
// // scModified is only fired when the modified state changes
|
|
|
|
if (changes.testFlag(scModified)) {
|
|
|
|
updateCaption();
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (fTabStopBegin >=0) and (fTabStopY=fText.CaretY) then begin
|
|
|
|
// if StartsStr(fLineBeforeTabStop,fText.LineText) and EndsStr(fLineAfterTabStop, fText.LineText) then
|
|
|
|
// fTabStopBegin := Length(fLineBeforeTabStop);
|
|
|
|
// if fLineAfterTabStop = '' then
|
|
|
|
// fTabStopEnd := Length(fText.LineText)+1
|
|
|
|
// else
|
|
|
|
// fTabStopEnd := Length(fText.LineText) - Length(fLineAfterTabStop);
|
|
|
|
// fXOffsetSince := fTabStopEnd - fText.CaretX;
|
|
|
|
// if (fText.CaretX < fTabStopBegin) or (fText.CaretX > (fTabStopEnd+1)) then begin
|
|
|
|
// fTabStopBegin :=-1;
|
|
|
|
// end;
|
|
|
|
// end;
|
|
|
|
|
|
|
|
// scSelection includes anything caret related
|
|
|
|
if (changes.testFlag(SynStatusChange::scSelection)) {
|
2021-06-12 22:36:23 +08:00
|
|
|
pMainWindow->updateStatusbarForLineCol();
|
2021-06-10 09:34:59 +08:00
|
|
|
|
|
|
|
// // Update the function tip
|
|
|
|
// fFunctionTip.ForceHide := false;
|
|
|
|
// if Assigned(fFunctionTipTimer) then begin
|
|
|
|
// if fFunctionTip.Activated and FunctionTipAllowed then begin
|
|
|
|
// fFunctionTip.Parser := fParser;
|
|
|
|
// fFunctionTip.FileName := fFileName;
|
|
|
|
// fFunctionTip.Show;
|
|
|
|
// end else begin // Reset the timer
|
|
|
|
// fFunctionTipTimer.Enabled := false;
|
|
|
|
// fFunctionTipTimer.Enabled := true;
|
|
|
|
// end;
|
|
|
|
}
|
|
|
|
|
|
|
|
// // Remove error line colors
|
|
|
|
// if not fIgnoreCaretChange then begin
|
|
|
|
// if (fErrorLine <> -1) and not fText.SelAvail then begin
|
|
|
|
// fText.InvalidateLine(fErrorLine);
|
|
|
|
// fText.InvalidateGutterLine(fErrorLine);
|
|
|
|
// fErrorLine := -1;
|
|
|
|
// end;
|
|
|
|
// end else
|
|
|
|
// fIgnoreCaretChange := false;
|
|
|
|
|
|
|
|
// if fText.SelAvail then begin
|
|
|
|
// if fText.GetWordAtRowCol(fText.CaretXY) = fText.SelText then begin
|
|
|
|
// fSelChanged:=True;
|
|
|
|
// BeginUpdate;
|
|
|
|
// EndUpdate;
|
|
|
|
// end else if fSelChanged then begin
|
|
|
|
// fSelChanged:=False; //invalidate to unhighlight others
|
|
|
|
// BeginUpdate;
|
|
|
|
// EndUpdate;
|
|
|
|
// end;
|
|
|
|
// end else if fSelChanged then begin
|
|
|
|
// fSelChanged:=False; //invalidate to unhighlight others
|
|
|
|
// BeginUpdate;
|
|
|
|
// EndUpdate;
|
|
|
|
// end;
|
|
|
|
// end;
|
|
|
|
|
2021-06-12 22:36:23 +08:00
|
|
|
if (changes.testFlag(scInsertMode) | changes.testFlag(scReadOnly))
|
|
|
|
pMainWindow->updateForStatusbarModeInfo();
|
|
|
|
|
|
|
|
pMainWindow->updateEditorActions();
|
2021-06-10 09:34:59 +08:00
|
|
|
|
2021-06-21 16:25:21 +08:00
|
|
|
// mainForm.CaretList.AddCaret(self,fText.CaretY,fText.CaretX);
|
|
|
|
}
|
|
|
|
|
2021-06-22 23:00:34 +08:00
|
|
|
QChar Editor::getCurrentChar()
|
|
|
|
{
|
|
|
|
if (lineText().length()<caretX())
|
|
|
|
return QChar();
|
|
|
|
else
|
|
|
|
return lineText()[caretX()-1];
|
|
|
|
}
|
|
|
|
|
2021-06-22 13:24:26 +08:00
|
|
|
bool Editor::handleSymbolCompletion(QChar key)
|
2021-06-21 16:25:21 +08:00
|
|
|
{
|
2021-06-22 13:24:26 +08:00
|
|
|
if (!pSettings->editor().completeSymbols() || selAvail())
|
|
|
|
return false;
|
2021-06-22 23:00:34 +08:00
|
|
|
if (!insertMode())
|
|
|
|
return false;
|
2021-06-21 16:25:21 +08:00
|
|
|
|
2021-06-22 13:24:26 +08:00
|
|
|
//todo: better methods to detect current caret type
|
|
|
|
if (caretX() <= 1) {
|
|
|
|
if (caretY()>1) {
|
|
|
|
if (highlighter()->isLastLineCommentNotFinished(lines()->ranges(caretY() - 2).state))
|
|
|
|
return false;
|
|
|
|
if (highlighter()->isLastLineStringNotFinished(lines()->ranges(caretY() - 2).state)
|
|
|
|
&& (key!='\"') && (key!='\''))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
BufferCoord HighlightPos = BufferCoord{caretX()-1, caretY()};
|
|
|
|
// Check if that line is highlighted as comment
|
|
|
|
PSynHighlighterAttribute Attr;
|
|
|
|
QString Token;
|
|
|
|
bool tokenFinished;
|
|
|
|
SynHighlighterTokenType tokenType;
|
|
|
|
if (GetHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) {
|
|
|
|
if ((tokenType == SynHighlighterTokenType::Comment) && (!tokenFinished))
|
|
|
|
return false;
|
|
|
|
if ((tokenType == SynHighlighterTokenType::String) && (!tokenFinished)
|
|
|
|
&& (key!='\'') && (key!='\"') && (key!='(') && (key!=')'))
|
|
|
|
return false;
|
|
|
|
if (( key=='<' || key =='>') && (tokenType != SynHighlighterTokenType::PreprocessDirective))
|
|
|
|
return false;
|
|
|
|
if ((key == '\'') && (Attr->name() == "SYNS_AttrNumber"))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if that line is highlighted as string or character or comment
|
|
|
|
// if (Attr = fText.Highlighter.StringAttribute) or (Attr = fText.Highlighter.CommentAttribute) or SameStr(Attr.Name,
|
|
|
|
// 'Character') then
|
|
|
|
// Exit;
|
|
|
|
|
|
|
|
QuoteStatus status;
|
|
|
|
switch(key.unicode()) {
|
|
|
|
case '(':
|
|
|
|
if (pSettings->editor().completeParenthese()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleParentheseCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case ')':
|
|
|
|
if (pSettings->editor().completeParenthese() && pSettings->editor().overwriteSymbols()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleParentheseSkip();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '[':
|
|
|
|
if (pSettings->editor().completeBracket()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleBracketCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case ']':
|
|
|
|
if (pSettings->editor().completeBracket() && pSettings->editor().overwriteSymbols()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleBracketSkip();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '*':
|
2021-06-22 23:00:34 +08:00
|
|
|
status = getQuoteStatus();
|
2021-06-22 13:24:26 +08:00
|
|
|
if (pSettings->editor().completeComment() && (status == QuoteStatus::NotQuote)) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleMultilineCommentCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '{':
|
|
|
|
if (pSettings->editor().completeBrace()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleBraceCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '}':
|
|
|
|
if (pSettings->editor().completeBrace() && pSettings->editor().overwriteSymbols()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleBraceSkip();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '\'':
|
|
|
|
if (pSettings->editor().completeSingleQuote()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleSingleQuoteCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '\"':
|
|
|
|
if (pSettings->editor().completeDoubleQuote()) {
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleDoubleQuoteCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '<':
|
|
|
|
if (pSettings->editor().completeGlobalInclude()) { // #include <>
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleGlobalIncludeCompletion();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case '>':
|
|
|
|
if (pSettings->editor().completeGlobalInclude() && pSettings->editor().overwriteSymbols()) { // #include <>
|
2021-06-22 23:00:34 +08:00
|
|
|
return handleGlobalIncludeSkip();
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-06-22 23:00:34 +08:00
|
|
|
bool Editor::handleParentheseCompletion()
|
|
|
|
{
|
|
|
|
QuoteStatus status = getQuoteStatus();
|
|
|
|
if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'(');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,')');
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// if (status == QuoteStatus::NotQuote) && FunctionTipAllowed then
|
|
|
|
// fFunctionTip.Activated := true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleParentheseSkip()
|
2021-06-22 13:24:26 +08:00
|
|
|
{
|
2021-06-22 23:00:34 +08:00
|
|
|
if (getCurrentChar() != ')')
|
|
|
|
return false;
|
|
|
|
QuoteStatus status = getQuoteStatus();
|
|
|
|
if (status == QuoteStatus::RawStringNoEscape) {
|
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (status != QuoteStatus::NotQuote)
|
|
|
|
return false;
|
|
|
|
BufferCoord pos = getMatchingBracket();
|
|
|
|
if (pos.Line != 0) {
|
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// if FunctionTipAllowed then
|
|
|
|
// fFunctionTip.Activated := false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleBracketCompletion()
|
|
|
|
{
|
|
|
|
// QuoteStatus status = getQuoteStatus();
|
|
|
|
// if (status == QuoteStatus::RawString || status == QuoteStatus::NotQuote) {
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'[');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,']');
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleBracketSkip()
|
|
|
|
{
|
|
|
|
if (getCurrentChar() != ']')
|
|
|
|
return false;
|
|
|
|
BufferCoord pos = getMatchingBracket();
|
|
|
|
if (pos.Line != 0) {
|
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleMultilineCommentCompletion()
|
|
|
|
{
|
|
|
|
if (((caretX() > 1) && (caretX()-1 < lineText().length())) && (lineText()[caretX() - 1] == '/')) {
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'*');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'*');
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'/');
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleBraceCompletion()
|
|
|
|
{
|
|
|
|
QString s = lineText().trimmed();
|
|
|
|
int i= caretY()-2;
|
|
|
|
while ((s.isEmpty()) && (i>=0)) {
|
|
|
|
s=lines()->getString(i);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'{');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'}');
|
|
|
|
if (
|
|
|
|
( (s.startsWith("struct")
|
|
|
|
|| s.startsWith("class")
|
|
|
|
|| s.startsWith("union")
|
|
|
|
|| s.startsWith("typedef")
|
|
|
|
|| s.startsWith("public")
|
|
|
|
|| s.startsWith("private")
|
|
|
|
|| s.startsWith("enum") )
|
|
|
|
&& !s.contains(';')
|
|
|
|
) || s.endsWith('=')) {
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,';');
|
|
|
|
}
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleBraceSkip()
|
|
|
|
{
|
|
|
|
if (getCurrentChar() != '}')
|
|
|
|
return false;
|
|
|
|
BufferCoord pos = getMatchingBracket();
|
|
|
|
if (pos.Line != 0) {
|
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleSingleQuoteCompletion()
|
|
|
|
{
|
|
|
|
QuoteStatus status = getQuoteStatus();
|
|
|
|
QChar ch = getCurrentChar();
|
|
|
|
if (ch == '\'') {
|
|
|
|
if (status == QuoteStatus::SingleQuote) {
|
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (status == QuoteStatus::NotQuote) {
|
2021-06-23 08:55:56 +08:00
|
|
|
if (ch == 0 || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
2021-06-22 23:00:34 +08:00
|
|
|
// insert ''
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'\'');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'\'');
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleDoubleQuoteCompletion()
|
|
|
|
{
|
|
|
|
QuoteStatus status = getQuoteStatus();
|
|
|
|
QChar ch = getCurrentChar();
|
|
|
|
if (ch == '"') {
|
2021-06-23 08:55:56 +08:00
|
|
|
if (status == QuoteStatus::DoubleQuote || status == QuoteStatus::RawString) {
|
2021-06-22 23:00:34 +08:00
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (status == QuoteStatus::NotQuote) {
|
2021-06-23 08:55:56 +08:00
|
|
|
if ((ch == 0) || highlighter()->isWordBreakChar(ch) || highlighter()->isSpaceChar(ch)) {
|
2021-06-22 23:00:34 +08:00
|
|
|
// insert ""
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'"');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'"');
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleGlobalIncludeCompletion()
|
|
|
|
{
|
|
|
|
if (!lineText().startsWith('#'))
|
|
|
|
return false;
|
|
|
|
QString s= lineText().mid(1).trimmed();
|
|
|
|
if (!s.startsWith("include")) //it's not #include
|
|
|
|
return false;
|
|
|
|
beginUpdate();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'<');
|
|
|
|
BufferCoord oldCaret = caretXY();
|
|
|
|
CommandProcessor(SynEditorCommand::ecChar,'>');
|
|
|
|
setCaretXY(oldCaret);
|
|
|
|
endUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Editor::handleGlobalIncludeSkip()
|
|
|
|
{
|
|
|
|
if (getCurrentChar()!='>')
|
|
|
|
return false;
|
|
|
|
QString s= lineText().mid(1).trimmed();
|
|
|
|
if (!s.startsWith("include")) //it's not #include
|
|
|
|
return false;
|
|
|
|
BufferCoord pos = getMatchingBracket();
|
|
|
|
if (pos.Line != 0) {
|
|
|
|
setCaretXY( BufferCoord{caretX() + 1, caretY()}); // skip over
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2021-06-22 13:24:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Editor::QuoteStatus Editor::getQuoteStatus()
|
|
|
|
{
|
|
|
|
QuoteStatus Result = QuoteStatus::NotQuote;
|
|
|
|
if ((caretY()>1) && highlighter()->isLastLineStringNotFinished(lines()->ranges(caretY() - 2).state))
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
|
|
|
|
QString Line = lines()->getString(caretY()-1);
|
2021-06-22 23:00:34 +08:00
|
|
|
int posX = caretX()-1;
|
|
|
|
if (posX >= Line.length()) {
|
|
|
|
posX = Line.length()-1;
|
|
|
|
}
|
2021-06-23 08:55:56 +08:00
|
|
|
for (int i=0; i<posX;i++) {
|
2021-06-22 23:00:34 +08:00
|
|
|
if (i+1<Line.length() && (Line[i] == 'R') && (Line[i+1] == '"') && (Result == QuoteStatus::NotQuote)) {
|
|
|
|
Result = QuoteStatus::RawString;
|
|
|
|
i++; // skip R
|
|
|
|
} else if (Line[i] == '(') {
|
|
|
|
switch(Result) {
|
|
|
|
case QuoteStatus::RawString:
|
|
|
|
Result=QuoteStatus::RawStringNoEscape;
|
|
|
|
break;
|
|
|
|
//case RawStringNoEscape: do nothing
|
|
|
|
}
|
|
|
|
} else if (Line[i] == ')') {
|
|
|
|
switch(Result) {
|
|
|
|
case QuoteStatus::RawStringNoEscape:
|
|
|
|
Result=QuoteStatus::RawString;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (Line[i] == '"') {
|
|
|
|
switch(Result) {
|
|
|
|
case QuoteStatus::NotQuote:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuote:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuoteEscape:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuote:
|
|
|
|
Result = QuoteStatus::NotQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuoteEscape:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::RawString:
|
|
|
|
Result=QuoteStatus::NotQuote;
|
|
|
|
break;
|
|
|
|
//RawStringNoEscape: do nothing
|
|
|
|
}
|
|
|
|
} else if (Line[i] == '\'') {
|
|
|
|
switch(Result) {
|
|
|
|
case QuoteStatus::NotQuote:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuote:
|
|
|
|
Result = QuoteStatus::NotQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuoteEscape:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuote:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuoteEscape:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (Line[i] == '\\') {
|
|
|
|
switch(Result) {
|
|
|
|
case QuoteStatus::NotQuote:
|
|
|
|
Result = QuoteStatus::NotQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuote:
|
|
|
|
Result = QuoteStatus::SingleQuoteEscape;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuoteEscape:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuote:
|
|
|
|
Result = QuoteStatus::DoubleQuoteEscape;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuoteEscape:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch(Result) {
|
|
|
|
case QuoteStatus::NotQuote:
|
|
|
|
Result = QuoteStatus::NotQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuote:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::SingleQuoteEscape:
|
|
|
|
Result = QuoteStatus::SingleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuote:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
case QuoteStatus::DoubleQuoteEscape:
|
|
|
|
Result = QuoteStatus::DoubleQuote;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-22 13:24:26 +08:00
|
|
|
return Result;
|
2021-06-10 09:34:59 +08:00
|
|
|
}
|
|
|
|
|
2021-06-07 11:02:03 +08:00
|
|
|
void Editor::applySettings()
|
|
|
|
{
|
|
|
|
SynEditorOptions options = eoAltSetsColumnMode |
|
|
|
|
eoDragDropEditing | eoDropFiles | eoKeepCaretX | eoTabsToSpaces |
|
2021-06-07 21:34:48 +08:00
|
|
|
eoRightMouseMovesCursor | eoScrollByOneLess | eoTabIndent | eoHideShowScrollbars;
|
2021-06-09 17:12:23 +08:00
|
|
|
|
|
|
|
//options
|
2021-06-07 11:02:03 +08:00
|
|
|
options.setFlag(eoAddIndent,pSettings->editor().addIndent());
|
|
|
|
options.setFlag(eoAutoIndent,pSettings->editor().autoIndent());
|
|
|
|
options.setFlag(eoTabsToSpaces,pSettings->editor().tabToSpaces());
|
|
|
|
|
|
|
|
options.setFlag(eoKeepCaretX,pSettings->editor().keepCaretX());
|
|
|
|
options.setFlag(eoEnhanceHomeKey,pSettings->editor().enhanceHomeKey());
|
|
|
|
options.setFlag(eoEnhanceEndKey,pSettings->editor().enhanceEndKey());
|
|
|
|
|
2021-06-08 21:41:42 +08:00
|
|
|
options.setFlag(eoHideShowScrollbars,pSettings->editor().autoHideScrollbar());
|
|
|
|
options.setFlag(eoScrollPastEol,pSettings->editor().scrollPastEol());
|
|
|
|
options.setFlag(eoScrollPastEof,pSettings->editor().scrollPastEof());
|
|
|
|
options.setFlag(eoScrollByOneLess,pSettings->editor().scrollByOneLess());
|
|
|
|
options.setFlag(eoHalfPageScroll,pSettings->editor().halfPageScroll());
|
2021-06-07 11:02:03 +08:00
|
|
|
setOptions(options);
|
|
|
|
|
|
|
|
setTabWidth(pSettings->editor().tabWidth());
|
|
|
|
setInsertCaret(pSettings->editor().caretForInsert());
|
|
|
|
setOverwriteCaret(pSettings->editor().caretForOverwrite());
|
|
|
|
setCaretColor(pSettings->editor().caretColor());
|
2021-06-09 17:12:23 +08:00
|
|
|
|
|
|
|
QFont f=QFont(pSettings->editor().fontName(),pSettings->editor().fontSize());
|
|
|
|
f.setStyleStrategy(QFont::PreferAntialias);
|
|
|
|
setFont(f);
|
|
|
|
|
|
|
|
// Set gutter properties
|
|
|
|
gutter().setLeftOffset(pSettings->editor().gutterLeftOffset());
|
|
|
|
gutter().setRightOffset(pSettings->editor().gutterRightOffset());
|
|
|
|
gutter().setBorderStyle(SynGutterBorderStyle::None);
|
|
|
|
gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont());
|
|
|
|
if (pSettings->editor().gutterUseCustomFont()) {
|
|
|
|
f=QFont(pSettings->editor().gutterFontName(),pSettings->editor().gutterFontSize());
|
|
|
|
} else {
|
|
|
|
f=QFont(pSettings->editor().fontName(),pSettings->editor().fontSize());
|
|
|
|
}
|
|
|
|
f.setStyleStrategy(QFont::PreferAntialias);
|
|
|
|
gutter().setFont(f);
|
|
|
|
gutter().setDigitCount(pSettings->editor().gutterDigitsCount());
|
|
|
|
gutter().setVisible(pSettings->editor().gutterVisible());
|
|
|
|
gutter().setAutoSize(pSettings->editor().gutterAutoSize());
|
|
|
|
gutter().setShowLineNumbers(pSettings->editor().gutterShowLineNumbers());
|
|
|
|
gutter().setLeadingZeros(pSettings->editor().gutterAddLeadingZero());
|
|
|
|
if (pSettings->editor().gutterLineNumbersStartZero())
|
|
|
|
gutter().setLineNumberStart(0);
|
|
|
|
else
|
|
|
|
gutter().setLineNumberStart(1);
|
|
|
|
//font color
|
|
|
|
|
2021-06-07 11:02:03 +08:00
|
|
|
}
|
|
|
|
|
2021-06-19 22:58:35 +08:00
|
|
|
void Editor::applyColorScheme(const QString& schemeName)
|
|
|
|
{
|
2021-06-20 22:54:16 +08:00
|
|
|
highlighterManager.applyColorScheme(highlighter(),schemeName);
|
2021-06-19 22:58:35 +08:00
|
|
|
PColorSchemeItem item = pColorManager->getItem(schemeName,COLOR_SCHEME_ACTIVE_LINE);
|
|
|
|
if (item) {
|
|
|
|
setActiveLineColor(item->background());
|
|
|
|
}
|
|
|
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_GUTTER);
|
|
|
|
if (item) {
|
|
|
|
gutter().setTextColor(item->foreground());
|
|
|
|
gutter().setColor(item->background());
|
|
|
|
}
|
|
|
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_FOLD_LINE);
|
|
|
|
if (item) {
|
2021-06-24 22:33:57 +08:00
|
|
|
codeFolding().folderBarLinesColor = item->foreground();
|
2021-06-19 22:58:35 +08:00
|
|
|
}
|
|
|
|
item = pColorManager->getItem(schemeName,COLOR_SCHEME_INDENT_GUIDE_LINE);
|
|
|
|
if (item) {
|
2021-06-24 22:33:57 +08:00
|
|
|
codeFolding().indentGuidesColor = item->foreground();
|
2021-06-19 22:58:35 +08:00
|
|
|
}
|
|
|
|
this->invalidate();
|
|
|
|
}
|
|
|
|
|
2021-04-11 12:39:22 +08:00
|
|
|
void Editor::updateCaption(const QString& newCaption) {
|
2021-06-19 22:58:35 +08:00
|
|
|
if (mParentPageControl==nullptr) {
|
2021-04-11 12:39:22 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int index = mParentPageControl->indexOf(this);
|
|
|
|
if (index==-1)
|
|
|
|
return;
|
|
|
|
if (newCaption.isEmpty()) {
|
|
|
|
QString caption = QFileInfo(mFilename).fileName();
|
2021-05-24 00:41:00 +08:00
|
|
|
if (this->modified()) {
|
2021-04-11 12:39:22 +08:00
|
|
|
caption.append("[*]");
|
|
|
|
}
|
|
|
|
mParentPageControl->setTabText(index,caption);
|
|
|
|
} else {
|
|
|
|
mParentPageControl->setTabText(index,newCaption);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|