|
|
@ -75,7 +75,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
|
|
|
|
m_highlighterActionGroup(nullptr), m_documentModified(false), m_previewToggled(true),
|
|
|
|
m_highlighterActionGroup(nullptr), m_documentModified(false), m_previewToggled(true),
|
|
|
|
m_indentHandler(nullptr), m_centralSplitter(nullptr), m_settingsDialog(nullptr),
|
|
|
|
m_indentHandler(nullptr), m_centralSplitter(nullptr), m_settingsDialog(nullptr),
|
|
|
|
m_highlighter(nullptr), m_highlightingActions(), m_toolBarWidget(nullptr)
|
|
|
|
m_highlighter(nullptr), m_highlightingActions(), m_toolBarWidget(nullptr)
|
|
|
|
///_aboutDialogGraphicsView(nullptr), m_textEditVScrollBar(nullptr)
|
|
|
|
///-- m_textEditVScrollBar(nullptr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Init of some variables.
|
|
|
|
// Init of some variables.
|
|
|
|
m_sourceCodeChanged = false;
|
|
|
|
m_sourceCodeChanged = false;
|
|
|
@ -689,148 +689,146 @@ void MainWindow::sourceCodeChangedHelperSlot()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void MainWindow::sourceCodeChangedSlot()
|
|
|
|
void MainWindow::sourceCodeChangedSlot()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
///-- TQChar enteredCharacter;
|
|
|
|
TQChar enteredCharacter;
|
|
|
|
///-- int cursorPos, cursorPosAbsolut, cursorLine;
|
|
|
|
int cursorPos, cursorPosAbsolut, cursorLine;
|
|
|
|
///-- TQString text;
|
|
|
|
TQString text;
|
|
|
|
///--
|
|
|
|
|
|
|
|
///-- m_sourceCodeChanged = true;
|
|
|
|
m_sourceCodeChanged = true;
|
|
|
|
///--
|
|
|
|
|
|
|
|
///-- // Get the content text of the text editor.
|
|
|
|
// Get the content text of the text editor.
|
|
|
|
///-- m_sourceFileContent = m_qSciSourceCodeEditor->text();
|
|
|
|
m_sourceFileContent = m_qSciSourceCodeEditor->text();
|
|
|
|
///--
|
|
|
|
|
|
|
|
///-- // Get the position of the cursor in the unindented text.
|
|
|
|
// Get the position of the cursor in the unindented text.
|
|
|
|
///-- if (m_sourceFileContent.isEmpty())
|
|
|
|
if (m_sourceFileContent.isEmpty())
|
|
|
|
///-- {
|
|
|
|
{
|
|
|
|
///-- // Add this line feed, because AStyle has problems with a totally emtpy file.
|
|
|
|
// Add this line feed, because AStyle has problems with a totally empty file.
|
|
|
|
///-- m_sourceFileContent += "\n";
|
|
|
|
m_sourceFileContent += "\n";
|
|
|
|
///-- cursorPosAbsolut = 0;
|
|
|
|
cursorPosAbsolut = 0;
|
|
|
|
///-- cursorPos = 0;
|
|
|
|
cursorPos = 0;
|
|
|
|
///-- cursorLine = 0;
|
|
|
|
cursorLine = 0;
|
|
|
|
///-- enteredCharacter = m_sourceFileContent.at(cursorPosAbsolut);
|
|
|
|
enteredCharacter = m_sourceFileContent.at(cursorPosAbsolut);
|
|
|
|
///-- }
|
|
|
|
}
|
|
|
|
///-- else
|
|
|
|
else
|
|
|
|
///-- {
|
|
|
|
{
|
|
|
|
///-- m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
|
|
|
|
m_qSciSourceCodeEditor->getCursorPosition(&cursorLine, &cursorPos);
|
|
|
|
///-- cursorPosAbsolut = m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_GETCURRENTPOS);
|
|
|
|
cursorPosAbsolut = m_qSciSourceCodeEditor->SendScintilla(TQextScintillaBase::SCI_GETCURRENTPOS);
|
|
|
|
///-- text = m_qSciSourceCodeEditor->text(cursorLine);
|
|
|
|
text = m_qSciSourceCodeEditor->text(cursorLine);
|
|
|
|
///-- if (cursorPosAbsolut > 0)
|
|
|
|
if (cursorPosAbsolut > 0)
|
|
|
|
///-- {
|
|
|
|
{
|
|
|
|
///-- cursorPosAbsolut--;
|
|
|
|
cursorPosAbsolut--;
|
|
|
|
///-- }
|
|
|
|
}
|
|
|
|
///-- if (cursorPos > 0)
|
|
|
|
if (cursorPos > 0)
|
|
|
|
///-- {
|
|
|
|
{
|
|
|
|
///-- cursorPos--;
|
|
|
|
cursorPos--;
|
|
|
|
///-- }
|
|
|
|
}
|
|
|
|
///-- enteredCharacter = m_sourceFileContent.at(cursorPosAbsolut);
|
|
|
|
// TODO: TQScintilla 1.7 returns the position as byte number within a C string.
|
|
|
|
///-- }
|
|
|
|
// In case of UTF-8 characters, the index could increase by more than one per
|
|
|
|
///--
|
|
|
|
// character. Therefore change the text to a C string and access the local
|
|
|
|
///-- // Call the indenter to reformat the text.
|
|
|
|
// 8 bit representation to get the character that was entered.
|
|
|
|
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
|
|
|
|
enteredCharacter = m_qSciSourceCodeEditor->text().local8Bit().at(cursorPosAbsolut);
|
|
|
|
///-- {
|
|
|
|
}
|
|
|
|
///-- callIndenter();
|
|
|
|
|
|
|
|
///-- m_previewToggled = true;
|
|
|
|
// Call the indenter to reformat the text.
|
|
|
|
///-- }
|
|
|
|
if (m_toolBarWidget->cbLivePreview->isChecked())
|
|
|
|
///--
|
|
|
|
{
|
|
|
|
///-- // Update the text editor.
|
|
|
|
callIndenter();
|
|
|
|
///-- updateSourceView();
|
|
|
|
m_previewToggled = true;
|
|
|
|
///--
|
|
|
|
}
|
|
|
|
///-- if (m_toolBarWidget->cbLivePreview->isChecked() && !enteredCharacter.isNull() &&
|
|
|
|
|
|
|
|
///-- enteredCharacter != 10)
|
|
|
|
// Update the text editor.
|
|
|
|
///-- {
|
|
|
|
updateSourceView();
|
|
|
|
///-- //const char ch = enteredCharacter.toAscii();
|
|
|
|
|
|
|
|
///--
|
|
|
|
if (m_toolBarWidget->cbLivePreview->isChecked() && !enteredCharacter.isNull() &&
|
|
|
|
///-- int saveCursorLine = cursorLine;
|
|
|
|
enteredCharacter != TQChar(10))
|
|
|
|
///-- int saveCursorPos = cursorPos;
|
|
|
|
{
|
|
|
|
///--
|
|
|
|
int saveCursorLine = cursorLine;
|
|
|
|
///-- bool charFound = false;
|
|
|
|
int saveCursorPos = cursorPos;
|
|
|
|
///--
|
|
|
|
|
|
|
|
///-- // Search forward
|
|
|
|
bool charFound = false;
|
|
|
|
///-- for (cursorLine = saveCursorLine;
|
|
|
|
|
|
|
|
///-- cursorLine - saveCursorLine < 6 && cursorLine < m_qSciSourceCodeEditor->lines();
|
|
|
|
// Search forward
|
|
|
|
///-- cursorLine++)
|
|
|
|
for (cursorLine = saveCursorLine;
|
|
|
|
///-- {
|
|
|
|
cursorLine - saveCursorLine < 6 && cursorLine < m_qSciSourceCodeEditor->lines();
|
|
|
|
///-- text = m_qSciSourceCodeEditor->text(cursorLine);
|
|
|
|
cursorLine++)
|
|
|
|
///-- while (cursorPos < text.count() && enteredCharacter != text.at(cursorPos))
|
|
|
|
{
|
|
|
|
///-- {
|
|
|
|
text = m_qSciSourceCodeEditor->text(cursorLine);
|
|
|
|
///-- cursorPos++;
|
|
|
|
while (cursorPos < text.length() && enteredCharacter != text.at(cursorPos))
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///-- if (cursorPos >= text.count())
|
|
|
|
cursorPos++;
|
|
|
|
///-- {
|
|
|
|
}
|
|
|
|
///-- cursorPos = 0;
|
|
|
|
if (cursorPos >= text.length())
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///-- else
|
|
|
|
cursorPos = 0;
|
|
|
|
///-- {
|
|
|
|
}
|
|
|
|
///-- charFound = true;
|
|
|
|
else
|
|
|
|
///-- break;
|
|
|
|
{
|
|
|
|
///-- }
|
|
|
|
charFound = true;
|
|
|
|
///-- }
|
|
|
|
break;
|
|
|
|
///--
|
|
|
|
}
|
|
|
|
///-- // If foward search did not find the character, search backward
|
|
|
|
}
|
|
|
|
///-- if (!charFound)
|
|
|
|
|
|
|
|
///-- {
|
|
|
|
// If forward search did not find the character, search backward
|
|
|
|
///-- text = m_qSciSourceCodeEditor->text(saveCursorLine);
|
|
|
|
if (!charFound)
|
|
|
|
///-- cursorPos = saveCursorPos;
|
|
|
|
{
|
|
|
|
///-- if (cursorPos >= text.count())
|
|
|
|
text = m_qSciSourceCodeEditor->text(saveCursorLine);
|
|
|
|
///-- {
|
|
|
|
cursorPos = saveCursorPos;
|
|
|
|
///-- cursorPos = text.count() - 1;
|
|
|
|
if (cursorPos >= text.length())
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///--
|
|
|
|
cursorPos = text.length() - 1;
|
|
|
|
///-- for (cursorLine = saveCursorLine; saveCursorLine - cursorLine < 6 && cursorLine >= 0;
|
|
|
|
}
|
|
|
|
///-- cursorLine--)
|
|
|
|
|
|
|
|
///-- {
|
|
|
|
for (cursorLine = saveCursorLine; saveCursorLine - cursorLine < 6 && cursorLine >= 0;
|
|
|
|
///-- text = m_qSciSourceCodeEditor->text(cursorLine);
|
|
|
|
cursorLine--)
|
|
|
|
///-- while (cursorPos >= 0 && enteredCharacter != text.at(cursorPos))
|
|
|
|
{
|
|
|
|
///-- {
|
|
|
|
text = m_qSciSourceCodeEditor->text(cursorLine);
|
|
|
|
///-- cursorPos--;
|
|
|
|
while (cursorPos >= 0 && enteredCharacter != text.at(cursorPos))
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///-- if (cursorPos < 0)
|
|
|
|
cursorPos--;
|
|
|
|
///-- {
|
|
|
|
}
|
|
|
|
///-- cursorPos = m_qSciSourceCodeEditor->lineLength(cursorLine - 1) - 1;
|
|
|
|
if (cursorPos < 0)
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///-- else
|
|
|
|
cursorPos = m_qSciSourceCodeEditor->lineLength(cursorLine - 1) - 1;
|
|
|
|
///-- {
|
|
|
|
}
|
|
|
|
///-- charFound = true;
|
|
|
|
else
|
|
|
|
///-- break;
|
|
|
|
{
|
|
|
|
///-- }
|
|
|
|
charFound = true;
|
|
|
|
///-- }
|
|
|
|
break;
|
|
|
|
///-- }
|
|
|
|
}
|
|
|
|
///--
|
|
|
|
}
|
|
|
|
///-- // If the character was found set its new cursor position...
|
|
|
|
}
|
|
|
|
///-- if (charFound)
|
|
|
|
|
|
|
|
///-- {
|
|
|
|
// If the character was found set its new cursor position...
|
|
|
|
///-- m_qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos + 1);
|
|
|
|
if (charFound)
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///-- // ...if it was not found, set the previous cursor position.
|
|
|
|
m_qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos + 1);
|
|
|
|
///-- else
|
|
|
|
}
|
|
|
|
///-- {
|
|
|
|
// ...if it was not found, set the previous cursor position.
|
|
|
|
///-- m_qSciSourceCodeEditor->setCursorPosition(saveCursorLine, saveCursorPos + 1);
|
|
|
|
else
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///-- }
|
|
|
|
m_qSciSourceCodeEditor->setCursorPosition(saveCursorLine, saveCursorPos + 1);
|
|
|
|
///-- // set the previous cursor position.
|
|
|
|
}
|
|
|
|
///-- else if (enteredCharacter == 10)
|
|
|
|
}
|
|
|
|
///-- {
|
|
|
|
// set the previous cursor position.
|
|
|
|
///-- m_qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos);
|
|
|
|
else if (enteredCharacter == TQChar(10))
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///--
|
|
|
|
m_qSciSourceCodeEditor->setCursorPosition(cursorLine, cursorPos);
|
|
|
|
///-- if (m_toolBarWidget->cbLivePreview->isChecked())
|
|
|
|
}
|
|
|
|
///-- {
|
|
|
|
|
|
|
|
///-- m_sourceCodeChanged = false;
|
|
|
|
if (m_toolBarWidget->cbLivePreview->isChecked())
|
|
|
|
///-- }
|
|
|
|
{
|
|
|
|
///--
|
|
|
|
m_sourceCodeChanged = false;
|
|
|
|
///-- if (m_savedSourceContent == m_qSciSourceCodeEditor->text())
|
|
|
|
}
|
|
|
|
///-- {
|
|
|
|
|
|
|
|
///-- m_qSciSourceCodeEditor->setModified(false);
|
|
|
|
if (m_savedSourceContent == m_qSciSourceCodeEditor->text())
|
|
|
|
///-- m_documentModified = false;
|
|
|
|
{
|
|
|
|
///-- }
|
|
|
|
m_qSciSourceCodeEditor->setModified(false);
|
|
|
|
///-- else
|
|
|
|
m_documentModified = false;
|
|
|
|
///-- {
|
|
|
|
}
|
|
|
|
///-- m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
|
|
|
|
else
|
|
|
|
///-- m_documentModified = true;
|
|
|
|
{
|
|
|
|
///-- }
|
|
|
|
m_qSciSourceCodeEditor->setModified(true); // Has no effect according to TQScintilla docs.
|
|
|
|
///--
|
|
|
|
m_documentModified = true;
|
|
|
|
///-- // Could set cursor this way and use normal linear search in text instead of columns and rows.
|
|
|
|
}
|
|
|
|
///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETCURRENTPOS, 50);
|
|
|
|
|
|
|
|
///-- //m_qSciSourceCodeEditor->SendScintilla(QsciScintillaBase::SCI_SETANCHOR, 50);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -926,6 +924,10 @@ void MainWindow::updateWindowTitle()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void MainWindow::exportToPDF()
|
|
|
|
void MainWindow::exportToPDF()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Not supported in TQt3
|
|
|
|
|
|
|
|
TQMessageBox::warning(this, tr("Not supported"),
|
|
|
|
|
|
|
|
tr("Export to PDF is currently not supported."));
|
|
|
|
|
|
|
|
|
|
|
|
///-- TQString fileExtensions = tr("PDF Document") + " (*.pdf)";
|
|
|
|
///-- TQString fileExtensions = tr("PDF Document") + " (*.pdf)";
|
|
|
|
///--
|
|
|
|
///--
|
|
|
|
///-- TQString fileName = m_currentSourceFile;
|
|
|
|
///-- TQString fileName = m_currentSourceFile;
|
|
|
@ -950,6 +952,10 @@ void MainWindow::exportToPDF()
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void MainWindow::exportToHTML()
|
|
|
|
void MainWindow::exportToHTML()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// Not supported in TQt3
|
|
|
|
|
|
|
|
TQMessageBox::warning(this, tr("Not supported"),
|
|
|
|
|
|
|
|
tr("Export to HTML is currently not supported."));
|
|
|
|
|
|
|
|
|
|
|
|
///-- TQString fileExtensions = tr("HTML Document") + " (*.html)";
|
|
|
|
///-- TQString fileExtensions = tr("HTML Document") + " (*.html)";
|
|
|
|
///--
|
|
|
|
///--
|
|
|
|
///-- TQString fileName = m_currentSourceFile;
|
|
|
|
///-- TQString fileName = m_currentSourceFile;
|
|
|
|