work save: support don't force fix-width
This commit is contained in:
parent
aa17ec785c
commit
3eadbafe25
|
@ -3469,7 +3469,7 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
|
||||||
pSettings->codeCompletion().height());
|
pSettings->codeCompletion().height());
|
||||||
|
|
||||||
// Position it at the top of the next line
|
// Position it at the top of the next line
|
||||||
QPoint popupPos = mapToGlobal(rowColumnToPixels(displayXY()));
|
QPoint popupPos = mapToGlobal(displayCoordToPixels(displayXY()));
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||||
QSize desktopSize = screen()->virtualSize();
|
QSize desktopSize = screen()->virtualSize();
|
||||||
if (desktopSize.height() - popupPos.y() < mCompletionPopup->height() && popupPos.y() > mCompletionPopup->height())
|
if (desktopSize.height() - popupPos.y() < mCompletionPopup->height() && popupPos.y() > mCompletionPopup->height())
|
||||||
|
@ -3599,7 +3599,7 @@ void Editor::showHeaderCompletion(bool autoComplete, bool forceShow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Position it at the top of the next line
|
// Position it at the top of the next line
|
||||||
QPoint p = rowColumnToPixels(displayXY());
|
QPoint p = displayCoordToPixels(displayXY());
|
||||||
p.setY(p.y() + textHeight() + 2);
|
p.setY(p.y() + textHeight() + 2);
|
||||||
mHeaderCompletionPopup->move(mapToGlobal(p));
|
mHeaderCompletionPopup->move(mapToGlobal(p));
|
||||||
|
|
||||||
|
@ -4372,7 +4372,7 @@ void Editor::updateFunctionTip(bool showTip)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Position it at the top of the next line
|
// Position it at the top of the next line
|
||||||
QPoint p = rowColumnToPixels(displayXY());
|
QPoint p = displayCoordToPixels(displayXY());
|
||||||
p+=QPoint(0,textHeight()+2);
|
p+=QPoint(0,textHeight()+2);
|
||||||
pMainWindow->functionTip()->move(mapToGlobal(p));
|
pMainWindow->functionTip()->move(mapToGlobal(p));
|
||||||
|
|
||||||
|
|
|
@ -1434,18 +1434,17 @@ QMenuBar *MainWindow::menuBar() const
|
||||||
void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
|
void MainWindow::updateStatusbarForLineCol(const Editor* e, bool clear)
|
||||||
{
|
{
|
||||||
if (!clear && e!=nullptr) {
|
if (!clear && e!=nullptr) {
|
||||||
int col = e->charToColumn(e->caretY(),e->caretX());
|
|
||||||
QString msg;
|
QString msg;
|
||||||
if (e->selAvail()) {
|
if (e->selAvail()) {
|
||||||
msg = tr("Line: %1 Col: %2 Sel:%3 Lines: %4")
|
msg = tr("Line: %1 Char: %2 Sel:%3 Lines: %4")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
.arg(col)
|
.arg(e->caretX())
|
||||||
.arg(e->selText().length())
|
.arg(e->selText().length())
|
||||||
.arg(e->document()->count());
|
.arg(e->document()->count());
|
||||||
} else {
|
} else {
|
||||||
msg = tr("Line: %1 Col: %2 Lines: %3")
|
msg = tr("Line: %1 Char: %2 Lines: %3")
|
||||||
.arg(e->caretY())
|
.arg(e->caretY())
|
||||||
.arg(col)
|
.arg(e->caretX())
|
||||||
.arg(e->document()->count());
|
.arg(e->document()->count());
|
||||||
}
|
}
|
||||||
mFileInfoStatus->setText(msg);
|
mFileInfoStatus->setText(msg);
|
||||||
|
@ -3233,7 +3232,7 @@ bool MainWindow::saveLastOpens()
|
||||||
fileObj["caretX"] = editor->caretX();
|
fileObj["caretX"] = editor->caretX();
|
||||||
fileObj["caretY"] = editor->caretY();
|
fileObj["caretY"] = editor->caretY();
|
||||||
fileObj["topLine"] = editor->topLine();
|
fileObj["topLine"] = editor->topLine();
|
||||||
fileObj["leftChar"] = editor->leftChar();
|
fileObj["left"] = editor->leftPos();
|
||||||
filesArray.append(fileObj);
|
filesArray.append(fileObj);
|
||||||
}
|
}
|
||||||
rootObj["files"]=filesArray;
|
rootObj["files"]=filesArray;
|
||||||
|
@ -3337,8 +3336,8 @@ void MainWindow::loadLastOpens()
|
||||||
editor->setTopLine(
|
editor->setTopLine(
|
||||||
fileObj["topLine"].toInt(1)
|
fileObj["topLine"].toInt(1)
|
||||||
);
|
);
|
||||||
editor->setLeftChar(
|
editor->setLeftPos(
|
||||||
fileObj["leftChar"].toInt(1)
|
fileObj["left"].toInt(1)
|
||||||
);
|
);
|
||||||
if (fileObj["focused"].toBool(false))
|
if (fileObj["focused"].toBool(false))
|
||||||
focusedEditor = editor;
|
focusedEditor = editor;
|
||||||
|
|
|
@ -426,7 +426,7 @@ Editor *Project::openUnit(PProjectUnit &unit, const PProjectEditorLayout &layout
|
||||||
editor->setCaretY(layout->caretY);
|
editor->setCaretY(layout->caretY);
|
||||||
editor->setCaretX(layout->caretX);
|
editor->setCaretX(layout->caretX);
|
||||||
editor->setTopLine(layout->topLine);
|
editor->setTopLine(layout->topLine);
|
||||||
editor->setLeftChar(layout->leftChar);
|
editor->setLeftPos(layout->left);
|
||||||
editor->activate();
|
editor->activate();
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
@ -663,7 +663,7 @@ void Project::saveLayout()
|
||||||
jsonLayout["caretX"]=editor->caretX();
|
jsonLayout["caretX"]=editor->caretX();
|
||||||
jsonLayout["caretY"]=editor->caretY();
|
jsonLayout["caretY"]=editor->caretY();
|
||||||
jsonLayout["topLine"]=editor->topLine();
|
jsonLayout["topLine"]=editor->topLine();
|
||||||
jsonLayout["leftChar"]=editor->leftChar();
|
jsonLayout["left"]=editor->leftPos();
|
||||||
jsonLayout["isOpen"]=true;
|
jsonLayout["isOpen"]=true;
|
||||||
jsonLayout["focused"]=(editor==e);
|
jsonLayout["focused"]=(editor==e);
|
||||||
int order=editorOrderSet.value(editor->filename(),-1);
|
int order=editorOrderSet.value(editor->filename(),-1);
|
||||||
|
@ -679,7 +679,7 @@ void Project::saveLayout()
|
||||||
jsonLayout["caretX"]=oldLayout->caretX;
|
jsonLayout["caretX"]=oldLayout->caretX;
|
||||||
jsonLayout["caretY"]=oldLayout->caretY;
|
jsonLayout["caretY"]=oldLayout->caretY;
|
||||||
jsonLayout["topLine"]=oldLayout->topLine;
|
jsonLayout["topLine"]=oldLayout->topLine;
|
||||||
jsonLayout["leftChar"]=oldLayout->leftChar;
|
jsonLayout["left"]=oldLayout->left;
|
||||||
jsonLayout["isOpen"]=false;
|
jsonLayout["isOpen"]=false;
|
||||||
jsonLayout["focused"]=false;
|
jsonLayout["focused"]=false;
|
||||||
jsonLayouts.append(jsonLayout);
|
jsonLayouts.append(jsonLayout);
|
||||||
|
@ -1953,7 +1953,7 @@ QHash<QString, PProjectEditorLayout> Project::loadLayout()
|
||||||
PProjectEditorLayout editorLayout = std::make_shared<ProjectEditorLayout>();
|
PProjectEditorLayout editorLayout = std::make_shared<ProjectEditorLayout>();
|
||||||
editorLayout->filename=unitFilename;
|
editorLayout->filename=unitFilename;
|
||||||
editorLayout->topLine=jsonLayout["topLine"].toInt();
|
editorLayout->topLine=jsonLayout["topLine"].toInt();
|
||||||
editorLayout->leftChar=jsonLayout["leftChar"].toInt();
|
editorLayout->left=jsonLayout["left"].toInt();
|
||||||
editorLayout->caretX=jsonLayout["caretX"].toInt();
|
editorLayout->caretX=jsonLayout["caretX"].toInt();
|
||||||
editorLayout->caretY=jsonLayout["caretY"].toInt();
|
editorLayout->caretY=jsonLayout["caretY"].toInt();
|
||||||
editorLayout->order=jsonLayout["order"].toInt(-1);
|
editorLayout->order=jsonLayout["order"].toInt(-1);
|
||||||
|
@ -2183,7 +2183,7 @@ void Project::loadUnitLayout(Editor *e)
|
||||||
e->setCaretY(layout->caretY);
|
e->setCaretY(layout->caretY);
|
||||||
e->setCaretX(layout->caretX);
|
e->setCaretX(layout->caretX);
|
||||||
e->setTopLine(layout->topLine);
|
e->setTopLine(layout->topLine);
|
||||||
e->setLeftChar(layout->leftChar);
|
e->setLeftPos(layout->left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ struct ProjectModelNode {
|
||||||
struct ProjectEditorLayout {
|
struct ProjectEditorLayout {
|
||||||
QString filename;
|
QString filename;
|
||||||
int topLine;
|
int topLine;
|
||||||
int leftChar;
|
int left;
|
||||||
int caretX;
|
int caretX;
|
||||||
int caretY;
|
int caretY;
|
||||||
int order;
|
int order;
|
||||||
|
|
|
@ -371,7 +371,7 @@ std::shared_ptr<SearchResultTreeItem> SearchInFileDialog::batchFindInEditor(QSyn
|
||||||
QSynedit::BufferCoord blockBeginBackup = e->blockBegin();
|
QSynedit::BufferCoord blockBeginBackup = e->blockBegin();
|
||||||
QSynedit::BufferCoord blockEndBackup = e->blockEnd();
|
QSynedit::BufferCoord blockEndBackup = e->blockEnd();
|
||||||
int toplineBackup = e->topLine();
|
int toplineBackup = e->topLine();
|
||||||
int leftCharBackup = e->leftChar();
|
int leftPosBackup = e->leftPos();
|
||||||
|
|
||||||
PSearchResultTreeItem parentItem = std::make_shared<SearchResultTreeItem>();
|
PSearchResultTreeItem parentItem = std::make_shared<SearchResultTreeItem>();
|
||||||
parentItem->filename = filename;
|
parentItem->filename = filename;
|
||||||
|
@ -394,7 +394,7 @@ std::shared_ptr<SearchResultTreeItem> SearchInFileDialog::batchFindInEditor(QSyn
|
||||||
// restore
|
// restore
|
||||||
e->setCaretXY(caretBackup);
|
e->setCaretXY(caretBackup);
|
||||||
e->setTopLine(toplineBackup);
|
e->setTopLine(toplineBackup);
|
||||||
e->setLeftChar(leftCharBackup);
|
e->setLeftPos(leftPosBackup);
|
||||||
e->setCaretAndSelection(
|
e->setCaretAndSelection(
|
||||||
caretBackup,
|
caretBackup,
|
||||||
blockBeginBackup,
|
blockBeginBackup,
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ int DocumentLine::glyphWidth(int i) const
|
||||||
} else {
|
} else {
|
||||||
end = mWidth+1;
|
end = mWidth+1;
|
||||||
}
|
}
|
||||||
return start - end;
|
return end-start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocumentLine::setLineText(const QString &newLineText)
|
void DocumentLine::setLineText(const QString &newLineText)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -29,8 +29,8 @@ class QSynEdit;
|
||||||
class QSynEditPainter
|
class QSynEditPainter
|
||||||
{
|
{
|
||||||
struct SynTokenAccu {
|
struct SynTokenAccu {
|
||||||
int columns;
|
int width;
|
||||||
int columnsBefore;
|
int left;
|
||||||
QString s;
|
QString s;
|
||||||
QColor foreground;
|
QColor foreground;
|
||||||
QColor background;
|
QColor background;
|
||||||
|
@ -39,8 +39,10 @@ class QSynEditPainter
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QSynEditPainter(QSynEdit * edit,QPainter* painter,int FirstRow, int LastRow,
|
QSynEditPainter(QSynEdit * edit,QPainter* painter,
|
||||||
int FirstCol, int LastCol);
|
int firstRow,
|
||||||
|
int lastRow,
|
||||||
|
int left, int right);
|
||||||
QSynEditPainter(const QSynEditPainter&)=delete;
|
QSynEditPainter(const QSynEditPainter&)=delete;
|
||||||
QSynEditPainter& operator=(const QSynEditPainter&)=delete;
|
QSynEditPainter& operator=(const QSynEditPainter&)=delete;
|
||||||
|
|
||||||
|
@ -51,45 +53,45 @@ private:
|
||||||
QColor colEditorBG();
|
QColor colEditorBG();
|
||||||
void computeSelectionInfo();
|
void computeSelectionInfo();
|
||||||
void setDrawingColors(bool selected);
|
void setDrawingColors(bool selected);
|
||||||
int columnToXValue(int col);
|
int fixXValue(int xpos);
|
||||||
void paintToken(const QString& token, int tokenLen, int columnsBefore,
|
void paintToken(const QString& token, int tokenWidth, int tokenLeft,
|
||||||
int first, int last, bool isSelection, const QFont& font,
|
int first, int last, bool isSelection, const QFont& font,
|
||||||
const QFont& fontForNonAscii, bool showGlyphs);
|
const QFont& fontForNonAscii, bool showGlyphs);
|
||||||
void paintEditAreas(const EditingAreaList& areaList);
|
void paintEditAreas(const EditingAreaList& areaList);
|
||||||
void paintHighlightToken(bool bFillToEOL);
|
void paintHighlightToken(bool bFillToEOL);
|
||||||
void addHighlightToken(const QString& token, int columnsBefore, int tokenColumns,
|
void addHighlightToken(const QString& token, int tokenLeft, int tokenWidth,
|
||||||
int cLine, PTokenAttribute p_Attri, bool showGlyphs);
|
int line, PTokenAttribute p_Attri, bool showGlyphs);
|
||||||
|
|
||||||
void paintFoldAttributes();
|
void paintFoldAttributes();
|
||||||
void getBraceColorAttr(int level, PTokenAttribute &attr);
|
void getBraceColorAttr(int level, PTokenAttribute &attr);
|
||||||
void paintLines();
|
void paintLines();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSynEdit* edit;
|
QSynEdit* mEdit;
|
||||||
QPainter* painter;
|
QPainter* mPainter;
|
||||||
bool bDoRightEdge; // right edge
|
bool bDoRightEdge; // right edge
|
||||||
int nRightEdge;
|
int nRightEdge;
|
||||||
// selection info
|
// selection info
|
||||||
bool bAnySelection; // any selection visible?
|
bool bAnySelection; // any selection visible?
|
||||||
DisplayCoord vSelStart; // start of selected area
|
DisplayCoord mSelStart; // start of selected area
|
||||||
DisplayCoord vSelEnd; // end of selected area
|
DisplayCoord mSelEnd; // end of selected area
|
||||||
// info about normal and selected text and background colors
|
// info about normal and selected text and background colors
|
||||||
bool bSpecialLine, bLineSelected, bCurrentLine;
|
bool mIsSpecialLine, mIsLineSelected, mIsCurrentLine;
|
||||||
QColor colFG, colBG;
|
QColor colFG, colBG;
|
||||||
QColor colSelFG, colSelBG;
|
QColor colSelFG, colSelBG;
|
||||||
QColor colSpFG, colSpBG;
|
QColor colSpFG, colSpBG;
|
||||||
// info about selection of the current line
|
// info about selection of the current line
|
||||||
int nLineSelStart, nLineSelEnd;
|
int mLineSelStart, mLineSelEnd;
|
||||||
bool bComplexLine;
|
bool mIsComplexLine;
|
||||||
// painting the background and the text
|
// painting the background and the text
|
||||||
QRect rcLine, rcToken;
|
QRect rcLine, rcToken;
|
||||||
int vFirstLine, vLastLine;
|
int mFirstLine, mLastLine;
|
||||||
|
|
||||||
QRect AClip;
|
QRect mClip;
|
||||||
int aFirstRow, aLastRow, FirstCol, LastCol;
|
int mFirstRow, mLastRow, mLeft, mRight;
|
||||||
SynTokenAccu mTokenAccu;
|
SynTokenAccu mTokenAccu;
|
||||||
|
|
||||||
static QSet<QString> operatorGlyphs;
|
static QSet<QString> OperatorGlyphs;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
|
||||||
|
|
||||||
mWantReturns = true;
|
mWantReturns = true;
|
||||||
mWantTabs = false;
|
mWantTabs = false;
|
||||||
mLeftChar = 0;
|
mLeftPos = 0;
|
||||||
mTopLine = 1;
|
mTopLine = 1;
|
||||||
mCaretX = 1;
|
mCaretX = 1;
|
||||||
mLastCaretColumn = 1;
|
mLastCaretColumn = 1;
|
||||||
|
@ -327,13 +327,13 @@ bool QSynEdit::canRedo() const
|
||||||
|
|
||||||
int QSynEdit::maxScrollWidth() const
|
int QSynEdit::maxScrollWidth() const
|
||||||
{
|
{
|
||||||
int maxLen = mDocument->longestLineWidth();
|
int maxWidth = mDocument->longestLineWidth();
|
||||||
if (syntaxer())
|
if (syntaxer())
|
||||||
maxLen += stringWidth(syntaxer()->foldString(""),maxLen);
|
maxWidth += stringWidth(syntaxer()->foldString(""),maxWidth);
|
||||||
if (mOptions.testFlag(eoScrollPastEol))
|
if (mOptions.testFlag(eoScrollPastEol))
|
||||||
return std::max(maxLen ,1);
|
return std::max(maxWidth ,1);
|
||||||
else
|
else
|
||||||
return std::max(maxLen-mCharsInWindow+1, 1);
|
return std::max(maxWidth-viewWidth()+mCharWidth, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QSynEdit::getTokenAttriAtRowCol(const BufferCoord &pos, QString &token, PTokenAttribute &attri)
|
bool QSynEdit::getTokenAttriAtRowCol(const BufferCoord &pos, QString &token, PTokenAttribute &attri)
|
||||||
|
@ -425,7 +425,8 @@ void QSynEdit::addCaretToUndo()
|
||||||
void QSynEdit::addLeftTopToUndo()
|
void QSynEdit::addLeftTopToUndo()
|
||||||
{
|
{
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.ch = leftChar();
|
//todo: use buffer coord to save left pos is ugly
|
||||||
|
p.ch = leftPos();
|
||||||
p.line = topLine();
|
p.line = topLine();
|
||||||
mUndoList->addChange(ChangeReason::LeftTop,p,p,QStringList(), mActiveSelectionMode);
|
mUndoList->addChange(ChangeReason::LeftTop,p,p,QStringList(), mActiveSelectionMode);
|
||||||
}
|
}
|
||||||
|
@ -643,7 +644,7 @@ bool QSynEdit::pointToCharLine(const QPoint &point, BufferCoord &coord)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
coord = displayToBufferPos(pixelsToRowColumn(point.x(),point.y()));
|
coord = displayToBufferPos(pixelsToGlyphPos(point.x(),point.y()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,25 +717,38 @@ void QSynEdit::invalidateGutterLines(int FirstLine, int LastLine)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DisplayCoord QSynEdit::pixelsToNearestRowColumn(int aX, int aY) const
|
DisplayCoord QSynEdit::pixelsToNearestGlyphPos(int aX, int aY) const
|
||||||
{
|
{
|
||||||
return {
|
int xpos = std::max(0, leftPos() + aX - mGutterWidth - 2);
|
||||||
std::max(1, (int)(mLeftChar + round((aX - mGutterWidth - 2.0) / mCharWidth))),
|
int row = yposToRow(aY);
|
||||||
std::max(1, mTopLine + (aY / mTextHeight))
|
int line = rowToLine(row);
|
||||||
};
|
if (line<1 || line > mDocument->count() )
|
||||||
|
return DisplayCoord{-1,-1};
|
||||||
|
if (xpos<0 || xpos>mDocument->lineWidth(line-1))
|
||||||
|
return DisplayCoord{-1,-1};
|
||||||
|
int glyphIndex = mDocument->xposToGlyphIndex(line-1, xpos);
|
||||||
|
xpos = mDocument->glyphStartPostion(line-1, glyphIndex);
|
||||||
|
return DisplayCoord{xpos, row};
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayCoord QSynEdit::pixelsToRowColumn(int aX, int aY) const
|
DisplayCoord QSynEdit::pixelsToGlyphPos(int aX, int aY) const
|
||||||
{
|
{
|
||||||
int line = std::max(1, mTopLine + (aY / mTextHeight));
|
int xpos = std::max(0, leftPos() + aX - mGutterWidth - 2);
|
||||||
int col = std::max(1, (int)(mLeftChar + (aX - mGutterWidth - 2.0) / mCharWidth));
|
int row = yposToRow(aY);
|
||||||
return DisplayCoord{col, line};
|
int line = rowToLine(row);
|
||||||
|
if (line<1 || line > mDocument->count() )
|
||||||
|
return DisplayCoord{-1,-1};
|
||||||
|
if (xpos<0 || xpos>mDocument->lineWidth(line-1))
|
||||||
|
return DisplayCoord{-1,-1};
|
||||||
|
int glyphIndex = mDocument->xposToGlyphIndex(line-1, xpos);
|
||||||
|
xpos = mDocument->glyphStartPostion(line-1, glyphIndex);
|
||||||
|
return DisplayCoord{xpos, row};
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint QSynEdit::rowColumnToPixels(const DisplayCoord &coord) const
|
QPoint QSynEdit::displayCoordToPixels(const DisplayCoord &coord) const
|
||||||
{
|
{
|
||||||
QPoint result;
|
QPoint result;
|
||||||
result.setX((coord.x - 1) * mCharWidth + textOffset());
|
result.setX(coord.x + textOffset());
|
||||||
result.setY((coord.row - mTopLine) * mTextHeight);
|
result.setY((coord.row - mTopLine) * mTextHeight);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -748,6 +762,8 @@ QPoint QSynEdit::rowColumnToPixels(const DisplayCoord &coord) const
|
||||||
DisplayCoord QSynEdit::bufferToDisplayPos(const BufferCoord &p) const
|
DisplayCoord QSynEdit::bufferToDisplayPos(const BufferCoord &p) const
|
||||||
{
|
{
|
||||||
DisplayCoord result {p.ch,p.line};
|
DisplayCoord result {p.ch,p.line};
|
||||||
|
if (p.line<1)
|
||||||
|
return result;
|
||||||
// Account for tabs and charColumns
|
// Account for tabs and charColumns
|
||||||
if (p.line-1 <mDocument->count())
|
if (p.line-1 <mDocument->count())
|
||||||
result.x = charToGlyphLeft(p.line,p.ch);
|
result.x = charToGlyphLeft(p.line,p.ch);
|
||||||
|
@ -764,15 +780,17 @@ DisplayCoord QSynEdit::bufferToDisplayPos(const BufferCoord &p) const
|
||||||
*/
|
*/
|
||||||
BufferCoord QSynEdit::displayToBufferPos(const DisplayCoord &p) const
|
BufferCoord QSynEdit::displayToBufferPos(const DisplayCoord &p) const
|
||||||
{
|
{
|
||||||
BufferCoord Result{p.x,p.row};
|
BufferCoord result{p.x,p.row};
|
||||||
|
if (p.row<1)
|
||||||
|
return result;
|
||||||
// Account for code folding
|
// Account for code folding
|
||||||
if (mUseCodeFolding)
|
if (mUseCodeFolding)
|
||||||
Result.line = foldRowToLine(p.row);
|
result.line = foldRowToLine(p.row);
|
||||||
// Account for tabs
|
// Account for tabs
|
||||||
if (Result.line <= mDocument->count() ) {
|
if (result.line <= mDocument->count() ) {
|
||||||
Result.ch = xposToGlyphStartChar(Result.line,p.x);
|
result.ch = xposToGlyphStartChar(result.line,p.x);
|
||||||
}
|
}
|
||||||
return Result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ContentsCoord SynEdit::fromBufferCoord(const BufferCoord &p) const
|
//ContentsCoord SynEdit::fromBufferCoord(const BufferCoord &p) const
|
||||||
|
@ -866,6 +884,20 @@ int QSynEdit::xposToGlyphStartChar(int line, const QString &s, int xpos) const
|
||||||
return mDocument->xposToGlyphStartChar(line-1,s,xpos)+1;
|
return mDocument->xposToGlyphStartChar(line-1,s,xpos)+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QSynEdit::xposToGlyphLeft(int line, int xpos) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(line>=1 && line <= mDocument->count());
|
||||||
|
int glyphIndex = mDocument->xposToGlyphIndex(line-1,xpos);
|
||||||
|
return mDocument->glyphStartPostion(line-1,glyphIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// int QSynEdit::xposToGlyphRight(int line, int xpos) const
|
||||||
|
// {
|
||||||
|
// Q_ASSERT(line>=1 && line <= mDocument->count());
|
||||||
|
// int glyphIndex = mDocument->xposToGlyphIndex(line-1,xpos);
|
||||||
|
// return mDocument->glyphStartPostion(line-1,glyphIndex) + mDocument->glyphLength(line-1,glyphIndex)+1;
|
||||||
|
// }
|
||||||
|
|
||||||
int QSynEdit::stringWidth(const QString &line, int left) const
|
int QSynEdit::stringWidth(const QString &line, int left) const
|
||||||
{
|
{
|
||||||
return mDocument->stringWidth(line, left);
|
return mDocument->stringWidth(line, left);
|
||||||
|
@ -903,9 +935,9 @@ int QSynEdit::lineToRow(int aLine) const
|
||||||
return bufferToDisplayPos({1, aLine}).row;
|
return bufferToDisplayPos({1, aLine}).row;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::foldRowToLine(int Row) const
|
int QSynEdit::foldRowToLine(int row) const
|
||||||
{
|
{
|
||||||
int result = Row;
|
int result = row;
|
||||||
for (int i=0;i<mAllFoldRanges->count();i++) {
|
for (int i=0;i<mAllFoldRanges->count();i++) {
|
||||||
PCodeFoldingRange range = (*mAllFoldRanges)[i];
|
PCodeFoldingRange range = (*mAllFoldRanges)[i];
|
||||||
if (range->collapsed && !range->parentCollapsed() && range->fromLine < result) {
|
if (range->collapsed && !range->parentCollapsed() && range->fromLine < result) {
|
||||||
|
@ -915,18 +947,18 @@ int QSynEdit::foldRowToLine(int Row) const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::foldLineToRow(int Line) const
|
int QSynEdit::foldLineToRow(int line) const
|
||||||
{
|
{
|
||||||
int result = Line;
|
int result = line;
|
||||||
for (int i=mAllFoldRanges->count()-1;i>=0;i--) {
|
for (int i=mAllFoldRanges->count()-1;i>=0;i--) {
|
||||||
PCodeFoldingRange range =(*mAllFoldRanges)[i];
|
PCodeFoldingRange range =(*mAllFoldRanges)[i];
|
||||||
if (range->collapsed && !range->parentCollapsed()) {
|
if (range->collapsed && !range->parentCollapsed()) {
|
||||||
// Line is found after fold
|
// Line is found after fold
|
||||||
if (range->toLine < Line)
|
if (range->toLine < line)
|
||||||
result -= range->linesCollapsed;
|
result -= range->linesCollapsed;
|
||||||
// Inside fold
|
// Inside fold
|
||||||
else if (range->fromLine < Line && Line <= range->toLine)
|
else if (range->fromLine < line && line <= range->toLine)
|
||||||
result -= Line - range->fromLine;
|
result -= line - range->fromLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -942,21 +974,21 @@ void QSynEdit::setExtraKeystrokes()
|
||||||
mKeyStrokes.setExtraKeyStrokes();
|
mKeyStrokes.setExtraKeyStrokes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::invalidateLine(int Line)
|
void QSynEdit::invalidateLine(int line)
|
||||||
{
|
{
|
||||||
QRect rcInval;
|
QRect rcInval;
|
||||||
if (mPainterLock >0)
|
if (mPainterLock >0)
|
||||||
return;
|
return;
|
||||||
if (Line<1 || (Line>mDocument->count() &&
|
if (line<1 || (line>mDocument->count() &&
|
||||||
Line!=1) || !isVisible())
|
line!=1) || !isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// invalidate text area of this line
|
// invalidate text area of this line
|
||||||
if (mUseCodeFolding)
|
if (mUseCodeFolding)
|
||||||
Line = foldLineToRow(Line);
|
line = foldLineToRow(line);
|
||||||
if (Line >= mTopLine && Line <= mTopLine + mLinesInWindow) {
|
if (line >= mTopLine && line <= mTopLine + mLinesInWindow) {
|
||||||
rcInval = { mGutterWidth,
|
rcInval = { mGutterWidth,
|
||||||
mTextHeight * (Line - mTopLine),
|
mTextHeight * (line - mTopLine),
|
||||||
clientWidth(),
|
clientWidth(),
|
||||||
mTextHeight};
|
mTextHeight};
|
||||||
if (mStateFlags.testFlag(StateFlag::sfLinesChanging))
|
if (mStateFlags.testFlag(StateFlag::sfLinesChanging))
|
||||||
|
@ -966,14 +998,14 @@ void QSynEdit::invalidateLine(int Line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::invalidateLines(int FirstLine, int LastLine)
|
void QSynEdit::invalidateLines(int firstLine, int lastLine)
|
||||||
{
|
{
|
||||||
if (mPainterLock>0)
|
if (mPainterLock>0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
if (FirstLine == -1 && LastLine == -1) {
|
if (firstLine == -1 && lastLine == -1) {
|
||||||
QRect rcInval = clientRect();
|
QRect rcInval = clientRect();
|
||||||
rcInval.setLeft(rcInval.left()+mGutterWidth);
|
rcInval.setLeft(rcInval.left()+mGutterWidth);
|
||||||
if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) {
|
if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) {
|
||||||
|
@ -982,34 +1014,34 @@ void QSynEdit::invalidateLines(int FirstLine, int LastLine)
|
||||||
invalidateRect(rcInval);
|
invalidateRect(rcInval);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FirstLine = std::max(FirstLine, 1);
|
firstLine = std::max(firstLine, 1);
|
||||||
LastLine = std::max(LastLine, 1);
|
lastLine = std::max(lastLine, 1);
|
||||||
// find the visible lines first
|
// find the visible lines first
|
||||||
if (LastLine < FirstLine)
|
if (lastLine < firstLine)
|
||||||
std::swap(LastLine, FirstLine);
|
std::swap(lastLine, firstLine);
|
||||||
|
|
||||||
if (LastLine >= mDocument->count())
|
if (lastLine >= mDocument->count())
|
||||||
LastLine = INT_MAX; // paint empty space beyond last line
|
lastLine = INT_MAX; // paint empty space beyond last line
|
||||||
|
|
||||||
if (mUseCodeFolding) {
|
if (mUseCodeFolding) {
|
||||||
FirstLine = lineToRow(FirstLine);
|
firstLine = lineToRow(firstLine);
|
||||||
// Could avoid this conversion if (First = Last) and
|
// Could avoid this conversion if (First = Last) and
|
||||||
// (Length < CharsInWindow) but the dependency isn't worth IMO.
|
// (Length < CharsInWindow) but the dependency isn't worth IMO.
|
||||||
if (LastLine < mDocument->count())
|
if (lastLine < mDocument->count())
|
||||||
LastLine = lineToRow(LastLine + 1) - 1;
|
lastLine = lineToRow(lastLine + 1) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mTopLine is in display coordinates, so FirstLine and LastLine must be
|
// mTopLine is in display coordinates, so FirstLine and LastLine must be
|
||||||
// converted previously.
|
// converted previously.
|
||||||
FirstLine = std::max(FirstLine, mTopLine);
|
firstLine = std::max(firstLine, mTopLine);
|
||||||
LastLine = std::min(LastLine, mTopLine + mLinesInWindow);
|
lastLine = std::min(lastLine, mTopLine + mLinesInWindow);
|
||||||
|
|
||||||
// any line visible?
|
// any line visible?
|
||||||
if (LastLine >= FirstLine) {
|
if (lastLine >= firstLine) {
|
||||||
QRect rcInval = {
|
QRect rcInval = {
|
||||||
clientLeft()+mGutterWidth,
|
clientLeft()+mGutterWidth,
|
||||||
mTextHeight * (FirstLine - mTopLine),
|
mTextHeight * (firstLine - mTopLine),
|
||||||
clientWidth(), mTextHeight * (LastLine - mTopLine + 1)
|
clientWidth(), mTextHeight * (lastLine - mTopLine + 1)
|
||||||
};
|
};
|
||||||
if (mStateFlags.testFlag(StateFlag::sfLinesChanging))
|
if (mStateFlags.testFlag(StateFlag::sfLinesChanging))
|
||||||
mInvalidateRect = mInvalidateRect.united(rcInval);
|
mInvalidateRect = mInvalidateRect.united(rcInval);
|
||||||
|
@ -1202,8 +1234,8 @@ void QSynEdit::processGutterClick(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
int x = event->pos().x();
|
int x = event->pos().x();
|
||||||
int y = event->pos().y();
|
int y = event->pos().y();
|
||||||
DisplayCoord rowColumn = pixelsToNearestRowColumn(x, y);
|
int row = yposToRow(y);
|
||||||
int line = rowToLine(rowColumn.row);
|
int line = rowToLine(row);
|
||||||
|
|
||||||
// Check if we clicked on a folding thing
|
// Check if we clicked on a folding thing
|
||||||
if (mUseCodeFolding) {
|
if (mUseCodeFolding) {
|
||||||
|
@ -1214,7 +1246,7 @@ void QSynEdit::processGutterClick(QMouseEvent *event)
|
||||||
QRect rect;
|
QRect rect;
|
||||||
rect.setLeft(mGutterWidth - mGutter.rightOffset());
|
rect.setLeft(mGutterWidth - mGutter.rightOffset());
|
||||||
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
|
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
|
||||||
rect.setTop((rowColumn.row - mTopLine) * mTextHeight);
|
rect.setTop((row - mTopLine) * mTextHeight);
|
||||||
rect.setBottom(rect.top() + mTextHeight - 1);
|
rect.setBottom(rect.top() + mTextHeight - 1);
|
||||||
if (rect.contains(event->pos())) {
|
if (rect.contains(event->pos())) {
|
||||||
if (foldRange->collapsed)
|
if (foldRange->collapsed)
|
||||||
|
@ -1728,32 +1760,33 @@ void QSynEdit::doMouseScroll(bool isDragging)
|
||||||
if (!buttons.testFlag(Qt::LeftButton))
|
if (!buttons.testFlag(Qt::LeftButton))
|
||||||
return;
|
return;
|
||||||
QPoint iMousePos;
|
QPoint iMousePos;
|
||||||
DisplayCoord C;
|
DisplayCoord coord;
|
||||||
int X, Y;
|
|
||||||
|
|
||||||
iMousePos = QCursor::pos();
|
iMousePos = QCursor::pos();
|
||||||
iMousePos = mapFromGlobal(iMousePos);
|
iMousePos = mapFromGlobal(iMousePos);
|
||||||
C = pixelsToNearestRowColumn(iMousePos.x(), iMousePos.y());
|
coord = pixelsToNearestGlyphPos(iMousePos.x(), iMousePos.y());
|
||||||
C.row = minMax(C.row, 1, displayLineCount());
|
coord.row = minMax(coord.row, 1, displayLineCount());
|
||||||
if (mScrollDeltaX != 0) {
|
if (mScrollDeltaX != 0) {
|
||||||
setLeftChar(leftChar() + mScrollDeltaX * mMouseSelectionScrollSpeed);
|
int x;
|
||||||
X = leftChar();
|
setLeftPos(leftPos() + mScrollDeltaX * mMouseSelectionScrollSpeed);
|
||||||
|
x = leftPos();
|
||||||
if (mScrollDeltaX > 0) // scrolling right?
|
if (mScrollDeltaX > 0) // scrolling right?
|
||||||
X+=charsInWindow();
|
x+=viewWidth();
|
||||||
C.x = X;
|
coord.x = x;
|
||||||
}
|
}
|
||||||
if (mScrollDeltaY != 0) {
|
if (mScrollDeltaY != 0) {
|
||||||
|
int y;
|
||||||
//qDebug()<<mScrollDeltaY;
|
//qDebug()<<mScrollDeltaY;
|
||||||
if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier))
|
if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier))
|
||||||
setTopLine(mTopLine + mScrollDeltaY * mLinesInWindow);
|
setTopLine(mTopLine + mScrollDeltaY * mLinesInWindow);
|
||||||
else
|
else
|
||||||
setTopLine(mTopLine + mScrollDeltaY * mMouseSelectionScrollSpeed);
|
setTopLine(mTopLine + mScrollDeltaY * mMouseSelectionScrollSpeed);
|
||||||
Y = mTopLine;
|
y = mTopLine;
|
||||||
if (mScrollDeltaY > 0) // scrolling down?
|
if (mScrollDeltaY > 0) // scrolling down?
|
||||||
Y+=mLinesInWindow - 1;
|
y+=mLinesInWindow - 1;
|
||||||
C.row = minMax(Y, 1, displayLineCount());
|
coord.row = minMax(y, 1, displayLineCount());
|
||||||
}
|
}
|
||||||
BufferCoord vCaret = displayToBufferPos(C);
|
BufferCoord vCaret = displayToBufferPos(coord);
|
||||||
if ((caretX() != vCaret.ch) || (caretY() != vCaret.line)) {
|
if ((caretX() != vCaret.ch) || (caretY() != vCaret.line)) {
|
||||||
// changes to line / column in one go
|
// changes to line / column in one go
|
||||||
incPaintLock();
|
incPaintLock();
|
||||||
|
@ -2469,7 +2502,7 @@ QRect QSynEdit::calculateCaretRect() const
|
||||||
QString sLine = lineText().left(mCaretX-1)
|
QString sLine = lineText().left(mCaretX-1)
|
||||||
+ mInputPreeditString
|
+ mInputPreeditString
|
||||||
+ lineText().mid(mCaretX-1);
|
+ lineText().mid(mCaretX-1);
|
||||||
coord.x = charToGlyphLeft(mCaretY-1, sLine,mCaretX+mInputPreeditString.length());
|
coord.x = charToGlyphLeft(mCaretY, sLine,mCaretX+mInputPreeditString.length());
|
||||||
}
|
}
|
||||||
int rows=1;
|
int rows=1;
|
||||||
if (mActiveSelectionMode == SelectionMode::Column) {
|
if (mActiveSelectionMode == SelectionMode::Column) {
|
||||||
|
@ -2478,13 +2511,13 @@ QRect QSynEdit::calculateCaretRect() const
|
||||||
coord.row = startRow;
|
coord.row = startRow;
|
||||||
rows = endRow-startRow+1;
|
rows = endRow-startRow+1;
|
||||||
}
|
}
|
||||||
QPoint caretPos = rowColumnToPixels(coord);
|
QPoint caretPos = displayCoordToPixels(coord);
|
||||||
int caretWidth=mCharWidth;
|
int caretWidth = mCharWidth;
|
||||||
if (mCaretY <= mDocument->count() && mCaretX <= mDocument->getLine(mCaretY-1).length()) {
|
if (mCaretY <= mDocument->count() && mCaretX <= mDocument->getLine(mCaretY-1).length()) {
|
||||||
int glyphIndex = mDocument->charToGlyphIndex(mCaretY-1, mCaretX-1);
|
int glyphIndex = mDocument->charToGlyphIndex(mCaretY-1, mCaretX-1);
|
||||||
QString glyph = mDocument->glyph(mCaretY-1, glyphIndex);
|
|
||||||
caretWidth = mDocument->glyphWidth(mCaretY-1, glyphIndex);
|
caretWidth = mDocument->glyphWidth(mCaretY-1, glyphIndex);
|
||||||
}
|
}
|
||||||
|
// qDebug()<<"caret:"<<mCaretX<<mCaretY<<caretWidth;
|
||||||
if (mActiveSelectionMode == SelectionMode::Column) {
|
if (mActiveSelectionMode == SelectionMode::Column) {
|
||||||
return QRect(caretPos.x(),caretPos.y(),caretWidth,
|
return QRect(caretPos.x(),caretPos.y(),caretWidth,
|
||||||
mTextHeight*(rows));
|
mTextHeight*(rows));
|
||||||
|
@ -2497,11 +2530,10 @@ QRect QSynEdit::calculateCaretRect() const
|
||||||
QRect QSynEdit::calculateInputCaretRect() const
|
QRect QSynEdit::calculateInputCaretRect() const
|
||||||
{
|
{
|
||||||
DisplayCoord coord = displayXY();
|
DisplayCoord coord = displayXY();
|
||||||
QPoint caretPos = rowColumnToPixels(coord);
|
QPoint caretPos = displayCoordToPixels(coord);
|
||||||
int caretWidth=mCharWidth;
|
int caretWidth=mCharWidth;
|
||||||
if (mCaretY <= mDocument->count() && mCaretX <= mDocument->getLine(mCaretY-1).length()) {
|
if (mCaretY <= mDocument->count() && mCaretX <= mDocument->getLine(mCaretY-1).length()) {
|
||||||
int glyphIndex = mDocument->charToGlyphIndex(mCaretY-1, mCaretX-1);
|
int glyphIndex = mDocument->charToGlyphIndex(mCaretY-1, mCaretX-1);
|
||||||
QString glyph = mDocument->glyph(mCaretY-1, glyphIndex);
|
|
||||||
caretWidth = mDocument->glyphWidth(mCaretY-1, glyphIndex);
|
caretWidth = mDocument->glyphWidth(mCaretY-1, glyphIndex);
|
||||||
}
|
}
|
||||||
return QRect(caretPos.x(),caretPos.y(),caretWidth,
|
return QRect(caretPos.x(),caretPos.y(),caretWidth,
|
||||||
|
@ -2517,10 +2549,10 @@ void QSynEdit::computeCaret()
|
||||||
{
|
{
|
||||||
QPoint iMousePos = QCursor::pos();
|
QPoint iMousePos = QCursor::pos();
|
||||||
iMousePos = mapFromGlobal(iMousePos);
|
iMousePos = mapFromGlobal(iMousePos);
|
||||||
int X=iMousePos.x();
|
int x=iMousePos.x();
|
||||||
int Y=iMousePos.y();
|
int y=iMousePos.y();
|
||||||
|
|
||||||
DisplayCoord vCaretNearestPos = pixelsToNearestRowColumn(X, Y);
|
DisplayCoord vCaretNearestPos = pixelsToNearestGlyphPos(x, y);
|
||||||
vCaretNearestPos.row = minMax(vCaretNearestPos.row, 1, displayLineCount());
|
vCaretNearestPos.row = minMax(vCaretNearestPos.row, 1, displayLineCount());
|
||||||
setInternalDisplayXY(vCaretNearestPos);
|
setInternalDisplayXY(vCaretNearestPos);
|
||||||
}
|
}
|
||||||
|
@ -2969,27 +3001,27 @@ void QSynEdit::decPaintLock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::clientWidth()
|
int QSynEdit::clientWidth() const
|
||||||
{
|
{
|
||||||
return viewport()->size().width();
|
return viewport()->size().width();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::clientHeight()
|
int QSynEdit::clientHeight() const
|
||||||
{
|
{
|
||||||
return viewport()->size().height();
|
return viewport()->size().height();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::clientTop()
|
int QSynEdit::clientTop() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::clientLeft()
|
int QSynEdit::clientLeft() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect QSynEdit::clientRect()
|
QRect QSynEdit::clientRect() const
|
||||||
{
|
{
|
||||||
return QRect(0,0, clientWidth(), clientHeight());
|
return QRect(0,0, clientWidth(), clientHeight());
|
||||||
}
|
}
|
||||||
|
@ -3018,13 +3050,13 @@ void QSynEdit::ensureCursorPosVisibleEx(bool ForceToMiddle)
|
||||||
decPaintLock();
|
decPaintLock();
|
||||||
});
|
});
|
||||||
// Make sure X is visible
|
// Make sure X is visible
|
||||||
int VisibleX = displayX();
|
int visibleX = displayX();
|
||||||
if (VisibleX < leftChar())
|
if (visibleX < leftPos())
|
||||||
setLeftChar(VisibleX);
|
setLeftPos(visibleX);
|
||||||
else if (VisibleX >= mCharsInWindow + leftChar() && mCharsInWindow > 0)
|
else if (visibleX >= viewWidth() + leftPos() && viewWidth()>0)
|
||||||
setLeftChar(VisibleX - mCharsInWindow + 1);
|
setLeftPos(visibleX - viewWidth() + 1);
|
||||||
else
|
else
|
||||||
setLeftChar(leftChar());
|
setLeftPos(leftPos());
|
||||||
// Make sure Y is visible
|
// Make sure Y is visible
|
||||||
int vCaretRow = displayY();
|
int vCaretRow = displayY();
|
||||||
if (ForceToMiddle) {
|
if (ForceToMiddle) {
|
||||||
|
@ -3107,8 +3139,8 @@ void QSynEdit::updateScrollbars()
|
||||||
nMaxScroll = maxScrollWidth();
|
nMaxScroll = maxScrollWidth();
|
||||||
nMin = 1;
|
nMin = 1;
|
||||||
nMax = nMaxScroll;
|
nMax = nMaxScroll;
|
||||||
nPage = mCharsInWindow;
|
nPage = viewWidth();
|
||||||
nPos = mLeftChar;
|
nPos = mLeftPos;
|
||||||
horizontalScrollBar()->setMinimum(nMin);
|
horizontalScrollBar()->setMinimum(nMin);
|
||||||
horizontalScrollBar()->setMaximum(nMax);
|
horizontalScrollBar()->setMaximum(nMax);
|
||||||
horizontalScrollBar()->setPageStep(nPage);
|
horizontalScrollBar()->setPageStep(nPage);
|
||||||
|
@ -3727,7 +3759,7 @@ void QSynEdit::paintCaret(QPainter &painter, const QRect rcClip)
|
||||||
|
|
||||||
int QSynEdit::textOffset() const
|
int QSynEdit::textOffset() const
|
||||||
{
|
{
|
||||||
return mGutterWidth + 2 - (mLeftChar-1)*mCharWidth;
|
return mGutterWidth + 2 - mLeftPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCommand QSynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
|
EditCommand QSynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
|
||||||
|
@ -3754,9 +3786,7 @@ EditCommand QSynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers)
|
||||||
|
|
||||||
void QSynEdit::onSizeOrFontChanged(bool bFont)
|
void QSynEdit::onSizeOrFontChanged(bool bFont)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mCharWidth != 0) {
|
if (mCharWidth != 0) {
|
||||||
mCharsInWindow = std::max(clientWidth() - mGutterWidth - 2, 0) / mCharWidth;
|
|
||||||
mLinesInWindow = clientHeight() / mTextHeight;
|
mLinesInWindow = clientHeight() / mTextHeight;
|
||||||
bool scrollBarChangedSettings = mStateFlags.testFlag(StateFlag::sfScrollbarChanged);
|
bool scrollBarChangedSettings = mStateFlags.testFlag(StateFlag::sfScrollbarChanged);
|
||||||
if (bFont) {
|
if (bFont) {
|
||||||
|
@ -3770,7 +3800,7 @@ void QSynEdit::onSizeOrFontChanged(bool bFont)
|
||||||
updateScrollbars();
|
updateScrollbars();
|
||||||
mStateFlags.setFlag(StateFlag::sfScrollbarChanged,scrollBarChangedSettings);
|
mStateFlags.setFlag(StateFlag::sfScrollbarChanged,scrollBarChangedSettings);
|
||||||
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol))
|
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol))
|
||||||
setLeftChar(mLeftChar);
|
setLeftPos(mLeftPos);
|
||||||
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEof))
|
//if (!mOptions.testFlag(SynEditorOption::eoScrollPastEof))
|
||||||
setTopLine(mTopLine);
|
setTopLine(mTopLine);
|
||||||
}
|
}
|
||||||
|
@ -3783,7 +3813,7 @@ void QSynEdit::onChanged()
|
||||||
|
|
||||||
void QSynEdit::onScrolled(int)
|
void QSynEdit::onScrolled(int)
|
||||||
{
|
{
|
||||||
mLeftChar = horizontalScrollBar()->value();
|
mLeftPos = horizontalScrollBar()->value();
|
||||||
mTopLine = verticalScrollBar()->value();
|
mTopLine = verticalScrollBar()->value();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
@ -4051,7 +4081,7 @@ void QSynEdit::setOptions(const EditorOptions &Value)
|
||||||
if (Value != mOptions) {
|
if (Value != mOptions) {
|
||||||
//bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles);
|
//bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles);
|
||||||
//if (!mOptions.testFlag(eoScrollPastEol))
|
//if (!mOptions.testFlag(eoScrollPastEol))
|
||||||
setLeftChar(mLeftChar);
|
setLeftPos(mLeftPos);
|
||||||
//if (!mOptions.testFlag(eoScrollPastEof))
|
//if (!mOptions.testFlag(eoScrollPastEof))
|
||||||
setTopLine(mTopLine);
|
setTopLine(mTopLine);
|
||||||
|
|
||||||
|
@ -4176,7 +4206,7 @@ void QSynEdit::doUndoItem()
|
||||||
break;
|
break;
|
||||||
case ChangeReason::LeftTop:
|
case ChangeReason::LeftTop:
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.ch = leftChar();
|
p.ch = leftPos();
|
||||||
p.line = topLine();
|
p.line = topLine();
|
||||||
mRedoList->addRedo(
|
mRedoList->addRedo(
|
||||||
item->changeReason(),
|
item->changeReason(),
|
||||||
|
@ -4184,7 +4214,7 @@ void QSynEdit::doUndoItem()
|
||||||
p, QStringList(),
|
p, QStringList(),
|
||||||
item->changeSelMode(),
|
item->changeSelMode(),
|
||||||
item->changeNumber());
|
item->changeNumber());
|
||||||
setLeftChar(item->changeStartPos().ch);
|
setLeftPos(item->changeStartPos().ch);
|
||||||
setTopLine(item->changeStartPos().line);
|
setTopLine(item->changeStartPos().line);
|
||||||
break;
|
break;
|
||||||
case ChangeReason::Selection:
|
case ChangeReason::Selection:
|
||||||
|
@ -4372,7 +4402,7 @@ void QSynEdit::doRedoItem()
|
||||||
break;
|
break;
|
||||||
case ChangeReason::LeftTop:
|
case ChangeReason::LeftTop:
|
||||||
BufferCoord p;
|
BufferCoord p;
|
||||||
p.ch = leftChar();
|
p.ch = leftPos();
|
||||||
p.line = topLine();
|
p.line = topLine();
|
||||||
mUndoList->restoreChange(
|
mUndoList->restoreChange(
|
||||||
item->changeReason(),
|
item->changeReason(),
|
||||||
|
@ -4380,7 +4410,7 @@ void QSynEdit::doRedoItem()
|
||||||
p, QStringList(),
|
p, QStringList(),
|
||||||
item->changeSelMode(),
|
item->changeSelMode(),
|
||||||
item->changeNumber());
|
item->changeNumber());
|
||||||
setLeftChar(item->changeStartPos().ch);
|
setLeftPos(item->changeStartPos().ch);
|
||||||
setTopLine(item->changeStartPos().line);
|
setTopLine(item->changeStartPos().line);
|
||||||
break;
|
break;
|
||||||
case ChangeReason::Selection:
|
case ChangeReason::Selection:
|
||||||
|
@ -5657,11 +5687,11 @@ void QSynEdit::executeCommand(EditCommand command, QChar ch, void *pData)
|
||||||
break;
|
break;
|
||||||
case EditCommand::PageLeft:
|
case EditCommand::PageLeft:
|
||||||
case EditCommand::SelPageLeft:
|
case EditCommand::SelPageLeft:
|
||||||
moveCaretHorz(-mCharsInWindow, command == EditCommand::SelPageLeft);
|
moveCaretHorz(-viewWidth(), command == EditCommand::SelPageLeft);
|
||||||
break;
|
break;
|
||||||
case EditCommand::PageRight:
|
case EditCommand::PageRight:
|
||||||
case EditCommand::SelPageRight:
|
case EditCommand::SelPageRight:
|
||||||
moveCaretHorz(mCharsInWindow, command == EditCommand::SelPageRight);
|
moveCaretHorz(viewWidth(), command == EditCommand::SelPageRight);
|
||||||
break;
|
break;
|
||||||
case EditCommand::LineStart:
|
case EditCommand::LineStart:
|
||||||
case EditCommand::SelLineStart:
|
case EditCommand::SelLineStart:
|
||||||
|
@ -5982,13 +6012,14 @@ void QSynEdit::updateMouseCursor(){
|
||||||
|
|
||||||
bool QSynEdit::isCaretVisible()
|
bool QSynEdit::isCaretVisible()
|
||||||
{
|
{
|
||||||
if (mCaretY < mTopLine)
|
DisplayCoord caret = displayXY();
|
||||||
|
if (caret.row < mTopLine)
|
||||||
return false;
|
return false;
|
||||||
if (mCaretY >= mTopLine + mLinesInWindow )
|
if (caret.row >= mTopLine + mLinesInWindow )
|
||||||
return false;
|
return false;
|
||||||
if (mCaretX < mLeftChar)
|
if (caret.x < mLeftPos)
|
||||||
return false;
|
return false;
|
||||||
if (mCaretX >= mLeftChar + mCharsInWindow)
|
if (caret.x >= mLeftPos + viewWidth())
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6023,14 +6054,13 @@ void QSynEdit::paintEvent(QPaintEvent *event)
|
||||||
painter.drawImage(rcCaret,*mContentImage,cacheRC);
|
painter.drawImage(rcCaret,*mContentImage,cacheRC);
|
||||||
} else {
|
} else {
|
||||||
QRect rcDraw;
|
QRect rcDraw;
|
||||||
int nL1, nL2, nC1, nC2;
|
int nL1, nL2, nX1, nX2;
|
||||||
// Compute the invalid area in lines / columns.
|
// Compute the invalid area in lines / columns.
|
||||||
// columns
|
// columns
|
||||||
nC1 = mLeftChar;
|
nX1 = mLeftPos;
|
||||||
if (rcClip.left() > mGutterWidth + 2 )
|
if (rcClip.left() > mGutterWidth + 2 )
|
||||||
nC1 += (rcClip.left() - mGutterWidth - 2 ) / mCharWidth;
|
nX1 += (rcClip.left() - mGutterWidth - 2 ) ;
|
||||||
nC2 = mLeftChar +
|
nX2 = mLeftPos + (rcClip.right() - mGutterWidth - 2);
|
||||||
(rcClip.right() - mGutterWidth - 2 + mCharWidth - 1) / mCharWidth;
|
|
||||||
// lines
|
// lines
|
||||||
nL1 = minMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount());
|
nL1 = minMax(mTopLine + rcClip.top() / mTextHeight, mTopLine, displayLineCount());
|
||||||
nL2 = minMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount());
|
nL2 = minMax(mTopLine + (rcClip.bottom() + mTextHeight - 1) / mTextHeight, 1, displayLineCount());
|
||||||
|
@ -6040,7 +6070,7 @@ void QSynEdit::paintEvent(QPaintEvent *event)
|
||||||
QPainter cachePainter(mContentImage.get());
|
QPainter cachePainter(mContentImage.get());
|
||||||
cachePainter.setFont(font());
|
cachePainter.setFont(font());
|
||||||
QSynEditPainter textPainter(this, &cachePainter,
|
QSynEditPainter textPainter(this, &cachePainter,
|
||||||
nL1,nL2,nC1,nC2);
|
nL1,nL2,nX1,nX2);
|
||||||
// First paint paint the text area if it was (partly) invalidated.
|
// First paint paint the text area if it was (partly) invalidated.
|
||||||
if (rcClip.right() > mGutterWidth ) {
|
if (rcClip.right() > mGutterWidth ) {
|
||||||
rcDraw = rcClip;
|
rcDraw = rcClip;
|
||||||
|
@ -6175,7 +6205,7 @@ void QSynEdit::mousePressEvent(QMouseEvent *event)
|
||||||
BufferCoord oldCaret=caretXY();
|
BufferCoord oldCaret=caretXY();
|
||||||
if (button == Qt::RightButton) {
|
if (button == Qt::RightButton) {
|
||||||
if (mOptions.testFlag(eoRightMouseMovesCursor) &&
|
if (mOptions.testFlag(eoRightMouseMovesCursor) &&
|
||||||
( (selAvail() && ! isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))))
|
( (selAvail() && ! isPointInSelection(displayToBufferPos(pixelsToGlyphPos(X, Y))))
|
||||||
|| ! selAvail())) {
|
|| ! selAvail())) {
|
||||||
invalidateSelection();
|
invalidateSelection();
|
||||||
//mBlockEnd=mBlockBegin;
|
//mBlockEnd=mBlockBegin;
|
||||||
|
@ -6192,7 +6222,7 @@ void QSynEdit::mousePressEvent(QMouseEvent *event)
|
||||||
computeCaret();
|
computeCaret();
|
||||||
mStateFlags.setFlag(StateFlag::sfWaitForDragging,false);
|
mStateFlags.setFlag(StateFlag::sfWaitForDragging,false);
|
||||||
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
|
if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2)
|
||||||
&& (mActiveSelectionMode == SelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
|
&& (mActiveSelectionMode == SelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToGlyphPos(X, Y))) ) {
|
||||||
bStartDrag = true;
|
bStartDrag = true;
|
||||||
}
|
}
|
||||||
if (bStartDrag && !mReadOnly) {
|
if (bStartDrag && !mReadOnly) {
|
||||||
|
@ -6393,7 +6423,7 @@ void QSynEdit::dragEnterEvent(QDragEnterEvent *event)
|
||||||
mDragCaretSave = caretXY();
|
mDragCaretSave = caretXY();
|
||||||
mDragSelBeginSave = blockBegin();
|
mDragSelBeginSave = blockBegin();
|
||||||
mDragSelEndSave = blockEnd();
|
mDragSelEndSave = blockEnd();
|
||||||
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
|
BufferCoord coord = displayToBufferPos(pixelsToNearestGlyphPos(event->pos().x(),
|
||||||
event->pos().y()));
|
event->pos().y()));
|
||||||
internalSetCaretXY(coord);
|
internalSetCaretXY(coord);
|
||||||
setBlockBegin(mDragSelBeginSave);
|
setBlockBegin(mDragSelBeginSave);
|
||||||
|
@ -6408,7 +6438,7 @@ void QSynEdit::dropEvent(QDropEvent *event)
|
||||||
{
|
{
|
||||||
//mScrollTimer->stop();
|
//mScrollTimer->stop();
|
||||||
|
|
||||||
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(event->pos().x(),
|
BufferCoord coord = displayToBufferPos(pixelsToNearestGlyphPos(event->pos().x(),
|
||||||
event->pos().y()));
|
event->pos().y()));
|
||||||
if (
|
if (
|
||||||
(event->proposedAction() == Qt::DropAction::CopyAction
|
(event->proposedAction() == Qt::DropAction::CopyAction
|
||||||
|
@ -6432,7 +6462,7 @@ void QSynEdit::dropEvent(QDropEvent *event)
|
||||||
coord = ensureBufferCoordValid(coord);
|
coord = ensureBufferCoordValid(coord);
|
||||||
bool lastLineUsed = coord.line == mDocument->count();
|
bool lastLineUsed = coord.line == mDocument->count();
|
||||||
int topLine = mTopLine;
|
int topLine = mTopLine;
|
||||||
int leftChar = mLeftChar;
|
int leftPos = mLeftPos;
|
||||||
int line=mDocument->count()-1;
|
int line=mDocument->count()-1;
|
||||||
QString s=mDocument->getLine(line-1);
|
QString s=mDocument->getLine(line-1);
|
||||||
QStringList text=splitStrings(event->mimeData()->text());
|
QStringList text=splitStrings(event->mimeData()->text());
|
||||||
|
@ -6495,7 +6525,7 @@ void QSynEdit::dropEvent(QDropEvent *event)
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
mDropped = true;
|
mDropped = true;
|
||||||
setTopLine(topLine);
|
setTopLine(topLine);
|
||||||
setLeftChar(leftChar);
|
setLeftPos(leftPos);
|
||||||
internalSetCaretXY(coord);
|
internalSetCaretXY(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6512,9 +6542,9 @@ void QSynEdit::dragMoveEvent(QDragMoveEvent *event)
|
||||||
|
|
||||||
QPoint iMousePos = QCursor::pos();
|
QPoint iMousePos = QCursor::pos();
|
||||||
iMousePos = mapFromGlobal(iMousePos);
|
iMousePos = mapFromGlobal(iMousePos);
|
||||||
int X=iMousePos.x();
|
int x=iMousePos.x();
|
||||||
int Y=iMousePos.y();
|
int y=iMousePos.y();
|
||||||
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(X,Y));
|
BufferCoord coord = displayToBufferPos(pixelsToNearestGlyphPos(x,y));
|
||||||
internalSetCaretXY(coord);
|
internalSetCaretXY(coord);
|
||||||
setBlockBegin(mDragSelBeginSave);
|
setBlockBegin(mDragSelBeginSave);
|
||||||
setBlockEnd(mDragSelEndSave);
|
setBlockEnd(mDragSelEndSave);
|
||||||
|
@ -6580,11 +6610,6 @@ void QSynEdit::setGutterWidth(int Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::charWidth() const
|
|
||||||
{
|
|
||||||
return mCharWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QSynEdit::setUndoLimit(int size)
|
void QSynEdit::setUndoLimit(int size)
|
||||||
{
|
{
|
||||||
mUndoList->setMaxUndoActions(size);
|
mUndoList->setMaxUndoActions(size);
|
||||||
|
@ -6596,11 +6621,6 @@ void QSynEdit::setUndoMemoryUsage(int size)
|
||||||
// mUndoList->setMaxMemoryUsage(size*1024);
|
// mUndoList->setMaxMemoryUsage(size*1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::charsInWindow() const
|
|
||||||
{
|
|
||||||
return mCharsInWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QSynEdit::onBookMarkOptionsChanged()
|
void QSynEdit::onBookMarkOptionsChanged()
|
||||||
{
|
{
|
||||||
invalidateGutter();
|
invalidateGutter();
|
||||||
|
@ -6653,7 +6673,7 @@ void QSynEdit::onLinesCleared()
|
||||||
setCaretXY({1,1});
|
setCaretXY({1,1});
|
||||||
// scroll to start of text
|
// scroll to start of text
|
||||||
setTopLine(1);
|
setTopLine(1);
|
||||||
setLeftChar(1);
|
setLeftPos(0);
|
||||||
mStatusChanges.setFlag(StatusChange::scAll);
|
mStatusChanges.setFlag(StatusChange::scAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6902,19 +6922,19 @@ void QSynEdit::setBlockBegin(BufferCoord value)
|
||||||
setStatusChanged(StatusChange::scSelection);
|
setStatusChanged(StatusChange::scSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSynEdit::leftChar() const
|
int QSynEdit::leftPos() const
|
||||||
{
|
{
|
||||||
return mLeftChar;
|
return mLeftPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSynEdit::setLeftChar(int Value)
|
void QSynEdit::setLeftPos(int value)
|
||||||
{
|
{
|
||||||
//int MaxVal;
|
//int MaxVal;
|
||||||
//QRect iTextArea;
|
//QRect iTextArea;
|
||||||
Value = std::min(Value,maxScrollWidth());
|
value = std::min(value,maxScrollWidth());
|
||||||
if (Value != mLeftChar) {
|
if (value != mLeftPos) {
|
||||||
horizontalScrollBar()->setValue(Value);
|
horizontalScrollBar()->setValue(value);
|
||||||
setStatusChanged(StatusChange::scLeftChar);
|
setStatusChanged(StatusChange::scLeftPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ enum StatusChange {
|
||||||
scAll = 0x0001,
|
scAll = 0x0001,
|
||||||
scCaretX = 0x0002,
|
scCaretX = 0x0002,
|
||||||
scCaretY = 0x0004,
|
scCaretY = 0x0004,
|
||||||
scLeftChar = 0x0008,
|
scLeftPos = 0x0008,
|
||||||
scTopLine = 0x0010,
|
scTopLine = 0x0010,
|
||||||
scInsertMode = 0x0020,
|
scInsertMode = 0x0020,
|
||||||
scModifyChanged = 0x0040,
|
scModifyChanged = 0x0040,
|
||||||
|
@ -161,9 +161,14 @@ public:
|
||||||
void invalidateGutter();
|
void invalidateGutter();
|
||||||
void invalidateGutterLine(int aLine);
|
void invalidateGutterLine(int aLine);
|
||||||
void invalidateGutterLines(int FirstLine, int LastLine);
|
void invalidateGutterLines(int FirstLine, int LastLine);
|
||||||
DisplayCoord pixelsToNearestRowColumn(int aX, int aY) const;
|
|
||||||
DisplayCoord pixelsToRowColumn(int aX, int aY) const;
|
int yposToRow(int y) const {
|
||||||
QPoint rowColumnToPixels(const DisplayCoord& coord) const;
|
return std::max(1, mTopLine + (y / mTextHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayCoord pixelsToNearestGlyphPos(int aX, int aY) const;
|
||||||
|
DisplayCoord pixelsToGlyphPos(int aX, int aY) const;
|
||||||
|
QPoint displayCoordToPixels(const DisplayCoord& coord) const;
|
||||||
DisplayCoord bufferToDisplayPos(const BufferCoord& p) const;
|
DisplayCoord bufferToDisplayPos(const BufferCoord& p) const;
|
||||||
BufferCoord displayToBufferPos(const DisplayCoord& p) const;
|
BufferCoord displayToBufferPos(const DisplayCoord& p) const;
|
||||||
|
|
||||||
|
@ -180,16 +185,18 @@ public:
|
||||||
//int charToColumn(const QString& s, int aChar) const;
|
//int charToColumn(const QString& s, int aChar) const;
|
||||||
int xposToGlyphStartChar(int line, int xpos) const;
|
int xposToGlyphStartChar(int line, int xpos) const;
|
||||||
int xposToGlyphStartChar(int line, const QString& s, int xpos) const;
|
int xposToGlyphStartChar(int line, const QString& s, int xpos) const;
|
||||||
|
int xposToGlyphLeft(int line, int xpos) const;
|
||||||
|
//int xposToGlyphRight(int line, int xpos) const;
|
||||||
int stringWidth(const QString& line, int left) const;
|
int stringWidth(const QString& line, int left) const;
|
||||||
int getLineIndent(const QString& line) const;
|
int getLineIndent(const QString& line) const;
|
||||||
int rowToLine(int aRow) const;
|
int rowToLine(int aRow) const;
|
||||||
int lineToRow(int aLine) const;
|
int lineToRow(int aLine) const;
|
||||||
int foldRowToLine(int Row) const;
|
int foldRowToLine(int row) const;
|
||||||
int foldLineToRow(int Line) const;
|
int foldLineToRow(int line) const;
|
||||||
void setDefaultKeystrokes();
|
void setDefaultKeystrokes();
|
||||||
void setExtraKeystrokes();
|
void setExtraKeystrokes();
|
||||||
void invalidateLine(int Line);
|
void invalidateLine(int line);
|
||||||
void invalidateLines(int FirstLine, int LastLine);
|
void invalidateLines(int firstLine, int lastLine);
|
||||||
void invalidateSelection();
|
void invalidateSelection();
|
||||||
void invalidateRect(const QRect& rect);
|
void invalidateRect(const QRect& rect);
|
||||||
void invalidate();
|
void invalidate();
|
||||||
|
@ -316,8 +323,8 @@ public:
|
||||||
|
|
||||||
int linesInWindow() const;
|
int linesInWindow() const;
|
||||||
|
|
||||||
int leftChar() const;
|
int leftPos() const;
|
||||||
void setLeftChar(int value);
|
void setLeftPos(int value);
|
||||||
|
|
||||||
BufferCoord blockBegin() const;
|
BufferCoord blockBegin() const;
|
||||||
BufferCoord blockEnd() const;
|
BufferCoord blockEnd() const;
|
||||||
|
@ -331,9 +338,13 @@ public:
|
||||||
SelectionMode activeSelectionMode() const;
|
SelectionMode activeSelectionMode() const;
|
||||||
void setActiveSelectionMode(const SelectionMode &Value);
|
void setActiveSelectionMode(const SelectionMode &Value);
|
||||||
|
|
||||||
int charsInWindow() const;
|
int charWidth() const {
|
||||||
|
return mCharWidth;
|
||||||
|
}
|
||||||
|
|
||||||
int charWidth() const;
|
int viewWidth() const{
|
||||||
|
return clientWidth() - mGutterWidth - 2;
|
||||||
|
}
|
||||||
|
|
||||||
void setUndoLimit(int size);
|
void setUndoLimit(int size);
|
||||||
void setUndoMemoryUsage(int size);
|
void setUndoMemoryUsage(int size);
|
||||||
|
@ -354,6 +365,9 @@ public:
|
||||||
|
|
||||||
QString displayLineText();
|
QString displayLineText();
|
||||||
QString lineText() const;
|
QString lineText() const;
|
||||||
|
QString lineText(int line) const {
|
||||||
|
return mDocument->getLine(line-1);
|
||||||
|
}
|
||||||
void setLineText(const QString s);
|
void setLineText(const QString s);
|
||||||
|
|
||||||
const PDocument& document() const;
|
const PDocument& document() const;
|
||||||
|
@ -486,11 +500,11 @@ private:
|
||||||
|
|
||||||
void incPaintLock();
|
void incPaintLock();
|
||||||
void decPaintLock();
|
void decPaintLock();
|
||||||
int clientWidth();
|
int clientWidth() const;
|
||||||
int clientHeight();
|
int clientHeight() const;
|
||||||
int clientTop();
|
int clientTop() const;
|
||||||
int clientLeft();
|
int clientLeft() const;
|
||||||
QRect clientRect();
|
QRect clientRect() const;
|
||||||
void synFontChanged();
|
void synFontChanged();
|
||||||
|
|
||||||
void doSetSelText(const QString& value);
|
void doSetSelText(const QString& value);
|
||||||
|
@ -656,7 +670,6 @@ private:
|
||||||
int mCaretX;
|
int mCaretX;
|
||||||
int mLastCaretColumn;
|
int mLastCaretColumn;
|
||||||
int mCaretY;
|
int mCaretY;
|
||||||
int mCharsInWindow;
|
|
||||||
int mCharWidth;
|
int mCharWidth;
|
||||||
QFont mFontDummy;
|
QFont mFontDummy;
|
||||||
QFont mFontForNonAscii;
|
QFont mFontForNonAscii;
|
||||||
|
@ -667,7 +680,7 @@ private:
|
||||||
bool mPainting;
|
bool mPainting;
|
||||||
PDocument mDocument;
|
PDocument mDocument;
|
||||||
int mLinesInWindow;
|
int mLinesInWindow;
|
||||||
int mLeftChar;
|
int mLeftPos;
|
||||||
int mPaintLock; // lock counter for internal calculations
|
int mPaintLock; // lock counter for internal calculations
|
||||||
bool mReadOnly;
|
bool mReadOnly;
|
||||||
int mRightEdge;
|
int mRightEdge;
|
||||||
|
|
Loading…
Reference in New Issue