mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 22:06:15 +00:00
lib/lyx2lyx/lyx_1_5.py: fix revert of listings insets
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18262 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
486ca0c750
commit
a8e9fe82d0
@ -1391,6 +1391,9 @@ lstinline[language=Delphi]{var i = 10;}
|
|||||||
i = find_token(document.body, '\\begin_inset listings', i)
|
i = find_token(document.body, '\\begin_inset listings', i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
if not '\\usepackage{listings}' in document.preamble:
|
||||||
|
document.preamble.append('\\usepackage{listings}')
|
||||||
j = find_end_of_inset(document.body, i + 1)
|
j = find_end_of_inset(document.body, i + 1)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
# this should not happen
|
# this should not happen
|
||||||
@ -1410,31 +1413,41 @@ lstinline[language=Delphi]{var i = 10;}
|
|||||||
k = line + 1
|
k = line + 1
|
||||||
# looking for the oneline code for lstinline
|
# looking for the oneline code for lstinline
|
||||||
for line in range(i + 2, j + 1):
|
for line in range(i + 2, j + 1):
|
||||||
if document.body[line].startswith(r'\begin_layout'):
|
if document.body[line].startswith(r'\end_layout'):
|
||||||
inlinecode = document.body[line+1]
|
inlinecode = document.body[line - 1]
|
||||||
break
|
break
|
||||||
|
if len(params) > 0:
|
||||||
|
params = '[%s]' % params
|
||||||
if inline == 'true':
|
if inline == 'true':
|
||||||
document.body[i:(j+1)] = [r'\begin_inset ERT'
|
document.body[i:(j+1)] = [r'\begin_inset ERT',
|
||||||
'status %s' % status,
|
'status %s' % status,
|
||||||
r'\begin_layout Standard',
|
r'\begin_layout Standard',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
r'\backslash',
|
r'\backslash',
|
||||||
'lstinline[%s]{%s}' % (params, inlinecode),
|
'lstinline%s{%s}' % (params, inlinecode),
|
||||||
r'\end_layout',
|
r'\end_layout',
|
||||||
'',
|
'',
|
||||||
r'\end_inset']
|
r'\end_inset']
|
||||||
else:
|
else:
|
||||||
document.body[i: k] = [r'\begin_inset ERT',
|
document.body[i: j+1] = [r'\begin_inset ERT',
|
||||||
'status %s' % status,
|
'status %s' % status,
|
||||||
'',
|
'',
|
||||||
r'\begin_layout Standard',
|
r'\begin_layout Standard',
|
||||||
'',
|
'',
|
||||||
'',
|
'',
|
||||||
r'\backslash',
|
r'\backslash',
|
||||||
r'lstlisting[%s]{' % params,
|
r'begin{lstlisting}%s' % params,
|
||||||
r'\end_layout'
|
r'\end_layout'
|
||||||
]
|
] + document.body[k : j - 1] + \
|
||||||
|
['',
|
||||||
|
r'\begin_layout Standard',
|
||||||
|
'',
|
||||||
|
r'\backslash',
|
||||||
|
'end{lstlisting}',
|
||||||
|
r'\end_layout',
|
||||||
|
'',
|
||||||
|
r'\end_inset']
|
||||||
|
|
||||||
|
|
||||||
def revert_include_listings(document):
|
def revert_include_listings(document):
|
||||||
@ -1464,6 +1477,9 @@ lstinputlisting{file}[opt]
|
|||||||
i = find_token(document.body, r'\begin_inset Include \lstinputlisting', i)
|
i = find_token(document.body, r'\begin_inset Include \lstinputlisting', i)
|
||||||
if i == -1:
|
if i == -1:
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
if not '\\usepackage{listings}' in document.preamble:
|
||||||
|
document.preamble.append('\\usepackage{listings}')
|
||||||
j = find_end_of_inset(document.body, i + 1)
|
j = find_end_of_inset(document.body, i + 1)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
# this should not happen
|
# this should not happen
|
||||||
|
@ -298,6 +298,7 @@ Color::Color()
|
|||||||
{ graphicsbg, N_("graphics background"), "graphicsbg", "linen", "graphicsbg" },
|
{ graphicsbg, N_("graphics background"), "graphicsbg", "linen", "graphicsbg" },
|
||||||
{ mathmacrobg, N_("Math macro background"), "mathmacrobg", "linen", "mathmacrobg" },
|
{ mathmacrobg, N_("Math macro background"), "mathmacrobg", "linen", "mathmacrobg" },
|
||||||
{ mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" },
|
{ mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" },
|
||||||
|
{ mathcorners, N_("math corners"), "mathcorners", "linen", "mathcorners" },
|
||||||
{ mathline, N_("math line"), "mathline", "Blue", "mathline" },
|
{ mathline, N_("math line"), "mathline", "Blue", "mathline" },
|
||||||
{ captionframe, N_("caption frame"), "captionframe", "DarkRed", "captionframe" },
|
{ captionframe, N_("caption frame"), "captionframe", "DarkRed", "captionframe" },
|
||||||
{ collapsable, N_("collapsable inset text"), "collapsable", "DarkRed", "collapsable" },
|
{ collapsable, N_("collapsable inset text"), "collapsable", "DarkRed", "collapsable" },
|
||||||
|
@ -123,8 +123,10 @@ public:
|
|||||||
mathbg,
|
mathbg,
|
||||||
/// Macro math inset background color
|
/// Macro math inset background color
|
||||||
mathmacrobg,
|
mathmacrobg,
|
||||||
/// Math inset frame color
|
/// Math inset frame color under focus
|
||||||
mathframe,
|
mathframe,
|
||||||
|
/// Math inset frame color not under focus
|
||||||
|
mathcorners,
|
||||||
/// Math line color
|
/// Math line color
|
||||||
mathline,
|
mathline,
|
||||||
|
|
||||||
|
@ -117,12 +117,12 @@ static TranslatorMap const build_translator()
|
|||||||
|
|
||||||
/// pretty arbitrary dimensions
|
/// pretty arbitrary dimensions
|
||||||
Inset::Inset()
|
Inset::Inset()
|
||||||
: dim_(10, 10, 10), background_color_(Color::background)
|
: dim_(10, 10, 10), background_color_(Color::background), redraw_background_(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
Inset::Inset(Inset const & inset)
|
Inset::Inset(Inset const & inset)
|
||||||
: dim_(inset.dim_), background_color_(inset.background_color_)
|
: dim_(inset.dim_), background_color_(inset.background_color_), redraw_background_(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ void Inset::metricsMarkers2(Dimension & dim, int framesize) const
|
|||||||
void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
|
void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
Color::color pen_color = editing(pi.base.bv)?
|
Color::color pen_color = editing(pi.base.bv)?
|
||||||
Color::mathframe : Color::background;
|
Color::mathframe : Color::mathcorners;
|
||||||
|
|
||||||
int const t = x + width() - 1;
|
int const t = x + width() - 1;
|
||||||
int const d = y + descent();
|
int const d = y + descent();
|
||||||
@ -303,7 +303,7 @@ void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
|
|||||||
void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
|
void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
Color::color pen_color = editing(pi.base.bv)?
|
Color::color pen_color = editing(pi.base.bv)?
|
||||||
Color::mathframe : Color::background;
|
Color::mathframe : Color::mathcorners;
|
||||||
|
|
||||||
drawMarkers(pi, x, y);
|
drawMarkers(pi, x, y);
|
||||||
int const t = x + width() - 1;
|
int const t = x + width() - 1;
|
||||||
|
@ -192,6 +192,9 @@ public:
|
|||||||
/// is called when the mouse enter or leave this inset
|
/// is called when the mouse enter or leave this inset
|
||||||
/// return true if this inset needs repaint
|
/// return true if this inset needs repaint
|
||||||
virtual bool setMouseHover(bool) { return false; }
|
virtual bool setMouseHover(bool) { return false; }
|
||||||
|
/// tells an inset to redraw background
|
||||||
|
virtual void setRedrawBackground(bool rd) const { redraw_background_ = rd; }
|
||||||
|
bool redrawBackground() const { return redraw_background_; }
|
||||||
|
|
||||||
/// request "external features"
|
/// request "external features"
|
||||||
virtual void validate(LaTeXFeatures &) const {}
|
virtual void validate(LaTeXFeatures &) const {}
|
||||||
@ -489,6 +492,8 @@ private:
|
|||||||
* of the header file.
|
* of the header file.
|
||||||
*/
|
*/
|
||||||
int background_color_;
|
int background_color_;
|
||||||
|
|
||||||
|
mutable bool redraw_background_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ public:
|
|||||||
void mathmlize(MathStream &) const;
|
void mathmlize(MathStream &) const;
|
||||||
///
|
///
|
||||||
//void octave(OctaveStream &) const;
|
//void octave(OctaveStream &) const;
|
||||||
|
/// tells an inset to redraw background
|
||||||
protected:
|
protected:
|
||||||
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
#include "insets/RenderPreview.h"
|
#include "insets/RenderPreview.h"
|
||||||
#include "insets/InsetLabel.h"
|
#include "insets/InsetLabel.h"
|
||||||
|
#include "frontends/Painter.h"
|
||||||
|
|
||||||
#include "graphics/PreviewImage.h"
|
#include "graphics/PreviewImage.h"
|
||||||
#include "graphics/PreviewLoader.h"
|
#include "graphics/PreviewLoader.h"
|
||||||
@ -333,7 +334,15 @@ bool InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
|
|
||||||
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
|
// setRedrawBackground(false);
|
||||||
use_preview_ = previewState(pi.base.bv);
|
use_preview_ = previewState(pi.base.bv);
|
||||||
|
/*Cursor & cur = pi.base.bv->cursor();
|
||||||
|
if (!editing(pi.base.bv) || !cur.selection() || &cur.inset() != this)
|
||||||
|
*/
|
||||||
|
lyxerr << "redraw " << x << " " << y << " " << width() << " " << redrawBackground() << std::endl;
|
||||||
|
if (redrawBackground())
|
||||||
|
pi.pain.fillRectangle(x + 1, y - ascent() + 1, width() - 2,
|
||||||
|
ascent() + descent() - 1, Color::mathbg);
|
||||||
|
|
||||||
if (use_preview_) {
|
if (use_preview_) {
|
||||||
// one pixel gap in front
|
// one pixel gap in front
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "InsetMathGrid.h"
|
#include "InsetMathGrid.h"
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
@ -120,7 +121,6 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
static int displayMargin() { return 12; }
|
static int displayMargin() { return 12; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
InsetMathHull(InsetMathHull const &);
|
InsetMathHull(InsetMathHull const &);
|
||||||
|
|
||||||
@ -183,6 +183,8 @@ private:
|
|||||||
boost::scoped_ptr<RenderPreview> preview_;
|
boost::scoped_ptr<RenderPreview> preview_;
|
||||||
///
|
///
|
||||||
mutable bool use_preview_;
|
mutable bool use_preview_;
|
||||||
|
///
|
||||||
|
/// mutable bool redraw_background_;
|
||||||
//
|
//
|
||||||
// Incorporate me
|
// Incorporate me
|
||||||
//
|
//
|
||||||
|
@ -310,6 +310,8 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
|
|||||||
|| x >= bv. workWidth())
|
|| x >= bv. workWidth())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (size_t i = 0, n = size(); i != n; ++i) {
|
for (size_t i = 0, n = size(); i != n; ++i) {
|
||||||
MathAtom const & at = operator[](i);
|
MathAtom const & at = operator[](i);
|
||||||
#if 0
|
#if 0
|
||||||
@ -331,7 +333,10 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
|
|||||||
#endif
|
#endif
|
||||||
bv.coordCache().insets().add(at.nucleus(), x, y);
|
bv.coordCache().insets().add(at.nucleus(), x, y);
|
||||||
at->drawSelection(pi, x, y);
|
at->drawSelection(pi, x, y);
|
||||||
|
at->setRedrawBackground(false);
|
||||||
|
lyxerr << "selection draw " << x << " " << y << " " << at->redrawBackground() << std::endl;
|
||||||
at->draw(pi, x, y);
|
at->draw(pi, x, y);
|
||||||
|
//at->setRedrawBackground(true);
|
||||||
x += at->width();
|
x += at->width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user