3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
15 #include "FuncRequest.h"
23 GuiMath::GuiMath(LyXView & lv, std::string const & name)
26 // FIXME: Ideally, those unicode codepoints would be defined
27 // in "lib/symbols". Unfortunately, some of those are already
28 // defined with non-unicode ids for use within mathed.
29 // FIXME 2: We should fill-in this map with the parsed "symbols"
30 // file done in MathFactory.cpp.
31 math_symbols_["("] = MathSymbol('(');
32 math_symbols_[")"] = MathSymbol(')');
33 math_symbols_["{"] = MathSymbol('{');
34 math_symbols_["}"] = MathSymbol('}');
35 math_symbols_["["] = MathSymbol('[');
36 math_symbols_["]"] = MathSymbol(']');
37 math_symbols_["|"] = MathSymbol('|');
38 math_symbols_["/"] = MathSymbol('/', 54, Font::CMSY_FAMILY);
39 math_symbols_["backslash"] = MathSymbol('\\', 110, Font::CMSY_FAMILY);
40 math_symbols_["lceil"] = MathSymbol(0x2308, 100, Font::CMSY_FAMILY);
41 math_symbols_["rceil"] = MathSymbol(0x2309, 101, Font::CMSY_FAMILY);
42 math_symbols_["lfloor"] = MathSymbol(0x230A, 98, Font::CMSY_FAMILY);
43 math_symbols_["rfloor"] = MathSymbol(0x230B, 99, Font::CMSY_FAMILY);
44 math_symbols_["langle"] = MathSymbol(0x2329, 104, Font::CMSY_FAMILY);
45 math_symbols_["rangle"] = MathSymbol(0x232A, 105, Font::CMSY_FAMILY);
46 math_symbols_["uparrow"] = MathSymbol(0x2191, 34, Font::CMSY_FAMILY);
47 math_symbols_["Uparrow"] = MathSymbol(0x21D1, 42, Font::CMSY_FAMILY);
48 math_symbols_["updownarrow"] = MathSymbol(0x2195, 108, Font::CMSY_FAMILY);
49 math_symbols_["Updownarrow"] = MathSymbol(0x21D5, 109, Font::CMSY_FAMILY);
50 math_symbols_["downarrow"] = MathSymbol(0x2193, 35, Font::CMSY_FAMILY);
51 math_symbols_["Downarrow"] = MathSymbol(0x21D3, 43, Font::CMSY_FAMILY);
52 math_symbols_["downdownarrows"] = MathSymbol(0x21CA, 184, Font::MSA_FAMILY);
53 math_symbols_["downharpoonleft"] = MathSymbol(0x21C3, 188, Font::MSA_FAMILY);
54 math_symbols_["downharpoonright"] = MathSymbol(0x21C2, 186, Font::MSA_FAMILY);
55 math_symbols_["vert"] = MathSymbol(0x007C, 106, Font::CMSY_FAMILY);
56 math_symbols_["Vert"] = MathSymbol(0x2016, 107, Font::CMSY_FAMILY);
58 std::map<string, MathSymbol>::const_iterator it = math_symbols_.begin();
59 std::map<string, MathSymbol>::const_iterator end = math_symbols_.end();
60 for (; it != end; ++it)
61 tex_names_[it->second.unicode] = it->first;
65 void GuiMath::dispatchFunc(kb_action action, string const & arg) const
67 dispatch(FuncRequest(action, arg));
71 void GuiMath::dispatchInsert(string const & name) const
73 dispatchFunc(LFUN_MATH_INSERT, '\\' + name);
77 void GuiMath::dispatchSubscript() const
79 dispatchFunc(LFUN_MATH_INSERT, "_");
83 void GuiMath::dispatchSuperscript() const
85 dispatchFunc(LFUN_MATH_INSERT, "^");
89 void GuiMath::dispatchCubeRoot() const
91 dispatchFunc(LFUN_MATH_INSERT, "\\root");
92 dispatchFunc(LFUN_SELF_INSERT, "3");
93 dispatchFunc(LFUN_CHAR_FORWARD);
97 void GuiMath::dispatchMatrix(string const & str) const
99 dispatchFunc(LFUN_MATH_MATRIX, str);
103 void GuiMath::dispatchDelim(string const & str) const
105 dispatchFunc(LFUN_MATH_DELIM, str);
109 void GuiMath::dispatchBigDelim(string const & str) const
111 dispatchFunc(LFUN_MATH_BIGDELIM, str);
115 void GuiMath::dispatchToggleDisplay() const
117 dispatchFunc(LFUN_MATH_DISPLAY);
121 void GuiMath::showDialog(string const & name) const
123 dispatchFunc(LFUN_DIALOG_SHOW, name);
127 MathSymbol const & GuiMath::mathSymbol(string tex_name) const
129 map<string, MathSymbol>::const_iterator it =
130 math_symbols_.find(tex_name);
132 static MathSymbol unknown_symbol;
133 if (it == math_symbols_.end())
134 return unknown_symbol;
140 std::string const & GuiMath::texName(char_type math_symbol) const
142 map<char_type, string>::const_iterator it =
143 tex_names_.find(math_symbol);
145 static string empty_string;
146 if (it == tex_names_.end())
153 } // namespace frontend