From 5a6c9536f63220a3dbe8223f9aed8dab05aacac5 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 25 Feb 2003 19:09:00 +0000 Subject: [PATCH] (Alfredo) strip BufferView out of the graphics code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6268 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/XWorkArea.C | 45 ++++---------------------------- src/graphics/ChangeLog | 9 +++++++ src/graphics/GraphicsLoader.C | 15 +++-------- src/graphics/GraphicsLoader.h | 6 ++--- src/graphics/PreviewImage.C | 12 ++++----- src/graphics/PreviewImage.h | 4 +-- src/graphics/PreviewedInset.C | 2 +- src/insets/ChangeLog | 6 +++++ src/insets/insetgraphics.C | 2 +- src/insets/insetinclude.C | 2 +- src/mathed/formula.C | 2 +- src/mathed/formulabase.C | 31 ++++++++++++++-------- 12 files changed, 57 insertions(+), 79 deletions(-) diff --git a/src/frontends/xforms/XWorkArea.C b/src/frontends/xforms/XWorkArea.C index 561d90b5b5..3bf532b960 100644 --- a/src/frontends/xforms/XWorkArea.C +++ b/src/frontends/xforms/XWorkArea.C @@ -368,55 +368,20 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event, case FL_KEYPRESS: { lyxerr[Debug::WORKAREA] << "Workarea event: KEYPRESS" << endl; - - KeySym keysym = 0; - char dummy[1]; XKeyEvent * xke = reinterpret_cast(ev); - XLookupString(xke, dummy, 1, &keysym, 0); if (lyxerr.debugging(Debug::KEY)) { char const * const tmp = XKeysymToString(key); - char const * const tmp2 = XKeysymToString(keysym); - string const stm = (tmp ? tmp : string()); - string const stm2 = (tmp2 ? tmp2 : string()); - - lyxerr << "XWorkArea: Key is `" << stm - << "' [" << key << "]\n" - << "XWorkArea: Keysym is `" << stm2 - << "' [" << keysym << ']' << endl; + lyxerr << "XWorkArea: Key is `" << tmp + << "' [" << key << "]" << endl; } - // Note that we need this handling because of a bug - // in XForms 0.89, if this bug is resolved in the way I hope - // we can just use the keysym directly without looking - // at key at all. (Lgb) - KeySym ret_key = 0; if (!key) { - // We might have to add more keysyms here also, - // we will do that as the issues arise. (Lgb) - if (keysym == XK_space) { - ret_key = keysym; - lyxerr[Debug::KEY] << "Using keysym [A]" - << endl; - } else - break; - } else { - // It seems that this was a bit optimistic... - // With this hacking things seems to be better (Lgb) - //if (!iscntrl(key)) { - // ret_key = key; - // lyxerr[Debug::KEY] - // << "Using key [B]\n" - // << "Uchar[" - // << static_cast(key) - // << endl; - //} else { - ret_key = (keysym ? keysym : key); - lyxerr[Debug::KEY] << "Using keysym [B]" - << endl; - //} + lyxerr << "Probably composing" << endl; + break; } + KeySym ret_key = key; unsigned int const ret_state = xke->state; // If you have a better way to handle "wild-output" of diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 3c2ba3e9d8..c7605830e7 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,12 @@ +2003-02-25 Alfredo Braunstein + + * GraphicsConverter (startConversion): add the call to + ForkedCallQueue::add + + * GraphicsLoader.[Ch], + * PreviewImage.[Ch], + * PreviewedInset.C: Removed unneeded BufferView + 2003-02-25 Alfredo Braunstein * LoaderQueue.[Ch]: a simplification of the code, eliminated diff --git a/src/graphics/GraphicsLoader.C b/src/graphics/GraphicsLoader.C index 5bfa5ac6cc..02f99da749 100644 --- a/src/graphics/GraphicsLoader.C +++ b/src/graphics/GraphicsLoader.C @@ -12,8 +12,6 @@ #include "GraphicsLoader.h" -#include "BufferView.h" - #include "GraphicsCache.h" #include "GraphicsCacheItem.h" #include "GraphicsImage.h" @@ -21,9 +19,7 @@ #include "LoaderQueue.h" #include "frontends/LyXView.h" -#include "frontends/Timeout.h" -#include #include #include @@ -44,7 +40,7 @@ struct Loader::Impl : boost::signals::trackable { void createPixmap(); /// - void startLoading(Inset const &, BufferView const &); + void startLoading(Inset const &); /// The loading status of the image. ImageStatus status_; @@ -70,8 +66,6 @@ private: typedef std::list InsetList; /// InsetList insets; - /// - boost::weak_ptr view; }; @@ -132,11 +126,11 @@ void Loader::startLoading() const } -void Loader::startLoading(Inset const & inset, BufferView const & bv) const +void Loader::startLoading(Inset const & inset) const { if (pimpl_->status_ != WaitingToLoad || !pimpl_->cached_item_.get()) return; - pimpl_->startLoading(inset, bv); + pimpl_->startLoading(inset); } @@ -287,7 +281,7 @@ void Loader::Impl::createPixmap() } -void Loader::Impl::startLoading(Inset const & inset, BufferView const & bv) +void Loader::Impl::startLoading(Inset const & inset) { if (status_ != WaitingToLoad) return; @@ -297,7 +291,6 @@ void Loader::Impl::startLoading(Inset const & inset, BufferView const & bv) it = std::find(it, end, &inset); if (it == end) insets.push_back(&inset); - view = bv.owner()->view(); LoaderQueue::get().touch(cached_item_); } diff --git a/src/graphics/GraphicsLoader.h b/src/graphics/GraphicsLoader.h index ddd43e3b87..2fcd23a262 100644 --- a/src/graphics/GraphicsLoader.h +++ b/src/graphics/GraphicsLoader.h @@ -66,10 +66,10 @@ public: /// We are explicit about when we begin the loading process. void startLoading() const; - /** starting loading of the image is conditional upon the - * inset being visible or not. + /** starting loading of the image is done by a urgency-based + * decision. Here we only call LoaderQueue::touch to request it. */ - void startLoading(Inset const &, BufferView const &) const; + void startLoading(Inset const &) const; /** Monitor any changes to the file. * There is no point monitoring the file before startLoading() is diff --git a/src/graphics/PreviewImage.C b/src/graphics/PreviewImage.C index 2ec2e846d2..2dde30b979 100644 --- a/src/graphics/PreviewImage.C +++ b/src/graphics/PreviewImage.C @@ -30,7 +30,7 @@ struct PreviewImage::Impl : public boost::signals::trackable { /// ~Impl(); /// - Image const * image(Inset const &, BufferView const &); + Image const * image(Inset const &); /// void statusChanged(); @@ -93,10 +93,9 @@ int PreviewImage::width() const } -Image const * PreviewImage::image(Inset const & inset, - BufferView const & bv) const +Image const * PreviewImage::image(Inset const & inset) const { - return pimpl_->image(inset, bv); + return pimpl_->image(inset); } @@ -117,11 +116,10 @@ PreviewImage::Impl::~Impl() } -Image const * PreviewImage::Impl::image(Inset const & inset, - BufferView const & bv) +Image const * PreviewImage::Impl::image(Inset const & inset) { if (iloader_.status() == WaitingToLoad) - iloader_.startLoading(inset, bv); + iloader_.startLoading(inset); return iloader_.image(); } diff --git a/src/graphics/PreviewImage.h b/src/graphics/PreviewImage.h index f4909d4538..bc12bfb81b 100644 --- a/src/graphics/PreviewImage.h +++ b/src/graphics/PreviewImage.h @@ -46,10 +46,8 @@ public: /** If the image is not yet loaded (WaitingToLoad), then this method * triggers that. - * inset and bv are passed so we can choose to load only - * those insets that are visible. */ - Image const * image(Inset const & inset, BufferView const & bv) const; + Image const * image(Inset const & inset) const; private: /// Use the Pimpl idiom to hide the internals. diff --git a/src/graphics/PreviewedInset.C b/src/graphics/PreviewedInset.C index 6cb33c9769..89604d6747 100644 --- a/src/graphics/PreviewedInset.C +++ b/src/graphics/PreviewedInset.C @@ -105,7 +105,7 @@ bool PreviewedInset::previewReady() const if (!pimage_) return false; - return pimage_->image(inset_, *view()); + return pimage_->image(inset_); } diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 7217ea5f10..92953044f3 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2003-02-25 Alfredo Braunstein + + * insetgraphics.C (draw) + * insetinclude.C (draw): Eliminate Buferview argument in call to + PreviewImage::image + 2003-02-25 John Levon * insetgraphicsParams.h: diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 604bcc37e3..f344ead2a4 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -348,7 +348,7 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, if (gparams.display != grfx::NoDisplay && cache_->loader.status() == grfx::WaitingToLoad) - cache_->loader.startLoading(*this, *bv); + cache_->loader.startLoading(*this); if (!cache_->loader.monitoring()) cache_->loader.startMonitoring(); diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 54b53c508e..93efb6d10f 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -534,7 +534,7 @@ void InsetInclude::draw(BufferView * bv, LyXFont const & font, int y, int const h = a + d; bv->painter().image(x, y - a, w, h, - *(preview_->pimage()->image(*this, *bv))); + *(preview_->pimage()->image(*this))); xx += w; } diff --git a/src/mathed/formula.C b/src/mathed/formula.C index f903814baa..be88b35c58 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -211,7 +211,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font, if (use_preview) { pi.pain.image(x + 1, y - a, w, h, // one pixel gap in front - *(preview_->pimage()->image(*this, *bv))); + *(preview_->pimage()->image(*this))); } else { pi.base.style = LM_ST_TEXT; pi.base.font = font; diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index f1b50471c0..98474106e1 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -51,7 +51,6 @@ #include "textpainter.h" #include "frontends/Dialogs.h" #include "intl.h" -#include "insets/insetcommand.h" #include "ref_inset.h" using std::endl; @@ -798,8 +797,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) case LFUN_DIALOG_SHOW_NEW_INSET: { string const & name = argument; if (name == "ref") { - InsetCommandParams p(name); - string data = InsetCommandMailer::params2string(p); + string data = "LatexCommand \\ref{}\n\\end_inset\n\n"; bv->owner()->getDialogs().show(name, data, 0); } else result = UNDISPATCHED; @@ -807,13 +805,24 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) break; case LFUN_REF_APPLY: { - InsetCommandParams params; - InsetCommandMailer::string2params(argument, params); + // argument comes with a head "LatexCommand " and a + // tail "\nend_inset\n\n". Strip them off. + string trimmed; + string body = split(argument, trimmed, ' '); + split(body, trimmed, '\n'); + lyxerr << "passing '" << trimmed << "' to the math parser\n"; + + MathAtom at; + if (!mathed_parse_normal(at, trimmed)) { + result = UNDISPATCHED; + break; + } - // It would be nice if RefInset could handle an - // InsetCommandParams arg, but for now we convert it to - // 'foo|++|bar|++|nonsense'. - string const tmp = params.getAsString(); + RefInset * tmp = at.nucleus()->asRefInset(); + if (!tmp) { + result = UNDISPATCHED; + break; + } InsetBase * base = bv->owner()->getDialogs().getOpenInset("ref"); @@ -824,9 +833,9 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd) break; } - *inset = RefInset(tmp); + *inset = *tmp; } else { - mathcursor->insert(MathAtom(new RefInset(tmp))); + mathcursor->insert(at); } updateLocal(bv, true); } -- 2.39.2