void LyXFunc::setLyXView(LyXView * lv)
{
- if (lyx_view_ && lyx_view_->view() && lyx_view_ != lv)
+ if (lyx_view_ && lyx_view_->currentBufferView() && lyx_view_ != lv)
// save current selection to the selection buffer to allow
// middle-button paste in another window
- cap::saveSelection(lyx_view_->view()->cursor());
+ cap::saveSelection(lyx_view_->currentBufferView()->cursor());
lyx_view_ = lv;
}
if (keyseq.length())
c = 0;
- LASSERT(lyx_view_ && lyx_view_->view(), /**/);
- lyx_view_->view()->getIntl().getTransManager().deadkey(
- c, get_accent(action).accent, view()->cursor().innerText(), view()->cursor());
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
+ lyx_view_->currentBufferView()->getIntl().getTransManager().deadkey(
+ c, get_accent(action).accent, view()->cursor().innerText(),
+ currentBufferView()->cursor());
// Need to clear, in case the minibuffer calls these
// actions
keyseq.clear();
case LFUN_WORD_FIND_FORWARD:
case LFUN_WORD_FIND_BACKWARD: {
- LASSERT(lyx_view_ && lyx_view_->view(), /**/);
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
static docstring last_search;
docstring searched_string;
break;
case LFUN_CANCEL:
- LASSERT(lyx_view_ && lyx_view_->view(), /**/);
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
keyseq.reset();
meta_fake_bit = NoModifier;
if (buffer)
break;
case LFUN_BUFFER_TOGGLE_READ_ONLY: {
- LASSERT(lyx_view_ && lyx_view_->view() && buffer, /**/);
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView() && buffer, /**/);
if (buffer->lyxvc().inUse())
buffer->lyxvc().toggleReadOnly();
else
case LFUN_KEYMAP_OFF:
LASSERT(lyx_view_ && lyx_view_->view(), /**/);
- lyx_view_->view()->getIntl().keyMapOn(false);
+ lyx_view_->currentBufferView()->getIntl().keyMapOn(false);
break;
case LFUN_KEYMAP_PRIMARY:
- LASSERT(lyx_view_ && lyx_view_->view(), /**/);
- lyx_view_->view()->getIntl().keyMapPrim();
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
+ lyx_view_->currentBufferView()->getIntl().keyMapPrim();
break;
case LFUN_KEYMAP_SECONDARY:
- LASSERT(lyx_view_ && lyx_view_->view(), /**/);
- lyx_view_->view()->getIntl().keyMapSec();
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
+ lyx_view_->currentBufferView()->getIntl().keyMapSec();
break;
case LFUN_KEYMAP_TOGGLE:
- LASSERT(lyx_view_ && lyx_view_->view(), /**/);
- lyx_view_->view()->getIntl().toggleKeyMap();
+ LASSERT(lyx_view_ && lyx_view_->currentBufferView(), /**/);
+ lyx_view_->currentBufferView()->getIntl().toggleKeyMap();
break;
case LFUN_REPEAT: {
// Let the current LyXView dispatch its own actions.
if (lyx_view_->dispatch(cmd)) {
- if (lyx_view_->view()) {
- updateFlags = lyx_view_->view()->cursor().result().update();
+ if (lyx_view_->currentBufferView()) {
+ updateFlags = lyx_view_->currentBufferView()->cursor().result().update();
if (theBufferList().isLoaded(buffer))
buffer->undo().endUndoGroup();
}
break;
}
- LASSERT(lyx_view_->view(), /**/);
+ LASSERT(lyx_view_->currentBufferView(), /**/);
// Let the current BufferView dispatch its own actions.
if (view()->dispatch(cmd)) {
BufferView * LyXFunc::view() const
{
LASSERT(lyx_view_, /**/);
- return lyx_view_->view();
+ return lyx_view_->currentBufferView();
}
//@{ generic accessor functions
/// \return the currently selected buffer view.
- virtual BufferView * view() = 0;
+ virtual BufferView * currentBufferView() = 0;
+ virtual BufferView const * currentBufferView() const = 0;
/// \return the current document buffer view.
virtual BufferView * documentBufferView() = 0;
+ virtual BufferView const * documentBufferView() const = 0;
/// \return the buffer currently selected in this window
virtual Buffer * buffer() = 0;
BufferView const * Dialog::bufferview() const
{
- return lyxview_->view();
+ return lyxview_->currentBufferView();
}
docstring const GuiCommandBuffer::getCurrentState() const
{
- return view_->view()->cursor().currentState();
+ return view_->currentBufferView()->cursor().currentState();
}
if (old_gwa == wa)
return;
- if (view())
- cap::saveSelection(view()->cursor());
+ if (currentBufferView())
+ cap::saveSelection(currentBufferView()->cursor());
theGuiApp()->setCurrentView(this);
d.current_work_area_ = wa;
}
-BufferView * GuiView::view()
+BufferView const * GuiView::documentBufferView() const
+{
+ return currentMainWorkArea()
+ ? ¤tMainWorkArea()->bufferView()
+ : 0;
+}
+
+
+BufferView * GuiView::currentBufferView()
+{
+ return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
+}
+
+
+BufferView const * GuiView::currentBufferView() const
{
return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
}
{
LYXERR(Debug::INFO, "Running autoSave()");
- if (buffer())
- view()->buffer().autoSave();
+ if (documentBufferView())
+ documentBufferView()->buffer().autoSave();
}
if (cmd.origin == FuncRequest::TOC) {
GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
FuncStatus fs;
- if (toc->getStatus(view()->cursor(), cmd, fs))
+ if (toc->getStatus(documentBufferView()->cursor(), cmd, fs))
flag |= fs;
else
flag.setEnabled(false);
enable = buf->isExportable("dvi")
&& lyxrc.print_command != "none";
else if (name == "character" || name == "symbols") {
- if (buf->isReadonly() || !view() || !view()->cursor().inTexted())
+ if (buf->isReadonly() || !currentBufferView()
+ || !currentBufferView()->cursor().inTexted())
enable = false;
else {
// FIXME we should consider passthru
// paragraphs too.
- Inset const & in = view()->cursor().inset();
+ Inset const & in = currentBufferView()->cursor().inset();
enable = !in.getLayout().isPassThru();
}
}
if (inset) {
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
FuncStatus fs;
- if (!inset->getStatus(view()->cursor(), fr, fs)) {
+ if (!inset->getStatus(currentBufferView()->cursor(), fr, fs)) {
// Every inset is supposed to handle this
LASSERT(false, break);
}
case LFUN_COMPLETION_INLINE:
if (!d.current_work_area_
- || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
+ || !d.current_work_area_->completer().inlinePossible(
+ currentBufferView()->cursor()))
enable = false;
break;
case LFUN_COMPLETION_POPUP:
if (!d.current_work_area_
- || !d.current_work_area_->completer().popupPossible(view()->cursor()))
+ || !d.current_work_area_->completer().popupPossible(
+ currentBufferView()->cursor()))
enable = false;
break;
case LFUN_COMPLETION_COMPLETE:
if (!d.current_work_area_
- || !d.current_work_area_->completer().inlinePossible(view()->cursor()))
+ || !d.current_work_area_->completer().inlinePossible(
+ currentBufferView()->cursor()))
enable = false;
break;
if (lyxrc.use_lastfilepos) {
LastFilePosSection::FilePos filepos =
theSession().lastFilePos().load(filename);
- view()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
+ documentBufferView()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
}
if (tolastfiles)
string filename2 = (loader_format == format) ? filename.absFilename()
: support::changeExtension(filename.absFilename(),
formats.extension(loader_format));
- lv->view()->insertPlaintextFile(FileName(filename2), as_paragraphs);
+ lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
+ as_paragraphs);
theLyXFunc().setLyXView(lv);
lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
}
// If no new document could be created, it is unsure
// whether there is a valid BufferView.
- if (view())
+ if (currentBufferView())
// Ensure the cursor is correctly positioned on screen.
- view()->showCursor();
+ currentBufferView()->showCursor();
}
void GuiView::insertLyXFile(docstring const & fname)
{
- BufferView * bv = view();
+ BufferView * bv = documentBufferView();
if (!bv)
return;
void GuiView::insertPlaintextFile(docstring const & fname,
bool asParagraph)
{
- BufferView * bv = view();
+ BufferView * bv = documentBufferView();
if (!bv)
return;
bool GuiView::dispatch(FuncRequest const & cmd)
{
- BufferView * bv = view();
+ BufferView * bv = currentBufferView();
// By default we won't need any update.
if (bv)
bv->cursor().updateFlags(Update::None);
Inset * inset = getOpenInset(name);
if (inset) {
FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
- inset->dispatch(view()->cursor(), fr);
+ inset->dispatch(currentBufferView()->cursor(), fr);
} else if (name == "paragraph") {
lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
} else if (name == "prefs" || name == "document") {
Inset * inset = getOpenInset(name);
if (inset) {
// put cursor in front of inset.
- if (!view()->setCursorFromInset(inset)) {
+ if (!currentBufferView()->setCursorFromInset(inset)) {
LASSERT(false, break);
}
-
+ BufferView * bv = currentBufferView();
// useful if we are called from a dialog.
- view()->cursor().beginUndoGroup();
- view()->cursor().recordUndo();
+ bv->cursor().beginUndoGroup();
+ bv->cursor().recordUndo();
FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
- inset->dispatch(view()->cursor(), fr);
- view()->cursor().endUndoGroup();
+ inset->dispatch(bv->cursor(), fr);
+ bv->cursor().endUndoGroup();
} else {
FuncRequest fr(LFUN_INSET_INSERT, cmd.argument());
lyx::dispatch(fr);
~GuiView();
- ///
- int id() const { return id_; }
- void setFocus();
+ /// LyXView inherited methods.
+ ///@{
+ int id() const;
void setBusy(bool);
- /// returns true if this view has the focus.
+ BufferView * currentBufferView();
+ BufferView const * currentBufferView() const;
+ BufferView * documentBufferView();
+ BufferView const * documentBufferView() const;
+ Buffer * buffer();
+ Buffer const * buffer() const;
+ Buffer * documentBuffer();
+ Buffer const * documentBuffer() const;
+ void setBuffer(Buffer * b);
+ bool closeBuffer();
+ bool closeBufferAll();
bool hasFocus() const;
+ Buffer * loadDocument(support::FileName const & name,
+ bool tolastfiles = true);
+ void newDocument(std::string const & filename,
+ bool fromTemplate);
+ void message(docstring const &);
+ bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
+ bool dispatch(FuncRequest const & cmd);
+ void restartCursor();
+ void updateCompletion(Cursor & cur, bool start, bool keep);
+ void setFocus();
+ ///@}
/// add toolbar, if newline==true, add a toolbar break before the toolbar
GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
- virtual void updateStatusBar();
- virtual void message(docstring const & str);
+ void updateStatusBar();
/// updates the possible layouts selectable
void updateLayoutList();
void updateToolbars();
QMenu * createPopupMenu();
- bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
- bool dispatch(FuncRequest const & cmd);
///
LayoutBox * getLayoutDialog() const;
- /// \return the buffer currently selected in this window
- virtual Buffer * buffer();
- virtual Buffer const * buffer() const;
-
- /// \return the document buffer in this window
- virtual Buffer * documentBuffer();
- virtual Buffer const * documentBuffer() const;
-
- /// set a buffer to the current workarea.
- void setBuffer(Buffer * b); ///< \c Buffer to set.
- /// closes the current active buffer
- bool closeBuffer();
/// hides the workarea and makes sure it is clean
bool hideWorkArea(GuiWorkArea * wa);
/// closes the workarea
bool closeWorkArea(GuiWorkArea * wa);
- /// load a document into the current workarea.
- Buffer * loadDocument(support::FileName const & name, ///< File to load.
- bool tolastfiles = true); ///< append to the "Open recent" menu?
///
void openDocument(std::string const & filename);
///
void importDocument(std::string const &);
- ///
- void newDocument(std::string const & filename, bool fromTemplate);
/// GuiBufferDelegate.
///@{
/// called on timeout
void autoSave();
- /// \return the currently selected buffer view.
- BufferView * view();
- /// \return the current document buffer view.
- BufferView * documentBufferView();
-
/** redraw \c inset in all the BufferViews in which it is currently
* visible. If successful return a pointer to the owning Buffer.
*/
Buffer const * updateInset(Inset const *);
- ///
- void restartCursor();
/// \return the \c Workarea associated to \p Buffer
/// \retval 0 if no \c WorkArea is found.
///
void disconnectDialog(std::string const & name);
- ///
- void updateCompletion(Cursor & cur, bool start, bool keep);
-
private:
///
void saveLayout() const;
/// or to discard the changes. If hiding is true, the
/// document will be reloaded.
bool saveBufferIfNeeded(Buffer & buf, bool hiding);
- /// closes all workareas and all hidden buffers
- bool closeBufferAll();
/// closes all workareas
bool closeWorkAreaAll();
/// write all open workareas into the session file
// or we've moved from one inset to another
DocumentClass const * text_class = &buffer->params().documentClass();
Inset const * inset =
- &(d->owner_.view()->cursor().innerText()->inset());
+ &(d->owner_.currentBufferView()->cursor().innerText()->inset());
if (!reset && d->text_class_ == text_class && d->inset_ == inset) {
- set(d->owner_.view()->cursor().innerParagraph().layout().name());
+ set(d->owner_.currentBufferView()->cursor().innerParagraph().layout().name());
return;
}
lyxrc.group_layouts, lit->isUnknown());
}
- set(d->owner_.view()->cursor().innerParagraph().layout().name());
+ set(d->owner_.currentBufferView()->cursor().innerParagraph().layout().name());
d->countCategories();
// needed to recalculate size hint
MenuDefinition menu;
BufferView * bv = 0;
if (view)
- bv = view->view();
+ bv = view->currentBufferView();
d->expand(d->menubar_, menu, bv);
MenuDefinition::const_iterator m = menu.begin();
MenuDefinition const & fromLyxMenu = d->getMenu(qmenu->d->name);
BufferView * bv = 0;
if (qmenu->d->view)
- bv = qmenu->d->view->view();
+ bv = qmenu->d->view->currentBufferView();
d->expand(fromLyxMenu, *qmenu->d->top_level_menu, bv);
qmenu->d->populate(*qmenu, *qmenu->d->top_level_menu);
}
void TocWidget::updateView()
{
- if (!gui_view_.view()) {
+ if (!gui_view_.currentBufferView()) {
enableControls(false);
typeCO->setEnabled(false);
tocTV->setModel(0);