mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-04 08:37:52 +00:00
e2bc7ffae3
RefChanger temporarily assigns a value to a non-const reference of any kind. RefChanger provides a flexible and uniform generalisation of the various scope guards previously derived from the old Changer class in MetricsInfo.h. As before, a temporary assignment lasts as long as the Changer object lives. But the new Changer is movable. In particular, contorsions are no longer needed to change a private field. Special code can be moved into the appropriate classes, and it is no longer necessary to create a new class for each specific use. Syntax change: FontSetChanger dummy(mi.base, value); -> Changer dummy = mi.base.changeFontSet(value); New function for generating arbitrary Changers: Changer dummy = make_change(ref, val, condition); Bugfix: * Fix the display of \displaystyle{\substack{\frac{xyz}{}}} (missing style change).
33 lines
556 B
C++
33 lines
556 B
C++
// -*- C++ -*-
|
|
/**
|
|
* \file Changer.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Guillaume Munch
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef LYX_CHANGER_H
|
|
#define LYX_CHANGER_H
|
|
|
|
#include "support/unique_ptr.h"
|
|
|
|
|
|
namespace lyx {
|
|
|
|
// Forward declaration for support/RefChanger.h
|
|
struct Revertible {
|
|
virtual ~Revertible() {}
|
|
virtual void revert() {}
|
|
virtual void keep() {}
|
|
};
|
|
|
|
using Changer = unique_ptr<Revertible>;
|
|
|
|
|
|
}
|
|
|
|
#endif //LYX_CHANGER_H
|