From b1d75ead87793dedc8348159474d05e50daef1ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Fri, 1 Feb 2002 14:56:49 +0000 Subject: [PATCH] Somewhat better behaviour for Umlauts in math git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3472 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/formulabase.C | 71 ++++++++++++++++++++----------------- src/mathed/formulabase.h | 2 ++ src/mathed/math_cursor.C | 6 ++++ src/mathed/math_cursor.h | 2 ++ src/mathed/math_gridinset.C | 3 +- src/mathed/math_parser.C | 3 +- 6 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index d26933e0e5..195273d58b 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -65,18 +65,13 @@ int hack_y; int hack_button; -void handleFont(BufferView * bv, MathTextCodes t) +void handleFont(BufferView * bv, string const & arg, MathTextCodes t) { if (mathcursor->selection()) bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->handleFont(t); -} - - -void handleAccent(BufferView * bv, string const & name) -{ - bv->lockedInsetStoreUndo(Undo::EDIT); - mathcursor->insert(createMathInset(name)); + for (string::const_iterator it = arg.begin(); it != arg.end(); ++it) + mathcursor->insert(*it); } @@ -500,39 +495,39 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, // --- accented characters ------------------------------ - case LFUN_UMLAUT: handleAccent(bv, "ddot"); break; - case LFUN_CIRCUMFLEX: handleAccent(bv, "hat"); break; - case LFUN_GRAVE: handleAccent(bv, "grave"); break; - case LFUN_ACUTE: handleAccent(bv, "acute"); break; - case LFUN_TILDE: handleAccent(bv, "tilde"); break; - case LFUN_MACRON: handleAccent(bv, "bar"); break; - case LFUN_DOT: handleAccent(bv, "dot"); break; - case LFUN_CARON: handleAccent(bv, "check"); break; - case LFUN_BREVE: handleAccent(bv, "breve"); break; - case LFUN_VECTOR: handleAccent(bv, "vec"); break; - case LFUN_UNDERBAR: handleAccent(bv, "underbar"); break; + case LFUN_UMLAUT: handleAccent(bv, arg, "ddot"); break; + case LFUN_CIRCUMFLEX: handleAccent(bv, arg, "hat"); break; + case LFUN_GRAVE: handleAccent(bv, arg, "grave"); break; + case LFUN_ACUTE: handleAccent(bv, arg, "acute"); break; + case LFUN_TILDE: handleAccent(bv, arg, "tilde"); break; + case LFUN_MACRON: handleAccent(bv, arg, "bar"); break; + case LFUN_DOT: handleAccent(bv, arg, "dot"); break; + case LFUN_CARON: handleAccent(bv, arg, "check"); break; + case LFUN_BREVE: handleAccent(bv, arg, "breve"); break; + case LFUN_VECTOR: handleAccent(bv, arg, "vec"); break; + case LFUN_UNDERBAR: handleAccent(bv, arg, "underbar"); break; // Math fonts - case LFUN_GREEK_TOGGLE: handleFont(bv, LM_TC_GREEK); break; - case LFUN_BOLD: handleFont(bv, LM_TC_BF); break; - case LFUN_SANS: handleFont(bv, LM_TC_SF); break; - case LFUN_EMPH: handleFont(bv, LM_TC_CAL); break; - case LFUN_ROMAN: handleFont(bv, LM_TC_RM); break; - case LFUN_CODE: handleFont(bv, LM_TC_TT); break; - case LFUN_FRAK: handleFont(bv, LM_TC_EUFRAK); break; - case LFUN_ITAL: handleFont(bv, LM_TC_IT); break; - case LFUN_NOUN: handleFont(bv, LM_TC_BB); break; - case LFUN_DEFAULT: handleFont(bv, LM_TC_VAR); break; - case LFUN_FREE: handleFont(bv, LM_TC_TEXTRM); break; + case LFUN_GREEK_TOGGLE: handleFont(bv, arg, LM_TC_GREEK); break; + case LFUN_BOLD: handleFont(bv, arg, LM_TC_BF); break; + case LFUN_SANS: handleFont(bv, arg, LM_TC_SF); break; + case LFUN_EMPH: handleFont(bv, arg, LM_TC_CAL); break; + case LFUN_ROMAN: handleFont(bv, arg, LM_TC_RM); break; + case LFUN_CODE: handleFont(bv, arg, LM_TC_TT); break; + case LFUN_FRAK: handleFont(bv, arg, LM_TC_EUFRAK); break; + case LFUN_ITAL: handleFont(bv, arg, LM_TC_IT); break; + case LFUN_NOUN: handleFont(bv, arg, LM_TC_BB); break; + case LFUN_DEFAULT: handleFont(bv, arg, LM_TC_VAR); break; + case LFUN_FREE: handleFont(bv, arg, LM_TC_TEXTRM); break; case LFUN_GREEK: - handleFont(bv, LM_TC_GREEK1); + handleFont(bv, arg, LM_TC_GREEK1); if (arg.size()) mathcursor->interpret(arg); break; case LFUN_MATH_MODE: - //handleFont(bv, LM_TC_TEXTRM); + //handleFont(bv, arg, LM_TC_TEXTRM); //mathcursor->niceInsert(MathAtom(new MathHullInset(LM_OT_SIMPLE))); //updateLocal(bv, true); @@ -782,6 +777,18 @@ bool InsetFormulaBase::searchBackward(BufferView * bv, string const & what, } + +void InsetFormulaBase::handleAccent(BufferView * bv, + string const & arg, string const & name) +{ + bv->lockedInsetStoreUndo(Undo::EDIT); + MathAtom at = createMathInset(name); + mathed_parse_cell(at->cell(0), arg); + mathcursor->insert(at); + updateLocal(bv, true); +} + + ///////////////////////////////////////////////////////////////////// diff --git a/src/mathed/formulabase.h b/src/mathed/formulabase.h index 96dca1c1b4..b746bb698c 100644 --- a/src/mathed/formulabase.h +++ b/src/mathed/formulabase.h @@ -115,6 +115,8 @@ public: private: /// unimplemented void operator=(const InsetFormulaBase &); + /// common base for handling accents + void handleAccent(BufferView * bv, string const & arg, string const & name); /// mutable BufferView * view_; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 966dd60795..28c0ece6e0 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -442,6 +442,12 @@ void MathCursor::insert(char c, MathTextCodes t) } +void MathCursor::insert(char c) +{ + insert(c, lastcode_); +} + + void MathCursor::insert(MathAtom const & t) { macroModeClose(); diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 82e5a28d59..c518bc4419 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -241,6 +241,8 @@ public: void stripFromLastEqualSign(); /// moves on void setSelection(cursor_type const & where, size_type n); + /// + void insert(char); /// friend class Selection; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index d18713b0ec..4e302c6ff4 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -393,7 +393,8 @@ string MathGridInset::eolString(row_type row) const if (row + 1 < nrows()) { MathArray const & c = cell(index(row + 1, 0)); if (c.size() && c.front()->getChar() == '[') - eol += "[0pt]"; + //eol += "[0pt]"; + eol += "{}"; } // only add \\ if necessary diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 3fa0434295..ca09a0d750 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -800,7 +800,8 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code) // ignore braces around simple items if ((ar.size() == 1 && !ar.front()->needsBraces() || (ar.size() == 2 && !ar.front()->needsBraces() - && ar.back()->asScriptInset()))) + && ar.back()->asScriptInset())) + || (ar.size() == 0 && array.size() == 0)) { array.push_back(ar); } else { -- 2.39.2