⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mimerichtextedit.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 5 页
字号:
//// If the cursor went off the screen, move it to the top position//   spos = priv->cursorPos;   SoftLineC*	line = spos.softLine;   if ( line && !priv->LineFullyVisible(line) && priv->topTextLine ) {      priv->HideCursor();      priv->cursorPos.Set(priv->topTextLine, 0, 0);      priv->ScrollToCursor();      priv->desiredCursorX = 0;      priv->ShowCursor();   }#endif} // End ScrollTop/*--------------------------------------------------------------- *  Scroll the window to the bottom */voidMimeRichTextP::ActScrollBottom(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->ScrollBottom();}voidMimeRichTextC::ScrollBottom(){   if ( priv->textVSB ) {      int	val, ss, i, pi;      XmScrollBarGetValues(priv->textVSB, &val, &ss, &i, &pi);      int	max = priv->vsbMax - ss;      XmScrollBarSetValues(priv->textVSB, max, ss, i, pi, True);   }#if 0//   if ( !priv->botSoftLine ) return;//// Make the bottom position visible//   ScreenPosC	spos(priv->botSoftLine, 0);   priv->ScrollToPosition(spos);//// If the cursor went off the screen, move it to the bottom position//   spos = priv->cursorPos;   SoftLineC	*line = spos.softLine;   if ( line && !priv->LineFullyVisible(line) && priv->botTextLine ) {      TextLineC	*tline   = priv->botTextLine;      unsigned	cmdCount = tline->cmdList.size();      RichCmdC	*cmd     = tline->Cmd(cmdCount-1);      unsigned	strSize  = cmd->LastPos();      priv->HideCursor();      priv->cursorPos.Set(tline, cmdCount-1, strSize);      priv->ScrollToCursor();      ScreenPosC	spos = priv->cursorPos;      priv->desiredCursorX = spos.x;      priv->ShowCursor();   }#endif} // End ScrollBottom/*--------------------------------------------------------------- *  Scroll the current line to the top of the window */voidMimeRichTextP::ActLineToTop(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->LineToTop();}voidMimeRichTextC::LineToTop(){   priv->HideCursor();   priv->ShowCursor();} // End LineToTop/*--------------------------------------------------------------- *  Scroll the current line to the center of the window */voidMimeRichTextP::ActLineToCenter(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->LineToCenter();}voidMimeRichTextC::LineToCenter(){   priv->HideCursor();   priv->ShowCursor();} // End LineToCenter/*--------------------------------------------------------------- *  Scroll the current line to the bottom of the window */voidMimeRichTextP::ActLineToBottom(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->LineToBottom();}voidMimeRichTextC::LineToBottom(){   priv->HideCursor();   priv->ShowCursor();} // End LineToBottom/*--------------------------------------------------------------- *  Make the specified font change to the current selection or at the cursor *  If fcmd is FC_PLAIN, remove all markup. */voidMimeRichTextC::ChangeFont(FontCmdT fcmd){   priv->ChangeFont(fcmd);}voidMimeRichTextP::ChangeFont(FontCmdT fcmd){   if ( !editable ) {      XBell(halApp->display, 0);      return;   }   HideCursor();   TextPosC	newPos;//// If there is a current selection, make the change to that.  Otherwise, insert//    the command at the cursor position.//   if ( selectOn ) {//// Save copies of the selection positions.//      TextPosC	begPos;      TextPosC	endPos;      if ( selectBegPos > selectEndPos ) {	 begPos = selectEndPos;	 endPos = selectBegPos;      }      else {	 begPos = selectBegPos;	 endPos = selectEndPos;      }      Boolean	correct;//// If we're making the text bigger or smaller, we do so regardless of the//    current state//      if ( fcmd != FC_BIGGER && fcmd != FC_SMALLER ) {//// If the beginning state is already correct, advance the beginning state until//    it's not//	 if ( fcmd == FC_PLAIN )	    correct = (begPos.Cmd()->state.FontStack().size() == 0 &&	               begPos.Cmd()->state.Underline() == 0);	 else if ( fcmd == FC_UNDERLINE )	    correct = (begPos.Cmd()->state.Underline() > 0);	 else	    correct = (begPos.Cmd()->state.CmdCount(fcmd) > 0);	 while ( correct && begPos < endPos &&		 FindPosNextCmd(begPos, &newPos) ) {	    begPos = newPos;	    if ( fcmd == FC_PLAIN )	       correct = (begPos.Cmd()->state.FontStack().size() == 0 &&			  begPos.Cmd()->state.Underline() == 0);	    else if ( fcmd == FC_UNDERLINE )	       correct = (begPos.Cmd()->state.Underline() > 0);	    else	       correct = (begPos.Cmd()->state.CmdCount(fcmd) > 0);	 }      } // End if current state is important//// If the beginning position is at the end of a non-blank string, we can//    move to the start of the next one//      if ( begPos.strPos > 0 && begPos.strPos >= begPos.Cmd()->LastPos() &&	   FindPosNextCmd(begPos, &newPos) ) {	 begPos = newPos;      }      if ( fcmd != FC_BIGGER && fcmd != FC_SMALLER ) {//// If the end state is already correct, move the end state until//    it's not//	 if ( fcmd == FC_PLAIN )	    correct = (endPos.Cmd()->state.FontStack().size() == 0 &&	               endPos.Cmd()->state.Underline() == 0);	 else if ( fcmd == FC_UNDERLINE )	    correct = (endPos.Cmd()->state.Underline() > 0);	 else	    correct = (endPos.Cmd()->state.CmdCount(fcmd) > 0);	 while ( correct && endPos > begPos &&		 FindPosPrevCmd(endPos, &newPos) ) {	    endPos = newPos;	    if ( fcmd == FC_PLAIN )	       correct = (endPos.Cmd()->state.FontStack().size() == 0 &&			  endPos.Cmd()->state.Underline() == 0);	    else if ( fcmd == FC_UNDERLINE )	       correct = (endPos.Cmd()->state.Underline() > 0);	    else	       correct = (endPos.Cmd()->state.CmdCount(fcmd) > 0);	 }      } // End if current state is important//// If the end position is at the beginning of a non-blank string, we can//    move to the end of the previous one//      if ( endPos.strPos == 0 && endPos.Cmd()->LastPos() > 0 &&	   FindPosPrevCmd(endPos, &newPos) ) {	 endPos = newPos;      }//// If there's no text in-between, we're done//      if ( begPos >= endPos ) {	 ShowCursor();	 return;      }//// Clear the selection//      DrawSelection();	// To clear it      selectOn = False;//// If the beginning position is not the beginning of a command, split//    the command.//      if ( begPos.strPos != 0 ) {	 SplitCommand(begPos, &newPos);	 FixPosAfterSplit(&endPos, begPos);	 begPos = newPos;      }//// If the end position is not the end of a command, split the command.//      if ( endPos.strPos < endPos.Cmd()->LastPos() )	 SplitCommand(endPos, &newPos);//// For each command between the beginning and end (inclusive), make the//    font change//      TextPosC	curPos = begPos;      Boolean	done = False;      while ( !done && curPos <= endPos ) {	 RichCmdC	*cmd = curPos.Cmd();	 if ( fcmd == FC_PLAIN ) {	    cmd->state.FontStack().Clear();	    cmd->state.Underline(0);	 }	 else if ( fcmd == FC_UNDERLINE )	    cmd->state.UnderlineMore();	 else {//// If we want "bigger" and the current command is "smaller", or if we want//    "smaller" and the current command is "bigger", just pop it.// Otherwise push the new command//	    if ( (fcmd == FC_BIGGER && cmd->state.CurFontCmd() == FC_SMALLER) ||		 (fcmd == FC_SMALLER && cmd->state.CurFontCmd() == FC_BIGGER) )	       cmd->state.PopFont();	    else	       cmd->state.PushFont(fcmd);	 } // End if font is not plain	 done = !FindPosNextCmd(curPos, &newPos);	 curPos = newPos;      } // End for each command changing//// Update all affected lines//      LinesChanged(begPos.textLine, endPos.textLine);//// Turn the selection back on//      CompactSelection();      DrawSelection();      selectOn = True;   } // End if selectOn//// Since there is no current selection, insert a command at the cursor//    position.//   else {//// See what the text state is at the cursor position//      RichCmdC	*cmd = cursorPos.Cmd();//// If it's not already correct, add a blank string with the desired state//      Boolean	correct;      if ( fcmd == FC_BIGGER || fcmd == FC_SMALLER )	 correct = False;      else if ( fcmd == FC_PLAIN )	 correct = (cmd->state.FontStack().size() == 0 &&		    cmd->state.Underline() == 0);      else if ( fcmd == FC_UNDERLINE )	 correct = (cmd->state.Underline() > 0);      else	 correct = (cmd->state.CmdCount(fcmd) > 0);      if ( !correct ) {//// If the cursor is not in a blank text string, create one.//	 if ( cmd->IsText() && cmd->LastPos() > 0 ) {	    TextPosC	oldPos = cursorPos;	    SplitCommand(cursorPos, &newPos);//// Splitting may have left one of the two parts blank.  If so, use that part.//	    if ( cursorPos.Cmd()->LastPos() == 0 ) {	       selectBegPos =	       selectEndPos = cursorPos;	    }	    else if ( newPos.Cmd()->LastPos() == 0 ) {	       cursorPos    =	       selectBegPos =	       selectEndPos = newPos;	    }	    else if ( oldPos.Cmd()->LastPos() == 0 ) {	       cursorPos    =	       selectBegPos =	       selectEndPos = oldPos;	    }//// If no part is blank, insert a blank command//	    else { 	       InsertCommand(RC_TEXT, True/*after*/, oldPos, &newPos);	       cursorPos    =	       selectBegPos =	       selectEndPos = newPos;	    }	    cmd = cursorPos.Cmd();	 } // End if a new command is needed//// The cursor should now be in a blank text command//	 if ( fcmd == FC_PLAIN ) {	    cmd->state.FontStack().Clear();	    cmd->state.Underline(0);	 }	 else if ( fcmd == FC_UNDERLINE )	    cmd->state.UnderlineMore();	 else if ((fcmd == FC_BIGGER  && cmd->state.CurFontCmd() == FC_SMALLER)	       || (fcmd == FC_SMALLER && cmd->state.CurFontCmd() == FC_BIGGER))	    cmd->state.PopFont();	 else	    cmd->state.PushFont(fcmd);//// Update the current line//	 LineChanged(cursorPos.textLine);      } // End if not already correct   } // End if no current selection//// Keep the cursor in the window//   ScrollToCursor();   ScreenPosC        spos = cursorPos;   desiredCursorX = spos.x;   ShowCursor();} // End ChangeFont/*--------------------------------------------------------------- *  Make the specified character set change to the current selection *     or at the cursor. */voidMimeRichTextC::ChangeCharset(CharC cs){   priv->ChangeCharset(cs);}voidMimeRichTextP::ChangeCharset(CharC cs){   int	num = pub->AddCharset(cs);   switch (num) {      case 1:	ChangeFont(FC_CHARSET_1);	break;      case 2:	ChangeFont(FC_CHARSET_2);	break;      case 3:	ChangeFont(FC_CHARSET_3);	break;      case 4:	ChangeFont(FC_CHARSET_4);	break;      case 5:	ChangeFont(FC_CHARSET_5);	break;      case 6:	ChangeFont(FC_CHARSET_6);	break;      case 7:	ChangeFont(FC_CHARSET_7);	break;      case 8:	ChangeFont(FC_CHARSET_8);	break;      case 9:	ChangeFont(FC_CHARSET_9);	break;   }} // End ChangeCharset/*--------------------------------------------------------------- *  Make the specified color change to the current selection or at the cursor *  If the color is the same as the foreground color, remove all color markup. */voidMimeRichTextC::ChangeColor(StringC name){   priv->ChangeColor(name);}voidMimeRichTextP::ChangeColor(StringC name){   if ( !editable ) {      XBell(halApp->display, 0);      return;   }   HideCursor();   TextPosC	newPos;   Pixel	value = 0;   PixelValue(textDA, name, &value);//// If there is a current selection, make the change to that.  Otherwise, insert//    the command at the cursor position.//   if ( selectOn ) {//// Save copies of the selection positions.//      TextPosC	begPos;      TextPosC	endPos;      if ( selectBegPos > selectEndPos ) {	 begPos = selectEndPos;	 endPos = selectBegPos;      }      else {	 begPos = selectBegPos;	 endPos = selectEndPos;      }      Boolean	correct;//// If the beginning state is already correct, advance the beginning state until//    it's not//      if ( name.Equals("none", IGNORE_CASE) )	 correct = (begPos.Cmd()->state.ColorStack().size() == 0);      else	 correct = (begPos.Cmd()->state.ColorCount(value) > 0);      while ( correct && begPos < endPos &&	      FindPosNextCmd(begPos, &newPos) ) {	 begPos = newPos;	 if ( name.Equals("none", IGNORE_CASE) )	    correct = (begPos.Cmd()->state.ColorStack().size() == 0);	 else	    correct = (begPos.Cmd()->state.ColorCount(value) > 0);      }//// If the beginning position is at the end of a non-blank string, we can//    move to the start of the next one//      if ( begPos.strPos > 0 && begPos.strPos >= begPos.Cmd()->LastPos() &&	   FindPosNextCmd(begPos, &newPos) ) {	 begPos = newPos;      }//// If the end state is already correct, move the end state until//    it's not//      if ( name.Equals("none", IGNORE_CASE) )	 correct = (endPos.Cmd()->state.ColorStack().size() == 0);      else	 correct = (endPos.Cmd()->state.ColorCount(value) > 0);      while ( correct && endPos > begPos &&	      FindPosPrevCmd(endPos, &newPos) ) {	 endPos = newPos;	 if ( name.Equals("none", IGNORE_CASE) )	    correct = (endPos.Cmd()->state.ColorStack().size() == 0);	 else	    correct = (endPos.Cmd()->state.ColorCount(value) > 0);      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -