WPCubed Product Support

Tabstops

I have to interrelated questions regarding tab stops.

A) There are a number of methods in TWPTextStyle that deal with tab stops, but I can not find a method to determine the number of tabs that have been entered at the start of a given paragraph. Is there a way to determine whether tabs have been placed at the front of a paragraph and if so how many?

b) If I capture the first character of a paragraph that has a single implemented tab stop, it does not display a character, But it also does not appear to be blank. In the following example, evaluating the value copied from the first character location of the paragraph does not display a value, but it also does not evaluate as blank. In the following demo, the first showmessage displays no value, but the second showmessage does not execute

var
tempString1: String;
tempString2: String;

tempString1 := tempParagraph.GetText;
tempString2 := Copy(tempString1, 1, 1);

showmessage(tempIndentString);

if tempIndentString1 = ' ' then
showmessage('Test = True');

From the above, it would appear that the first character location of the paragraph that contains a tab contains some non visual character to represent the tab itself. How can I evaluate that first character location to determine whether it is a tab?

TIA

John

#1 ♥ 0
5.8k Views 2 users read 3 min
support

Hi,

You can use

a)

TabstopGet(nr: Integer; var Value: Integer; var Kind: TTabKind; var FillMode: TTabFill; var
FillColor: Integer);

to read all tabs. In case nr is larger than the count of tabs Value will remain unchanged to 0.

b)

As usual tabs are implemented using the #9 character - that needs to be trimmed before you can use Copy(tempString1, 1, 1);

Julian

#2 ♥ 0

Julian

I am now questioning basic functionality.

If I set ViewOptions.wsShowTab := True and iterate through three paragraphs. The second of which has a tab at the start of the paragraph and (which can be seen visually via the displayed arrow) the tab count for all three paragraphs is 0. I would have expected the tab count for the second paragraph to be 1. (See code below)

Am I confusing the number of tabs as defined in a style and the actual presence of one or more tabs in a paragraph?

Do I need to examine the control characters of a paragraph to count the number of times #9 occures. If so, how do I actually examine in code the control characters associated with a paragraph?

var
  tempParagraph: TParagraph;
  I: Integer;
begin
      with WPRichText1 do
        begin
          tempParagraph := FirstPar;
          I := 1;
          while tempParagraph <> nil do
            begin
              if tempParagraph.ContainsText = True then
                begin
                   showmessage('Paragraph Number = ' + IntToStr(I) + #13 +
'Tab Stop Count = ' + IntToStr(tempParagraph.TabstopCount));

                   I := I + 1;
                end;
           end; 
    end;

I appreciate your efforts in this matter and apologize for my confusion.

John

#3 ♥ 0
support

Hi,

please do not confuse the count of tab characters with the count of defined tabstop positions in a paragraph.

To work with the tab characters simply access CharItem[i] with i:=0 to CharCount-1

#4 ♥ 0
This category is archived. No new posts are possible.