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

📄 mimerichtextedit.c

📁 linux下的E_MAIL客户端源码
💻 C
📖 第 1 页 / 共 5 页
字号:
   XtVaGetValues(w, XmNuserData, &This, NULL);   This->DeleteLeftWord();}voidMimeRichTextC::DeleteLeftWord(){   if ( !priv->editable ) {      XBell(halApp->display, 0);      return;   }//// Delete the current selection//   if ( priv->selectOn ) {      priv->DeleteSelection();      return;   }   TextPosC	newPos;   if ( !priv->FindPosPrevWord(priv->cursorPos, &newPos) ) return;   priv->DeleteRange(newPos, priv->cursorPos);} // End DeleteLeftWord/*--------------------------------------------------------------- *  Delete the character to the right of the cursor */voidMimeRichTextP::ActDeleteRightChar(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->DeleteRightChar();}voidMimeRichTextC::DeleteRightChar(){   if ( !priv->editable ) {      XBell(halApp->display, 0);      return;   }//// Delete the current selection//   if ( priv->selectOn ) {      priv->DeleteSelection();      return;   }   TextPosC	newPos;   if ( !priv->FindPosNextChar(priv->cursorPos, &newPos) ) return;   priv->DeleteRange(priv->cursorPos, newPos);} // End DeleteRightChar/*--------------------------------------------------------------- *  Delete the word to the right of the cursor */voidMimeRichTextP::ActDeleteRightWord(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->DeleteRightWord();}voidMimeRichTextC::DeleteRightWord(){   if ( !priv->editable ) {      XBell(halApp->display, 0);      return;   }//// Delete the current selection//   if ( priv->selectOn ) {      priv->DeleteSelection();      return;   }   TextPosC	newPos;   if ( !priv->FindPosNextWord(priv->cursorPos, &newPos) ) return;   priv->DeleteRange(priv->cursorPos, newPos);} // End DeleteRightWord/*--------------------------------------------------------------- *  Delete to the beginning of the line */voidMimeRichTextP::ActDeleteLineBeg(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->DeleteLineBeg();}voidMimeRichTextC::DeleteLineBeg(){   if ( !priv->editable ) {      XBell(halApp->display, 0);      return;   }//// Delete the current selection//   if ( priv->selectOn ) {      priv->DeleteSelection();      return;   }   ScreenPosC	sp = priv->cursorPos;   sp.Set(sp.softLine, sp.softLine->bounds.xmin);   TextPosC	newPos = sp;   priv->DeleteRange(newPos, priv->cursorPos);} // End DeleteLineBeg/*--------------------------------------------------------------- *  Delete to the end of the line */voidMimeRichTextP::ActDeleteLineEnd(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   This->DeleteLineEnd();}voidMimeRichTextC::DeleteLineEnd(){   if ( !priv->editable ) {      XBell(halApp->display, 0);      return;   }//// Delete the current selection//   if ( priv->selectOn ) {      priv->DeleteSelection();      return;   }   ScreenPosC	sp = priv->cursorPos;   sp.Set(sp.softLine, sp.softLine->bounds.xmax);   TextPosC	newPos = sp;   priv->DeleteRange(priv->cursorPos, newPos);} // End DeleteLineEnd/*--------------------------------------------------------------- *  Delete the current selection */voidMimeRichTextP::ActDeleteSelection(Widget w, XKeyEvent*, String*, Cardinal*){   ActCutSelection(w, NULL, NULL, NULL);   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);//// Clear out the clipboard//   XmClipboardUndoCopy(halApp->display, XtWindow(This->priv->textDA));} // End ActDeleteSelection/*--------------------------------------------------------------- *  Delete the current selection and place a copy on the clipboard */voidMimeRichTextP::ActCutSelection(Widget w, XKeyEvent*, String*, Cardinal*){   MimeRichTextC	*This;   XtVaGetValues(w, XmNuserData, &This, NULL);   if ( !This->priv->editable ) {      XBell(halApp->display, 0);      return;   }   if ( !This->priv->selectOn ) return;//// Force the cursor to the beginning of the selection so that the text gets//   deleted.  It only gets cleared if the cursor is not in it.//   This->priv->HideCursor();   This->priv->cursorPos = This->priv->selectBegPos;   This->priv->DeleteSelection();   This->priv->ShowCursor();//// We don't need to worry about the clipboard because the item was copied//    there when it was selected.//} // End ActCutSelection/*--------------------------------------------------------------- *  Delete the text between the 2 positions */voidMimeRichTextP::DeleteRange(TextPosC& pos1, TextPosC& pos2){   if ( !editable ) {      XBell(halApp->display, 0);      return;   }   if ( pos1 == pos2 ) return;   TextPosC	begPos = pos1;   TextPosC	endPos = pos2;   if ( pos1 > pos2 ) {      begPos = pos2;      endPos = pos1;   }   HideCursor();//// Erase the current selection//   if ( selectOn ) {      DrawSelection();      selectOn = False;   }//// Prepare to save the stuff to be deleted so that we can recover//   TextLineC	*tline = topSaveLine;   while ( tline ) {      TextLineC	*next = tline->next;      delete tline;      tline = next;   }   lastDelPos = begPos;//// See if we're deleting on just one line or spanning more than one//   Boolean	forcePlace;   if ( begPos.textLine == endPos.textLine ) {//// Create a text line for the saved data//      TextLineC	*saveLine = new TextLineC;      saveLine->DeleteCmd(0);      topSaveLine = botSaveLine = saveLine;//// See if we're deleting within just one command//      if ( begPos.cmdPos == endPos.cmdPos ) {//// Delete between the 2 character positions//	 if ( begPos.Cmd()->IsText() ) {	    int	len = endPos.strPos - begPos.strPos;	    MoveText(begPos, len, saveLine);	    FixPosAfterDelText(&endPos, begPos, len);	 }	 else {	    begPos.Cmd()->graphic->Hide();	    MoveCommand(begPos, saveLine);	    FixPosAfterDelCmd(&begPos, begPos);	    FixPosAfterDelCmd(&endPos, begPos);	 }      } // End if deleting within one text command//// We're deleting more than one command//      else {//// Delete all commands between the beginning and end commands (not inclusive)//	 int	begDelPos = begPos.cmdPos + 1;	 int	endDelPos = endPos.cmdPos - 1;	 TextPosC	delPos = begPos;	 for (int i=endDelPos; i>=begDelPos; i--) {	    delPos.cmdPos = i;	    if ( delPos.Cmd()->IsGraphic() ) delPos.Cmd()->graphic->Hide();	    MoveCommand(delPos, saveLine, 0);	    FixPosAfterDelCmd(&endPos, delPos);	 }//// Delete to the end of the beginning command.//	 if ( begPos.strPos == 0 ) {	    if ( begPos.Cmd()->IsGraphic() ) begPos.Cmd()->graphic->Hide();	    MoveCommand(begPos, saveLine, 0);	    FixPosAfterDelCmd(&begPos, begPos);	    FixPosAfterDelCmd(&endPos, begPos);	 }	 else if ( begPos.Cmd()->IsText() ) {	    int	len = begPos.Cmd()->text->size() - begPos.strPos;	    MoveText(begPos, len, saveLine, 0);	    FixPosAfterDelText(&endPos, begPos, len);	 }//// Delete from the beginning of the end command//	 if ( endPos.Cmd()->IsText() ) {	    int	len = endPos.strPos;	    endPos.strPos = 0;	    MoveText(endPos, len, saveLine);	 }	 else if ( endPos.strPos > 0 ) {	    endPos.Cmd()->graphic->Hide();	    MoveCommand(endPos, saveLine);	    FixPosAfterDelCmd(&endPos, endPos);	 }      } // End if deleting more than one text command      forcePlace = False;   } // End if deleting within one line   else {//// Create lines for saving//      TextLineC	*begSaveLine = new TextLineC;      TextLineC	*endSaveLine = new TextLineC;      begSaveLine->DeleteCmd(0);      endSaveLine->DeleteCmd(0);//// Delete all commands in the beginning line after the beginning command//      RichCmdC	*cmd;      TextPosC	delPos = begPos;      unsigned	count = begPos.textLine->cmdList.size();      int i=count-1; for (i=count-1; i>begPos.cmdPos; i--) {	 delPos.cmdPos = i;	 cmd = delPos.Cmd();	 if ( cmd->IsGraphic() ) cmd->graphic->Hide();	 MoveCommand(delPos, begSaveLine, 0);      }//// Delete to the end of the beginning command.//      cmd = begPos.Cmd();      if ( begPos.strPos == 0 ) {	 if ( cmd->IsGraphic() ) cmd->graphic->Hide();	 MoveCommand(begPos, begSaveLine, 0);	 FixPosAfterDelCmd(&begPos, begPos);      }      else if ( cmd->IsText() ) {	 int	len = cmd->text->size() - begPos.strPos;	 MoveText(begPos, len, begSaveLine, 0);      }//// Delete all commands in the end line before the end command//      delPos = endPos;      for (i=endPos.cmdPos-1; i>=0; i--) {	 delPos.cmdPos = i;	 cmd = delPos.Cmd();	 if ( cmd->IsGraphic() ) cmd->graphic->Hide();	 MoveCommand(delPos, endSaveLine, 0);	 FixPosAfterDelCmd(&endPos, delPos);      }//// Delete from the beginning of the end command//      cmd = endPos.Cmd();      if ( cmd->IsText() ) {	 int	len = endPos.strPos;	 endPos.strPos = 0;	 MoveText(endPos, len, endSaveLine);      }      else if ( endPos.strPos > 0 ) {	 cmd->graphic->Hide();	 MoveCommand(endPos, endSaveLine);	 FixPosAfterDelCmd(&endPos, endPos);      }//// Merge the end line with the beginning line//      MergeLines(begPos.textLine, endPos.textLine);//// Delete lines up to and including the end line//      topSaveLine = botSaveLine = begSaveLine;      TextLineC	*delLine = begPos.textLine->next;      TextLineC	*endLine = endPos.textLine;      RemoveLines(delLine, endLine);      while ( delLine && delLine != endLine ) {	 u_int		ccount = delLine->cmdList.size();	 for (int c=0; c<ccount; c++) {	    RichCmdC	*delCmd = delLine->Cmd(c);	    if ( delCmd->IsGraphic() ) delCmd->graphic->Hide();	 }	 botSaveLine->next = delLine;	 delLine->prev = botSaveLine;	 botSaveLine = delLine;	 delLine = delLine->next;	 botSaveLine->next = NULL;      }      DeleteLine(endLine);      botSaveLine->next = endSaveLine;      endSaveLine->prev = botSaveLine;      botSaveLine = endSaveLine;      botSaveLine->next = NULL;      endPos = begPos;      forcePlace = True;   } // End if deleting on more than one line//// Make the line as efficient as possible.  The beginning line should be//    the only remaining line.//   CompactLine(begPos.textLine);   LineChanged(begPos.textLine, forcePlace);//// Keep the cursor visible//   ScrollToCursor();   ScreenPosC	spos = cursorPos;   desiredCursorX = spos.x;   ShowCursor();} // End DeleteRange/*--------------------------------------------------------------- * In the specified line, remove any blank text blocks and merge any *    text blocks with the same state. */voidMimeRichTextP::CompactLine(TextLineC *line){   TextPosC	curPos(line, 0, 0);   u_int	count;   int		i;// If we take this code out, excerpting is not drawn correctly#if 1//// Remove any blank text blocks, making sure to keep at least one.//   RichCmdC	*cmd;   count = line->cmdList.size();   for (i=0; i<count; ) {      curPos.cmdPos = i;      cmd = curPos.Cmd();      if ( cmd->IsText() && cmd->text->size() == 0 && count > 1 ) {	 DeleteCommand(curPos);	 count--;      }      else	 i++;   } // End for each remaining command#endif//// Merge any text blocks with the same state.//   count = line->cmdList.size();   TextPosC	prevPos(line, 0, 0);   curPos = prevPos;   for (i=1; i<count; ) {      prevPos.cmdPos = i-1;      curPos.cmdPos  = i;      if ( prevPos.Cmd()->IsText() && curPos.Cmd()->IsText() &&	   prevPos.Cmd()->state == curPos.Cmd()->state ) {//// Add the beginning and end strings together//	 MergeCommands(prevPos, curPos);	 DeleteCommand(curPos);	 count--;      } // End if states are the same      else {	 i++;      }   } // End for each state command} // End CompactLine/*--------------------------------------------------------------- * Make the selection range as tight as possible. */voidMimeRichTextP::CompactSelection(){//// If the beginning position is at the end of a non-blank string, we can//    move to the start of the next one//   RichCmdC	*cmd = selectBegPos.Cmd();   TextPosC	newPos;   if ( selectBegPos.strPos > 0 && selectBegPos.strPos >= cmd->LastPos() &&	FindPosNextCmd(selectBegPos, &newPos) ) {      selectBegPos = newPos;   }//// If the end position is at the beginning of a non-blank string, we can//    move to the end of the previous one//   cmd = selectEndPos.Cmd();   if ( selectEndPos.strPos == 0 && cmd->LastPos() > 0 &&	FindPosPrevCmd(selectEndPos, &newPos) ) {      selectEndPos = newPos;   }   if      ( cursorPos <= selectBegPos ) cursorPos = selectBegPos;   else if ( cursorPos >= selectEndPos ) cursorPos = selectEndPos;

⌨️ 快捷键说明

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