LyXView::view() now returns boost::shared_ptr<BufferView> const &.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4836 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-08-02 09:21:50 +00:00
parent d47e8c38e3
commit eed7fcfdf4
15 changed files with 81 additions and 47 deletions

View File

@ -1,3 +1,9 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* importer.C (Import):
* lyxfunc.C (moveCursorUpdate, dispatch, view_status_message):
changes due to LyXView::view() now returning a boost::shared_ptr.
2002-08-02 John Levon <levon@movementarian.org> 2002-08-02 John Levon <levon@movementarian.org>
* text2.C (status): small cleanup, no logic change * text2.C (status): small cleanup, no logic change

View File

@ -1,3 +1,12 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* LyXView.[Ch] (view): now returns shared_ptr<BufferView> const &
so that anything wanting to cache the buffer view can do so safely
using a boost::weak_ptr.
* LyXView.h: store bufferview_ as a shared_ptr, not as a scoped_ptr.
Spell Bjønnes correctly.
2002-08-01 John Levon <levon@movementarian.org> 2002-08-01 John Levon <levon@movementarian.org>
* Dialogs.h: * Dialogs.h:

View File

@ -86,9 +86,9 @@ Buffer * LyXView::buffer() const
} }
BufferView * LyXView::view() const boost::shared_ptr<BufferView> const & LyXView::view() const
{ {
return bufferview_.get(); return bufferview_;
} }
@ -139,7 +139,7 @@ void LyXView::autoSave()
lyxerr[Debug::INFO] << "Running autoSave()" << endl; lyxerr[Debug::INFO] << "Running autoSave()" << endl;
if (view()->available()) { if (view()->available()) {
::AutoSave(view()); ::AutoSave(view().get());
} }
} }

View File

@ -4,7 +4,7 @@
* Copyright 1995-2002 the LyX Team * Copyright 1995-2002 the LyX Team
* Read the file COPYING * Read the file COPYING
* *
* \author Lars Gullik Bjornes <larsbj@lyx.org> * \author Lars Gullik Bjønnes <larsbj@lyx.org>
* \author John Levon <moz@compsoc.man.ac.uk> * \author John Levon <moz@compsoc.man.ac.uk>
*/ */
@ -21,6 +21,7 @@
#include <boost/utility.hpp> #include <boost/utility.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signals/trackable.hpp> #include <boost/signals/trackable.hpp>
#include <boost/signals/signal0.hpp> #include <boost/signals/signal0.hpp>
@ -70,8 +71,11 @@ public:
//@{ generic accessor functions //@{ generic accessor functions
/// return the current buffer view /** return the current buffer view
BufferView * view() const; Returned as a shared_ptr so that anything wanting to cache the
buffer view can do so safely using a boost::weak_ptr.
*/
boost::shared_ptr<BufferView> const & view() const;
/// return the LyX function handler for this view /// return the LyX function handler for this view
LyXFunc * getLyXFunc() const; LyXFunc * getLyXFunc() const;
@ -120,7 +124,7 @@ public:
protected: protected:
/// view of a buffer. Eventually there will be several. /// view of a buffer. Eventually there will be several.
boost::scoped_ptr<BufferView> bufferview_; boost::shared_ptr<BufferView> bufferview_;
/// view's menubar /// view's menubar
boost::scoped_ptr<Menubar> menubar_; boost::scoped_ptr<Menubar> menubar_;

View File

@ -1,3 +1,12 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* ControlCharacter.C (apply):
* ControlERT.C (applyParamsToInset):
* ControlParagraph.C (apply):
* ControlSearch.C (find, replace):
* ControlThesaurus.C (replace): changes due to LyXView::view() now
returning a boost::shared_ptr.
2002-08-01 John Levon <levon@movementarian.org> 2002-08-01 John Levon <levon@movementarian.org>
* ControlSendto.C: writeFile() change * ControlSendto.C: writeFile() change

View File

@ -62,7 +62,7 @@ void ControlCharacter::apply()
if (lv_.view()->available()) if (lv_.view()->available())
view().apply(); view().apply();
toggleAndShow(lv_.view(), *(font_.get()), toggleall_); toggleAndShow(lv_.view().get(), *(font_.get()), toggleall_);
lv_.view_state_changed(); lv_.view_state_changed();
lv_.buffer()->markDirty(); lv_.buffer()->markDirty();
setMinibuffer(&lv_, _("Character set")); setMinibuffer(&lv_, _("Character set"));

View File

@ -30,7 +30,7 @@ ControlERT::ControlERT(LyXView & lv, Dialogs & d)
void ControlERT::applyParamsToInset() void ControlERT::applyParamsToInset()
{ {
inset()->status(lv_.view(), params().status); inset()->status(lv_.view().get(), params().status);
} }

View File

@ -63,7 +63,7 @@ void ControlParagraph::apply()
view().apply(); view().apply();
LyXText * text(lv_.view()->getLyXText()); LyXText * text(lv_.view()->getLyXText());
text->setParagraph(lv_.view(), text->setParagraph(lv_.view().get(),
pp_->lineTop(), pp_->lineTop(),
pp_->lineBottom(), pp_->lineBottom(),
pp_->pagebreakTop(), pp_->pagebreakTop(),

View File

@ -39,7 +39,7 @@ ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
void ControlSearch::find(string const & search, void ControlSearch::find(string const & search,
bool casesensitive, bool matchword, bool forward) const bool casesensitive, bool matchword, bool forward) const
{ {
bool const found = lyxfind::LyXFind(lv_.view(), search, bool const found = lyxfind::LyXFind(lv_.view().get(), search,
forward, casesensitive, forward, casesensitive,
matchword); matchword);
@ -56,7 +56,7 @@ void ControlSearch::replace(string const & search, string const & replace,
// changed // changed
bool const once = !all; bool const once = !all;
int const replace_count = int const replace_count =
lyxfind::LyXReplace(lv_.view(), lyxfind::LyXReplace(lv_.view().get(),
search, replace, true, casesensitive, search, replace, true, casesensitive,
matchword, all, once); matchword, all, once);

View File

@ -43,7 +43,7 @@ void ControlThesaurus::replace(string const & newstr)
* deletion/change ! * deletion/change !
*/ */
int const replace_count = int const replace_count =
lyxfind::LyXReplace(lv_.view(), oldstr_, newstr, lyxfind::LyXReplace(lv_.view().get(), oldstr_, newstr,
true, true, true, false, true); true, true, true, false, true);
oldstr_ = newstr; oldstr_ = newstr;

View File

@ -1,3 +1,9 @@
2002-08-02 Angus Leeming <leeming@lyx.org>
* FormTabular.C (input):
* XMiniBuffer.C (show_info): changes due to LyXView::view() now
returning a boost::shared_ptr.
2002-08-01 John Levon <levon@movementarian.org> 2002-08-01 John Levon <levon@movementarian.org>
* FormDocument.C: writeFile() change * FormDocument.C: writeFile() change

View File

@ -558,7 +558,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
string const str = string const str =
getLengthFromWidgets(column_options_->input_column_width, getLengthFromWidgets(column_options_->input_column_width,
column_options_->choice_value_column_width); column_options_->choice_value_column_width);
inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str); inset_->tabularFeatures(lv_->view().get(), LyXTabular::SET_PWIDTH, str);
//check if the input is valid //check if the input is valid
string const input = string const input =
@ -577,7 +577,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
string const str = string const str =
getLengthFromWidgets(cell_options_->input_mcolumn_width, getLengthFromWidgets(cell_options_->input_mcolumn_width,
cell_options_->choice_value_mcolumn_width); cell_options_->choice_value_mcolumn_width);
inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str); inset_->tabularFeatures(lv_->view().get(), LyXTabular::SET_MPWIDTH, str);
//check if the input is valid //check if the input is valid
string const input = string const input =
@ -690,7 +690,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
else else
return false; return false;
inset_->tabularFeatures(lv_->view(), num, special); inset_->tabularFeatures(lv_->view().get(), num, special);
update(); update();
return true; return true;

View File

@ -230,7 +230,7 @@ void XMiniBuffer::show_info(string const & info, string const & input, bool appe
void XMiniBuffer::idle_timeout() void XMiniBuffer::idle_timeout()
{ {
set_input(currentState(view_->view())); set_input(currentState(view_->view().get()));
} }

View File

@ -77,7 +77,7 @@ bool Importer::Import(LyXView * lv, string const & filename,
string filename2 = (loader_format == format) ? filename string filename2 = (loader_format == format) ? filename
: ChangeExtension(filename, : ChangeExtension(filename,
formats.extension(loader_format)); formats.extension(loader_format));
InsertAsciiFile(lv->view(), filename2, as_paragraphs); InsertAsciiFile(lv->view().get(), filename2, as_paragraphs);
lv->getLyXFunc()->dispatch(LFUN_MARK_OFF); lv->getLyXFunc()->dispatch(LFUN_MARK_OFF);
} }

View File

@ -148,7 +148,7 @@ inline
void LyXFunc::moveCursorUpdate(bool flag, bool selecting) void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
{ {
if (selecting || TEXT(flag)->selection.mark()) { if (selecting || TEXT(flag)->selection.mark()) {
TEXT(flag)->setSelection(owner->view()); TEXT(flag)->setSelection(owner->view().get());
if (TEXT(flag)->bv_owner) if (TEXT(flag)->bv_owner)
owner->view()->toggleToggle(); owner->view()->toggleToggle();
} }
@ -760,7 +760,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
#if 1 #if 1
int inset_x; int inset_x;
int dummy_y; int dummy_y;
inset->getCursorPos(owner->view(), inset_x, dummy_y); inset->getCursorPos(owner->view().get(), inset_x, dummy_y);
#endif #endif
if ((action == LFUN_UNKNOWN_ACTION) if ((action == LFUN_UNKNOWN_ACTION)
&& argument.empty()) { && argument.empty()) {
@ -775,7 +775,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
goto exit_with_message; goto exit_with_message;
} else if (((result=inset-> } else if (((result=inset->
// Hand-over to inset's own dispatch: // Hand-over to inset's own dispatch:
localDispatch(owner->view(), action, argument)) == localDispatch(owner->view().get(), action, argument)) ==
UpdatableInset::DISPATCHED) || UpdatableInset::DISPATCHED) ||
(result == UpdatableInset::DISPATCHED_NOUPDATE)) (result == UpdatableInset::DISPATCHED_NOUPDATE))
goto exit_with_message; goto exit_with_message;
@ -786,7 +786,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
// FINISHED means that the cursor should be // FINISHED means that the cursor should be
// one position after the inset. // one position after the inset.
} else if (result == UpdatableInset::FINISHED_RIGHT) { } else if (result == UpdatableInset::FINISHED_RIGHT) {
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
goto exit_with_message; goto exit_with_message;
@ -794,12 +794,12 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
if (TEXT()->cursor.irow()->previous()) { if (TEXT()->cursor.irow()->previous()) {
#if 1 #if 1
TEXT()->setCursorFromCoordinates( TEXT()->setCursorFromCoordinates(
owner->view(), TEXT()->cursor.ix() + inset_x, owner->view().get(), TEXT()->cursor.ix() + inset_x,
TEXT()->cursor.iy() - TEXT()->cursor.iy() -
TEXT()->cursor.irow()->baseline() - 1); TEXT()->cursor.irow()->baseline() - 1);
TEXT()->cursor.x_fix(TEXT()->cursor.x()); TEXT()->cursor.x_fix(TEXT()->cursor.x());
#else #else
TEXT()->cursorUp(owner->view()); TEXT()->cursorUp(owner->view().get());
#endif #endif
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
@ -811,16 +811,16 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
if (TEXT()->cursor.irow()->next()) { if (TEXT()->cursor.irow()->next()) {
#if 1 #if 1
TEXT()->setCursorFromCoordinates( TEXT()->setCursorFromCoordinates(
owner->view(), TEXT()->cursor.ix() + inset_x, owner->view().get(), TEXT()->cursor.ix() + inset_x,
TEXT()->cursor.iy() - TEXT()->cursor.iy() -
TEXT()->cursor.irow()->baseline() + TEXT()->cursor.irow()->baseline() +
TEXT()->cursor.irow()->height() + 1); TEXT()->cursor.irow()->height() + 1);
TEXT()->cursor.x_fix(TEXT()->cursor.x()); TEXT()->cursor.x_fix(TEXT()->cursor.x());
#else #else
TEXT()->cursorDown(owner->view()); TEXT()->cursorDown(owner->view().get());
#endif #endif
} else { } else {
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
} }
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
@ -833,29 +833,29 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
case LFUN_UNKNOWN_ACTION: case LFUN_UNKNOWN_ACTION:
case LFUN_BREAKPARAGRAPH: case LFUN_BREAKPARAGRAPH:
case LFUN_BREAKLINE: case LFUN_BREAKLINE:
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
owner->view()->switchKeyMap(); owner->view()->switchKeyMap();
owner->view_state_changed(); owner->view_state_changed();
break; break;
case LFUN_RIGHT: case LFUN_RIGHT:
if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
} }
goto exit_with_message; goto exit_with_message;
case LFUN_LEFT: case LFUN_LEFT:
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
} }
goto exit_with_message; goto exit_with_message;
case LFUN_DOWN: case LFUN_DOWN:
if (TEXT()->cursor.row()->next()) if (TEXT()->cursor.row()->next())
TEXT()->cursorDown(owner->view()); TEXT()->cursorDown(owner->view().get());
else else
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
goto exit_with_message; goto exit_with_message;
@ -879,11 +879,11 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
if (tli == lock) { if (tli == lock) {
owner->view()->unlockInset(tli); owner->view()->unlockInset(tli);
TEXT()->cursorRight(owner->view()); TEXT()->cursorRight(owner->view().get());
moveCursorUpdate(true, false); moveCursorUpdate(true, false);
owner->view_state_changed(); owner->view_state_changed();
} else { } else {
tli->unlockInsetInInset(owner->view(), tli->unlockInsetInInset(owner->view().get(),
lock, lock,
true); true);
} }
@ -908,7 +908,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
} }
bool fw = (action == LFUN_WORDFINDBACKWARD); bool fw = (action == LFUN_WORDFINDBACKWARD);
if (!searched_string.empty()) { if (!searched_string.empty()) {
lyxfind::LyXFind(owner->view(), searched_string, fw); lyxfind::LyXFind(owner->view().get(), searched_string, fw);
} }
// owner->view()->showCursor(); // owner->view()->showCursor();
} }
@ -977,15 +977,15 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
s1 << _("Saving document") << ' ' s1 << _("Saving document") << ' '
<< MakeDisplayPath(owner->buffer()->fileName() + "..."); << MakeDisplayPath(owner->buffer()->fileName() + "...");
owner->message(s1.str().c_str()); owner->message(s1.str().c_str());
MenuWrite(owner->view(), owner->buffer()); MenuWrite(owner->view().get(), owner->buffer());
s1 << _(" done."); s1 << _(" done.");
owner->message(s1.str().c_str()); owner->message(s1.str().c_str());
} else } else
WriteAs(owner->view(), owner->buffer()); WriteAs(owner->view().get(), owner->buffer());
break; break;
case LFUN_WRITEAS: case LFUN_WRITEAS:
WriteAs(owner->view(), owner->buffer(), argument); WriteAs(owner->view().get(), owner->buffer(), argument);
break; break;
case LFUN_MENURELOAD: case LFUN_MENURELOAD:
@ -1057,7 +1057,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
break; break;
case LFUN_AUTOSAVE: case LFUN_AUTOSAVE:
AutoSave(owner->view()); AutoSave(owner->view().get());
break; break;
case LFUN_UNDO: case LFUN_UNDO:
@ -1081,11 +1081,11 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
break; break;
case LFUN_DEPTH_MIN: case LFUN_DEPTH_MIN:
changeDepth(owner->view(), TEXT(false), -1); changeDepth(owner->view().get(), TEXT(false), -1);
break; break;
case LFUN_DEPTH_PLUS: case LFUN_DEPTH_PLUS:
changeDepth(owner->view(), TEXT(false), 1); changeDepth(owner->view().get(), TEXT(false), 1);
break; break;
case LFUN_FREE: case LFUN_FREE:
@ -1093,7 +1093,7 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
break; break;
case LFUN_RECONFIGURE: case LFUN_RECONFIGURE:
Reconfigure(owner->view()); Reconfigure(owner->view().get());
break; break;
#if 0 #if 0
@ -1226,12 +1226,12 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) { if (owner->view()->theLockingInset()->lyxCode()==Inset::TABULAR_CODE) {
InsetTabular * inset = static_cast<InsetTabular *> InsetTabular * inset = static_cast<InsetTabular *>
(owner->view()->theLockingInset()); (owner->view()->theLockingInset());
inset->openLayoutDialog(owner->view()); inset->openLayoutDialog(owner->view().get());
} else if (owner->view()->theLockingInset()-> } else if (owner->view()->theLockingInset()->
getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) { getFirstLockingInsetOfType(Inset::TABULAR_CODE)!=0) {
InsetTabular * inset = static_cast<InsetTabular *>( InsetTabular * inset = static_cast<InsetTabular *>(
owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)); owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
inset->openLayoutDialog(owner->view()); inset->openLayoutDialog(owner->view().get());
} }
} }
break; break;
@ -1313,10 +1313,10 @@ void LyXFunc::dispatch(kb_action action, string argument, bool verbose)
if (owner->view()->theLockingInset()) if (owner->view()->theLockingInset())
owner->view()->unlockInset(owner->view()->theLockingInset()); owner->view()->unlockInset(owner->view()->theLockingInset());
if (par->inInset()) { if (par->inInset()) {
par->inInset()->edit(owner->view()); par->inInset()->edit(owner->view().get());
} }
// Set the cursor // Set the cursor
owner->view()->getLyXText()->setCursor(owner->view(), par, 0); owner->view()->getLyXText()->setCursor(owner->view().get(), par, 0);
owner->view()->switchKeyMap(); owner->view()->switchKeyMap();
owner->view_state_changed(); owner->view_state_changed();
@ -1879,5 +1879,5 @@ string const LyXFunc::view_status_message()
if (!owner->view()->available()) if (!owner->view()->available())
return _("Welcome to LyX!"); return _("Welcome to LyX!");
return currentState(owner->view()); return currentState(owner->view().get());
} }