]> git.lyx.org Git - lyx.git/blob - src/lyxrow_funcs.C
Fix event loop to no longer eat CPU
[lyx.git] / src / lyxrow_funcs.C
1 /**
2  * \file lyxrow_funcs.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "lyxrow_funcs.h"
15 #include "debug.h"
16 #include "lyxlayout.h"
17 #include "lyxrow.h"
18 #include "paragraph.h"
19
20 using lyx::pos_type;
21
22
23 bool hfillExpansion(Paragraph const & par, Row const & row, pos_type pos)
24 {
25         if (!par.isHfill(pos))
26                 return false;
27
28         // at the end of a row it does not count
29         // unless another hfill exists on the line
30         if (pos >= row.endpos()) {
31                 for (pos_type i = row.pos(); i < pos && !par.isHfill(i); ++i)
32                         return false;
33         }
34
35         // at the beginning of a row it does not count, if it is not
36         // the first row of a paragaph
37         if (row.pos() == 0)
38                 return true;
39
40         // in some labels it does not count
41         if (par.layout()->margintype != MARGIN_MANUAL
42             && pos < par.beginOfBody())
43                 return false;
44
45         // if there is anything between the first char of the row and
46         // the specified position that is not a newline and not a hfill,
47         // the hfill will count, otherwise not
48         pos_type i = row.pos();
49         while (i < pos && (par.isNewline(i) || par.isHfill(i)))
50                 ++i;
51
52         return i != pos;
53 }