Given a TextNode that has as the first Paragraph:
ABYX~ \ ab<cr>
I want to set a Caret to the End of a Run so I can do this and get the "plain text":
wprintf(L"[%s]\n", textBlock->ToString(*runCaret, *endOfCurrentRun));
So I do this:
CaretPtr endOfCurrentRun = runCaret->Clone(); endOfCurrentRun->MoveToNextRun();
and I get the <cr> included (The "length" is reported as 11). If I do this:
CaretPtr endOfCurrentRun = runCaret->Clone(); endOfCurrentRun->MoveToNextRun(); endOfCurrentRun->MoveToPreviousCharacter();
I get "ABYZ~ \ ab". (The length is reported as 9) The ending "c' is left off.
So. how to set the "endOfCurrentRun" Caret to return the proper, complete string? I am interested in getting the Carets set properly, NOT the resulting string. I'm just using the string to verify the Caret positions..
Bruce
Unknown said: Given a TextNode that has as the first Paragraph: ABYX~ \ ab<cr> The "length" is reported as 11
The "length" is reported as 11
Unknown said:I get "ABYZ~ \ ab". (The length is reported as 9) The ending "c' is left off
Looks OK to me. Where's the ending "c' in the original?
The 2-character length difference may be in the representation of 'newline'. It could be a carriage-return + line feed.
Regards, Jon Summers LA Solutions
Unknown said: Bruce Reeves SRNS I get "ABYZ~ \ ab". (The length is reported as 9) The ending "c' is left off
My typo. The returned string is "ABYZ~ \ a", the "b" is left off.
What if you obtain your carets this way...
CaretPtr startCaret = textBlock.CreateStartCaret(); CaretPtr endCaret = textBlock.CreateEndCaret();
For find the Start and End carets of a TextBlock, that will work. However, I am trying to do that for a Run. Using:
RunCP currentRun = runCaret->GetCurrentRunCP();
will get the Start of the Run, but there is no equivalent "runCaret->GetCurrentRunEndCP()". I'm using this instead:
CaretPtr nextRun = runCaret->Clone(); if ( SUCCESS != nextRun->MoveToNextRun() ) nextRun = textBlock->CreateEndCaret();
but I'm getting a "linefeed" included when the Run is the last Run in a Paragraph.