mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
code cleanup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2890 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
873de089f0
commit
c804ecd29a
@ -1,3 +1,21 @@
|
||||
2001-10-16 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* text2.C (setCursorFromCoordinates): use Paragraph::size_type
|
||||
|
||||
* lyxtext.h: change type of refresh_pos to Paragraph::size_type;
|
||||
change return type of getColumnNearX.
|
||||
|
||||
|
||||
* text.C (changeRegionCase): use uppercase/lowercase instead of
|
||||
toupper/tolower.
|
||||
(leftMargin):
|
||||
(rightMargin): simplify code by factoring out the uses of
|
||||
textclasslist.
|
||||
(labelFill):
|
||||
(numberOfHfills):
|
||||
(setHeightOfRow):
|
||||
(appendParagraph): use Paragraph::size_type
|
||||
|
||||
2001-10-15 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* vspace.C (asLatexString): add a missing break
|
||||
|
@ -194,7 +194,7 @@ public:
|
||||
///
|
||||
mutable Row * refresh_row;
|
||||
///
|
||||
int refresh_pos;
|
||||
Paragraph::size_type refresh_pos;
|
||||
|
||||
/// give and set the LyXText status
|
||||
text_status status() const;
|
||||
@ -217,7 +217,7 @@ public:
|
||||
/** returns the column near the specified x-coordinate of the row
|
||||
x is set to the real beginning of this column
|
||||
*/
|
||||
int getColumnNearX(BufferView *, Row * row,
|
||||
Paragraph::size_type getColumnNearX(BufferView *, Row * row,
|
||||
int & x, bool & boundary) const;
|
||||
|
||||
/** returns a pointer to a specified row. y is set to the beginning
|
||||
|
101
src/text.C
101
src/text.C
@ -9,8 +9,8 @@
|
||||
* ====================================================== */
|
||||
|
||||
#include <config.h>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
//#include <cstdlib> //these two do not seem useful anymore (JMarc)
|
||||
//#include <cctype>
|
||||
#include <algorithm>
|
||||
|
||||
#include "lyxtext.h"
|
||||
@ -595,20 +595,15 @@ void LyXText::draw(BufferView * bview, Row const * row,
|
||||
// exactly the label-width.
|
||||
int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(bview->buffer()->params.textclass,
|
||||
row->par()->getLayout());
|
||||
LyXTextClass const & tclass =
|
||||
textclasslist.TextClass(bview->buffer()->params.textclass);
|
||||
LyXLayout const & layout = tclass[row->par()->getLayout()];
|
||||
|
||||
string parindent = layout.parindent;
|
||||
|
||||
int x = LYX_PAPER_MARGIN;
|
||||
|
||||
x += lyxfont::signedWidth(textclasslist
|
||||
.TextClass(bview->buffer()->params.textclass)
|
||||
.leftmargin(),
|
||||
textclasslist
|
||||
.TextClass(bview->buffer()->params.textclass)
|
||||
.defaultfont());
|
||||
x += lyxfont::signedWidth(tclass.leftmargin(), tclass.defaultfont());
|
||||
|
||||
// this is the way, LyX handles the LaTeX-Environments.
|
||||
// I have had this idea very late, so it seems to be a
|
||||
@ -620,9 +615,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
Paragraph * newpar = row->par()
|
||||
->depthHook(row->par()->getDepth());
|
||||
if (newpar &&
|
||||
textclasslist.Style(bview->buffer()->params.textclass,
|
||||
newpar->getLayout())
|
||||
.nextnoindent)
|
||||
tclass[newpar->getLayout()].nextnoindent)
|
||||
parindent.erase();
|
||||
}
|
||||
}
|
||||
@ -636,9 +629,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
|
||||
// check wether it is a sufficent paragraph
|
||||
if (newpar
|
||||
&& textclasslist
|
||||
.Style(bview->buffer()->params.textclass,
|
||||
newpar->getLayout()).isEnvironment()) {
|
||||
&& tclass[newpar->getLayout()].isEnvironment()) {
|
||||
Row dummyrow;
|
||||
dummyrow.par(newpar);
|
||||
dummyrow.pos(newpar->size());
|
||||
@ -655,9 +646,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
if (newpar->params().noindent())
|
||||
parindent.erase();
|
||||
else
|
||||
parindent = textclasslist
|
||||
.Style(bview->buffer()->params.textclass,
|
||||
newpar->getLayout()).parindent;
|
||||
parindent = tclass[newpar->getLayout()].parindent;
|
||||
}
|
||||
|
||||
}
|
||||
@ -667,10 +656,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
case MARGIN_DYNAMIC:
|
||||
if (!layout.leftmargin.empty()) {
|
||||
x += lyxfont::signedWidth(layout.leftmargin,
|
||||
textclasslist
|
||||
.TextClass(bview->buffer()->params.
|
||||
textclass)
|
||||
.defaultfont());
|
||||
tclass.defaultfont());
|
||||
}
|
||||
if (!row->par()->getLabelstring().empty()) {
|
||||
x += lyxfont::signedWidth(layout.labelindent,
|
||||
@ -691,7 +677,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
}
|
||||
break;
|
||||
case MARGIN_STATIC:
|
||||
x += lyxfont::signedWidth(layout.leftmargin, textclasslist.TextClass(bview->buffer()->params.textclass).defaultfont()) * 4
|
||||
x += lyxfont::signedWidth(layout.leftmargin, tclass.defaultfont()) * 4
|
||||
/ (row->par()->getDepth() + 4);
|
||||
break;
|
||||
case MARGIN_FIRST_DYNAMIC:
|
||||
@ -743,15 +729,13 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
}
|
||||
|
||||
x += lyxfont::signedWidth(layout.leftmargin,
|
||||
textclasslist
|
||||
.TextClass(bview->buffer()->params.textclass)
|
||||
.defaultfont());
|
||||
tclass.defaultfont());
|
||||
x += minfill;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
int align; // wrong type
|
||||
LyXAlignment align; // wrong type
|
||||
|
||||
if (row->par()->params().align() == LYX_ALIGN_LAYOUT)
|
||||
align = layout.align;
|
||||
@ -772,16 +756,10 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
bview->buffer()->params.paragraph_separation ==
|
||||
BufferParams::PARSEP_INDENT))
|
||||
x += lyxfont::signedWidth(parindent,
|
||||
textclasslist
|
||||
.TextClass(bview->buffer()->params
|
||||
.textclass)
|
||||
.defaultfont());
|
||||
tclass.defaultfont());
|
||||
else if (layout.labeltype == LABEL_BIBLIO) {
|
||||
// ale970405 Right width for bibitems
|
||||
x += bibitemMaxWidth(bview,textclasslist
|
||||
.TextClass(bview->buffer()->params
|
||||
.textclass)
|
||||
.defaultfont());
|
||||
x += bibitemMaxWidth(bview, tclass.defaultfont());
|
||||
}
|
||||
}
|
||||
return x;
|
||||
@ -790,17 +768,13 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
|
||||
int LyXText::rightMargin(Buffer const * buf, Row const * row) const
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass,
|
||||
row->par()->getLayout());
|
||||
LyXTextClass const & tclass =
|
||||
textclasslist.TextClass(buf->params.textclass);
|
||||
LyXLayout const & layout = tclass[row->par()->getLayout()];
|
||||
|
||||
int x = LYX_PAPER_MARGIN
|
||||
+ lyxfont::signedWidth(textclasslist
|
||||
.TextClass(buf->params.textclass)
|
||||
.rightmargin(),
|
||||
textclasslist
|
||||
.TextClass(buf->params.textclass)
|
||||
.defaultfont());
|
||||
+ lyxfont::signedWidth(tclass.rightmargin(),
|
||||
tclass.defaultfont());
|
||||
|
||||
// this is the way, LyX handles the LaTeX-Environments.
|
||||
// I have had this idea very late, so it seems to be a
|
||||
@ -819,9 +793,7 @@ int LyXText::rightMargin(Buffer const * buf, Row const * row) const
|
||||
|
||||
// check wether it is a sufficent paragraph
|
||||
if (newpar
|
||||
&& textclasslist.Style(buf->params.textclass,
|
||||
newpar->getLayout())
|
||||
.isEnvironment()) {
|
||||
&& tclass[newpar->getLayout()].isEnvironment()) {
|
||||
Row dummyrow;
|
||||
dummyrow.par(newpar);
|
||||
dummyrow.pos(0);
|
||||
@ -836,10 +808,8 @@ int LyXText::rightMargin(Buffer const * buf, Row const * row) const
|
||||
}
|
||||
|
||||
//lyxerr << "rightmargin: " << layout->rightmargin << endl;
|
||||
x += lyxfont::signedWidth(layout.rightmargin, textclasslist
|
||||
.TextClass(buf->params.textclass)
|
||||
.defaultfont()) * 4 / (row->par()->getDepth()
|
||||
+ 4);
|
||||
x += lyxfont::signedWidth(layout.rightmargin, tclass.defaultfont())
|
||||
* 4 / (row->par()->getDepth() + 4);
|
||||
return x;
|
||||
}
|
||||
|
||||
@ -881,7 +851,8 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
|
||||
Paragraph::size_type const main_body =
|
||||
beginningOfMainBody(bview->buffer(), par);
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(bview->buffer()->params.textclass, par->getLayout());
|
||||
textclasslist.Style(bview->buffer()->params.textclass,
|
||||
par->getLayout());
|
||||
Paragraph::size_type i = pos;
|
||||
|
||||
if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
|
||||
@ -1053,7 +1024,7 @@ int LyXText::labelFill(BufferView * bview, Row const * row) const
|
||||
--last;
|
||||
|
||||
int w = 0;
|
||||
int i = row->pos();
|
||||
Paragraph::size_type i = row->pos();
|
||||
while (i <= last) {
|
||||
w += singleWidth(bview, row->par(), i);
|
||||
++i;
|
||||
@ -1102,7 +1073,8 @@ int LyXText::numberOfHfills(Buffer const * buf, Row const * row) const
|
||||
|
||||
first = max(first, beginningOfMainBody(buf, row->par()));
|
||||
int n = 0;
|
||||
for (int p = first; p <= last; ++p) { // last, because the end is ignored!
|
||||
for (Paragraph::size_type p = first; p <= last; ++p) {
|
||||
// last, because the end is ignored!
|
||||
if (row->par()->isHfill(p)) {
|
||||
++n;
|
||||
}
|
||||
@ -1233,12 +1205,12 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
int maxdesc = int(lyxfont::maxDescent(font) *
|
||||
layout.spacing.getValue() *
|
||||
spacing_val);
|
||||
int const pos_end = rowLast(row_ptr);
|
||||
Paragraph::size_type const pos_end = rowLast(row_ptr);
|
||||
int labeladdon = 0;
|
||||
int maxwidth = 0;
|
||||
|
||||
// Check if any insets are larger
|
||||
for (int pos = row_ptr->pos(); pos <= pos_end; ++pos) {
|
||||
for (Paragraph::size_type pos = row_ptr->pos(); pos <= pos_end; ++pos) {
|
||||
if (row_ptr->par()->getChar(pos) == Paragraph::META_INSET) {
|
||||
tmpfont = getFont(bview->buffer(), row_ptr->par(), pos);
|
||||
tmpinset = row_ptr->par()->getInset(pos);
|
||||
@ -1506,10 +1478,10 @@ void LyXText::appendParagraph(BufferView * bview, Row * row) const
|
||||
|
||||
// The last character position of a paragraph is an invariant so we can
|
||||
// safely get it here. (Asger)
|
||||
int const lastposition = row->par()->size();
|
||||
Paragraph::size_type const lastposition = row->par()->size();
|
||||
do {
|
||||
// Get the next breakpoint
|
||||
int z = nextBreakPoint(bview, row, workWidth(bview));
|
||||
Paragraph::size_type z = nextBreakPoint(bview, row, workWidth(bview));
|
||||
|
||||
Row * tmprow = row;
|
||||
|
||||
@ -2505,14 +2477,14 @@ void LyXText::changeRegionCase(BufferView * bview,
|
||||
if (!IsInsetChar(c) && !IsHfillChar(c)) {
|
||||
switch (action) {
|
||||
case text_lowercase:
|
||||
c = tolower(c);
|
||||
c = lowercase(c);
|
||||
break;
|
||||
case text_capitalization:
|
||||
c = toupper(c);
|
||||
c = uppercase(c);
|
||||
action = text_lowercase;
|
||||
break;
|
||||
case text_uppercase:
|
||||
c = toupper(c);
|
||||
c = uppercase(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3567,7 +3539,8 @@ int LyXText::defaultHeight() const
|
||||
|
||||
/* returns the column near the specified x-coordinate of the row
|
||||
* x is set to the real beginning of this column */
|
||||
int LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
Paragraph::size_type
|
||||
LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
bool & boundary) const
|
||||
{
|
||||
float tmpx = 0.0;
|
||||
|
11
src/text2.C
11
src/text2.C
@ -1760,16 +1760,16 @@ void LyXText::cutSelection(BufferView * bview, bool doclear, bool realcut)
|
||||
int pos = selection.end.pos();
|
||||
CutAndPaste::cutSelection(selection.start.par(), &endpar,
|
||||
selection.start.pos(), pos,
|
||||
bview->buffer()->params.textclass, doclear,
|
||||
realcut);
|
||||
bview->buffer()->params.textclass,
|
||||
doclear, realcut);
|
||||
selection.end.pos(pos);
|
||||
} else {
|
||||
endpar = selection.end.par();
|
||||
int pos = selection.end.pos();
|
||||
CutAndPaste::cutSelection(selection.start.par(), &endpar,
|
||||
selection.start.pos(), pos,
|
||||
bview->buffer()->params.textclass, doclear,
|
||||
realcut);
|
||||
bview->buffer()->params.textclass,
|
||||
doclear, realcut);
|
||||
cursor.par(endpar);
|
||||
selection.end.par(endpar);
|
||||
selection.end.pos(pos);
|
||||
@ -2273,7 +2273,8 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, LyXCursor & cur,
|
||||
|
||||
Row * row = getRowNearY(y);
|
||||
bool bound = false;
|
||||
int const column = getColumnNearX(bview, row, x, bound);
|
||||
Paragraph::size_type const column = getColumnNearX(bview, row, x,
|
||||
bound);
|
||||
|
||||
cur.par(row->par());
|
||||
cur.pos(row->pos() + column);
|
||||
|
Loading…
Reference in New Issue
Block a user