* work save
This commit is contained in:
parent
38edefa59b
commit
f914994993
|
@ -32,6 +32,7 @@ SOURCES += \
|
|||
qsynedit/exporter/synexporter.cpp \
|
||||
qsynedit/exporter/synhtmlexporter.cpp \
|
||||
qsynedit/exporter/synrtfexporter.cpp \
|
||||
qsynedit/highlighter/asm.cpp \
|
||||
qsynedit/highlighter/base.cpp \
|
||||
qsynedit/highlighter/composition.cpp \
|
||||
qsynedit/highlighter/cpp.cpp \
|
||||
|
@ -53,6 +54,7 @@ SOURCES += \
|
|||
widgets/coloredit.cpp \
|
||||
widgets/consolewidget.cpp \
|
||||
widgets/issuestable.cpp \
|
||||
widgets/qconsole.cpp \
|
||||
widgets/qpatchedcombobox.cpp
|
||||
|
||||
HEADERS += \
|
||||
|
@ -79,6 +81,7 @@ HEADERS += \
|
|||
qsynedit/exporter/synexporter.h \
|
||||
qsynedit/exporter/synhtmlexporter.h \
|
||||
qsynedit/exporter/synrtfexporter.h \
|
||||
qsynedit/highlighter/asm.h \
|
||||
qsynedit/highlighter/base.h \
|
||||
qsynedit/highlighter/composition.h \
|
||||
qsynedit/highlighter/cpp.h \
|
||||
|
@ -101,6 +104,7 @@ HEADERS += \
|
|||
widgets/coloredit.h \
|
||||
widgets/consolewidget.h \
|
||||
widgets/issuestable.h \
|
||||
widgets/qconsole.h \
|
||||
widgets/qpatchedcombobox.h
|
||||
|
||||
FORMS += \
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
#include "asm.h"
|
||||
|
||||
const QSet<QString> SynEditASMHighlighter::Keywords {
|
||||
"aaa","aad","aam","adc","add","and","arpl","bound","bsf","bsr","bswap","bt","btc","btr","bts",
|
||||
"call","cbw","cdq","clc","cld","cli","clts","cmc","cmp","cmps","cmpsb","cmpsd","cmpsw",
|
||||
"cmpxchg","cwd","cwde","daa","das","dec","div","emms","enter","f2xm1","fabs","fadd","faddp","fbld",
|
||||
"fbstp","fchs","fclex","fcmovb","fcmovbe","fcmove","fcmovnb","fcmovnbe","fcmovne","fcmovnu",
|
||||
"fcmovu","fcom","fcomi","fcomip","fcomp","fcompp","fcos","fdecstp","fdiv","fdivp","fdivr",
|
||||
"fdivrp","femms","ffree","fiadd","ficom","ficomp","fidiv","fidivr","fild","fimul","fincstp",
|
||||
"finit","fist","fistp","fisub","fisubr","fld","fld1","fldcw","fldenv","fldl2e","fldl2t","fldlg2",
|
||||
"fldln2","fldpi","fldz","fmul","fmulp","fnclex","fninit","fnop","fnsave","fnstcw","fnstenv",
|
||||
"fnstsw","fpatan","fprem1","fptan","frndint","frstor","fsave","fscale","fsin","fsincos",
|
||||
"fsqrt","fst","fstcw","fstenv","fstp","fstsw","fsub","fsubp","fsubr","fsubrp","ftst",
|
||||
"fucom","fucomi","fucomip","fucomp","fucompp","fwait","fxch","fxtract","fyl2xp1","hlt","idiv",
|
||||
"imul","in","inc","ins","insb","insd","insw","int","into","invd","invlpg","iret","iretd","iretw",
|
||||
"ja","jae","jb","jbe","jc","jcxz","je","jecxz","jg","jge","jl","jle","jmp","jna","jnae","jnb","jnbe","jnc",
|
||||
"jne","jng","jnge","jnl","jnle","jno","jnp","jns","jnz","jo","jp","jpe","jpo","js","jz","lahf","lar","lds",
|
||||
"lea","leave","les","lfs","lgdt","lgs","lidt","lldt","lmsw","lock","lods","lodsb","lodsd","lodsw",
|
||||
"loop","loope","loopne","loopnz","loopz","lsl","lss","ltr","mov","movd","movq"," movs","movsb",
|
||||
"movsd","movsw","movsx","movzx","mul","neg","nop","not","or","out","outs","outsb","outsd","outsw",
|
||||
"packssdw","packsswb","packuswb","paddb","paddd","paddsb","paddsw","paddusb","paddusw",
|
||||
"paddw","pand","pandn","pavgusb","pcmpeqb","pcmpeqd","pcmpeqw","pcmpgtb","pcmpgtd","pcmpgtw",
|
||||
"pf2id","pfacc","pfadd","pfcmpeq","pfcmpge","pfcmpgt","pfmax","pfmin","pfmul","pfrcp",
|
||||
"pfrcpit1","pfrcpit2","pfrsqit1","pfrsqrt","pfsub","pfsubr","pi2fd","pmaddwd","pmulhrw",
|
||||
"pmulhw","pmullw","pop","popa","popad","popaw","popf","popfd","popfw","por","prefetch","prefetchw",
|
||||
"pslld","psllq","psllw","psrad","psraw","psrld","psrlq","psrlw","psubb","psubd","psubsb",
|
||||
"psubsw","psubusb","psubusw","psubw","punpckhbw","punpckhdq","punpckhwd","punpcklbw",
|
||||
"punpckldq","punpcklwd","push","pusha","pushad","pushaw","pushf","pushfd","pushfw","pxor",
|
||||
"rcl","rcr","rep","repe","repne","repnz","repz","ret","rol","ror","sahf","sal","sar","sbb","scas",
|
||||
"scasb","scasd","scasw","seta","setae","setb","setbe","setc","sete","setg","setge","setl","setle",
|
||||
"setna","setnae","setnb","setnbe","setnc","setne","setng","setnge","setnl","setnle","setno",
|
||||
"setnp","setns","setnz","seto","setp","setpo","sets","setz","sgdt","shl","shld","shr","shrd","sidt",
|
||||
"sldt","smsw","stc","std","sti","stos","stosb","stosd","stosw","str","sub","test","verr","verw",
|
||||
"wait","wbinvd","xadd","xchg","xlat","xlatb","xor"
|
||||
};
|
||||
|
||||
SynEditASMHighlighter::SynEditASMHighlighter()
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef SYNEDITASMHIGHLIGHTER_H
|
||||
#define SYNEDITASMHIGHLIGHTER_H
|
||||
|
||||
#include "base.h"
|
||||
|
||||
|
||||
class SynEditASMHighlighter : public SynHighlighter
|
||||
{
|
||||
enum TokenKind {
|
||||
Comment,
|
||||
Identifier,
|
||||
Key,
|
||||
Null,
|
||||
Number,
|
||||
Space,
|
||||
String,
|
||||
Symbol,
|
||||
Unknown
|
||||
};
|
||||
public:
|
||||
SynEditASMHighlighter();
|
||||
|
||||
static const QSet<QString> Keywords;
|
||||
private:
|
||||
QChar* mLine;
|
||||
int mLineNumber;
|
||||
int mRun;
|
||||
int mStringLen;
|
||||
QChar mToIdent;
|
||||
int mTokenPos;
|
||||
SynTokenKind mTokenID;
|
||||
SynHighlighterAttribute mCommentAttri;
|
||||
SynHighlighterAttribute mIdentifierAttri;
|
||||
SynHighlighterAttribute mKeyAttri;
|
||||
SynHighlighterAttribute mNumberAttri;
|
||||
SynHighlighterAttribute mSpaceAttri;
|
||||
SynHighlighterAttribute mStringAttri;
|
||||
SynHighlighterAttribute mSymbolAttri;
|
||||
};
|
||||
|
||||
#endif // SYNEDITASMHIGHLIGHTER_H
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,217 @@
|
|||
#ifndef QCONSOLE_H
|
||||
#define QCONSOLE_H
|
||||
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QVector>
|
||||
|
||||
struct ConsoleLine {
|
||||
QString text;
|
||||
QStringList fragments;
|
||||
int maxColumns;
|
||||
};
|
||||
|
||||
enum class ConsoleCaretType {
|
||||
ctVerticalLine,ctHorizontalLine,ctBlock,ctHalfBlock
|
||||
};
|
||||
|
||||
using PConsoleLine = std::shared_ptr<ConsoleLine>;
|
||||
|
||||
using ConsoleLineList = QVector<PConsoleLine>;
|
||||
|
||||
/**
|
||||
* @brief The RowColumn struct
|
||||
* column and row are 0-based
|
||||
*/
|
||||
struct RowColumn {
|
||||
int column;
|
||||
int row;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The LineChar struct
|
||||
* line and ch are 0-based
|
||||
*/
|
||||
struct LineChar {
|
||||
int ch;
|
||||
int line;
|
||||
};
|
||||
|
||||
class QConsole;
|
||||
class ConsoleLines : public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConsoleLines(QConsole* console);
|
||||
void addLine(const QString& line);
|
||||
void RemoveLastLine();
|
||||
void changeLastLine(const QString& newLine);
|
||||
QString getLastLine();
|
||||
QString getLine(int line);
|
||||
QChar getChar(int line,int ch);
|
||||
QChar getChar(const LineChar& lineChar);
|
||||
/**
|
||||
* @brief getRows
|
||||
* @param startRow 1-based
|
||||
* @param endRow 1-based
|
||||
* @return
|
||||
*/
|
||||
QStringList getRows(int startRow, int endRow);
|
||||
|
||||
LineChar rowColumnToLineChar(const RowColumn& rowColumn);
|
||||
LineChar rowColumnToLineChar(int row ,int column);
|
||||
RowColumn lineCharToRowColumn(const LineChar& lineChar);
|
||||
RowColumn lineCharToRowColumn(int line, int ch);
|
||||
int rows() const;
|
||||
int lines() const;
|
||||
bool layouting() const;
|
||||
int maxLines() const;
|
||||
void setMaxLines(int maxLines);
|
||||
|
||||
int getMaxLines() const;
|
||||
public slots:
|
||||
void layout();
|
||||
signals:
|
||||
void layoutStarted();
|
||||
void layoutFinished();
|
||||
void needRelayout();
|
||||
void rowsAdded(int rowCount);
|
||||
void lastRowsRemoved(int rowCount);
|
||||
void lastRowsChanged(int rowCount);
|
||||
private:
|
||||
int breakLine(const QString& line, QStringList& fragments);
|
||||
private:
|
||||
ConsoleLineList mLines;
|
||||
int mRows;
|
||||
bool mLayouting;
|
||||
bool mNeedRelayout;
|
||||
int mOldTabSize;
|
||||
QConsole* mConsole;
|
||||
int mMaxLines;
|
||||
};
|
||||
|
||||
|
||||
class QConsole : public QAbstractScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QConsole(QWidget* parent = nullptr);
|
||||
int historySize() const;
|
||||
void setHistorySize(int historySize);
|
||||
|
||||
int tabSize() const;
|
||||
|
||||
int columnsPerRow() const;
|
||||
|
||||
int rowsInWindow() const;
|
||||
int charColumns(QChar ch, int columnsBefore) const;
|
||||
|
||||
void invalidate();
|
||||
void invalidateRows(int startRow,int endRow);
|
||||
void invalidateRect(const QRect& rect);
|
||||
|
||||
void addLine(const QString& line);
|
||||
void removeLastLine();
|
||||
void changeLastLine(const QString& line);
|
||||
QString getLastLine();
|
||||
|
||||
signals:
|
||||
void commandInput(const QString& command);
|
||||
private:
|
||||
ConsoleLines mContents;
|
||||
QStringList mCommandHistory;
|
||||
int mHistorySize;
|
||||
int mHistoryIndex;
|
||||
QString mCommand;
|
||||
QString mCurrentEditableLine;
|
||||
// bool mIndex;
|
||||
int mRowHeight;
|
||||
int mTopRow; // 1-based
|
||||
int mRowsInWindow;
|
||||
int mColumnsPerRow;
|
||||
int mColumnWidth;
|
||||
bool mReadonly;
|
||||
LineChar mSelectionBegin;
|
||||
LineChar mSelectionEnd;
|
||||
int mCaretChar;
|
||||
QColor mBackground;
|
||||
QColor mForeground;
|
||||
QColor mSelectionBackground;
|
||||
QColor mSelectionForeground;
|
||||
QColor mInactiveSelectionBackground;
|
||||
QColor mInactiveSelectionForeground;
|
||||
int mTabSize;
|
||||
std::shared_ptr<QImage> mContentImage;
|
||||
int mBlinkTimerId;
|
||||
int mBlinkStatus;
|
||||
QTimer* mScrollTimer;
|
||||
int mScrollDeltaY;
|
||||
private:
|
||||
void fontChanged();
|
||||
void recalcCharExtent();
|
||||
void sizeOrFontChanged(bool bFont);
|
||||
int clientWidth();
|
||||
int clientHeight();
|
||||
/**
|
||||
* @brief setTopRow
|
||||
* @param value 1-based
|
||||
*/
|
||||
void setTopRow(int value);
|
||||
int maxScrollHeight();
|
||||
void updateScrollbars();
|
||||
void paintRows(QPainter& painter, int row1,int row2);
|
||||
void ensureCaretVisible();
|
||||
void showCaret();
|
||||
void hideCaret();
|
||||
void updateCaret();
|
||||
LineChar caretPos();
|
||||
RowColumn caretRowColumn();
|
||||
QPoint rowColumnToPixels(const RowColumn& rowColumn);
|
||||
QRect getCaretRect();
|
||||
void paintCaret(QPainter &painter, const QRect rcClip);
|
||||
void textInputed(const QString& text);
|
||||
void loadCommandFromHistory();
|
||||
LineChar selectionBegin();
|
||||
LineChar selectionEnd();
|
||||
void setCaretChar(int newCaretChar, bool resetSelection);
|
||||
bool caretInSelection();
|
||||
QString removeSelection();
|
||||
bool hasSelection();
|
||||
int computeScrollY(int Y);
|
||||
RowColumn pixelsToNearestRowColumn(int x,int y);
|
||||
|
||||
|
||||
private slots:
|
||||
void doScrolled();
|
||||
void contentsLayouted();
|
||||
void contentsRowsAdded(int rowCount);
|
||||
void contentsLastRowsRemoved(int rowCount);
|
||||
void contentsLastRowsChanged(int rowCount);
|
||||
void scrollTimerHandler();
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void focusInEvent(QFocusEvent *event) override;
|
||||
void focusOutEvent(QFocusEvent *event) override;
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
bool event(QEvent *event) override;
|
||||
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
// QObject interface
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void inputMethodEvent(QInputMethodEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
};
|
||||
|
||||
|
||||
#endif // QCONSOLE_H
|
Loading…
Reference in New Issue