mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-13 09:15:50 +00:00
Make MathBigInset working and implement GUI for fixed size math delimiters
(by Georg and me) * src/lfuns.h (enum kb_action): New lfun LFUN_MATH_BIGDELIM * src/LyXAction.C (init): New lfun LFUN_MATH_BIGDELIM * src/cursor.C (macroModeClose): try to intepret the current macro before it is simply inserted * src/mathed/math_biginset.[Ch] (name): implement (isBigInsetDelim): new, test whether a given token is a valid MathBigInset delimiter (infoize2): implement to show name if the cursor is to the right * src/mathed/math_biginset.C (size): handle Big, bigg and Bigg (increase): ditto (draw): fix deco drawing (write): don't write space before delimiter but append one if necessary * src/mathed/math_factory.C (createMathInset): handle l->inset == "big" * src/mathed/math_parser.C (asInput): return a token as input, stolen from tex2lyx (parse1): create a MathBigInset when needed * src/mathed/math_nestinset.C (doDispatch): try to intepret the argument of LFUN_SELFINSERT also if it is longer than one character (doDispatch): remove debug message (doDispatch): remove LFUN_MATH_DELIM test for multiple cells (now in getStatus) (doDispatch): handle LFUN_MATH_BIGDELIM (getStatus): Disable LFUN_MATH_DELIM and LFUN_MATH_BIGDELIM when the selection spans multiple cells * src/mathed/math_nestinset.[Ch] (interpret): new, combine the previous math atom with the new character to a MathBigInset if possible * src/mathed/math_support.C (deco_table): add lbrace and rbrace * src/frontends/qt2/QDelimiterDialog.[Ch] (fix_name, QDelimiterDialog, insertClicked, size_selected): Allow for fixed size delimiters. * src/frontends/qt2/ui/QDelimiterDialogBase.ui: Added a combobox for selecting delimiter size. * src/frontends/xforms/forms/form_maths_delim.fd: ditto * src/frontends/xforms/FormMathsDelim.h: Added a private variable to store selected delimiter size * src/frontends/xforms/FormMathsDelim.C: Correct entry in delim_rversion[] for matching braces. (fix_name): new, return correct name for fixed size delimiter (build, apply, update): allow for fixed size delimiters. * src/frontends/gtk/GMathDelim.C: Add FIXME comment for fixed size delimiters * src/frontends/controllers/ControlMath.[Ch]: Added dispatchBigDelim() to deal with fixed size delimiters. * src/ParagraphParameters.C (findToken): move from here * src/support/lstrings.[Ch] (findToken): to here * src/text3.C (dispatch): handle LFUN_MATH_BIGDELIM (getStatus): ditto * src/ToolbarBackend.C (getIcon): handle LFUN_MATH_BIGDELIM * lib/symbols: add MathBigInset symbols git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@15570 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
37d00bdce7
commit
6ce8659e50
@ -1,3 +1,7 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* symbols: add MathBigInset symbols.
|
||||||
|
|
||||||
2006-10-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2006-10-26 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* CREDITS:
|
* CREDITS:
|
||||||
|
22
lib/symbols
22
lib/symbols
@ -41,6 +41,28 @@ dotso dots none
|
|||||||
ldots dots none
|
ldots dots none
|
||||||
vdots dots none
|
vdots dots none
|
||||||
|
|
||||||
|
# big delimiters
|
||||||
|
bigl big none
|
||||||
|
bigm big none
|
||||||
|
bigr big none
|
||||||
|
Bigl big none
|
||||||
|
Bigm big none
|
||||||
|
Bigr big none
|
||||||
|
biggl big none
|
||||||
|
biggm big none
|
||||||
|
biggr big none
|
||||||
|
Biggl big none
|
||||||
|
Biggm big none
|
||||||
|
Biggr big none
|
||||||
|
# The following are not standard LaTeX, but defined in the lucida font
|
||||||
|
# packages. No 'm' versions!
|
||||||
|
# See lucidabr.dtx for a possible implementation if you want to use these
|
||||||
|
# with other fonts.
|
||||||
|
bigggl big none
|
||||||
|
bigggr big none
|
||||||
|
Bigggl big none
|
||||||
|
Bigggr big none
|
||||||
|
|
||||||
# font changes
|
# font changes
|
||||||
# name "font" math/text family series shape color
|
# name "font" math/text family series shape color
|
||||||
# mathnormal should stay the first
|
# mathnormal should stay the first
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* lfuns.h (enum kb_action): New lfun LFUN_MATH_BIGDELIM
|
||||||
|
* LyXAction.C (init): New lfun LFUN_MATH_BIGDELIM
|
||||||
|
* cursor.C (macroModeClose): try to intepret the current macro before
|
||||||
|
it is simply inserted
|
||||||
|
* ParagraphParameters.C (findToken): move from here to lstrings.[Ch]
|
||||||
|
* text3.C (dispatch): handle LFUN_MATH_BIGDELIM
|
||||||
|
(getStatus): ditto
|
||||||
|
* ToolbarBackend.C (getIcon): handle LFUN_MATH_BIGDELIM
|
||||||
|
|
||||||
2006-10-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2006-10-25 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* text.C (backspacePos0): rewrite to make it simple and allow
|
* text.C (backspacePos0): rewrite to make it simple and allow
|
||||||
|
@ -212,6 +212,7 @@ void LyXAction::init()
|
|||||||
{ LFUN_MARK_ON, "mark-on", ReadOnly },
|
{ LFUN_MARK_ON, "mark-on", ReadOnly },
|
||||||
{ LFUN_SETMARK, "mark-toggle", ReadOnly },
|
{ LFUN_SETMARK, "mark-toggle", ReadOnly },
|
||||||
{ LFUN_MATH_DELIM, "math-delim", Noop },
|
{ LFUN_MATH_DELIM, "math-delim", Noop },
|
||||||
|
{ LFUN_MATH_BIGDELIM, "math-bigdelim", Noop },
|
||||||
{ LFUN_MATH_DISPLAY, "math-display", Noop },
|
{ LFUN_MATH_DISPLAY, "math-display", Noop },
|
||||||
{ LFUN_INSERT_MATH, "math-insert", Noop },
|
{ LFUN_INSERT_MATH, "math-insert", Noop },
|
||||||
{ LFUN_SUBSCRIPT, "math-subscript", Noop },
|
{ LFUN_SUBSCRIPT, "math-subscript", Noop },
|
||||||
|
@ -40,20 +40,11 @@ using std::string;
|
|||||||
|
|
||||||
// anonym namespace
|
// anonym namespace
|
||||||
namespace {
|
namespace {
|
||||||
int findToken(char const * const str[], string const search_token)
|
int findToken(char const * const str[], string const & search_token)
|
||||||
{
|
{
|
||||||
int i = 0;
|
return search_token == "default" ?
|
||||||
|
0 :
|
||||||
if (search_token != "default") {
|
lyx::support::findToken(str, search_token);
|
||||||
while (str[i][0] && str[i] != search_token) {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
if (!str[i][0]) {
|
|
||||||
i = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -217,12 +217,16 @@ string const ToolbarBackend::getIcon(FuncRequest const & f)
|
|||||||
|
|
||||||
string fullname;
|
string fullname;
|
||||||
|
|
||||||
if (f.action == LFUN_INSERT_MATH) {
|
switch (f.action) {
|
||||||
|
case LFUN_INSERT_MATH:
|
||||||
if (!f.argument.empty())
|
if (!f.argument.empty())
|
||||||
fullname = find_xpm(f.argument.substr(1));
|
fullname = find_xpm(f.argument.substr(1));
|
||||||
} else if (f.action == LFUN_MATH_DELIM) {
|
break;
|
||||||
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM:
|
||||||
fullname = find_xpm(f.argument);
|
fullname = find_xpm(f.argument);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
string const name = lyxaction.getActionName(f.action);
|
string const name = lyxaction.getActionName(f.action);
|
||||||
string xpm_name(name);
|
string xpm_name(name);
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "mathed/math_inset.h"
|
#include "mathed/math_inset.h"
|
||||||
#include "mathed/math_scriptinset.h"
|
#include "mathed/math_scriptinset.h"
|
||||||
#include "mathed/math_macrotable.h"
|
#include "mathed/math_macrotable.h"
|
||||||
|
#include "mathed/math_parser.h"
|
||||||
|
|
||||||
#include "support/limited_stack.h"
|
#include "support/limited_stack.h"
|
||||||
|
|
||||||
@ -857,6 +858,9 @@ bool LCursor::macroModeClose()
|
|||||||
if (macro && macro->getInsetName() == name)
|
if (macro && macro->getInsetName() == name)
|
||||||
lyxerr << "can't enter recursive macro" << endl;
|
lyxerr << "can't enter recursive macro" << endl;
|
||||||
|
|
||||||
|
MathNestInset * const in = inset().asMathInset()->asNestInset();
|
||||||
|
if (in && in->interpret(*this, s))
|
||||||
|
return true;
|
||||||
plainInsert(createMathInset(name));
|
plainInsert(createMathInset(name));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* ControlMath.[Ch]: (dispatchBigDelim): new, deal with fixed size
|
||||||
|
delimiters.
|
||||||
|
|
||||||
2006-08-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2006-08-16 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* ControlAboutlyx.C (getVersion): change a bit the display of LyX
|
* ControlAboutlyx.C (getVersion): change a bit the display of LyX
|
||||||
|
@ -79,6 +79,12 @@ void ControlMath::dispatchDelim(string const & str) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlMath::dispatchBigDelim(string const & str) const
|
||||||
|
{
|
||||||
|
dispatchFunc(LFUN_MATH_BIGDELIM, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlMath::dispatchToggleDisplay() const
|
void ControlMath::dispatchToggleDisplay() const
|
||||||
{
|
{
|
||||||
dispatchFunc(LFUN_MATH_DISPLAY);
|
dispatchFunc(LFUN_MATH_DISPLAY);
|
||||||
|
@ -43,9 +43,11 @@ public:
|
|||||||
void dispatchCubeRoot() const;
|
void dispatchCubeRoot() const;
|
||||||
/// Insert a matrix
|
/// Insert a matrix
|
||||||
void dispatchMatrix(std::string const & str) const;
|
void dispatchMatrix(std::string const & str) const;
|
||||||
/// Insert a delimiter
|
/// Insert a variable size delimiter
|
||||||
void dispatchDelim(std::string const & str) const;
|
void dispatchDelim(std::string const & str) const;
|
||||||
/// Wwitch between display and inline
|
/// Insert a big delimiter
|
||||||
|
void dispatchBigDelim(std::string const & str) const;
|
||||||
|
/// Switch between display and inline
|
||||||
void dispatchToggleDisplay() const;
|
void dispatchToggleDisplay() const;
|
||||||
/** A request to the kernel to launch a dialog.
|
/** A request to the kernel to launch a dialog.
|
||||||
* \param name the dialog identifier.
|
* \param name the dialog identifier.
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* GMathDelim.C: Add FIXME comment for fixed size delimiters.
|
||||||
|
|
||||||
2006-03-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2006-03-20 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* GBibtex.C: Move parsing of Options (stylefile, bibtotoc)
|
* GBibtex.C: Move parsing of Options (stylefile, bibtotoc)
|
||||||
|
@ -36,6 +36,8 @@ using std::string;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
// FIXME: Implement fixed size delimiters (see qt3 and xforms frontends)
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* QDelimiterDialog.[Ch] (fix_name, QDelimiterDialog, insertClicked,
|
||||||
|
size_selected): Allow for fixed size delimiters.
|
||||||
|
* ui/QDelimiterDialogBase.ui: Added a combobox for selecting
|
||||||
|
delimiter size.
|
||||||
|
|
||||||
2006-10-16 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2006-10-16 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* QDocumentDialog.C (updateNumbering): don't include headings
|
* QDocumentDialog.C (updateNumbering): don't include headings
|
||||||
|
@ -18,9 +18,14 @@
|
|||||||
|
|
||||||
#include "controllers/ControlMath.h"
|
#include "controllers/ControlMath.h"
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
#include <qpixmap.h>
|
#include <qpixmap.h>
|
||||||
#include <qcheckbox.h>
|
#include <qcheckbox.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -38,6 +43,12 @@ char const * delim[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
char const * const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
|
||||||
|
char const * const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""};
|
||||||
|
char const * const biggui[] = {N_("big size"), N_("Big size"),
|
||||||
|
N_("bigg size"), N_("Bigg size"), ""};
|
||||||
|
|
||||||
|
|
||||||
string do_match(const string & str)
|
string do_match(const string & str)
|
||||||
{
|
{
|
||||||
if (str == "(") return ")";
|
if (str == "(") return ")";
|
||||||
@ -59,7 +70,7 @@ string do_match(const string & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string fix_name(const string & str)
|
string fix_name(const string & str, bool big)
|
||||||
{
|
{
|
||||||
if (str == "slash")
|
if (str == "slash")
|
||||||
return "/";
|
return "/";
|
||||||
@ -67,7 +78,10 @@ string fix_name(const string & str)
|
|||||||
return "\\";
|
return "\\";
|
||||||
if (str == "empty")
|
if (str == "empty")
|
||||||
return ".";
|
return ".";
|
||||||
return str;
|
if (!big || str == "(" || str == ")" || str == "[" || str == "]")
|
||||||
|
return str;
|
||||||
|
|
||||||
|
return "\\" + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
@ -89,11 +103,17 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
|||||||
|
|
||||||
leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
||||||
rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
||||||
|
delimSize->insertItem(qt_("Variable size"));
|
||||||
|
for (int i = 0; *biggui[i]; ++i)
|
||||||
|
delimSize->insertItem(qt_(biggui[i]));
|
||||||
|
size_ = 0;
|
||||||
// Leave these std:: qualifications alone !
|
// Leave these std:: qualifications alone !
|
||||||
connect(leftIP, SIGNAL(button_clicked(const std::string &)),
|
connect(leftIP, SIGNAL(button_clicked(const std::string &)),
|
||||||
this, SLOT(ldelim_clicked(const std::string &)));
|
this, SLOT(ldelim_clicked(const std::string &)));
|
||||||
connect(rightIP, SIGNAL(button_clicked(const std::string &)),
|
connect(rightIP, SIGNAL(button_clicked(const std::string &)),
|
||||||
this, SLOT(rdelim_clicked(const std::string &)));
|
this, SLOT(rdelim_clicked(const std::string &)));
|
||||||
|
connect(delimSize, SIGNAL(activated(int)),
|
||||||
|
this, SLOT(size_selected(int)) );
|
||||||
ldelim_clicked("(");
|
ldelim_clicked("(");
|
||||||
rdelim_clicked(")");
|
rdelim_clicked(")");
|
||||||
}
|
}
|
||||||
@ -101,7 +121,18 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
|||||||
|
|
||||||
void QDelimiterDialog::insertClicked()
|
void QDelimiterDialog::insertClicked()
|
||||||
{
|
{
|
||||||
form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
|
if (size_ == 0) {
|
||||||
|
form_->controller().dispatchDelim(
|
||||||
|
fix_name(left_, false) + ' ' +
|
||||||
|
fix_name(right_, false));
|
||||||
|
} else {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << '"' << bigleft[size_ - 1] << "\" \""
|
||||||
|
<< fix_name(left_, true) << "\" \""
|
||||||
|
<< bigright[size_ - 1] << "\" \""
|
||||||
|
<< fix_name(right_, true) << '"';
|
||||||
|
form_->controller().dispatchBigDelim(os.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,5 +168,11 @@ void QDelimiterDialog::rdelim_clicked(const string & str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QDelimiterDialog::size_selected(int index)
|
||||||
|
{
|
||||||
|
size_ = index;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void ldelim_clicked(const std::string & str);
|
void ldelim_clicked(const std::string & str);
|
||||||
void rdelim_clicked(const std::string & str);
|
void rdelim_clicked(const std::string & str);
|
||||||
|
void size_selected(int);
|
||||||
void insertClicked();
|
void insertClicked();
|
||||||
protected:
|
protected:
|
||||||
//needed ? virtual void closeEvent(QCloseEvent * e);
|
//needed ? virtual void closeEvent(QCloseEvent * e);
|
||||||
@ -42,6 +43,9 @@ private:
|
|||||||
/// symbol of right delimiter
|
/// symbol of right delimiter
|
||||||
std::string right_;
|
std::string right_;
|
||||||
|
|
||||||
|
/// size of delimiters
|
||||||
|
int size_;
|
||||||
|
|
||||||
/// owning form
|
/// owning form
|
||||||
QMathDelimiter * form_;
|
QMathDelimiter * form_;
|
||||||
};
|
};
|
||||||
|
@ -350,6 +350,22 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>delimSize</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" stdset="0">
|
||||||
|
<string>Choose delimiter size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</hbox>
|
</hbox>
|
||||||
</widget>
|
</widget>
|
||||||
<widget>
|
<widget>
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* forms/form_maths_delim.fd: Add combobox for selecting delimiter size.
|
||||||
|
* FormMathsDelim.h: Add private variable to store delimiter size.
|
||||||
|
* FormMathsDelim.C: Correct entry in delim_rversion[].
|
||||||
|
(fix_name): new, return correct name for fixed size delimiter.
|
||||||
|
(build, apply, update): allow for fixed size delimiters.
|
||||||
|
|
||||||
2006-08-13 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
2006-08-13 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
|
||||||
|
|
||||||
* FormErrorList.C (update): do not call updateContents if the
|
* FormErrorList.C (update): do not call updateContents if the
|
||||||
|
@ -18,13 +18,16 @@
|
|||||||
#include "ControlMath.h"
|
#include "ControlMath.h"
|
||||||
|
|
||||||
#include "bmtable.h"
|
#include "bmtable.h"
|
||||||
|
#include "xforms_helpers.h"
|
||||||
#include "xformsBC.h"
|
#include "xformsBC.h"
|
||||||
|
|
||||||
#include "controllers/ButtonController.h"
|
#include "controllers/ButtonController.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using std::ostringstream;
|
using std::ostringstream;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
#include "delim.xbm"
|
#include "delim.xbm"
|
||||||
#include "delim0.xpm"
|
#include "delim0.xpm"
|
||||||
@ -37,7 +40,7 @@ namespace {
|
|||||||
|
|
||||||
int const delim_rversion[] = {
|
int const delim_rversion[] = {
|
||||||
1,1,3,3,4,5,7,7,9,9,10,11,
|
1,1,3,3,4,5,7,7,9,9,10,11,
|
||||||
3,13,15,15,16,17,19,19,20,21,22
|
13,13,15,15,16,17,19,19,20,21,22
|
||||||
};
|
};
|
||||||
int const delim_size =
|
int const delim_size =
|
||||||
sizeof(delim_rversion) / sizeof(delim_rversion[0]);
|
sizeof(delim_rversion) / sizeof(delim_rversion[0]);
|
||||||
@ -50,6 +53,20 @@ char const * delim_values[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
string fix_name(string const & str)
|
||||||
|
{
|
||||||
|
if (str == "(" || str == ")" || str == "[" || str == "]" ||
|
||||||
|
str == "/" || str == "|" || str == ".")
|
||||||
|
return str;
|
||||||
|
|
||||||
|
return "\\" + str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char const * const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
|
||||||
|
char const * const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""};
|
||||||
|
char const * const biggui[] = {N_("big"), N_("Big"), N_("bigg"), N_("Bigg"), ""};
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
@ -64,6 +81,11 @@ void FormMathsDelim::build()
|
|||||||
{
|
{
|
||||||
dialog_.reset(build_maths_delim(this));
|
dialog_.reset(build_maths_delim(this));
|
||||||
|
|
||||||
|
size_ = 0;
|
||||||
|
fl_addto_choice(dialog_->choice_size, _(N_("Variable")).c_str());
|
||||||
|
for (int i = 0; *biggui[i]; ++i)
|
||||||
|
fl_addto_choice(dialog_->choice_size, _(biggui[i]).c_str());
|
||||||
|
|
||||||
fl_set_button(dialog_->radio_left, 1);
|
fl_set_button(dialog_->radio_left, 1);
|
||||||
// Initialize button_pix to "()" as found in images/delim0.xpm:
|
// Initialize button_pix to "()" as found in images/delim0.xpm:
|
||||||
fl_set_pixmap_data(dialog_->button_pix, const_cast<char**>(delim0));
|
fl_set_pixmap_data(dialog_->button_pix, const_cast<char**>(delim0));
|
||||||
@ -91,15 +113,26 @@ void FormMathsDelim::apply()
|
|||||||
{
|
{
|
||||||
int const left = int(dialog_->radio_left->u_ldata);
|
int const left = int(dialog_->radio_left->u_ldata);
|
||||||
int const right = int(dialog_->radio_right->u_ldata);
|
int const right = int(dialog_->radio_right->u_ldata);
|
||||||
|
size_ = fl_get_choice(dialog_->choice_size) - 1;
|
||||||
|
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
os << delim_values[left] << ' ' << delim_values[right];
|
if (size_ == 0) {
|
||||||
controller().dispatchDelim(os.str());
|
os << delim_values[left] << ' ' << delim_values[right];
|
||||||
|
controller().dispatchDelim(os.str());
|
||||||
|
} else {
|
||||||
|
os << '"' << bigleft[size_ - 1] << "\" \""
|
||||||
|
<< fix_name(delim_values[left]) << "\" \""
|
||||||
|
<< bigright[size_ - 1] << "\" \""
|
||||||
|
<< fix_name(delim_values[right]) << '"';
|
||||||
|
controller().dispatchBigDelim(os.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FormMathsDelim::update()
|
void FormMathsDelim::update()
|
||||||
{
|
{
|
||||||
|
fl_set_choice(dialog_->choice_size, size_ + 1);
|
||||||
|
setEnabled(dialog_->choice_size, true);
|
||||||
bc().valid();
|
bc().valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ private:
|
|||||||
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
|
||||||
///
|
///
|
||||||
virtual void update();
|
virtual void update();
|
||||||
|
/// size of delimiters
|
||||||
|
int size_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -11,7 +11,7 @@ SnapGrid: 2
|
|||||||
Name: form_maths_delim
|
Name: form_maths_delim
|
||||||
Width: 250
|
Width: 250
|
||||||
Height: 221
|
Height: 221
|
||||||
Number of Objects: 11
|
Number of Objects: 12
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: FL_BOX
|
class: FL_BOX
|
||||||
@ -70,7 +70,7 @@ argument: 0
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_PIXMAPBUTTON
|
class: FL_PIXMAPBUTTON
|
||||||
type: NORMAL_BUTTON
|
type: NORMAL_BUTTON
|
||||||
box: 100 58 50 40
|
box: 47 58 50 40
|
||||||
boxtype: FL_UP_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_COL1
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_BOTTOM
|
alignment: FL_ALIGN_BOTTOM
|
||||||
@ -85,6 +85,24 @@ name: button_pix
|
|||||||
callback: C_FormDialogView_ApplyCB
|
callback: C_FormDialogView_ApplyCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
class: FL_CHOICE
|
||||||
|
type: NORMAL_CHOICE
|
||||||
|
box: 107 73 80 25
|
||||||
|
boxtype: FL_FRAME_BOX
|
||||||
|
colors: FL_COL1 FL_BLACK
|
||||||
|
alignment: FL_ALIGN_TOP
|
||||||
|
style: FL_NORMAL_STYLE
|
||||||
|
size: FL_NORMAL_SIZE
|
||||||
|
lcol: FL_BLACK
|
||||||
|
label: Size:|#S
|
||||||
|
shortcut:
|
||||||
|
resize: FL_RESIZE_X
|
||||||
|
gravity: FL_NoGravity FL_NoGravity
|
||||||
|
name: choice_size
|
||||||
|
callback: C_FormDialogView_InputCB
|
||||||
|
argument: 0
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: FL_BUTTON
|
class: FL_BUTTON
|
||||||
type: NORMAL_BUTTON
|
type: NORMAL_BUTTON
|
||||||
|
@ -363,8 +363,9 @@ enum kb_action {
|
|||||||
LFUN_OUTLINE_IN,
|
LFUN_OUTLINE_IN,
|
||||||
LFUN_OUTLINE_OUT,
|
LFUN_OUTLINE_OUT,
|
||||||
LFUN_TOGGLE_COMPRESSION, // bpeng 20060427
|
LFUN_TOGGLE_COMPRESSION, // bpeng 20060427
|
||||||
// 275
|
LFUN_INSET_DISSOLVE, // jspitzm 20060807
|
||||||
LFUN_INSET_DISSOLVE, // jspitzm 20060807
|
// 280
|
||||||
|
LFUN_MATH_BIGDELIM,
|
||||||
|
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,27 @@
|
|||||||
|
2006-10-26 Enrico Forestieri <forenr@tlc.unipr.it>
|
||||||
|
|
||||||
|
* math_biginset.[Ch] (name): implement
|
||||||
|
(isBigInsetDelim): new, test whether a given token is a valid
|
||||||
|
MathBigInset delimiter.
|
||||||
|
(infoize2): implement to show name if the cursor is to the right.
|
||||||
|
* math_biginset.C (size, increase): handle Big, bigg and Bigg.
|
||||||
|
(draw): fix deco drawing.
|
||||||
|
(write): don't write space before delimiter but append one if necessary
|
||||||
|
* math_factory.C (createMathInset): handle l->inset == "big"
|
||||||
|
* math_parser.C (asInput): return a token as input, stolen from tex2lyx
|
||||||
|
(parse1): create a MathBigInset when needed.
|
||||||
|
* math_nestinset.C (doDispatch): try to intepret the argument of
|
||||||
|
LFUN_SELFINSERT also if it is longer than one character.
|
||||||
|
(doDispatch): remove debug message.
|
||||||
|
(doDispatch): remove LFUN_MATH_DELIM test for multiple cells (now
|
||||||
|
in getStatus).
|
||||||
|
(doDispatch): handle LFUN_MATH_BIGDELIM.
|
||||||
|
(getStatus): Disable LFUN_MATH_DELIM and LFUN_MATH_BIGDELIM when
|
||||||
|
the selection spans multiple cells.
|
||||||
|
* math_nestinset.[Ch] (interpret): new, combine the previous math
|
||||||
|
atom with the new character to a MathBigInset if possible.
|
||||||
|
* math_support.C (deco_table): add lbrace and rbrace.
|
||||||
|
|
||||||
2006-10-09 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
2006-10-09 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* math_hullinset.C (doDispatch): changeRefsIfUnique needs a
|
* math_hullinset.C (doDispatch): changeRefsIfUnique needs a
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "math_mathmlstream.h"
|
#include "math_mathmlstream.h"
|
||||||
#include "math_streamstr.h"
|
#include "math_streamstr.h"
|
||||||
|
|
||||||
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::auto_ptr;
|
using std::auto_ptr;
|
||||||
@ -25,6 +27,12 @@ MathBigInset::MathBigInset(string const & name, string const & delim)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
string MathBigInset::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
auto_ptr<InsetBase> MathBigInset::doClone() const
|
auto_ptr<InsetBase> MathBigInset::doClone() const
|
||||||
{
|
{
|
||||||
return auto_ptr<InsetBase>(new MathBigInset(*this));
|
return auto_ptr<InsetBase>(new MathBigInset(*this));
|
||||||
@ -33,18 +41,21 @@ auto_ptr<InsetBase> MathBigInset::doClone() const
|
|||||||
|
|
||||||
MathBigInset::size_type MathBigInset::size() const
|
MathBigInset::size_type MathBigInset::size() const
|
||||||
{
|
{
|
||||||
return name_.size() - 4;
|
// order: big Big bigg Bigg biggg Biggg
|
||||||
|
// 0 1 2 3 4 5
|
||||||
|
return name_[0] == 'B' ?
|
||||||
|
2 * (name_.size() - 4) + 1:
|
||||||
|
2 * (name_.size() - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double MathBigInset::increase() const
|
double MathBigInset::increase() const
|
||||||
{
|
{
|
||||||
switch (size()) {
|
// The formula used in amsmath.sty is
|
||||||
case 1: return 0.2;
|
// 1.2 * (1.0 + size() * 0.5) - 1.0.
|
||||||
case 2: return 0.44;
|
// We use a smaller step and a bigger offset because our base size
|
||||||
case 3: return 0.7;
|
// is different.
|
||||||
default: return 0.0;
|
return (size() + 1) * 0.3;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,13 +72,23 @@ void MathBigInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
|||||||
|
|
||||||
void MathBigInset::draw(PainterInfo & pi, int x, int y) const
|
void MathBigInset::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(), delim_);
|
// mathed_draw_deco does not use the leading backslash, so remove it.
|
||||||
|
// Replace \| by \Vert (equivalent in LaTeX), since mathed_draw_deco
|
||||||
|
// would treat it as |.
|
||||||
|
string const delim = (delim_ == "\\|") ?
|
||||||
|
"Vert" :
|
||||||
|
lyx::support::ltrim(delim_, "\\");
|
||||||
|
mathed_draw_deco(pi, x + 1, y - dim_.ascent(), 4, dim_.height(),
|
||||||
|
delim);
|
||||||
|
setPosCache(pi, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathBigInset::write(WriteStream & os) const
|
void MathBigInset::write(WriteStream & os) const
|
||||||
{
|
{
|
||||||
os << '\\' << name_ << ' ' << delim_;
|
os << '\\' << name_ << delim_;
|
||||||
|
if (delim_[0] == '\\')
|
||||||
|
os.pendingSpace(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,3 +96,25 @@ void MathBigInset::normalize(NormalStream & os) const
|
|||||||
{
|
{
|
||||||
os << '[' << name_ << ' ' << delim_ << ']';
|
os << '[' << name_ << ' ' << delim_ << ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBigInset::infoize2(std::ostream & os) const
|
||||||
|
{
|
||||||
|
os << name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MathBigInset::isBigInsetDelim(string const & delim)
|
||||||
|
{
|
||||||
|
// mathed_draw_deco must handle these
|
||||||
|
static char const * const delimiters[] = {
|
||||||
|
"(", ")", "\\{", "\\}", "\\lbrace", "\\rbrace", "[", "]",
|
||||||
|
"|", "/", "\\|", "\\vert", "\\Vert", "'", "\\backslash",
|
||||||
|
"\\langle", "\\lceil", "\\lfloor",
|
||||||
|
"\\rangle", "\\rceil", "\\rfloor",
|
||||||
|
"\\downarrow", "\\Downarrow",
|
||||||
|
"\\uparrow", "\\Uparrow",
|
||||||
|
"\\updownarrow", "\\Updownarrow", ""
|
||||||
|
};
|
||||||
|
return (lyx::support::findToken(delimiters, delim) >= 0);
|
||||||
|
}
|
||||||
|
@ -16,12 +16,14 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/// Inset for \bigl & Co.
|
/// Inset for \\bigl & Co.
|
||||||
class MathBigInset : public MathDimInset {
|
class MathBigInset : public MathDimInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathBigInset(std::string const & name, std::string const & delim);
|
MathBigInset(std::string const & name, std::string const & delim);
|
||||||
///
|
///
|
||||||
|
std::string name() const;
|
||||||
|
///
|
||||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||||
///
|
///
|
||||||
void draw(PainterInfo & pi, int x, int y) const;
|
void draw(PainterInfo & pi, int x, int y) const;
|
||||||
@ -29,6 +31,10 @@ public:
|
|||||||
void write(WriteStream & os) const;
|
void write(WriteStream & os) const;
|
||||||
///
|
///
|
||||||
void normalize(NormalStream & os) const;
|
void normalize(NormalStream & os) const;
|
||||||
|
///
|
||||||
|
void infoize2(std::ostream & os) const;
|
||||||
|
///
|
||||||
|
static bool isBigInsetDelim(std::string const &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual std::auto_ptr<InsetBase> doClone() const;
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
||||||
@ -37,9 +43,9 @@ private:
|
|||||||
///
|
///
|
||||||
double increase() const;
|
double increase() const;
|
||||||
|
|
||||||
/// \bigl or what?
|
/// \\bigl or what?
|
||||||
std::string const name_;
|
std::string const name_;
|
||||||
/// ( or [ or Vert...
|
/// ( or [ or \\Vert...
|
||||||
std::string const delim_;
|
std::string const delim_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -278,6 +278,10 @@ MathAtom createMathInset(string const & s)
|
|||||||
return MathAtom(new MathAMSArrayInset(s));
|
return MathAtom(new MathAMSArrayInset(s));
|
||||||
if (inset == "split")
|
if (inset == "split")
|
||||||
return MathAtom(new MathSplitInset(s));
|
return MathAtom(new MathSplitInset(s));
|
||||||
|
if (inset == "big")
|
||||||
|
// we can't create a MathBigInset, since the argument
|
||||||
|
// is missing.
|
||||||
|
return MathAtom(new MathUnknownInset(s));
|
||||||
return MathAtom(new MathSymbolInset(l));
|
return MathAtom(new MathSymbolInset(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "math_nestinset.h"
|
#include "math_nestinset.h"
|
||||||
|
|
||||||
#include "math_arrayinset.h"
|
#include "math_arrayinset.h"
|
||||||
|
#include "math_biginset.h"
|
||||||
#include "math_boxinset.h"
|
#include "math_boxinset.h"
|
||||||
#include "math_braceinset.h"
|
#include "math_braceinset.h"
|
||||||
#include "math_colorinset.h"
|
#include "math_colorinset.h"
|
||||||
@ -657,7 +658,8 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
case LFUN_SELFINSERT:
|
case LFUN_SELFINSERT:
|
||||||
if (cmd.argument.size() != 1) {
|
if (cmd.argument.size() != 1) {
|
||||||
recordUndo(cur);
|
recordUndo(cur);
|
||||||
cur.insert(cmd.argument);
|
if (!interpret(cur, cmd.argument))
|
||||||
|
cur.insert(cmd.argument);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Don't record undo steps if we are in macro mode and
|
// Don't record undo steps if we are in macro mode and
|
||||||
@ -840,7 +842,6 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MATH_DELIM: {
|
case LFUN_MATH_DELIM: {
|
||||||
lyxerr << "MathNestInset::LFUN_MATH_DELIM" << endl;
|
|
||||||
string ls;
|
string ls;
|
||||||
string rs = lyx::support::split(cmd.argument, ls, ' ');
|
string rs = lyx::support::split(cmd.argument, ls, ' ');
|
||||||
// Reasonable default values
|
// Reasonable default values
|
||||||
@ -849,9 +850,37 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
if (rs.empty())
|
if (rs.empty())
|
||||||
rs = ')';
|
rs = ')';
|
||||||
recordUndo(cur, Undo::ATOMIC);
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
// Don't do this with multi-cell selections
|
cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
|
||||||
if (cur.selBegin().idx() == cur.selEnd().idx())
|
break;
|
||||||
cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
|
}
|
||||||
|
|
||||||
|
case LFUN_MATH_BIGDELIM: {
|
||||||
|
string const lname = cmd.getArg(0);
|
||||||
|
string const ldelim = cmd.getArg(1);
|
||||||
|
string const rname = cmd.getArg(2);
|
||||||
|
string const rdelim = cmd.getArg(3);
|
||||||
|
latexkeys const * l = in_word_set(lname);
|
||||||
|
bool const have_l = l && l->inset == "big" &&
|
||||||
|
MathBigInset::isBigInsetDelim(ldelim);
|
||||||
|
l = in_word_set(rname);
|
||||||
|
bool const have_r = l && l->inset == "big" &&
|
||||||
|
MathBigInset::isBigInsetDelim(rdelim);
|
||||||
|
// We mimic LFUN_MATH_DELIM in case we have an empty left
|
||||||
|
// or right delimiter.
|
||||||
|
if (have_l || have_r) {
|
||||||
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
|
string const selection = grabAndEraseSelection(cur);
|
||||||
|
selClearOrDel(cur);
|
||||||
|
if (have_l)
|
||||||
|
cur.insert(MathAtom(new MathBigInset(lname,
|
||||||
|
ldelim)));
|
||||||
|
cur.niceInsert(selection);
|
||||||
|
if (have_r)
|
||||||
|
cur.insert(MathAtom(new MathBigInset(rname,
|
||||||
|
rdelim)));
|
||||||
|
}
|
||||||
|
// Don't call cur.undispatched() if we did nothing, this would
|
||||||
|
// lead to infinite recursion via LyXText::dispatch().
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,7 +938,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
|
bool MathNestInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||||
FuncStatus & flag) const
|
FuncStatus & flag) const
|
||||||
{
|
{
|
||||||
// the font related toggles
|
// the font related toggles
|
||||||
@ -985,6 +1014,13 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
|
|||||||
case LFUN_INSERT_MATRIX:
|
case LFUN_INSERT_MATRIX:
|
||||||
flag.enabled(currentMode() == MATH_MODE);
|
flag.enabled(currentMode() == MATH_MODE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM:
|
||||||
|
// Don't do this with multi-cell selections
|
||||||
|
flag.enabled(cur.selBegin().idx() == cur.selEnd().idx());
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
@ -1138,6 +1174,36 @@ bool MathNestInset::interpret(LCursor & cur, char c)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// One character big delimiters. The others are handled in
|
||||||
|
// the other interpret() method.
|
||||||
|
latexkeys const * l = in_word_set(name.substr(1));
|
||||||
|
if (name[0] == '\\' && l && l->inset == "big") {
|
||||||
|
string delim;
|
||||||
|
switch (c) {
|
||||||
|
case '{':
|
||||||
|
delim = "\\{";
|
||||||
|
break;
|
||||||
|
case '}':
|
||||||
|
delim = "\\}";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
delim = string(1, c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (MathBigInset::isBigInsetDelim(delim)) {
|
||||||
|
// name + delim ared a valid MathBigInset.
|
||||||
|
// We can't use cur.macroModeClose() because
|
||||||
|
// it does not handle delim.
|
||||||
|
MathUnknownInset * p = cur.activeMacro();
|
||||||
|
p->finalize();
|
||||||
|
--cur.pos();
|
||||||
|
cur.cell().erase(cur.pos());
|
||||||
|
cur.plainInsert(MathAtom(
|
||||||
|
new MathBigInset(name.substr(1), delim)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// leave macro mode and try again if necessary
|
// leave macro mode and try again if necessary
|
||||||
cur.macroModeClose();
|
cur.macroModeClose();
|
||||||
if (c == '{')
|
if (c == '{')
|
||||||
@ -1214,8 +1280,8 @@ bool MathNestInset::interpret(LCursor & cur, char c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' || c == '%'
|
if (c == '{' || c == '}' || c == '&' || c == '$' || c == '#' ||
|
||||||
|| c == '_' || c == '^') {
|
c == '%' || c == '_' || c == '^') {
|
||||||
cur.niceInsert(createMathInset(string(1, c)));
|
cur.niceInsert(createMathInset(string(1, c)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1232,6 +1298,29 @@ bool MathNestInset::interpret(LCursor & cur, char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MathNestInset::interpret(LCursor & cur, string const & str)
|
||||||
|
{
|
||||||
|
// Create a MathBigInset from cur.cell()[cur.pos() - 1] and t if
|
||||||
|
// possible
|
||||||
|
if (!cur.empty() && cur.pos() > 0 &&
|
||||||
|
cur.cell()[cur.pos() - 1]->asUnknownInset()) {
|
||||||
|
if (MathBigInset::isBigInsetDelim(str)) {
|
||||||
|
string prev = asString(cur.cell()[cur.pos() - 1]);
|
||||||
|
if (prev[0] == '\\') {
|
||||||
|
prev = prev.substr(1);
|
||||||
|
latexkeys const * l = in_word_set(prev);
|
||||||
|
if (l && l->inset == "big") {
|
||||||
|
cur.cell()[cur.pos() - 1] =
|
||||||
|
MathAtom(new MathBigInset(prev, str));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MathNestInset::script(LCursor & cur, bool up, string const &
|
bool MathNestInset::script(LCursor & cur, bool up, string const &
|
||||||
save_selection)
|
save_selection)
|
||||||
{
|
{
|
||||||
|
@ -107,12 +107,18 @@ protected:
|
|||||||
///
|
///
|
||||||
void handleFont2(LCursor & cur, std::string const & arg);
|
void handleFont2(LCursor & cur, std::string const & arg);
|
||||||
|
|
||||||
///
|
/// interpret \p c and insert the result at the current position of
|
||||||
|
/// of \p cur. Return whether the cursor should stay in the formula.
|
||||||
bool interpret(LCursor & cur, char c);
|
bool interpret(LCursor & cur, char c);
|
||||||
///
|
///
|
||||||
bool script(LCursor & cur, bool,
|
bool script(LCursor & cur, bool,
|
||||||
std::string const & save_selection = std::string());
|
std::string const & save_selection = std::string());
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// interpret \p str and insert the result at the current position of
|
||||||
|
/// \p cur if it is something known. Return whether \p cur was
|
||||||
|
/// inserted.
|
||||||
|
bool interpret(LCursor & cur, std::string const & str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// lfun handler
|
/// lfun handler
|
||||||
|
@ -40,6 +40,7 @@ following hack as starting point to write some macros:
|
|||||||
|
|
||||||
#include "math_parser.h"
|
#include "math_parser.h"
|
||||||
#include "math_arrayinset.h"
|
#include "math_arrayinset.h"
|
||||||
|
#include "math_biginset.h"
|
||||||
#include "math_braceinset.h"
|
#include "math_braceinset.h"
|
||||||
#include "math_charinset.h"
|
#include "math_charinset.h"
|
||||||
#include "math_colorinset.h"
|
#include "math_colorinset.h"
|
||||||
@ -257,6 +258,8 @@ public:
|
|||||||
char character() const { return char_; }
|
char character() const { return char_; }
|
||||||
///
|
///
|
||||||
string asString() const { return cs_.size() ? cs_ : string(1, char_); }
|
string asString() const { return cs_.size() ? cs_ : string(1, char_); }
|
||||||
|
///
|
||||||
|
string asInput() const { return cs_.size() ? '\\' + cs_ : string(1, char_); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
@ -1316,7 +1319,19 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
|
|||||||
else if (t.cs().size()) {
|
else if (t.cs().size()) {
|
||||||
latexkeys const * l = in_word_set(t.cs());
|
latexkeys const * l = in_word_set(t.cs());
|
||||||
if (l) {
|
if (l) {
|
||||||
if (l->inset == "font") {
|
if (l->inset == "big") {
|
||||||
|
skipSpaces();
|
||||||
|
string const delim = getToken().asInput();
|
||||||
|
if (MathBigInset::isBigInsetDelim(delim))
|
||||||
|
cell->push_back(MathAtom(
|
||||||
|
new MathBigInset(t.cs(), delim)));
|
||||||
|
else {
|
||||||
|
cell->push_back(createMathInset(t.cs()));
|
||||||
|
putback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (l->inset == "font") {
|
||||||
cell->push_back(createMathInset(t.cs()));
|
cell->push_back(createMathInset(t.cs()));
|
||||||
parse(cell->back().nucleus()->cell(0),
|
parse(cell->back().nucleus()->cell(0),
|
||||||
FLAG_ITEM, asMode(mode, l->extra));
|
FLAG_ITEM, asMode(mode, l->extra));
|
||||||
|
@ -283,6 +283,8 @@ named_deco_struct deco_table[] = {
|
|||||||
{")", parenth, 2 },
|
{")", parenth, 2 },
|
||||||
{"{", brace, 0 },
|
{"{", brace, 0 },
|
||||||
{"}", brace, 2 },
|
{"}", brace, 2 },
|
||||||
|
{"lbrace", brace, 0 },
|
||||||
|
{"rbrace", brace, 2 },
|
||||||
{"[", brack, 0 },
|
{"[", brack, 0 },
|
||||||
{"]", brack, 2 },
|
{"]", brack, 2 },
|
||||||
{"|", vert, 0 },
|
{"|", vert, 0 },
|
||||||
|
@ -534,6 +534,18 @@ string const getStringFromVector(vector<string> const & vec,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int findToken(char const * const str[], string const & search_token)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (str[i][0] && str[i] != search_token)
|
||||||
|
++i;
|
||||||
|
if (!str[i][0])
|
||||||
|
i = -1;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
#ifndef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
||||||
#if USE_BOOST_FORMAT
|
#if USE_BOOST_FORMAT
|
||||||
|
|
||||||
|
@ -176,6 +176,10 @@ std::vector<std::string> const getVectorFromString(std::string const & str,
|
|||||||
std::string const getStringFromVector(std::vector<std::string> const & vec,
|
std::string const getStringFromVector(std::vector<std::string> const & vec,
|
||||||
std::string const & delim = std::string(","));
|
std::string const & delim = std::string(","));
|
||||||
|
|
||||||
|
/// Search \p search_token in \p str and return the position if it is
|
||||||
|
/// found, else -1. The last item in \p str must be "".
|
||||||
|
int findToken(char const * const str[], std::string const & search_token);
|
||||||
|
|
||||||
|
|
||||||
#ifdef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
#ifdef I_AM_NOT_AFRAID_OF_HEADER_LIBRARIES
|
||||||
|
|
||||||
|
@ -1173,7 +1173,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
case LFUN_INSERT_MATH:
|
case LFUN_INSERT_MATH:
|
||||||
case LFUN_INSERT_MATRIX:
|
case LFUN_INSERT_MATRIX:
|
||||||
case LFUN_MATH_DELIM: {
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM: {
|
||||||
cur.insert(new MathHullInset("simple"));
|
cur.insert(new MathHullInset("simple"));
|
||||||
cur.dispatch(FuncRequest(LFUN_RIGHT));
|
cur.dispatch(FuncRequest(LFUN_RIGHT));
|
||||||
cur.dispatch(cmd);
|
cur.dispatch(cmd);
|
||||||
@ -1733,6 +1734,7 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|||||||
case LFUN_INSERT_MATH:
|
case LFUN_INSERT_MATH:
|
||||||
case LFUN_INSERT_MATRIX:
|
case LFUN_INSERT_MATRIX:
|
||||||
case LFUN_MATH_DELIM:
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM:
|
||||||
case LFUN_SUBSCRIPT:
|
case LFUN_SUBSCRIPT:
|
||||||
case LFUN_SUPERSCRIPT:
|
case LFUN_SUPERSCRIPT:
|
||||||
case LFUN_DEFAULT:
|
case LFUN_DEFAULT:
|
||||||
|
@ -69,6 +69,8 @@ What's new
|
|||||||
|
|
||||||
- Make clicking in a "Wide" inset always enter that inset.
|
- Make clicking in a "Wide" inset always enter that inset.
|
||||||
|
|
||||||
|
- Add support for fixed size math delimiters.
|
||||||
|
|
||||||
* Build/installation:
|
* Build/installation:
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user