Hello,
This patch continue the BufferView cleanup series. There are only two
changes in this patch. See Lars? I am improving ;-)
First it erase the clipboard methods from BufferView and change the
code to use the global clipboard directly via the indirection
"BufferView::owner()->gui().clipboard()". This may seem complicated (and
it is) but the clipboard have nothing to do with the BufferView. The
goal is to have in the future some class that gives access to global
application properties like the Application class in qt4/. When we have
that, we will access the Clipboard via "theApp->clipboard()".
* BufferView and BufferView::pimpl:
- getClipboard, stuffClipboard, haveSelection: deleted
* CutAndPaste.C: use BufferView::owner()->gui().clipboard()
* insettabular.C: ditto
* math_nestinset.C: ditto
* text3.C: ditto
Second, it deletes the delete "BufferView::repaintAll()" methods. These
methods were used as a temporary variable inside rowpainter.C for
some recursive function. This temporary variable (refresh_inside_) was
never initialized and its value is always saved and restored for each
operation so it is _not_ BufferView dependant.
This methods replace the use of the repaintAll() methods with the
variable refreshInside which is local to rowpainter.C. This rowpainter
code needs some cleanup.
* BufferView and Bufferview::pimpl: repaintAll() methods deleted.
* rowpainter.C:
- refreshInside : new variable in the anonymous namespace.
- use of refreshInside instead of the repaintAll() methods
I will commit this to the younes branch as I don't have to do a merge to
trunk now. I am off for a few days so Lars, feel free to take care of
the merge is you are willing to.
Thanks,
Abdel.
Index: src/BufferView.C
===================================================================
--- src/BufferView.C (revision 14313)
+++ src/BufferView.C (working copy)
@@ -205,18 +205,6 @@
}
-string const BufferView::getClipboard() const
-{
- return pimpl_->gui().clipboard().get();
-}
-
-
-void BufferView::stuffClipboard(string const & stuff) const
-{
- pimpl_->stuffClipboard(stuff);
-}
-
-
FuncStatus BufferView::getStatus(FuncRequest const & cmd)
{
return pimpl_->getStatus(cmd);
@@ -326,12 +314,6 @@
}
-void BufferView::haveSelection(bool sel)
-{
- pimpl_->gui().clipboard().haveSelection(sel);
-}
-
-
int BufferView::workHeight() const
{
return pimpl_->height();
@@ -392,18 +374,6 @@
}
-bool const BufferView::repaintAll() const
-{
- return pimpl_->repaintAll();
-}
-
-
-void const BufferView::repaintAll(bool r) const
-{
- pimpl_->repaintAll(r);
-}
-
-
LCursor & BufferView::cursor()
{
return pimpl_->cursor_;
Index: src/BufferView.h
===================================================================
--- src/BufferView.h (revision 14313)
+++ src/BufferView.h (working copy)
@@ -176,13 +176,6 @@
/// switch between primary and secondary keymaps for RTL entry
void switchKeyMap();
- /// get the contents of the window system clipboard
- std::string const getClipboard() const;
- /// fill the window system clipboard
- void stuffClipboard(std::string const &) const;
- /// tell the window system we have a selection
- void haveSelection(bool sel);
-
/// return true for events that will handle
FuncStatus getStatus(FuncRequest const & cmd);
/// execute the given function
@@ -229,10 +222,6 @@
void putSelectionAt(DocIterator const & cur,
int length, bool backwards);
///
- bool const repaintAll() const;
- ///
- void const repaintAll(bool r) const;
- ///
ViewMetricsInfo const & viewMetricsInfo();
/// needs_redraw_ accessor
Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C (revision 14313)
+++ src/BufferView_pimpl.C (working copy)
@@ -815,12 +815,7 @@
}
-void BufferView::Pimpl::stuffClipboard(string const & content) const
-{
- owner_->gui().clipboard().put(content);
-}
-
void BufferView::Pimpl::menuInsertLyXFile(string const & filenm)
{
BOOST_ASSERT(cursor_.inTexted());
Index: src/BufferView_pimpl.h
===================================================================
--- src/BufferView_pimpl.h (revision 14313)
+++ src/BufferView_pimpl.h (working copy)
@@ -101,10 +101,6 @@
FuncStatus getStatus(FuncRequest const & cmd);
/// a function should be executed
bool dispatch(FuncRequest const & ev);
- /// Flag: do a full redraw of inside text of inset
- bool repaintAll() { return refresh_inside_; }
- ///
- void repaintAll(bool r) {refresh_inside_ = r; }
/// the frontend
lyx::frontend::Gui & gui() const;
@@ -187,8 +183,6 @@
/// Estimated average par height for scrollbar
int wh_;
///
- void stuffClipboard(std::string const &) const;
- ///
bool using_xterm_cursor;
///
class Position {
@@ -224,8 +218,6 @@
lyx::pit_type anchor_ref_;
///
int offset_ref_;
- /// Working variable indicating a full screen refresh
- mutable bool refresh_inside_;
};
#endif // BUFFERVIEW_PIMPL_H
Index: src/CutAndPaste.C
===================================================================
--- src/CutAndPaste.C (revision 14313)
+++ src/CutAndPaste.C (working copy)
@@ -45,6 +45,10 @@
#include "support/lstrings.h"
+#include "frontends/Gui.h"
+#include "frontends/LyXView.h"
+#include "frontends/Clipboard.h"
+
#include <boost/tuple/tuple.hpp>
using lyx::pos_type;
@@ -53,6 +57,9 @@
using lyx::support::bformat;
+using lyx::frontend::Gui;
+using lyx::frontend::Clipboard;
+
using std::endl;
using std::for_each;
using std::make_pair;
@@ -492,7 +499,8 @@
// finished. The solution used currently just works, to make it
// faster we need to be more clever and probably also have more
// calls to stuffClipboard. (Lgb)
-// cur.bv().stuffClipboard(cur.selectionAsString(true));
+//
cur.bv().owner()->gui().clipboard().put(cur.selectionAsString(true));
+
// make sure that the depth behind the selection are restored,
too
recordUndoSelection(cur);
@@ -555,7 +563,7 @@
void copySelection(LCursor & cur)
{
// stuff the selection onto the X clipboard, from an explicit copy
request
- cur.bv().stuffClipboard(cur.selectionAsString(true));
+ cur.bv().owner()->gui().clipboard().put(cur.selectionAsString(true));
// this doesn't make sense, if there is no selection
if (!cur.selection())
Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C (revision 14313)
+++ src/insets/insettabular.C (working copy)
@@ -38,7 +38,9 @@
#include "frontends/Alert.h"
#include "frontends/font_metrics.h"
+#include "frontends/Gui.h"
#include "frontends/LyXView.h"
+#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "frontends/nullpainter.h"
@@ -54,6 +56,8 @@
using lyx::support::ltrim;
using lyx::frontend::Painter;
+using lyx::frontend::Gui;
+using lyx::frontend::Clipboard;
using boost::shared_ptr;
@@ -671,7 +675,7 @@
break;
case LFUN_PRIMARY_SELECTION_PASTE: {
- string const clip = cur.bv().getClipboard();
+ string const clip = cur.bv().owner()->gui().clipboard().get();
if (clip.empty())
break;
// pass to InsertAsciiString, but
@@ -1692,7 +1696,7 @@
ostringstream os;
OutputParams const runparams;
paste_tabular->plaintext(cur.buffer(), os, runparams, 0, true, '\t');
- cur.bv().stuffClipboard(os.str());
+ cur.bv().owner()->gui().clipboard().put(os.str());
// mark tabular stack dirty
// FIXME: this is a workaround for bug 1919. Should be removed for 1.5,
// when we (hopefully) have a one-for-all paste mechanism.
Index: src/mathed/math_nestinset.C
===================================================================
--- src/mathed/math_nestinset.C (revision 14313)
+++ src/mathed/math_nestinset.C (working copy)
@@ -50,7 +50,9 @@
#include "support/lstrings.h"
#include "frontends/Dialogs.h"
+#include "frontends/Gui.h"
#include "frontends/LyXView.h"
+#include "frontends/Clipboard.h"
#include "frontends/Painter.h"
#include "frontends/nullpainter.h"
@@ -62,6 +64,9 @@
using lyx::cap::replaceSelection;
using lyx::cap::selClearOrDel;
+using lyx::frontend::Gui;
+using lyx::frontend::Clipboard;
+
using std::endl;
using std::string;
using std::istringstream;
@@ -1083,7 +1088,7 @@
if (cmd.button() == mouse_button::button2) {
MathArray ar;
- asArray(cur.bv().getClipboard(), ar);
+ asArray(cur.bv().owner()->gui().clipboard().get(), ar);
cur.clearSelection();
editXY(cur, cmd.x, cmd.y);
cur.insert(ar);
@@ -1116,7 +1121,7 @@
//lyxerr << "## lfunMouseRelease: buttons: " << cmd.button() << endl;
if (cmd.button() == mouse_button::button1) {
- //cur.bv().stuffClipboard(cur.grabSelection());
+ //cur.bv().owner()->gui().clipboard().put(cur.grabSelection());
return;
}
Index: src/rowpainter.C
===================================================================
--- src/rowpainter.C (revision 14313)
+++ src/rowpainter.C (working copy)
@@ -56,6 +56,10 @@
namespace {
+/// Flag: do a full redraw of inside text of inset
+/// Working variable indicating a full screen refresh
+bool refreshInside;
+
/**
* A class used for painting an individual row of text.
*/
@@ -169,15 +173,15 @@
theCoords.insets().add(inset, int(x_), yo_);
InsetText const * const in = inset->asTextInset();
// non-wide insets are painted completely. Recursive
- bool tmp = bv_.repaintAll();
+ bool tmp = refreshInside;
if (!in || !in->Wide()) {
- bv_.repaintAll(true);
+ refreshInside = true;
lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl;
}
- if (bv_.repaintAll())
+ if (refreshInside)
inset->drawSelection(pi, int(x_), yo_);
inset->draw(pi, int(x_), yo_);
- bv_.repaintAll(tmp);
+ refreshInside = tmp;
x_ += inset->width();
}
@@ -801,9 +805,9 @@
lyx::size_type rowno(0);
for (RowList::const_iterator rit = rb; rit != re; ++rit, ++rowno) {
y += rit->ascent();
- // Allow setting of bv->repaintAll() for nested insets in
+ // Allow setting of refreshInside for nested insets in
// this row only
- bool tmp = pi.base.bv->repaintAll();
+ bool tmp = refreshInside;
// Row signature; has row changed since last paint?
lyx::size_type const row_sig = calculateRowSignature(*rit, par,
x, y);
@@ -843,7 +847,7 @@
// If outer row has changed, force nested
// insets to repaint completely
if (row_has_changed)
- pi.base.bv->repaintAll(true);
+ refreshInside = true;
}
// Instrumentation for testing row cache (see also
@@ -865,7 +869,7 @@
}
y += rit->descent();
// Restore, see above
- pi.base.bv->repaintAll(tmp);
+ refreshInside = tmp;
}
lyxerr[Debug::PAINTING] << "." << endl;
}
@@ -880,7 +884,7 @@
PainterInfo pi(const_cast<BufferView *>(&bv), pain);
// Should the whole screen, including insets, be refreshed?
- bool repaintAll(select || !vi.singlepar);
+ bool repaintAll = select || !vi.singlepar;
if (repaintAll) {
// Clear background (if not delegated to rows)
@@ -894,7 +898,7 @@
int yy = vi.y1;
// draw contents
for (pit_type pit = vi.p1; pit <= vi.p2; ++pit) {
- bv.repaintAll(repaintAll);
+ refreshInside = repaintAll;
Paragraph const & par = text->getPar(pit);
yy += par.ascent();
paintPar(pi, *bv.text(), pit, 0, yy, repaintAll);
@@ -935,7 +939,7 @@
y -= text.getPar(0).ascent();
// This flag can not be set from within same inset:
- bool repaintAll = pi.base.bv->repaintAll();
+ bool repaintAll = refreshInside;
for (int pit = 0; pit < int(text.paragraphs().size()); ++pit) {
y += text.getPar(pit).ascent();
paintPar(pi, text, pit, x, y, repaintAll);
Index: src/text3.C
===================================================================
--- src/text3.C (revision 14313)
+++ src/text3.C (working copy)
@@ -47,7 +47,9 @@
#include "pariterator.h"
#include "frontends/Dialogs.h"
+#include "frontends/Gui.h"
#include "frontends/LyXView.h"
+#include "frontends/Clipboard.h"
#include "insets/insetcommand.h"
#include "insets/insetfloatlist.h"
@@ -79,6 +81,9 @@
using lyx::support::isStrUnsignedInt;
using lyx::support::token;
+using lyx::frontend::Gui;
+using lyx::frontend::Clipboard;
+
using std::endl;
using std::string;
using std::istringstream;
@@ -119,7 +124,7 @@
if (selecting || cur.mark())
cur.setSelection();
if (!cur.selection())
- cur.bv().haveSelection(false);
+
cur.bv().owner()->gui().clipboard().haveSelection(false);
cur.bv().switchKeyMap();
}
@@ -980,7 +985,7 @@
case LFUN_PRIMARY_SELECTION_PASTE: {
cur.clearSelection();
- string const clip = bv->getClipboard();
+ string const clip = bv->owner()->gui().clipboard().get();
if (!clip.empty()) {
recordUndo(cur);
if (cmd.argument == "paragraph")
@@ -1040,7 +1045,7 @@
cursorEnd(cur);
cur.setSelection();
bv->cursor() = cur;
- bv->haveSelection(cur.selection());
+
bv->owner()->gui().clipboard().haveSelection(cur.selection());
}
break;
@@ -1048,7 +1053,7 @@
if (cmd.button() == mouse_button::button1) {
selectWord(cur, lyx::WHOLE_WORD_STRICT);
bv->cursor() = cur;
- bv->haveSelection(cur.selection());
+
bv->owner()->gui().clipboard().haveSelection(cur.selection());
}
break;
@@ -1130,7 +1135,7 @@
// finish selection
if (cmd.button() == mouse_button::button1)
- bv->haveSelection(cur.selection());
+
bv->owner()->gui().clipboard().haveSelection(cur.selection());
bv->switchKeyMap();
bv->owner()->updateMenubar();
@@ -1151,7 +1156,7 @@
if (lyxrc.auto_region_delete) {
if (cur.selection())
cutSelection(cur, false, false);
- bv->haveSelection(false);
+ bv->owner()->gui().clipboard().haveSelection(false);
}
cur.clearSelection();