summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-pangoattriter.xml
blob: e82b51e57fc8762cda206aa311ae75ccb3178dd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-pangoattriterator">
  <refnamediv>
    <refname>pango.AttrIterator</refname>
    <refpurpose>an object pointing to a location in a <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>.</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>pango.AttrIterator</classname></ooclass>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangoattriterator--copy">copy</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangoattriterator--range">range</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangoattriterator--next">next</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangoattriterator--get">get</link></methodname>
	<methodparam><parameter
		       role="keyword">type</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangoattriterator--get-font">get_font</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangoattriterator--get-attrs">get_attrs</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>

    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>The <link
linkend="class-pangoattriterator"><classname>pango.AttrIterator</classname></link> 
object contains a pointer into a <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>.
A <link
linkend="class-pangoattriterator"><classname>pango.AttrIterator</classname></link> 
object is created using the <link
linkend="method-pangoattrlist--get-iterator"><methodname>pango.AttrList.get_iterator</methodname>()</link> 
method and then can be advanced through the attribute changes in the text
using the <link
linkend="method-pangoattriterator--next"><methodname>next</methodname>()</link> 
method. The <link
linkend="class-pangoattriterator"><classname>pango.AttrIterator</classname></link> 
object can access information about the current attributes applied at the
iterator location (using the <link
linkend="method-pangoattriterator--get"><methodname>get</methodname>()</link> 
method) and the range of text that the current attribute change applies to
(using the <link
linkend="method-pangoattriterator--range"><methodname>range</methodname>()</link> 
method).</para>

    <para>The <link
linkend="class-pangoattriterator"><classname>pango.AttrIterator</classname></link> 
object is only valid as long as the associated <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>
is not changed.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-pangoattriterator--copy">
      <title>pango.AttrIterator.copy</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>copy</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a new <link
linkend="class-pangoattriterator"><classname>pango.AttrIterator</classname></link> 
object</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>copy</methodname>() method returns a new <link
linkend="class-pangoattriterator"><classname>pango.AttrIterator</classname></link> 
object that is a copy of this attribute iterator.</para>

    </refsect2>

    <refsect2 id="method-pangoattriterator--range">
      <title>pango.AttrIterator.range</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>range</methodname>
	  <methodparam></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 2-tuple containing the start and end index of
the current attribute in the text.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>range</methodname>() method returns a 2-tuple
containing the start and end index of the application of the current
attribute change in the text.</para>

    </refsect2>

    <refsect2 id="method-pangoattriterator--next">
      <title>pango.AttrIterator.next</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>next</methodname>
	  <methodparam></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>False</literal> if the iterator is at
the end of the <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>next</methodname>() method advances the iterator
to the next attribute change in its <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>.
The <methodname>next</methodname> method returns <literal>False</literal> if
the iterator is at the end of the <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>;
otherwise, <literal>True</literal>. </para>

    </refsect2>

    <refsect2 id="method-pangoattriterator--get">
      <title>pango.AttrIterator.get</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get</methodname>
	  <methodparam><parameter
			 role="keyword">type</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">type</parameter>&nbsp;:</term>
	  <listitem><simpara>the <link
linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
type to find.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the <link
linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
matching type or <literal>None</literal>.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get</methodname>() method returns the <link
linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
at the iterator location that matches the specified
<parameter>type</parameter>. When multiple attributes of the same type
overlap, the attribute whose range starts closest to the current location is
returned. If no attribute matches, <literal>None</literal> is
returned.</para>

    </refsect2>

    <refsect2 id="method-pangoattriterator--get-font">
      <title>pango.AttrIterator.get_font</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_font</methodname>
	  <methodparam></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 3-tuple containing a <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link>, 
a <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
and a list of non-font <link
linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
objects at the current iterator location.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_font</methodname>() method returns a 3-tuple
containing a <link
linkend="class-pangofontdescription"><classname>pango.FontDescription</classname></link> 
holding the current font attributes, a <link
linkend="class-pangolanguage"><classname>pango.Language</classname></link>
object (if a language is set) or <literal>None</literal> and a list of
non-font <link
linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
objects in effect at the current iterator location.</para>

    </refsect2>

    <refsect2 id="method-pangoattriterator--get-attrs">
      <title>pango.AttrIterator.get_attrs</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_attrs</methodname>
	  <methodparam></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a tuple containing the <link
	  linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
	  objects in effect at the current iterator
	  location.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_attrs</methodname>() method returns a tuple
containing the <link
linkend="class-pangoattribute"><classname>pango.Attribute</classname></link>
objects in effect at the current iterator location.</para>

    </refsect2>

  </refsect1>

</refentry>