short_delay : long_delay);
}
+
void ViewSourceWidget::updateViewNow()
{
update_timer_->start(0);
}
-namespace {
-
-QString prependTexRow(TexRow const & texrow, QString const & content)
-{
- QStringList list = content.split(QChar('\n'));
- docstring_list dlist;
- for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
- dlist.push_back(from_utf8(fromqstr(*it)));
- texrow.prepend(dlist);
- QString qstr;
- for (docstring_list::iterator it = dlist.begin(); it != dlist.end(); ++it)
- qstr += toqstr(*it) + '\n';
- return qstr;
-}
-
-} // anon namespace
void ViewSourceWidget::realUpdateView()
{
QString old = document_->toPlainText();
QString qcontent = toqstr(content);
#ifdef DEVEL_VERSION
- if (texrow_.get() && lyx::lyxerr.debugging(Debug::LATEX))
- qcontent = prependTexRow(*texrow_, qcontent);
+ // output tex<->row correspondences in the source panel if the "-dbg latex"
+ // option is given.
+ if (texrow_.get() && lyx::lyxerr.debugging(Debug::LATEX)) {
+ QStringList list = qcontent.split(QChar('\n'));
+ docstring_list dlist;
+ for (QStringList::const_iterator it = list.begin(); it != list.end(); ++it)
+ dlist.push_back(from_utf8(fromqstr(*it)));
+ texrow_->prepend(dlist);
+ qcontent.clear();
+ for (docstring_list::iterator it = dlist.begin(); it != dlist.end(); ++it)
+ qcontent += toqstr(*it) + '\n';
+ }
#endif
// prevent gotoCursor()
viewSourceTV->blockSignals(true);
} else if (texrow_.get()) {
// Use the available position-to-row conversion to highlight
// the current selection in the source
- int beg_row, end_row;
- {
- DocIterator beg = bv_->cursor().selectionBegin();
- DocIterator end = bv_->cursor().selectionEnd();
- std::pair<int,int> beg_rows = texrow_->rowFromDocIterator(beg);
- beg_row = beg_rows.first;
- if (beg != end) {
- end.backwardChar();
- std::pair<int,int> end_rows = texrow_->rowFromDocIterator(end);
- end_row = end_rows.second;
- } else {
- end_row = beg_rows.second;
- }
- }
+ std::pair<int,int> rows = texrow_->rowFromCursor(bv_->cursor());
+ int const beg_row = rows.first;
+ int const end_row = rows.second;
QTextCursor c = QTextCursor(viewSourceTV->document());