#include "bufferparams.h"
#include "buffer.h"
#include "debug.h"
+#include "intl.h"
#include "lyxrc.h"
#include "encoding.h"
#include "frontends/LyXView.h"
#include "frontends/Painter.h"
#include "frontends/font_metrics.h"
#include "frontends/screen.h"
+#include "frontends/WorkArea.h"
#include "bufferview_funcs.h"
#include "BufferView.h"
#include "language.h"
#include "ParagraphParameters.h"
#include "undo_funcs.h"
+#include "WordLangTuple.h"
+#include "paragraph_funcs.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin();
Buffer::inset_iterator end = bview->buffer()->inset_iterator_end();
for (; it != end; ++it) {
- if (*it == inset) {
+ if (&(*it) == inset) {
par = it.getPar();
pos = it.getPos();
break;
drawForeignMark(p, orig_x, orig_font);
-#ifdef INHERIT_LANGUAGE
-#ifdef WITH_WARNINGS
- if ((font.language() == inherit_language) ||
- (font.language() == ignore_language))
- lyxerr << "No this shouldn't happen!\n";
-#endif
-#endif
return true;
}
} else {
// find the next level paragraph
- Paragraph * newpar =
- row->par()->outerHook();
+ Paragraph * newpar = row->par()->outerHook();
// make a corresponding row. Needed to call LeftMargin()
// this is only allowed, if the current paragraph is not empty or caption
// and if it has not the keepempty flag aktive
- if ((cursor.par()->size() <= 0)
+ if (cursor.par()->empty()
&& layout->labeltype != LABEL_SENSITIVE
&& !layout->keepempty)
return;
// breakParagraph call should return a bool if it inserts the
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
- bool const isempty = (layout->keepempty && !cursor.par()->size());
- cursor.par()->breakParagraph(bview->buffer()->params, cursor.pos(),
- keep_layout);
+ bool const isempty = (layout->keepempty && cursor.par()->empty());
+ ::breakParagraph(bview->buffer()->params, cursor.par(), cursor.pos(),
+ keep_layout);
// well this is the caption hack since one caption is really enough
if (layout->labeltype == LABEL_SENSITIVE) {
setHeightOfRow(bview, cursor.row());
- while (cursor.par()->next()->size()
+ while (!cursor.par()->next()->empty()
&& cursor.par()->next()->isNewline(0))
cursor.par()->next()->erase(0);
insertParagraph(bview, cursor.par()->next(), cursor.row());
- updateCounters(bview, cursor.row()->previous());
+ updateCounters(bview);
// This check is necessary. Otherwise the new empty paragraph will
// be deleted automatically. And it is more friendly for the user!
// This function is only used by the spellchecker for NextWord().
// It doesn't handle LYX_ACCENTs and probably never will.
-string const LyXText::selectNextWordToSpellcheck(BufferView * bview,
- float & value) const
+WordLangTuple const
+LyXText::selectNextWordToSpellcheck(BufferView * bview, float & value) const
{
if (the_locking_inset) {
- string str = the_locking_inset->selectNextWordToSpellcheck(bview, value);
- if (!str.empty()) {
+ WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bview, value);
+ if (!word.word().empty()) {
value += float(cursor.y())/float(height);
- return str;
+ return word;
}
- // we have to go on checking so move cusor to the next char
+ // we have to go on checking so move cursor to the next char
if (cursor.pos() == cursor.par()->size()) {
if (!cursor.par()->next())
- return str;
+ return word;
cursor.par(cursor.par()->next());
cursor.pos(0);
} else
// Start the selection from here
selection.cursor = cursor;
+ string lang_code(
+ getFont(bview->buffer(), cursor.par(), cursor.pos())
+ .language()->code());
// and find the end of the word (insets like optional hyphens
// and ligature break are part of a word)
while (cursor.pos() < cursor.par()->size()
str += cursor.par()->getChar(i);
}
}
- return str;
+ return WordLangTuple(str, lang_code);
}
// Delete from cursor up to the end of the current or next word.
void LyXText::deleteWordForward(BufferView * bview)
{
- if (!cursor.par()->size())
+ if (cursor.par()->empty())
cursorRight(bview);
else {
LyXCursor tmpcursor = cursor;
// Delete from cursor to start of current or prior word.
void LyXText::deleteWordBackward(BufferView * bview)
{
- if (!cursor.par()->size())
+ if (cursor.par()->empty())
cursorLeft(bview);
else {
LyXCursor tmpcursor = cursor;
// Kill to end of line.
void LyXText::deleteLineForward(BufferView * bview)
{
- if (!cursor.par()->size())
+ if (cursor.par()->empty())
// Paragraph is empty, so we just go to the right
cursorRight(bview);
else {
&& cursor.par()->getAlign() == tmppar->getAlign()) {
removeParagraph(tmprow);
removeRow(tmprow);
- cursor.par()->pasteParagraph(bview->buffer()->params);
+ pasteParagraph(bview->buffer()->params, cursor.par());
if (!cursor.pos() || !cursor.par()->isSeparator(cursor.pos() - 1))
; //cursor.par()->insertChar(cursor.pos(), ' ');
// This rebuilds the rows.
appendParagraph(bview, cursor.row());
- updateCounters(bview, cursor.row());
+ updateCounters(bview);
// the row may have changed, block, hfills etc.
setCursor(bview, cursor.par(), cursor.pos(), false);
}
// delete newlines at the beginning of paragraphs
- while (cursor.par()->size() &&
+ while (!cursor.par()->empty() &&
cursor.par()->isNewline(cursor.pos()) &&
cursor.pos() == beginningOfMainBody(bview->buffer(),
cursor.par())) {
}
return;
} else if (startrow != row && endrow != row) {
- int w = p.width;
- int h = row->height();
if (p.y > starty && p.y < endy) {
+ int w = p.width;
+ int h = row->height();
p.pain->fillRectangle(p.xo, p.yo, w, h, LColor::selection);
}
return;
}
- if (!((startrow != row && !is_rtl) || (endrow != row && is_rtl))) {
- return;
- }
-
- float tmpx = p.x;
-
- p.pain->fillRectangle(p.xo, p.yo, int(p.x), row->height(), LColor::selection);
+ if ((startrow != row && !is_rtl) || (endrow != row && is_rtl))
+ p.pain->fillRectangle(p.xo, p.yo, int(p.x), row->height(), LColor::selection);
Buffer const * buffer = p.bv->buffer();
Paragraph * par = row->par();
pos_type main_body = beginningOfMainBody(buffer, par);
pos_type const last = rowLastPrintable(row);
+ float tmpx = p.x;
for (pos_type vpos = row->pos(); vpos <= last; ++vpos) {
pos_type pos = vis2log(vpos);
int(tmpx - old_tmpx + 1),
row->height(), LColor::selection);
}
+ }
- if ((startrow != row && is_rtl) || (endrow != row && !is_rtl)) {
- p.pain->fillRectangle(p.xo + int(tmpx),
- p.yo, int(p.bv->workWidth() - tmpx),
- row->height(), LColor::selection);
- }
+ if ((startrow != row && is_rtl) || (endrow != row && !is_rtl)) {
+ p.pain->fillRectangle(p.xo + int(tmpx),
+ p.yo, int(p.bv->workWidth() - tmpx),
+ row->height(), LColor::selection);
}
}
int const text_start = p.xo + ((p.width - w) / 2);
int const text_end = text_start + w;
-
+
p.pain->rectText(text_start, y + d, label, pb_font);
-
+
p.pain->line(p.xo, y, text_start, y,
LColor::pagebreak, Painter::line_onoffdash);
p.pain->line(text_end, y, p.xo + p.width, y,
return 3 * defaultHeight();
}
-
+
void LyXText::paintFirstRow(DrawRowParams & p)
{
break;
}
}
-
+
void LyXText::paintRowText(DrawRowParams & p)
{