work save
This commit is contained in:
parent
1420dfb32b
commit
83bc63f14e
|
@ -234,7 +234,7 @@ void MainWindow::on_actionSelectAll_triggered()
|
||||||
{
|
{
|
||||||
Editor * editor = mEditorList->getEditor();
|
Editor * editor = mEditorList->getEditor();
|
||||||
if (editor != NULL ) {
|
if (editor != NULL ) {
|
||||||
//editor->selectAll();
|
editor->SelectAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
int MinMax(int x, int mi, int ma)
|
int MinMax(int x, int mi, int ma)
|
||||||
{
|
{
|
||||||
|
@ -540,3 +541,53 @@ SynFontStyles getFontStyles(const QFont &font)
|
||||||
styles.setFlag(SynFontStyle::fsUnderline, font.underline());
|
styles.setFlag(SynFontStyle::fsUnderline, font.underline());
|
||||||
styles.setFlag(SynFontStyle::fsStrikeOut, font.strikeOut());
|
styles.setFlag(SynFontStyle::fsStrikeOut, font.strikeOut());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isWordChar(const QChar& ch) {
|
||||||
|
return (ch == '_') || ch.isLetterOrNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
int StrScanForWordChar(const QString &s, int startPos)
|
||||||
|
{
|
||||||
|
for (int i=startPos-1;i<s.length();i++) {
|
||||||
|
if (isWordChar(s[i])) {
|
||||||
|
return i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int StrScanForNonWordChar(const QString &s, int startPos)
|
||||||
|
{
|
||||||
|
for (int i=startPos-1;i<s.length();i++) {
|
||||||
|
if (!isWordChar(s[i])) {
|
||||||
|
return i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int StrRScanForWordChar(const QString &s, int startPos)
|
||||||
|
{
|
||||||
|
int i = startPos-1;
|
||||||
|
if (i>s.length())
|
||||||
|
return 0;
|
||||||
|
while (i>=0) {
|
||||||
|
if (isWordChar(s[i]))
|
||||||
|
return i+1;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int StrRScanForNonWordChar(const QString &s, int startPos)
|
||||||
|
{
|
||||||
|
int i = startPos-1;
|
||||||
|
if (i>s.length())
|
||||||
|
return 0;
|
||||||
|
while (i>=0) {
|
||||||
|
if (!isWordChar(s[i]))
|
||||||
|
return i+1;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -89,4 +89,32 @@ void SynDrawGradient(QPaintDevice* ACanvas, const QColor& AStartColor, const QCo
|
||||||
|
|
||||||
SynFontStyles getFontStyles(const QFont& font);
|
SynFontStyles getFontStyles(const QFont& font);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first occurency of word char in s, starting from startPos
|
||||||
|
* Note: the index of first char in s in 1
|
||||||
|
* @return index of the char founded , 0 if not found
|
||||||
|
*/
|
||||||
|
int StrScanForWordChar(const QString& s, int startPos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first occurency of non word char in s, starting from startPos
|
||||||
|
* Note: the index of first char in s in 1
|
||||||
|
* @return index of the char founded , 0 if not found
|
||||||
|
*/
|
||||||
|
int StrScanForNonWordChar(const QString& s, int startPos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first occurency of word char in s right to left, starting from startPos
|
||||||
|
* Note: the index of first char in s in 1
|
||||||
|
* @return index of the char founded , 0 if not found
|
||||||
|
*/
|
||||||
|
int StrRScanForWordChar(const QString& s, int startPos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first occurency of non word char in s right to left, starting from startPos
|
||||||
|
* Note: the index of first char in s in 1
|
||||||
|
* @return index of the char founded , 0 if not found
|
||||||
|
*/
|
||||||
|
int StrRScanForNonWordChar(const QString& s, int startPos);
|
||||||
|
|
||||||
#endif // MISCPROCS_H
|
#endif // MISCPROCS_H
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,7 +91,8 @@ enum SynEditorOption {
|
||||||
eoTabIndent = 0x02000000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
|
eoTabIndent = 0x02000000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
|
||||||
eoTabsToSpaces = 0x04000000, //Converts a tab character to a specified number of space characters
|
eoTabsToSpaces = 0x04000000, //Converts a tab character to a specified number of space characters
|
||||||
eoShowRainbowColor = 0x08000000,
|
eoShowRainbowColor = 0x08000000,
|
||||||
eoTrimTrailingSpaces = 0x10000000 //Spaces at the end of lines will be trimmed and not saved
|
eoTrimTrailingSpaces = 0x10000000, //Spaces at the end of lines will be trimmed and not saved
|
||||||
|
eoSelectWordByDblClick = 0x20000000
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_FLAGS(SynEditorOptions, SynEditorOption)
|
Q_DECLARE_FLAGS(SynEditorOptions, SynEditorOption)
|
||||||
|
@ -172,7 +173,9 @@ public:
|
||||||
QPoint RowColumnToPixels(const DisplayCoord& coord);
|
QPoint RowColumnToPixels(const DisplayCoord& coord);
|
||||||
DisplayCoord bufferToDisplayPos(const BufferCoord& p);
|
DisplayCoord bufferToDisplayPos(const BufferCoord& p);
|
||||||
BufferCoord displayToBufferPos(const DisplayCoord& p);
|
BufferCoord displayToBufferPos(const DisplayCoord& p);
|
||||||
|
int leftSpaces(const QString& line);
|
||||||
int charToColumn(int aLine, int aChar);
|
int charToColumn(int aLine, int aChar);
|
||||||
|
int columnToChar(int aLine, int aColumn);
|
||||||
int stringColumns(const QString& line, int colsBefore);
|
int stringColumns(const QString& line, int colsBefore);
|
||||||
int getLineIndent(const QString& line);
|
int getLineIndent(const QString& line);
|
||||||
int rowToLine(int aRow);
|
int rowToLine(int aRow);
|
||||||
|
@ -197,6 +200,20 @@ public:
|
||||||
void showCaret();
|
void showCaret();
|
||||||
void hideCaret();
|
void hideCaret();
|
||||||
bool IsPointInSelection(const BufferCoord& Value);
|
bool IsPointInSelection(const BufferCoord& Value);
|
||||||
|
BufferCoord NextWordPos();
|
||||||
|
BufferCoord NextWordPosEx(const BufferCoord& XY);
|
||||||
|
BufferCoord WordStart();
|
||||||
|
BufferCoord WordStartEx(const BufferCoord& XY);
|
||||||
|
BufferCoord WordEnd();
|
||||||
|
BufferCoord WordEndEx(const BufferCoord& XY);
|
||||||
|
BufferCoord PrevWordPos();
|
||||||
|
BufferCoord PrevWordPosEx(const BufferCoord& XY);
|
||||||
|
void SetSelWord();
|
||||||
|
void SetWordBlock(BufferCoord Value);
|
||||||
|
|
||||||
|
//Commands
|
||||||
|
void SelectAll();
|
||||||
|
void DeleteLastChar();
|
||||||
|
|
||||||
// setter && getters
|
// setter && getters
|
||||||
int topLine() const;
|
int topLine() const;
|
||||||
|
@ -246,6 +263,10 @@ public:
|
||||||
SynSelectionMode selectionMode() const;
|
SynSelectionMode selectionMode() const;
|
||||||
void setSelectionMode(SynSelectionMode value);
|
void setSelectionMode(SynSelectionMode value);
|
||||||
|
|
||||||
|
QString selText();
|
||||||
|
|
||||||
|
QString lineBreak();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void Changed();
|
void Changed();
|
||||||
|
|
||||||
|
@ -306,6 +327,8 @@ private:
|
||||||
void scrollWindow(int dx,int dy);
|
void scrollWindow(int dx,int dy);
|
||||||
void setInternalDisplayXY(const DisplayCoord& aPos);
|
void setInternalDisplayXY(const DisplayCoord& aPos);
|
||||||
void internalSetCaretXY(const BufferCoord& Value);
|
void internalSetCaretXY(const BufferCoord& Value);
|
||||||
|
void internalSetCaretX(int Value);
|
||||||
|
void internalSetCaretY(int Value);
|
||||||
void setStatusChanged(SynStatusChanges changes);
|
void setStatusChanged(SynStatusChanges changes);
|
||||||
void doOnStatusChange(SynStatusChanges changes);
|
void doOnStatusChange(SynStatusChanges changes);
|
||||||
void insertBlock(const BufferCoord& BB, const BufferCoord& BE, const QString& ChangeStr,
|
void insertBlock(const BufferCoord& BB, const BufferCoord& BE, const QString& ChangeStr,
|
||||||
|
@ -352,6 +375,14 @@ private:
|
||||||
bool isSelection);
|
bool isSelection);
|
||||||
void MoveCaretToLineStart(bool isSelection);
|
void MoveCaretToLineStart(bool isSelection);
|
||||||
void MoveCaretToLineEnd(bool isSelection);
|
void MoveCaretToLineEnd(bool isSelection);
|
||||||
|
void SetSelectedTextEmpty();
|
||||||
|
void SetSelTextPrimitive(const QString& aValue);
|
||||||
|
void SetSelTextPrimitiveEx(SynSelectionMode PasteMode,
|
||||||
|
const QString& Value, bool AddToUndoList);
|
||||||
|
void DoLinesDeleted(int FirstLine, int Count);
|
||||||
|
void ProperSetLine(int ALine, const QString& ALineText);
|
||||||
|
void DeleteSelection(const BufferCoord& BB, const BufferCoord& BE);
|
||||||
|
void InsertText(const QString& Value, SynSelectionMode PasteMode);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void bookMarkOptionsChanged();
|
void bookMarkOptionsChanged();
|
||||||
|
@ -415,8 +446,7 @@ private:
|
||||||
PSynEditUndoList mUndoList;
|
PSynEditUndoList mUndoList;
|
||||||
PSynEditUndoList mRedoList;
|
PSynEditUndoList mRedoList;
|
||||||
SynEditMarkList mBookMarks;
|
SynEditMarkList mBookMarks;
|
||||||
int mMouseDownX;
|
QPoint mMouseDownPos;
|
||||||
int mMouseDownY;
|
|
||||||
SynBookMarkOpt mBookMarkOpt;
|
SynBookMarkOpt mBookMarkOpt;
|
||||||
bool mHideSelection;
|
bool mHideSelection;
|
||||||
int mMouseWheelAccumulator;
|
int mMouseWheelAccumulator;
|
||||||
|
@ -476,9 +506,6 @@ private:
|
||||||
int m_blinkTimerId;
|
int m_blinkTimerId;
|
||||||
int m_blinkStatus;
|
int m_blinkStatus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
friend class SynEditTextPainter;
|
friend class SynEditTextPainter;
|
||||||
|
|
||||||
// QWidget interface
|
// QWidget interface
|
||||||
|
@ -491,6 +518,9 @@ void focusInEvent(QFocusEvent *event) override;
|
||||||
void focusOutEvent(QFocusEvent *event) override;
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SYNEDIT_H
|
#endif // SYNEDIT_H
|
||||||
|
|
|
@ -90,6 +90,18 @@ int SynEditStringList::lengthOfLongestLine()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SynEditStringList::lineBreak()
|
||||||
|
{
|
||||||
|
switch(mFileEndingType) {
|
||||||
|
case FileEndingType::Linux:
|
||||||
|
return "\n";
|
||||||
|
case FileEndingType::Windows:
|
||||||
|
return "\r\n";
|
||||||
|
case FileEndingType::Mac:
|
||||||
|
return "\r";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SynRangeState SynEditStringList::ranges(int Index)
|
SynRangeState SynEditStringList::ranges(int Index)
|
||||||
{
|
{
|
||||||
if (Index>=0 && Index < mList.size()) {
|
if (Index>=0 && Index < mList.size()) {
|
||||||
|
@ -340,14 +352,7 @@ QString SynEditStringList::GetTextStr()
|
||||||
QString Result;
|
QString Result;
|
||||||
for (PSynEditStringRec& line:mList) {
|
for (PSynEditStringRec& line:mList) {
|
||||||
Result.append(line->fString);
|
Result.append(line->fString);
|
||||||
switch(mFileEndingType) {
|
Result.append(lineBreak());
|
||||||
case FileEndingType::Linux:
|
|
||||||
Result.append('\n');
|
|
||||||
case FileEndingType::Windows:
|
|
||||||
Result.append("\r\n");
|
|
||||||
case FileEndingType::Mac:
|
|
||||||
Result.append("\r");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
@ -489,14 +494,14 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
|
||||||
allAscii = isTextAllAscii(line);
|
allAscii = isTextAllAscii(line);
|
||||||
}
|
}
|
||||||
if (allAscii) {
|
if (allAscii) {
|
||||||
addItem(removeLineEnds(QString::fromLatin1(line)));
|
addItem(TrimRight(QString::fromLatin1(line)));
|
||||||
} else {
|
} else {
|
||||||
QString newLine = codec->toUnicode(line.constData(),line.length(),&state);
|
QString newLine = codec->toUnicode(line.constData(),line.length(),&state);
|
||||||
if (state.invalidChars>0) {
|
if (state.invalidChars>0) {
|
||||||
needReread = true;
|
needReread = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
addItem(removeLineEnds(newLine));
|
addItem(TrimRight(newLine));
|
||||||
}
|
}
|
||||||
if (file.atEnd()){
|
if (file.atEnd()){
|
||||||
break;
|
break;
|
||||||
|
@ -528,7 +533,7 @@ void SynEditStringList::LoadFromFile(QFile &file, const QByteArray& encoding, QB
|
||||||
QString line;
|
QString line;
|
||||||
clear();
|
clear();
|
||||||
while (textStream.readLineInto(&line)) {
|
while (textStream.readLineInto(&line)) {
|
||||||
addItem(removeLineEnds(line));
|
addItem(TrimRight(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
int braceLevels(int Index);
|
int braceLevels(int Index);
|
||||||
int lineColumns(int Index);
|
int lineColumns(int Index);
|
||||||
int lengthOfLongestLine();
|
int lengthOfLongestLine();
|
||||||
|
QString lineBreak();
|
||||||
SynRangeState ranges(int Index);
|
SynRangeState ranges(int Index);
|
||||||
void setRange(int Index, SynRangeState ARange);
|
void setRange(int Index, SynRangeState ARange);
|
||||||
void setParenthesisLevel(int Index, int level);
|
void setParenthesisLevel(int Index, int level);
|
||||||
|
|
|
@ -364,7 +364,7 @@ void inflateRect(QRect &rect, int dx, int dy)
|
||||||
rect.setBottom(rect.bottom()+dy);
|
rect.setBottom(rect.bottom()+dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString removeLineEnds(const QString &s)
|
QString TrimRight(const QString &s)
|
||||||
{
|
{
|
||||||
if (s.isEmpty())
|
if (s.isEmpty())
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -75,27 +75,21 @@ QString getCompiledExecutableName(const QString filename);
|
||||||
void splitStringArguments(const QString& arguments, QStringList& argumentList);
|
void splitStringArguments(const QString& arguments, QStringList& argumentList);
|
||||||
bool programHasConsole(const QString& filename);
|
bool programHasConsole(const QString& filename);
|
||||||
QString toLocalPath(const QString& filename);
|
QString toLocalPath(const QString& filename);
|
||||||
|
|
||||||
using LineProcessFunc = std::function<void(const QString&)>;
|
using LineProcessFunc = std::function<void(const QString&)>;
|
||||||
|
|
||||||
QStringList ReadStreamToLines(QTextStream* stream);
|
QStringList ReadStreamToLines(QTextStream* stream);
|
||||||
|
|
||||||
void ReadStreamToLines(QTextStream* stream, LineProcessFunc lineFunc);
|
void ReadStreamToLines(QTextStream* stream, LineProcessFunc lineFunc);
|
||||||
|
|
||||||
|
|
||||||
QStringList TextToLines(const QString& text);
|
QStringList TextToLines(const QString& text);
|
||||||
|
|
||||||
void TextToLines(const QString& text, LineProcessFunc lineFunc);
|
void TextToLines(const QString& text, LineProcessFunc lineFunc);
|
||||||
|
|
||||||
QStringList ReadFileToLines(const QString& fileName, QTextCodec* codec);
|
QStringList ReadFileToLines(const QString& fileName, QTextCodec* codec);
|
||||||
|
|
||||||
void ReadFileToLines(const QString& fileName, QTextCodec* codec, LineProcessFunc lineFunc);
|
void ReadFileToLines(const QString& fileName, QTextCodec* codec, LineProcessFunc lineFunc);
|
||||||
|
|
||||||
void decodeKey(int combinedKey, int& key, Qt::KeyboardModifiers& modifiers);
|
void decodeKey(int combinedKey, int& key, Qt::KeyboardModifiers& modifiers);
|
||||||
|
|
||||||
void inflateRect(QRect& rect, int delta);
|
void inflateRect(QRect& rect, int delta);
|
||||||
void inflateRect(QRect& rect, int dx, int dy);
|
void inflateRect(QRect& rect, int dx, int dy);
|
||||||
QString removeLineEnds(const QString& s);
|
QString TrimRight(const QString& s);
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
class final_action
|
class final_action
|
||||||
|
|
Loading…
Reference in New Issue