small cleanup, doxygen, formatting changes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1521 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-16 09:25:43 +00:00
parent 14ee5d8843
commit 9a3176581d
83 changed files with 2331 additions and 1920 deletions

View File

@ -128,7 +128,7 @@ void io_cb(int fd, void *data)
if (n>=0)
s[n] = 0;
fprintf(stderr, "monitor: Coming: %s\n", s);
if (strncmp(s, "LYXSRV:", 7)==0) {
if (compare(s, "LYXSRV:", 7) == 0) {
if (strstr(s, "bye")) {
lyx_listen = 0;
fprintf(stderr, "monitor: LyX has closed connection!\n");

View File

@ -65,6 +65,11 @@ src/frontends/kde/tabcreatedlg.C
src/frontends/kde/tocdlg.C
src/frontends/kde/urldlg.C
src/frontends/qt2/FormCopyright.C
src/frontends/qt2/FormParagraph.C
src/frontends/qt2/FormPrint.C
src/frontends/qt2/FormTabularCreate.C
src/frontends/qt2/paragraphdlgimpl.C
src/frontends/qt2/tabularcreatedlgimpl.C
src/frontends/xforms/FormBase.h
src/frontends/xforms/form_bibitem.C
src/frontends/xforms/FormBibitem.C

View File

@ -1,3 +1,32 @@
2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* vspace.h: doxygen
* text.C (GetVisibleRow): make several local vars const
* tabular.C: small cleanup.
* lyxserver.C (callback): use compare instead of strncmp
* lyxparagraph.h: remove all code dep. on HAVE_ROPE, move inclass
inlines to after class or to paragraph.C
* lyxfont.h: remove friend operator!=
* converter.h: move friend bool operator< to non friend and after
class def.
* combox.h: small cleanup
* buffer.h: doxygen, remove unused constructor, move inclas inlies
to inlines after class def.
* buffer.C (pop_tag): use string operations instead of strcmp
* bmtable.c: doxygen, small cleanup
* LaTeX.h: remove friend operator==
2001-02-14 Lars Gullik Bjønnes <larsbj@lyx.org>
* screen.C:

View File

@ -74,9 +74,6 @@ public:
std::set<string> databases;
///
std::set<string> styles;
///
friend
bool operator==(Aux_Info const & a, Aux_Info const & o);
};

View File

@ -160,11 +160,6 @@ struct PrinterParams {
{
testInvariant();
}
// do we need these?
// friend bool operator==(PrinterParams const &, PrinterParams const &);
// friend bool operator<(PrinterParams const &, PrinterParams const &);
};
#endif

View File

@ -29,15 +29,15 @@ extern "C"
#endif
typedef struct {
int nx, ny; /* Dimensions of the table */
int dx, dy; /* Size of each item */
int bx, by; /* Bitmap's position */
int bw, bh; /* Bitmap dimensions */
unsigned char const * bdata; /* Bitmap data */
int maxi; /* Number of items */
int i; /* Current position */
int mousebut; /* mouse button pushed */
Pixmap pix; /* Pixmap from data (temporal) */
int nx, ny; /**< Dimensions of the table */
int dx, dy; /**< Size of each item */
int bx, by; /**< Bitmap's position */
int bw, bh; /**< Bitmap dimensions */
unsigned char const * bdata; /**< Bitmap data */
int maxi; /**< Number of items */
int i; /**< Current position */
int mousebut; /**< mouse button pushed */
Pixmap pix; /**< Pixmap from data (temporal) */
} BMTABLE_SPEC;
@ -294,8 +294,10 @@ void fl_set_bmtable_pixmap_data(FL_OBJECT * ob, int nx, int ny,
void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
{
int xh, yh;
unsigned int bw, bh;
int xh;
int yh;
unsigned int bw;
unsigned int bh;
unsigned char * bdata;
if (XReadBitmapFileData(filename, &bw, &bh,
@ -436,7 +438,10 @@ Pixmap fl_get_bmtable_pixmap(FL_OBJECT * ob)
void fl_draw_bmtable_item(FL_OBJECT * ob, int i, Drawable d, int xx, int yy)
{
int x, y, w, h;
int x;
int y;
int w;
int h;
GC gc = fl_state[fl_get_vclass()].gc[0];
BMTABLE_SPEC * sp = (BMTABLE_SPEC *)ob->spec;

View File

@ -2546,7 +2546,7 @@ void Buffer::pop_tag(ostream & os, string const & tag,
int j;
// pop all tags till specified one
for (j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
for (j = pos; (j >= 0) && tag != stack[j]; --j)
os << "</" << stack[j] << ">";
// closes the tag
@ -2561,7 +2561,7 @@ void Buffer::pop_tag(ostream & os, string const & tag,
#else
// pop all tags till specified one
int j = pos;
for (int j = pos; (j >= 0) && (strcmp(stack[j], tag.c_str())); --j)
for (int j = pos; (j >= 0) && tag != stack[j]; --j)
os << "</" << stack[j] << ">";
// closes the tag

View File

@ -37,7 +37,6 @@
class LyXRC;
class TeXErrors;
class LaTeXFeatures;
class auto_mem_buffer;
class Language;
///
@ -54,26 +53,30 @@ struct DEPCLEAN {
The is is the buffer object. It contains all the informations about
a document loaded into LyX. I am not sure if the class is complete or
minimal, probably not.
\author Lars Gullik Bjønnes
*/
class Buffer {
public:
/// what type of log will getLogName() return ?
/// What type of log will \c getLogName() return?
enum LogType {
latexlog, /**< LaTeX log */
buildlog /**< Literate build log */
latexlog, ///< LaTeX log
buildlog ///< Literate build log
};
///
/** Constructor
\param file
\param b optional \c false by default
*/
explicit Buffer(string const & file, bool b = false);
///
/// Destrucotr
~Buffer();
/** save the buffer's parameters as user default
This function saves a file #user_lyxdir/templates/defaults.lyx#
/** Save the buffer's parameters as user default.
This function saves a file \c user_lyxdir/templates/defaults.lyx
which parameters are those of the current buffer. This file
is used as a default template when creating a new
file. Returns #true# on success.
file. Returns \c true on success.
*/
bool saveParamsAsDefaults();
@ -85,50 +88,43 @@ public:
/// Maybe we know the function already by number...
bool Dispatch(int ac, string const & argument);
/// and have an xtl buffer to work with.
bool Dispatch(int, auto_mem_buffer &);
/// should be changed to work for a list.
/// Should be changed to work for a list.
void resize();
///
void resizeInsets(BufferView *);
/// Update window titles of all users
/// Update window titles of all users.
void updateTitles() const;
/// Reset autosave timers for all users
/// Reset autosave timers for all users.
void resetAutosaveTimers() const;
/** Adds the BufferView to the users list.
Later this func will insert the #BufferView# into a real list,
Later this func will insert the \c BufferView into a real list,
not just setting a pointer.
*/
void addUser(BufferView * u) { users = u; }
void addUser(BufferView * u);
/** Removes the #BufferView# from the users list.
Since we only can have one at the moment, we just reset it.
*/
void delUser(BufferView *) { users = 0; }
void delUser(BufferView *);
///
void redraw() {
users->redraw();
users->fitCursor(users->text);
//users->updateScrollbar();
}
void redraw();
///
/// Load the autosaved file.
void loadAutoSaveFile();
/** Reads a file.
@param par if != 0 insert the file.
@return #false# if method fails.
\param par if != 0 insert the file.
\return \c false if method fails.
*/
bool readFile(LyXLex &, LyXParagraph * par = 0);
/** Reads a file without header.
@param par if != 0 insert the file.
@return false if file is not completely read.
\param par if != 0 insert the file.
\return \c false if file is not completely read.
*/
bool readLyXformat2(LyXLex &, LyXParagraph * par = 0);
@ -146,13 +142,13 @@ private:
/// Parse a single inset.
void readInset(LyXLex &, LyXParagraph *& par, int & pos, LyXFont &);
public:
/** Save file
/** Save file.
Takes care of auto-save files and backup file if requested.
Returns #true# if the save is successful, #false# otherwise.
Returns \c true if the save is successful, \c false otherwise.
*/
bool save() const;
/// Write file. Returns #false# if unsuccesful.
/// Write file. Returns \c false if unsuccesful.
bool writeFile(string const &, bool) const;
///
@ -167,7 +163,7 @@ public:
string const & original_path,
bool nice, bool only_body = false);
/** LaTeX all paragraphs from par to endpar.
@param endpar if == 0 then to the end
\param \a endpar if == 0 then to the end
*/
void latexParagraphs(std::ostream & os, LyXParagraph * par,
LyXParagraph * endpar, TexRow & texrow) const;
@ -188,66 +184,42 @@ public:
bool nice, bool only_body = false);
/// returns the main language for the buffer (document)
Language const * GetLanguage() const {
return params.language;
}
Language const * GetLanguage() const;
///
bool isLyxClean() const { return lyx_clean; }
bool isLyxClean() const;
///
bool isBakClean() const { return bak_clean; }
bool isBakClean() const;
///
bool isDepClean(string const & name) const;
///
void markLyxClean() const {
if (!lyx_clean) {
lyx_clean = true;
updateTitles();
}
// if the .lyx file has been saved, we don't need an
// autosave
bak_clean = true;
}
void markLyxClean() const;
///
void markBakClean() { bak_clean = true; }
void markBakClean();
///
void markDepClean(string const & name);
///
void setUnnamed(bool flag=true) { unnamed = flag; }
void setUnnamed(bool flag=true);
///
bool isUnnamed() { return unnamed; }
bool isUnnamed();
///
void markDirty() {
if (lyx_clean) {
lyx_clean = false;
updateTitles();
}
bak_clean = false;
DEPCLEAN * tmp = dep_clean;
while (tmp) {
tmp->clean = false;
tmp = tmp->next;
}
}
/// Mark this buffer as dirty.
void markDirty();
///
string const & fileName() const { return filename; }
/// Returns the buffers filename.
string const & fileName() const;
/** A transformed version of the file name, adequate for LaTeX
The path is stripped if no_path is true (default)
/** A transformed version of the file name, adequate for LaTeX.
\param no_path optional if \c true then the path is stripped.
*/
string const getLatexName(bool no_path = true) const;
/// get the name and type of the log
std::pair<LogType, string> const getLogName(void) const;
/// Get the name and type of the log.
std::pair<LogType, string> const getLogName() const;
/// Change name of buffer. Updates "read-only" flag.
void setFileName(string const & newfile);
@ -256,21 +228,21 @@ public:
void setParentName(string const &);
/// Is buffer read-only?
bool isReadonly() const { return read_only; }
bool isReadonly() const;
/// Set buffer read-only flag
void setReadonly(bool flag = true);
/// returns #true# if the buffer contains a LaTeX document
/// returns \c true if the buffer contains a LaTeX document
bool isLatex() const;
/// returns #true# if the buffer contains a LinuxDoc document
/// returns \c true if the buffer contains a LinuxDoc document
bool isLinuxDoc() const;
/// returns #true# if the buffer contains a DocBook document
/// returns \c true if the buffer contains a DocBook document
bool isDocBook() const;
/** returns #true# if the buffer contains either a LinuxDoc
/** returns \c true if the buffer contains either a LinuxDoc
or DocBook document */
bool isSGML() const;
/// returns #true# if the buffer contains a Wed document
/// returns \c true if the buffer contains a Wed document
bool isLiterate() const;
///
@ -300,16 +272,12 @@ public:
///
string str;
};
///
/// The different content list types.
enum TocType {
///
TOC_TOC = 0,
///
TOC_LOF,
///
TOC_LOT,
///
TOC_LOA
TOC_TOC = 0, ///< Table of Contents
TOC_LOF, ///< List of Figures
TOC_LOT, ///< List of Tables
TOC_LOA ///< List of Algorithms
};
///
std::vector<std::vector<TocItem> > const getTocList() const;
@ -318,7 +286,7 @@ public:
/** This will clearly have to change later. Later we can have more
than one user per buffer. */
BufferView * getUser() const { return users; }
BufferView * getUser() const;
///
void ChangeLanguage(Language const * from, Language const * to);
@ -334,20 +302,23 @@ public:
///
BufferParams params;
/** is a list of paragraphs.
/** The list of paragraphs.
This is a linked list of paragraph, this list holds the
whole contents of the document.
*/
LyXParagraph * paragraph;
/// RCS object
/// LyX version control object.
LyXVC lyxvc;
/// where the temporaries go if we want them
/// Where to put temporary files.
string tmppath;
///
/// The path to the document file.
string filepath;
/** While writing as LaTeX, tells whether we are
/** If we are writing a nice LaTeX file or not.
While writing as LaTeX, tells whether we are
doing a 'nice' LaTeX file */
bool niceFile;
@ -472,10 +443,6 @@ public:
friend
bool operator==(inset_iterator const & iter1,
inset_iterator const & iter2);
//
//friend
//bool operator!=(inset_iterator const & iter1,
// inset_iterator const & iter2);
private:
///
void SetParagraph();
@ -497,11 +464,126 @@ public:
inline
void Buffer::setParentName(string const & name)
void Buffer::addUser(BufferView * u)
{
users = u;
}
inline
void Buffer::delUser(BufferView *)
{
users = 0;
}
inline
void Buffer::redraw()
{
users->redraw();
users->fitCursor(users->text);
}
inline
Language const * Buffer::GetLanguage() const
{
return params.language;
}
inline
bool Buffer::isLyxClean() const
{
return lyx_clean;
}
inline
bool Buffer::isBakClean() const
{
return bak_clean;
}
inline
void Buffer::markLyxClean() const
{
if (!lyx_clean) {
lyx_clean = true;
updateTitles();
}
// if the .lyx file has been saved, we don't need an
// autosave
bak_clean = true;
}
inline
void Buffer::markBakClean()
{
bak_clean = true;
}
inline
void Buffer::setUnnamed(bool flag = true)
{
unnamed = flag;
}
inline
bool Buffer::isUnnamed()
{
return unnamed;
}
inline
void Buffer::markDirty()
{
if (lyx_clean) {
lyx_clean = false;
updateTitles();
}
bak_clean = false;
DEPCLEAN * tmp = dep_clean;
while (tmp) {
tmp->clean = false;
tmp = tmp->next;
}
}
inline
string const & Buffer::fileName() const
{
return filename;
}
inline
bool Buffer::isReadonly() const
{
return read_only;
}
inline
BufferView * Buffer::getUser() const
{
return users;
}
inline
void Buffer::Buffer::setParentName(string const & name)
{
params.parentname = name;
}
///
inline
bool operator==(Buffer::TocItem const & a, Buffer::TocItem const & b) {

View File

@ -133,7 +133,9 @@ public:
///
combox_type type;
///
int bw, bh;
int bw;
///
int bh;
///
int sel;
///

View File

@ -61,9 +61,6 @@ public:
void setViewer(string const & v) {
viewer_ = v;
}
friend bool operator<(Format const & a, Format const & b) {
return compare_no_case(a.prettyname(),b.prettyname()) < 0;
}
private:
string name_;
///
@ -77,6 +74,13 @@ private:
};
inline
bool operator<(Format const & a, Format const & b)
{
return compare_no_case(a.prettyname(),b.prettyname()) < 0;
}
///
class Formats {
public:

View File

@ -78,9 +78,6 @@ struct Debug {
///
static type const ANY;
///
// friend inline void operator|=(Debug::type & d1, Debug::type d2);
/** A function to convert symbolic string names on debug levels
to their numerical value.
*/

View File

@ -0,0 +1,7 @@
2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* FormCitation.C: small cleanup.
(searchSimple): better localization of variables, don't use
sequencing operator if you don't have to.
* other: use compare instead of strcmp/strncmp

View File

@ -924,10 +924,11 @@ void FormCitation::searchReg()
void FormCitation::searchSimple()
{
vector<string> searchwords;
string tmp, stext( search_string_ );
string tmp;
string stext(search_string_);
stext = frontStrip( strip( stext ) );
stext = frontStrip( split(stext, tmp, ' ') );
while( !tmp.empty() )
while ( !tmp.empty() )
{
searchwords.push_back(tmp);
stext = frontStrip( split(stext, tmp, ' ') );
@ -939,20 +940,17 @@ void FormCitation::searchSimple()
clist_bib_->freeze();
int const sz = bibkeys.size();
bool additem;
for ( int i = 0; i < sz; ++i )
{
string data = bibkeys[i] + bibkeysInfo[i];
for (int i = 0; i < sz; ++i) {
string const data = bibkeys[i] + bibkeysInfo[i];
additem = true;
bool additem = true;
int j, szs;
for (j = 0, szs = searchwords.size();
additem && j < szs; ++j )
if ( data.find(searchwords[j]) == string::npos )
additem = false;
int const szs = searchwords.size();
for (int j = 0; additem && j < szs; ++j)
if (data.find(searchwords[j]) == string::npos)
additem = false;
if ( additem ) addItemToBibList(i);
if (additem) addItemToBibList(i);
}
clist_bib_->sort();

View File

@ -85,14 +85,10 @@ void
diaprint_on_print_from_changed (GtkEditable *editable,
gpointer user_data)
{
GtkSpinButton * to;
GtkAdjustment * a;
int nmin, v;
nmin = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(editable) );
to = GTK_SPIN_BUTTON(lookup_widget(GTK_WIDGET(editable), "print_to"));
a = gtk_spin_button_get_adjustment(to);
v = gtk_spin_button_get_value_as_int(to);
int nmin = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(editable) );
GtkSpinButton * to = GTK_SPIN_BUTTON(lookup_widget(GTK_WIDGET(editable), "print_to"));
GtkAdjustment * a = gtk_spin_button_get_adjustment(to);
int v = gtk_spin_button_get_value_as_int(to);
a->lower = nmin;
if (v < nmin)

View File

@ -143,7 +143,8 @@ void FormRef::updateRefs()
dialog_->reference->setText(tmp.c_str());
for (unsigned int i=0; i < dialog_->refs->count(); ++i) {
if (!strcmp(dialog_->reference->text(),dialog_->refs->text(i)))
if (!compare(dialog_->reference->text(),
dialog_->refs->text(i)))
dialog_->refs->setCurrentItem(i);
}

View File

@ -582,20 +582,20 @@ bool DocDialog::updateParams(BufferParams & params)
string DocDialog::placementString(QComboBox * box) const
{
if (!strcmp(box->currentText(), _("Here")))
if (!compare(box->currentText(), _("Here")))
return "h";
if (!strcmp(box->currentText(), _("Bottom of page")))
if (!compare(box->currentText(), _("Bottom of page")))
return "b";
if (!strcmp(box->currentText(), _("Top of page")))
if (!compare(box->currentText(), _("Top of page")))
return "t";
if (!strcmp(box->currentText(), _("Separate page")))
if (!compare(box->currentText(), _("Separate page")))
return "p";
return "";
}
void DocDialog::linespacingChanged(const char * sel)
{
bool const custom = !strcmp(sel, _("custom"));
bool const custom = !compare(sel, _("custom"));
settings->linespacingVal->setEnabled(custom);
}
@ -603,7 +603,7 @@ void DocDialog::linespacingChanged(const char * sel)
void DocDialog::paraspacingChanged(const char * sel)
{
bool const custom = !strcmp(sel, _("custom"));
bool const custom = !compare(sel, _("custom"));
settings->paraspacingValue->setEnabled(custom);
settings->paraspacingStretch->setEnabled(custom);
settings->paraspacingShrink->setEnabled(custom);
@ -612,7 +612,8 @@ void DocDialog::paraspacingChanged(const char * sel)
void DocDialog::addspaceChanged(bool on)
{
settings->paraspacing->setEnabled(on);
on = (on && !strcmp(settings->paraspacing->currentText(), _("custom")));
on = (on && !compare(settings->paraspacing->currentText(),
_("custom")));
settings->paraspacingValue->setEnabled(on);
settings->paraspacingStretch->setEnabled(on);
settings->paraspacingShrink->setEnabled(on);

View File

@ -91,7 +91,7 @@ void ParaDialog::setReadOnly(bool readonly)
void ParaDialog::setLabelWidth(char const * text)
{
// FIXME: should be cleverer here
if (!strcmp(_("Senseless with this layout!"),text)) {
if (!compare(_("Senseless with this layout!"), text)) {
generalpage->labelwidth->setText("");
generalpage->labelwidth->setEnabled(false);
} else {

View File

@ -56,7 +56,7 @@ void PrintDialog::clickedBrowse()
void PrintDialog::changedCount(char const * text)
{
if (strcmp("",text) && strToInt(text) == 0) {
if (compare("", text) && strToInt(text) == 0) {
count->setText("1");
return;
}

View File

@ -1,3 +1,7 @@
2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* other: use compare instead of strcmp/strncmp
2001-02-15 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonController.[Ch]: changed trigger_change_ vector and associated

View File

@ -79,7 +79,7 @@ void FormBibitem::build()
bool FormBibitem::input(FL_OBJECT *, long)
{
// minimal validation
if (!strcmp(fl_get_input(dialog_->key),""))
if (!compare(fl_get_input(dialog_->key), ""))
return false;
return true;

View File

@ -79,7 +79,7 @@ void FormBibtex::build()
bool FormBibtex::input(FL_OBJECT *, long)
{
// minimal validation
if (!strcmp(fl_get_input(dialog_->database),""))
if (!compare(fl_get_input(dialog_->database),""))
return false;
return true;

View File

@ -196,7 +196,7 @@ void FormPrint::update()
fl_set_input(dialog_->input_count,
tostr(pp.count_copies).c_str());
bc_.valid();
bc_.valid(true);
}
}

View File

@ -1,3 +1,15 @@
2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* insettext.C (textWidth): constify local var
* insettabular.C: small cleanup.
* insetfoot.C (Latex): constify local var
* insetcollapsable.C: small cleanup.
* figinset.C (runqueue): use compare instead of strcmp
2001-02-14 Lars Gullik Bjønnes <larsbj@lyx.org>
* insettext.C:

View File

@ -566,7 +566,7 @@ void runqueue()
for (i = 0; i < nprop; ++i) {
char * p = XGetAtomName(tempdisp,
prop[i]);
if (strcmp(p, "GHOSTVIEW") == 0) {
if (compare(p, "GHOSTVIEW") == 0) {
err = false;
// We free it when we leave so we don't leak.
XFree(p);

View File

@ -99,7 +99,9 @@ void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
{
int width = 0, ascent = 0, descent = 0;
int width = 0;
int ascent = 0;
int descent = 0;
pain.buttonText(0, 0, label, labelfont, false,
width, ascent, descent);
return ascent;
@ -108,7 +110,9 @@ int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
{
int width = 0, ascent = 0, descent = 0;
int width = 0;
int ascent = 0;
int descent = 0;
pain.buttonText(0, 0, label, labelfont, false,
width, ascent, descent);
return descent;
@ -117,7 +121,9 @@ int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
{
int width, ascent, descent;
int width;
int ascent;
int descent;
pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label, labelfont, false,
width, ascent, descent);
return width + (2*TEXT_TO_INSET_OFFSET);
@ -292,7 +298,7 @@ int InsetCollapsable::Latex(Buffer const * buf, ostream & os,
int InsetCollapsable::getMaxWidth(Painter & pain,
UpdatableInset const * inset) const
{
int w = UpdatableInset::getMaxWidth(pain,inset);
int const w = UpdatableInset::getMaxWidth(pain, inset);
if (w < 0) {
// What does a negative max width signify? (Lgb)

View File

@ -55,7 +55,7 @@ int InsetFoot::Latex(Buffer const * buf,
{
os << "\\footnote{%\n";
int i = inset->Latex(buf, os, fragile, fp);
int const i = inset->Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;

View File

@ -220,7 +220,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
return;
Painter & pain = bv->painter();
int i, j;
int i;
int j;
int nx;
UpdatableInset::draw(bv, font, baseline, x, cleared);
@ -355,7 +356,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
int row, int cell) const
{
int x2 = x + tabular->GetWidthOfColumn(cell);
int x2 = x + tabular->GetWidthOfColumn(cell);
bool on_off;
if (!tabular->TopAlreadyDrawed(cell)) {
@ -1367,7 +1368,7 @@ bool InsetTabular::TabularFeatures(BufferView * bv, string const & what)
string const tmp = tabularFeatures[i].feature;
if (tmp == what.substr(0, tmp.length())) {
//if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
//if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
//tabularFeatures[i].feature.length())) {
action = tabularFeatures[i].action;
break;
@ -1805,7 +1806,7 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const
for (; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
string const tmp = tabularFeatures[i].feature;
if (tmp == what.substr(0, tmp.length())) {
//if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
//if (!compare(tabularFeatures[i].feature.c_str(), what.c_str(),
// tabularFeatures[i].feature.length())) {
action = tabularFeatures[i].action;
break;
@ -1816,7 +1817,8 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const
string const argument = frontStrip(what.substr(tabularFeatures[i].feature.length()));
int sel_row_start, sel_row_end;
int sel_row_start;
int sel_row_end;
int dummy;
bool flag = true;
@ -2022,8 +2024,10 @@ bool InsetTabular::copySelection(BufferView * bv)
return false;
delete paste_tabular;
int sel_col_start, sel_col_end;
int sel_row_start, sel_row_end;
int sel_col_start;
int sel_col_end;
int sel_row_start;
int sel_row_end;
sel_col_start = tabular->column_of_cell(sel_cell_start);
sel_col_end = tabular->column_of_cell(sel_cell_end);
@ -2108,8 +2112,10 @@ bool InsetTabular::cutSelection()
if (!hasSelection())
return false;
int sel_col_start, sel_col_end;
int sel_row_start, sel_row_end;
int sel_col_start;
int sel_col_end;
int sel_row_start;
int sel_row_end;
sel_col_start = tabular->column_of_cell(sel_cell_start);
sel_col_end = tabular->column_of_cell(sel_cell_end);

View File

@ -261,7 +261,7 @@ int InsetText::width(BufferView * bv, LyXFont const &) const
int InsetText::textWidth(Painter & pain) const
{
int w = getMaxWidth(pain, this);
int const w = getMaxWidth(pain, this);
return w;
}

View File

@ -320,10 +320,6 @@ public:
friend
bool operator==(LyXFont const & font1, LyXFont const & font2);
///
friend
bool operator!=(LyXFont const & font1, LyXFont const & font2);
/// compares two fonts, ignoring the setting of the Latex part.
bool equalExceptLatex(LyXFont const &) const;

View File

@ -16,12 +16,6 @@
#pragma interface
#endif
//#define HAVE_ROPE 1
#ifdef HAVE_ROPE
#include <rope>
#endif
#include <vector>
#include <list>
@ -128,11 +122,7 @@ public:
///
typedef char value_type;
///
#ifndef HAVE_ROPE
typedef std::vector<value_type> TextContainer;
#else
typedef std::rope<value_type> TextContainer;
#endif
///
/* This should be TextContainer::size_type, but we need
signed values for now.
@ -169,14 +159,9 @@ public:
void validate(LaTeXFeatures &) const;
///
int id() const {
return id_;
}
int id() const;
///
void id(int id_arg) {
id_ = id_arg;
}
void id(int id_arg);
///
void read();
@ -212,18 +197,13 @@ public:
void MakeSameLayout(LyXParagraph const * par);
/// Is it the first par with same depth and layout?
bool IsFirstInSequence() const {
LyXParagraph const * dhook = DepthHook(GetDepth());
return (dhook == this
|| dhook->GetLayout() != GetLayout()
|| dhook->GetDepth() != GetDepth());
}
bool IsFirstInSequence() const;
/** Check if the current paragraph is the last paragraph in a
proof environment */
int GetEndLabel(BufferParams const &) const;
///
Inset * InInset() { return inset_owner; }
Inset * InInset();
///
void SetInsetOwner(Inset * i);
///
@ -238,26 +218,13 @@ private:
public:
///
size_type size() const { return text.size(); }
size_type size() const;
///
void fitToSize() {
#ifndef HAVE_ROPE
text.resize(text.size());
#endif
}
void fitToSize();
///
void setContentsFromPar(LyXParagraph * par) {
text = par->text;
}
void setContentsFromPar(LyXParagraph * par);
///
void clearContents() {
#ifndef HAVE_ROPE
text.clear();
#else
text.erase(text.mutable_begin(), text.mutable_end());
#endif
}
void clearContents();
///
VSpace added_space_top;
@ -308,11 +275,11 @@ private:
array<int, 10> counter_;
public:
///
void setCounter(int i, int v) { counter_[i] = v; }
void setCounter(int i, int v);
///
int getCounter(int i) const { return counter_[i]; }
int getCounter(int i) const;
///
void incCounter(int i) { counter_[i]++; }
void incCounter(int i);
///
bool start_of_appendix;
@ -444,14 +411,7 @@ public:
///
value_type GetUChar(BufferParams const &, size_type pos) const;
/// The position must already exist.
void SetChar(size_type pos, value_type c) {
#ifndef HAVE_ROPE
text[pos] = c;
#else
text.replace(pos, c);
#endif
}
void SetChar(size_type pos, value_type c);
///
void SetFont(size_type pos, LyXFont const & font);
///
@ -688,15 +648,97 @@ public:
InsetList::iterator it;
};
///
inset_iterator inset_iterator_begin() {
return inset_iterator(insetlist.begin());
}
inset_iterator inset_iterator_begin();
///
inset_iterator inset_iterator_end() {
return inset_iterator(insetlist.end());
}
inset_iterator inset_iterator_end();
///
inset_iterator InsetIterator(size_type pos);
};
inline
int LyXParagraph::id() const
{
return id_;
}
inline
void LyXParagraph::id(int id_arg)
{
id_ = id_arg;
}
inline
bool LyXParagraph::IsFirstInSequence() const
{
LyXParagraph const * dhook = DepthHook(GetDepth());
return (dhook == this
|| dhook->GetLayout() != GetLayout()
|| dhook->GetDepth() != GetDepth());
}
inline
Inset * LyXParagraph::InInset()
{
return inset_owner;
}
inline
LyXParagraph::size_type LyXParagraph::size() const
{
return text.size();
}
inline
void LyXParagraph::clearContents()
{
text.clear();
}
inline
void LyXParagraph::setCounter(int i, int v)
{
counter_[i] = v;
}
inline
int LyXParagraph::getCounter(int i) const
{
return counter_[i];
}
inline
void LyXParagraph::incCounter(int i)
{
counter_[i]++;
}
inline
void LyXParagraph::SetChar(size_type pos, value_type c)
{
text[pos] = c;
}
inline
LyXParagraph::inset_iterator LyXParagraph::inset_iterator_begin()
{
return inset_iterator(insetlist.begin());
}
inline
LyXParagraph::inset_iterator LyXParagraph::inset_iterator_end()
{
return inset_iterator(insetlist.end());
}
#endif

View File

@ -432,9 +432,9 @@ void LyXServer::callback(LyXServer * serv, string const & msg)
while(*p) {
// --- 1. check 'header' ---
if (strncmp(p, "LYXSRV:", 7) == 0) {
if (compare(p, "LYXSRV:", 7) == 0) {
server_only = true;
} else if (0!= strncmp(p, "LYXCMD:", 7)) {
} else if (0 != compare(p, "LYXCMD:", 7)) {
lyxerr << "LyXServer: Unknown request" << endl;
return;
}

View File

@ -1,6 +1,21 @@
2001-02-16 Lars Gullik Bjønnes <larsbj@lyx.org>
* Makefile.am (libmathed_la_SOURCES): remove math_write.C, add
math_utils.h
* math_write.C: delete file
* math_delim.C: delete file
* marh_sqrtinset.h: delete file
* move funcs to more localized files, more general cleanup.
Constify several local vars. Doxygen changes. Formatting.
2001-02-15 Lars Gullik Bjønnes <larsbj@lyx.org>
* support.C: add some consts
* matriz.C: clean up a bit.
(matmat): remove the for loop.
* several files: changes so that several friends can be removed

View File

@ -65,7 +65,7 @@ libmathed_la_SOURCES = \
math_spaceinset.h \
math_symbols.C \
math_utils.C \
math_write.C \
math_utils.h \
math_xiter.C \
math_xiter.h \
matriz.C \

View File

@ -59,6 +59,7 @@ extern string mathed_label;
extern char const * latex_special_chars;
int greek_kb_flag = 0;
extern char const * latex_mathenv[];
// this is only used by Whichfont and mathed_init_fonts (Lgb)
LyXFont * Math_Fonts = 0;
@ -70,15 +71,22 @@ static int sel_x;
static int sel_y;
static bool sel_flag;
MathedCursor * InsetFormula::mathcursor = 0;
// quite a hack i know. Should be done with return values...
int number_of_newlines = 0;
static
int mathed_write(MathParInset *, std::ostream &, bool fragile,
string const & label = string());
void mathed_init_fonts();
static
void mathedValidate(LaTeXFeatures & features, MathParInset * par);
MathedCursor * InsetFormula::mathcursor = 0;
LyXFont WhichFont(short type, int size)
{
LyXFont f;
@ -250,11 +258,9 @@ void InsetFormula::Write(Buffer const * buf, ostream & os) const
int InsetFormula::Latex(Buffer const *, ostream & os, bool fragile, bool) const
{
int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
// This problem will disapear at 0.13.
mathed_write(par, os, &ret, fragile, label);
return ret;
return mathed_write(par, os, fragile, label);
}
@ -905,7 +911,7 @@ InsetFormula::LocalDispatch(BufferView * bv, int action, string const & arg)
case LFUN_MATH_SIZE:
if (!arg.empty()) {
latexkeys * l = in_word_set(arg);
latexkeys const * l = in_word_set(arg);
int sz = (l) ? l->id: -1;
mathcursor->SetSize(sz);
UpdateLocal(bv);
@ -950,7 +956,7 @@ InsetFormula::LocalDispatch(BufferView * bv, int action, string const & arg)
bv->lockedInsetStoreUndo(Undo::INSERT);
char lf[40], rg[40], arg2[40];
int ilf = '(', irg = '.';
latexkeys * l;
latexkeys const * l;
string vdelim("(){}[]./|");
if (arg.empty())
@ -1246,3 +1252,57 @@ void mathedValidate(LaTeXFeatures & features, MathParInset * par)
it.Next();
}
}
static
int mathed_write(MathParInset * p, ostream & os,
bool fragile, string const & label)
{
number_of_newlines = 0;
short mathed_env = p->GetType();
if (mathed_env == LM_OT_MIN) {
if (fragile) os << "\\protect";
os << "\\( "; // changed from " \\( " (Albrecht Dress)
} else {
if (mathed_env == LM_OT_PAR){
os << "\\[\n";
} else {
os << "\\begin{"
<< latex_mathenv[mathed_env]
<< "}";
if (is_multicolumn(mathed_env)) {
if (mathed_env != LM_OT_ALIGNAT
&& mathed_env != LM_OT_ALIGNATN)
os << "%";
os << "{" << p->GetColumns()/2 << "}";
}
os << "\n";
}
++number_of_newlines;
}
if (!label.empty() && label[0] > ' '
&& is_singlely_numbered(mathed_env)) {
os << "\\label{"
<< label
<< "}\n";
++number_of_newlines;
}
p->Write(os, fragile);
if (mathed_env == LM_OT_MIN){
if (fragile) os << "\\protect";
os << " \\)";
} else if (mathed_env == LM_OT_PAR) {
os << "\\]\n";
++number_of_newlines;
} else {
os << "\n\\end{"
<< latex_mathenv[mathed_env]
<< "}\n";
number_of_newlines += 2;
}
return number_of_newlines;
}

View File

@ -198,7 +198,7 @@ void InsetFormulaMacro::InsetUnlock(BufferView * bv)
MathedArray * tarray = tmacro->GetData();
MathedIter it(tarray);
it.Clear();
tmacro->SetData(par->GetData());
tmacro->setData(par->GetData());
tmacro->setEditMode(false);
InsetFormula::InsetUnlock(bv);
}

View File

@ -1,26 +0,0 @@
#ifndef MATH_SQRTINSET_H
#define MATH_SQRTINSET_H
#include "math_parinset.h"
///
class MathSqrtInset: public MathParInset {
public:
///
MathSqrtInset(short st = LM_ST_TEXT);
///
MathedInset * Clone();
///
void draw(Painter &, int x, int baseline);
///
void Write(std::ostream &, bool fragile);
///
void Metrics();
///
bool Inside(int, int);
private:
///
int hmax, wbody;
};
#endif

View File

@ -84,7 +84,7 @@ MathAccentInset::Metrics()
void MathAccentInset::Write(ostream & os, bool fragile)
{
latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
os << '\\' << l->name;
if (code!= LM_not)
os << '{';
@ -100,7 +100,7 @@ void MathAccentInset::Write(ostream & os, bool fragile)
<< '{';
}
if (MathIsSymbol(fn)) {
latexkeys * l = lm_get_key_by_id(c, LM_TK_SYM);
latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
if (l) {
os << '\\' << l->name << ' ';
}

View File

@ -452,8 +452,8 @@ void MathedCursor::Insert(byte c, MathedTextCodes t)
MathMatrixInset * mt = create_multiline(type, cols);
mt->SetStyle(LM_ST_DISPLAY);
mt->SetType(type);
mt->SetData(p->GetData());
p->SetData(0); // BUG duda
mt->setData(p->GetData());
p->setData(0); // BUG duda
delete p;
par = mt;
p = mt;
@ -510,7 +510,7 @@ void MathedCursor::Insert(MathedInset * p, int t)
if (selection) {
if (MathIsActive(t)) {
SelCut();
static_cast<MathParInset*>(p)->SetData(selarray);
static_cast<MathParInset*>(p)->setData(selarray);
} else
SelDel();
}
@ -720,7 +720,7 @@ void MathedCursor::setNumbered()
void MathedCursor::Interpret(string const & s)
{
MathedInset * p = 0;
latexkeys * l = 0;
latexkeys const * l = 0;
MathedTextCodes tcode = LM_TC_INSET;
if (s[0] == '^' || s[0] == '_') {
@ -758,7 +758,7 @@ void MathedCursor::Interpret(string const & s)
if (!p) {
lyxerr[Debug::MATHED] << "Macro2 " << s << ' ' << tcode << endl;
if (s == "root") {
p = new MathRootInset();
p = new MathRootInset;
tcode = LM_TC_ACTIVE_INSET;
} else
p = new MathFuncInset(s, LM_OT_UNDEF);
@ -844,7 +844,7 @@ bool MathedCursor::pullArg()
return false;
MathedArray * a = p->GetData();
p->SetData(0);
p->setData(0);
Delete();
if (a) {
cursor->Merge(a);
@ -872,7 +872,7 @@ void MathedCursor::MacroModeClose()
{
if (macro_mode) {
macro_mode = false;
latexkeys * l = in_word_set(imacro->GetName());
latexkeys const * l = in_word_set(imacro->GetName());
if (!imacro->GetName().empty()
&& (!l || (l && IsMacro(l->token, l->id))) &&
!MathMacroTable::mathMTable.getMacro(imacro->GetName())) {

View File

@ -9,24 +9,24 @@
using std::ostream;
bool MathDecorationInset::GetLimits() const
MathDecorationInset::MathDecorationInset(int d, short st)
: MathParInset(st, "", LM_OT_DECO), deco_(d)
{
return deco == LM_underbrace || deco == LM_overbrace;
upper_ = (deco_ != LM_underline && deco_ != LM_underbrace);
}
MathDecorationInset::MathDecorationInset(int d, short st)
: MathParInset(st, "", LM_OT_DECO), deco(d)
bool MathDecorationInset::GetLimits() const
{
upper = (deco!= LM_underline && deco!= LM_underbrace);
return deco_ == LM_underbrace || deco_ == LM_overbrace;
}
MathedInset * MathDecorationInset::Clone()
{
MathDecorationInset * p = new MathDecorationInset(deco, GetStyle());
MathDecorationInset * p = new MathDecorationInset(deco_, GetStyle());
MathedIter it(array);
p->SetData(it.Copy());
p->setData(it.Copy());
return p;
}
@ -34,8 +34,8 @@ MathedInset * MathDecorationInset::Clone()
void
MathDecorationInset::draw(Painter & pain, int x, int y)
{
MathParInset::draw(pain, x + (width - dw) / 2, y);
mathed_draw_deco(pain, x, y + dy, width, dh, deco);
MathParInset::draw(pain, x + (width - dw_) / 2, y);
mathed_draw_deco(pain, x, y + dy_, width, dh_, deco_);
}
@ -47,24 +47,24 @@ MathDecorationInset::Metrics()
MathParInset::Metrics();
int w = Width() + 4;
if (w < 16) w = 16;
dh = w / 5;
if (dh > h) dh = h;
dh_ = w / 5;
if (dh_ > h) dh_ = h;
if (upper) {
ascent += dh + 2;
dy = -ascent;
if (upper_) {
ascent += dh_ + 2;
dy_ = -ascent;
} else {
dy = descent + 2;
descent += dh + 4;
dy_ = descent + 2;
descent += dh_ + 4;
}
dw = width;
dw_ = width;
width = w;
}
void MathDecorationInset::Write(ostream & os, bool fragile)
{
latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
latexkeys const * l = lm_get_key_by_id(deco_, LM_TK_WIDE);
if (fragile &&
(strcmp(l->name, "overbrace") == 0 ||
strcmp(l->name, "underbrace") == 0 ||

View File

@ -3,7 +3,9 @@
#include "math_parinset.h"
/// Decorations over (below) a math object
/** Decorations over (below) a math object
\author Alejandro Aguilar Sierra
*/
class MathDecorationInset: public MathParInset {
public:
///
@ -18,12 +20,16 @@ public:
void Metrics();
///
bool GetLimits() const;
protected:
private:
///
int deco;
int deco_;
///
bool upper;
bool upper_;
///
int dw, dh, dy;
int dw_;
///
int dh_;
///
int dy_;
};
#endif

View File

@ -1,64 +0,0 @@
/*
* File: math_delim.C
* Purpose: Draw delimiters and decorations
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description: Vectorial fonts for simple and resizable objets.
*
* Dependencies: Xlib, XForms
*
* Copyright: 1996, Alejandro Aguilar Sierra
*
* Version: 0.8beta, Mathed & Lyx project.
*
* You are free to use and modify this code under the terms of
* the GNU General Public Licence version 2 or later.
*/
#include <config.h>
#include FORMS_H_LOCATION
#include <algorithm>
#include "symbol_def.h"
#include "math_inset.h"
#include "LColor.h"
#include "Painter.h"
#include "math_deliminset.h"
#include "mathed/support.h"
using std::sort;
using std::lower_bound;
using std::endl;
/*
* Internal struct of a drawing: code n x1 y1 ... xn yn, where code is:
* 0 = end, 1 = line, 2 = polyline, 3 = square line, 4= square polyline
*/
//inline
//int odd(int x) { return ((x) & 1); }
//typedef float matriz_data[2][2];
//const matriz_data MATIDEN= { {1, 0}, {0, 1}};
//extern int mathed_char_width(short type, int style, byte c);
//extern int mathed_char_height(short, int, byte, int &, int &);
//#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
// If we had exceptions we could return a reference in stead and not
// have to check for a null pointer in mathed_draw_deco

View File

@ -12,31 +12,32 @@ using std::ostream;
MathDelimInset::MathDelimInset(int l, int r, short st)
: MathParInset(st, "", LM_OT_DELIM), left(l), right(r) {}
: MathParInset(st, "", LM_OT_DELIM), left_(l), right_(r) {}
MathedInset * MathDelimInset::Clone()
{
MathDelimInset * p = new MathDelimInset(left, right, GetStyle());
MathDelimInset * p = new MathDelimInset(left_, right_, GetStyle());
MathedIter it(array);
p->SetData(it.Copy());
p->setData(it.Copy());
return p;
}
void MathDelimInset::Write(ostream & os, bool fragile)
{
latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
latexkeys const * l = (left_ != '|') ?
lm_get_key_by_id(left_, LM_TK_SYM) : 0;
latexkeys const * r = (right_ != '|') ?
lm_get_key_by_id(right_, LM_TK_SYM) : 0;
os << "\\left";
if (l) {
os << '\\' << l->name << ' ';
} else {
if (left == '{' || left == '}') {
os << '\\' << char(left) << ' ';
if (left_ == '{' || left_ == '}') {
os << '\\' << char(left_) << ' ';
} else {
os << char(left) << ' ';
os << char(left_) << ' ';
}
}
MathParInset::Write(os, fragile);
@ -44,36 +45,35 @@ void MathDelimInset::Write(ostream & os, bool fragile)
if (r) {
os << '\\' << r->name << ' ';
} else {
if (right == '{' || right == '}') {
os << '\\' << char(right) << ' ';
if (right_ == '{' || right_ == '}') {
os << '\\' << char(right_) << ' ';
} else {
os << char(right) << ' ';
os << char(right_) << ' ';
}
}
}
void
MathDelimInset::draw(Painter & pain, int x, int y)
{
xo(x);
yo(y);
MathParInset::draw(pain, x + dw + 2, y - dh);
MathParInset::draw(pain, x + dw_ + 2, y - dh_);
if (left == '.') {
if (left_ == '.') {
pain.line(x + 4, yo() - ascent,
x + 4, yo() + descent,
LColor::mathcursor, Painter::line_onoffdash);
} else
mathed_draw_deco(pain, x, y - ascent, dw, Height(), left);
x += Width() - dw - 2;
if (right == '.') {
mathed_draw_deco(pain, x, y - ascent, dw_, Height(), left_);
x += Width() - dw_ - 2;
if (right_ == '.') {
pain.line(x + 4, yo() - ascent,
x + 4, yo() + descent,
LColor::mathcursor, Painter::line_onoffdash);
} else
mathed_draw_deco(pain, x, y - ascent, dw, Height(), right);
mathed_draw_deco(pain, x, y - ascent, dw_, Height(), right_);
}
@ -83,12 +83,12 @@ MathDelimInset::Metrics()
MathParInset::Metrics();
int d;
mathed_char_height(LM_TC_CONST, size(), 'I', d, dh);
dh /= 2;
ascent += 2 + dh;
descent += 2 - dh;
dw = Height()/5;
if (dw > 15) dw = 15;
if (dw < 6) dw = 6;
width += 2 * dw + 4;
mathed_char_height(LM_TC_CONST, size(), 'I', d, dh_);
dh_ /= 2;
ascent += 2 + dh_;
descent += 2 - dh_;
dw_ = Height()/5;
if (dw_ > 15) dw_ = 15;
if (dw_ < 6) dw_ = 6;
width += 2 * dw_ + 4;
}

View File

@ -4,8 +4,10 @@
#include "math_parinset.h"
/// A delimiter
class MathDelimInset: public MathParInset {
/** A delimiter
\author Alejandro Aguilar Sierra
*/
class MathDelimInset : public MathParInset {
public:
///
MathDelimInset(int, int, short st = LM_ST_TEXT);
@ -17,14 +19,14 @@ public:
void Write(std::ostream &, bool fragile);
///
void Metrics();
protected:
private:
///
int left;
int left_;
///
int right;
int right_;
///
int dw;
int dw_;
///
int dh;
int dh_;
};
#endif

View File

@ -8,22 +8,22 @@ using std::ostream;
MathDotsInset::MathDotsInset(string const & nam, int id, short st)
: MathedInset(nam, LM_OT_DOTS, st), code(id) {}
: MathedInset(nam, LM_OT_DOTS, st), code_(id) {}
MathedInset * MathDotsInset::Clone()
{
return new MathDotsInset(name, code, GetStyle());
return new MathDotsInset(name, code_, GetStyle());
}
void
MathDotsInset::draw(Painter & pain, int x, int y)
{
mathed_draw_deco(pain, x + 2, y - dh, width - 2, ascent, code);
if (code == LM_vdots || code == LM_ddots) ++x;
if (code != LM_vdots) --y;
mathed_draw_deco(pain, x + 2, y - dh, width - 2, ascent, code);
mathed_draw_deco(pain, x + 2, y - dh_, width - 2, ascent, code_);
if (code_ == LM_vdots || code_ == LM_ddots) ++x;
if (code_ != LM_vdots) --y;
mathed_draw_deco(pain, x + 2, y - dh_, width - 2, ascent, code_);
}
@ -32,11 +32,11 @@ MathDotsInset::Metrics()
{
mathed_char_height(LM_TC_VAR, size(), 'M', ascent, descent);
width = mathed_char_width(LM_TC_VAR, size(), 'M');
switch (code) {
case LM_ldots: dh = 0; break;
case LM_cdots: dh = ascent/2; break;
switch (code_) {
case LM_ldots: dh_ = 0; break;
case LM_cdots: dh_ = ascent/2; break;
case LM_vdots: width /= 2;
case LM_ddots: dh = ascent; break;
case LM_ddots: dh_ = ascent; break;
}
}

View File

@ -4,7 +4,7 @@
#include "math_inset.h"
#include "math_defs.h"
///
/// The different kinds of ellipsis
class MathDotsInset: public MathedInset {
public:
///
@ -19,6 +19,8 @@ public:
void Metrics();
protected:
///
int dh, code;
int dh_;
///
int code_;
};
#endif

View File

@ -14,9 +14,9 @@ MathFracInset::MathFracInset(short ot)
: MathParInset(LM_ST_TEXT, "frac", ot)
{
den = new MathParInset(LM_ST_TEXT); // this leaks
dh = 0;
idx = 0;
den_ = new MathParInset(LM_ST_TEXT); // this leaks
dh_ = 0;
idx_ = 0;
if (objtype == LM_OT_STACKREL) {
flag |= LMPF_SCRIPT;
SetName("stackrel");
@ -26,7 +26,7 @@ MathFracInset::MathFracInset(short ot)
MathFracInset::~MathFracInset()
{
delete den;
delete den_;
}
@ -34,10 +34,10 @@ MathedInset * MathFracInset::Clone()
{
MathFracInset * p = new MathFracInset(GetType());
MathedIter itn(array);
MathedIter itd(den->GetData());
MathedIter itd(den_->GetData());
p->SetData(itn.Copy(), itd.Copy());
p->idx = idx;
p->dh = dh;
p->idx_ = idx_;
p->dh_ = dh_;
return p;
}
@ -45,7 +45,7 @@ MathedInset * MathFracInset::Clone()
bool MathFracInset::setArgumentIdx(int i)
{
if (i == 0 || i == 1) {
idx = i;
idx_ = i;
return true;
} else
return false;
@ -55,8 +55,8 @@ bool MathFracInset::setArgumentIdx(int i)
void MathFracInset::SetStyle(short st)
{
MathParInset::SetStyle(st);
dh = 0;
den->SetStyle((size() == LM_ST_DISPLAY) ?
dh_ = 0;
den_->SetStyle((size() == LM_ST_DISPLAY) ?
static_cast<short>(LM_ST_TEXT)
: size());
}
@ -64,42 +64,42 @@ void MathFracInset::SetStyle(short st)
void MathFracInset::SetData(MathedArray * n, MathedArray * d)
{
den->SetData(d);
MathParInset::SetData(n);
den_->setData(d);
MathParInset::setData(n);
}
void MathFracInset::SetData(MathedArray * d)
void MathFracInset::setData(MathedArray * d)
{
if (idx == 0)
MathParInset::SetData(d);
if (idx_ == 0)
MathParInset::setData(d);
else {
den->SetData(d);
den_->setData(d);
}
}
void MathFracInset::GetXY(int & x, int & y) const
{
if (idx == 0)
if (idx_ == 0)
MathParInset::GetXY(x, y);
else
den->GetXY(x, y);
den_->GetXY(x, y);
}
MathedArray * MathFracInset::GetData()
{
if (idx == 0)
if (idx_ == 0)
return array;
else
return den->GetData();
return den_->GetData();
}
bool MathFracInset::Inside(int x, int y)
{
int xx = xo() - (width - w0) / 2;
int xx = xo() - (width - w0_) / 2;
return x >= xx
&& x <= xx + width
@ -110,50 +110,52 @@ bool MathFracInset::Inside(int x, int y)
void MathFracInset::SetFocus(int /*x*/, int y)
{
// lyxerr << "y " << y << " " << yo << " " << den->yo << " ";
idx = (y > yo()) ? 1: 0;
// lyxerr << "y " << y << " " << yo << " " << den_->yo << " ";
idx_ = (y > yo()) ? 1 : 0;
}
void
MathFracInset::draw(Painter & pain, int x, int y)
{
short idxp = idx;
short sizex = size();
int const idxp = idx_;
int const sizex = size();
idx = 0;
idx_ = 0;
if (size() == LM_ST_DISPLAY) incSize();
MathParInset::draw(pain, x + (width - w0) / 2, y - des0);
den->draw(pain, x + (width - w1) / 2, y + den->Ascent() + 2 - dh);
MathParInset::draw(pain, x + (width - w0_) / 2, y - des0_);
den_->draw(pain, x + (width - w1_) / 2, y + den_->Ascent() + 2 - dh_);
size(sizex);
if (objtype == LM_OT_FRAC)
pain.line(x + 2, y - dh, x + width - 4, y - dh, LColor::mathline);
idx = idxp;
pain.line(x + 2, y - dh_,
x + width - 4, y - dh_, LColor::mathline);
idx_ = idxp;
}
void
MathFracInset::Metrics()
{
if (!dh) {
int a, b;
dh = mathed_char_height(LM_TC_CONST, size(), 'I', a, b) / 2;
if (!dh_) {
int a;
int b;
dh_ = mathed_char_height(LM_TC_CONST, size(), 'I', a, b) / 2;
}
short idxp = idx;
short sizex = size();
idx = 0;
int const idxp = idx_;
int const sizex = size();
idx_ = 0;
if (size() == LM_ST_DISPLAY) incSize();
MathParInset::Metrics();
size(sizex);
w0 = width;
int as = Height() + 2 + dh;
des0 = Descent() + 2 + dh;
den->Metrics();
w1 = den->Width();
width = ((w0 > w1) ? w0: w1) + 12;
w0_ = width;
int const as = Height() + 2 + dh_;
des0_ = Descent() + 2 + dh_;
den_->Metrics();
w1_ = den_->Width();
width = ((w0_ > w1_) ? w0_: w1_) + 12;
ascent = as;
descent = den->Height()+ 2 - dh;
idx = idxp;
descent = den_->Height()+ 2 - dh_;
idx_ = idxp;
}
@ -162,6 +164,6 @@ void MathFracInset::Write(ostream & os, bool fragile)
os << '\\' << name << '{';
MathParInset::Write(os, fragile);
os << "}{";
den->Write(os, fragile);
den_->Write(os, fragile);
os << '}';
}

View File

@ -1,9 +1,12 @@
// -*- C++ -*-
#ifndef MATH_FRACINSET_H
#define MATH_FRACINSET_H
#include "math_parinset.h"
/// Fraction like objects (frac, stackrel, binom)
/** Fraction like objects (frac, stackrel, binom)
\author Alejandro Aguilar Sierra
*/
class MathFracInset: public MathParInset {
public:
///
@ -24,7 +27,7 @@ public:
*/
void SetData(MathedArray *, MathedArray *);
///
void SetData(MathedArray *);
void setData(MathedArray *);
///
void GetXY(int & x, int & y) const;
///
@ -36,17 +39,37 @@ public:
///
bool setArgumentIdx(int i); // was bool Up/down(void);
///
int getArgumentIdx() const { return idx; }
int getArgumentIdx() const;
///
int getMaxArgumentIdx() const { return 1; }
int getMaxArgumentIdx() const;
///
void SetStyle(short);
protected:
private:
///
int idx;
int idx_;
///
MathParInset * den;
MathParInset * den_;
///
int w0, w1, des0, dh;
int w0_;
///
int w1_;
///
int des0_;
///
int dh_;
};
inline
int MathFracInset::getArgumentIdx() const
{
return idx_;
}
inline
int MathFracInset::getMaxArgumentIdx() const
{
return 1;
}
#endif

View File

@ -2,10 +2,9 @@
/* Command-line: gperf -a -p -o -t -G -D keywords */
#include <config.h>
#include <cstring>
#include "math_defs.h"
#include "math_parser.h"
#include "support/lstrings.h"
int const TOTAL_KEYWORDS = 269;
int const MIN_WORD_LENGTH = 2;
@ -38,8 +37,9 @@ math_hash (register char const * str, register int len)
return len + asso_values[str[len - 1]] + asso_values[str[0]];
}
static
latexkeys wordlist[] =
latexkeys const wordlist[] =
{
{"",0,0}, {"",0,0}, {"",0,0}, {"",0,0},
{"",0,0}, {"",0,0}, {"",0,0}, {"",0,0},
@ -355,7 +355,7 @@ static short lookup[] =
};
latexkeys *
latexkeys const *
in_word_set (register char const * str, register int len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) {
@ -367,17 +367,19 @@ in_word_set (register char const * str, register int len)
if (idx >= 0 && idx < MAX_HASH_VALUE) {
char const * s = wordlist[idx].name;
if (*s == *str && !strcmp (str + 1, s + 1))
if (*s == *str && !compare(str + 1, s + 1))
return &wordlist[idx];
} else if (idx < 0 && idx >= -MAX_HASH_VALUE) {
return 0;
} else {
int const offset = key + idx + (idx > 0 ? -MAX_HASH_VALUE : MAX_HASH_VALUE);
latexkeys * base = &wordlist[-lookup[offset]];
latexkeys * ptr = base + -lookup[offset + 1];
latexkeys const * base = &wordlist[-lookup[offset]];
latexkeys const * ptr = base + -lookup[offset + 1];
while (--ptr >= base)
if (*str == *ptr->name && !strcmp (str + 1, ptr->name + 1))
if (*str == *ptr->name
&& !compare(str + 1,
ptr->name + 1))
return ptr;
}
}
@ -386,16 +388,16 @@ in_word_set (register char const * str, register int len)
}
latexkeys * in_word_set(string const & str)
latexkeys const * in_word_set(string const & str)
{
return in_word_set(str.c_str(), str.length());
}
latexkeys * lm_get_key_by_id(int t, short tk)
latexkeys const * lm_get_key_by_id(int t, short tk)
{
latexkeys * l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS];
latexkeys * base = &wordlist[MIN_HASH_VALUE];
latexkeys const * l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS];
latexkeys const * base = &wordlist[MIN_HASH_VALUE];
while (--l >= base) {
if (t == l->id && tk == l->token)
return l;
@ -404,7 +406,7 @@ latexkeys * lm_get_key_by_id(int t, short tk)
}
latexkeys * lm_get_key_by_index(int i)
latexkeys const * lm_get_key_by_index(int i)
{
if (i > 0 && i < TOTAL_KEYWORDS + 2)
return &wordlist[i];

View File

@ -173,7 +173,7 @@ void MathMacro::SetFocus(int x, int y)
}
void MathMacro::SetData(MathedArray * a)
void MathMacro::setData(MathedArray * a)
{
args_[idx_].array = a;
}

View File

@ -27,7 +27,10 @@
class MathMacroTemplate;
/// This class contains the data for a macro
/** This class contains the data for a macro
\author Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
\version November 1996
*/
class MathMacro : public MathParInset
{
public:
@ -64,7 +67,7 @@ public:
///
MathedRowSt * getRowSt() const;
///
void SetData(MathedArray *);
void setData(MathedArray *);
///
MathedTextCodes getTCode() const;
///

View File

@ -4,7 +4,9 @@
#include "math_parinset.h"
/// An argument
/** A macro argument
\author Alejandro Aguilar Sierra
*/
class MathMacroArgument: public MathParInset {
public:
///

View File

@ -63,7 +63,7 @@ void MathMacroTable::builtinMacros()
MathedArray * array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(new MathAccentInset(LM_in, LM_TC_BOPS, LM_not)); // this leaks
m->SetData(array);
m->setData(array);
// These two are only while we are still with LyX 2.x
m = new MathMacroTemplate("emptyset"); // this leaks
@ -71,20 +71,20 @@ void MathMacroTable::builtinMacros()
array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(new MathAccentInset('O', LM_TC_RM, LM_not)); // this leaks
m->SetData(array);
m->setData(array);
m = new MathMacroTemplate("perp"); // this leaks
addTemplate(m);
array = new MathedArray; // this leaks
iter.SetData(array);
iter.Insert(LM_bot, LM_TC_BOP);
m->SetData(array);
m->setData(array);
// binom has two arguments
m = new MathMacroTemplate("binom", 2);
addTemplate(m);
array = new MathedArray;
m->SetData(array);
m->setData(array);
iter.SetData(array);
inset = new MathDelimInset('(', ')');
iter.Insert(inset, LM_TC_ACTIVE_INSET);
@ -92,7 +92,7 @@ void MathMacroTable::builtinMacros()
iter.SetData(array);
MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
iter.Insert(frac, LM_TC_ACTIVE_INSET);
inset->SetData(array);
inset->setData(array);
array = new MathedArray;
array2 = new MathedArray;
iter.SetData(array);

View File

@ -48,7 +48,7 @@ MathMacroTemplate::~MathMacroTemplate()
{
// prevent to delete already deleted objects
for (int i = 0; i < nargs_; ++i) {
args_[i].SetData(0);
args_[i].setData(0);
}
}
@ -125,7 +125,7 @@ void MathMacroTemplate::update(MathMacro * macro)
for (int i = 0; i < nargs_; ++i) {
if (macro) {
macro->setArgumentIdx(i);
args_[i].SetData(macro->GetData());
args_[i].setData(macro->GetData());
MathedRowSt * row = macro->getRowSt();
args_[i].setRowSt(row);
}
@ -154,7 +154,7 @@ void MathMacroTemplate::WriteDef(ostream & os, bool fragile)
void MathMacroTemplate::setArgument(MathedArray * a, int i)
{
args_[i].SetData(a);
args_[i].setData(a);
}

View File

@ -9,7 +9,9 @@
class MathMacro;
/// This class contains the macro definition
/** This class contains the macro definition
\author Alejandro Aguilar Sierra
*/
class MathMacroTemplate : public MathParInset {
public:
/// A template constructor needs all the data

View File

@ -10,244 +10,254 @@ using std::ostream;
extern int number_of_newlines;
MathMatrixInset::MathMatrixInset(int m, int n, short st)
: MathParInset(st, "array", LM_OT_MATRIX), nc(m), nr(0), ws_(m),
v_align(0), h_align(nc, 'c')
: MathParInset(st, "array", LM_OT_MATRIX), nc_(m), nr_(0), ws_(m),
v_align_(0), h_align_(nc_, 'c'), row_(0)
{
row = 0;
flag = 15;
if (n > 0) {
row = new MathedRowSt(nc+1);
MathedXIter it(this);
for (int j = 1; j < n; ++j) it.addRow();
nr = n;
if (nr == 1 && nc > 1) {
for (int j = 0; j < nc - 1; ++j)
it.Insert('T', LM_TC_TAB);
flag = 15;
if (n > 0) {
row_ = new MathedRowSt(nc_ + 1);
MathedXIter it(this);
for (int j = 1; j < n; ++j) it.addRow();
nr_ = n;
if (nr_ == 1 && nc_ > 1) {
for (int j = 0; j < nc_ - 1; ++j)
it.Insert('T', LM_TC_TAB);
}
} else if (n < 0) {
row_ = new MathedRowSt(nc_ + 1);
nr_ = 1;
}
} else if (n < 0) {
row = new MathedRowSt(nc + 1);
nr = 1;
}
}
MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
: MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType()),
nc(mt->nc), nr(0), ws_(mt->nc), v_align(mt->v_align), h_align(mt->h_align)
nc_(mt->nc_), nr_(0), ws_(mt->nc_),
v_align_(mt->v_align_), h_align_(mt->h_align_)
{
MathedIter it;
it.SetData(mt->GetData());
array = it.Copy();
if (mt->row != 0) {
MathedRowSt * r, * ro= 0, * mrow = mt->row;
//mrow = mt->row; // This must be redundant...
while (mrow) {
r = new MathedRowSt(nc + 1);
r->setNumbered(mrow->isNumbered());
//if (mrow->label)
r->setLabel(mrow->getLabel());
if (!ro)
row = r;
else
ro->setNext(r);
mrow = mrow->getNext();
ro = r;
++nr;
}
} else
row = 0;
flag = mt->flag;
MathedIter it;
it.SetData(mt->GetData());
array = it.Copy();
if (mt->row_ != 0) {
MathedRowSt * ro = 0;
MathedRowSt * mrow = mt->row_;
while (mrow) {
MathedRowSt * r = new MathedRowSt(nc_ + 1);
r->setNumbered(mrow->isNumbered());
//if (mrow->label)
r->setLabel(mrow->getLabel());
if (!ro)
row_ = r;
else
ro->setNext(r);
mrow = mrow->getNext();
ro = r;
++nr_;
}
} else
row_ = 0;
flag = mt->flag;
}
MathMatrixInset::~MathMatrixInset()
{
MathedRowSt * r = row;
while (r) {
MathedRowSt * q = r->getNext();
delete r;
r = q;
}
MathedRowSt * r = row_;
while (r) {
MathedRowSt * q = r->getNext();
delete r;
r = q;
}
}
MathedInset * MathMatrixInset::Clone()
{
return new MathMatrixInset(this);
return new MathMatrixInset(this);
}
void MathMatrixInset::SetAlign(char vv, string const & hh)
{
v_align = vv;
h_align = hh.substr(0, nc); // usr just h_align = hh; perhaps
v_align_ = vv;
h_align_ = hh.substr(0, nc_); // usr just h_align = hh; perhaps
}
// Check the number of tabs and crs
void MathMatrixInset::SetData(MathedArray * a)
void MathMatrixInset::setData(MathedArray * a)
{
if (!a) return;
MathedIter it(a);
int nn = nc - 1;
nr = 1;
// count tabs per row
while (it.OK()) {
if (it.IsTab()) {
if (nn < 0) {
it.Delete();
continue;
} else {
// it.Next();
--nn;
}
if (!a) return;
MathedIter it(a);
int nn = nc_ - 1;
nr_ = 1;
// count tabs per row
while (it.OK()) {
if (it.IsTab()) {
if (nn < 0) {
it.Delete();
continue;
} else {
// it.Next();
--nn;
}
}
if (it.IsCR()) {
while (nn > 0) {
it.Insert(' ', LM_TC_TAB);
--nn;
}
nn = nc_ - 1;
++nr_;
}
it.Next();
}
if (it.IsCR()) {
while (nn > 0) {
it.Insert(' ', LM_TC_TAB);
--nn;
}
nn = nc - 1;
++nr;
}
it.Next();
}
it.Reset();
it.Reset();
// Automatically inserts tabs around bops
// DISABLED because it's very easy to insert tabs
array = a;
// Automatically inserts tabs around bops
// DISABLED because it's very easy to insert tabs
array = a;
}
void MathMatrixInset::draw(Painter & pain, int x, int baseline)
{
MathParInset::draw(pain, x, baseline);
MathParInset::draw(pain, x, baseline);
}
void MathMatrixInset::Metrics()
{
int i, hl, h = 0;
MathedRowSt * cprow= 0;
if (!row) {
// lyxerr << " MIDA ";
MathedXIter it(this);
row = it.adjustVerticalSt();
}
// Clean the arrays
MathedRowSt * cxrow = row;
while (cxrow) {
for (i = 0; i <= nc; ++i) cxrow->setTab(i, 0);
cxrow = cxrow->getNext();
}
// Basic metrics
MathParInset::Metrics();
if (nc <= 1 && !row->getNext()) {
row->ascent(ascent);
row->descent(descent);
}
// Vertical positions of each row
cxrow = row;
while (cxrow) {
for (i = 0; i < nc; ++i) {
if (cxrow == row || ws_[i] < cxrow->getTab(i))
ws_[i] = cxrow->getTab(i);
if (cxrow->getNext() == 0 && ws_[i] == 0) ws_[i] = df_width;
if (!row_) {
// lyxerr << " MIDA ";
MathedXIter it(this);
row_ = it.adjustVerticalSt();
}
cxrow->setBaseline((cxrow == row) ?
cxrow->ascent() :
cxrow->ascent() + cprow->descent()
+ MATH_ROWSEP + cprow->getBaseline());
h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP;
cprow = cxrow;
cxrow = cxrow->getNext();
}
hl = Descent();
h -= MATH_ROWSEP;
// Compute vertical align
switch (v_align) {
case 't': ascent = row->getBaseline(); break;
case 'b': ascent = h - hl; break;
default: ascent = (row->getNext()) ? h / 2: h - hl; break;
}
descent = h - ascent + 2;
// Increase ws_[i] for 'R' columns (except the first one)
for (i = 1; i < nc; ++i)
if (h_align[i] == 'R')
ws_[i] += 10*df_width;
// Increase ws_[i] for 'C' column
if (h_align[0] == 'C')
if (ws_[0] < 7*workWidth/8)
ws_[0] = 7*workWidth/8;
// Adjust local tabs
cxrow = row;
width = MATH_COLSEP;
while (cxrow) {
int rg = MATH_COLSEP, ww, lf = 0; //, * w = cxrow->w;
for (i = 0; i < nc; ++i) {
bool isvoid = false;
if (cxrow->getTab(i) <= 0) {
cxrow->setTab(i, df_width);
isvoid = true;
}
switch (h_align[i]) {
case 'l':
lf = 0;
break;
case 'c':
lf = (ws_[i] - cxrow->getTab(i))/2;
break;
case 'r':
case 'R':
lf = ws_[i] - cxrow->getTab(i);
break;
case 'C':
if (cxrow == row)
lf = 0;
else if (!cxrow->getNext())
lf = ws_[i] - cxrow->getTab(i);
else
lf = (ws_[i] - cxrow->getTab(i))/2;
break;
}
ww = (isvoid) ? lf : lf + cxrow->getTab(i);
cxrow->setTab(i, lf + rg);
rg = ws_[i] - ww + MATH_COLSEP;
if (cxrow == row) width += ws_[i] + MATH_COLSEP;
// Clean the arrays
MathedRowSt * cxrow = row_;
while (cxrow) {
for (int i = 0; i <= nc_; ++i)
cxrow->setTab(i, 0);
cxrow = cxrow->getNext();
}
// Basic metrics
MathParInset::Metrics();
if (nc_ <= 1 && !row_->getNext()) {
row_->ascent(ascent);
row_->descent(descent);
}
// Vertical positions of each row
cxrow = row_;
MathedRowSt * cprow = 0;
int h = 0;
while (cxrow) {
for (int i = 0; i < nc_; ++i) {
if (cxrow == row_ || ws_[i] < cxrow->getTab(i))
ws_[i] = cxrow->getTab(i);
if (cxrow->getNext() == 0 && ws_[i] == 0)
ws_[i] = df_width;
}
cxrow->setBaseline((cxrow == row_) ?
cxrow->ascent() :
cxrow->ascent() + cprow->descent()
+ MATH_ROWSEP + cprow->getBaseline());
h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP;
cprow = cxrow;
cxrow = cxrow->getNext();
}
int hl = Descent();
h -= MATH_ROWSEP;
// Compute vertical align
switch (v_align_) {
case 't':
ascent = row_->getBaseline();
break;
case 'b':
ascent = h - hl;
break;
default:
ascent = (row_->getNext()) ? h / 2 : h - hl;
break;
}
descent = h - ascent + 2;
// Increase ws_[i] for 'R' columns (except the first one)
for (int i = 1; i < nc_; ++i)
if (h_align_[i] == 'R')
ws_[i] += 10 * df_width;
// Increase ws_[i] for 'C' column
if (h_align_[0] == 'C')
if (ws_[0] < 7 * workWidth / 8)
ws_[0] = 7 * workWidth / 8;
// Adjust local tabs
cxrow = row_;
width = MATH_COLSEP;
while (cxrow) {
int rg = MATH_COLSEP;
int lf = 0;
for (int i = 0; i < nc_; ++i) {
bool isvoid = false;
if (cxrow->getTab(i) <= 0) {
cxrow->setTab(i, df_width);
isvoid = true;
}
switch (h_align_[i]) {
case 'l':
lf = 0;
break;
case 'c':
lf = (ws_[i] - cxrow->getTab(i))/2;
break;
case 'r':
case 'R':
lf = ws_[i] - cxrow->getTab(i);
break;
case 'C':
if (cxrow == row_)
lf = 0;
else if (!cxrow->getNext())
lf = ws_[i] - cxrow->getTab(i);
else
lf = (ws_[i] - cxrow->getTab(i))/2;
break;
}
int ww = (isvoid) ? lf : lf + cxrow->getTab(i);
cxrow->setTab(i, lf + rg);
rg = ws_[i] - ww + MATH_COLSEP;
if (cxrow == row_)
width += ws_[i] + MATH_COLSEP;
}
cxrow->setBaseline(cxrow->getBaseline() - ascent);
cxrow = cxrow->getNext();
}
cxrow->setBaseline(cxrow->getBaseline() - ascent);
cxrow = cxrow->getNext();
}
}
void MathMatrixInset::Write(ostream & os, bool fragile)
{
if (GetType() == LM_OT_MATRIX){
if (GetType() == LM_OT_MATRIX) {
if (fragile)
os << "\\protect";
os << "\\begin{"
<< name
<< '}';
if (v_align == 't' || v_align == 'b') {
if (v_align_ == 't' || v_align_ == 'b') {
os << '['
<< char(v_align)
<< char(v_align_)
<< ']';
}
os << '{'
<< h_align
<< h_align_
<< "}\n";
++number_of_newlines;
}

View File

@ -9,55 +9,89 @@
/** Multiline math paragraph base class.
This is the base to all multiline editable math objects
like array and eqnarray.
*/
class MathMatrixInset: public MathParInset {
public:
///
explicit
MathMatrixInset(int m = 1, int n = 1, short st = LM_ST_TEXT);
///
explicit
MathMatrixInset(MathMatrixInset *);
///
MathedInset * Clone();
///
virtual ~MathMatrixInset();
///
void draw(Painter &, int, int);
///
void Write(std::ostream &, bool fragile);
///
void Metrics();
///
void SetData(MathedArray *);
///
void SetAlign(char, string const &);
///
int GetColumns() const { return nc; }
///
int GetRows() const { return nr; }
///
virtual bool isMatrix() const { return true; }
\author Alejandro Aguilar Sierra
*/
class MathMatrixInset : public MathParInset {
public:
///
explicit
MathMatrixInset(int m = 1, int n = 1, short st = LM_ST_TEXT);
///
explicit
MathMatrixInset(MathMatrixInset *);
///
MathedInset * Clone();
///
virtual ~MathMatrixInset();
///
void draw(Painter &, int, int);
///
void Write(std::ostream &, bool fragile);
///
void Metrics();
///
void setData(MathedArray *);
///
void SetAlign(char, string const &);
///
int GetColumns() const;
///
int GetRows() const;
///
virtual bool isMatrix() const;
/// Use this to manage the extra information independently of paragraph
MathedRowSt * getRowSt() const { return row; }
///
void setRowSt(MathedRowSt * r) { row = r; }
protected:
/// Number of columns & rows
int nc;
///
int nr;
/// tab sizes
std::vector<int> ws_;
///
char v_align; // add approp. type
///
/// Use this to manage the extra information independently of paragraph
MathedRowSt * getRowSt() const;
///
void setRowSt(MathedRowSt * r);
private:
/// Number of columns & rows
int nc_;
///
int nr_;
/// tab sizes
std::vector<int> ws_;
///
char v_align_; // add approp. type
///
//std::vector<char> h_align;
string h_align; // a vector would perhaps be more correct
/// Vertical structure
MathedRowSt * row;
string h_align_; // a vector would perhaps be more correct
/// Vertical structure
MathedRowSt * row_;
};
inline
int MathMatrixInset::GetColumns() const
{
return nc_;
}
inline
int MathMatrixInset::GetRows() const
{
return nr_;
}
inline
bool MathMatrixInset::isMatrix() const
{
return true;
}
inline
MathedRowSt * MathMatrixInset::getRowSt() const
{
return row_;
}
inline
void MathMatrixInset::setRowSt(MathedRowSt * r)
{
row_ = r;
}
#endif

View File

@ -150,8 +150,9 @@ void button_cb(FL_OBJECT * ob, long data)
/* callbacks for form delim */
void delim_cb(FL_OBJECT *, long data)
{
int left = fd_delim->left->u_ldata, right= fd_delim->right->u_ldata;
int side = (fl_get_button(fd_delim->right)!= 0);
int left = fd_delim->left->u_ldata;
int right= fd_delim->right->u_ldata;
int side = (fl_get_button(fd_delim->right) != 0);
switch (data) {
case MM_APPLY:

View File

@ -66,7 +66,6 @@ enum SomeMathValues {
};
///
/// Class to manage bitmap menu bars
class BitmapMenu {
///
@ -78,7 +77,9 @@ class BitmapMenu {
///
typedef bitmaps_type::size_type size_type;
///
BitmapMenu * next, * prev;
BitmapMenu * next;
///
BitmapMenu * prev;
/// Current bitmap
size_type current_;
/// Border width

View File

@ -42,7 +42,7 @@ MathParInset::MathParInset(MathParInset * p)
flag = p->flag;
p->setArgumentIdx(0);
MathedIter it(p->GetData());
SetData(it.Copy());
setData(it.Copy());
}
@ -62,7 +62,7 @@ MathedInset * MathParInset::Clone()
}
void MathParInset::SetData(MathedArray * a)
void MathParInset::setData(MathedArray * a)
{
array = a;
@ -286,7 +286,7 @@ void MathParInset::Write(ostream & os, bool fragile)
{
if (!array) return;
int brace = 0;
latexkeys * l;
latexkeys const * l;
MathedIter data(array);
// hack
MathedRowSt const * crow = getRowSt();

View File

@ -5,11 +5,13 @@
#include "math_inset.h"
#include "math_defs.h"
struct MathedRowSt;
class MathedRowSt;
class MathedArray;
/** The math paragraph base class, base to all editable math objects */
/** The math paragraph base class, base to all editable math objects
\author Alejandro Aguilar Sierra
*/
class MathParInset: public MathedInset {
public:
///
@ -31,7 +33,7 @@ public:
///
virtual void UserSetSize(short);
/// Data is stored in a LyXArray
virtual void SetData(MathedArray *);
virtual void setData(MathedArray *);
///
virtual MathedArray * GetData();
/// Paragraph position

View File

@ -44,6 +44,7 @@
#include "debug.h"
#include "support/lyxlib.h"
#include "mathed/support.h"
#include "boost/array.hpp"
using std::istream;
using std::endl;
@ -64,6 +65,19 @@ enum {
FLAG_BRACK_END = 256 // Next ] ends the parsing process
};
///
union YYSTYPE {
///
unsigned char c;
///
char const * s;
///
int i;
///
latexkeys const * l;
};
static
YYSTYPE yylval;
@ -115,7 +129,8 @@ enum lexcode_enum {
static lexcode_enum lexcode[256];
#warning Replace with string
static char yytext[256];
//static char yytext[256];
static array<char, 256> yytext;
static int yylineno;
static istream * yyis;
static bool yy_mtextmode= false;
@ -195,7 +210,7 @@ char LexGetArg(char lf, bool accept_spaces= false)
if (c == lf) ++bcnt;
if (c == rg) --bcnt;
if ((c > ' ' || (c == ' ' && accept_spaces)) && bcnt > 0) *(p++) = c;
} while (bcnt > 0 && yyis->good() && p-yytext < 255);
} while (bcnt > 0 && yyis->good() && p - yytext.data() < 255);
*p = '\0';
return rg;
}
@ -295,7 +310,7 @@ int yylex(void)
if (lexcode[c] == LexAlpha || lexcode[c] == LexDigit) {
char * p = &yytext[0];
while ((lexcode[c] == LexAlpha || lexcode[c] == LexDigit)
&& p-yytext < 255) {
&& p - yytext.data() < 255) {
*p = c;
yyis->get(cc);
c = cc;
@ -303,16 +318,16 @@ int yylex(void)
}
*p = '\0';
if (yyis->good()) yyis->putback(c);
latexkeys * l = in_word_set (yytext, strlen(yytext));
latexkeys const * l = in_word_set (yytext.data(), strlen(yytext.data()));
if (l) {
if (l->token == LM_TK_BEGIN || l->token == LM_TK_END) {
int i;
LexGetArg('{');
// for (i = 0; i < 5 && strncmp(yytext, latex_mathenv[i],
// for (i = 0; i < 5 && compare(yytext, latex_mathenv[i],
// strlen(latex_mathenv[i])); ++i);
for (i = 0; i < latex_mathenv_num
&& strcmp(yytext, latex_mathenv[i]); ++i);
&& compare(yytext.data(), latex_mathenv[i]); ++i);
yylval.i = i;
} else
if (l->token == LM_TK_SPACE)
@ -321,7 +336,7 @@ int yylex(void)
yylval.l = l;
return l->token;
} else {
yylval.s = yytext;
yylval.s = yytext.data();
return LM_TK_UNDEF;
}
}
@ -449,12 +464,12 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
char const c = yyis->peek();
if (c == '[') {
LexGetArg('[');
na = lyx::atoi(yytext);
na = lyx::atoi(yytext.data());
}
macro = new MathMacroTemplate(name, na);
flags = FLAG_BRACE|FLAG_BRACE_LAST;
*mtx = macro;
macro->SetData(array);
macro->setData(array);
break;
}
case LM_TK_SPECIAL:
@ -545,7 +560,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
{
MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
p->SetData(ar);
p->setData(ar);
// lyxerr << "UP[" << p->GetStyle() << "]" << endl;
data.Insert (p, LM_TC_UP);
break;
@ -554,7 +569,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
{
MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
MathedArray * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
p->SetData(ar);
p->setData(ar);
data.Insert (p, LM_TC_DOWN);
break;
}
@ -666,13 +681,13 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
if (c == '[') {
rt = new MathRootInset(size);
rt->setArgumentIdx(0);
rt->SetData(mathed_parse(FLAG_BRACK_END, 0, &rt));
rt->setData(mathed_parse(FLAG_BRACK_END, 0, &rt));
rt->setArgumentIdx(1);
} else {
yyis->putback(c);
rt = new MathSqrtInset(size);
}
rt->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST, 0, &rt));
rt->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST, 0, &rt));
data.Insert(rt, LM_TC_ACTIVE_INSET);
break;
}
@ -689,7 +704,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
if (rgd == LM_TK_SYM || rgd == LM_TK_STR || rgd == LM_TK_BOP || rgd == LM_TK_SPECIAL)
rgd = (rgd == LM_TK_SYM) ? yylval.l->id: yylval.i;
MathDelimInset * dl = new MathDelimInset(lfd, rgd);
dl->SetData(a);
dl->setData(a);
data.Insert(dl, LM_TC_ACTIVE_INSET);
// lyxerr << "RL[" << lfd << " " << rgd << "]";
break;
@ -717,7 +732,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
{
MathDecorationInset * sq = new MathDecorationInset(yylval.l->id,
size);
sq->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
sq->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
data.Insert(sq, LM_TC_ACTIVE_INSET);
break;
}
@ -759,7 +774,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
else
data.Insert(p, p->getTCode());
for (int i = 0; p->setArgumentIdx(i); ++i)
p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
p->setData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
}
else {
MathedInset * q = new MathFuncInset(yylval.s, LM_OT_UNDEF);
@ -780,7 +795,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
lyxerr << "[" << yylval.i << "]" << endl;
--plevel;
if (mt) { // && (flags & FLAG_END)) {
mt->SetData(array);
mt->setData(array);
array = 0;
}
return array;
@ -792,10 +807,10 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
ar[0] = ar2[0] = '\0';
char rg = LexGetArg(0);
if (rg == ']') {
strcpy(ar2, yytext);
strcpy(ar2, yytext.data());
rg = LexGetArg('{');
}
strcpy(ar, yytext);
strcpy(ar, yytext.data());
int const nc = parse_align(ar, ar2);
MathParInset * mm = new MathMatrixInset(nc, 0);
mm->SetAlign(ar2[0], ar);
@ -827,7 +842,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
<< c << "'" << endl;
}
LexGetArg('{');
cols = strToInt(string(yytext));
cols = strToInt(string(yytext.data()));
}
mt = create_multiline(mathed_env, cols);
if (mtx) *mtx = mt;
@ -847,7 +862,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
} else {
// lyxerr << "MATHCRO[" << yytext << "]";
MathMacro * p =
MathMacroTable::mathMTable.getMacro(yytext);
MathMacroTable::mathMTable.getMacro(yytext.data());
if (p) {
data.Insert(p, p->getTCode());
p->setArgumentIdx(0);
@ -880,14 +895,14 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
if (rg != '}') {
mathPrintError("Expected '{'");
// debug info
lyxerr << "[" << yytext << "]" << endl;
lyxerr << "[" << yytext.data() << "]" << endl;
panic = true;
break;
}
if (crow) {
crow->setLabel(yytext);
crow->setLabel(yytext.data());
} else {
mathed_label = yytext;
mathed_label = yytext.data();
}
#ifdef DEBUG
lyxerr << "Label[" << mathed_label << "]" << endl;
@ -897,7 +912,7 @@ MathedArray * mathed_parse(unsigned flags = 0, MathedArray * array = 0,
default:
mathPrintError("Unrecognized token");
// debug info
lyxerr << "[" << t << " " << yytext << "]" << endl;
lyxerr << "[" << t << " " << yytext.data() << "]" << endl;
break;
}
tprev = t;

View File

@ -35,105 +35,93 @@
///
enum MathTokenEnum
{
///
LM_TK_BOP = 256,
///
LM_TK_ALPHA,
///
LM_TK_STR,
///
LM_TK_SYM,
///
LM_TK_FRAC,
///
LM_TK_SQRT,
///
LM_TK_BEGIN,
///
LM_TK_END,
///
LM_TK_NEWLINE,
///
LM_TK_UNDEF,
///
LM_TK_FONT,
///
LM_TK_LEFT,
///
LM_TK_RIGHT,
///
LM_TK_ACCENT,
///
LM_TK_WIDE,
///
LM_TK_FUNC,
///
LM_TK_FUNCLIM,
///
LM_TK_BIGSYM,
///
LM_TK_LABEL,
///
LM_TK_NONUM,
///
LM_TK_SPACE,
///
LM_TK_DOTS,
///
LM_TK_LIMIT,
///
LM_TK_STY,
///
LM_TK_PMOD,
///
LM_TK_BMOD,
///
LM_TK_MACRO,
///
LM_TK_SPECIAL,
///
LM_TK_ARGUMENT,
///
LM_TK_NEWCOMMAND,
///
LM_TK_STACK
///
LM_TK_BOP = 256,
///
LM_TK_ALPHA,
///
LM_TK_STR,
///
LM_TK_SYM,
///
LM_TK_FRAC,
///
LM_TK_SQRT,
///
LM_TK_BEGIN,
///
LM_TK_END,
///
LM_TK_NEWLINE,
///
LM_TK_UNDEF,
///
LM_TK_FONT,
///
LM_TK_LEFT,
///
LM_TK_RIGHT,
///
LM_TK_ACCENT,
///
LM_TK_WIDE,
///
LM_TK_FUNC,
///
LM_TK_FUNCLIM,
///
LM_TK_BIGSYM,
///
LM_TK_LABEL,
///
LM_TK_NONUM,
///
LM_TK_SPACE,
///
LM_TK_DOTS,
///
LM_TK_LIMIT,
///
LM_TK_STY,
///
LM_TK_PMOD,
///
LM_TK_BMOD,
///
LM_TK_MACRO,
///
LM_TK_SPECIAL,
///
LM_TK_ARGUMENT,
///
LM_TK_NEWCOMMAND,
///
LM_TK_STACK
};
///
struct latexkeys {
///
char const * name;
///
short token;
///
int id;
///
char const * name;
///
short token;
///
int id;
};
///
latexkeys *
latexkeys const *
in_word_set (register char const * str, register int len);
///
latexkeys * in_word_set(string const & str);
latexkeys const * in_word_set(string const & str);
///
latexkeys * lm_get_key(int index);
///
latexkeys * lm_get_key_by_id(int id, short tc = LM_TK_SYM);
///
union YYSTYPE {
///
unsigned char c;
///
char * s;
///
int i;
///
latexkeys * l;
};
latexkeys const * lm_get_key_by_id(int id, short tc = LM_TK_SYM);
#endif

View File

@ -28,35 +28,36 @@ using std::ostream;
MathRootInset::MathRootInset(short st)
: MathSqrtInset(st)
{
idx = 1;
uroot = new MathParInset(LM_ST_TEXT);
idx_ = 1;
uroot_ = new MathParInset(LM_ST_TEXT);
}
MathRootInset::~MathRootInset()
{
delete uroot;
delete uroot_;
}
MathedInset * MathRootInset::Clone()
{
MathRootInset * p = new MathRootInset(GetStyle());
MathedIter it(array), itr(uroot->GetData());
p->SetData(it.Copy());
MathedIter it(array);
MathedIter itr(uroot_->GetData());
p->setData(it.Copy());
p->setArgumentIdx(0);
p->SetData(itr.Copy());
p->setData(itr.Copy());
return p;
}
void MathRootInset::SetData(MathedArray * d)
void MathRootInset::setData(MathedArray * d)
{
if (idx == 1)
MathParInset::SetData(d);
if (idx_ == 1)
MathParInset::setData(d);
else {
uroot->SetData(d);
uroot_->setData(d);
}
}
@ -64,7 +65,7 @@ void MathRootInset::SetData(MathedArray * d)
bool MathRootInset::setArgumentIdx(int i)
{
if (i == 0 || i == 1) {
idx = i;
idx_ = i;
return true;
} else
return false;
@ -73,54 +74,54 @@ bool MathRootInset::setArgumentIdx(int i)
void MathRootInset::GetXY(int & x, int & y) const
{
if (idx == 1)
if (idx_ == 1)
MathParInset::GetXY(x, y);
else
uroot->GetXY(x, y);
uroot_->GetXY(x, y);
}
MathedArray * MathRootInset::GetData()
{
if (idx == 1)
if (idx_ == 1)
return array;
else
return uroot->GetData();
return uroot_->GetData();
}
bool MathRootInset::Inside(int x, int y)
{
return (uroot->Inside(x, y) || MathSqrtInset::Inside(x, y));
return (uroot_->Inside(x, y) || MathSqrtInset::Inside(x, y));
}
void MathRootInset::Metrics()
{
int idxp = idx;
int idxp = idx_;
idx = 1;
idx_ = 1;
MathSqrtInset::Metrics();
uroot->Metrics();
wroot = uroot->Width();
dh = Height()/2;
width += wroot;
uroot_->Metrics();
wroot_ = uroot_->Width();
dh_ = Height()/2;
width += wroot_;
// if (uroot->Ascent() > dh)
if (uroot->Height() > dh)
ascent += uroot->Height() - dh;
dh -= descent - uroot->Descent();
idx = idxp;
if (uroot_->Height() > dh_)
ascent += uroot_->Height() - dh_;
dh_ -= descent - uroot_->Descent();
idx_ = idxp;
}
void MathRootInset::draw(Painter & pain, int x, int y)
{
int idxp = idx;
int idxp = idx_;
idx = 1;
uroot->draw(pain, x, y - dh);
MathSqrtInset::draw(pain, x + wroot, y);
idx = idxp;
idx_ = 1;
uroot_->draw(pain, x, y - dh_);
MathSqrtInset::draw(pain, x + wroot_, y);
idx_ = idxp;
}
@ -128,20 +129,20 @@ void MathRootInset::SetStyle(short st)
{
MathSqrtInset::SetStyle(st);
uroot->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
uroot_->SetStyle((size() < LM_ST_SCRIPTSCRIPT) ? size() + 1 : size());
}
void MathRootInset::SetFocus(int x, int)
{
idx = (x > xo() + wroot) ? 1: 0;
idx_ = (x > xo() + wroot_) ? 1: 0;
}
void MathRootInset::Write(ostream & os, bool fragile)
{
os << '\\' << name << '[';
uroot->Write(os, fragile);
uroot_->Write(os, fragile);
os << "]{";
MathParInset::Write(os, fragile);
os << '}';

View File

@ -21,49 +21,68 @@
#include "math_sqrtinset.h"
#include "symbol_def.h"
#include "LString.h"
///
class MathRootInset: public MathSqrtInset {
/** The general n-th root inset.
\author Alejandro Aguilar Sierra
\version January 1999
*/
class MathRootInset : public MathSqrtInset {
public:
///
explicit
MathRootInset(short st = LM_ST_TEXT);
///
~MathRootInset();
///
MathedInset * Clone();
///
void draw(Painter &, int x, int baseline);
///
void Write(std::ostream &, bool fragile);
///
void Metrics();
///
bool Inside(int, int);
///
void SetFocus(int, int);
///
void SetData(MathedArray *);
///
void GetXY(int & x, int & y) const;
///
MathedArray * GetData();
///
bool setArgumentIdx(int i);
///
int getArgumentIdx() const { return idx; }
///
int getMaxArgumentIdx() const { return 1; }
///
void SetStyle(short);
protected:
///
int idx;
///
MathParInset * uroot;
///
int wroot, dh;
///
explicit
MathRootInset(short st = LM_ST_TEXT);
///
~MathRootInset();
///
MathedInset * Clone();
///
void draw(Painter &, int x, int baseline);
///
void Write(std::ostream &, bool fragile);
///
void Metrics();
///
bool Inside(int, int);
///
void SetFocus(int, int);
///
void setData(MathedArray *);
///
void GetXY(int & x, int & y) const;
///
MathedArray * GetData();
///
bool setArgumentIdx(int i);
///
int getArgumentIdx() const;
///
int getMaxArgumentIdx() const;
///
void SetStyle(short);
private:
///
int idx_;
///
MathParInset * uroot_;
///
int wroot_;
///
int dh_;
};
inline
int MathRootInset::getArgumentIdx() const
{
return idx_;
}
inline
int MathRootInset::getMaxArgumentIdx() const
{
return 1;
}
#endif

View File

@ -8,8 +8,9 @@
It allows to manage the extra info independently of the paragraph data.
Only used for multiline paragraphs.
*/
struct MathedRowSt
class MathedRowSt
{
public:
///
typedef std::vector<int> Widths;
@ -20,37 +21,39 @@ struct MathedRowSt
numbered_(true), next_(0)
{}
/// Should be const but...
MathedRowSt * getNext() const { return next_; }
MathedRowSt * getNext() const;
/// ...we couldn't use this.
void setNext(MathedRowSt * n) { next_ = n; }
void setNext(MathedRowSt * n);
///
string const & getLabel() const { return label_; }
string const & getLabel() const;
///
bool isNumbered() const { return numbered_; }
bool isNumbered() const;
///
int getBaseline() const { return y_; }
int getBaseline() const;
///
void setBaseline(int b) { y_ = b; }
void setBaseline(int b);
///
int ascent() const { return asc_; }
int ascent() const;
///
int descent() const { return desc_; }
int descent() const;
///
void ascent(int a) { asc_ = a; }
void ascent(int a);
///
void descent(int d) { desc_ = d; }
void descent(int d);
///
int getTab(int i) const { return widths_[i]; }
int getTab(int i) const;
///
void setLabel(string const & l) { label_ = l; }
void setLabel(string const & l);
///
void setNumbered(bool nf) { numbered_ = nf; }
void setNumbered(bool nf);
///
void setTab(int i, int t) { widths_[i] = t; }
void setTab(int i, int t);
private:
/// Vericals
int asc_;
///
int desc_;
///
int y_;
/// widths
Widths widths_;
@ -61,4 +64,102 @@ private:
///
MathedRowSt * next_;
};
inline
MathedRowSt * MathedRowSt::getNext() const
{
return next_;
}
inline
void MathedRowSt::setNext(MathedRowSt * n)
{
next_ = n;
}
inline
string const & MathedRowSt::getLabel() const
{
return label_;
}
inline
bool MathedRowSt::isNumbered() const
{
return numbered_;
}
inline
int MathedRowSt::getBaseline() const
{
return y_;
}
inline
void MathedRowSt::setBaseline(int b)
{
y_ = b;
}
inline
int MathedRowSt::ascent() const
{
return asc_;
}
inline
int MathedRowSt::descent() const
{
return desc_;
}
inline
void MathedRowSt::ascent(int a)
{
asc_ = a;
}
inline
void MathedRowSt::descent(int d)
{
desc_ = d;
}
inline
int MathedRowSt::getTab(int i) const
{
return widths_[i];
}
inline
void MathedRowSt::setLabel(string const & l)
{
label_ = l;
}
inline
void MathedRowSt::setNumbered(bool nf)
{
numbered_ = nf;
}
inline
void MathedRowSt::setTab(int i, int t)
{
widths_[i] = t;
}
#endif

View File

@ -17,15 +17,15 @@ MathedInset * MathSqrtInset::Clone()
{
MathSqrtInset * p = new MathSqrtInset(GetStyle());
MathedIter it(array);
p->SetData(it.Copy());
p->setData(it.Copy());
return p;
}
bool MathSqrtInset::Inside(int x, int y)
{
return x >= xo() - hmax
&& x <= xo() + width - hmax
return x >= xo() - hmax_
&& x <= xo() + width - hmax_
&& y <= yo() + descent
&& y >= yo() - ascent;
}
@ -34,16 +34,17 @@ bool MathSqrtInset::Inside(int x, int y)
void
MathSqrtInset::draw(Painter & pain, int x, int y)
{
MathParInset::draw(pain, x + hmax + 2, y);
int h = ascent;
int d = descent;
int h2 = Height() / 2;
int w2 = (Height() > 4 * hmax) ? hmax : hmax / 2;
int xp[4], yp[4];
xp[0] = x + hmax + wbody; yp[0] = y - h;
xp[1] = x + hmax; yp[1] = y - h;
xp[2] = x + w2; yp[2] = y + d;
xp[3] = x; yp[3] = y + d - h2;
MathParInset::draw(pain, x + hmax_ + 2, y);
int const h = ascent;
int const d = descent;
int const h2 = Height() / 2;
int const w2 = (Height() > 4 * hmax_) ? hmax_ : hmax_ / 2;
int xp[4];
int yp[4];
xp[0] = x + hmax_ + wbody_; yp[0] = y - h;
xp[1] = x + hmax_; yp[1] = y - h;
xp[2] = x + w2; yp[2] = y + d;
xp[3] = x; yp[3] = y + d - h2;
pain.lines(xp, yp, 4, LColor::mathline);
}
@ -54,11 +55,12 @@ MathSqrtInset::Metrics()
MathParInset::Metrics();
ascent += 4;
descent += 2;
int a, b;
hmax = mathed_char_height(LM_TC_VAR, size(), 'I', a, b);
if (hmax < 10) hmax = 10;
wbody = width + 4;
width += hmax + 4;
int a;
int b;
hmax_ = mathed_char_height(LM_TC_VAR, size(), 'I', a, b);
if (hmax_ < 10) hmax_ = 10;
wbody_ = width + 4;
width += hmax_ + 4;
}

View File

@ -4,8 +4,10 @@
#include "math_parinset.h"
///
class MathSqrtInset: public MathParInset {
/** The square root inset.
\author Alejandro Aguilar Siearra
*/
class MathSqrtInset : public MathParInset {
public:
///
MathSqrtInset(short st = LM_ST_TEXT);
@ -21,6 +23,8 @@ public:
bool Inside(int, int);
private:
///
int hmax, wbody;
int hmax_;
///
int wbody_;
};
#endif

View File

@ -58,70 +58,83 @@ extern BufferView * current_view;
#include "dots.xbm"
/* Latex code for those bitmaps */
static char const * latex_greek[] = {
"Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
"Sigma", "Upsilon", "Phi", "Psi", "Omega",
"alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
"eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
"nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
"tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
static
char const * latex_greek[] = {
"Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi",
"Sigma", "Upsilon", "Phi", "Psi", "Omega",
"alpha", "beta", "gamma", "delta", "epsilon", "varepsilon", "zeta",
"eta", "theta", "vartheta", "iota", "kappa", "lambda", "mu",
"nu", "xi", "pi", "varpi", "rho", "sigma", "varsigma",
"tau", "upsilon", "phi", "varphi", "chi", "psi", "omega", ""
};
static char const * latex_brel[] = {
"leq", "geq", "equiv", "models",
"prec", "succ", "sim", "perp",
"preceq", "succeq", "simeq", "mid",
"ll", "gg", "asymp", "parallel",
"subset", "supset", "approx", "smile",
"subseteq", "supseteq", "cong", "frown",
"sqsubseteq", "sqsupseteq", "doteq", "neq",
"in", "ni", "propto", "notin",
"vdash", "dashv", "bowtie", ""
static
char const * latex_brel[] = {
"leq", "geq", "equiv", "models",
"prec", "succ", "sim", "perp",
"preceq", "succeq", "simeq", "mid",
"ll", "gg", "asymp", "parallel",
"subset", "supset", "approx", "smile",
"subseteq", "supseteq", "cong", "frown",
"sqsubseteq", "sqsupseteq", "doteq", "neq",
"in", "ni", "propto", "notin",
"vdash", "dashv", "bowtie", ""
};
static char const * latex_arrow[] = {
"downarrow", "leftarrow", "Downarrow", "Leftarrow",
"hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
"hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
"rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
"leftharpoondown", "rightharpoondown", "mapsto",
"Longleftarrow", "Longrightarrow", "Longleftrightarrow",
"longleftrightarrow", "longleftarrow", "longrightarrow", "longmapsto",
"nwarrow", "nearrow", "swarrow", "searrow", "",
static
char const * latex_arrow[] = {
"downarrow", "leftarrow", "Downarrow", "Leftarrow",
"hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
"hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
"rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
"leftharpoondown", "rightharpoondown", "mapsto",
"Longleftarrow", "Longrightarrow", "Longleftrightarrow",
"longleftrightarrow", "longleftarrow", "longrightarrow", "longmapsto",
"nwarrow", "nearrow", "swarrow", "searrow", "",
};
char const * latex_varsz[] = {
"sum", "int", "oint",
"prod", "coprod", "bigsqcup",
"bigotimes", "bigodot", "bigoplus",
"bigcap", "bigcup", "biguplus",
"bigvee", "bigwedge", ""
"sum", "int", "oint",
"prod", "coprod", "bigsqcup",
"bigotimes", "bigodot", "bigoplus",
"bigcap", "bigcup", "biguplus",
"bigvee", "bigwedge", ""
};
static char const * latex_bop[] = {
"pm", "cap", "diamond", "oplus",
"mp", "cup", "bigtriangleup", "ominus",
"times", "uplus", "bigtriangledown", "otimes",
"div", "sqcap", "triangleright", "oslash",
"cdot", "sqcup", "triangleleft", "odot",
"star", "vee", "amalg", "bigcirc",
"setminus", "wedge", "dagger", "circ",
"bullet", "wr", "ddagger", ""
static
char const * latex_bop[] = {
"pm", "cap", "diamond", "oplus",
"mp", "cup", "bigtriangleup", "ominus",
"times", "uplus", "bigtriangledown", "otimes",
"div", "sqcap", "triangleright", "oslash",
"cdot", "sqcup", "triangleleft", "odot",
"star", "vee", "amalg", "bigcirc",
"setminus", "wedge", "dagger", "circ",
"bullet", "wr", "ddagger", ""
};
static char const * latex_misc[] = {
"nabla", "partial", "infty", "prime", "ell",
"emptyset", "exists", "forall", "imath", "jmath",
"Re", "Im", "aleph", "wp", "hbar",
"angle", "top", "bot", "Vert", "neg",
"flat", "natural", "sharp", "surd", "triangle",
"diamondsuit", "heartsuit", "clubsuit", "spadesuit", ""
static
char const * latex_misc[] = {
"nabla", "partial", "infty", "prime", "ell",
"emptyset", "exists", "forall", "imath", "jmath",
"Re", "Im", "aleph", "wp", "hbar",
"angle", "top", "bot", "Vert", "neg",
"flat", "natural", "sharp", "surd", "triangle",
"diamondsuit", "heartsuit", "clubsuit", "spadesuit", ""
};
static char const * latex_dots[] = {
"ldots", "cdots", "vdots", "ddots"
static
char const * latex_dots[] = {
"ldots", "cdots", "vdots", "ddots"
};
extern char const ** mathed_get_pixmap_from_icon(int d);
extern "C" void math_cb(FL_OBJECT*, long);
static char const ** pixmapFromBitmapData(char const *, int, int);
@ -133,17 +146,17 @@ BitmapMenu * BitmapMenu::active = 0;
BitmapMenu::BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx)
: current_(0), bitmaps_(n)
{
w = h = 0;
form = 0;
ww = 2 * FL_abs(FL_BOUND_WIDTH);
x = y = ww;
y += 8;
button = bt;
button->u_vdata = this;
prev = prevx;
next = 0;
if (prev)
prev->next = this;
w = h = 0;
form = 0;
ww = 2 * FL_abs(FL_BOUND_WIDTH);
x = y = ww;
y += 8;
button = bt;
button->u_vdata = this;
prev = prevx;
next = 0;
if (prev)
prev->next = this;
}
@ -157,404 +170,424 @@ BitmapMenu::~BitmapMenu()
void BitmapMenu::Hide()
{
fl_hide_form(form);
fl_set_button(button, 0);
active = 0;
fl_hide_form(form);
fl_set_button(button, 0);
active = 0;
}
void BitmapMenu::Show()
{
if (active)
active->Hide();
active = this;
// int x = button->form->x + button->x, y = button->form->y + button->y;
// fl_set_form_position(form, x, y + button->h);
fl_set_button(button, 1);
fl_show_form(form, FL_PLACE_MOUSE, FL_NOBORDER, "");
if (active)
active->Hide();
active = this;
// int x = button->form->x + button->x, y = button->form->y + button->y;
// fl_set_form_position(form, x, y + button->h);
fl_set_button(button, 1);
fl_show_form(form, FL_PLACE_MOUSE, FL_NOBORDER, "");
}
FL_OBJECT *
BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh,
unsigned char const * data, Bool vert)
{
if (current_ >= bitmaps_.size())
return 0;
int wx = bw+ww/2, wy = bh+ww/2;
wx += (wx % nx);
wy += (wy % ny);
FL_OBJECT * obj = fl_create_bmtable(1, x, y, wx, wy, "");
fl_set_object_callback(obj, math_cb, id);
fl_set_object_lcol(obj, FL_BLUE);
fl_set_object_boxtype(obj, FL_UP_BOX);
fl_set_bmtable_data(obj, nx, ny, bw, bh, data);
if (vert) {
y += wy + 8;
h = max(y, h);
w = max(x + wx + ww, w);
} else {
x += wx + 8;
w = max(x, w);
h = max(y + wy + ww, h);
}
bitmaps_[current_++] = obj;
return obj;
if (current_ >= bitmaps_.size())
return 0;
int wx = bw + ww / 2;
int wy = bh + ww / 2;
wx += (wx % nx);
wy += (wy % ny);
FL_OBJECT * obj = fl_create_bmtable(1, x, y, wx, wy, "");
fl_set_object_callback(obj, math_cb, id);
fl_set_object_lcol(obj, FL_BLUE);
fl_set_object_boxtype(obj, FL_UP_BOX);
fl_set_bmtable_data(obj, nx, ny, bw, bh, data);
if (vert) {
y += wy + 8;
h = max(y, h);
w = max(x + wx + ww, w);
} else {
x += wx + 8;
w = max(x, w);
h = max(y + wy + ww, h);
}
bitmaps_[current_++] = obj;
return obj;
}
void BitmapMenu::Create()
{
if (current_ < bitmaps_.size()) {
lyxerr << "Error: Bitmaps not created!" << endl;
return;
}
form = fl_bgn_form(FL_UP_BOX, w, h);
for (current_ = 0; current_ < bitmaps_.size(); ++current_) {
fl_add_object(form, bitmaps_[current_]);
bitmaps_[current_]->u_vdata = this;
}
fl_end_form();
fl_register_raw_callback(form, KeyPressMask, C_peek_event);
if (current_ < bitmaps_.size()) {
lyxerr << "Error: Bitmaps not created!" << endl;
return;
}
form = fl_bgn_form(FL_UP_BOX, w, h);
for (current_ = 0; current_ < bitmaps_.size(); ++current_) {
fl_add_object(form, bitmaps_[current_]);
bitmaps_[current_]->u_vdata = this;
}
fl_end_form();
fl_register_raw_callback(form, KeyPressMask, C_peek_event);
}
int BitmapMenu::GetIndex(FL_OBJECT* ob)
{
if (active == this) {
int k = 0;
for (current_ = 0; current_ < bitmaps_.size(); ++current_) {
if (bitmaps_[current_] == ob)
return k+fl_get_bmtable(ob);
k += fl_get_bmtable_maxitems(bitmaps_[current_]);
}
}
return -1;
if (active == this) {
int k = 0;
for (current_ = 0; current_ < bitmaps_.size(); ++current_) {
if (bitmaps_[current_] == ob)
return k+fl_get_bmtable(ob);
k += fl_get_bmtable_maxitems(bitmaps_[current_]);
}
}
return -1;
}
int peek_event(FL_FORM * /*form*/, void *xev)
{
if (BitmapMenu::active == 0)
return 0;
if (BitmapMenu::active == 0)
return 0;
if (static_cast<XEvent *>(xev)->type == ButtonPress)
{
BitmapMenu::active->Hide();
return 1;
}
if (static_cast<XEvent *>(xev)->type == KeyPress)
{
char c[5];
KeySym keysym;
XLookupString(&static_cast<XEvent *>(xev)->xkey, &c[0], 5, &keysym, 0);
if (keysym == XK_Left)
BitmapMenu::active->Prev(); else
if (keysym == XK_Right)
BitmapMenu::active->Next();
else
BitmapMenu::active->Hide();
return 1;
}
return 0;
if (static_cast<XEvent *>(xev)->type == ButtonPress) {
BitmapMenu::active->Hide();
return 1;
}
if (static_cast<XEvent *>(xev)->type == KeyPress) {
char c[5];
KeySym keysym;
XLookupString(&static_cast<XEvent *>(xev)->xkey, &c[0], 5, &keysym, 0);
if (keysym == XK_Left)
BitmapMenu::active->Prev(); else
if (keysym == XK_Right)
BitmapMenu::active->Next();
else
BitmapMenu::active->Hide();
return 1;
}
return 0;
}
// This is just a wrapper.
extern "C" int C_peek_event(FL_FORM *form, void *ptr) {
return peek_event(form, ptr);
extern "C" int C_peek_event(FL_FORM *form, void *ptr)
{
return peek_event(form, ptr);
}
extern "C" void math_cb(FL_OBJECT* ob, long data)
{
BitmapMenu * menu = static_cast<BitmapMenu*>(ob->u_vdata);
int i = menu->GetIndex(ob);
char const *s = 0;
BitmapMenu * menu = static_cast<BitmapMenu*>(ob->u_vdata);
int i = menu->GetIndex(ob);
char const *s = 0;
// lyxerr << "data[" << data << "]";
if (i<0) return;
switch (data) {
case MM_GREEK:
s = latex_greek[i];
break;
case MM_ARROW:
s = latex_arrow[i];
break;
case MM_BRELATS:
s = latex_brel[i];
break;
case MM_BOP:
s = latex_bop[i];
break;
case MM_VARSIZE:
s = latex_varsz[i];
break;
case MM_MISC:
s = latex_misc[i];
break;
case MM_DOTS:
// lyxerr << "dots[" << latex_dots[i] << " " << i << "]";
s = latex_dots[i-29];
break;
}
// lyxerr << "data[" << data << "]";
if (i<0) return;
switch (data) {
case MM_GREEK:
s = latex_greek[i];
break;
case MM_ARROW:
s = latex_arrow[i];
break;
case MM_BRELATS:
s = latex_brel[i];
break;
case MM_BOP:
s = latex_bop[i];
break;
case MM_VARSIZE:
s = latex_varsz[i];
break;
case MM_MISC:
s = latex_misc[i];
break;
case MM_DOTS:
// lyxerr << "dots[" << latex_dots[i] << " " << i << "]";
s = latex_dots[i-29];
break;
}
if (s) {
if (current_view->available() && lyxrc.display_shortcuts) {
current_view->owner()->getMiniBuffer()->Set("Inserting symbol ", s);
}
current_view->owner()->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, s);
}
if (menu)
menu->Hide();
if (s) {
if (current_view->available() && lyxrc.display_shortcuts) {
current_view->owner()->getMiniBuffer()->Set("Inserting symbol ", s);
}
current_view->owner()->getLyXFunc()->Dispatch(LFUN_INSERT_MATH, s);
}
if (menu)
menu->Hide();
}
char const ** get_pixmap_from_symbol(char const * arg, int wx, int hx)
{
char const ** data = 0;
latexkeys * l = in_word_set (arg, strlen(arg));
if (!l)
return 0;
char const ** data = 0;
latexkeys const * l = in_word_set (arg, strlen(arg));
if (!l)
return 0;
switch (l->token) {
case LM_TK_FRAC:
data = mathed_get_pixmap_from_icon(MM_FRAC);
break;
case LM_TK_SQRT:
data = mathed_get_pixmap_from_icon(MM_SQRT);
break;
case LM_TK_BIGSYM:
case LM_TK_SYM:
// I have to use directly the bitmap data since the
// bitmap tables are not yet created when this
// function is called.
data = pixmapFromBitmapData(arg, wx, hx);
break;
}
switch (l->token) {
case LM_TK_FRAC:
data = mathed_get_pixmap_from_icon(MM_FRAC);
break;
case LM_TK_SQRT:
data = mathed_get_pixmap_from_icon(MM_SQRT);
break;
case LM_TK_BIGSYM:
case LM_TK_SYM:
// I have to use directly the bitmap data since the
// bitmap tables are not yet created when this
// function is called.
data = pixmapFromBitmapData(arg, wx, hx);
break;
}
return data;
return data;
}
bool math_insert_greek(BufferView * bv, char c)
{
if (bv->available() &&
(('A' <= c && c <= 'Z') ||
('a'<= c && c<= 'z'))) {
string tmp;
tmp = c;
if (!bv->theLockingInset() || bv->theLockingInset()->IsTextInset()) {
int greek_kb_flag_save = greek_kb_flag;
InsetFormula * new_inset = new InsetFormula();
bv->beforeChange(bv->text);
if (!bv->insertInset(new_inset)) {
delete new_inset;
return false;
}
if (bv->available() &&
(('A' <= c && c <= 'Z') ||
('a'<= c && c<= 'z'))) {
string tmp;
tmp = c;
if (!bv->theLockingInset() || bv->theLockingInset()->IsTextInset()) {
int greek_kb_flag_save = greek_kb_flag;
InsetFormula * new_inset = new InsetFormula();
bv->beforeChange(bv->text);
if (!bv->insertInset(new_inset)) {
delete new_inset;
return false;
}
// Update(1);//BUG
new_inset->Edit(bv, 0, 0, 0);
new_inset->LocalDispatch(bv, LFUN_SELFINSERT, tmp);
if (greek_kb_flag_save < 2) {
bv->unlockInset(new_inset); // bv->theLockingInset());
bv->text->CursorRight(bv, true);
}
} else
if (bv->theLockingInset()->LyxCode() == Inset::MATH_CODE ||
bv->theLockingInset()->LyxCode() == Inset::MATHMACRO_CODE)
static_cast<InsetFormula*>(bv->theLockingInset())->LocalDispatch(bv, LFUN_SELFINSERT, tmp);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
return true;
}
return false;
new_inset->Edit(bv, 0, 0, 0);
new_inset->LocalDispatch(bv, LFUN_SELFINSERT, tmp);
if (greek_kb_flag_save < 2) {
bv->unlockInset(new_inset); // bv->theLockingInset());
bv->text->CursorRight(bv, true);
}
} else
if (bv->theLockingInset()->LyxCode() == Inset::MATH_CODE ||
bv->theLockingInset()->LyxCode() == Inset::MATHMACRO_CODE)
static_cast<InsetFormula*>(bv->theLockingInset())->LocalDispatch(bv, LFUN_SELFINSERT, tmp);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
return true;
}
return false;
}
void math_insert_symbol(BufferView * bv, string const & s)
{
if (bv->available()) {
if (!bv->theLockingInset() || bv->theLockingInset()->IsTextInset()) {
InsetFormula * new_inset = new InsetFormula();
bv->beforeChange(bv->text);
if (!bv->insertInset(new_inset)) {
delete new_inset;
return;
}
// Update(1);//BUG
new_inset->Edit(bv, 0, 0, 0);
new_inset->InsertSymbol(bv, s);
} else
if (bv->theLockingInset()->LyxCode() == Inset::MATH_CODE ||
bv->theLockingInset()->LyxCode() == Inset::MATHMACRO_CODE)
static_cast<InsetFormula*>(bv->theLockingInset())->InsertSymbol(bv, s);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
}
if (bv->available()) {
if (!bv->theLockingInset() || bv->theLockingInset()->IsTextInset()) {
InsetFormula * new_inset = new InsetFormula();
bv->beforeChange(bv->text);
if (!bv->insertInset(new_inset)) {
delete new_inset;
return;
}
new_inset->Edit(bv, 0, 0, 0);
new_inset->InsertSymbol(bv, s);
} else
if (bv->theLockingInset()->LyxCode() == Inset::MATH_CODE ||
bv->theLockingInset()->LyxCode() == Inset::MATHMACRO_CODE)
static_cast<InsetFormula*>(bv->theLockingInset())->InsertSymbol(bv, s);
else
lyxerr << "Math error: attempt to write on a wrong "
"class of inset." << endl;
}
}
BitmapMenu * sym_menu= 0;
BitmapMenu * sym_menu = 0;
void create_symbol_menues(FD_panel * symb_form)
void create_symbol_menues(FD_panel * symb_form)
{
FL_OBJECT * obj;
BitmapMenu * menu;
FL_OBJECT * obj;
BitmapMenu * menu;
sym_menu = menu = new BitmapMenu(2, symb_form->greek);
obj = menu->AddBitmap(MM_GREEK, 6, 2, Greek_width, Greek_height,
Greek_bits);
fl_set_bmtable_maxitems(obj, 11);
obj = menu->AddBitmap(MM_GREEK, 7, 4, greek_width, greek_height,
greek_bits);
menu->Create();
sym_menu = menu = new BitmapMenu(2, symb_form->greek);
obj = menu->AddBitmap(MM_GREEK, 6, 2, Greek_width, Greek_height,
Greek_bits);
fl_set_bmtable_maxitems(obj, 11);
obj = menu->AddBitmap(MM_GREEK, 7, 4, greek_width, greek_height,
greek_bits);
menu->Create();
menu = new BitmapMenu(1, symb_form->boperator, menu);
obj = menu->AddBitmap(MM_BOP, 4, 8, bop_width, bop_height,
bop_bits);
fl_set_bmtable_maxitems(obj, 31);
menu->Create();
menu = new BitmapMenu(1, symb_form->boperator, menu);
obj = menu->AddBitmap(MM_BOP, 4, 8, bop_width, bop_height,
bop_bits);
fl_set_bmtable_maxitems(obj, 31);
menu->Create();
menu = new BitmapMenu(1, symb_form->brelats, menu);
obj = menu->AddBitmap(MM_BRELATS, 4, 9, brel_width, brel_height,
brel_bits);
fl_set_bmtable_maxitems(obj, 35);
menu->Create();
menu = new BitmapMenu(1, symb_form->brelats, menu);
obj = menu->AddBitmap(MM_BRELATS, 4, 9, brel_width, brel_height,
brel_bits);
fl_set_bmtable_maxitems(obj, 35);
menu->Create();
menu = new BitmapMenu(3, symb_form->arrow, menu);
obj = menu->AddBitmap(MM_ARROW, 5, 4, arrow_width, arrow_height,
arrow_bits);
obj = menu->AddBitmap(MM_ARROW, 2, 4, larrow_width, larrow_height,
larrow_bits, False);
fl_set_bmtable_maxitems(obj, 7);
obj = menu->AddBitmap(MM_ARROW, 2, 2, darrow_width, darrow_height,
darrow_bits);
menu->Create();
menu = new BitmapMenu(3, symb_form->arrow, menu);
obj = menu->AddBitmap(MM_ARROW, 5, 4, arrow_width, arrow_height,
arrow_bits);
obj = menu->AddBitmap(MM_ARROW, 2, 4, larrow_width, larrow_height,
larrow_bits, False);
fl_set_bmtable_maxitems(obj, 7);
obj = menu->AddBitmap(MM_ARROW, 2, 2, darrow_width, darrow_height,
darrow_bits);
menu->Create();
menu = new BitmapMenu(1, symb_form->varsize, menu);
obj = menu->AddBitmap(MM_VARSIZE, 3, 5, varsz_width, varsz_height,
varsz_bits);
fl_set_bmtable_maxitems(obj, 14);
menu->Create();
menu = new BitmapMenu(1, symb_form->varsize, menu);
obj = menu->AddBitmap(MM_VARSIZE, 3, 5, varsz_width, varsz_height,
varsz_bits);
fl_set_bmtable_maxitems(obj, 14);
menu->Create();
menu = new BitmapMenu(2, symb_form->misc, menu);
obj = menu->AddBitmap(MM_MISC, 5, 6, misc_width, misc_height,
misc_bits);
fl_set_bmtable_maxitems(obj, 29);
obj = menu->AddBitmap(MM_DOTS, 4, 1, dots_width, dots_height,
dots_bits);
menu->Create();
menu = new BitmapMenu(2, symb_form->misc, menu);
obj = menu->AddBitmap(MM_MISC, 5, 6, misc_width, misc_height,
misc_bits);
fl_set_bmtable_maxitems(obj, 29);
obj = menu->AddBitmap(MM_DOTS, 4, 1, dots_width, dots_height,
dots_bits);
menu->Create();
}
static
char const ** pixmapFromBitmapData(char const * s, int wx, int hx)
{
int i;
char const ** data = 0;
char const ** data = 0;
int id = -1;
int id = -1;
for (i = 0; i < 6; ++i) {
char const ** latex_str = 0;
switch (i) {
case 0: latex_str = latex_greek; break;
case 1: latex_str = latex_bop; break;
case 2: latex_str = latex_brel; break;
case 3: latex_str = latex_arrow; break;
case 4: latex_str = latex_varsz; break;
case 5: latex_str = latex_misc; break;
int i = 0;
for (; i < 6; ++i) {
char const ** latex_str = 0;
switch (i) {
case 0: latex_str = latex_greek; break;
case 1: latex_str = latex_bop; break;
case 2: latex_str = latex_brel; break;
case 3: latex_str = latex_arrow; break;
case 4: latex_str = latex_varsz; break;
case 5: latex_str = latex_misc; break;
}
for (int k = 0; latex_str[k][0] > ' '; ++k) {
if (compare(latex_str[k], s) == 0) {
id = k;
break;
}
}
if (id >= 0) break;
}
if (i < 6 && id >= 0) {
unsigned char const * bdata = 0;
int w = 0;
int h = 0;
int dw = 0;
int dh = 0;
for (int k = 0; latex_str[k][0] > ' '; ++k) {
if (strcmp(latex_str[k], s) == 0) {
id = k;
break;
}
}
if (id >= 0) break;
}
if (i < 6 && id >= 0) {
unsigned char const * bdata = 0;
int w = 0, h = 0, dw = 0, dh = 0;
lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
switch (i) {
case 0:
if (id <= 10) {
w = Greek_width;
h = Greek_height;
bdata = Greek_bits;
dw = 6;
dh = 2;
} else {
w = greek_width;
h = greek_height;
bdata = greek_bits;
dw = 7;
dh = 4;
id -= 11;
}
break;
case 1:
w = bop_width;
h = bop_height;
bdata = bop_bits;
dw = 4;
dh = 8;
break;
case 2:
w = brel_width;
h = brel_height;
bdata = brel_bits;
dw = 4;
dh = 9;
break;
case 3:
if (id < 20) {
w = arrow_width;
h = arrow_height;
bdata = arrow_bits;
dw = 5;
dh = 4;
} else if (id > 28) {
w = darrow_width;
h = darrow_height;
bdata = darrow_bits;
dw = 2;
dh = 2;
id -= 29;
} else {
w = larrow_width;
h = larrow_height;
bdata = larrow_bits;
dw = 2;
dh = 4;
id -= 20;
}
break;
case 4:
w = varsz_width;
h = varsz_height;
bdata = varsz_bits;
dw = 3;
dh = 5;
break;
case 5:
w = misc_width;
h = misc_height;
bdata = misc_bits;
dw = 5;
dh = 6;
break;
}
int ww = w / dw;
int hh = h / dh;
lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
switch (i) {
case 0:
if (id<= 10) {
w = Greek_width;
h = Greek_height;
bdata = Greek_bits;
dw = 6; dh = 2;
} else {
w = greek_width;
h = greek_height;
bdata = greek_bits;
dw = 7; dh = 4;
id -= 11;
}
break;
case 1:
w = bop_width;
h = bop_height;
bdata = bop_bits;
dw = 4; dh = 8;
break;
case 2:
w = brel_width;
h = brel_height;
bdata = brel_bits;
dw = 4; dh = 9;
break;
case 3:
if (id<20) {
w = arrow_width;
h = arrow_height;
bdata = arrow_bits;
dw = 5; dh = 4;
} else if (id>28) {
w = darrow_width;
h = darrow_height;
bdata = darrow_bits;
dw = 2; dh = 2;
id -= 29;
} else {
w = larrow_width;
h = larrow_height;
bdata = larrow_bits;
dw = 2; dh = 4;
id -= 20;
}
break;
case 4:
w = varsz_width;
h = varsz_height;
bdata = varsz_bits;
dw = 3; dh = 5;
break;
case 5:
w = misc_width;
h = misc_height;
bdata = misc_bits;
dw = 5; dh = 6;
break;
}
int ww = w/dw, hh = h/dh, x, y;
XImage * xima = XCreateImage(fl_get_display(), 0, 1, XYBitmap, 0,
const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
xima->byte_order = LSBFirst;
xima->bitmap_bit_order = LSBFirst;
int x = (id % dw) * ww;
int y = (id/dw) * hh;
if (ww > wx) ww = wx;
if (hh > hx) hh = hx;
XImage * sbima = XSubImage(xima, x, y, ww, hh);
XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
XImage * xima = XCreateImage(fl_get_display(), 0, 1, XYBitmap, 0,
const_cast<char*>(reinterpret_cast<char const *>(bdata)), w, h, 8, 0);
xima->byte_order = LSBFirst;
xima->bitmap_bit_order = LSBFirst;
x = (id % dw)*ww;
y = (id/dw)*hh;
if (ww > wx) ww = wx;
if (hh > hx) hh = hx;
XImage * sbima = XSubImage(xima, x, y, ww, hh);
XpmCreateDataFromImage(fl_get_display(), const_cast<char***>(&data), sbima, sbima, 0);
// Dirty hack to get blue symbols quickly
char * sx = const_cast<char*>(strstr(data[2], "FFFFFFFF"));
if (sx) {
for (int k = 0; k < 8; ++k) sx[k] = '0';
}
// Dirty hack to get blue symbols quickly
char * sx = const_cast<char*>(strstr(data[2], "FFFFFFFF"));
if (sx) {
for (int k = 0; k < 8; ++k) sx[k] = '0';
}
// XDestroyImage(xima);
}
}
return data;
return data;
}

View File

@ -25,6 +25,8 @@ struct binary_op_pair {
short isrel;
};
static
binary_op_pair binary_op_table[] = {
{ LM_leq, LMB_RELATION }, { LM_geq, LMB_RELATION },
{ LM_equiv, LMB_RELATION }, { LM_models, LMB_RELATION },

9
src/mathed/math_utils.h Normal file
View File

@ -0,0 +1,9 @@
// -*- C++ -*-
#ifndef MATHUTILS_H
#define MATHUTILS_H
extern
int MathedLookupBOP(short id);
#endif

View File

@ -1,90 +0,0 @@
/*
* File: math_write.h
* Purpose: Write math paragraphs in LaTeX
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
* Created: January 1996
* Description:
*
* Dependencies: Xlib, XForms
*
* Copyright: 1996, 1997 Alejandro Aguilar Sierra
*
* Version: 0.8beta, Mathed & Lyx project.
*
* You are free to use and modify this code under the terms of
* the GNU General Public Licence version 2 or later.
*/
#include <config.h>
#include "LString.h"
#include "math_inset.h"
#include "math_iter.h"
#include "math_parser.h"
#include "math_parinset.h"
#include "mathed/support.h"
#include "support/lstrings.h"
#include "debug.h"
using std::ostream;
using std::endl;
extern char const * latex_mathenv[];
// quite a hack i know. Should be done with return values...
int number_of_newlines = 0;
void mathed_write(MathParInset * p, ostream & os, int * newlines,
bool fragile, string const & label)
{
number_of_newlines = 0;
short mathed_env = p->GetType();
if (mathed_env == LM_OT_MIN) {
if (fragile) os << "\\protect";
os << "\\( "; // changed from " \\( " (Albrecht Dress)
}
else {
if (mathed_env == LM_OT_PAR){
os << "\\[\n";
} else {
os << "\\begin{"
<< latex_mathenv[mathed_env]
<< "}";
if (is_multicolumn(mathed_env)) {
if (mathed_env != LM_OT_ALIGNAT
&& mathed_env != LM_OT_ALIGNATN)
os << "%";
os << "{" << p->GetColumns()/2 << "}";
}
os << "\n";
}
++number_of_newlines;
}
if (!label.empty() && label[0] > ' ' && is_singlely_numbered(mathed_env)) {
os << "\\label{"
<< label
<< "}\n";
++number_of_newlines;
}
p->Write(os, fragile);
if (mathed_env == LM_OT_MIN){
if (fragile) os << "\\protect";
os << " \\)";
}
else if (mathed_env == LM_OT_PAR) {
os << "\\]\n";
++number_of_newlines;
}
else {
os << "\n\\end{"
<< latex_mathenv[mathed_env]
<< "}\n";
number_of_newlines += 2;
}
*newlines = number_of_newlines;
}

View File

@ -214,7 +214,7 @@ void MathedXIter::SetData(MathParInset * pp)
}
if (!array) {
array = new MathedArray; // this leaks
p->SetData(array);
p->setData(array);
}
size = p->GetStyle();
Reset();

View File

@ -4,7 +4,7 @@
#include "math_iter.h"
struct MathedRowSt;
class MathedRowSt;
class MathParInset;
/**

View File

@ -4,8 +4,13 @@
#include "matriz.h"
static inline
int odd(int x) { return ((x) & 1); }
int odd(int x)
{
return (x & 1);
}
#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
@ -25,8 +30,10 @@ void Matriz::rota(int code)
mateq(r, MATIDEN);
float const cs = (odd(code)) ? 0 : (1 - code);
float const sn = (odd(code)) ? (2 - code) : 0;
r[0][0] = cs; r[0][1] = sn;
r[1][0] = -r[0][1]; r[1][1] = r[0][0];
r[0][0] = cs;
r[0][1] = sn;
r[1][0] = -r[0][1];
r[1][1] = r[0][0];
matmat(r);
}
@ -35,7 +42,8 @@ void Matriz::escala(float x, float y)
{
matriz_data s;
mateq(s, MATIDEN);
s[0][0] = x; s[1][1] = y;
s[0][0] = x;
s[1][1] = y;
matmat(s);
}
@ -43,10 +51,10 @@ void Matriz::escala(float x, float y)
void Matriz::matmat(matriz_data & a)
{
matriz_data c;
for (int i = 0; i < 2; ++i) {
c[0][i] = a[0][0] * m_[0][i] + a[0][1] * m_[1][i];
c[1][i] = a[1][0] * m_[0][i] + a[1][1] * m_[1][i];
}
c[0][0] = a[0][0] * m_[0][0] + a[0][1] * m_[1][0];
c[1][0] = a[1][0] * m_[0][0] + a[1][1] * m_[1][0];
c[0][1] = a[0][0] * m_[0][1] + a[0][1] * m_[1][1];
c[1][1] = a[1][0] * m_[0][1] + a[1][1] * m_[1][1];
mateq(m_, c);
}

View File

@ -10,6 +10,7 @@
#include "matriz.h"
#include "symbol_def.h"
#include "debug.h"
#include "math_utils.h"
using std::sort;
using std::lower_bound;
@ -19,18 +20,18 @@ using std::max;
extern LyXFont WhichFont(short type, int size);
char const * math_font_name[] = {
"mathrm",
"mathcal",
"mathbf",
"mathsf",
"mathtt",
"mathit",
"textrm"
"mathrm",
"mathcal",
"mathbf",
"mathsf",
"mathtt",
"mathit",
"textrm"
};
char const * latex_mathspace[] = {
"!", ",", ":", ";", "quad", "qquad"
"!", ",", ":", ";", "quad", "qquad"
};
/*
@ -40,199 +41,238 @@ char const * latex_mathspace[] = {
static
float parenthHigh[] = {
2.0, 13.0, 0.9840, 0.0014, 0.7143, 0.0323, 0.4603, 0.0772, 0.2540,
0.1278, 0.1746, 0.1966, 0.0952, 0.3300, 0.0950, 0.5000, 0.0952, 0.6700,
0.1746, 0.8034, 0.2540, 0.8722, 0.4603, 0.9228, 0.7143, 0.9677, 0.9840,
0.9986, 0.0
float const parenthHigh[] = {
2.0, 13.0,
0.9840, 0.0014, 0.7143, 0.0323, 0.4603, 0.0772,
0.2540, 0.1278, 0.1746, 0.1966, 0.0952, 0.3300,
0.0950, 0.5000, 0.0952, 0.6700, 0.1746, 0.8034,
0.2540, 0.8722, 0.4603, 0.9228, 0.7143, 0.9677,
0.9840, 0.9986,
0.0
};
static float parenth[] = {
2.0, 13.0,
0.9930, 0.0071, 0.7324, 0.0578, 0.5141, 0.1126, 0.3380, 0.1714,
0.2183, 0.2333, 0.0634, 0.3621, 0.0141, 0.5000, 0.0563, 0.6369,
0.2113, 0.7647, 0.3310, 0.8276, 0.5070, 0.8864, 0.7254, 0.9412,
0.9930, 0.9919,
0.0
static
float const parenth[] = {
2.0, 13.0,
0.9930, 0.0071, 0.7324, 0.0578, 0.5141, 0.1126,
0.3380, 0.1714, 0.2183, 0.2333, 0.0634, 0.3621,
0.0141, 0.5000, 0.0563, 0.6369, 0.2113, 0.7647,
0.3310, 0.8276, 0.5070, 0.8864, 0.7254, 0.9412,
0.9930, 0.9919,
0.0
};
static float brace[] = {
2.0, 21.0,
0.9492, 0.0020, 0.9379, 0.0020, 0.7458, 0.0243, 0.5819, 0.0527,
0.4859, 0.0892, 0.4463, 0.1278, 0.4463, 0.3732, 0.4011, 0.4199,
0.2712, 0.4615, 0.0734, 0.4919, 0.0113, 0.5000, 0.0734, 0.5081,
0.2712, 0.5385, 0.4011, 0.5801, 0.4463, 0.6268, 0.4463, 0.8722,
0.4859, 0.9108, 0.5819, 0.9473, 0.7458, 0.9757, 0.9379, 0.9980,
0.9492, 0.9980,
0.0
};
static float arrow[] = {
4, 7,
0.015, 0.7500, 0.2, 0.6, 0.35, 0.35, 0.5, 0.05,
0.65, 0.35, 0.8, 0.6, 0.95, 0.7500,
3, 0.5, 0.15, 0.5, 0.95,
0.0
};
static float Arrow[] = {
4, 7,
0.015, 0.7500, 0.2, 0.6, 0.35, 0.35, 0.5, 0.05,
0.65, 0.35, 0.8, 0.6, 0.95, 0.7500,
3, 0.35, 0.5, 0.35, 0.95,
3, 0.65, 0.5, 0.65, 0.95,
0.0
};
static float udarrow[] = {
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
0.015, 0.75, 0.5, 0.95, 0.95, 0.75,
1, 0.5, 0.2, 0.5, 0.8,
0.0
};
static float Udarrow[] = {
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
0.015, 0.75, 0.5, 0.95, 0.95, 0.75,
1, 0.35, 0.2, 0.35, 0.8,
1, 0.65, 0.2, 0.65, 0.8,
0.0
};
static float brack[] = {
2.0, 4,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95, 0.95, 0.95,
0.0
};
static float corner[] = {
2.0, 3,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95,
0.0
};
static float angle[] = {
2.0, 3,
1, 0, 0.05, 0.5, 1, 1,
0.0
};
static float slash[] = {
1, 0.95, 0.05, 0.05, 0.95,
0.0
};
static float hline[] = {
1, 0.05, 0.5, 0.95, 0.5,
0.0
static
float const brace[] = {
2.0, 21.0,
0.9492, 0.0020, 0.9379, 0.0020, 0.7458, 0.0243,
0.5819, 0.0527, 0.4859, 0.0892, 0.4463, 0.1278,
0.4463, 0.3732, 0.4011, 0.4199, 0.2712, 0.4615,
0.0734, 0.4919, 0.0113, 0.5000, 0.0734, 0.5081,
0.2712, 0.5385, 0.4011, 0.5801, 0.4463, 0.6268,
0.4463, 0.8722, 0.4859, 0.9108, 0.5819, 0.9473,
0.7458, 0.9757, 0.9379, 0.9980, 0.9492, 0.9980,
0.0
};
static float hline2[] = {
// Is this correct? (Lgb)
static
float const arrow[] = {
4, 7,
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
0.9500, 0.7500,
3, 0.5000, 0.1500, 0.5000, 0.9500,
0.0
};
// Is this correct? (Lgb)
static
float const Arrow[] = {
4, 7,
0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
0.9500, 0.7500,
3, 0.3500, 0.5000, 0.3500, 0.9500,
3, 0.6500, 0.5000, 0.6500, 0.9500,
0.0
};
static
float const udarrow[] = {
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
0.015, 0.75, 0.5, 0.95, 0.95, 0.75,
1, 0.5, 0.2, 0.5, 0.8,
0.0
};
static
float const Udarrow[] = {
2, 3,
0.015, 0.25, 0.5, 0.05, 0.95, 0.25,
2, 3,
0.015, 0.75, 0.5, 0.95, 0.95, 0.75,
1, 0.35, 0.2, 0.35, 0.8,
1, 0.65, 0.2, 0.65, 0.8,
0.0
};
static
float const brack[] = {
2.0, 4,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95, 0.95, 0.95,
0.0
};
static
float const corner[] = {
2.0, 3,
0.95, 0.05, 0.05, 0.05, 0.05, 0.95,
0.0
};
static
float const angle[] = {
2.0, 3,
1, 0, 0.05, 0.5, 1, 1,
0.0
};
static
float const slash[] = {
1, 0.95, 0.05, 0.05, 0.95,
0.0
};
static const float hline[] = {
1, 0.05, 0.5, 0.95, 0.5,
0.0
};
static
float const hline2[] = {
1, 0.1, 0.5, 0.3, 0.5,
1, 0.7, 0.5, 0.9, 0.5,
0.0
};
static float hline3[] = {
1, 0.1, 0, 0.15, 0,
1, 0.475, 0, 0.525, 0,
1, 0.85, 0, 0.9, 0,
0.0
static
float const hline3[] = {
1, 0.1, 0, 0.15, 0,
1, 0.475, 0, 0.525, 0,
1, 0.85, 0, 0.9, 0,
0.0
};
static float dline3[] = {
1, 0.1, 0.1, 0.15, 0.15,
1, 0.475, 0.475, 0.525, 0.525,
1, 0.85, 0.85, 0.9, 0.9,
0.0
static
float const dline3[] = {
1, 0.1, 0.1, 0.15, 0.15,
1, 0.475, 0.475, 0.525, 0.525,
1, 0.85, 0.85, 0.9, 0.9,
0.0
};
static float hlinesmall[] = {
1, 0.4, 0.5, 0.6, 0.5,
0.0
static
float const hlinesmall[] = {
1, 0.4, 0.5, 0.6, 0.5,
0.0
};
static float vert[] = {
1, 0.5, 0.05, 0.5, 0.95,
0.0
static
float const vert[] = {
1, 0.5, 0.05, 0.5, 0.95,
0.0
};
static float Vert[] = {
1, 0.3, 0.05, 0.3, 0.95,
1, 0.7, 0.05, 0.7, 0.95,
0.0
static
float const Vert[] = {
1, 0.3, 0.05, 0.3, 0.95,
1, 0.7, 0.05, 0.7, 0.95,
0.0
};
static float tilde[] = {
2.0, 4,
0.05, 0.8, 0.25, 0.2, 0.75, 0.8, 0.95, 0.2,
0.0
static
float const tilde[] = {
2.0, 4,
0.05, 0.8, 0.25, 0.2, 0.75, 0.8, 0.95, 0.2,
0.0
};
static
math_deco_struct math_deco_table[] = {
// Decorations
{ LM_widehat, &angle[0], 3 },
{ LM_widetilde, &tilde[0], 0 },
{ LM_underline, &hline[0], 0 },
{ LM_overline, &hline[0], 0 },
{ LM_underbrace, &brace[0], 1 },
{ LM_overbrace, &brace[0], 3 },
{ LM_overleftarrow, &arrow[0], 1 },
{ LM_overightarrow, &arrow[0], 3 },
// Decorations
{ LM_widehat, &angle[0], 3 },
{ LM_widetilde, &tilde[0], 0 },
{ LM_underline, &hline[0], 0 },
{ LM_overline, &hline[0], 0 },
{ LM_underbrace, &brace[0], 1 },
{ LM_overbrace, &brace[0], 3 },
{ LM_overleftarrow, &arrow[0], 1 },
{ LM_overightarrow, &arrow[0], 3 },
// Delimiters
{ '(', &parenth[0], 0 },
{ ')', &parenth[0], 2 },
{ '{', &brace[0], 0 },
{ '}', &brace[0], 2 },
{ '[', &brack[0], 0 },
{ ']', &brack[0], 2 },
{ '|', &vert[0], 0 },
{ '/', &slash[0], 0 },
{ LM_Vert, &Vert[0], 0 },
{ LM_backslash, &slash[0], 1 },
{ LM_langle, &angle[0], 0 },
{ LM_lceil, &corner[0], 0 },
{ LM_lfloor, &corner[0], 1 },
{ LM_rangle, &angle[0], 2 },
{ LM_rceil, &corner[0], 3 },
{ LM_rfloor, &corner[0], 2 },
{ LM_downarrow, &arrow[0], 2 },
{ LM_Downarrow, &Arrow[0], 2 },
{ LM_uparrow, &arrow[0], 0 },
{ LM_Uparrow, &Arrow[0], 0 },
{ LM_updownarrow, &udarrow[0], 0 },
{ LM_Updownarrow, &Udarrow[0], 0 },
// Delimiters
{ '(', &parenth[0], 0 },
{ ')', &parenth[0], 2 },
{ '{', &brace[0], 0 },
{ '}', &brace[0], 2 },
{ '[', &brack[0], 0 },
{ ']', &brack[0], 2 },
{ '|', &vert[0], 0 },
{ '/', &slash[0], 0 },
{ LM_Vert, &Vert[0], 0 },
{ LM_backslash, &slash[0], 1 },
{ LM_langle, &angle[0], 0 },
{ LM_lceil, &corner[0], 0 },
{ LM_lfloor, &corner[0], 1 },
{ LM_rangle, &angle[0], 2 },
{ LM_rceil, &corner[0], 3 },
{ LM_rfloor, &corner[0], 2 },
{ LM_downarrow, &arrow[0], 2 },
{ LM_Downarrow, &Arrow[0], 2 },
{ LM_uparrow, &arrow[0], 0 },
{ LM_Uparrow, &Arrow[0], 0 },
{ LM_updownarrow, &udarrow[0], 0 },
{ LM_Updownarrow, &Udarrow[0], 0 },
// Accents
{ LM_ddot, &hline2[0], 0 },
{ LM_hat, &angle[0], 3 },
{ LM_grave, &slash[0], 1 },
{ LM_acute, &slash[0], 0 },
{ LM_tilde, &tilde[0], 0 },
{ LM_bar, &hline[0], 0 },
{ LM_dot, &hlinesmall[0], 0 },
{ LM_check, &angle[0], 1 },
{ LM_breve, &parenth[0], 1 },
{ LM_vec, &arrow[0], 3 },
{ LM_not, &slash[0], 0 },
// Accents
{ LM_ddot, &hline2[0], 0 },
{ LM_hat, &angle[0], 3 },
{ LM_grave, &slash[0], 1 },
{ LM_acute, &slash[0], 0 },
{ LM_tilde, &tilde[0], 0 },
{ LM_bar, &hline[0], 0 },
{ LM_dot, &hlinesmall[0], 0 },
{ LM_check, &angle[0], 1 },
{ LM_breve, &parenth[0], 1 },
{ LM_vec, &arrow[0], 3 },
{ LM_not, &slash[0], 0 },
// Dots
{ LM_ldots, &hline3[0], 0 },
{ LM_cdots, &hline3[0], 0 },
{ LM_vdots, &hline3[0], 1 },
{ LM_ddots, &dline3[0], 0 }
// Dots
{ LM_ldots, &hline3[0], 0 },
{ LM_cdots, &hline3[0], 0 },
{ LM_vdots, &hline3[0], 1 },
{ LM_ddots, &dline3[0], 0 }
};
@ -247,7 +287,9 @@ struct math_deco_compare {
static
int const math_deco_table_size = sizeof(math_deco_table) /sizeof(math_deco_struct);
int const math_deco_table_size =
sizeof(math_deco_table) /sizeof(math_deco_struct);
class init_deco_table {
public:
@ -263,16 +305,17 @@ private:
static bool init;
};
bool init_deco_table::init = false;
static init_deco_table idt;
int mathed_char_height(short type, int size, byte c, int & asc, int & des)
{
LyXFont font = WhichFont(type, size);
des = lyxfont::descent(c, font);
asc = lyxfont::ascent(c, font);
return asc + des;
LyXFont const font = WhichFont(type, size);
des = lyxfont::descent(c, font);
asc = lyxfont::ascent(c, font);
return asc + des;
}
@ -282,16 +325,15 @@ int mathed_char_width(short type, int size, byte c)
string s;
s += c;
return mathed_string_width(type, size, s);
}
else
return lyxfont::width(c, WhichFont(type, size));
} else
return lyxfont::width(c, WhichFont(type, size));
}
int mathed_string_height(short type, int size, string const & s,
int & asc, int & des)
{
LyXFont font = WhichFont(type, size);
LyXFont const font = WhichFont(type, size);
asc = des = 0;
for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
des = max(des, lyxfont::descent(*it, font));
@ -350,8 +392,8 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
return;
}
int r = mds.angle;
float * d = mds.data;
int const r = mds.angle;
float const * d = mds.data;
if (h > 70 && (mds.code == int('(')
|| mds.code == int(')')))
@ -365,8 +407,8 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
}
int r = mds->angle;
float * d = mds->data;
int const r = mds->angle;
float const * d = mds->data;
if (h > 70 && (mds->code == int('(')
|| mds->code == int(')')))
@ -376,7 +418,7 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
mt.rota(r);
mt.escala(w, h);
int n = (w < h) ? w : h;
int const n = (w < h) ? w : h;
sqmt.rota(r);
sqmt.escala(n, n);
if (r > 0 && r < 3) y += h;
@ -403,8 +445,9 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code)
case 2:
case 4:
{
int xp[32], yp[32];
n = int(d[i++]);
int xp[32];
int yp[32];
int const n = int(d[i++]);
for (int j = 0; j < n; ++j) {
xx = d[i++]; yy = d[i++];
// lyxerr << " " << xx << " " << yy << " ";
@ -430,7 +473,7 @@ struct deco_not_found {};
math_deco_struct const & search_deco(int code)
{
math_deco_struct * res =
math_deco_struct const * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
code, math_deco_compare());
@ -447,7 +490,7 @@ math_deco_struct const * search_deco(int code)
{
math_deco_struct search_elem = { code, 0, 0 };
math_deco_struct * res =
math_deco_struct const * res =
lower_bound(math_deco_table,
math_deco_table + math_deco_table_size,
search_elem, math_deco_compare());
@ -509,12 +552,13 @@ bool MathIsBOPS(short x)
bool MathIsBinary(short x)
{
return x == LM_TC_BOP || x == LM_TC_BOPS;
return x == LM_TC_BOP || x == LM_TC_BOPS;
}
bool MathIsSymbol(short x) {
return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
bool MathIsSymbol(short x)
{
return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
}

View File

@ -15,7 +15,7 @@ class MathParInset;
struct math_deco_struct {
int code;
float * data;
float const * data;
int angle;
};
@ -38,10 +38,6 @@ extern math_deco_struct const * search_deco(int code);
extern
MathedArray * mathed_parse(unsigned flags, MathedArray * data,
MathParInset ** mt);
/// math_write.C
extern
void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
string const & label = string());
/// math_parser.C
extern
@ -49,9 +45,6 @@ void mathed_parser_file(std::istream &, int);
/// math_parser.C
extern
int mathed_parser_lineno();
/// math_utils.C
extern
int MathedLookupBOP(short);
extern
bool MathIsInset(short x);

View File

@ -1,4 +1,5 @@
// This file was created automatically. Don't change it! [asierra18jan96]
// This -*- C++ -*- file was created automatically.
// Don't change it! [asierra18jan96]
#ifndef SYMBOL_DEF
#define SYMBOL_DEF
@ -215,202 +216,202 @@
/// Symbols that don't exist in X11 symbol font
enum Math_Symbols_enum {
///
LM_NoFont = 256,
///
LM_epsilon,
///
LM_hookleftarrow,
///
LM_hookrightarrow,
///
LM_updownarrow,
///
LM_leftharpoonup,
///
LM_rightharpoonup,
///
LM_rightleftharpoons,
///
LM_Updownarrow,
///
LM_leftharpoondown,
///
LM_rightharpoondown,
///
LM_mapsto,
///
LM_Longleftarrow,
///
LM_Longrightarrow,
///
LM_Longleftrightarrow,
///
LM_longleftrightarrow,
///
LM_longleftarrow,
///
LM_longrightarrow,
///
LM_longmapsto,
///
LM_nwarrow,
///
LM_nearrow,
///
LM_swarrow,
///
LM_searrow,
///
LM_models,
///
LM_prec,
///
LM_succ,
///
LM_sim,
///
LM_perp,
///
LM_preceq,
///
LM_succeq,
///
LM_simeq,
///
LM_ll,
///
LM_gg,
///
LM_asymp,
///
LM_parallel,
///
LM_smile,
///
LM_frown,
///
LM_sqsubseteq,
///
LM_sqsupseteq,
///
LM_doteq,
///
LM_ni,
///
LM_notin,
///
LM_vdash,
///
LM_dashv,
///
LM_bowtie,
///
LM_mp,
///
LM_bigtriangleup,
///
LM_ominus,
///
LM_uplus,
///
LM_bigtriangledown,
///
LM_sqcap,
///
LM_triangleright,
///
LM_sqcup,
///
LM_triangleleft,
///
LM_odot,
///
LM_star,
///
LM_amalg,
///
LM_bigcirc,
///
LM_setminus,
///
LM_dagger,
///
LM_circ,
///
LM_wr,
///
LM_ddagger,
///
LM_oint,
///
LM_coprod,
///
LM_bigsqcup,
///
LM_bigotimes,
///
LM_bigodot,
///
LM_bigoplus,
///
LM_bigcap,
///
LM_bigcup,
///
LM_biguplus,
///
LM_bigvee,
///
LM_bigwedge,
///
LM_ell,
///
LM_imath,
///
LM_jmath,
///
LM_hbar,
///
LM_top,
///
LM_Vert,
///
LM_flat,
///
LM_natural,
///
LM_triangle,
///
LM_widehat,
///
LM_widetilde,
///
LM_underline,
///
LM_overline,
///
LM_underbrace,
///
LM_overbrace,
///
LM_overleftarrow,
///
LM_overightarrow,
///
LM_ldots,
///
LM_cdots,
///
LM_vdots,
///
LM_ddots,
///
LM_backslash,
///
LM_emptyset,
///
LM_last_symbol
///
LM_NoFont = 256,
///
LM_epsilon,
///
LM_hookleftarrow,
///
LM_hookrightarrow,
///
LM_updownarrow,
///
LM_leftharpoonup,
///
LM_rightharpoonup,
///
LM_rightleftharpoons,
///
LM_Updownarrow,
///
LM_leftharpoondown,
///
LM_rightharpoondown,
///
LM_mapsto,
///
LM_Longleftarrow,
///
LM_Longrightarrow,
///
LM_Longleftrightarrow,
///
LM_longleftrightarrow,
///
LM_longleftarrow,
///
LM_longrightarrow,
///
LM_longmapsto,
///
LM_nwarrow,
///
LM_nearrow,
///
LM_swarrow,
///
LM_searrow,
///
LM_models,
///
LM_prec,
///
LM_succ,
///
LM_sim,
///
LM_perp,
///
LM_preceq,
///
LM_succeq,
///
LM_simeq,
///
LM_ll,
///
LM_gg,
///
LM_asymp,
///
LM_parallel,
///
LM_smile,
///
LM_frown,
///
LM_sqsubseteq,
///
LM_sqsupseteq,
///
LM_doteq,
///
LM_ni,
///
LM_notin,
///
LM_vdash,
///
LM_dashv,
///
LM_bowtie,
///
LM_mp,
///
LM_bigtriangleup,
///
LM_ominus,
///
LM_uplus,
///
LM_bigtriangledown,
///
LM_sqcap,
///
LM_triangleright,
///
LM_sqcup,
///
LM_triangleleft,
///
LM_odot,
///
LM_star,
///
LM_amalg,
///
LM_bigcirc,
///
LM_setminus,
///
LM_dagger,
///
LM_circ,
///
LM_wr,
///
LM_ddagger,
///
LM_oint,
///
LM_coprod,
///
LM_bigsqcup,
///
LM_bigotimes,
///
LM_bigodot,
///
LM_bigoplus,
///
LM_bigcap,
///
LM_bigcup,
///
LM_biguplus,
///
LM_bigvee,
///
LM_bigwedge,
///
LM_ell,
///
LM_imath,
///
LM_jmath,
///
LM_hbar,
///
LM_top,
///
LM_Vert,
///
LM_flat,
///
LM_natural,
///
LM_triangle,
///
LM_widehat,
///
LM_widetilde,
///
LM_underline,
///
LM_overline,
///
LM_underbrace,
///
LM_overbrace,
///
LM_overleftarrow,
///
LM_overightarrow,
///
LM_ldots,
///
LM_cdots,
///
LM_vdots,
///
LM_ddots,
///
LM_backslash,
///
LM_emptyset,
///
LM_last_symbol
};
// Accents
@ -429,16 +430,16 @@ enum Math_Symbols_enum {
///
enum Math_Accent_enum {
///
LM_ddot = LM_last_symbol,
///
LM_check,
///
LM_vec,
///
LM_breve,
///
LM_not
///
LM_ddot = LM_last_symbol,
///
LM_check,
///
LM_vec,
///
LM_breve,
///
LM_not
};
///
@ -447,4 +448,3 @@ enum Math_Accent_enum {
#define LM_qquad 5
#endif

View File

@ -68,9 +68,7 @@ unsigned int LyXParagraph::paragraph_id = 0;
LyXParagraph::LyXParagraph()
{
#ifndef HAVE_ROPE
text.reserve(500); // is this number too big?
#endif
for (int i = 0; i < 10; ++i) setCounter(i , 0);
appendix = false;
enumdepth = 0;
@ -93,9 +91,7 @@ LyXParagraph::LyXParagraph()
// This konstruktor inserts the new paragraph in a list.
LyXParagraph::LyXParagraph(LyXParagraph * par)
{
#ifndef HAVE_ROPE
text.reserve(500);
#endif
par->fitToSize();
for (int i = 0; i < 10; ++i) setCounter(i, 0);
@ -560,11 +556,9 @@ void LyXParagraph::Erase(LyXParagraph::size_type pos)
insetlist.erase(it);
}
}
#ifndef HAVE_ROPE
text.erase(text.begin() + pos);
#else
text.erase(text.mutable_begin() + pos);
#endif
// Erase entries in the tables.
FontTable search_font(pos, LyXFont());
@ -640,11 +634,8 @@ void LyXParagraph::InsertChar(LyXParagraph::size_type pos,
#else
Assert(pos <= size());
#endif
#ifndef HAVE_ROPE
text.insert(text.begin() + pos, c);
#else
text.insert(pos, c);
#endif
// Update the font table.
FontTable search_font(pos, LyXFont());
for (FontList::iterator it = lower_bound(fontlist.begin(),
@ -4089,3 +4080,16 @@ void LyXParagraph::resizeInsetsLyXText(BufferView * bv)
}
}
}
void LyXParagraph::fitToSize()
{
TextContainer tmp(text.begin(), text.end());
text.swap(tmp);
}
void LyXParagraph::setContentsFromPar(LyXParagraph * par)
{
text = par->text;
}

View File

@ -1,9 +1,12 @@
// -*- C++ -*-
/*
This is a collection of string helper functions that works
together with string (and later also with STL String. Some of these
would certainly benefit from a rewrite/optimization.
/** String helper functions.
\file lstrings.h
This is a collection of string helper functions that works
together with string (and later also with STL String. Some of these
would certainly benefit from a rewrite/optimization.
\author Lars Gullik Bjønnes
\author Jean-Marc Lasgouttes
*/
#ifndef LSTRINGS_H
@ -71,7 +74,7 @@ string const lowercase(string const &);
///
string const uppercase(string const &);
/// convert T to string
/// convert \a T to string
template<typename T>
inline
string const tostr(T const & t)
@ -147,20 +150,24 @@ bool containsOnly(char const *, string const &);
string::size_type countChar(string const & a, char c);
/** Extracts a token from this string at the nth delim.
Doesn't modify the original string. Similar to strtok.
Example:
#"a;bc;d".token(';', 1) == "bc";#
#"a;bc;d".token(';', 2) == "d";#
Doesn't modify the original string. Similar to strtok.
Example:
\code
"a;bc;d".token(';', 1) == "bc";
"a;bc;d".token(';', 2) == "d";
\endcode
*/
string const token(string const & a, char delim, int n);
/** Search a token in this string using the delim.
Doesn't modify the original string. Returns -1 in case of
failure.
Example:
#"a;bc;d".tokenPos(';', "bc") == 1;#
#"a;bc;d".token(';', "d") == 2;#
Doesn't modify the original string. Returns -1 in case of
failure.
Example:
\code
"a;bc;d".tokenPos(';', "bc") == 1;
"a;bc;d".token(';', "d") == 2;
\endcode
*/
int tokenPos(string const & a, char delim, string const & tok);
@ -170,37 +177,47 @@ int tokenPos(string const & a, char delim, string const & tok);
*/
bool regexMatch(string const & a, string const & pattern);
/// Substitute all "oldchar"s with "newchar"
/// Substitute all \a oldchar with \a newchar
string const subst(string const & a, char oldchar, char newchar);
/// Substitutes all instances of oldstr with newstr
/// Substitutes all instances of \a oldstr with \a newstr
string const subst(string const & a,
char const * oldstr, string const & newstr);
/// substitutes all instances ofr oldstr with newstr
/// substitutes all instances of \a oldstr with \a newstr
string const subst(string const & a,
string const & oldstr, string const & newstr);
/** Strips characters off the end of a string.
#"abccc".strip('c') = "ab".#
*/
\code
"abccc".strip('c') = "ab".
\endcode
*/
string const strip(string const & a, char c = ' ');
/** Strips characters of the beginning of a string.
#"cccba".frontstrip('c') = "ba"#. */
\code
"cccba".frontstrip('c') = "ba"
\endcode
*/
string const frontStrip(string const & a, char c = ' ');
/** Strips characters off the beginning of a string.
#"ababcdef".frontstrip("ab") = "cdef"# .*/
\code
"ababcdef".frontstrip("ab") = "cdef"
\endcode
*/
string const frontStrip(string const & a, char const * p);
/** Splits the string by the first delim.
Splits the string by the first appearance of delim.
The leading string up to delim is returned in piece (not including
delim), while the original string is cut from after the delimiter.
Example:
#s1= ""; s2= "a;bc".split(s1, ';') -> s1 == "a"; s2 == "bc";#
*/
Splits the string by the first appearance of delim.
The leading string up to delim is returned in piece (not including
delim), while the original string is cut from after the delimiter.
Example:
\code
s1= ""; s2= "a;bc".split(s1, ';') -> s1 == "a"; s2 == "bc";
\endcode
*/
string const split(string const & a, string & piece, char delim);
/// Same as split but does not return a piece

View File

@ -1348,7 +1348,8 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
{
int version;
int i, j;
int i;
int j;
int rows_arg = 0;
int columns_arg = 0;
int is_long_tabular_arg = false;

View File

@ -365,6 +365,7 @@ public:
bool GetLTNewPage(int cell) const;
///
InsetText * GetCellInset(int cell) const;
///
InsetText * GetCellInset(int row, int column) const;
///
int rows() const { return rows_; }

View File

@ -3088,15 +3088,12 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
#warning Should be fixed with a lyxinset::clear_width(bv, font) function! (Jug)
#warning Should we not fix this in the Painter, please have a look Lars! (Jug)
#endif
int w = (inset_owner ? inset_owner->width(bview, font)-2 : ww);
int h = row_ptr->height();
int x = x_offset;
int y = y_offset;
if (y < 0) {
h += y;
y = 0;
}
int const y = y_offset < 0 ? 0 : y_offset;
int const h = y_offset < 0 ?
row_ptr->height() + y_offset : row_ptr->height();
int const w = inset_owner ?
inset_owner->width(bview, font) - 2 : ww;
int const x = x_offset;
pain.fillRectangle(x, y, w, h);
} else if (inset != 0) {
int h = row_ptr->baseline() - inset->ascent(bview, font);

View File

@ -173,7 +173,7 @@ extern bool isValidGlueLength(string const & data, LyXGlueLength * result);
/// VSpace class
class VSpace {
public:
///
/// The different kinds of spaces.
enum vspace_kind {
///
NONE,
@ -190,37 +190,37 @@ public:
///
LENGTH
};
/// constructors
/// Constructor
VSpace() :
kin (NONE),
len(0.0, LyXLength::PT),
kp (false) {}
///
/// Constructor
explicit
VSpace(vspace_kind k) :
kin (k),
len (0.0, LyXLength::PT),
kp (false) {}
///
/// Constructor
explicit
VSpace(LyXGlueLength l) :
kin (LENGTH),
len (l),
kp (false) {}
///
/// Constructor
explicit
VSpace(float v, LyXLength::UNIT u) :
kin (LENGTH),
len (v, u),
kp (false) {}
/// this constructor is for reading from a .lyx file
/// Constructor for reading from a .lyx file
explicit
VSpace(string const & data);
// access functions
vspace_kind kind() const { return kin; }
/// access functions
vspace_kind kind() const { return kin; }
///
LyXGlueLength length() const { return len; }
@ -241,7 +241,7 @@ public:
///
int inPixels(int default_height, int default_skip) const;
private:
///
/// This VSpace kind
vspace_kind kin;
///
LyXGlueLength len;