📄 textarea.h
字号:
/*************************************************************************** * Copyright (C) 2007 by Motorola Commnunity around the World * * lahu3672@googlemail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/#ifndef TEXTAREA_H#define TEXTAREA_H#include <qobject.h>#include <qframe.h>#include <qcstring.h>#include <qpen.h>#include <qstringlist.h>#include <qthread.h>#include <qpainter.h>#include <qfontmanager_qws.h>#include <qfontdatabase.h>#include <qdir.h>#include <qdict.h>#include <sys/ioctl.h>#define ANSI_ATTR_BOLD 0x1#define ANSI_ATTR_UNDERLINED 0x2#define ANSI_ATTR_BLINK 0x4#define ANSI_ATTR_INVERSE 0x8#define ANSI_ATTR_INVISIBLE 0x10#define ANSI_CHANGED_ATTRS 0x1#define ANSI_CHANGED_POSITION 0x2#define ESC_CHAR 0x1b#define TAB_SIZE 8typedef struct { QPen pen; QColor bgColor; QColor textBgColor; uchar attrs;} text_attrs;typedef struct { ulong hash; text_attrs *attrs;} attrs_applier;class TextArea: public QFrame{ Q_OBJECTpublic: TextArea(QWidget *parent = 0, const char *name = 0); ~TextArea(); void back(); void newline(); void appendChar(const QChar &ch); void appendText(const QByteArray &text, uint offset = 0, bool new_call = true); void scroll(int delta = 2); void home(); void getSize(struct winsize *ws);protected: virtual void drawContents(QPainter *painter); virtual void resizeEvent(QResizeEvent *event);signals: void configured();private: enum EraseType {EraseAll = 0, EraseToCurrent, EraseToEnd}; uint drawText(QPixmap *pix, const QPoint &where, const QString &s); void showLine(QPixmap *pix, const QPoint &where, uint width, QPaintDevice *dev = 0); void renderText(int row, const QPoint &where, const QString &s); void renderChar(uint r, uint c); void renderLine(uint r, uint s, uint e, const QPoint &wh); void pushLine(); QPoint lineCoord(const QPoint &c); void moveChars(uint r, uint from, uint cnt, uint to); void eraseLine(uint row, EraseType type, const QPoint &crd); void eraseLines(uint from, uint to); void erase(const QRect &rect, QPaintDevice *p = 0); QStringList ansiParseArgs(); void ansiSetAttrs(); void ansiGo(uint direction); void ansiEraseLine(); void ansiEraseChars(); void ansiInsertChars(); void ansiEraseScreen(); void ansiSetMode(); void ansiResetMode(); void ansiProcess(char ch); int insertChar(char ch); int getX(); int getY(); int getX(uint r, uint c); int getY(uint r, uint c); void tab(); bool newlineShift(); void showTextBlock(uint from, uint to, uint diff); void go(uint r, uint c); uint xsize; uint ysize; uint row, col, topRow, fakeTopRow; QPoint crd, stcrd; QList<QPixmap> lines; QFont font, defFont; QFontMetrics *metrics; bool focus; QPen defPen; text_attrs defAttrs, curAttrs, newAttrs; QMutex mutex; typedef enum {ESEQ_NONE=0, ESEQ_ESC, ESEQ_ANSI_STARTED, ESEQ_ANSI_DONE, ESEQ_STUB, ESEQ_STUB2} eseq_state; enum {DIR_UP, DIR_DOWN, DIR_FORWARD, DIR_BACKWARD, DIR_ABSOLUTE}; eseq_state eseq; QString esc_seq; ulong ansiChanges; uint newRow, newCol; QPoint newCrd; bool canDraw; bool insertMode;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -