#include "font.h"
#include "encoding.h"
#include "lyxscreen.h"
+#include "bufferview_funcs.h"
using std::max;
using std::min;
unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
- if (!Encoding::is_arabic(c))
+ if (!Encodings::is_arabic(c))
if (lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 && isdigit(c))
return c + (0xb0 - '0');
else
return c;
- unsigned char prev_char = pos > 0 ? par->GetChar(pos-1) : ' ';
+ unsigned char const prev_char = pos > 0 ? par->GetChar(pos-1) : ' ';
unsigned char next_char = ' ';
for (LyXParagraph::size_type i = pos+1; i < par->Last(); ++i)
- if (!Encoding::IsComposeChar_arabic(par->GetChar(i))) {
+ if (!Encodings::IsComposeChar_arabic(par->GetChar(i))) {
next_char = par->GetChar(i);
break;
}
- if (Encoding::is_arabic(next_char)) {
- if (Encoding::is_arabic(prev_char))
- return Encoding::TransformChar(c, Encoding::FORM_MEDIAL);
+ if (Encodings::is_arabic(next_char)) {
+ if (Encodings::is_arabic(prev_char))
+ return Encodings::TransformChar(c, Encodings::FORM_MEDIAL);
else
- return Encoding::TransformChar(c, Encoding::FORM_INITIAL);
+ return Encodings::TransformChar(c, Encodings::FORM_INITIAL);
} else {
- if (Encoding::is_arabic(prev_char))
- return Encoding::TransformChar(c, Encoding::FORM_FINAL);
+ if (Encodings::is_arabic(prev_char))
+ return Encodings::TransformChar(c, Encodings::FORM_FINAL);
else
- return Encoding::TransformChar(c, Encoding::FORM_ISOLATED);
+ return Encodings::TransformChar(c, Encodings::FORM_ISOLATED);
}
}
if (font.language()->lang() == "arabic" &&
(lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
lyxrc.font_norm_type == LyXRC::ISO_10646_1))
- if (Encoding::IsComposeChar_arabic(c))
+ if (Encodings::IsComposeChar_arabic(c))
return 0;
else
c = TransformChar(c, par, pos);
else if (font.language()->lang() == "hebrew" &&
- Encoding::IsComposeChar_hebrew(c))
+ Encodings::IsComposeChar_hebrew(c))
return 0;
}
return lyxfont::width(c, font);
LyXParagraph::size_type LyXText::RowLastPrintable(Row const * row) const
{
- LyXParagraph::size_type last = RowLast(row);
+ LyXParagraph::size_type const last = RowLast(row);
if (last >= row->pos()
&& row->next()
&& row->next()->par() == row->par()
log2vis_list[bidi_end + 1 - bidi_start] = -1;
LyXParagraph::size_type stack[2];
- bool rtl_par = row->par()->getParLanguage(buf->params)->RightToLeft();
+ bool const rtl_par =
+ row->par()->getParLanguage(buf->params)->RightToLeft();
int level = 0;
bool rtl = false;
bool rtl0 = false;
- LyXParagraph::size_type main_body = BeginningOfMainBody(buf, row->par());
+ LyXParagraph::size_type const main_body =
+ BeginningOfMainBody(buf, row->par());
for (LyXParagraph::size_type lpos = bidi_start;
lpos <= bidi_end; ++lpos) {
bool is_space = row->par()->IsLineSeparator(lpos);
- LyXParagraph::size_type pos =
+ LyXParagraph::size_type const pos =
(is_space && lpos + 1 <= bidi_end &&
!row->par()->IsLineSeparator(lpos + 1) &&
!row->par()->IsNewline(lpos + 1))
? lpos + 1 : lpos;
LyXFont font = row->par()->GetFontSettings(buf->params, pos);
+ if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
+ font.number() == LyXFont::ON &&
+ row->par()->GetFontSettings(buf->params, lpos-1).number()
+ == LyXFont::ON) {
+ font = row->par()->GetFontSettings(buf->params, lpos);
+ is_space = false;
+ }
+
+
bool new_rtl = font.isVisibleRightToLeft();
bool new_rtl0 = font.isRightToLeft();
int new_level;
if (lpos == main_body - 1
&& row->pos() < main_body - 1
- && row->par()->IsLineSeparator(lpos)) {
+ && is_space) {
new_level = (rtl_par) ? 1 : 0;
new_rtl = new_rtl0 = rtl_par;
} else if (new_rtl0)
}
while (level > 0) {
- LyXParagraph::size_type old_lpos = stack[--level];
+ LyXParagraph::size_type const old_lpos = stack[--level];
int delta = bidi_end - old_lpos;
if (level % 2)
delta = -delta;
bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
- if (!lyxrc.rtl_support)
- return false; // This is just for speedup
+ if (!lyxrc.rtl_support || pos == 0)
+ return false;
- if (!bidi_InRange(pos - 1))
+ if (!bidi_InRange(pos - 1)) {
+ lyxerr << "LyXText::IsBoundary This shouldn't happen." << endl;
return false;
+ }
bool const rtl = bidi_level(pos - 1) % 2;
- bool rtl2 = rtl;
- if (pos == par->Last())
- rtl2 = par->isRightToLeftPar(buf->params);
- else if (bidi_InRange(pos))
- rtl2 = bidi_level(pos) % 2;
+ bool rtl2 = bidi_InRange(pos)
+ ? bidi_level(pos) % 2
+ : par->isRightToLeftPar(buf->params);
return rtl != rtl2;
}
return false; // This is just for speedup
bool const rtl = font.isVisibleRightToLeft();
- bool rtl2 = rtl;
- if (pos == par->Last())
- rtl2 = par->isRightToLeftPar(buf->params);
- else if (bidi_InRange(pos))
- rtl2 = bidi_level(pos) % 2;
+ bool rtl2 = bidi_InRange(pos)
+ ? bidi_level(pos) % 2
+ : par->isRightToLeftPar(buf->params);
return rtl != rtl2;
}
if (IsNewlineChar(c)) {
++vpos;
// Draw end-of-line marker
- LyXFont font = GetFont(bview->buffer(), row->par(), pos);
- int wid = lyxfont::width('n', font);
- int asc = lyxfont::maxAscent(font);
- int y = offset + row->baseline();
+ LyXFont const font = GetFont(bview->buffer(), row->par(), pos);
+ int const wid = lyxfont::width('n', font);
+ int const asc = lyxfont::maxAscent(font);
+ int const y = offset + row->baseline();
int xp[3], yp[3];
if (bidi_level(pos) % 2 == 0) {
font.decSize();
// calculate the position of the footnotemark
- int y = (row->baseline() - lyxfont::maxAscent(font2)
- + lyxfont::maxAscent(font));
+ int const y = (row->baseline() - lyxfont::maxAscent(font2)
+ + lyxfont::maxAscent(font));
font.setColor(LColor::footnote);
++vpos;
if (lyxrc.mark_foreign_language &&
- font.language()->lang() != "default" &&
- font.language() != bview->buffer()->params.language_info) {
- int y = offset + row->height() - 1;
+ font.language() != bview->buffer()->params.language) {
+ int const y = offset + row->height() - 1;
pain.line(int(tmpx), y, int(x), y,
LColor::language);
}
textstring = c;
++vpos;
- LyXParagraph::size_type last = RowLastPrintable(row);
+ LyXParagraph::size_type const last = RowLastPrintable(row);
if (font.language()->lang() == "hebrew") {
- if (Encoding::IsComposeChar_hebrew(c)) {
- int width = lyxfont::width(c, font2);
+ if (Encodings::IsComposeChar_hebrew(c)) {
+ int const width = lyxfont::width(c, font2);
int dx = 0;
for (LyXParagraph::size_type i = pos-1; i >= 0; --i) {
c = row->par()->GetChar(i);
- if (!Encoding::IsComposeChar_hebrew(c)) {
+ if (!Encodings::IsComposeChar_hebrew(c)) {
if (IsPrintableNonspace(c)) {
- int width2 = SingleWidth(bview, row->par(), i, c);
+ int const width2 =
+ SingleWidth(bview,
+ row->par(),
+ i, c);
dx = (c == 'ø' || c == 'ã') // dalet / resh
? width2 - width : (width2 - width) / 2;
}
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& IsPrintableNonspace(c = row->par()->GetChar(pos))
- && !Encoding::IsComposeChar_hebrew(c)
+ && !Encodings::IsComposeChar_hebrew(c)
&& font2 == GetFont(bview->buffer(), row->par(), pos)) {
textstring += c;
++vpos;
} else if (font.language()->lang() == "arabic" &&
(lyxrc.font_norm_type == LyXRC::ISO_8859_6_8 ||
lyxrc.font_norm_type == LyXRC::ISO_10646_1)) {
- if (Encoding::IsComposeChar_arabic(c)) {
+ if (Encodings::IsComposeChar_arabic(c)) {
c = TransformChar(c, row->par(), pos);
textstring = c;
- int width = lyxfont::width(c, font2);
+ int const width = lyxfont::width(c, font2);
int dx = 0;
for (LyXParagraph::size_type i = pos-1; i >= 0; --i) {
c = row->par()->GetChar(i);
- if (!Encoding::IsComposeChar_arabic(c)) {
+ if (!Encodings::IsComposeChar_arabic(c)) {
if (IsPrintableNonspace(c)) {
- int width2 = SingleWidth(bview, row->par(), i, c);
+ int const width2 =
+ SingleWidth(bview,
+ row->par(),
+ i, c);
dx = (width2 - width) / 2;
}
break;
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& IsPrintableNonspace(c = row->par()->GetChar(pos))
- && !Encoding::IsComposeChar_arabic(c)
+ && !Encodings::IsComposeChar_arabic(c)
&& font2 == GetFont(bview->buffer(), row->par(), pos)) {
c = TransformChar(c, row->par(), pos);
textstring += c;
}
if (lyxrc.mark_foreign_language &&
- font.language()->lang() != "default" &&
- font.language() != bview->buffer()->params.language_info) {
- int y = offset + row->height() - 1;
+ font.language() != bview->buffer()->params.language) {
+ int const y = offset + row->height() - 1;
pain.line(int(tmpx), y, int(x), y,
LColor::language);
}
}
-int LyXText::LabelEnd (BufferView * bview, Row const * row) const
+int LyXText::LabelEnd(BufferView * bview, Row const * row) const
{
if (textclasslist.Style(bview->buffer()->params.textclass,
row->par()->GetLayout()).margintype
LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const
{
LyXParagraph * par = row->par();
- LyXParagraph::size_type pos = row->pos();
if (width < 0)
return par->Last();
+ LyXParagraph::size_type const pos = row->pos();
+
+
// position of the last possible breakpoint
// -1 isn't a suitable value, but a flag
LyXParagraph::size_type last_separator = -1;
width -= RightMargin(bview->buffer(), row);
- LyXParagraph::size_type main_body = BeginningOfMainBody(bview->buffer(), par);
+ LyXParagraph::size_type const main_body =
+ BeginningOfMainBody(bview->buffer(), par);
LyXLayout const & layout =
textclasslist.Style(bview->buffer()->params.textclass, par->GetLayout());
LyXParagraph::size_type i = pos;
bool doitonetime = true;
while (doitonetime || ((x < width) && (i < last))) {
doitonetime = false;
- char c = par->GetChar(i);
+ char const c = par->GetChar(i);
if (IsNewlineChar(c)) {
last_separator = i;
x = width; // this means break
// non-display
if (par->GetInset(i)->display() &&
(layout.isCommand() ||
- ((layout.labeltype == LABEL_MANUAL) &&
- (i < BeginningOfMainBody(bview->buffer(), par))))) {
+ (layout.labeltype == LABEL_MANUAL
+ && i < BeginningOfMainBody(bview->buffer(), par)))) {
// display istn't allowd
par->GetInset(i)->display(false);
x += SingleWidth(bview, par, i, c);
int w;
// get the pure distance
- LyXParagraph::size_type last = RowLastPrintable(row);
+ LyXParagraph::size_type const last = RowLastPrintable(row);
// special handling of the right address boxes
if (textclasslist.Style(bview->buffer()->params.textclass,
row->par()->GetLayout()).margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
- int tmpfill = row->fill();
+ int const tmpfill = row->fill();
row->fill(0); // the minfill in MarginLeft()
w = LeftMargin(bview, row);
row->fill(tmpfill);
LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass,
row->par()->GetLayout());
- LyXParagraph::size_type main_body =
+ LyXParagraph::size_type const main_body =
BeginningOfMainBody(bview->buffer(), row->par());
LyXParagraph::size_type i = row->pos();
w += lyxfont::width(layout.labelsep, GetFont(bview->buffer(), row->par(), -2));
if (last >= 0 && row->par()->IsLineSeparator(last))
w -= SingleWidth(bview, row->par(), last);
- int left_margin = LabelEnd(bview, row);
+ int const left_margin = LabelEnd(bview, row);
if (w < left_margin)
w = left_margin;
}
/* this must not happen before the currentrow for clear reasons.
so the trick is just to set the current row onto this row */
- long unused_y;
+ int unused_y;
GetRow(row_ptr->par(), row_ptr->pos(), unused_y);
/* ok , let us initialize the maxasc and maxdesc value.
firstpar->GetLayout());
LyXFont font = GetFont(bview->buffer(), par, par->Last() - 1);
- LyXFont::FONT_SIZE size = font.size();
+ LyXFont::FONT_SIZE const size = font.size();
font = GetFont(bview->buffer(), par, -1);
font.setSize(size);
int maxdesc = int(lyxfont::maxDescent(font) *
layout.spacing.getValue() *
spacing_val);
- int pos_end = RowLast(row_ptr);
+ int const pos_end = RowLast(row_ptr);
int labeladdon = 0;
int maxwidth = 0;
// Check if any custom fonts are larger (Asger)
// This is not completely correct, but we can live with the small,
// cosmetic error for now.
- LyXFont::FONT_SIZE maxsize =
+ LyXFont::FONT_SIZE const maxsize =
row_ptr->par()->HighestFontInRange(row_ptr->pos(),
pos_end);
if (maxsize > font.size()) {
LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview));
Row * tmprow = row;
- if (z < row->par()->Last() ) {
+ if (z < row->par()->Last()) {
if (!row->next() || (row->next() && row->next()->par() != row->par())) {
// insert a new row
++z;
LyXParagraph::size_type z = NextBreakPoint(bview, row, workWidth(bview));
Row * tmprow = row;
- if (z < row->par()->Last() ) {
+ if (z < row->par()->Last()) {
if (!row->next()
|| (row->next() && row->next()->par() != row->par())) {
/* insert a new row */
* move one row up!
* This touches only the screen-update. Otherwise we would may have
* an empty row on the screen */
- if (cursor.pos() && !cursor.row()->par()->IsNewline(cursor.row()->pos() - 1) &&
- cursor.row()->pos() == cursor.pos()) {
+ if (cursor.pos() && !cursor.row()->par()->IsNewline(cursor.row()->pos() - 1)
+ && cursor.row()->pos() == cursor.pos()) {
CursorLeft(bview);
}
// When the free-spacing option is set for the current layout,
// disable the double-space checking
- bool freeSpacing =
+ bool const freeSpacing =
textclasslist.Style(bview->buffer()->params.textclass,
cursor.row()->par()->GetLayout()).free_spacing;
+
+ if (lyxrc.auto_number) {
+ if (current_font.number() == LyXFont::ON) {
+ if (!isdigit(c) && !strchr("+-/*", c) &&
+ !(strchr(".,",c) &&
+ cursor.pos() >= 1 &&
+ cursor.pos() < cursor.par()->size() &&
+ GetFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos()).number() == LyXFont::ON &&
+ GetFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos()-1).number() == LyXFont::ON)
+ )
+ Number(bview); // Set current_font.number to OFF
+ } else if (isdigit(c) &&
+ real_current_font.isVisibleRightToLeft()) {
+ Number(bview); // Set current_font.number to ON
+
+ if (cursor.pos() > 0) {
+ char const c = cursor.par()->GetChar(cursor.pos() - 1);
+ if (strchr("+-",c) &&
+ (cursor.pos() == 1 ||
+ cursor.par()->IsSeparator(cursor.pos() - 2) ||
+ cursor.par()->IsNewline(cursor.pos() - 2) )
+ ) {
+ SetCharFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos() - 1,
+ current_font);
+ } else if (strchr(".,", c) &&
+ cursor.pos() >= 2 &&
+ GetFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos()-2).number() == LyXFont::ON) {
+ SetCharFont(bview->buffer(),
+ cursor.par(),
+ cursor.pos() - 1,
+ current_font);
+ }
+ }
+ }
+ }
+
+
/* First check, if there will be two blanks together or a blank at
the beginning of a paragraph.
I decided to handle blanks like normal characters, the main
* current font */
// Get the font that is used to calculate the baselineskip
- LyXParagraph::size_type lastpos = cursor.par()->Last();
+ LyXParagraph::size_type const lastpos = cursor.par()->Last();
LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params,
lastpos - 1);
// get the cursor row fist
Row * row = cursor.row();
- long y = cursor.y() - row->baseline();
+ int y = cursor.y() - row->baseline();
if (c != LyXParagraph::META_INSET) /* Here case LyXText::InsertInset
* already insertet the character */
cursor.par()->InsertChar(cursor.pos(), c);
LyXParagraph::size_type z = NextBreakPoint(bview,
row->previous(),
workWidth(bview));
- if ( z >= row->pos()) {
+ if (z >= row->pos()) {
row->pos(z + 1);
// set the dimensions of the row above
* will set fill to -1. Otherwise
* we would not get a rebreak! */
row->fill(Fill(bview, row, workWidth(bview)));
- if (row->fill() < 0 ) {
+ if (row->fill() < 0) {
refresh_y = y;
refresh_row = row;
refresh_x = cursor.x();
SetCursor(bview, cursor.par(), cursor.pos() + 1, false,
cursor.boundary());
+ if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos())
+ != cursor.boundary())
+ SetCursor(bview, cursor.par(), cursor.pos(), false,
+ !cursor.boundary());
if (row->next() && row->next()->par() == row->par())
need_break_row = row->next();
else
refresh_row = row;
refresh_pos = cursor.pos();
- int tmpheight = row->height();
+ int const tmpheight = row->height();
SetHeightOfRow(bview, row);
if (tmpheight == row->height())
status = LyXText::NEED_VERY_LITTLE_REFRESH;
fill_separator = 0;
fill_label_hfill = 0;
- bool is_rtl = row->par()->isRightToLeftPar(bview->buffer()->params);
+ bool const is_rtl =
+ row->par()->isRightToLeftPar(bview->buffer()->params);
#ifndef NEW_INSETS
if (is_rtl) {
if (row->par()->GetChar(row->pos()) == LyXParagraph::META_INSET
&& (inset=row->par()->GetInset(row->pos()))
&& (inset->display())) // || (inset->scroll() < 0)))
- align = LYX_ALIGN_CENTER;
+ align = (inset->LyxCode() == Inset::MATHMACRO_CODE)
+ ? LYX_ALIGN_BLOCK : LYX_ALIGN_CENTER;
switch (align) {
case LYX_ALIGN_BLOCK:
int steps = 0;
// Skip through initial nonword stuff.
- while ( tmpcursor.pos() < tmpcursor.par()->Last() &&
+ while (tmpcursor.pos() < tmpcursor.par()->Last() &&
! tmpcursor.par()->IsWord( tmpcursor.pos() ) )
{
// printf("Current pos1 %d", tmpcursor.pos()) ;
++steps;
}
// Advance through word.
- while ( tmpcursor.pos() < tmpcursor.par()->Last() &&
+ while (tmpcursor.pos() < tmpcursor.par()->Last() &&
tmpcursor.par()->IsWord( tmpcursor.pos() ) )
{
// printf("Current pos2 %d", tmpcursor.pos()) ;
void LyXText::SelectWord(BufferView * bview)
{
// Move cursor to the beginning, when not already there.
- if ( cursor.pos()
- && !cursor.par()->IsSeparator(cursor.pos()-1)
- && !cursor.par()->IsKomma(cursor.pos()-1) )
+ if (cursor.pos()
+ && !cursor.par()->IsSeparator(cursor.pos()-1)
+ && !cursor.par()->IsKomma(cursor.pos()-1) )
CursorLeftOneWord(bview);
// set the sel cursor
sel_cursor = cursor;
- while ( cursor.pos() < cursor.par()->Last()
- && !cursor.par()->IsSeparator(cursor.pos())
- && !cursor.par()->IsKomma(cursor.pos()) )
+ while (cursor.pos() < cursor.par()->Last()
+ && !cursor.par()->IsSeparator(cursor.pos())
+ && !cursor.par()->IsKomma(cursor.pos()) )
cursor.pos(cursor.pos() + 1);
SetCursor(bview, cursor.par(), cursor.pos() );
&& !cursor.par()->IsSeparator(cursor.pos())
&& !cursor.par()->IsKomma(cursor.pos())
&& !cursor.par()->IsSeparator(cursor.pos() -1)
- && !cursor.par()->IsKomma(cursor.pos() -1) ) {
+ && !cursor.par()->IsKomma(cursor.pos() -1)) {
SelectWord(bview);
return true;
}
// this is a very easy implementation
LyXCursor old_cursor = cursor;
- int old_cur_par_id = old_cursor.par()->id();
- int old_cur_par_prev_id = old_cursor.par()->previous ?
+ int const old_cur_par_id = old_cursor.par()->id();
+ int const old_cur_par_prev_id = old_cursor.par()->previous ?
old_cursor.par()->previous->id() : 0;
// just move to the right
CursorLeft(bview);
// the layout things can change the height of a row !
- int tmpheight = cursor.row()->height();
+ int const tmpheight = cursor.row()->height();
SetHeightOfRow(bview, cursor.row());
if (cursor.row()->height() != tmpheight) {
refresh_y = cursor.y() - cursor.row()->baseline();
}
Row * row = cursor.row();
- long y = cursor.y() - row->baseline();
+ int y = cursor.y() - row->baseline();
LyXParagraph::size_type z;
/* remember that a space at the end of a row doesnt count
* when calculating the fill */
if (row->previous() && row->previous()->par() == row->par()) {
z = NextBreakPoint(bview, row->previous(),
workWidth(bview));
- if ( z >= row->pos()) {
+ if (z >= row->pos()) {
row->pos(z + 1);
Row * tmprow = row->previous();
status = LyXText::NEED_MORE_REFRESH;
BreakAgainOneRow(bview, row);
+ // will the cursor be in another row now?
+ if (row->next() && row->next()->par() == row->par() &&
+ RowLast(row) <= cursor.pos()) {
+ row = row->next();
+ BreakAgainOneRow(bview, row);
+ }
+
SetCursor(bview, cursor.par(), cursor.pos(), false, cursor.boundary());
- // cursor MUST be in row now
-
- need_break_row = row->next();
+
+ if (row->next() && row->next()->par() == row->par())
+ need_break_row = row->next();
+ else
+ need_break_row = 0;
} else {
// set the dimensions of the row
row->fill(Fill(bview, row, workWidth(bview)));
- int tmpheight = row->height();
+ int const tmpheight = row->height();
SetHeightOfRow(bview, row);
if (tmpheight == row->height())
status = LyXText::NEED_VERY_LITTLE_REFRESH;
// current_font = rawtmpfont;
// real_current_font = realtmpfont;
+ if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos())
+ != cursor.boundary())
+ SetCursor(bview, cursor.par(), cursor.pos(), false,
+ !cursor.boundary());
+
lastpos = cursor.par()->Last();
- if (cursor.pos() == lastpos) {
- if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) != cursor.boundary())
- SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary());
+ if (cursor.pos() == lastpos)
SetCurrentFont(bview);
- }
- // check, wether the last characters font has changed.
+ // check, whether the last characters font has changed.
if (rawparfont !=
cursor.par()->GetFontSettings(bview->buffer()->params, lastpos - 1)) {
RedoHeightOfParagraph(bview, cursor);
void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
- Row * row_ptr, long y, bool cleared)
+ Row * row_ptr, int y, bool cleared)
{
/* returns a printed row */
Painter & pain = bview->painter();
- bool is_rtl = row_ptr->par()->isRightToLeftPar(bview->buffer()->params);
- LyXParagraph::size_type last = RowLastPrintable(row_ptr);
+ bool const is_rtl =
+ row_ptr->par()->isRightToLeftPar(bview->buffer()->params);
+
+ LyXParagraph::size_type const last = RowLastPrintable(row_ptr);
LyXParagraph::size_type vpos, pos;
float x;
bool clear_area = true;
Inset * inset = 0;
- if (!bview->screen()->forceClear() && (last == row_ptr->pos()) &&
- (row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) &&
- (inset = row_ptr->par()->GetInset(row_ptr->pos()))) {
+ if (!bview->screen()->forceClear() && last == row_ptr->pos()
+ && row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET
+ && (inset = row_ptr->par()->GetInset(row_ptr->pos()))) {
clear_area = inset->doClearArea();
}
// we don't need to clear it's already done!!!
if (cleared) {
clear_area = true;
} else if (clear_area) {
- int w = (inset_owner ? inset_owner->width(bview, font) : ww);
+#ifdef WITH_WARNINGS
+#warning Should be fixed with a lyxinset::clear_width(bv, font) function! (Jug)
+#endif
+ int const w = (inset_owner ?
+ inset_owner->width(bview, font)-2 : ww);
pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
} else if (inset != 0) {
int h = row_ptr->baseline() - inset->ascent(bview, font);
if (h > 0) {
- int w = (inset_owner ?
+ int const w = (inset_owner ?
inset_owner->width(bview, font) : ww);
pain.fillRectangle(x_offset, y_offset, w, h);
}
h += inset->ascent(bview, font) + inset->descent(bview, font);
if ((row_ptr->height() - h) > 0) {
- int w = (inset_owner ?
+ int const w = (inset_owner ?
inset_owner->width(bview, font) : ww);
- pain.fillRectangle(x_offset,y_offset+h, w, row_ptr->height()-h);
+ pain.fillRectangle(x_offset, y_offset + h,
+ w, row_ptr->height() - h);
}
if (!inset_owner && !inset->display() && !inset->needFullRow())
{
- int w = inset->width(bview, font) + int(x);
+ int const w = inset->width(bview, font) + int(x);
pain.fillRectangle(w, y_offset, ww - w, row_ptr->height());
}
}
if (selection) {
- int w = (inset_owner ? inset_owner->width(bview, font) : ww);
+ int const w = (inset_owner ?
+ inset_owner->width(bview, font) : ww);
/* selection code */
if (bidi_same_direction) {
if (sel_start_cursor.row() == row_ptr &&
sel_end_cursor.x(),
row_ptr->height(),
LColor::selection);
- } else if (y > long(sel_start_cursor.y())
- && y < long(sel_end_cursor.y())) {
+ } else if (y > sel_start_cursor.y()
+ && y < sel_end_cursor.y()) {
pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
}
- } else if ( sel_start_cursor.row() != row_ptr &&
+ } else if (sel_start_cursor.row() != row_ptr &&
sel_end_cursor.row() != row_ptr &&
- y > long(sel_start_cursor.y())
- && y < long(sel_end_cursor.y())) {
+ y > sel_start_cursor.y()
+ && y < sel_end_cursor.y()) {
pain.fillRectangle(x_offset, y_offset, w,
row_ptr->height(),
LColor::selection);
} else if (sel_start_cursor.row() == row_ptr ||
sel_end_cursor.row() == row_ptr) {
float tmpx = x;
- if ( (sel_start_cursor.row() != row_ptr && !is_rtl) ||
+ if ((sel_start_cursor.row() != row_ptr && !is_rtl) ||
(sel_end_cursor.row() != row_ptr && is_rtl))
pain.fillRectangle(x_offset, y_offset,
int(tmpx),
for (vpos = row_ptr->pos(); vpos <= last; ++vpos) {
pos = vis2log(vpos);
- float old_tmpx = tmpx;
+ float const old_tmpx = tmpx;
if (main_body > 0 && pos == main_body-1) {
tmpx += fill_label_hfill +
lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass,
} else
tmpx += SingleWidth(bview, row_ptr->par(), pos);
- if ( (sel_start_cursor.row() != row_ptr ||
+ if ((sel_start_cursor.row() != row_ptr ||
sel_start_cursor.pos() <= pos) &&
(sel_end_cursor.row() != row_ptr ||
pos < sel_end_cursor.pos()) )
LColor::selection);
}
- if ( (sel_start_cursor.row() != row_ptr && is_rtl) ||
+ if ((sel_start_cursor.row() != row_ptr && is_rtl) ||
(sel_end_cursor.row() != row_ptr && !is_rtl) )
pain.fillRectangle(x_offset + int(tmpx),
y_offset,
}
// Draw minipage line
- bool minipage = p->pextra_type == LyXParagraph::PEXTRA_MINIPAGE;
+ bool const minipage =
+ (p->pextra_type == LyXParagraph::PEXTRA_MINIPAGE);
if (minipage)
pain.line(LYX_PAPER_MARGIN/5, y_offset,
LYX_PAPER_MARGIN/5,
LColor::minipageline);
// Draw depth lines
- int depth = p->GetDepth();
+ int const depth = p->GetDepth();
for (int i = 1; i <= depth; ++i) {
- int line_x = (LYX_PAPER_MARGIN / 5) * (i + minipage);
+ int const line_x = (LYX_PAPER_MARGIN / 5) *
+ (i + minipage);
pain.line(line_x, y_offset, line_x,
y_offset + row_ptr->height() - 1,
LColor::depthbar);
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE);
- int box_x = LYX_PAPER_MARGIN;
- box_x += lyxfont::width(" wide-tab ", font);
+ int const box_x = LYX_PAPER_MARGIN
+ + lyxfont::width(" wide-tab ", font);
pain.line(box_x, y_offset,
workWidth(bview) - LYX_PAPER_MARGIN,
}
// Draw minipage line
- bool minipage = firstpar->pextra_type == LyXParagraph::PEXTRA_MINIPAGE;
+ bool const minipage =
+ (firstpar->pextra_type == LyXParagraph::PEXTRA_MINIPAGE);
if (minipage)
pain.line(LYX_PAPER_MARGIN/5 + box_x, y_offset,
LYX_PAPER_MARGIN/5 + box_x,
LColor::minipageline);
// Draw depth lines
- int depth = firstpar->GetDepth();
+ int const depth = firstpar->GetDepth();
if (depth > 0) {
int next_depth = 0;
int prev_depth = 0;
#endif
for (int i = 1; i <= depth; ++i) {
- int line_x = (LYX_PAPER_MARGIN / 5) * (i + minipage) + box_x;
+ int const line_x = (LYX_PAPER_MARGIN / 5) *
+ (i + minipage) + box_x + x_offset;
pain.line(line_x, y_offset, line_x,
y_offset + row_ptr->height() - 1 - (i - next_depth - 1) * 3,
LColor::depthbar);
y_top += lyxfont::ascent('x',
GetFont(bview->buffer(),
row_ptr->par(), 0));
-
- pain.line(0, y_offset + y_top,
- ww, y_offset + y_top,
+ int const w = (inset_owner ?
+ inset_owner->width(bview, font) : ww);
+ int const xp = static_cast<int>(inset_owner ? x : 0);
+ pain.line(xp, y_offset + y_top,
+ w, y_offset + y_top,
LColor::topline,
Painter::line_solid,
Painter::line_thick);
font = GetFont(bview->buffer(), row_ptr->par(), -2);
if (!row_ptr->par()->GetLabelstring().empty()) {
tmpx = x;
- string tmpstring = row_ptr->par()->GetLabelstring();
+ string const tmpstring =
+ row_ptr->par()->GetLabelstring();
if (layout.labeltype == LABEL_COUNTER_CHAPTER) {
if (bview->buffer()->params.secnumdepth >= 0) {
font = GetFont(bview->buffer(),
row_ptr->par(), -2);
if (!row_ptr->par()->GetLabelstring().empty()) {
- string tmpstring = row_ptr->par()->GetLabelstring();
+ string const tmpstring =
+ row_ptr->par()->GetLabelstring();
float spacing_val = 1.0;
if (!row_ptr->par()->spacing.isDefault()) {
spacing_val = row_ptr->par()->spacing.getValue();
#endif
if (
#ifndef NEW_INSETS
- (row_ptr->par()->ParFromPos(last + 1) == par)
+ row_ptr->par()->ParFromPos(last + 1) == par
#else
- (row_ptr->par() == par)
+ row_ptr->par() == par
#endif
- && (!row_ptr->next() || (row_ptr->next()->par() != row_ptr->par())))
+ && (!row_ptr->next() || row_ptr->next()->par() != row_ptr->par()))
{
/* think about the margins */
if (!row_ptr->next() && bv_owner)
/* draw a bottom line */
y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
par, par->Last() - 1));
- pain.line(0, y_offset + y_bottom,
- ww, y_offset + y_bottom,
+ int const w = (inset_owner ?
+ inset_owner->width(bview, font) : ww);
+ int const xp = static_cast<int>(inset_owner ? x : 0);
+ pain.line(xp, y_offset + y_bottom,
+ w, y_offset + y_bottom,
LColor::topline, Painter::line_solid,
Painter::line_thick);
- y_bottom -= lyxfont::ascent('x', GetFont(bview->buffer(),
- par, par->Last() - 1));
+ y_bottom -= lyxfont::ascent('x',
+ GetFont(bview->buffer(),
+ par,
+ par->Last() - 1));
}
// draw an endlabel
- int endlabel = row_ptr->par()->GetEndLabel(bview->buffer()->params);
+ int const endlabel =
+ row_ptr->par()->GetEndLabel(bview->buffer()->params);
switch (endlabel) {
case END_LABEL_BOX:
case END_LABEL_FILLED_BOX:
{
- LyXFont font = GetFont(bview->buffer(),
- row_ptr->par(), last);
- int size = int(0.75 * lyxfont::maxAscent(font));
- int y = (y_offset + row_ptr->baseline()) - size;
+ LyXFont const font = GetFont(bview->buffer(),
+ row_ptr->par(), last);
+ int const size = int(0.75 * lyxfont::maxAscent(font));
+ int const y = (y_offset + row_ptr->baseline()) - size;
int x = is_rtl ? LYX_PAPER_MARGIN
: ww - LYX_PAPER_MARGIN - size;
#ifndef NEW_INSETS
case END_LABEL_STATIC:
{
LyXTextClass::LayoutList::size_type layout = row_ptr->par()->GetLayout();
- string tmpstring = textclasslist.Style(bview->buffer()->params.textclass,
- layout).endlabelstring();
+ string const tmpstring = textclasslist.
+ Style(bview->buffer()->params.textclass,
+ layout).endlabelstring();
font = GetFont(bview->buffer(), row_ptr->par(), -2);
- int tmpx = is_rtl ? int(x) - lyxfont::width(tmpstring, font)
+ int const tmpx = is_rtl ?
+ int(x) - lyxfont::width(tmpstring, font)
: ww - RightMargin(bview->buffer(), row_ptr) - row_ptr->fill();
pain.text( tmpx, y_offset + row_ptr->baseline(), tmpstring, font);
break;
++vc;
}
- if (vc > row->pos() && (tmpx + last_tmpx) / 2 > x) {
+ if ((tmpx + last_tmpx) / 2 > x) {
tmpx = last_tmpx;
left_side = true;
}
vc = last + 1;
boundary = false;
-#if 0 // currently unused
- bool lastrow = (!row->next() || row->next()->par() != row->par());
- bool rtl = (lastrow)
+ bool const lastrow = lyxrc.rtl_support // This is not needed, but gives
+ // some speedup if rtl_support=false
+ && (!row->next() || row->next()->par() != row->par());
+ bool const rtl = (lastrow)
? row->par()->isRightToLeftPar(bview->buffer()->params)
- : false;
-#endif
-
+ : false; // If lastrow is false, we don't need to compute
+ // the value of rtl.
+
if (row->pos() > last) // Row is empty?
c = row->pos();
-#warning This is wrong, please have a look Dekel (Jug)
-#if 0
else if (lastrow &&
- ( (rtl && vc == row->pos()&& x < tmpx - 5) ||
- (!rtl && vc == last + 1 && x > tmpx + 5) ))
+ ( ( rtl && left_side && vc == row->pos() && x < tmpx - 5) ||
+ (!rtl && !left_side && vc == last + 1 && x > tmpx + 5) ))
c = last + 1;
-#endif
else if (vc == row->pos()) {
c = vis2log(vc);
if (bidi_level(c) % 2 == 1)
++c;
} else {
c = vis2log(vc - 1);
- bool rtl = (bidi_level(c) % 2 == 1);
+ bool const rtl = (bidi_level(c) % 2 == 1);
if (left_side == rtl) {
++c;
boundary = IsBoundary(bview->buffer(), row->par(), c);
// returns pointer to a specified row
Row * LyXText::GetRow(LyXParagraph * par,
- LyXParagraph::size_type pos, long & y) const
+ LyXParagraph::size_type pos, int & y) const
{
+ if (!firstrow)
+ return 0;
+
Row * tmprow = firstrow;
y = 0;