📄 mimerichtextp.h
字号:
TextStateC state; union { StringC *text; RichGraphicC *graphic; }; Boolean IsText() { return (type == RC_TEXT); } Boolean IsGraphic() { return (type == RC_GRAPHIC); } int LastPos() { return (type == RC_TEXT ? text->size() : 1); } RichCmdC(RichCmdTypeT t) { type = t; if ( IsText() ) text = new StringC; else graphic = NULL; } ~RichCmdC() { if ( IsText() ) delete text; else if ( graphic && graphic->okToDelete ) delete graphic; }};/*---------------------------------------------------------------------- * Rich/Enriched unformatted line data as defined by the user. TextLines * are defined by newlines in the input. */class TextLineC {public: PtrListC cmdList; // List of strings and state changes SoftLineC *softLine; // wrapped lines for this line RectC bounds; // Combination of all soft lines int index; TextLineC *prev; TextLineC *next; TextLineC(); ~TextLineC(); void AddCommand(const RichCmdC*, int pos=NULL_CMD_POS); void AddCommand(const RichCmdC*, const RichCmdC*); void AddCommand(const TextStateC*, const StringC*, int pos=NULL_CMD_POS); void AddSoftLine(SoftLineC*); inline RichCmdC *Cmd(int i) { return ((i>=0 && i<cmdList.size()) ? (RichCmdC*)*cmdList[i] : (RichCmdC*)NULL); } inline RichCmdC *CurCmd() { return Cmd(cmdList.size()-1); } inline TextStateC *State(int i) { RichCmdC *cmd = Cmd(i); return (cmd ? &cmd->state : (TextStateC*)NULL); } inline StringC *Text(int i) { RichCmdC *cmd = Cmd(i); return (cmd && cmd->IsText() ? cmd->text : (StringC*)NULL); } inline RichGraphicC *Graphic(int i) { RichCmdC *cmd = Cmd(i); return (cmd && cmd->IsGraphic() ? cmd->graphic : (RichGraphicC*)NULL); } inline void DeleteCmd(int i) { RichCmdC *cmd = Cmd(i); if ( cmd ) { delete cmd; cmdList.remove(i); } } inline SoftLineC *FirstSoft() { return softLine; } inline SoftLineC *LastSoft() { SoftLineC *line = softLine; SoftLineC *last = softLine; while ( line && line->textLine == this ) { line = line->next; if ( line && line->textLine == this ) last = line; } return last; } Boolean IsBlank(); void RemoveExcerpt();//// comparison// inline int compare(const TextLineC&) const { return 0; } inline int operator<(const TextLineC&) const { return 0; } inline int operator>(const TextLineC&) const { return 0; } inline int operator==(const TextLineC&) const { return 1; } inline int operator!=(const TextLineC&) const { return 0; }};/*---------------------------------------------------------------------- * Class to hold information about a text location */class ScreenPosC;class TextPosC {public: TextLineC *textLine; int cmdPos; int strPos; TextPosC(); TextPosC(TextLineC*, int, int); TextPosC(const ScreenPosC&); RichCmdC *Cmd() const { return textLine ? textLine->Cmd(cmdPos) : (RichCmdC*)NULL; } TextStateC *State() const { return textLine ? textLine->State(cmdPos) : (TextStateC*)NULL; } void Set(TextLineC*, int, int); TextPosC& operator=(const TextPosC&); TextPosC& operator=(const ScreenPosC&); int operator==(const TextPosC&) const; int operator<(const TextPosC&) const; int operator>(const TextPosC&) const; inline int operator!=(const TextPosC& tp) const { return !(*this == tp); } inline int operator<=(const TextPosC& tp) const { return !(*this > tp); } inline int operator>=(const TextPosC& tp) const { return !(*this < tp); }};/*---------------------------------------------------------------------- * Class to hold information about a screen location */class ScreenPosC {public: SoftLineC *softLine; RichDrawDataC *data; int charPos; // Position within data string int x; // Position on screen ScreenPosC(); ScreenPosC(SoftLineC*, int); ScreenPosC(const TextPosC&); void Set(SoftLineC*, int x); void Set(SoftLineC*, RichDrawDataC*, int pos); ScreenPosC& operator=(const ScreenPosC&); ScreenPosC& operator=(const TextPosC&); int operator==(const ScreenPosC&) const; int operator<(const ScreenPosC&) const; int operator>(const ScreenPosC&) const; inline int operator!=(const ScreenPosC& sp) const { return !(*this == sp); } inline int operator<=(const ScreenPosC& sp) const { return !(*this > sp); } inline int operator>=(const ScreenPosC& sp) const { return !(*this < sp); } void Snap();};/*---------------------------------------------------------------------- * Rich/Enriched text drawing class */class CharC;class MimeRichTextP { friend class MimeRichTextC; friend class RichSearchWinC; friend class RichGraphicC; MimeRichTextC *pub; Widget textSW; // Scrolled window parent Widget textClip; // Scrolled window clip window Widget scrollForm; // Parent if no scrolled window Widget hlForm; // Highlight Widget textFrame; // Scrollbars Widget textVSB; // Scrollbars Widget textHSB; // Scrollbars Widget textDA; // Drawing area//// Data for scrolling// int hsbVal; // Position of horizontal scroll bar int vsbVal; // Position of vertical scroll bar int hsbMax; // horizontal scroll bar max - slider int vsbMax; // vertical scroll bar max - slider Boolean hsbOn; // True if scrolling enabled Boolean vsbOn; // True if scrolling enabled Boolean hsbAlwaysOn; // User setting Boolean vsbAlwaysOn; // User setting int scrollRoff; // Offset used if scrolling int scrollBoff; // Offset used if scrolling int noScrollRoff; // Offset used if not scrolling int noScrollBoff; // Offset used if not scrolling Pixmap textPm; u_int textPmWd; u_int textPmHt;//// Input parser variables// RichCmdC *inputCmd; // Current input state and text TextLineC *inputLine; // Current line being filled StringC inputTextBuf; // Working text buffer Boolean inputLastWhite; // True if last character was whitespace StringC excerptStr; // Prefix used for excerpts int excerptWd; // Size of excerpt string TextPosC lastDelPos; // Start position of deleted text SoftLineC *topSoftLine; // Pointers to soft line lists SoftLineC *botSoftLine; TextLineC *topTextLine; // Pointers to text line lists TextLineC *botTextLine; TextLineC *topSaveLine; // Pointers to saved line lists TextLineC *botSaveLine; u_int maxLength;//// Drawing variables// Boolean realized; Window textWin; GC textGC; Pixel fgColor; Pixel bgColor; Pixel urlColor; Pixel linkColor; Pixel cursorColor; Pixmap stipplePm; Dimension marginWd, marginHt; Dimension marginWd2, marginHt2; Dimension clipWd, clipHt; // Size of clip win (if in scroll win) Dimension initWd, initHt; // Initial size of drawing area Dimension drawWd, drawHt; // Current size of drawing area Dimension maxWd, maxHt; // Max size of drawing area int textWd, textHt; // Size of text data int textX, textY; Dimension indentWd; int hlThick; Pixel hlColor; Pixel hlFormBg; char lineSpacing; Boolean resizeWidth; Boolean editable; Boolean hasFocus; char defer; Boolean changed; TextTypeT textType; char tabStop; Boolean checkFroms; Boolean singleLine; Boolean tabTraverses; // If True, TAB causes traversal and // Ctrl-TAB inserts tab. If False, // vice-versa. Boolean forceFixed; // Always use fixed font PtrListC graphicList; // List of graphic objects for quick // picking//// Cursor data// TextPosC cursorPos; TextPosC lastCursorPos; // Saved in HideCur, checked in ShowCur int desiredCursorX; Boolean cursorOn; int cursorHideCount; int cursorOnTime; int cursorOffTime; XtIntervalId cursorTimer; CallbackListC stateCalls; // When state under cursor changes TextStateC lastCursorState;//// Selection data// int clickCount; XtIntervalId clickTimer; Widget clickWidget; XButtonEvent clickEvent; Boolean timerOk; Boolean mousePaste; TextPosC selectBegPos; TextPosC selectEndPos; Boolean selectOn; Time selectTime;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -