mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
Re-introduction of a BraceInset to handle "extra braces"
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2943 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
549d6b7441
commit
fcc87d756b
@ -12,6 +12,8 @@ Items marked with
|
|||||||
!! - mark "not a bug, a feature" replies, usually with a request for
|
!! - mark "not a bug, a feature" replies, usually with a request for
|
||||||
further discussion
|
further discussion
|
||||||
|
|
||||||
|
pp - partially fixed
|
||||||
|
|
||||||
Unmarked items are known unfixed but probably unverified bugs.
|
Unmarked items are known unfixed but probably unverified bugs.
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
@ -60,7 +62,7 @@ Misc:
|
|||||||
// - When you press the mouse just to the left of the middle point of
|
// - When you press the mouse just to the left of the middle point of
|
||||||
// some char, the cursor will be positioned to the right of the char.
|
// some char, the cursor will be positioned to the right of the char.
|
||||||
|
|
||||||
- It is possible to put two or more consecutive spaces in math text mode
|
pp - It is possible to put two or more consecutive spaces in math text mode
|
||||||
|
|
||||||
// - Text in superscript is not smaller than normal text.
|
// - Text in superscript is not smaller than normal text.
|
||||||
|
|
||||||
@ -113,9 +115,9 @@ Eran Tromer:
|
|||||||
// enter the cell its cell and press
|
// enter the cell its cell and press
|
||||||
// M-m ( M-f 1 <right> <right> <right> (zoom=100, screenDPI=100)
|
// M-m ( M-f 1 <right> <right> <right> (zoom=100, screenDPI=100)
|
||||||
|
|
||||||
- When selecting multiple cells in a array using the keyboard, <left>
|
// - When selecting multiple cells in a array using the keyboard, <left>
|
||||||
etc. should can move whole cell at a time -- no need to navigate
|
// etc. should can move whole cell at a time -- no need to navigate
|
||||||
within cells.
|
// within cells.
|
||||||
|
|
||||||
- When selecting, maybe give a visual indication of the "original"
|
- When selecting, maybe give a visual indication of the "original"
|
||||||
anchor, when it differs from the "actual" one.
|
anchor, when it differs from the "actual" one.
|
||||||
|
@ -24,6 +24,8 @@ libmathed_la_SOURCES = \
|
|||||||
math_atom.h \
|
math_atom.h \
|
||||||
math_binominset.C \
|
math_binominset.C \
|
||||||
math_binominset.h \
|
math_binominset.h \
|
||||||
|
math_braceinset.C \
|
||||||
|
math_braceinset.h \
|
||||||
math_boxinset.C \
|
math_boxinset.C \
|
||||||
math_boxinset.h \
|
math_boxinset.h \
|
||||||
math_charinset.C \
|
math_charinset.C \
|
||||||
|
@ -291,14 +291,6 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MATH_EXTERN:
|
|
||||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
|
||||||
handleExtern(arg);
|
|
||||||
// re-compute inset dimension
|
|
||||||
metrics(bv);
|
|
||||||
updateLocal(bv, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_MATH_MUTATE:
|
case LFUN_MATH_MUTATE:
|
||||||
{
|
{
|
||||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
@ -312,6 +304,16 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case LFUN_MATH_EXTERN:
|
||||||
|
{
|
||||||
|
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||||
|
handleExtern(arg);
|
||||||
|
// re-compute inset dimension
|
||||||
|
metrics(bv);
|
||||||
|
updateLocal(bv, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case LFUN_MATH_DISPLAY:
|
case LFUN_MATH_DISPLAY:
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
56
src/mathed/math_braceinset.C
Normal file
56
src/mathed/math_braceinset.C
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "math_braceinset.h"
|
||||||
|
#include "math_parser.h"
|
||||||
|
#include "mathed/support.h"
|
||||||
|
#include "support/LOstream.h"
|
||||||
|
|
||||||
|
using std::max;
|
||||||
|
|
||||||
|
|
||||||
|
MathBraceInset::MathBraceInset()
|
||||||
|
: MathNestInset(1)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
MathInset * MathBraceInset::clone() const
|
||||||
|
{
|
||||||
|
return new MathBraceInset(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBraceInset::write(MathWriteInfo & os) const
|
||||||
|
{
|
||||||
|
os << '{' << cell(0) << '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBraceInset::writeNormal(std::ostream & os) const
|
||||||
|
{
|
||||||
|
os << "[block ";
|
||||||
|
cell(0).writeNormal(os);
|
||||||
|
os << "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBraceInset::metrics(MathMetricsInfo const & mi) const
|
||||||
|
{
|
||||||
|
xcell(0).metrics(mi);
|
||||||
|
int a, d;
|
||||||
|
mathed_char_dim(LM_TC_TEX, mi, '{', a, d, wid_);
|
||||||
|
ascent_ = std::max(xcell(0).ascent(), a);
|
||||||
|
descent_ = std::max(xcell(0).descent(), a);
|
||||||
|
width_ = xcell(0).width() + 2 * wid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MathBraceInset::draw(Painter & pain, int x, int y) const
|
||||||
|
{
|
||||||
|
drawChar(pain, LM_TC_TEX, mi_, x, y, '{');
|
||||||
|
xcell(0).draw(pain, x + wid_, y);
|
||||||
|
drawChar(pain, LM_TC_TEX, mi_, x + width_ - wid_, y, '}');
|
||||||
|
}
|
38
src/mathed/math_braceinset.h
Normal file
38
src/mathed/math_braceinset.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
#ifndef MATH_BRACEINSET_H
|
||||||
|
#define MATH_BRACEINSET_H
|
||||||
|
|
||||||
|
#include "math_nestinset.h"
|
||||||
|
#include "math_metricsinfo.h"
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** Extra nesting
|
||||||
|
\author André Pönitz
|
||||||
|
*/
|
||||||
|
|
||||||
|
class MathBraceInset : public MathNestInset {
|
||||||
|
public:
|
||||||
|
///
|
||||||
|
MathBraceInset();
|
||||||
|
///
|
||||||
|
MathInset * clone() const;
|
||||||
|
///
|
||||||
|
void draw(Painter &, int x, int y) const;
|
||||||
|
///
|
||||||
|
void write(MathWriteInfo & os) const;
|
||||||
|
/// write normalized content
|
||||||
|
void writeNormal(std::ostream &) const;
|
||||||
|
///
|
||||||
|
void metrics(MathMetricsInfo const & st) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// width of brace character
|
||||||
|
mutable int wid_;
|
||||||
|
///
|
||||||
|
MathMetricsInfo mi_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -33,6 +33,7 @@
|
|||||||
#include "math_cursor.h"
|
#include "math_cursor.h"
|
||||||
#include "math_factory.h"
|
#include "math_factory.h"
|
||||||
#include "math_arrayinset.h"
|
#include "math_arrayinset.h"
|
||||||
|
#include "math_braceinset.h"
|
||||||
#include "math_charinset.h"
|
#include "math_charinset.h"
|
||||||
#include "math_deliminset.h"
|
#include "math_deliminset.h"
|
||||||
#include "math_matrixinset.h"
|
#include "math_matrixinset.h"
|
||||||
@ -786,7 +787,6 @@ void MathCursor::drawSelection(Painter & pain) const
|
|||||||
MathCursorPos i1;
|
MathCursorPos i1;
|
||||||
MathCursorPos i2;
|
MathCursorPos i2;
|
||||||
getSelection(i1, i2);
|
getSelection(i1, i2);
|
||||||
|
|
||||||
//lyxerr << "selection from: " << i1 << " to " << i2 << "\n";
|
//lyxerr << "selection from: " << i1 << " to " << i2 << "\n";
|
||||||
|
|
||||||
if (i1.idx_ == i2.idx_) {
|
if (i1.idx_ == i2.idx_) {
|
||||||
@ -808,6 +808,18 @@ void MathCursor::drawSelection(Painter & pain) const
|
|||||||
pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
|
pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// draw anchor if different from selection boundary
|
||||||
|
MathCursorPos anc = Anchor_.back();
|
||||||
|
if (anc != i1 && anc != i2) {
|
||||||
|
MathXArray & c = anc.xcell();
|
||||||
|
int x = c.xo() + c.pos2x(anc.pos_);
|
||||||
|
int y1 = c.yo() - c.ascent();
|
||||||
|
int y2 = c.yo() + c.descent();
|
||||||
|
pain.line(x, y1, x, y2, LColor::mathline);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1385,10 +1397,21 @@ void MathCursor::interpret(char c)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (strchr("{}", c)) {
|
if (strchr("{}", c)) {
|
||||||
insert(c, LM_TC_TEX);
|
insert(c, LM_TC_TEX);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (c == '{') {
|
||||||
|
niceInsert(MathAtom(new MathBraceInset));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == '}') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (strchr("#$%", c)) {
|
if (strchr("#$%", c)) {
|
||||||
insert(MathAtom(new MathSpecialCharInset(c)));
|
insert(MathAtom(new MathSpecialCharInset(c)));
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
using std::max;
|
using std::max;
|
||||||
|
|
||||||
|
|
||||||
MathDelimInset::MathDelimInset(string const & l, string const & r)
|
MathDelimInset::MathDelimInset(string const & l, string const & r)
|
||||||
: MathNestInset(1), left_(l), right_(r)
|
: MathNestInset(1), left_(l), right_(r)
|
||||||
{}
|
{}
|
||||||
@ -51,7 +52,9 @@ void MathDelimInset::write(MathWriteInfo & os) const
|
|||||||
|
|
||||||
void MathDelimInset::writeNormal(std::ostream & os) const
|
void MathDelimInset::writeNormal(std::ostream & os) const
|
||||||
{
|
{
|
||||||
os << "[delim " << latexName(left_) << " " << latexName(right_) << "]";
|
os << "[delim " << latexName(left_) << ' ' << latexName(right_) << ' ';
|
||||||
|
cell(0).writeNormal(os);
|
||||||
|
os << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,34 @@
|
|||||||
* the GNU General Public Licence version 2 or later.
|
* the GNU General Public Licence version 2 or later.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
If someone desperately needs partial "structures" (such as a few cells of
|
||||||
|
an array inset or similar) (s)he could uses the following hack as starting
|
||||||
|
point to write some macros:
|
||||||
|
|
||||||
|
\newif\ifcomment
|
||||||
|
\commentfalse
|
||||||
|
\ifcomment
|
||||||
|
\def\makeamptab{\catcode`\&=4\relax}
|
||||||
|
\def\makeampletter{\catcode`\&=11\relax}
|
||||||
|
\def\b{\makeampletter\expandafter\makeamptab\bi}
|
||||||
|
\long\def\bi#1\e{}
|
||||||
|
\else
|
||||||
|
\def\b{}\def\e{}
|
||||||
|
\fi
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
\[\begin{array}{ccc}
|
||||||
|
1 & 2\b & 3^2\\
|
||||||
|
4 & 5\e & 6\\
|
||||||
|
7 & 8 & 9
|
||||||
|
\end{array}\]
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
@ -28,6 +56,7 @@
|
|||||||
#include "array.h"
|
#include "array.h"
|
||||||
#include "math_inset.h"
|
#include "math_inset.h"
|
||||||
#include "math_arrayinset.h"
|
#include "math_arrayinset.h"
|
||||||
|
#include "math_braceinset.h"
|
||||||
#include "math_charinset.h"
|
#include "math_charinset.h"
|
||||||
#include "math_deliminset.h"
|
#include "math_deliminset.h"
|
||||||
#include "math_factory.h"
|
#include "math_factory.h"
|
||||||
@ -642,9 +671,6 @@ bool Parser::parse_normal(MathAtom & matrix)
|
|||||||
|
|
||||||
void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
||||||
{
|
{
|
||||||
stack<MathTextCodes> fontcodes;
|
|
||||||
fontcodes.push(LM_TC_MIN);
|
|
||||||
|
|
||||||
bool panic = false;
|
bool panic = false;
|
||||||
int limits = 0;
|
int limits = 0;
|
||||||
|
|
||||||
@ -695,11 +721,10 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
else if (t.cat() == catLetter)
|
else if (t.cat() == catLetter)
|
||||||
add(array, t.character(), fontcodes.top());
|
add(array, t.character(), code);
|
||||||
|
|
||||||
else if (t.cat() == catSpace &&
|
else if (t.cat() == catSpace && code == LM_TC_TEXTRM)
|
||||||
(fontcodes.top() == LM_TC_TEXTRM || code == LM_TC_TEXTRM))
|
add(array, t.character(), code);
|
||||||
add(array, ' ', fontcodes.top());
|
|
||||||
|
|
||||||
else if (t.cat() == catParameter) {
|
else if (t.cat() == catParameter) {
|
||||||
Token const & n = getToken();
|
Token const & n = getToken();
|
||||||
@ -707,15 +732,15 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cat() == catBegin) {
|
else if (t.cat() == catBegin) {
|
||||||
add(array, '{', LM_TC_TEX);
|
array.push_back(MathAtom(new MathBraceInset));
|
||||||
fontcodes.push(LM_TC_MIN);
|
parse_into(array.back()->cell(0), FLAG_BRACE_LAST, LM_TC_MIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cat() == catEnd) {
|
else if (t.cat() == catEnd) {
|
||||||
if (flags & FLAG_BRACE_LAST)
|
if (flags & FLAG_BRACE_LAST)
|
||||||
return;
|
return;
|
||||||
|
lyxerr << "found '}' unexpectedly, array: '" << array << "'\n";
|
||||||
add(array, '}', LM_TC_TEX);
|
add(array, '}', LM_TC_TEX);
|
||||||
fontcodes.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (t.cat() == catAlign) {
|
else if (t.cat() == catAlign) {
|
||||||
@ -742,7 +767,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
else if (t.cat() == catOther)
|
else if (t.cat() == catOther)
|
||||||
add(array, t.character(), fontcodes.top());
|
add(array, t.character(), code);
|
||||||
|
|
||||||
//
|
//
|
||||||
// codesequences
|
// codesequences
|
||||||
@ -930,8 +955,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (l->token == LM_TK_OLDFONT) {
|
else if (l->token == LM_TK_OLDFONT) {
|
||||||
fontcodes.pop();
|
code = static_cast<MathTextCodes>(l->id);
|
||||||
fontcodes.push(static_cast<MathTextCodes>(l->id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -24,7 +24,7 @@ void MathSymbolInset::write(MathWriteInfo & os) const
|
|||||||
|
|
||||||
void MathSymbolInset::writeNormal(ostream & os) const
|
void MathSymbolInset::writeNormal(ostream & os) const
|
||||||
{
|
{
|
||||||
os << "[" << sym_->name << "] ";
|
os << "[symbol " << sym_->name << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user