Commit Graph

82 Commits

Author SHA1 Message Date
Richard Heck
4b1777d2fa Inset::addToToc() can and should be const. It wasn't, I take it, because
of things like:
  pit.push_back(CursorSlice(*this));
which I've had to change to:
  pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
and similarly in a few other places.

If anyone thinks we should instead have:
  explicit CursorSlice(Inset const &);
then we can also do that.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37192 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-12 22:23:27 +00:00
Richard Heck
645f9fdf6d Fix bug #6894. We save counter information during updateBuffer(), and
then output \setcounter macros during snippet generation, so that we get
the right equation values.

Note: It would be possible to use this same machinery to fix bugs in
instant preview, e.g., that you always get things like (0.3) as equation
numbers, if you use equations numbered by section. I'll perhaps post a
patch for that.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37186 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-12 16:04:59 +00:00
Richard Heck
68c43a2b18 XHTML output was a mess for grids output as LaTeX. This will probably
still be a mess in many cases, but hopefully we won't have to go here
very often.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37181 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-11 23:55:20 +00:00
Richard Heck
fe9aabf34a Fix equation number output for MathML+HTML.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37180 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-11 23:34:59 +00:00
Richard Heck
7ef3d12a80 Fix equation number output for XHTML+MathML. HTML to come.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37179 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-11 23:18:56 +00:00
Richard Heck
47ca44e296 Record and use equation numbers. This is towards getting equation
numbering in XHTML output, but it's just as easy to fix this in the LyX
display.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37177 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-11 19:35:52 +00:00
Richard Heck
9e9c96035c Finish disentangling tocString(). We introduce a new method, forToc(),
that also makes sure it doesn't do more work than it needs to do, by
limiting the size to 40 characters. Previously, InsetBranch::addToToc()
would have added a string representing the entire contents of the
branch! It's hard to imagine that having to recalculate that sort of
thing doesn't cause some problems with speed, especially in documents
with lots of notes and branches and such.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36974 a592a061-630c-0410-9148-cb99ea01b6c8
2010-12-20 21:55:09 +00:00
Richard Heck
832d6cd7e1 Begin undoing the tocString() mess by renaming that routine.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36889 a592a061-630c-0410-9148-cb99ea01b6c8
2010-12-15 01:34:04 +00:00
Vincent van Ravesteijn
e7f2bbe1ee Rename InsetXXX::contextMenu to InsetXXX::contextMenuName. Now this function doesn't need all the parameters and we split the functionality of choosing which context menu to return, from the functionality of supplying the name for the Inset itself. Now, the InsetText context menu is returned for InsetCollapsables when the button is not hit by the mouse. There is no (intended) change in functionality for insets without a button, collapsed insets. This fixes partly bug #6642. A fix for InsetTabular and for insets with no button will follow.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36604 a592a061-630c-0410-9148-cb99ea01b6c8
2010-11-29 21:27:25 +00:00
Enrico Forestieri
79ef98205d Fix bug #7019 (Math labels should not be escaped on saving)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36156 a592a061-630c-0410-9148-cb99ea01b6c8
2010-11-06 02:53:29 +00:00
Vincent van Ravesteijn
8a550ba48a I don't like negated logic. Especially not if it leads to the use of more !-operations.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35801 a592a061-630c-0410-9148-cb99ea01b6c8
2010-10-24 17:27:32 +00:00
Jean-Marc Lasgouttes
6d4709d46c Sanitize ColorChanger
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35331 a592a061-630c-0410-9148-cb99ea01b6c8
2010-09-09 13:02:20 +00:00
Enrico Forestieri
fa0cd9ad60 Fix bug #6793: Changing an existing formula type to displayed formula loses the label
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35178 a592a061-630c-0410-9148-cb99ea01b6c8
2010-08-19 13:58:36 +00:00
Richard Heck
e48fb0b661 Allow images to be export even when LyXRC says no previews.
I'll try to figure out how to get rid of the magic booleans.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35022 a592a061-630c-0410-9148-cb99ea01b6c8
2010-07-29 15:17:58 +00:00
Richard Heck
80aca38970 Partially revert r34995, which broke math output. Not sure why yet....
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35001 a592a061-630c-0410-9148-cb99ea01b6c8
2010-07-22 02:20:12 +00:00
Richard Heck
c036ecb649 Tweak the math-as-LaTeX output, including the correct tags for jsMath.
We don't yet write info to load the jsMath files, though.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34995 a592a061-630c-0410-9148-cb99ea01b6c8
2010-07-21 13:43:35 +00:00
Richard Heck
b8d43b05bc Support for exporting math as images with XHTML. The next step is to
allow this as a fallback. E.g., if we're unable to export as MathML,
then we try to export as an image.

There are several ways, I am sure, in which this implementation is not
ideal.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34993 a592a061-630c-0410-9148-cb99ea01b6c8
2010-07-21 13:19:52 +00:00
Enrico Forestieri
9536afe742 Fix bug #6595: empty last row of matrix or eqnarray vanishes.
This patch essentially reverts r30795 and also provides the correct fix
for #2969.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34751 a592a061-630c-0410-9148-cb99ea01b6c8
2010-07-04 16:31:53 +00:00
Uwe Stöhr
106d31cd67 InsetMathHull.h: fix typo in comment
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34445 a592a061-630c-0410-9148-cb99ea01b6c8
2010-05-22 00:46:57 +00:00
Vincent van Ravesteijn
86eaa6de73 Another base class without a virtual destructor.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34362 a592a061-630c-0410-9148-cb99ea01b6c8
2010-05-03 22:55:40 +00:00
Enrico Forestieri
6c33aa2e5b Index: src/mathed/InsetMathHull.cpp
===================================================================
--- src/mathed/InsetMathHull.cpp	(revisione 34304)
+++ src/mathed/InsetMathHull.cpp	(copia locale)
@@ -328,6 +328,23 @@ docstring InsetMathHull::standardFont()
 }
 
 
+docstring InsetMathHull::standardColor() const
+{
+	docstring color;
+	switch (type_) {
+	case hullRegexp:
+		color = from_ascii("foreground");
+		break;
+	case hullNone:
+		color = from_ascii("foreground");
+		break;
+	default:
+		color = from_ascii("math");
+	}
+	return color;
+}
+
+
 bool InsetMathHull::previewState(BufferView * bv) const
 {
 	if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
@@ -417,8 +434,11 @@ void InsetMathHull::draw(PainterInfo & p
 		return;
 	}
 
+	bool const really_change_color = pi.base.font.color() == Color_none;
+	ColorChanger dummy0(pi.base.font, standardColor(), really_change_color);
 	FontSetChanger dummy1(pi.base, standardFont());
 	StyleChanger dummy2(pi.base, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+
 	InsetMathGrid::draw(pi, x + 1, y);
 
 	if (numberedType()) {
Index: src/mathed/MathSupport.cpp
===================================================================
--- src/mathed/MathSupport.cpp	(revisione 34311)
+++ src/mathed/MathSupport.cpp	(copia locale)
@@ -653,6 +653,13 @@ bool isMathFont(docstring const & name)
 }
 
 
+bool isTextFont(docstring const & name)
+{
+	fontinfo * f = lookupFont(name);
+	return f && f->color_ == Color_foreground;
+}
+
+
 FontInfo getFont(docstring const & name)
 {
 	FontInfo font;
Index: src/mathed/MathSupport.h
===================================================================
--- src/mathed/MathSupport.h	(revisione 34311)
+++ src/mathed/MathSupport.h	(copia locale)
@@ -51,6 +51,8 @@ bool isFontName(docstring const & name);
 
 bool isMathFont(docstring const & name);
 
+bool isTextFont(docstring const & name);
+
 // converts single cell to string
 docstring asString(MathData const & ar);
 // converts single inset to string
Index: src/mathed/InsetMathHull.h
===================================================================
--- src/mathed/InsetMathHull.h	(revisione 34304)
+++ src/mathed/InsetMathHull.h	(copia locale)
@@ -197,6 +197,8 @@ private:
 	void changeCols(col_type);
 	///
 	docstring standardFont() const;
+	///
+	docstring standardColor() const;
 	/// consistency check
 	void check() const;
 	/// can this change its number of rows?
Index: src/MetricsInfo.cpp
===================================================================
--- src/MetricsInfo.cpp	(revisione 34312)
+++ src/MetricsInfo.cpp	(copia locale)
@@ -235,11 +235,15 @@ FontSetChanger::FontSetChanger(MetricsBa
 		save_ = mb;
 		FontSize oldsize = save_.font.size();
 		ColorCode oldcolor = save_.font.color();
+		docstring const oldname = from_ascii(save_.fontname);
 		mb.fontname = name;
 		mb.font = sane_font;
 		augmentFont(mb.font, from_ascii(name));
 		mb.font.setSize(oldsize);
-		mb.font.setColor(oldcolor);
+		if (string(name) != "lyxtex"
+		    && ((isTextFont(oldname) && oldcolor != Color_foreground)
+			|| (isMathFont(oldname) && oldcolor != Color_math)))
+			mb.font.setColor(oldcolor);
 	}
 }
 
@@ -252,11 +256,15 @@ FontSetChanger::FontSetChanger(MetricsBa
 		save_ = mb;
 		FontSize oldsize = save_.font.size();
 		ColorCode oldcolor = save_.font.color();
+		docstring const oldname = from_ascii(save_.fontname);
 		mb.fontname = to_utf8(name);
 		mb.font = sane_font;
 		augmentFont(mb.font, name);
 		mb.font.setSize(oldsize);
-		mb.font.setColor(oldcolor);
+		if (name != "lyxtex"
+		    && ((isTextFont(oldname) && oldcolor != Color_foreground)
+			|| (isMathFont(oldname) && oldcolor != Color_math)))
+			mb.font.setColor(oldcolor);
 	}
 }
 
@@ -294,17 +302,21 @@ WidthChanger::~WidthChanger()
 //
 /////////////////////////////////////////////////////////////////////////
 
-ColorChanger::ColorChanger(FontInfo & font, string const & color)
-	: Changer<FontInfo, string>(font)
+ColorChanger::ColorChanger(FontInfo & font, docstring const & color,
+			   bool really_change_color)
+	: Changer<FontInfo, ColorCode>(font), change_(really_change_color)
 {
-	save_ = lcolor.getFromLyXName(color);
-	font.setColor(lcolor.getFromLyXName(color));
+	if (change_) {
+		save_ = font.color();
+		font.setColor(lcolor.getFromLyXName(to_utf8(color)));
+	}
 }
 
 
 ColorChanger::~ColorChanger()
 {
-	orig_.setColor(lcolor.getFromLyXName(save_));
+	if (change_)
+		orig_.setColor(save_);
 }
 
 
Index: src/MetricsInfo.h
===================================================================
--- src/MetricsInfo.h	(revisione 34312)
+++ src/MetricsInfo.h	(copia locale)
@@ -222,12 +222,16 @@ public:
 
 
 // temporarily change the used color
-class ColorChanger : public Changer<FontInfo, std::string> {
+class ColorChanger : public Changer<FontInfo, ColorCode> {
 public:
 	///
-	ColorChanger(FontInfo & font, std::string const & color);
+	ColorChanger(FontInfo & font, docstring const & color,
+		     bool really_change_color = true);
 	///
 	~ColorChanger();
+private:
+	///
+	bool change_;
 };
 
 } // namespace lyx


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34320 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-28 01:40:11 +00:00
Richard Heck
d65020b293 s/updateLabels/updateBuffer/g, per a suggestion of Abdel's.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33613 a592a061-630c-0410-9148-cb99ea01b6c8
2010-03-03 22:13:45 +00:00
Jürgen Spitzmüller
fd40810a8c * InsetMathHull.h: constness, as suggested by Abdel.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33243 a592a061-630c-0410-9148-cb99ea01b6c8
2010-01-28 09:18:15 +00:00
Jürgen Spitzmüller
a484f95910 When pasting a math inset with a label, check for duplicates (as we do outside math)
(bug 6218)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33230 a592a061-630c-0410-9148-cb99ea01b6c8
2010-01-27 08:41:19 +00:00
Richard Heck
caa4e94bf0 Get rid of some magic booleans in updateLabels() and related routines.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33110 a592a061-630c-0410-9148-cb99ea01b6c8
2010-01-20 19:42:12 +00:00
Richard Heck
c060a85d81 Revert r32684, per Andre's suggestion.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32689 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-31 15:46:39 +00:00
Richard Heck
8a0134cc8c Introduce a return value for mathmlize(). We will need this to be able
to defer labels.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32684 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-31 03:50:12 +00:00
Vincent van Ravesteijn
6b96abd211 Correctly paint the background of the instant preview of a displayed equation.
For a displayed equation, the height is artificially increased by a displayMargin() in InsetMathHull::metrics if it is a displayed equation and there is a preview. 

This extra height is not covered by the preview image and what one can see is the background as drawn by the MathHull inset. The color of this background should be either Color_mathbg or Color_background depending on whether the preview is shown or not.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32560 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-17 14:09:37 +00:00
Richard Heck
5f27992e16 Restore the MathML output we had before. Still work to be done here.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32540 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-15 13:14:57 +00:00
Vincent van Ravesteijn
80ac638d42 Fix trunk after r32352.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32353 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-05 01:07:38 +00:00
Vincent van Ravesteijn
b56e4c5697 Do not start loading a preview each time one is added. This caused LyX to generate LaTeX code of the document over and over again for each math inset. As a consequence, the loading of the User's Guide took ages.
Fixes a bug introduced in r32157 while fixing bug #4360.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32352 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-05 00:43:28 +00:00
Richard Heck
996505c2ae This patch introduces an optional argument to Buffer::updateLabels(), so
as to allow us to call the routine when we are preparing for output and
so to do certain things we might not want to do every time. 

This is an abuse of updateLabels(), in a way, but updateLabels() long
ago became the general recurse-through-the-Buffer routine, and to
implement the sort of thing I want to do here in validate(), say, much
of the code in updateLabels()---in particular, the counter-update
code---would have to be duplicated. So I believe this is the best, and
easiest, way to go.

Actual use of the new argument will follow.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32318 a592a061-630c-0410-9148-cb99ea01b6c8
2009-12-04 03:03:38 +00:00
Vincent van Ravesteijn
92c8561674 Some cosmetics after r32157.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32159 a592a061-630c-0410-9148-cb99ea01b6c8
2009-11-22 21:45:51 +00:00
Vincent van Ravesteijn
f19b6178a9 Fix bug #4360: Instant preview does not render formulas which contain math-macro from input file.
Patch from Stefan.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32157 a592a061-630c-0410-9148-cb99ea01b6c8
2009-11-22 20:50:35 +00:00
Richard Heck
54b4b8e6b4 Get MathML output for XHTML working a bit.
Turns out MathML is already here, for the most part, so this will
not be too bad at all. 

Anyone else think that is very cool?!



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31979 a592a061-630c-0410-9148-cb99ea01b6c8
2009-11-14 15:25:32 +00:00
Abdelrazak Younes
ff4460603e Make Buffer argument mandatory in most of the InsetMath based class... boring work...
Math manual loads and save correctly it seems but expect some instability period.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31898 a592a061-630c-0410-9148-cb99ea01b6c8
2009-11-08 11:45:46 +00:00
Enrico Forestieri
a1a34443ef Fix bug #5530: LyX expansion in math-macro overwritten by default one.
This patch initializes the buffer_ member of a MathHull inset in most
(but not all) cases. The problems with buffer_ should be greatly
allievated now, but there still can be some corner case.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31873 a592a061-630c-0410-9148-cb99ea01b6c8
2009-11-06 15:18:48 +00:00
Vincent van Ravesteijn
b62b366a67 Fix bug #2969: Double labels appear on empty lines of multi-line equations.
This reverts part of r10553. There, an extra '//' was added when the last line was empty. However, this really makes an extra line and that is visible when the lines have a line number. The bug #2067 that would have been fixed by this does not seem to 'exist' anymore.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30795 a592a061-630c-0410-9148-cb99ea01b6c8
2009-07-26 20:25:11 +00:00
Richard Heck
0facb603fe Give inset codes to all the math insets, so we get more information when
we run into assertions.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30634 a592a061-630c-0410-9148-cb99ea01b6c8
2009-07-16 19:00:24 +00:00
Jean-Marc Lasgouttes
78c45693ef remove all trace of editMessage
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30585 a592a061-630c-0410-9148-cb99ea01b6c8
2009-07-14 18:56:13 +00:00
Pavel Sanda
49ea9227cd Fix leftover from r27378. Patch and report from John McCabe-Dansted.
Presumably it fixes
"r30414 unselects insets after a fraction of a second. 1.5.7 doesn't exhibit this bug"
http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg152960.html

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30536 a592a061-630c-0410-9148-cb99ea01b6c8
2009-07-13 09:50:46 +00:00
Vincent van Ravesteijn
4c9fe33c83 * Move handling of LFUN_INSET_SETTINGS to Inset,
* Remove the EDITABLE enum,
* add functions hasSettings() for all insets.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29375 a592a061-630c-0410-9148-cb99ea01b6c8
2009-04-22 20:55:13 +00:00
Abdelrazak Younes
f000a62b0d part 7
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27524 a592a061-630c-0410-9148-cb99ea01b6c8
2008-11-16 00:18:52 +00:00
André Pönitz
f1cba8ff64 more latin1..utf8 schanges. all of src/* should be utf8 now
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27425 a592a061-630c-0410-9148-cb99ea01b6c8
2008-11-14 15:58:50 +00:00
Enrico Forestieri
28fe97b553 Avoid creating bad math insets with Ctrl+M
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27214 a592a061-630c-0410-9148-cb99ea01b6c8
2008-10-31 15:19:39 +00:00
Abdelrazak Younes
84eec959c5 Revert 27186 which fixed an invalid bug.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27189 a592a061-630c-0410-9148-cb99ea01b6c8
2008-10-29 15:33:52 +00:00
Abdelrazak Younes
8939303131 Fix http://bugzilla.lyx.org/show_bug.cgi?id=5392
The problem is that, for an unknown reason, an InsetMathHull is used *inside* an InsetMathHull. This is the reason why we have two levels of instant preview. I don't know if that was intended.

When moving the cursor, only the doDispatch() of the enclosing InsetMathHull is
called, not the inner one; so we don't have a chance to detect that the inner InsetMathHull should leave its preview mode.

The new leavePreview() method ensures that the screen will be redrawn if needed with cursor movement.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27186 a592a061-630c-0410-9148-cb99ea01b6c8
2008-10-29 09:24:54 +00:00
Pavel Sanda
e4808961c9 Another selection painting patch, PainterInfo::backgroundColor introduced.
Patch by Vincent.

http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg145438.html



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27097 a592a061-630c-0410-9148-cb99ea01b6c8
2008-10-25 10:47:38 +00:00
Enrico Forestieri
02ebfa000b Fix bug 3397
http://bugzilla.lyx.org/show_bug.cgi?id=3397


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26934 a592a061-630c-0410-9148-cb99ea01b6c8
2008-10-17 21:40:11 +00:00
Enrico Forestieri
5ca3be4d67 In mathmode, treat nonascii chars with diacritical marks as an input method
for entering math accents, such that an umlauted A is translated as \ddot{A},
for example.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26577 a592a061-630c-0410-9148-cb99ea01b6c8
2008-09-26 15:53:15 +00:00