📄 mimerichtextselect.c
字号:
cmdPos--; RichCmdC *cmd = tl->Cmd(cmdPos); if ( cmd->IsText() ) { strPos = cmd->text->size() - 1; while ( strPos >= 0 && charClasses[(*cmd->text)[strPos]] == curClass ) strPos--; } else { cmdPos++; strPos = -1; done = True; } } if ( strPos < 0 ) strPos = 0; else strPos++; // Since last one didn't pass newPos->Set(tl, cmdPos, strPos); return True;} // End FindPosBegClass/*----------------------------------------------------------------------- * Find the rightmost character that belongs to the current character class. */BooleanMimeRichTextP::FindPosEndClass(TextPosC& curPos, TextPosC *newPos){ TextLineC *tl = curPos.textLine; RichCmdC *cmd = tl->Cmd(curPos.cmdPos); *newPos = curPos;//// If we're on a graphic command, just use that one// if ( cmd->IsGraphic() ) { newPos->Set(tl, curPos.cmdPos, 1); return True; }//// We must be on a text command// StringC *str = tl->Text(curPos.cmdPos); unsigned strSize = str->size(); if ( strSize == 0 ) return True; int charPos = curPos.strPos; if ( charPos == strSize ) charPos--;//// Find the character class of the current character// char curChar = (*str)[charPos]; int curClass = charClasses[curChar];//// Look to the right// int strPos = curPos.strPos; int checkStrPos = charPos + 1; while ( checkStrPos < strSize && charClasses[(*str)[checkStrPos]] == curClass ) { strPos = checkStrPos; checkStrPos++; }//// If we're still good, look in other text strings// int cmdPos = curPos.cmdPos; int checkCmdPos = cmdPos + 1; unsigned cmdCount = tl->cmdList.size(); unsigned checkStrSize = strSize; Boolean done = False; while ( !done && checkStrPos >= checkStrSize && checkCmdPos < cmdCount ) { RichCmdC *cmd = tl->Cmd(checkCmdPos); if ( cmd->IsText() ) { checkStrSize = cmd->text->size(); checkStrPos = 0; while ( checkStrPos < checkStrSize && charClasses[(*cmd->text)[checkStrPos]] == curClass ) { cmdPos = checkCmdPos; strPos = checkStrPos; strSize = checkStrSize; checkStrPos++; } } else { done = True; } checkCmdPos++; }//// Now, move to the right of the last matching character// if ( strPos < strSize ) strPos++; newPos->Set(tl, cmdPos, strPos); return True;} // End FindPosEndClass/*----------------------------------------------------------------------- * Find the position one character to the left of the specified position */BooleanMimeRichTextP::FindPosPrevChar(TextPosC& curPos, TextPosC *newPos){ *newPos = curPos; if ( !newPos->textLine ) return False;//// See if we still have room in the current command// if ( newPos->strPos > 0 ) { newPos->strPos--;//// Make sure we're not pointing to a clipped position// ScreenPosC spos = *newPos; while ( !spos.softLine && newPos->strPos > 0 ) { newPos->strPos--; spos = *newPos; } if ( spos.softLine ) return True; } // End if there is more room in the string//// See if there is another command// if ( newPos->cmdPos > 0 ) { newPos->cmdPos--; RichCmdC *cmd = newPos->Cmd(); newPos->strPos = cmd->LastPos();//// If we're in the middle of a line, we may not have actually moved. Check// this by seeing if we're in the same soft line.// ScreenPosC pos0 = curPos; ScreenPosC pos1 = *newPos;//// Make sure we're not pointing to a clipped position// while ( !pos1.softLine && newPos->strPos > 0 ) { newPos->strPos--; pos1 = *newPos; } if ( pos1.softLine ) { if ( pos0.softLine == pos1.softLine ) newPos->strPos--; if ( newPos->strPos < 0 ) newPos->strPos = 0; return True; } } // End if there are more commands//// See if there is another line// TextLineC *prevLine = newPos->textLine->prev; if ( prevLine ) { newPos->textLine = prevLine; newPos->cmdPos = newPos->textLine->cmdList.size() - 1; RichCmdC *cmd = newPos->Cmd(); newPos->strPos = cmd->LastPos();//// Make sure we're not pointing to a clipped position// ScreenPosC spos = *newPos; while ( !spos.softLine && newPos->strPos > 0 ) { newPos->strPos--; spos = *newPos; } if ( spos.softLine ) return True; } // End if more lines above//// Nothing to the left// return False;} // End FindPosPrevChar/*----------------------------------------------------------------------- * Find the position one character to the right of the specified position */BooleanMimeRichTextP::FindPosNextChar(TextPosC& curPos, TextPosC *newPos){ *newPos = curPos; if ( !newPos->textLine ) return False; RichCmdC *cmd = newPos->Cmd();//// See if we still have room in the current command// if ( newPos->strPos < cmd->LastPos() ) { newPos->strPos++;//// Make sure we're not pointing to a clipped position// ScreenPosC spos = *newPos; while ( !spos.softLine && newPos->strPos < cmd->LastPos() ) { newPos->strPos++; spos = *newPos; } if ( spos.softLine ) return True; } // End if we're not at the end of the string//// See if there is another command// unsigned cmdCount = newPos->textLine->cmdList.size(); if ( newPos->cmdPos+1 < cmdCount ) { newPos->cmdPos++; newPos->strPos = 0;//// If we're in the middle of a line, we may not have actually moved. Check// this by seeing if we're in the same soft line.// ScreenPosC pos0 = curPos; ScreenPosC pos1 = *newPos; cmd = newPos->Cmd();//// Make sure we're not pointing to a clipped position// while ( !pos1.softLine && newPos->strPos < cmd->LastPos() ) { newPos->strPos++; pos1 = *newPos; } if ( pos1.softLine ) { if ( pos0.softLine == pos1.softLine ) newPos->strPos++; if ( newPos->strPos > cmd->LastPos() ) newPos->strPos = cmd->LastPos(); return True; } } // End if there are more commands//// See if there is another line// TextLineC *nextLine = newPos->textLine->next; if ( nextLine ) { newPos->textLine = nextLine; newPos->cmdPos = 0; newPos->strPos = 0; cmd = newPos->Cmd();//// Make sure we're not pointing to a clipped position// ScreenPosC spos = *newPos; while ( !spos.softLine && newPos->strPos < cmd->LastPos() ) { newPos->strPos++; spos = *newPos; } if ( spos.softLine ) return True; } // End if more lines below//// Nothing to the right// return False;} // End FindPosNextChar/*----------------------------------------------------------------------- * Find the beginning of this word or if we're at the beginning, the * beginning of the previous word. This means find the first whitespace * character to the left of the next non-white character. */BooleanMimeRichTextP::FindPosPrevWord(TextPosC& curPos, TextPosC *newPos){ *newPos = curPos; if ( !newPos->textLine ) return False;//// See if we're at the beginning of the line// if ( newPos->cmdPos == 0 && newPos->strPos == 0 ) { int tindex = newPos->textLine->index; if ( tindex == 0 ) return False;//// Move to the previous line// newPos->textLine = newPos->textLine->prev; unsigned cmdCount = newPos->textLine->cmdList.size(); newPos->cmdPos = cmdCount - 1; RichCmdC *cmd = newPos->Cmd(); newPos->strPos = cmd->LastPos(); } // End if we're at the beginning of a line Boolean needWhite = True; Boolean needNonWhite = True;//// Look backwards through data// unsigned cmdCount = newPos->textLine->cmdList.size(); int strPos = newPos->strPos; int cmdPos = newPos->cmdPos; RichCmdC *cmd = newPos->Cmd(); Boolean found = False; while ( !found && cmdPos >= 0 ) {//// Look backwards through the characters// strPos--; while ( !found && strPos >= 0 ) { if ( cmd->IsText() ) { char c = (*cmd->text)[strPos]; if ( needNonWhite ) { if ( !isspace(c) ) needNonWhite = False; } else if ( needWhite ) { if ( isspace(c) ) { strPos++; found = True; } } } else { strPos = 0; found = True; } if ( !found ) strPos--; } // End for each character//// Move to previous command// if ( !found ) { cmdPos--;//// See if we can possibly stop here. We have to have found some characters.// if ( !needNonWhite ) { // Means we found some if ( cmdPos < 0 ) { cmdPos++; strPos = 0; found = True; } else { cmd = newPos->textLine->Cmd(cmdPos); if ( !cmd->IsText() ) { cmdPos++; strPos = 0; found = True; } else strPos = cmd->LastPos(); } } // End if characters have been found else if ( cmdPos >= 0 ) { cmd = newPos->textLine->Cmd(cmdPos); strPos = cmd->LastPos(); } // End if no characters found yet } // End if not yet found } // End for each data block if ( found ) { newPos->cmdPos = cmdPos; newPos->strPos = strPos; } else { newPos->cmdPos = 0; newPos->strPos = 0; }//// Make sure we're not pointing to a clipped position// ScreenPosC spos = *newPos; while ( !spos.softLine && newPos->strPos > 0 ) { newPos->strPos--; spos = *newPos; } if ( spos.softLine ) return True; else return False;} // End FindPosPrevWord/*----------------------------------------------------------------------- * Find the beginning of this word. This means find the first whitespace * character to the left of the next non-white character. */BooleanMimeRichTextP::FindPosBegWord(TextPosC& curPos, TextPosC *newPos){ *newPos = curPos; if ( !newPos->textLine ) return False;//// See if we're at the beginning of the line// if ( newPos->cmdPos == 0 && newPos->strPos == 0 ) return True;//// Look backwards through data// unsigned cmdCount = newPos->textLine->cmdList.size(); int strPos = newPos->strPos; int cmdPos = newPos->cmdPos; RichCmdC *cmd = newPos->Cmd(); Boolean found = False; while ( !found && cmdPos >= 0 ) {//// Look backwards through the characters// strPos--; while ( !found && strPos >= 0 ) { if ( cmd->IsText() ) { char c = (*cmd->text)[strPos]; if ( isspace(c) ) { strPos++; found = True; } } else { strPos = 0; found = True; } if ( !found ) strPos--; } // End for each character//// Move to previous command// if ( !found ) { cmdPos--; if ( cmdPos < 0 ) { cmdPos++; strPos = 0; found = True; } else { cmd = newPos->textLine->Cmd(cmdPos); if ( !cmd->IsText() ) { cmdPos++; strPos = 0; found = True; } else strPos = cmd->LastPos(); } } // End if not yet found } // End for each data block if ( found ) { newPos->cmdPos = cmdPos; newPos->strPos = strPos; } else { newPos->cmdPos = 0; newPos->strPos = 0; }//// Make sure we're not pointing to a clipped position// ScreenPosC spos = *newPos; while ( !spos.softLine && newPos->strPos > 0 ) { newPos->strPos--; spos = *newPos; } if ( spos.softLine ) return True; else return False;} // End FindPosBegWord/*----------------------------------------------------------------------- * Find the beginning of the next word. This means find the first non-white * character to the right of the next white character. */BooleanMimeRichTextP::FindPosNextWord(TextPosC& curPos, TextPosC *newPos){ *newPos = curPos; if ( !newPos->textLine ) return False;//// Look forward through data// Boolean needWhite = True; Boolean needNonWhite = True; unsigned cmdCount = newPos->textLine->cmdList.size(); int strPos = newPos->strPos; int cmdPos = newPos->cmdPos;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -