RichViewEdit.InsertText at the start of a paragraph

General TRichView support forum. Please post your questions here
Post Reply
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

I am sorting out a situation where I need to do an InsertText at the start of a Paragraph with a space or narrow-width space. After much testing the space or narrow-width space doesn't seem to matter in affecting this.

What happens is that Insert text seems to take over the same line (not whole paragraph) text with the Paragraph Style not the Font style.
Here is the scenario:
1. Delete text at the start of the paragraph using
RichViewEditClean.SetSelectionBounds(rsiNo, rsiOffs, ereiNo, ereiOffs);
RichViewEditClean.DeleteSelection; //This does not actually matter (I've tested it without this)
2. Insert Text
RichViewEditClean.InsertText(' ', True);
3. I insert a checkpint next but this does not seem to affect either if removed
4. Now this line has the paragraph style after the InsertText not the font style.

So a minimal scenario to repeat:
RichViewEditClean.SetSelectionBounds(rsiNo, rsiOffs, ereiNo, ereiOffs); //Make sure it is at the start of a paragraph.
RichViewEditClean.InsertText(' ', True);
//Now the rest of that line changes to Paragraph style.
How can I make it so that Font style is used instead of Paragraph Style in InsertText
Sergey Tkachenko
Site Admin
Posts: 17555
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: RichViewEdit.InsertText at the start of a paragraph

Post by Sergey Tkachenko »

Sorry, I do not understand what's the problem. Is the space is inserted using unexpected text style?
It must use RichViewEdit.CurTextStyleNo at the moment of insertion.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

That is what I am expecting as well but it appears that since it is at the start of a paragraph that it is more like the paragraph style instead of current text style.
So the paragraph style in this case is not bolded. The text style is bolded. But if I insert the space at the start now the line of text becomes not bolded. I am not sure if it is relates to styles, or what. I can send the program and a small example to see what is going on.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

I have noted if I put a manual space at the start of a paragraph so when InsertText is ran it is the second character in that gets InsertText then it works fine. It appears to only be at the start of a paragraph/line. Note I transfer between two different RichViewEdits with the same RVStyle component. I'm also trying with a different RVStyle component doesn't seem to matter.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

The first line with InsertText space seems to work right but then the line immediately following it seems to have this loss of formatting.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

We are beginning to wonder if there is something with this specific document we are working on like the styles that it converted over from docx are odd.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

Here is a portion that demonstrates the problem
Attachments
TESTE22xploring The Bible - 1 and 2 Thessalonians - Build.rtf
(10.27 KiB) Downloaded 1226 times
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

A connected way to try this: Try the attached document above in ActionTest in the Lazarus demo. Note that when you click a format it does not really update unless you clear the format first then it will update to the correct format.


And found out a fix: rvstimIgnoreSourceStyleTemplates it is not a complete fix but the Styles are messing things up somehow.
jgkoehn
Posts: 303
Joined: Thu Feb 20, 2020 9:32 pm

Re: RichViewEdit.InsertText at the start of a paragraph

Post by jgkoehn »

So one small addition: The program we convert to also uses RichViewEdit so perhaps if they use IgnoreStyles this could be the reason in the end. So sorry for all this crazy
Post Reply