#include <config.h>
+#include "GuiApplication.h"
#include "GuiViewSource.h"
#include "LaTeXHighlighter.h"
#include "qt_helpers.h"
-#include "Application.h"
#include "BufferView.h"
#include "Buffer.h"
#include "Cursor.h"
-#include "gettext.h"
#include "Paragraph.h"
#include "TexRow.h"
+#include "support/assert.h"
+#include "support/docstream.h"
+#include "support/gettext.h"
+
#include <QTextCursor>
#include <QTextDocument>
-#include <boost/tuple/tuple.hpp>
-using std::string;
+using namespace std;
namespace lyx {
namespace frontend {
highlighter_(new LaTeXHighlighter(document_))
{
setupUi(this);
- setWindowTitle(qt_("LaTeX Source"));
connect(viewFullSourceCB, SIGNAL(clicked()),
this, SLOT(updateView()));
viewSourceTV->setReadOnly(true);
///dialog_->viewSourceTV->setAcceptRichText(false);
// this is personal. I think source code should be in fixed-size font
- QFont font(toqstr(theApp()->typewriterFontName()));
+ QFont font(guiApp->typewriterFontName());
font.setKerning(false);
font.setFixedPitch(true);
font.setStyleHint(QFont::TypeWriter);
if (autoUpdateCB->isChecked())
update(viewFullSourceCB->isChecked());
- int beg, end;
- boost::tie(beg, end) = controller_.getRows();
+ GuiViewSource::Row row = controller_.getRows();
QTextCursor c = QTextCursor(viewSourceTV->document());
- c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, beg);
+ c.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor, row.begin);
c.select(QTextCursor::BlockUnderCursor);
- c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, end - beg + 1);
+ c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor,
+ row.end - row.begin + 1);
viewSourceTV->setTextCursor(c);
}
}
-GuiViewSource::GuiViewSource(GuiViewBase & parent, Qt::DockWidgetArea area, Qt::WindowFlags flags)
- : DockView(parent, "view-source", area, flags)
+GuiViewSource::GuiViewSource(GuiView & parent,
+ Qt::DockWidgetArea area, Qt::WindowFlags flags)
+ : DockView(parent, "view-source", qt_("LaTeX Source"), area, flags)
{
widget_ = new ViewSourceWidget(*this);
setWidget(widget_);
- setWindowTitle(widget_->windowTitle());
}
par_end = view->cursor().selectionEnd().bottom().pit();
}
if (par_begin > par_end)
- std::swap(par_begin, par_end);
+ swap(par_begin, par_end);
odocstringstream ostr;
view->buffer().getSourceCode(ostr, par_begin, par_end + 1, fullSource);
return toqstr(ostr.str());
}
-std::pair<int, int> GuiViewSource::getRows() const
+GuiViewSource::Row GuiViewSource::getRows() const
{
BufferView const * view = bufferview();
CursorSlice beg = view->cursor().selectionBegin().bottom();
getRowFromIdPos(end.paragraph().id(), end.pos());
int nextendrow = view->buffer().texrow().
getRowFromIdPos(end.paragraph().id(), end.pos() + 1);
- return std::make_pair(begrow, endrow == nextendrow ? endrow : (nextendrow - 1));
+ Row row;
+ row.begin = begrow;
+ row.end = endrow == nextendrow ? endrow : (nextendrow - 1);
+ return row;
}
case LITERATE:
return qt_("Literate Source");
}
- BOOST_ASSERT(false);
+ LASSERT(false, /**/);
return QString();
}
-Dialog * createGuiViewSource(LyXView & lv)
+Dialog * createGuiViewSource(GuiView & lv)
{
- return new GuiViewSource(static_cast<GuiViewBase &>(lv));
+ return new GuiViewSource(lv);
}