📄 mimerichtextinit.c
字号:
} // End constructor/*---------------------------------------------------------------------- * Destructor */MimeRichTextC::~MimeRichTextC(){ if ( halApp->xRunning ) { if ( priv->cursorTimer ) XtRemoveTimeOut(priv->cursorTimer); XtReleaseGC(priv->textDA, priv->textGC); if ( priv->textPm ) XFreePixmap(halApp->display, priv->textPm); if ( priv->stipplePm ) XFreePixmap(halApp->display, priv->stipplePm); if ( priv->editable && priv->realized ) XmImUnregister(priv->textDA); } priv->selectOn = False; // So selection won't get erased priv->Reset(); delete priv;} // End Destructor/*---------------------------------------------------------------------- * Method to clear out the line lists */voidMimeRichTextP::Reset(){ if ( selectOn ) { DrawSelection(); selectOn = False; } inputTextBuf.Clear(); inputLine = NULL; inputCmd = NULL;//// Delete text lines// TextLineC *line = topTextLine; TextLineC *next; while ( line ) { next = line->next; delete line; line = next; } line = topSaveLine; while ( line ) { next = line->next; delete line; line = next; } topTextLine = NULL; botTextLine = NULL; topSaveLine = NULL; botSaveLine = NULL; topSoftLine = NULL; botSoftLine = NULL; NewInputLine();#if 0 if ( curCharset != 0 ) AddCharsetCommand(pub->Charset(curCharset), False/*not negate*/);#endif#if 0 if ( textType == TT_PLAIN ) inputCmd->state.PushJust(JC_NOFILL);#endif cursorPos.Set (inputLine, 0, 0); selectBegPos.Set(inputLine, 0, 0); selectEndPos.Set(inputLine, 0, 0); nextPartPos.Set (inputLine, 0, 0); moreParts = True;} // End MimeRichTextP::Reset/*----------------------------------------------------------------------- * Create a new text line and set its initial state. */voidMimeRichTextP::NewInputLine(){//// If we're in single line mode, just add a space to the input// if ( singleLine && !inputLastWhite ) inputTextBuf += ' '; FlushTextBuf(); if ( singleLine && inputLine ) return;//// Add a new line to the list// TextLineC *prevLine = inputLine; inputLine = new TextLineC; if ( prevLine ) AddLine(inputLine, prevLine); else { inputLine->index = 0; topTextLine = botTextLine = inputLine; }//// Move all commands to the right of inputCmd to the new line// if ( prevLine ) { void *tmp = (void*)inputCmd; int startPos = prevLine->cmdList.indexOf(tmp) + 1; if ( startPos >= 0 ) {//// Add commands to new line// int i; for (i=startPos; i<prevLine->cmdList.size(); i++) { RichCmdC *cmd = prevLine->Cmd(i); inputLine->AddCommand(cmd); }//// Remove commands from previous line// for (i=prevLine->cmdList.size()-1; i>=startPos; i--) prevLine->cmdList.remove(i); } TextPosC curPos(prevLine, startPos-1, inputCmd->text->size()); FixPosAfterBreak(&cursorPos, curPos, inputLine); } // End if there is a previous line//// Copy the current state// RichCmdC *cmd = inputLine->Cmd(0); if ( inputCmd ) cmd->state = inputCmd->state; inputCmd = cmd; inputLastWhite = True;} // End NewInputLine/*---------------------------------------------------------------------- * Clear the data */voidMimeRichTextC::Clear(){ priv->Reset(); priv->changed = True; if ( !priv->defer ) { Refresh(); CallCallbacks(priv->changeCalls, this); }}/*---------------------------------------------------------------------- * Set text string */voidMimeRichTextC::SetString(CharC cs){ priv->Reset(); AddString(cs);}voidMimeRichTextC::AddString(CharC cs){ if ( debuglev > 1 ) cout <<"AddString with (" <<cs <<")" NL; if ( cs.Length() > 10000 ) halApp->BusyCursor(True);#if 0 Boolean truncated = False; if ( cs.Length() > priv->maxLength ) { cs.CutEnd(cs.Length() - priv->maxLength); truncated = True; }#endif Defer(True);//// Create an input line if necessary// if ( !priv->botTextLine ) priv->Reset(); priv->inputLine = priv->botTextLine; priv->inputCmd = priv->inputLine->Cmd(priv->inputLine->cmdList.size()-1);//// Create text command if necessary// if ( !priv->inputCmd->IsText() ) { RichCmdC *rcmd = new RichCmdC(RC_TEXT); rcmd->state = priv->inputCmd->state; priv->inputLine->AddCommand(rcmd, /*after*/priv->inputCmd); priv->inputCmd = rcmd; }//// Add string based on type// if ( priv->textType == TT_ENRICHED ) AddStringEnriched(cs); else if ( priv->textType == TT_RICH ) AddStringRichtext(cs); else if ( priv->textType == TT_HTML ) AddStringHTML(cs); else AddStringPlain(cs);#if 0 if ( truncated ) { StringC msg("\n\n<center><bold>... DISPLAY TRUNCATED BY "); msg += halApp->name; msg += " ...</bold></center>\n\n"; AddStringEnriched(msg); }#endif Defer(False); if ( cs.Length() > 10000 ) halApp->BusyCursor(False);} // End AddString/*---------------------------------------------------------------------- * Set text string in enriched mode */voidMimeRichTextC::AddStringEnriched(CharC cs){ if ( cs.Length() > 10000 ) halApp->BusyCursor(True); TextTypeT saveType = priv->textType; priv->textType = TT_ENRICHED;//// Create text command if necessary// if ( !priv->inputCmd->IsText() ) { RichCmdC *rcmd = new RichCmdC(RC_TEXT); rcmd->state = priv->inputCmd->state; priv->inputLine->AddCommand(rcmd, /*after*/priv->inputCmd); priv->inputCmd = rcmd; } int inParam = 0; StringC paramCmd; StringC paramText; static StringC *cmd = NULL; if ( !cmd ) cmd = new StringC;//// Loop through input// u_int i = 0; if ( priv->checkFroms && priv->BeginningOfInputLine() && cs.StartsWith(">From ") ) i++; while ( i < cs.Length() ) { char c = cs[i];//// Look at current character// if ( c == '<' ) { c = cs[++i]; if ( c == '<' ) { // Second '<' if ( inParam ) paramText += c; else priv->inputTextBuf += c; c = cs[++i]; } else { // Look for end of command and process//// Get command// Boolean negate = False; if ( c == '/' ) { negate = True; c = cs[++i]; } cmd->Clear(); int pos = cs.PosOf('>', i); if ( pos >= 0 ) { *cmd = cs(i, (u_int)pos-i); i = pos + 1; c = cs[i]; }//// If we're in a parameter, the only command we'll recognize is another param// command.// if ( inParam ) { if ( strcasecmp(*cmd, "param") == 0 ) { inParam += (negate ? -1: 1); if ( inParam < 0 ) inParam = 0;//// If we have a command that was waiting on a parameter, issue it now// if ( !inParam && paramCmd.size() > 0 ) { priv->AddParamCommand(paramCmd, paramText); paramCmd.Clear(); paramText.Clear(); } } } // End if inside parameter block//// Look for a parameter command// else if ( strcasecmp(*cmd, "param") == 0 ) { inParam += (negate ? -1: 1); if ( inParam < 0 ) inParam = 0; } // End if got parameter command//// If we're starting a color range, look for the parameters// else if ( strcasecmp(*cmd, "x-color") == 0 && !negate ) { paramCmd = *cmd; }//// If we're starting a link, look for the parameters// else if ( strcasecmp(*cmd, "x-link") == 0 && !negate ) { paramCmd = *cmd; }//// Process command// else if ( !AddCommand(*cmd, negate) ) { // Unknown command if ( priv->inputTextBuf.size() > 0 && !isspace(priv->inputTextBuf.LastChar()) ) priv->inputTextBuf += ' '; } } // End if found a command } // End if left angle else if ( c == '\n' ) { // Skip this one and copy all others c = cs[++i]; if ( c == '\n' ) { while ( c == '\n' ) { if ( !inParam ) priv->NewInputLine(); c = cs[++i]; } } else if ( c && !inParam ) { // Single newline becomes space#if 0 if ( priv->inputTextBuf.size() > 0 && !isspace(priv->inputTextBuf.LastChar()) )#endif priv->inputTextBuf += ' '; }//// Skip > if necessary// if ( priv->checkFroms && cs.StartsWith(">From ", i) ) c = cs[++i]; } // End if found a newline else { // Printable character if ( inParam ) paramText += c; else priv->inputTextBuf += c; i++; } } // End for each input character//// Transfer final text// priv->FlushTextBuf(); priv->textType = saveType;//// Redraw if necessary// priv->changed = True; if ( !priv->defer ) { Refresh(); CallCallbacks(priv->changeCalls, this); } if ( cs.Length() > 10000 ) halApp->BusyCursor(False);} // End AddStringEnriched/*---------------------------------------------------------------------- * Set text string in richtext mode */voidMimeRichTextC::AddStringRichtext(CharC cs){ if ( cs.Length() > 10000 ) halApp->BusyCursor(True);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -