mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
several changes from FilePtr to FileInfo, reverted back to Inset* and MathedInset* as return types from Clone. White space changes. Some changes from FilePtr to fstream
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@332 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6a1f065501
commit
65b4999759
49
ChangeLog
49
ChangeLog
@ -1,3 +1,52 @@
|
|||||||
|
1999-11-24 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||||
|
|
||||||
|
* several files: white-space changes.
|
||||||
|
|
||||||
|
* src/mathed/formula.C: removed IsAlpha and IsDigit
|
||||||
|
|
||||||
|
* src/insets/insetbib.C (getKeys): use findtexfile to look for the
|
||||||
|
.bib file. use a ifstream instead of FilePtr when parsing the .bib
|
||||||
|
file for keys.
|
||||||
|
|
||||||
|
* src/insets/figinset.C (GetPSSizes): don't break when
|
||||||
|
"EndComments" is seen. But break when a boundingbox is read.
|
||||||
|
|
||||||
|
* all classes inherited from Inset: return value of Clone
|
||||||
|
changed back to Inset *.
|
||||||
|
|
||||||
|
* all classes inherited form MathInset: return value of Clone
|
||||||
|
changed back to MathedInset *.
|
||||||
|
|
||||||
|
* src/insets/figinset.C (runqueue): use a ofstream to output the
|
||||||
|
gs/ps file. Might need some setpresicion or setw. However I can
|
||||||
|
see no problem with the current code.
|
||||||
|
(runqueue): use sleep instead of the alarm/signal code. I just
|
||||||
|
can't see the difference.
|
||||||
|
|
||||||
|
* src/paragraph.C (LyXParagraph): reserve space in the new
|
||||||
|
paragraph and resize the inserted paragraph to just fit.
|
||||||
|
|
||||||
|
* src/lyxfunc.h (operator|=): added operator for func_status.
|
||||||
|
|
||||||
|
* src/lyxfunc.C (MenuNew): use FileInfo instead of FilePtr to
|
||||||
|
check for readable file.
|
||||||
|
|
||||||
|
* src/lyx_cb.C (MenuMakeLaTeX): use FileInfo instead of FilePtr to
|
||||||
|
check for readable file.
|
||||||
|
(MenuMakeLinuxDoc): ditto
|
||||||
|
(MenuMakeDocBook): ditto
|
||||||
|
(MenuMakeAscii): ditto
|
||||||
|
(InsertAsciiFile): split the test for openable and readable
|
||||||
|
|
||||||
|
* src/bmtable.C (draw_bitmaptable): use
|
||||||
|
fl_state[fl_get_vclass()].depth instead of DefualtScreen.
|
||||||
|
|
||||||
|
* src/LaTeX.C, src/support/filetools.[Ch]: moved do_popen and
|
||||||
|
findtexfile from LaTeX to filetools.
|
||||||
|
|
||||||
|
* src/ImportNoweb.C (documentclass): rewrote to use ifstream
|
||||||
|
instead of FilePtr. Needs to be verified by a literate user.
|
||||||
|
|
||||||
1999-11-23 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
1999-11-23 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||||
|
|
||||||
* src/mathed/formula.[Ch] (GetCursorPos): add a missing 'const'.
|
* src/mathed/formula.[Ch] (GetCursorPos): add a missing 'const'.
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <cstdlib> // atoi
|
#include <cstdlib> // atoi
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@ -30,6 +31,8 @@
|
|||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
|
using std::ifstream;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CLASS Chktex
|
* CLASS Chktex
|
||||||
*/
|
*/
|
||||||
@ -56,7 +59,7 @@ int Chktex::run(TeXErrors &terr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Chktex::scanLogFile(TeXErrors &terr)
|
int Chktex::scanLogFile(TeXErrors & terr)
|
||||||
{
|
{
|
||||||
string token;
|
string token;
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
@ -17,10 +17,11 @@
|
|||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "ImportNoweb.h"
|
#include "ImportNoweb.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "support/syscall.h"
|
#include "support/syscall.h"
|
||||||
#include "support/filetools.h"
|
|
||||||
#include "bufferlist.h"
|
#include "bufferlist.h"
|
||||||
|
|
||||||
extern LyXRC * lyxrc;
|
extern LyXRC * lyxrc;
|
||||||
@ -46,30 +47,28 @@ Buffer * ImportNoweb::run()
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Provide the literate documentclass by parsing the file.
|
// Provide the literate documentclass by parsing the file.
|
||||||
//
|
|
||||||
string ImportNoweb::documentclass()
|
string ImportNoweb::documentclass()
|
||||||
{
|
{
|
||||||
string result = "literate-article"; // Default
|
string result = "literate-article"; // Default
|
||||||
|
|
||||||
FilePtr inputfile(file, FilePtr::read);
|
#warning If you use literate programming you should verify that this works
|
||||||
if (!inputfile()) return "nofile"; // Should not happen!
|
// This method has been rewritten to use ifstream, but since I
|
||||||
|
// don't use literate programming myself I am unable to check
|
||||||
|
// this correclty. (Lgb)
|
||||||
|
ifstream ifs(file.c_str());
|
||||||
|
|
||||||
char buf[BUFSIZE], *p, *q;
|
if (!ifs) return "nofile"; // Should not happen!
|
||||||
|
string line;
|
||||||
while(!feof(inputfile())) {
|
while (getline(ifs, line)) {
|
||||||
(void)fgets(buf, BUFSIZE, inputfile());
|
int p = line.find("\\documentclass");
|
||||||
if ((p = strstr(buf, "\\documentclass"))) {
|
if (p != string::npos) {
|
||||||
while ((*p) && (*p != '{'))
|
p = line.find('{', p);
|
||||||
p++;
|
int q = line.find('}', p);
|
||||||
q = p++;
|
result = "literate-" + line.substr(p, q - p);
|
||||||
while ((*q) && (*q != '}'))
|
break;
|
||||||
q++;
|
|
||||||
*q = '\0';
|
|
||||||
result = p;
|
|
||||||
result = "literate-" + result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
40
src/LaTeX.C
40
src/LaTeX.C
@ -16,6 +16,7 @@
|
|||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "LaTeX.h"
|
#include "LaTeX.h"
|
||||||
@ -29,7 +30,7 @@
|
|||||||
#include "minibuffer.h"
|
#include "minibuffer.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
using std::make_pair;
|
using std::ifstream;
|
||||||
|
|
||||||
// TODO: in no particular order
|
// TODO: in no particular order
|
||||||
// - get rid of the extern BufferList and the call to
|
// - get rid of the extern BufferList and the call to
|
||||||
@ -310,43 +311,6 @@ bool LaTeX::runMakeIndex(string const &file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef pair<int, string> cmdret;
|
|
||||||
static cmdret do_popen(string const & cmd)
|
|
||||||
{
|
|
||||||
// One question is if we should use popen or
|
|
||||||
// create our own popen based on fork, exec, pipe
|
|
||||||
// of course the best would be to have a
|
|
||||||
// pstream (process stream), with the
|
|
||||||
// variants ipstream, opstream and
|
|
||||||
FILE * inf = popen(cmd.c_str(), "r");
|
|
||||||
string ret;
|
|
||||||
int c = fgetc(inf);
|
|
||||||
while (c != EOF) {
|
|
||||||
ret += static_cast<char>(c);
|
|
||||||
c = fgetc(inf);
|
|
||||||
}
|
|
||||||
int pret = pclose(inf);
|
|
||||||
return make_pair(pret, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static string findtexfile(string const & fil, string const & format)
|
|
||||||
{
|
|
||||||
// If fil is a file with absolute path we just return it
|
|
||||||
if (AbsolutePath(fil)) return fil;
|
|
||||||
|
|
||||||
// Check in the current dir.
|
|
||||||
if (FileInfo(OnlyFilename(fil)).exist())
|
|
||||||
return OnlyFilename(fil);
|
|
||||||
|
|
||||||
// No we try to find it using kpsewhich.
|
|
||||||
string kpsecmd = "kpsewhich --format= " + format + " " + fil;
|
|
||||||
cmdret c = do_popen(kpsecmd);
|
|
||||||
|
|
||||||
lyxerr << "kpse status = " << c.first << "\n"
|
|
||||||
<< "kpse result = `" << strip(c.second, '\n') << "'" << endl;
|
|
||||||
return c.first == 0 ? strip(c.second, '\n') : string();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool LaTeX::runBibTeX(string const & file, DepTable & dep)
|
bool LaTeX::runBibTeX(string const & file, DepTable & dep)
|
||||||
|
@ -24,10 +24,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
using std::ifstream;
|
|
||||||
using std::ofstream;
|
|
||||||
|
|
||||||
class MiniBuffer;
|
class MiniBuffer;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
#endif
|
#endif
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
#include "LaTeX.h"
|
#include "LaTeX.h"
|
||||||
@ -27,6 +28,8 @@
|
|||||||
#include "minibuffer.h"
|
#include "minibuffer.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
|
using std::ifstream;
|
||||||
|
|
||||||
extern BufferList bufferlist;
|
extern BufferList bufferlist;
|
||||||
|
|
||||||
Literate::Literate(string const & latex, string const & f, string const & p,
|
Literate::Literate(string const & latex, string const & f, string const & p,
|
||||||
|
@ -92,7 +92,7 @@ static void draw_bitmaptable(FL_OBJECT *ob)
|
|||||||
reinterpret_cast<char*>(sp->bdata),
|
reinterpret_cast<char*>(sp->bdata),
|
||||||
sp->bw, sp->bh,
|
sp->bw, sp->bh,
|
||||||
fl_get_flcolor(ob->lcol), fl_get_flcolor(ob->col1),
|
fl_get_flcolor(ob->lcol), fl_get_flcolor(ob->col1),
|
||||||
DefaultDepth(fl_display, DefaultScreen(fl_display)));
|
/*DefaultDepth(fl_display, DefaultScreen(fl_display))*/ fl_state[fl_get_vclass()].depth);
|
||||||
XFlush(fl_display);
|
XFlush(fl_display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
50
src/buffer.C
50
src/buffer.C
@ -219,9 +219,9 @@ bool Buffer::insertLyXFile(string const & filen)
|
|||||||
// check if file exist
|
// check if file exist
|
||||||
FileInfo fi(filename);
|
FileInfo fi(filename);
|
||||||
|
|
||||||
if (!fi.exist() || !fi.readable()) {
|
if (!fi.readable()) {
|
||||||
WriteAlert(_("Error!"),
|
WriteAlert(_("Error!"),
|
||||||
_("Cannot open specified file:"),
|
_("Specified file is unreadable: "),
|
||||||
MakeDisplayPath(filename, 50));
|
MakeDisplayPath(filename, 50));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ bool Buffer::insertLyXFile(string const & filen)
|
|||||||
FilePtr myfile(filename, FilePtr::read);
|
FilePtr myfile(filename, FilePtr::read);
|
||||||
if (!myfile()) {
|
if (!myfile()) {
|
||||||
WriteAlert(_("Error!"),
|
WriteAlert(_("Error!"),
|
||||||
_("Cannot open specified file:"),
|
_("Cannot open specified file: "),
|
||||||
MakeDisplayPath(filename, 50));
|
MakeDisplayPath(filename, 50));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1236,46 +1236,28 @@ bool Buffer::writeFile(string const & filename, bool flag)
|
|||||||
void Buffer::writeFileAscii(string const & filename, int linelen)
|
void Buffer::writeFileAscii(string const & filename, int linelen)
|
||||||
{
|
{
|
||||||
FilePtr file(filename, FilePtr::write);
|
FilePtr file(filename, FilePtr::write);
|
||||||
LyXFont
|
LyXFont font1, font2;
|
||||||
font1, font2;
|
|
||||||
Inset * inset;
|
Inset * inset;
|
||||||
LyXParagraph * par = paragraph;
|
char c, footnoteflag = 0, depth = 0;
|
||||||
char
|
string tmp;
|
||||||
c,
|
|
||||||
footnoteflag = 0,
|
|
||||||
depth = 0;
|
|
||||||
|
|
||||||
string
|
|
||||||
fname1,
|
|
||||||
tmp;
|
|
||||||
|
|
||||||
LyXParagraph::size_type i;
|
LyXParagraph::size_type i;
|
||||||
int
|
int j, h, ltype = 0, ltype_depth = 0,
|
||||||
j, h,
|
* clen = 0, actcell = 0, actpos = 0, cell = 0, cells = 0,
|
||||||
ltype = 0,
|
|
||||||
ltype_depth = 0,
|
|
||||||
noparbreak = 0,
|
|
||||||
islatex = 0,
|
|
||||||
* clen = 0,
|
|
||||||
actcell = 0,
|
|
||||||
actpos = 0,
|
|
||||||
cell = 0,
|
|
||||||
cells = 0,
|
|
||||||
currlinelen = 0;
|
currlinelen = 0;
|
||||||
long
|
long fpos = 0;
|
||||||
fpos = 0;
|
bool ref_printed = false;
|
||||||
bool
|
|
||||||
ref_printed = false;
|
|
||||||
|
|
||||||
|
|
||||||
if (!file()) {
|
if (!file()) {
|
||||||
WriteFSAlert(_("Error: Cannot write file:"), filename);
|
WriteFSAlert(_("Error: Cannot write file:"), filename);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fname1 = TmpFileName();
|
|
||||||
|
string fname1 = TmpFileName();
|
||||||
|
LyXParagraph * par = paragraph;
|
||||||
while (par) {
|
while (par) {
|
||||||
noparbreak = 0;
|
int noparbreak = 0;
|
||||||
islatex = 0;
|
int islatex = 0;
|
||||||
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
|
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
|
||||||
!par->previous ||
|
!par->previous ||
|
||||||
par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE){
|
par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE){
|
||||||
@ -1366,7 +1348,7 @@ void Buffer::writeFileAscii(string const & filename, int linelen)
|
|||||||
actcell = 0;
|
actcell = 0;
|
||||||
cells = par->table->columns;
|
cells = par->table->columns;
|
||||||
clen = new int [cells];
|
clen = new int [cells];
|
||||||
memset(clen, 0, sizeof(int)*cells);
|
memset(clen, 0, sizeof(int) * cells);
|
||||||
for (i = 0, j = 0, h = 1; i < par->size(); ++i, ++h) {
|
for (i = 0, j = 0, h = 1; i < par->size(); ++i, ++h) {
|
||||||
c = par->GetChar(i);
|
c = par->GetChar(i);
|
||||||
if (c == LyXParagraph::META_INSET) {
|
if (c == LyXParagraph::META_INSET) {
|
||||||
|
@ -39,6 +39,7 @@ extern long int background_pixels;
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "form1.h"
|
#include "form1.h"
|
||||||
#include "figinset.h"
|
#include "figinset.h"
|
||||||
@ -438,19 +439,19 @@ int FindBmpIndex(figdata *tmpdata)
|
|||||||
|
|
||||||
static void chpixmap(Pixmap, int, int)
|
static void chpixmap(Pixmap, int, int)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
Display * tempdisp = XOpenDisplay(XDisplayName(0));
|
Display * tempdisp = XOpenDisplay(XDisplayName(0));
|
||||||
|
|
||||||
// here read the pixmap and change all colors to those we
|
// here read the pixmap and change all colors to those we
|
||||||
// have allocated
|
// have allocated
|
||||||
|
|
||||||
XCloseDisplay(tempdisp);
|
XCloseDisplay(tempdisp);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void freefigdata(figdata *tmpdata)
|
static void freefigdata(figdata *tmpdata)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
tmpdata->ref--;
|
tmpdata->ref--;
|
||||||
if (tmpdata->ref) return;
|
if (tmpdata->ref) return;
|
||||||
|
|
||||||
@ -468,7 +469,7 @@ static void freefigdata(figdata *tmpdata)
|
|||||||
|
|
||||||
if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
|
if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
|
||||||
delete tmpdata;
|
delete tmpdata;
|
||||||
i = FindBmpIndex(tmpdata);
|
int i = FindBmpIndex(tmpdata);
|
||||||
--bmpinsref;
|
--bmpinsref;
|
||||||
while (i < bmpinsref) {
|
while (i < bmpinsref) {
|
||||||
bitmaps[i] = bitmaps[i+1];
|
bitmaps[i] = bitmaps[i+1];
|
||||||
@ -488,10 +489,8 @@ static void runqueue()
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (gsrunning < MAXGS) {
|
while (gsrunning < MAXGS) {
|
||||||
queue *p;
|
|
||||||
int pid;
|
|
||||||
char tbuf[384], tbuf2[80];
|
char tbuf[384], tbuf2[80];
|
||||||
Atom *prop;
|
Atom * prop;
|
||||||
int nprop, i;
|
int nprop, i;
|
||||||
|
|
||||||
if (!gsqueue) {
|
if (!gsqueue) {
|
||||||
@ -502,18 +501,19 @@ static void runqueue()
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p = gsqueue;
|
queue * p = gsqueue;
|
||||||
|
|
||||||
if (!p->data) {
|
if (!p->data) {
|
||||||
delete p;
|
delete p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = fork();
|
int pid = fork();
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
if (lyxerr.debugging()) {
|
if (lyxerr.debugging()) {
|
||||||
lyxerr << "GS start error! Cannot fork." << endl;
|
lyxerr << "GS start error! Cannot fork."
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
p->data->broken = true;
|
p->data->broken = true;
|
||||||
p->data->reading = false;
|
p->data->reading = false;
|
||||||
@ -528,26 +528,22 @@ static void runqueue()
|
|||||||
sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
|
sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
|
||||||
int(getpid()));
|
int(getpid()));
|
||||||
|
|
||||||
FilePtr f(tbuf, FilePtr::write);
|
ofstream ofs(tbuf);
|
||||||
fprintf(f, "gsave clippath pathbbox grestore\n"
|
ofs << "gsave clippath pathbbox grestore\n"
|
||||||
"4 dict begin\n"
|
<< "4 dict begin\n"
|
||||||
"/ury exch def /urx exch def /lly exch def "
|
<< "/ury exch def /urx exch def /lly exch def "
|
||||||
"/llx exch def\n"
|
"/llx exch def\n"
|
||||||
"%g %g translate\n"
|
<< p->data->wid / 2.0 << " "
|
||||||
"%g rotate\n"
|
<< p->data->hgh / 2.0 << " translate\n"
|
||||||
"%g %g translate\n"
|
<< p->data->angle << " rotate\n"
|
||||||
"%g %g scale\n"
|
<< -(p->data->raw_wid / 2.0) << " "
|
||||||
"%d %d translate\nend\n",
|
<< -(p->data->raw_hgh / 2.0) << " translate\n"
|
||||||
p->data->wid / 2.0, p->data->hgh / 2.0,
|
<< p->rx / 72.0 << " " << p->ry / 72.0
|
||||||
p->data->angle,
|
<< " scale\n"
|
||||||
- (p->data->raw_wid / 2.0), -(p->data->raw_hgh / 2.0),
|
<< -p->ofsx << " " << -p->ofsy << " translate\n"
|
||||||
p->rx / 72.0, p->ry / 72.0,
|
<< "end" << endl;
|
||||||
-p->ofsx, -p->ofsy
|
ofs.close(); // Don't remove this.
|
||||||
);
|
|
||||||
|
|
||||||
// DON'T EVER remove this!!
|
|
||||||
f.close(); // was this all? (Lgb)
|
|
||||||
|
|
||||||
// gs process - set ghostview environment first
|
// gs process - set ghostview environment first
|
||||||
sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
|
sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
|
||||||
figinset_canvas), p->data->bitmap);
|
figinset_canvas), p->data->bitmap);
|
||||||
@ -597,6 +593,7 @@ static void runqueue()
|
|||||||
<< "] GHOSTVIEW property"
|
<< "] GHOSTVIEW property"
|
||||||
" found. Waiting." << endl;
|
" found. Waiting." << endl;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
#warning What is this doing? (wouldn't a sleep(1); work too?')
|
#warning What is this doing? (wouldn't a sleep(1); work too?')
|
||||||
#endif
|
#endif
|
||||||
@ -604,6 +601,9 @@ static void runqueue()
|
|||||||
alarmed = false;
|
alarmed = false;
|
||||||
signal(SIGALRM, waitalarm);
|
signal(SIGALRM, waitalarm);
|
||||||
while (!alarmed) pause();
|
while (!alarmed) pause();
|
||||||
|
#else
|
||||||
|
sleep(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
XChangeProperty(tempdisp,
|
XChangeProperty(tempdisp,
|
||||||
@ -1296,7 +1296,7 @@ void InsetFig::Edit(int, int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetFig * InsetFig::Clone() const
|
Inset * InsetFig::Clone() const
|
||||||
{
|
{
|
||||||
InsetFig * tmp = new InsetFig(100, 100, owner);
|
InsetFig * tmp = new InsetFig(100, 100, owner);
|
||||||
|
|
||||||
@ -1717,9 +1717,10 @@ void InsetFig::Recompute()
|
|||||||
|
|
||||||
void InsetFig::GetPSSizes()
|
void InsetFig::GetPSSizes()
|
||||||
{
|
{
|
||||||
|
#warning rewrite this method to use ifstream
|
||||||
/* get %%BoundingBox: from postscript file */
|
/* get %%BoundingBox: from postscript file */
|
||||||
int lastchar, c;
|
int lastchar, c;
|
||||||
char *p = 0;
|
char * p = 0;
|
||||||
|
|
||||||
/* defaults to associated size
|
/* defaults to associated size
|
||||||
* ..just in case the PS-file is not readable (Henner, 24-Aug-97)
|
* ..just in case the PS-file is not readable (Henner, 24-Aug-97)
|
||||||
@ -1730,7 +1731,7 @@ void InsetFig::GetPSSizes()
|
|||||||
pshgh = hgh;
|
pshgh = hgh;
|
||||||
|
|
||||||
if (fname.empty()) return;
|
if (fname.empty()) return;
|
||||||
|
|
||||||
FilePtr f(fname, FilePtr::read);
|
FilePtr f(fname, FilePtr::read);
|
||||||
|
|
||||||
if (!f()) return; // file not found !!!!
|
if (!f()) return; // file not found !!!!
|
||||||
@ -1752,7 +1753,9 @@ void InsetFig::GetPSSizes()
|
|||||||
if (c == '%' && lastchar == '%') {
|
if (c == '%' && lastchar == '%') {
|
||||||
p = NextToken(f);
|
p = NextToken(f);
|
||||||
if (!p) break;
|
if (!p) break;
|
||||||
if (strcmp(p, "EndComments") == 0) break;
|
// we should not use this, with it we cannot
|
||||||
|
// discover bounding box and end of file.
|
||||||
|
//if (strcmp(p, "EndComments") == 0) break;
|
||||||
if (strcmp(p, "BoundingBox:") == 0) {
|
if (strcmp(p, "BoundingBox:") == 0) {
|
||||||
float fpsx, fpsy, fpswid, fpshgh;
|
float fpsx, fpsy, fpswid, fpshgh;
|
||||||
if (fscanf(f, "%f %f %f %f", &fpsx, &fpsy,
|
if (fscanf(f, "%f %f %f %f", &fpsx, &fpsy,
|
||||||
@ -1769,8 +1772,8 @@ void InsetFig::GetPSSizes()
|
|||||||
<< psy << ' '
|
<< psy << ' '
|
||||||
<< pswid << ' '
|
<< pswid << ' '
|
||||||
<< pshgh << endl;
|
<< pshgh << endl;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
c = 0;
|
c = 0;
|
||||||
delete[] p;
|
delete[] p;
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
(C)1996 by Ivan Schreter
|
(C)1996 by Ivan Schreter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _FIGINSET_H
|
#ifndef FIGINSET_H
|
||||||
#define _FIGINSET_H
|
#define FIGINSET_H
|
||||||
|
|
||||||
#include "form1.h"
|
#include "form1.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
@ -24,30 +24,30 @@ public:
|
|||||||
///
|
///
|
||||||
~InsetFig();
|
~InsetFig();
|
||||||
///
|
///
|
||||||
int Ascent(LyXFont const &font) const;
|
int Ascent(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
int Descent(LyXFont const &font) const;
|
int Descent(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
int Width(LyXFont const &font) const;
|
int Width(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x);
|
void Draw(LyXFont font, LyXScreen & scr, int baseline, float & x);
|
||||||
///
|
///
|
||||||
void Write(FILE *file);
|
void Write(FILE * file);
|
||||||
///
|
///
|
||||||
void Read(LyXLex &lex);
|
void Read(LyXLex & lex);
|
||||||
///
|
///
|
||||||
int Latex(FILE *file, signed char fragile);
|
int Latex(FILE * file, signed char fragile);
|
||||||
///
|
///
|
||||||
int Latex(string &file, signed char fragile);
|
int Latex(string & file, signed char fragile);
|
||||||
///
|
///
|
||||||
int Linuxdoc(string &file);
|
int Linuxdoc(string & file);
|
||||||
///
|
///
|
||||||
int DocBook(string &file);
|
int DocBook(string & file);
|
||||||
/// Updates needed features for this inset.
|
/// Updates needed features for this inset.
|
||||||
void Validate(LaTeXFeatures &features) const;
|
void Validate(LaTeXFeatures & features) const;
|
||||||
|
|
||||||
/// what appears in the minibuffer when opening
|
/// what appears in the minibuffer when opening
|
||||||
char const* EditMessage() {return "Opened figure";}
|
char const * EditMessage() { return "Opened figure"; }
|
||||||
///
|
///
|
||||||
void Edit(int, int);
|
void Edit(int, int);
|
||||||
///
|
///
|
||||||
@ -57,16 +57,16 @@ public:
|
|||||||
///
|
///
|
||||||
Inset::Code LyxCode() const;
|
Inset::Code LyxCode() const;
|
||||||
///
|
///
|
||||||
InsetFig * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
void CallbackFig(long arg);
|
void CallbackFig(long arg);
|
||||||
///
|
///
|
||||||
void Preview(char const *p);
|
void Preview(char const * p);
|
||||||
/// browse for file
|
/// browse for file
|
||||||
void BrowseFile();
|
void BrowseFile();
|
||||||
|
|
||||||
/// form for user input
|
/// form for user input
|
||||||
FD_Figure *form;
|
FD_Figure * form;
|
||||||
/// width and height in pixels on screen
|
/// width and height in pixels on screen
|
||||||
int wid, hgh;
|
int wid, hgh;
|
||||||
/// width and height in postscript units (1/72 inch)
|
/// width and height in postscript units (1/72 inch)
|
||||||
@ -124,14 +124,14 @@ public:
|
|||||||
int flags;
|
int flags;
|
||||||
bool subfigure : 1;
|
bool subfigure : 1;
|
||||||
/// figure reference
|
/// figure reference
|
||||||
Figref *figure;
|
Figref * figure;
|
||||||
/// temporary flags
|
/// temporary flags
|
||||||
int pflags;
|
int pflags;
|
||||||
bool psubfigure : 1;
|
bool psubfigure : 1;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
///
|
///
|
||||||
Buffer *owner;
|
Buffer * owner;
|
||||||
/// restore values on the form
|
/// restore values on the form
|
||||||
void RestoreForm();
|
void RestoreForm();
|
||||||
/// recompute screen params
|
/// recompute screen params
|
||||||
@ -177,9 +177,9 @@ struct figdata {
|
|||||||
///
|
///
|
||||||
struct Figref {
|
struct Figref {
|
||||||
/// figure data (image)
|
/// figure data (image)
|
||||||
figdata *data;
|
figdata * data;
|
||||||
/// inset of this figure
|
/// inset of this figure
|
||||||
InsetFig *inset;
|
InsetFig * inset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
@ -342,6 +343,7 @@ int InsetBibtex::Latex(string &file, signed char /*fragile*/)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This method returns a comma separated list of Bibtex entries
|
// This method returns a comma separated list of Bibtex entries
|
||||||
string InsetBibtex::getKeys()
|
string InsetBibtex::getKeys()
|
||||||
{
|
{
|
||||||
@ -350,64 +352,46 @@ string InsetBibtex::getKeys()
|
|||||||
if (!owner) {
|
if (!owner) {
|
||||||
owner = current_view->buffer();
|
owner = current_view->buffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to create absolute path names for bibliographies
|
string tmp, keys;
|
||||||
// First look for bib-file in same directory as document,
|
string bibfiles = getContents();
|
||||||
// then in all directories listed in environment variable
|
bibfiles = split(bibfiles, tmp, ',');
|
||||||
// BIBINPUTS
|
|
||||||
string bibfiles, linebuf, tmp, keys;
|
|
||||||
bibfiles = getContents();
|
|
||||||
bibfiles= split(bibfiles, tmp, ',');
|
|
||||||
while(!tmp.empty()) {
|
while(!tmp.empty()) {
|
||||||
if (IsFileReadable(MakeAbsPath(tmp, owner->filepath)+".bib"))
|
string fil = findtexfile(ChangeExtension(tmp, "bib", false),
|
||||||
tmp = MakeAbsPath(tmp, owner->filepath)+".bib";
|
"bib");
|
||||||
else {
|
lyxerr << "Bibfile: " << fil << endl;
|
||||||
tmp = FileOpenSearch(GetEnvPath("BIBINPUTS"), tmp, "bib");
|
|
||||||
if (tmp.empty())
|
|
||||||
tmp = FileOpenSearch(GetEnvPath("BIBINPUT"),
|
|
||||||
tmp, "bib");
|
|
||||||
}
|
|
||||||
// If we didn't find a matching file name just fail silently
|
// If we didn't find a matching file name just fail silently
|
||||||
if (!tmp.empty()) {
|
if (!fil.empty()) {
|
||||||
|
// This is a _very_ simple parser for Bibtex database
|
||||||
// This is a _very_ simple parser for Bibtex database files.
|
// files. All it does is to look for lines starting
|
||||||
// All it does is to look for lines starting in @ and not
|
// in @ and not being @preamble and @string entries.
|
||||||
// being @preamble and @string entries.
|
|
||||||
// It does NOT do any syntax checking!
|
// It does NOT do any syntax checking!
|
||||||
FilePtr file(tmp, FilePtr::read);
|
ifstream ifs(fil.c_str());
|
||||||
char c;
|
string linebuf;
|
||||||
|
while (getline(ifs, linebuf)) {
|
||||||
// On some systems where feof() is a macro,
|
if (prefixIs(linebuf, "@")) {
|
||||||
// the () after file is needed (JMarc)
|
linebuf = subst(linebuf, '{', '(');
|
||||||
while (! feof(file())) {
|
linebuf = split(linebuf, tmp, '(');
|
||||||
c = fgetc(file);
|
tmp = lowercase(tmp);
|
||||||
|
if (!prefixIs(tmp, "@string")
|
||||||
// At end of each line check if line begins with '@'
|
&& !prefixIs(tmp, "@preamble")) {
|
||||||
if ( c == '\n') {
|
|
||||||
if (prefixIs(linebuf, "@") ) {
|
|
||||||
linebuf = subst(linebuf,
|
|
||||||
'{', '(');
|
|
||||||
linebuf = split(linebuf,
|
linebuf = split(linebuf,
|
||||||
tmp,'(');
|
tmp, ',');
|
||||||
tmp = lowercase(tmp);
|
if (!tmp.empty()) {
|
||||||
if (!prefixIs(tmp, "@string") && !prefixIs(tmp, "@preamble") ) {
|
keys += strip(tmp);
|
||||||
linebuf = split(linebuf, tmp,',');
|
keys += ", ";
|
||||||
if (!tmp.empty())
|
|
||||||
keys += strip(tmp) + ", ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
linebuf.clear();
|
|
||||||
} else {
|
|
||||||
linebuf += c;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get next file name
|
// Get next file name
|
||||||
bibfiles= split(bibfiles, tmp, ',');
|
bibfiles = split(bibfiles, tmp, ',');
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// BibTeX should have its own dialog. This is provisional.
|
// BibTeX should have its own dialog. This is provisional.
|
||||||
void InsetBibtex::Edit(int, int)
|
void InsetBibtex::Edit(int, int)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
///
|
///
|
||||||
~InsetCitation();
|
~InsetCitation();
|
||||||
///
|
///
|
||||||
InsetCitation * Clone() const {
|
Inset * Clone() const {
|
||||||
return new InsetCitation(contents, options);
|
return new InsetCitation(contents, options);
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
@ -62,7 +62,7 @@ public:
|
|||||||
///
|
///
|
||||||
~InsetBibKey();
|
~InsetBibKey();
|
||||||
///
|
///
|
||||||
InsetBibKey * Clone() const { return new InsetBibKey(this); }
|
Inset * Clone() const { return new InsetBibKey(this); }
|
||||||
/// Currently \bibitem is used as a LyX2.x command, so we need this method.
|
/// Currently \bibitem is used as a LyX2.x command, so we need this method.
|
||||||
void Write(FILE *);
|
void Write(FILE *);
|
||||||
///
|
///
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
InsetBibtex(string const & dbase, string const & style,
|
InsetBibtex(string const & dbase, string const & style,
|
||||||
Buffer *);
|
Buffer *);
|
||||||
///
|
///
|
||||||
InsetBibtex * Clone() const {
|
Inset * Clone() const {
|
||||||
return new InsetBibtex(contents, options, 0);
|
return new InsetBibtex(contents, options, 0);
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
@ -195,7 +195,7 @@ int InsetCommand::DocBook(string &/*file*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetCommand * InsetCommand::Clone() const
|
Inset * InsetCommand::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetCommand(command, contents, options);
|
return new InsetCommand(command, contents, options);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public:
|
|||||||
///
|
///
|
||||||
virtual int DocBook(string & file);
|
virtual int DocBook(string & file);
|
||||||
///
|
///
|
||||||
InsetCommand * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const
|
Inset::Code LyxCode() const
|
||||||
{
|
{
|
||||||
|
@ -181,7 +181,7 @@ void InsetError::Edit(int, int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetError * InsetError::Clone() const
|
Inset * InsetError::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetError(contents);
|
return new InsetError(contents);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
///
|
///
|
||||||
unsigned char Editable() const;
|
unsigned char Editable() const;
|
||||||
///
|
///
|
||||||
InsetError * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const { return Inset::NO_CODE; }
|
Inset::Code LyxCode() const { return Inset::NO_CODE; }
|
||||||
/// We don't want "begin" and "end inset" in lyx-file
|
/// We don't want "begin" and "end inset" in lyx-file
|
||||||
|
@ -210,7 +210,7 @@ InsetInclude::~InsetInclude()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InsetInclude * InsetInclude::Clone() const
|
Inset * InsetInclude::Clone() const
|
||||||
{
|
{
|
||||||
InsetInclude * ii = new InsetInclude (contents, master);
|
InsetInclude * ii = new InsetInclude (contents, master);
|
||||||
ii->setNoLoad(isNoLoad());
|
ii->setNoLoad(isNoLoad());
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
///
|
///
|
||||||
~InsetInclude();
|
~InsetInclude();
|
||||||
///
|
///
|
||||||
InsetInclude * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
|
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
|
||||||
/// This is 1 if the childs have labels, 0 otherwise
|
/// This is 1 if the childs have labels, 0 otherwise
|
||||||
|
@ -29,13 +29,13 @@ struct LaTeXFeatures;
|
|||||||
class InsetIndex: public InsetCommand {
|
class InsetIndex: public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetIndex(): InsetCommand("index") {;}
|
InsetIndex() : InsetCommand("index") {}
|
||||||
///
|
///
|
||||||
InsetIndex(string const & key);
|
InsetIndex(string const & key);
|
||||||
///
|
///
|
||||||
~InsetIndex();
|
~InsetIndex();
|
||||||
///
|
///
|
||||||
InsetIndex * Clone() const { return new InsetIndex(contents);}
|
Inset * Clone() const { return new InsetIndex(contents);}
|
||||||
///
|
///
|
||||||
void Edit(int, int);
|
void Edit(int, int);
|
||||||
///
|
///
|
||||||
@ -48,7 +48,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class InsetPrintIndex: public InsetCommand {
|
class InsetPrintIndex : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetPrintIndex();
|
InsetPrintIndex();
|
||||||
@ -64,6 +64,7 @@ public:
|
|||||||
unsigned char Editable() const{
|
unsigned char Editable() const{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/// WHY is clone missing? (Lgb)
|
||||||
///
|
///
|
||||||
bool display() const { return true; }
|
bool display() const { return true; }
|
||||||
///
|
///
|
||||||
|
@ -215,7 +215,7 @@ void InsetInfo::Edit(int, int)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetInfo * InsetInfo::Clone() const
|
Inset * InsetInfo::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetInfo(contents);
|
return new InsetInfo(contents);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
in a yellow box. Currently, the Read-function is a terrible hack.
|
in a yellow box. Currently, the Read-function is a terrible hack.
|
||||||
Some day in the distant future, this will hopefully be obsoleted by
|
Some day in the distant future, this will hopefully be obsoleted by
|
||||||
a true comment-environment. */
|
a true comment-environment. */
|
||||||
class InsetInfo: public Inset {
|
class InsetInfo : public Inset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetInfo();
|
InsetInfo();
|
||||||
@ -65,7 +65,7 @@ public:
|
|||||||
///
|
///
|
||||||
Inset::Code LyxCode() const;
|
Inset::Code LyxCode() const;
|
||||||
///
|
///
|
||||||
InsetInfo * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
static void CloseInfoCB(FL_OBJECT *, long data);
|
static void CloseInfoCB(FL_OBJECT *, long data);
|
||||||
private:
|
private:
|
||||||
|
@ -25,7 +25,7 @@ InsetLabel::InsetLabel(string const & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetLabel * InsetLabel::Clone() const
|
Inset * InsetLabel::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetLabel(getCommand());
|
return new InsetLabel(getCommand());
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
#include "LString.h"
|
#include "LString.h"
|
||||||
|
|
||||||
///
|
///
|
||||||
class InsetLabel: public InsetCommand {
|
class InsetLabel : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetLabel(string const & cmd);
|
InsetLabel(string const & cmd);
|
||||||
///
|
///
|
||||||
InsetLabel() : InsetCommand("label") {}
|
InsetLabel() : InsetCommand("label") {}
|
||||||
///
|
///
|
||||||
InsetLabel * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
|
Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
|
||||||
///
|
///
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
delete/backspace operations. This is used when you insert a LaTeX
|
delete/backspace operations. This is used when you insert a LaTeX
|
||||||
figure (done as "\input "), but you still have to type the filename
|
figure (done as "\input "), but you still have to type the filename
|
||||||
yourself after the inset. */
|
yourself after the inset. */
|
||||||
class InsetLatex: public Inset {
|
class InsetLatex : public Inset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetLatex();
|
InsetLatex();
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
///
|
///
|
||||||
bool Deletable() const;
|
bool Deletable() const;
|
||||||
///
|
///
|
||||||
InsetLatex * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const;
|
Inset::Code LyxCode() const;
|
||||||
private:
|
private:
|
||||||
|
@ -630,7 +630,7 @@ bool InsetLatexAccent::DirectWrite() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetLatexAccent * InsetLatexAccent::Clone() const
|
Inset * InsetLatexAccent::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetLatexAccent(contents);
|
return new InsetLatexAccent(contents);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
it also can handle other special characters (e.g. Hstroke)
|
it also can handle other special characters (e.g. Hstroke)
|
||||||
Initiated by Ivan Schreter, later modified by Lgb.
|
Initiated by Ivan Schreter, later modified by Lgb.
|
||||||
*/
|
*/
|
||||||
class InsetLatexAccent: public Inset {
|
class InsetLatexAccent : public Inset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetLatexAccent();
|
InsetLatexAccent();
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
///
|
///
|
||||||
bool DirectWrite() const;
|
bool DirectWrite() const;
|
||||||
///
|
///
|
||||||
InsetLatexAccent * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode()const;
|
Inset::Code LyxCode()const;
|
||||||
///
|
///
|
||||||
|
@ -23,21 +23,19 @@
|
|||||||
|
|
||||||
/** Used to insert table of algorithms
|
/** Used to insert table of algorithms
|
||||||
*/
|
*/
|
||||||
class InsetLOA: public InsetCommand {
|
class InsetLOA : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetLOA(): InsetCommand("listofalgorithms") {}
|
InsetLOA() : InsetCommand("listofalgorithms") {}
|
||||||
///
|
///
|
||||||
InsetLOA(Buffer * b): InsetCommand("listofalgorithms"), owner(b) {}
|
InsetLOA(Buffer * b) : InsetCommand("listofalgorithms"), owner(b) {}
|
||||||
///
|
///
|
||||||
void Validate(LaTeXFeatures & features) const;
|
void Validate(LaTeXFeatures & features) const;
|
||||||
///
|
///
|
||||||
InsetLOA * Clone() const { return new InsetLOA(owner); }
|
Inset * Clone() const { return new InsetLOA(owner); }
|
||||||
///
|
///
|
||||||
string getScreenLabel() const { return _("List of Algorithms"); }
|
string getScreenLabel() const { return _("List of Algorithms"); }
|
||||||
|
|
||||||
|
|
||||||
//void Edit(int, int);
|
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
unsigned char Editable() const {
|
||||||
return 0; // not yet
|
return 0; // not yet
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
/** Used to insert table of contents
|
/** Used to insert table of contents
|
||||||
*/
|
*/
|
||||||
class InsetLOF: public InsetCommand {
|
class InsetLOF : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetLOF(): InsetCommand("listoffigures") {}
|
InsetLOF() : InsetCommand("listoffigures") {}
|
||||||
///
|
///
|
||||||
InsetLOF(Buffer * b): InsetCommand("listoffigures"), owner(b) {}
|
InsetLOF(Buffer * b) : InsetCommand("listoffigures"), owner(b) {}
|
||||||
///
|
///
|
||||||
InsetLOF * Clone() const { return new InsetLOF(owner); }
|
Inset * Clone() const { return new InsetLOF(owner); }
|
||||||
///
|
///
|
||||||
string getScreenLabel() const { return _("List of Figures"); }
|
string getScreenLabel() const { return _("List of Figures"); }
|
||||||
|
|
||||||
//void Edit(int, int);
|
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
unsigned char Editable() const {
|
||||||
return 0; // not yet
|
return 0; // not yet
|
||||||
|
@ -23,18 +23,17 @@
|
|||||||
|
|
||||||
/** Used to insert table of contents
|
/** Used to insert table of contents
|
||||||
*/
|
*/
|
||||||
class InsetLOT: public InsetCommand {
|
class InsetLOT : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetLOT(): InsetCommand("listoftables") {}
|
InsetLOT() : InsetCommand("listoftables") {}
|
||||||
///
|
///
|
||||||
InsetLOT(Buffer * b): InsetCommand("listoftables"), owner(b) {}
|
InsetLOT(Buffer * b) : InsetCommand("listoftables"), owner(b) {}
|
||||||
///
|
///
|
||||||
InsetLOT * Clone() const { return new InsetLOT(owner); }
|
Inset * Clone() const { return new InsetLOT(owner); }
|
||||||
///
|
///
|
||||||
string getScreenLabel() const { return _("List of Tables"); }
|
string getScreenLabel() const { return _("List of Tables"); }
|
||||||
|
|
||||||
//void Edit(int, int);
|
|
||||||
///
|
///
|
||||||
unsigned char Editable() const {
|
unsigned char Editable() const {
|
||||||
return 0; // not yet
|
return 0; // not yet
|
||||||
|
@ -24,22 +24,22 @@
|
|||||||
Useful to load a parent document from a child document and to
|
Useful to load a parent document from a child document and to
|
||||||
share parent's properties between preambleless children.
|
share parent's properties between preambleless children.
|
||||||
*/
|
*/
|
||||||
class InsetParent: public InsetCommand {
|
class InsetParent : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
/// Non-standard LyX macro
|
/// Non-standard LyX macro
|
||||||
InsetParent(): InsetCommand("lyxparent") { }
|
InsetParent() : InsetCommand("lyxparent") {}
|
||||||
///
|
///
|
||||||
InsetParent(string fn, Buffer * owner= 0);
|
InsetParent(string fn, Buffer * owner = 0);
|
||||||
///
|
|
||||||
~InsetParent() {}
|
|
||||||
///
|
///
|
||||||
int Latex(FILE * file, signed char fragile);
|
int Latex(FILE * file, signed char fragile);
|
||||||
///
|
///
|
||||||
int Latex(string & file, signed char fragile);
|
int Latex(string & file, signed char fragile);
|
||||||
///
|
///
|
||||||
InsetParent * Clone() const { return new InsetParent(getContents()); }
|
Inset * Clone() const { return new InsetParent(getContents()); }
|
||||||
///
|
///
|
||||||
string getScreenLabel() const { return string(_("Parent:"))+getContents(); }
|
string getScreenLabel() const {
|
||||||
|
return string(_("Parent:")) + getContents();
|
||||||
|
}
|
||||||
///
|
///
|
||||||
void Edit(int, int);
|
void Edit(int, int);
|
||||||
///
|
///
|
||||||
|
@ -309,7 +309,7 @@ void InsetQuotes::Validate(LaTeXFeatures & features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetQuotes * InsetQuotes::Clone() const
|
Inset * InsetQuotes::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetQuotes(language, side, times);
|
return new InsetQuotes(language, side, times);
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,6 @@ public:
|
|||||||
InsetQuotes(string const & str = "eld");
|
InsetQuotes(string const & str = "eld");
|
||||||
/// Create the right quote inset after character c
|
/// Create the right quote inset after character c
|
||||||
InsetQuotes(char c, BufferParams const & params);
|
InsetQuotes(char c, BufferParams const & params);
|
||||||
///
|
|
||||||
~InsetQuotes() {}; //nothing to do
|
|
||||||
|
|
||||||
///
|
///
|
||||||
int Ascent(LyXFont const & font) const;
|
int Ascent(LyXFont const & font) const;
|
||||||
@ -97,7 +95,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Validate(LaTeXFeatures &) const;
|
void Validate(LaTeXFeatures &) const;
|
||||||
///
|
///
|
||||||
InsetQuotes * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const;
|
Inset::Code LyxCode() const;
|
||||||
private:
|
private:
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
///
|
///
|
||||||
~InsetRef();
|
~InsetRef();
|
||||||
///
|
///
|
||||||
InsetRef * Clone() const {
|
Inset * Clone() const {
|
||||||
return new InsetRef (getCommand(), master);
|
return new InsetRef (getCommand(), master);
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
|
@ -184,7 +184,7 @@ int InsetSpecialChar::DocBook(string & file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetSpecialChar * InsetSpecialChar::Clone() const
|
Inset * InsetSpecialChar::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetSpecialChar(kind);
|
return new InsetSpecialChar(kind);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
struct LaTeXFeatures;
|
struct LaTeXFeatures;
|
||||||
|
|
||||||
/// Used to insert special chars
|
/// Used to insert special chars
|
||||||
class InsetSpecialChar: public Inset {
|
class InsetSpecialChar : public Inset {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// The different kinds of special chars we support
|
/// The different kinds of special chars we support
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
///
|
///
|
||||||
int DocBook(string & file);
|
int DocBook(string & file);
|
||||||
///
|
///
|
||||||
InsetSpecialChar * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const
|
Inset::Code LyxCode() const
|
||||||
{
|
{
|
||||||
|
@ -23,14 +23,14 @@
|
|||||||
|
|
||||||
/** Used to insert table of contents
|
/** Used to insert table of contents
|
||||||
*/
|
*/
|
||||||
class InsetTOC: public InsetCommand {
|
class InsetTOC : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetTOC(): InsetCommand("tableofcontents") {}
|
InsetTOC() : InsetCommand("tableofcontents") {}
|
||||||
///
|
///
|
||||||
InsetTOC(Buffer * b): InsetCommand("tableofcontents"), owner(b) {}
|
InsetTOC(Buffer * b) : InsetCommand("tableofcontents"), owner(b) {}
|
||||||
///
|
///
|
||||||
InsetTOC * Clone() const { return new InsetTOC(owner); }
|
Inset * Clone() const { return new InsetTOC(owner); }
|
||||||
///
|
///
|
||||||
string getScreenLabel() const { return _("Table of Contents"); }
|
string getScreenLabel() const { return _("Table of Contents"); }
|
||||||
/// On edit, we open the TOC pop-up
|
/// On edit, we open the TOC pop-up
|
||||||
|
@ -23,7 +23,7 @@ struct LaTeXFeatures;
|
|||||||
|
|
||||||
/** The url inset
|
/** The url inset
|
||||||
*/
|
*/
|
||||||
class InsetUrl: public InsetCommand {
|
class InsetUrl : public InsetCommand {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
enum Url_Flags {
|
enum Url_Flags {
|
||||||
@ -34,7 +34,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
InsetUrl(): InsetCommand("url"), fd_form_url(0) {
|
InsetUrl() : InsetCommand("url"), fd_form_url(0) {
|
||||||
flag = InsetUrl::URL;
|
flag = InsetUrl::URL;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
///
|
///
|
||||||
~InsetUrl();
|
~InsetUrl();
|
||||||
///
|
///
|
||||||
InsetUrl * Clone() const { return new InsetUrl(getCommand()); }
|
Inset * Clone() const { return new InsetUrl(getCommand()); }
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const { return Inset::URL_CODE; }
|
Inset::Code LyxCode() const { return Inset::URL_CODE; }
|
||||||
///
|
///
|
||||||
|
@ -172,7 +172,7 @@ public:
|
|||||||
class UpdatableInset: public Inset {
|
class UpdatableInset: public Inset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
virtual ~UpdatableInset() {}
|
//virtual ~UpdatableInset() {}
|
||||||
///
|
///
|
||||||
virtual unsigned char Editable() const;
|
virtual unsigned char Editable() const;
|
||||||
|
|
||||||
|
32
src/lyx_cb.C
32
src/lyx_cb.C
@ -820,8 +820,8 @@ void MenuMakeLaTeX(Buffer * buffer)
|
|||||||
buffer->getFileName(),
|
buffer->getFileName(),
|
||||||
".tex", false));
|
".tex", false));
|
||||||
|
|
||||||
FilePtr myfile(s, FilePtr::read);
|
FileInfo fi(s);
|
||||||
if (myfile() &&
|
if (fi.readable() &&
|
||||||
!AskQuestion(_("File already exists:"),
|
!AskQuestion(_("File already exists:"),
|
||||||
MakeDisplayPath(s, 50),
|
MakeDisplayPath(s, 50),
|
||||||
_("Do you want to overwrite the file?"))) {
|
_("Do you want to overwrite the file?"))) {
|
||||||
@ -857,8 +857,8 @@ void MenuMakeLinuxDoc(Buffer *buffer)
|
|||||||
string s = ChangeExtension (buffer->getFileName(),
|
string s = ChangeExtension (buffer->getFileName(),
|
||||||
".sgml", false);
|
".sgml", false);
|
||||||
|
|
||||||
FilePtr myfile(s, FilePtr::read);
|
FileInfo fi(s);
|
||||||
if (myfile() &&
|
if (fi.readable() &&
|
||||||
!AskQuestion(_("File already exists:"),
|
!AskQuestion(_("File already exists:"),
|
||||||
MakeDisplayPath(s, 50),
|
MakeDisplayPath(s, 50),
|
||||||
_("Do you want to overwrite the file?"))) {
|
_("Do you want to overwrite the file?"))) {
|
||||||
@ -890,8 +890,8 @@ void MenuMakeDocBook(Buffer *buffer)
|
|||||||
string s = ChangeExtension (buffer->getFileName(),
|
string s = ChangeExtension (buffer->getFileName(),
|
||||||
".sgml", false);
|
".sgml", false);
|
||||||
|
|
||||||
FilePtr myfile(s, FilePtr::read);
|
FileInfo fi(s);
|
||||||
if (myfile() &&
|
if (fi.readable() &&
|
||||||
!AskQuestion(_("File already exists:"),
|
!AskQuestion(_("File already exists:"),
|
||||||
MakeDisplayPath(s, 50),
|
MakeDisplayPath(s, 50),
|
||||||
_("Do you want to overwrite the file?"))) {
|
_("Do you want to overwrite the file?"))) {
|
||||||
@ -917,8 +917,8 @@ void MenuMakeAscii(Buffer *buffer)
|
|||||||
string s = ChangeExtension (buffer->getFileName(),
|
string s = ChangeExtension (buffer->getFileName(),
|
||||||
".txt", false);
|
".txt", false);
|
||||||
|
|
||||||
FilePtr myfile(s, FilePtr::read);
|
FileInfo fi(s);
|
||||||
if (myfile() &&
|
if (fi.readable() &&
|
||||||
!AskQuestion(_("File already exists:"),
|
!AskQuestion(_("File already exists:"),
|
||||||
MakeDisplayPath(s, 50),
|
MakeDisplayPath(s, 50),
|
||||||
_("Do you want to overwrite the file?"))) {
|
_("Do you want to overwrite the file?"))) {
|
||||||
@ -1086,7 +1086,6 @@ Buffer * NewLyxFile(string const & filename)
|
|||||||
void InsertAsciiFile(string const & f, bool asParagraph)
|
void InsertAsciiFile(string const & f, bool asParagraph)
|
||||||
{
|
{
|
||||||
string fname = f;
|
string fname = f;
|
||||||
LyXParagraph *tmppar;
|
|
||||||
LyXFileDlg fileDlg;
|
LyXFileDlg fileDlg;
|
||||||
|
|
||||||
if (!current_view->getScreen()) return;
|
if (!current_view->getScreen()) return;
|
||||||
@ -1101,15 +1100,20 @@ void InsertAsciiFile(string const & f, bool asParagraph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileInfo fi(fname);
|
FileInfo fi(fname);
|
||||||
FilePtr myfile(fname, FilePtr::read);
|
|
||||||
|
|
||||||
if (!fi.exist() || !fi.readable() || !myfile()) {
|
if (!fi.readable()) {
|
||||||
WriteFSAlert(_("Error! Cannot open specified file:"),
|
WriteFSAlert(_("Error! Specified file is unreadable: "),
|
||||||
MakeDisplayPath(fname, 50));
|
MakeDisplayPath(fname, 50));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmppar = new LyXParagraph;
|
FilePtr myfile(fname, FilePtr::read);
|
||||||
|
if (!myfile()) {
|
||||||
|
WriteFSAlert(_("Error! Cannot open specified file: "),
|
||||||
|
MakeDisplayPath(fname, 50));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LyXParagraph * tmppar = new LyXParagraph;
|
||||||
tmppar->readSimpleWholeFile(myfile);
|
tmppar->readSimpleWholeFile(myfile);
|
||||||
|
|
||||||
// set the end of the string
|
// set the end of the string
|
||||||
|
@ -421,7 +421,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
|||||||
box = LyXFunc::OK;
|
box = LyXFunc::OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
flag = func_status(flag | box);
|
flag |= box;
|
||||||
|
|
||||||
|
|
||||||
return flag;
|
return flag;
|
||||||
@ -2580,8 +2580,8 @@ void LyXFunc::MenuNew(bool fromTemplate)
|
|||||||
|
|
||||||
// Check whether the file already exists
|
// Check whether the file already exists
|
||||||
if (IsLyXFilename(s)) {
|
if (IsLyXFilename(s)) {
|
||||||
FilePtr myfile(s, FilePtr::read);
|
FileInfo fi(s);
|
||||||
if (myfile() &&
|
if (fi.readable() &&
|
||||||
AskQuestion(_("File already exists:"),
|
AskQuestion(_("File already exists:"),
|
||||||
MakeDisplayPath(s, 50),
|
MakeDisplayPath(s, 50),
|
||||||
_("Do you want to open the document?"))) {
|
_("Do you want to open the document?"))) {
|
||||||
|
@ -29,7 +29,6 @@ public:
|
|||||||
ToggleOn = 4,
|
ToggleOn = 4,
|
||||||
ToggleOff = 8
|
ToggleOff = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
LyXFunc(LyXView *);
|
LyXFunc(LyXView *);
|
||||||
|
|
||||||
@ -168,4 +167,10 @@ void LyXFunc::setHintMessage(bool hm)
|
|||||||
show_sc = hm;
|
show_sc = hm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f)
|
||||||
|
{
|
||||||
|
fs = static_cast<LyXFunc::func_status>(fs | f);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,60 +39,53 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "lyx_gui_misc.h"
|
#include "lyx_gui_misc.h"
|
||||||
|
|
||||||
extern void UpdateInset(Inset* inset, bool mark_dirty = true);
|
extern void UpdateInset(Inset * inset, bool mark_dirty = true);
|
||||||
extern void LockedInsetStoreUndo(Undo::undo_kind);
|
extern void LockedInsetStoreUndo(Undo::undo_kind);
|
||||||
extern MiniBuffer *minibuffer;
|
extern MiniBuffer * minibuffer;
|
||||||
extern void ShowLockedInsetCursor(long, long, int, int);
|
extern void ShowLockedInsetCursor(long, long, int, int);
|
||||||
extern void HideLockedInsetCursor(long, long, int, int);
|
extern void HideLockedInsetCursor(long, long, int, int);
|
||||||
extern void FitLockedInsetCursor(long, long, int, int);
|
extern void FitLockedInsetCursor(long, long, int, int);
|
||||||
extern int LockInset(UpdatableInset*);
|
extern int LockInset(UpdatableInset *);
|
||||||
extern int UnlockInset(UpdatableInset*);
|
extern int UnlockInset(UpdatableInset *);
|
||||||
|
|
||||||
|
|
||||||
extern GC canvasGC, mathGC, mathLineGC, latexGC, cursorGC, mathFrameGC;
|
extern GC canvasGC, mathGC, mathLineGC, latexGC, cursorGC, mathFrameGC;
|
||||||
extern char *mathed_label;
|
extern char * mathed_label;
|
||||||
|
|
||||||
extern int mono_video;
|
extern int mono_video;
|
||||||
extern int fast_selection;
|
extern int fast_selection;
|
||||||
|
|
||||||
extern BufferView *current_view;
|
extern BufferView * current_view;
|
||||||
extern BufferList bufferlist;
|
extern BufferList bufferlist;
|
||||||
extern char const *latex_special_chars;
|
extern char const * latex_special_chars;
|
||||||
|
|
||||||
short greek_kb_flag = 0;
|
short greek_kb_flag = 0;
|
||||||
|
|
||||||
LyXFont *Math_Fonts = 0; // this is only used by Whichfont and mathed_init_fonts (Lgb)
|
LyXFont * Math_Fonts = 0; // this is only used by Whichfont and mathed_init_fonts (Lgb)
|
||||||
|
|
||||||
static LyXFont::FONT_SIZE lfont_size = LyXFont::SIZE_NORMAL;
|
static LyXFont::FONT_SIZE lfont_size = LyXFont::SIZE_NORMAL;
|
||||||
|
|
||||||
// local global
|
// local global
|
||||||
static int sel_x, sel_y;
|
static int sel_x, sel_y;
|
||||||
static bool sel_flag;
|
static bool sel_flag;
|
||||||
MathedCursor* InsetFormula::mathcursor = 0;
|
MathedCursor * InsetFormula::mathcursor = 0;
|
||||||
|
|
||||||
|
|
||||||
int MathedInset::df_asc;
|
int MathedInset::df_asc;
|
||||||
int MathedInset::df_des;
|
int MathedInset::df_des;
|
||||||
int MathedInset::df_width;
|
int MathedInset::df_width;
|
||||||
|
|
||||||
// wrong name on this one should be called "IsAscii"
|
|
||||||
inline bool IsAlpha(char c)
|
|
||||||
{
|
|
||||||
return ('A' <= c && c<= 'Z' || 'a' <= c && c<= 'z');
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsDigit(char c)
|
|
||||||
{
|
|
||||||
return ('0' <= c && c <= '9');
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsMacro(short token, int id)
|
inline bool IsMacro(short token, int id)
|
||||||
{
|
{
|
||||||
return (token!= LM_TK_FRAC && token!= LM_TK_SQRT &&
|
return (token != LM_TK_FRAC && token != LM_TK_SQRT &&
|
||||||
!((token == LM_TK_SYM || token == LM_TC_BSYM) && id<255));
|
!((token == LM_TK_SYM || token == LM_TC_BSYM) && id < 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mathedValidate(LaTeXFeatures &features, MathParInset *par);
|
|
||||||
|
static
|
||||||
|
void mathedValidate(LaTeXFeatures & features, MathParInset * par);
|
||||||
|
|
||||||
|
|
||||||
LyXFont WhichFont(short type, int size)
|
LyXFont WhichFont(short type, int size)
|
||||||
{
|
{
|
||||||
@ -157,19 +150,21 @@ LyXFont WhichFont(short type, int size)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type!= LM_TC_TEXTRM)
|
if (type != LM_TC_TEXTRM)
|
||||||
f.setColor(LyXFont::MATH);
|
f.setColor(LyXFont::MATH);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mathed_init_fonts() //removed 'static' because DEC cxx does not
|
void mathed_init_fonts() //removed 'static' because DEC cxx does not
|
||||||
//like it (JMarc)
|
//like it (JMarc)
|
||||||
|
// Probably because this func is declared as a friend in math_defs.h
|
||||||
|
// Lgb
|
||||||
{
|
{
|
||||||
|
|
||||||
Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
|
Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
|
||||||
//at once (JMarc) rc
|
//at once (JMarc) rc
|
||||||
for (int i= 0 ; i<8 ; i++){
|
for (int i = 0 ; i < 8 ; ++i){
|
||||||
Math_Fonts[i] = LyXFont::ALL_SANE;
|
Math_Fonts[i] = LyXFont::ALL_SANE;
|
||||||
}
|
}
|
||||||
Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
|
Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
|
||||||
@ -215,69 +210,73 @@ void mathed_set_font(short type, int size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int mathed_string_width(short type, int size, byte const* s, int ls)
|
int mathed_string_width(short type, int size, byte const * s, int ls)
|
||||||
{
|
{
|
||||||
LyXFont f = WhichFont(type, size);
|
LyXFont f = WhichFont(type, size);
|
||||||
|
|
||||||
byte sx[80];
|
byte sx[80];
|
||||||
if (MathIsBinary(type)) {
|
if (MathIsBinary(type)) {
|
||||||
byte *ps = &sx[0];
|
byte * ps = &sx[0];
|
||||||
for (int i= 0; i<ls && i<75; i++) {
|
for (int i = 0; i < ls && i < 75; ++i) {
|
||||||
*(ps++) = ' ';
|
*(ps++) = ' ';
|
||||||
*(ps++) = s[i];
|
*(ps++) = s[i];
|
||||||
*(ps++) = ' ';
|
*(ps++) = ' ';
|
||||||
}
|
}
|
||||||
*(ps++) = '\0';
|
*(ps++) = '\0';
|
||||||
ls = 3*ls;
|
ls *= 3;
|
||||||
s = &sx[0];
|
s = &sx[0];
|
||||||
}
|
}
|
||||||
return f.textWidth((const char*)s, ls);;
|
return f.textWidth(reinterpret_cast<char const *>(s), ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int mathed_char_width(short type, int size, byte c)
|
int mathed_char_width(short type, int size, byte c)
|
||||||
{
|
{
|
||||||
int t= (MathIsBinary(type)) ? mathed_string_width(type, size, &c, 1):
|
int t = (MathIsBinary(type)) ? mathed_string_width(type, size, &c, 1):
|
||||||
WhichFont(type, size).width(c);
|
WhichFont(type, size).width(c);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mathed_string_height(short type, int size, byte const * s, int ls, int& asc, int& des)
|
|
||||||
|
int mathed_string_height(short type, int size, byte const * s,
|
||||||
|
int ls, int & asc, int & des)
|
||||||
{
|
{
|
||||||
LyXFont font = WhichFont(type, size);
|
LyXFont font = WhichFont(type, size);
|
||||||
asc = des = 0;
|
asc = des = 0;
|
||||||
for (int i= 0; i<ls; i++) {
|
for (int i = 0; i < ls; ++i) {
|
||||||
if (font.descent(s[i]) > des)
|
if (font.descent(s[i]) > des)
|
||||||
des = font.descent(s[i]);
|
des = font.descent(s[i]);
|
||||||
if (font.ascent(s[i]) > asc)
|
if (font.ascent(s[i]) > asc)
|
||||||
asc = font.ascent(s[i]);
|
asc = font.ascent(s[i]);
|
||||||
}
|
}
|
||||||
return asc+des;
|
return asc + des;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mathed_char_height(short type, int size, byte c, int& asc, int& des)
|
|
||||||
|
int mathed_char_height(short type, int size, byte c, int & asc, int & des)
|
||||||
{
|
{
|
||||||
LyXFont font = WhichFont(type, size);
|
LyXFont font = WhichFont(type, size);
|
||||||
asc = des = 0;
|
asc = des = 0;
|
||||||
des = font.descent(c);
|
des = font.descent(c);
|
||||||
asc = font.ascent(c);
|
asc = font.ascent(c);
|
||||||
return asc+des;
|
return asc + des;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// In a near future maybe we use a better fonts renderer
|
// In a near future maybe we use a better fonts renderer
|
||||||
void MathedInset::drawStr(short type, int siz, int x, int y, byte* s, int ls)
|
void MathedInset::drawStr(short type, int siz, int x, int y, byte * s, int ls)
|
||||||
{
|
{
|
||||||
mathed_set_font(type, siz);
|
mathed_set_font(type, siz);
|
||||||
byte sx[80];
|
byte sx[80];
|
||||||
if (MathIsBinary(type)) {
|
if (MathIsBinary(type)) {
|
||||||
byte *ps = &sx[0];
|
byte * ps = &sx[0];
|
||||||
for (int i= 0; i<ls && i < 75; i++) {
|
for (int i = 0; i < ls && i < 75; ++i) {
|
||||||
*(ps++) = ' ';
|
*(ps++) = ' ';
|
||||||
*(ps++) = s[i];
|
*(ps++) = s[i];
|
||||||
*(ps++) = ' ';
|
*(ps++) = ' ';
|
||||||
}
|
}
|
||||||
// *ps = ' ';
|
// *ps = ' ';
|
||||||
ls = 3*ls;
|
ls *= 3;
|
||||||
s = &sx[0];
|
s = &sx[0];
|
||||||
}
|
}
|
||||||
GC gc = (type == LM_TC_TEX) ? latexGC: mathGC;
|
GC gc = (type == LM_TC_TEX) ? latexGC: mathGC;
|
||||||
@ -298,7 +297,8 @@ InsetFormula::InsetFormula(bool display)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
InsetFormula::InsetFormula(MathParInset *p)
|
|
||||||
|
InsetFormula::InsetFormula(MathParInset * p)
|
||||||
{
|
{
|
||||||
par = (p->GetType()>= LM_OT_MPAR) ?
|
par = (p->GetType()>= LM_OT_MPAR) ?
|
||||||
new MathMatrixInset((MathMatrixInset*)p):
|
new MathMatrixInset((MathMatrixInset*)p):
|
||||||
@ -309,26 +309,29 @@ InsetFormula::InsetFormula(MathParInset *p)
|
|||||||
//label = 0;
|
//label = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetFormula::~InsetFormula()
|
InsetFormula::~InsetFormula()
|
||||||
{
|
{
|
||||||
delete par;
|
delete par;
|
||||||
//if (label) delete label;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InsetFormula * InsetFormula::Clone() const
|
|
||||||
|
Inset * InsetFormula::Clone() const
|
||||||
{
|
{
|
||||||
InsetFormula * f = new InsetFormula(par);
|
InsetFormula * f = new InsetFormula(par);
|
||||||
f->label = label;
|
f->label = label;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsetFormula::Write(FILE *file)
|
|
||||||
|
void InsetFormula::Write(FILE * file)
|
||||||
{
|
{
|
||||||
fprintf(file, "Formula ");
|
fprintf(file, "Formula ");
|
||||||
Latex(file, 0);
|
Latex(file, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsetFormula::Latex(FILE *file, signed char fragile)
|
|
||||||
|
int InsetFormula::Latex(FILE * file, signed char fragile)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
//#warning Alejandro, the number of lines is not returned in this case
|
//#warning Alejandro, the number of lines is not returned in this case
|
||||||
@ -339,9 +342,10 @@ int InsetFormula::Latex(FILE *file, signed char fragile)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsetFormula::Latex(string &file, signed char fragile)
|
|
||||||
|
int InsetFormula::Latex(string & file, signed char fragile)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
//#warning Alejandro, the number of lines is not returned in this case
|
//#warning Alejandro, the number of lines is not returned in this case
|
||||||
// This problem will disapear at 0.13.
|
// This problem will disapear at 0.13.
|
||||||
if (fragile < 0)
|
if (fragile < 0)
|
||||||
@ -365,7 +369,7 @@ int InsetFormula::DocBook(string &/*file*/)
|
|||||||
|
|
||||||
|
|
||||||
// Check if uses AMS macros
|
// Check if uses AMS macros
|
||||||
void InsetFormula::Validate(LaTeXFeatures &features) const
|
void InsetFormula::Validate(LaTeXFeatures & features) const
|
||||||
{
|
{
|
||||||
// Validation only necesary if not using an AMS Style
|
// Validation only necesary if not using an AMS Style
|
||||||
if (!features.amsstyle)
|
if (!features.amsstyle)
|
||||||
@ -373,9 +377,9 @@ void InsetFormula::Validate(LaTeXFeatures &features) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::Read(LyXLex &lex)
|
void InsetFormula::Read(LyXLex & lex)
|
||||||
{
|
{
|
||||||
FILE *file = lex.getFile();
|
FILE * file = lex.getFile();
|
||||||
|
|
||||||
mathed_parser_file(file, lex.GetLineNo());
|
mathed_parser_file(file, lex.GetLineNo());
|
||||||
|
|
||||||
@ -383,7 +387,7 @@ void InsetFormula::Read(LyXLex &lex)
|
|||||||
mathed_label = 0;
|
mathed_label = 0;
|
||||||
mathed_parse(0, 0, &par);
|
mathed_parse(0, 0, &par);
|
||||||
par->Metrics();
|
par->Metrics();
|
||||||
disp_flag = (par->GetType()>0);
|
disp_flag = (par->GetType() > 0);
|
||||||
|
|
||||||
// Update line number
|
// Update line number
|
||||||
lex.setLineNo(mathed_parser_lineno());
|
lex.setLineNo(mathed_parser_lineno());
|
||||||
@ -399,45 +403,49 @@ void InsetFormula::Read(LyXLex &lex)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormula::Ascent(LyXFont const &) const
|
int InsetFormula::Ascent(LyXFont const &) const
|
||||||
{
|
{
|
||||||
return par->Ascent() + ((disp_flag) ? 8: 1);
|
return par->Ascent() + ((disp_flag) ? 8 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int InsetFormula::Descent(LyXFont const &) const
|
int InsetFormula::Descent(LyXFont const &) const
|
||||||
{
|
{
|
||||||
return par->Descent() + ((disp_flag) ? 8: 1);
|
return par->Descent() + ((disp_flag) ? 8 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsetFormula::Width(LyXFont const &f) const
|
|
||||||
|
int InsetFormula::Width(LyXFont const & f) const
|
||||||
{
|
{
|
||||||
lfont_size = f.size();
|
lfont_size = f.size();
|
||||||
par->Metrics();
|
par->Metrics();
|
||||||
return par->Width(); //+2;
|
return par->Width(); //+2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsetFormula::Draw(LyXFont f, LyXScreen &scr, int baseline, float &x)
|
|
||||||
|
void InsetFormula::Draw(LyXFont f, LyXScreen & scr, int baseline, float & x)
|
||||||
{
|
{
|
||||||
// This is Alejandros domain so I'll use this
|
// This is Alejandros domain so I'll use this
|
||||||
unsigned long pm = scr.getForeground();
|
unsigned long pm = scr.getForeground();
|
||||||
|
|
||||||
lfont_size = f.size();
|
lfont_size = f.size();
|
||||||
mathed_set_font(LM_TC_TEXTRM, LM_ST_TEXT); // otherwise a segfault could occur
|
mathed_set_font(LM_TC_TEXTRM, LM_ST_TEXT); // otherwise a segfault could occur
|
||||||
// in some XDrawRectangles (i.e. matrix) (Matthias)
|
// in some XDrawRectangles (i.e. matrix) (Matthias)
|
||||||
if (mathcursor && mathcursor->GetPar() == par) {
|
if (mathcursor && mathcursor->GetPar() == par) {
|
||||||
if (mathcursor->Selection()) {
|
if (mathcursor->Selection()) {
|
||||||
int n;
|
int n;
|
||||||
XPoint * p = mathcursor->SelGetArea(n);
|
XPoint * p = mathcursor->SelGetArea(n);
|
||||||
XFillPolygon(fl_display, pm, getGC(gc_selection), //LyXGetSelectionGC(),
|
XFillPolygon(fl_display, pm, getGC(gc_selection),
|
||||||
p, n, Nonconvex, CoordModeOrigin);
|
p, n, Nonconvex, CoordModeOrigin);
|
||||||
}
|
}
|
||||||
mathcursor->Draw(pm, (int)x, baseline);
|
mathcursor->Draw(pm, int(x), baseline);
|
||||||
} else {
|
} else {
|
||||||
// par->Metrics();
|
// par->Metrics();
|
||||||
par->setDrawable(pm);
|
par->setDrawable(pm);
|
||||||
par->Draw((int)x, baseline);
|
par->Draw(int(x), baseline);
|
||||||
}
|
}
|
||||||
x += (float)Width(f);
|
x += float(Width(f));
|
||||||
|
|
||||||
if (par->GetType() == LM_OT_PARN || par->GetType() == LM_OT_MPARN) {
|
if (par->GetType() == LM_OT_PARN || par->GetType() == LM_OT_MPARN) {
|
||||||
char s[80];
|
char s[80];
|
||||||
@ -453,7 +461,6 @@ void InsetFormula::Draw(LyXFont f, LyXScreen &scr, int baseline, float &x)
|
|||||||
} else
|
} else
|
||||||
if (par->GetType() == LM_OT_MPARN) {
|
if (par->GetType() == LM_OT_MPARN) {
|
||||||
MathMatrixInset *mt = (MathMatrixInset*)par;
|
MathMatrixInset *mt = (MathMatrixInset*)par;
|
||||||
//int i= 0;
|
|
||||||
int y;
|
int y;
|
||||||
MathedRowSt const* crow = mt->getRowSt();
|
MathedRowSt const* crow = mt->getRowSt();
|
||||||
while (crow) {
|
while (crow) {
|
||||||
@ -485,7 +492,8 @@ void InsetFormula::Edit(int x, int y)
|
|||||||
sel_x = sel_y = 0;
|
sel_x = sel_y = 0;
|
||||||
sel_flag = false;
|
sel_flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::InsetUnlock()
|
void InsetFormula::InsetUnlock()
|
||||||
{
|
{
|
||||||
if (mathcursor) {
|
if (mathcursor) {
|
||||||
@ -499,13 +507,15 @@ void InsetFormula::InsetUnlock()
|
|||||||
UpdateInset(this, false);
|
UpdateInset(this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Now a symbol can be inserted only if the inset is locked
|
// Now a symbol can be inserted only if the inset is locked
|
||||||
void InsetFormula::InsertSymbol(char const* s)
|
void InsetFormula::InsertSymbol(char const * s)
|
||||||
{
|
{
|
||||||
if (!s || !mathcursor) return;
|
if (!s || !mathcursor) return;
|
||||||
mathcursor->Interpret(s);
|
mathcursor->Interpret(s);
|
||||||
UpdateLocal();
|
UpdateLocal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::GetCursorPos(int& x, int& y) const
|
void InsetFormula::GetCursorPos(int& x, int& y) const
|
||||||
{
|
{
|
||||||
@ -534,10 +544,12 @@ void InsetFormula::ToggleInsetCursor()
|
|||||||
cursor_visible = !cursor_visible;
|
cursor_visible = !cursor_visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsetFormula::ShowInsetCursor(){
|
|
||||||
if (!cursor_visible){
|
void InsetFormula::ShowInsetCursor()
|
||||||
|
{
|
||||||
|
if (!cursor_visible) {
|
||||||
int x, y, asc, desc;
|
int x, y, asc, desc;
|
||||||
if (mathcursor){
|
if (mathcursor) {
|
||||||
mathcursor->GetPos(x, y);
|
mathcursor->GetPos(x, y);
|
||||||
// x -= par->xo;
|
// x -= par->xo;
|
||||||
y -= par->yo;
|
y -= par->yo;
|
||||||
@ -550,11 +562,14 @@ void InsetFormula::ShowInsetCursor(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsetFormula::HideInsetCursor(){
|
|
||||||
|
void InsetFormula::HideInsetCursor()
|
||||||
|
{
|
||||||
if (cursor_visible)
|
if (cursor_visible)
|
||||||
ToggleInsetCursor();
|
ToggleInsetCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::ToggleInsetSelection()
|
void InsetFormula::ToggleInsetSelection()
|
||||||
{
|
{
|
||||||
if (!mathcursor)
|
if (!mathcursor)
|
||||||
@ -572,14 +587,15 @@ void InsetFormula::ToggleInsetSelection()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::display(bool dspf)
|
void InsetFormula::display(bool dspf)
|
||||||
{
|
{
|
||||||
if (dspf!= disp_flag) {
|
if (dspf != disp_flag) {
|
||||||
if (dspf) {
|
if (dspf) {
|
||||||
par->SetType(LM_OT_PAR);
|
par->SetType(LM_OT_PAR);
|
||||||
par->SetStyle(LM_ST_DISPLAY);
|
par->SetStyle(LM_ST_DISPLAY);
|
||||||
} else {
|
} else {
|
||||||
if (par->GetType()>= LM_OT_MPAR) {
|
if (par->GetType() >= LM_OT_MPAR) {
|
||||||
MathParInset * p = new MathParInset(par);
|
MathParInset * p = new MathParInset(par);
|
||||||
delete par;
|
delete par;
|
||||||
par = p;
|
par = p;
|
||||||
@ -588,25 +604,24 @@ void InsetFormula::display(bool dspf)
|
|||||||
}
|
}
|
||||||
par->SetType(LM_OT_MIN);
|
par->SetType(LM_OT_MIN);
|
||||||
par->SetStyle(LM_ST_TEXT);
|
par->SetStyle(LM_ST_TEXT);
|
||||||
if (!label.empty() && par->GetType()!= LM_OT_MPARN) {
|
if (!label.empty() && par->GetType() != LM_OT_MPARN) {
|
||||||
label.clear();
|
label.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disp_flag = dspf;
|
disp_flag = dspf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int InsetFormula::GetNumberOfLabels() const
|
int InsetFormula::GetNumberOfLabels() const
|
||||||
{
|
{
|
||||||
// This is dirty, I know. I'll clean it at 0.13
|
// This is dirty, I know. I'll clean it at 0.13
|
||||||
if (par->GetType() == LM_OT_MPARN) {
|
if (par->GetType() == LM_OT_MPARN) {
|
||||||
MathMatrixInset * mt = (MathMatrixInset*)par;
|
MathMatrixInset * mt = static_cast<MathMatrixInset*>(par);
|
||||||
int nl = 0;
|
int nl = 0;
|
||||||
MathedRowSt const * crow = mt->getRowSt();
|
MathedRowSt const * crow = mt->getRowSt();
|
||||||
while (crow) {
|
while (crow) {
|
||||||
if (crow->getLabel()) nl++;
|
if (crow->getLabel()) ++nl;
|
||||||
crow = crow->getNext();
|
crow = crow->getNext();
|
||||||
}
|
}
|
||||||
return nl;
|
return nl;
|
||||||
@ -624,8 +639,8 @@ string InsetFormula::getLabel(int il) const
|
|||||||
// Correction, the only way to clean this is with a new kernel: 0.13.
|
// Correction, the only way to clean this is with a new kernel: 0.13.
|
||||||
if (par->GetType() == LM_OT_MPARN) {
|
if (par->GetType() == LM_OT_MPARN) {
|
||||||
string lab;
|
string lab;
|
||||||
MathMatrixInset * mt = (MathMatrixInset*)par;
|
MathMatrixInset * mt = static_cast<MathMatrixInset*>(par);
|
||||||
int nl= 0;
|
int nl = 0;
|
||||||
MathedRowSt const * crow = mt->getRowSt();
|
MathedRowSt const * crow = mt->getRowSt();
|
||||||
while (crow) {
|
while (crow) {
|
||||||
if (crow->getLabel()) {
|
if (crow->getLabel()) {
|
||||||
@ -633,7 +648,7 @@ string InsetFormula::getLabel(int il) const
|
|||||||
lab = crow->getLabel();
|
lab = crow->getLabel();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nl++;
|
++nl;
|
||||||
}
|
}
|
||||||
crow = crow->getNext();
|
crow = crow->getNext();
|
||||||
}
|
}
|
||||||
@ -642,13 +657,13 @@ string InsetFormula::getLabel(int il) const
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::UpdateLocal()
|
void InsetFormula::UpdateLocal()
|
||||||
{
|
{
|
||||||
par->Metrics(); // To inform lyx kernel the exact size
|
par->Metrics(); // To inform lyx kernel the exact size
|
||||||
// (there were problems with arrays).
|
// (there were problems with arrays).
|
||||||
UpdateInset(this);
|
UpdateInset(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::InsetButtonRelease(int x, int y, int /*button*/)
|
void InsetFormula::InsetButtonRelease(int x, int y, int /*button*/)
|
||||||
@ -665,6 +680,7 @@ void InsetFormula::InsetButtonRelease(int x, int y, int /*button*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::InsetButtonPress(int x, int y, int /*button*/)
|
void InsetFormula::InsetButtonPress(int x, int y, int /*button*/)
|
||||||
{
|
{
|
||||||
sel_flag = false;
|
sel_flag = false;
|
||||||
@ -675,9 +691,10 @@ void InsetFormula::InsetButtonPress(int x, int y, int /*button*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::InsetMotionNotify(int x, int y, int /*button*/)
|
void InsetFormula::InsetMotionNotify(int x, int y, int /*button*/)
|
||||||
{
|
{
|
||||||
if (sel_x && sel_y && abs(x-sel_x)>4 && !sel_flag) {
|
if (sel_x && sel_y && abs(x-sel_x) > 4 && !sel_flag) {
|
||||||
sel_flag = true;
|
sel_flag = true;
|
||||||
HideInsetCursor();
|
HideInsetCursor();
|
||||||
mathcursor->SetPos(sel_x + par->xo, sel_y + par->yo);
|
mathcursor->SetPos(sel_x + par->xo, sel_y + par->yo);
|
||||||
@ -698,26 +715,29 @@ void InsetFormula::InsetMotionNotify(int x, int y, int /*button*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetFormula::InsetKeyPress(XKeyEvent *)
|
void InsetFormula::InsetKeyPress(XKeyEvent *)
|
||||||
{
|
{
|
||||||
lyxerr[Debug::MATHED] << "Used InsetFormula::InsetKeyPress." << endl;
|
lyxerr[Debug::MATHED] << "Used InsetFormula::InsetKeyPress." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Special Mathed functions
|
// Special Mathed functions
|
||||||
bool InsetFormula::SetNumber(bool numbf)
|
bool InsetFormula::SetNumber(bool numbf)
|
||||||
{
|
{
|
||||||
if (disp_flag) {
|
if (disp_flag) {
|
||||||
short type = par->GetType();
|
short type = par->GetType();
|
||||||
bool oldf = (type == LM_OT_PARN || type == LM_OT_MPARN);
|
bool oldf = (type == LM_OT_PARN || type == LM_OT_MPARN);
|
||||||
if (numbf && !oldf) type++;
|
if (numbf && !oldf) ++type;
|
||||||
if (!numbf && oldf) type--;
|
if (!numbf && oldf) --type;
|
||||||
par->SetType(type);
|
par->SetType(type);
|
||||||
return oldf;
|
return oldf;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|
||||||
|
bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||||
{
|
{
|
||||||
// extern char *dispatch_result;
|
// extern char *dispatch_result;
|
||||||
MathedTextCodes varcode = LM_TC_MIN;
|
MathedTextCodes varcode = LM_TC_MIN;
|
||||||
@ -726,10 +746,11 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
bool space_on = false;
|
bool space_on = false;
|
||||||
bool was_selection = mathcursor->Selection();
|
bool was_selection = mathcursor->Selection();
|
||||||
bool result = true;
|
bool result = true;
|
||||||
static MathSpaceInset* sp= 0;
|
static MathSpaceInset * sp= 0;
|
||||||
|
|
||||||
HideInsetCursor();
|
HideInsetCursor();
|
||||||
if (mathcursor->Selection() && (fast_selection || mono_video)) ToggleInsetSelection();
|
if (mathcursor->Selection() && (fast_selection || mono_video))
|
||||||
|
ToggleInsetSelection();
|
||||||
|
|
||||||
if (mathcursor->getLastCode() == LM_TC_TEX) {
|
if (mathcursor->getLastCode() == LM_TC_TEX) {
|
||||||
varcode = LM_TC_TEX;
|
varcode = LM_TC_TEX;
|
||||||
@ -790,7 +811,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
if (!mathcursor->Left())
|
if (!mathcursor->Left())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!mathcursor-> InMacroMode() && mathcursor->pullArg()) {
|
if (!mathcursor->InMacroMode() && mathcursor->pullArg()) {
|
||||||
UpdateInset(this);
|
UpdateInset(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -858,7 +879,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
// Greek keyboard
|
// Greek keyboard
|
||||||
case LFUN_GREEK_TOGGLE:
|
case LFUN_GREEK_TOGGLE:
|
||||||
{
|
{
|
||||||
greek_kb_flag = (greek_kb_flag) ? 0: 2;
|
greek_kb_flag = (greek_kb_flag) ? 0 : 2;
|
||||||
if (greek_kb_flag)
|
if (greek_kb_flag)
|
||||||
minibuffer->Set(_("Math greek keyboard on"));
|
minibuffer->Set(_("Math greek keyboard on"));
|
||||||
else
|
else
|
||||||
@ -925,7 +946,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
|
|
||||||
case LFUN_MATH_SIZE:
|
case LFUN_MATH_SIZE:
|
||||||
if (arg) {
|
if (arg) {
|
||||||
latexkeys *l = in_word_set (arg, strlen(arg));
|
latexkeys * l = in_word_set (arg, strlen(arg));
|
||||||
int sz = (l) ? l->id: -1;
|
int sz = (l) ? l->id: -1;
|
||||||
mathcursor->SetSize(sz);
|
mathcursor->SetSize(sz);
|
||||||
UpdateLocal();
|
UpdateLocal();
|
||||||
@ -945,22 +966,22 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
int k, m, n;
|
int k, m, n;
|
||||||
char s[80], arg2[80];
|
char s[80], arg2[80];
|
||||||
// This is just so that too long args won't ooze out of s.
|
// This is just so that too long args won't ooze out of s.
|
||||||
strncpy(arg2, arg, 80); arg2[79]= (char)0;
|
strncpy(arg2, arg, 80); arg2[79]= '\0';
|
||||||
k = sscanf(arg2, "%d %d %s", &m, &n, s);
|
k = sscanf(arg2, "%d %d %s", &m, &n, s);
|
||||||
s[79] = (char)0;
|
s[79] = '\0';
|
||||||
|
|
||||||
if (k<1) {
|
if (k < 1) {
|
||||||
m = n = 1;
|
m = n = 1;
|
||||||
} else if (k == 1) {
|
} else if (k == 1) {
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathMatrixInset *p = new MathMatrixInset(m, n);
|
MathMatrixInset * p = new MathMatrixInset(m, n);
|
||||||
if (mathcursor && p) {
|
if (mathcursor && p) {
|
||||||
if (k>2 && (int)strlen(s)>m)
|
if (k > 2 && int(strlen(s)) > m)
|
||||||
p->SetAlign(s[0], &s[1]);
|
p->SetAlign(s[0], &s[1]);
|
||||||
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
||||||
UpdateLocal();
|
UpdateLocal();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -970,16 +991,16 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
LockedInsetStoreUndo(Undo::INSERT);
|
LockedInsetStoreUndo(Undo::INSERT);
|
||||||
char lf[40], rg[40], arg2[40];
|
char lf[40], rg[40], arg2[40];
|
||||||
int ilf = '(', irg = '.';
|
int ilf = '(', irg = '.';
|
||||||
latexkeys *l;
|
latexkeys * l;
|
||||||
string vdelim("(){}[]./|");
|
string vdelim("(){}[]./|");
|
||||||
|
|
||||||
if (!arg) break;
|
if (!arg) break;
|
||||||
strncpy(arg2, arg, 40); arg2[39]= (char)0;
|
strncpy(arg2, arg, 40); arg2[39]= '\0';
|
||||||
int n = sscanf(arg2, "%s %s", lf, rg);
|
int n = sscanf(arg2, "%s %s", lf, rg);
|
||||||
lf[39] = (char)0; rg[39] = (char)0;
|
lf[39] = '\0'; rg[39] = '\0';
|
||||||
|
|
||||||
if (n>0) {
|
if (n > 0) {
|
||||||
if (IsDigit(lf[0]))
|
if (isdigit(lf[0]))
|
||||||
ilf = atoi(lf);
|
ilf = atoi(lf);
|
||||||
else
|
else
|
||||||
if (lf[1]) {
|
if (lf[1]) {
|
||||||
@ -990,8 +1011,8 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
if (vdelim.find(lf[0]) != string::npos)
|
if (vdelim.find(lf[0]) != string::npos)
|
||||||
ilf = lf[0];
|
ilf = lf[0];
|
||||||
|
|
||||||
if (n>1) {
|
if (n > 1) {
|
||||||
if (IsDigit(rg[0]))
|
if (isdigit(rg[0]))
|
||||||
irg = atoi(rg);
|
irg = atoi(rg);
|
||||||
else
|
else
|
||||||
if (rg[1]) {
|
if (rg[1]) {
|
||||||
@ -1003,7 +1024,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MathDelimInset* p = new MathDelimInset(ilf, irg);
|
MathDelimInset * p = new MathDelimInset(ilf, irg);
|
||||||
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
||||||
UpdateLocal();
|
UpdateLocal();
|
||||||
break;
|
break;
|
||||||
@ -1022,11 +1043,11 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
case LFUN_INSERT_LABEL:
|
case LFUN_INSERT_LABEL:
|
||||||
{
|
{
|
||||||
LockedInsetStoreUndo(Undo::INSERT);
|
LockedInsetStoreUndo(Undo::INSERT);
|
||||||
if (par->GetType()<LM_OT_PAR) break;
|
if (par->GetType() < LM_OT_PAR) break;
|
||||||
string lb = arg;
|
string lb = arg;
|
||||||
if (lb.empty())
|
if (lb.empty())
|
||||||
lb = string(askForText(_("Enter new label to insert:")));
|
lb = string(askForText(_("Enter new label to insert:")));
|
||||||
if (!lb.empty() && lb[0]> ' ') {
|
if (!lb.empty() && lb[0] > ' ') {
|
||||||
SetNumber(true);
|
SetNumber(true);
|
||||||
if (par->GetType() == LM_OT_MPARN) {
|
if (par->GetType() == LM_OT_MPARN) {
|
||||||
mathcursor->setLabel(lb.c_str());
|
mathcursor->setLabel(lb.c_str());
|
||||||
@ -1039,7 +1060,6 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
UpdateLocal();
|
UpdateLocal();
|
||||||
} else
|
} else
|
||||||
label.clear();
|
label.clear();
|
||||||
//label = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1174,8 +1194,10 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (was_macro!= mathcursor->InMacroMode()&&action>= 0&&action!= LFUN_BACKSPACE)
|
if (was_macro != mathcursor->InMacroMode()
|
||||||
UpdateLocal();
|
&& action >= 0
|
||||||
|
&& action != LFUN_BACKSPACE)
|
||||||
|
UpdateLocal();
|
||||||
if (sp && !space_on) sp = 0;
|
if (sp && !space_on) sp = 0;
|
||||||
if (mathcursor->Selection() || (was_selection && !(fast_selection || mono_video)))
|
if (mathcursor->Selection() || (was_selection && !(fast_selection || mono_video)))
|
||||||
ToggleInsetSelection();
|
ToggleInsetSelection();
|
||||||
@ -1192,12 +1214,12 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
|||||||
void
|
void
|
||||||
MathFuncInset::Draw(int x, int y)
|
MathFuncInset::Draw(int x, int y)
|
||||||
{
|
{
|
||||||
if (name && name[0]>' ') {
|
if (name && name[0] > ' ') {
|
||||||
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
|
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
|
||||||
font.setLatex(LyXFont::ON);
|
font.setLatex(LyXFont::ON);
|
||||||
x += (font.textWidth("I", 1)+3)/4;
|
x += (font.textWidth("I", 1)+3)/4;
|
||||||
if (mono_video) {
|
if (mono_video) {
|
||||||
int a= font.maxAscent(), d= font.maxDescent();
|
int a = font.maxAscent(), d = font.maxDescent();
|
||||||
XFillRectangle (fl_display, pm, getGC(gc_copy),
|
XFillRectangle (fl_display, pm, getGC(gc_copy),
|
||||||
x, y-a,
|
x, y-a,
|
||||||
font.textWidth(name, strlen(name)), a+d);
|
font.textWidth(name, strlen(name)), a+d);
|
||||||
@ -1214,24 +1236,26 @@ void MathFuncInset::Metrics()
|
|||||||
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
|
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
|
||||||
font.setLatex(LyXFont::ON);
|
font.setLatex(LyXFont::ON);
|
||||||
width = font.textWidth(name, ln) + font.textWidth("I", 1)/2;
|
width = font.textWidth(name, ln) + font.textWidth("I", 1)/2;
|
||||||
mathed_string_height(LM_TC_TEXTRM, size, (byte const *) name,
|
mathed_string_height(LM_TC_TEXTRM, size,
|
||||||
|
reinterpret_cast<unsigned char const *>(name),
|
||||||
strlen(name), ascent, descent);
|
strlen(name), ascent, descent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mathedValidate(LaTeXFeatures &features, MathParInset *par)
|
static
|
||||||
|
void mathedValidate(LaTeXFeatures & features, MathParInset * par)
|
||||||
{
|
{
|
||||||
MathedIter it(par->GetData());
|
MathedIter it(par->GetData());
|
||||||
|
|
||||||
while (it.OK() && !(features.binom && features.boldsymbol)) {
|
while (it.OK() && !(features.binom && features.boldsymbol)) {
|
||||||
if (it.IsInset()) {
|
if (it.IsInset()) {
|
||||||
if(it.IsActive()) {
|
if(it.IsActive()) {
|
||||||
MathParInset *p = it.GetActiveInset();
|
MathParInset * p = it.GetActiveInset();
|
||||||
if (!features.binom && p->GetType() == LM_OT_MACRO &&
|
if (!features.binom && p->GetType() == LM_OT_MACRO &&
|
||||||
strcmp(p->GetName(), "binom") == 0) {
|
strcmp(p->GetName(), "binom") == 0) {
|
||||||
features.binom = true;
|
features.binom = true;
|
||||||
} else {
|
} else {
|
||||||
for (int i= 0; i<= p->getMaxArgumentIdx(); i++) {
|
for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) {
|
||||||
p->setArgumentIdx(i);
|
p->setArgumentIdx(i);
|
||||||
mathedValidate(features, p);
|
mathedValidate(features, p);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
///
|
///
|
||||||
void Validate(LaTeXFeatures &) const;
|
void Validate(LaTeXFeatures &) const;
|
||||||
///
|
///
|
||||||
InsetFormula * Clone() const;
|
Inset * Clone() const;
|
||||||
///
|
///
|
||||||
Inset::Code LyxCode() const { return Inset::MATH_CODE; }
|
Inset::Code LyxCode() const { return Inset::MATH_CODE; }
|
||||||
///
|
///
|
||||||
|
@ -60,7 +60,7 @@ InsetFormulaMacro::~InsetFormulaMacro()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetFormulaMacro * InsetFormulaMacro::Clone() const
|
Inset * InsetFormulaMacro::Clone() const
|
||||||
{
|
{
|
||||||
return new InsetFormulaMacro(name);
|
return new InsetFormulaMacro(name);
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
|
|
||||||
#include "formula.h"
|
#include "formula.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MathMacroTemplate;
|
class MathMacroTemplate;
|
||||||
|
|
||||||
|
|
||||||
@ -35,49 +32,47 @@ public:
|
|||||||
///
|
///
|
||||||
InsetFormulaMacro();
|
InsetFormulaMacro();
|
||||||
///
|
///
|
||||||
InsetFormulaMacro(string name, int na= 0, bool env= false);
|
InsetFormulaMacro(string name, int na = 0, bool env = false);
|
||||||
///
|
///
|
||||||
~InsetFormulaMacro();
|
~InsetFormulaMacro();
|
||||||
///
|
///
|
||||||
int Ascent(LyXFont const &font) const;
|
int Ascent(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
int Descent(LyXFont const &font) const;
|
int Descent(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
int Width(LyXFont const &font) const;
|
int Width(LyXFont const & font) const;
|
||||||
///
|
///
|
||||||
void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x);
|
void Draw(LyXFont font, LyXScreen & scr, int baseline, float & x);
|
||||||
///
|
///
|
||||||
void Read(LyXLex &lex);
|
void Read(LyXLex & lex);
|
||||||
///
|
///
|
||||||
void Write(FILE *file);
|
void Write(FILE * file);
|
||||||
///
|
///
|
||||||
// void Read(LyXLex &lex);
|
int Latex(FILE * file, signed char fragile);
|
||||||
///
|
///
|
||||||
int Latex(FILE *file, signed char fragile);
|
int Latex(string & file, signed char fragile);
|
||||||
///
|
///
|
||||||
int Latex(string &file, signed char fragile);
|
int Linuxdoc(string & file);
|
||||||
///
|
///
|
||||||
int Linuxdoc(string &file);
|
int DocBook(string & file);
|
||||||
///
|
///
|
||||||
int DocBook(string &file);
|
Inset * Clone() const;
|
||||||
///
|
|
||||||
InsetFormulaMacro * Clone() const;
|
|
||||||
|
|
||||||
/// what appears in the minibuffer when opening
|
/// what appears in the minibuffer when opening
|
||||||
char const* EditMessage() {return "Math macro editor mode";}
|
char const * EditMessage() {return "Math macro editor mode";}
|
||||||
///
|
///
|
||||||
void Edit(int x, int y);
|
void Edit(int x, int y);
|
||||||
///
|
///
|
||||||
void InsetUnlock();
|
void InsetUnlock();
|
||||||
|
|
||||||
bool LocalDispatch(int, char const*);
|
bool LocalDispatch(int, char const *);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void UpdateLocal();
|
void UpdateLocal();
|
||||||
private:
|
private:
|
||||||
bool opened;
|
bool opened;
|
||||||
string name;
|
string name;
|
||||||
class MathMacroTemplate* tmacro;
|
class MathMacroTemplate * tmacro;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ class MathParInset: public MathedInset {
|
|||||||
///
|
///
|
||||||
virtual ~MathParInset();
|
virtual ~MathParInset();
|
||||||
///
|
///
|
||||||
virtual MathParInset * Clone();
|
virtual MathedInset * Clone();
|
||||||
|
|
||||||
/// Draw the object on a drawable
|
/// Draw the object on a drawable
|
||||||
virtual void Draw(int x, int baseline);
|
virtual void Draw(int x, int baseline);
|
||||||
@ -482,7 +482,7 @@ class MathMatrixInset: public MathParInset {
|
|||||||
///
|
///
|
||||||
MathMatrixInset(MathMatrixInset *);
|
MathMatrixInset(MathMatrixInset *);
|
||||||
///
|
///
|
||||||
MathMatrixInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
virtual ~MathMatrixInset();
|
virtual ~MathMatrixInset();
|
||||||
///
|
///
|
||||||
|
@ -52,8 +52,8 @@ MathedInset::MathedInset(MathedInset * inset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathFuncInset::MathFuncInset(char const * nm, short ot, short st):
|
MathFuncInset::MathFuncInset(char const * nm, short ot, short st)
|
||||||
MathedInset("", ot, st)
|
: MathedInset("", ot, st)
|
||||||
{
|
{
|
||||||
ln = 0;
|
ln = 0;
|
||||||
lims = (GetType() == LM_OT_FUNCLIM);
|
lims = (GetType() == LM_OT_FUNCLIM);
|
||||||
@ -66,31 +66,26 @@ MathFuncInset::MathFuncInset(char const * nm, short ot, short st):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MathFuncInset * MathFuncInset::Clone()
|
|
||||||
|
MathedInset * MathFuncInset::Clone()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
MathedInset *l = new MathFuncInset(name, GetType(), GetStyle());
|
|
||||||
return l;
|
|
||||||
#endif
|
|
||||||
return new MathFuncInset(name, GetType(), GetStyle());
|
return new MathFuncInset(name, GetType(), GetStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
MathSpaceInset::MathSpaceInset(int sp, short ot, short st):
|
|
||||||
MathedInset("", ot, st), space(sp)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MathSpaceInset * MathSpaceInset::Clone()
|
MathSpaceInset::MathSpaceInset(int sp, short ot, short st)
|
||||||
|
: MathedInset("", ot, st), space(sp)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
MathedInset * MathSpaceInset::Clone()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
MathedInset *l = new MathSpaceInset(space, GetType(), GetStyle());
|
|
||||||
return l;
|
|
||||||
#endif
|
|
||||||
return new MathSpaceInset(space, GetType(), GetStyle());
|
return new MathSpaceInset(space, GetType(), GetStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
MathParInset::MathParInset(short st, char const * nm, short ot):
|
|
||||||
MathedInset(nm, ot, st)
|
MathParInset::MathParInset(short st, char const * nm, short ot)
|
||||||
|
: MathedInset(nm, ot, st)
|
||||||
{
|
{
|
||||||
array = 0;
|
array = 0;
|
||||||
ascent = 8;
|
ascent = 8;
|
||||||
@ -101,7 +96,9 @@ MathParInset::MathParInset(short st, char const * nm, short ot):
|
|||||||
flag |= LMPF_SCRIPT;
|
flag |= LMPF_SCRIPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathParInset::MathParInset(MathParInset * p): MathedInset(p)
|
|
||||||
|
MathParInset::MathParInset(MathParInset * p)
|
||||||
|
: MathedInset(p)
|
||||||
{
|
{
|
||||||
flag = p->flag;
|
flag = p->flag;
|
||||||
p->setArgumentIdx(0);
|
p->setArgumentIdx(0);
|
||||||
@ -120,12 +117,8 @@ MathParInset::~MathParInset()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathParInset * MathParInset::Clone()
|
MathedInset * MathParInset::Clone()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
MathParInset * p = new MathParInset(this);
|
|
||||||
return p;
|
|
||||||
#endif
|
|
||||||
return new MathParInset(this);
|
return new MathParInset(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,12 +141,11 @@ void MathParInset::SetData(LyxArrayBase * a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathSqrtInset::MathSqrtInset(short st): MathParInset(st, "sqrt", LM_OT_SQRT)
|
MathSqrtInset::MathSqrtInset(short st)
|
||||||
{
|
: MathParInset(st, "sqrt", LM_OT_SQRT) {}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MathSqrtInset * MathSqrtInset::Clone()
|
MathedInset * MathSqrtInset::Clone()
|
||||||
{
|
{
|
||||||
MathSqrtInset * p = new MathSqrtInset(GetStyle());
|
MathSqrtInset * p = new MathSqrtInset(GetStyle());
|
||||||
MathedIter it(array);
|
MathedIter it(array);
|
||||||
@ -164,16 +156,18 @@ MathSqrtInset * MathSqrtInset::Clone()
|
|||||||
|
|
||||||
bool MathSqrtInset::Inside(int x, int y)
|
bool MathSqrtInset::Inside(int x, int y)
|
||||||
{
|
{
|
||||||
return (x>= xo-hmax && x<= xo+width-hmax && y<= yo+descent && y>= yo-ascent);
|
return x >= xo - hmax
|
||||||
|
&& x <= xo + width - hmax
|
||||||
|
&& y <= yo + descent
|
||||||
|
&& y >= yo - ascent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathDelimInset::MathDelimInset(int l, int r, short st):
|
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) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MathDelimInset * MathDelimInset::Clone()
|
|
||||||
|
MathedInset * MathDelimInset::Clone()
|
||||||
{
|
{
|
||||||
MathDelimInset * p = new MathDelimInset(left, right, GetStyle());
|
MathDelimInset * p = new MathDelimInset(left, right, GetStyle());
|
||||||
MathedIter it(array);
|
MathedIter it(array);
|
||||||
@ -182,13 +176,14 @@ MathDelimInset * MathDelimInset::Clone()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathDecorationInset::MathDecorationInset(int d, short st):
|
MathDecorationInset::MathDecorationInset(int d, short st)
|
||||||
MathParInset(st, "", LM_OT_DECO), deco(d)
|
: MathParInset(st, "", LM_OT_DECO), deco(d)
|
||||||
{
|
{
|
||||||
upper = (deco!= LM_underline && deco!= LM_underbrace);
|
upper = (deco!= LM_underline && deco!= LM_underbrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
MathDecorationInset * MathDecorationInset::Clone()
|
|
||||||
|
MathedInset * MathDecorationInset::Clone()
|
||||||
{
|
{
|
||||||
MathDecorationInset * p = new MathDecorationInset(deco, GetStyle());
|
MathDecorationInset * p = new MathDecorationInset(deco, GetStyle());
|
||||||
MathedIter it(array);
|
MathedIter it(array);
|
||||||
@ -196,7 +191,9 @@ MathDecorationInset * MathDecorationInset::Clone()
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathFracInset::MathFracInset(short ot): MathParInset(LM_ST_TEXT, "frac", ot)
|
|
||||||
|
MathFracInset::MathFracInset(short ot)
|
||||||
|
: MathParInset(LM_ST_TEXT, "frac", ot)
|
||||||
{
|
{
|
||||||
|
|
||||||
den = new MathParInset(LM_ST_TEXT); // this leaks
|
den = new MathParInset(LM_ST_TEXT); // this leaks
|
||||||
@ -208,12 +205,14 @@ MathFracInset::MathFracInset(short ot): MathParInset(LM_ST_TEXT, "frac", ot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathFracInset::~MathFracInset()
|
MathFracInset::~MathFracInset()
|
||||||
{
|
{
|
||||||
delete den;
|
delete den;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathFracInset * MathFracInset::Clone()
|
|
||||||
|
MathedInset * MathFracInset::Clone()
|
||||||
{
|
{
|
||||||
MathFracInset * p = new MathFracInset(GetType());
|
MathFracInset * p = new MathFracInset(GetType());
|
||||||
MathedIter itn(array);
|
MathedIter itn(array);
|
||||||
@ -224,6 +223,7 @@ MathFracInset * MathFracInset::Clone()
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MathFracInset::setArgumentIdx(int i)
|
bool MathFracInset::setArgumentIdx(int i)
|
||||||
{
|
{
|
||||||
if (i == 0 || i == 1) {
|
if (i == 0 || i == 1) {
|
||||||
@ -238,15 +238,19 @@ void MathFracInset::SetStyle(short st)
|
|||||||
{
|
{
|
||||||
MathParInset::SetStyle(st);
|
MathParInset::SetStyle(st);
|
||||||
dh = 0;
|
dh = 0;
|
||||||
den->SetStyle((size == LM_ST_DISPLAY) ? (short)LM_ST_TEXT: size);
|
den->SetStyle((size == LM_ST_DISPLAY) ?
|
||||||
|
static_cast<short>(LM_ST_TEXT)
|
||||||
|
: size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFracInset::SetData(LyxArrayBase * n, LyxArrayBase * d)
|
void MathFracInset::SetData(LyxArrayBase * n, LyxArrayBase * d)
|
||||||
{
|
{
|
||||||
den->SetData(d);
|
den->SetData(d);
|
||||||
MathParInset::SetData(n);
|
MathParInset::SetData(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFracInset::SetData(LyxArrayBase * d)
|
void MathFracInset::SetData(LyxArrayBase * d)
|
||||||
{
|
{
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
@ -256,6 +260,7 @@ void MathFracInset::SetData(LyxArrayBase * d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFracInset::GetXY(int & x, int & y) const
|
void MathFracInset::GetXY(int & x, int & y) const
|
||||||
{
|
{
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
@ -263,7 +268,8 @@ void MathFracInset::GetXY(int & x, int & y) const
|
|||||||
else
|
else
|
||||||
den->GetXY(x, y);
|
den->GetXY(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyxArrayBase * MathFracInset::GetData()
|
LyxArrayBase * MathFracInset::GetData()
|
||||||
{
|
{
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
@ -275,11 +281,12 @@ LyxArrayBase * MathFracInset::GetData()
|
|||||||
|
|
||||||
bool MathFracInset::Inside(int x, int y)
|
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 && y<= yo+descent && y>= yo-ascent);
|
return x >= xx && x <= xx + width && y <= yo + descent && y >= yo - ascent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathFracInset::SetFocus(int /*x*/, int y)
|
void MathFracInset::SetFocus(int /*x*/, int y)
|
||||||
{
|
{
|
||||||
// lyxerr << "y " << y << " " << yo << " " << den->yo << " ";
|
// lyxerr << "y " << y << " " << yo << " " << den->yo << " ";
|
||||||
@ -287,49 +294,49 @@ void MathFracInset::SetFocus(int /*x*/, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathMatrixInset::MathMatrixInset(int m, int n, short st):
|
MathMatrixInset::MathMatrixInset(int m, int n, short st)
|
||||||
MathParInset(st, "array", LM_OT_MATRIX), nc(m)
|
: MathParInset(st, "array", LM_OT_MATRIX), nc(m)
|
||||||
{
|
{
|
||||||
ws = new int[nc];
|
ws = new int[nc];
|
||||||
v_align = 0;
|
v_align = 0;
|
||||||
h_align = new char[nc+1];
|
h_align = new char[nc + 1];
|
||||||
for (int i = 0; i < nc; i++) h_align[i] = 'c';
|
for (int i = 0; i < nc; ++i) h_align[i] = 'c';
|
||||||
h_align[nc] = '\0';
|
h_align[nc] = '\0';
|
||||||
nr = 0;
|
nr = 0;
|
||||||
row = 0;
|
row = 0;
|
||||||
flag = 15;
|
flag = 15;
|
||||||
if (n>0) {
|
if (n > 0) {
|
||||||
row = new MathedRowSt(nc+1);
|
row = new MathedRowSt(nc+1);
|
||||||
MathedXIter it(this);
|
MathedXIter it(this);
|
||||||
for (int j = 1; j < n; j++) it.addRow();
|
for (int j = 1; j < n; ++j) it.addRow();
|
||||||
nr = n;
|
nr = n;
|
||||||
if (nr == 1 && nc>1) {
|
if (nr == 1 && nc > 1) {
|
||||||
for (int j = 0; j < nc - 1; j++)
|
for (int j = 0; j < nc - 1; ++j)
|
||||||
it.Insert('T', LM_TC_TAB);
|
it.Insert('T', LM_TC_TAB);
|
||||||
}
|
}
|
||||||
} else if (n<0) {
|
} else if (n < 0) {
|
||||||
row = new MathedRowSt(nc+1);
|
row = new MathedRowSt(nc + 1);
|
||||||
nr = 1;
|
nr = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathMatrixInset::MathMatrixInset(MathMatrixInset * mt):
|
MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
|
||||||
MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType())
|
: MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType())
|
||||||
{
|
{
|
||||||
nr = 0;
|
nr = 0;
|
||||||
nc = mt->nc;
|
nc = mt->nc;
|
||||||
ws = new int[nc];
|
ws = new int[nc];
|
||||||
h_align = new char[nc+1];
|
h_align = new char[nc + 1];
|
||||||
strcpy(h_align, mt->GetAlign(&v_align));
|
strcpy(h_align, mt->GetAlign(&v_align));
|
||||||
MathedIter it;
|
MathedIter it;
|
||||||
it.SetData(mt->GetData());
|
it.SetData(mt->GetData());
|
||||||
array = it.Copy();
|
array = it.Copy();
|
||||||
if (mt->row != 0) {
|
if (mt->row != 0) {
|
||||||
MathedRowSt *r, *ro= 0, *mrow = mt->row;
|
MathedRowSt * r, * ro= 0, * mrow = mt->row;
|
||||||
mrow = mt->row;
|
//mrow = mt->row; // This must be redundant...
|
||||||
while (mrow) {
|
while (mrow) {
|
||||||
r = new MathedRowSt(nc+1);
|
r = new MathedRowSt(nc + 1);
|
||||||
r->numbered = mrow->numbered;
|
r->numbered = mrow->numbered;
|
||||||
if (mrow->label)
|
if (mrow->label)
|
||||||
r->label = strnew(mrow->label);
|
r->label = strnew(mrow->label);
|
||||||
@ -339,7 +346,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset * mt):
|
|||||||
ro->next = r;
|
ro->next = r;
|
||||||
mrow = mrow->next;
|
mrow = mrow->next;
|
||||||
ro = r;
|
ro = r;
|
||||||
nr++;
|
++nr;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
row = 0;
|
row = 0;
|
||||||
@ -359,13 +366,14 @@ MathMatrixInset::~MathMatrixInset()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MathMatrixInset * MathMatrixInset::Clone()
|
|
||||||
{
|
MathedInset * MathMatrixInset::Clone()
|
||||||
MathMatrixInset * mt = new MathMatrixInset(this);
|
{
|
||||||
return mt;
|
return new MathMatrixInset(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MathMatrixInset::SetAlign(char vv, char const* hh)
|
|
||||||
|
void MathMatrixInset::SetAlign(char vv, char const * hh)
|
||||||
{
|
{
|
||||||
v_align = vv;
|
v_align = vv;
|
||||||
strncpy(h_align, hh, nc);
|
strncpy(h_align, hh, nc);
|
||||||
@ -377,29 +385,29 @@ void MathMatrixInset::SetData(LyxArrayBase * a)
|
|||||||
{
|
{
|
||||||
if (!a) return;
|
if (!a) return;
|
||||||
MathedIter it(a);
|
MathedIter it(a);
|
||||||
int nn = nc-1;
|
int nn = nc - 1;
|
||||||
nr = 1;
|
nr = 1;
|
||||||
// count tabs per row
|
// count tabs per row
|
||||||
while (it.OK()) {
|
while (it.OK()) {
|
||||||
if (it.IsTab()) {
|
if (it.IsTab()) {
|
||||||
if (nn<0) {
|
if (nn < 0) {
|
||||||
it.Delete();
|
it.Delete();
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// it.Next();
|
// it.Next();
|
||||||
nn--;
|
--nn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (it.IsCR()) {
|
if (it.IsCR()) {
|
||||||
while (nn>0) {
|
while (nn > 0) {
|
||||||
it.Insert(' ', LM_TC_TAB);
|
it.Insert(' ', LM_TC_TAB);
|
||||||
nn--;
|
--nn;
|
||||||
}
|
}
|
||||||
nn = nc-1;
|
nn = nc - 1;
|
||||||
nr++;
|
++nr;
|
||||||
}
|
}
|
||||||
it.Next();
|
it.Next();
|
||||||
}
|
}
|
||||||
it.Reset();
|
it.Reset();
|
||||||
|
|
||||||
// Automatically inserts tabs around bops
|
// Automatically inserts tabs around bops
|
||||||
@ -413,10 +421,11 @@ void MathMatrixInset::Draw(int x, int baseline)
|
|||||||
MathParInset::Draw(x, baseline);
|
MathParInset::Draw(x, baseline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MathMatrixInset::Metrics()
|
void MathMatrixInset::Metrics()
|
||||||
{
|
{
|
||||||
int i, /*cy,*/ hl, h= 0;
|
int i, hl, h= 0;
|
||||||
MathedRowSt *cprow= 0, *cxrow;
|
MathedRowSt * cprow= 0, * cxrow;
|
||||||
|
|
||||||
if (!row) {
|
if (!row) {
|
||||||
// lyxerr << " MIDA ";
|
// lyxerr << " MIDA ";
|
||||||
@ -427,14 +436,14 @@ void MathMatrixInset::Metrics()
|
|||||||
// Clean the arrays
|
// Clean the arrays
|
||||||
cxrow = row;
|
cxrow = row;
|
||||||
while (cxrow) {
|
while (cxrow) {
|
||||||
for (i= 0; i<= nc; i++) cxrow->w[i] = 0;
|
for (i = 0; i <= nc; ++i) cxrow->w[i] = 0;
|
||||||
cxrow = cxrow->next;
|
cxrow = cxrow->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basic metrics
|
// Basic metrics
|
||||||
MathParInset::Metrics();
|
MathParInset::Metrics();
|
||||||
|
|
||||||
if (nc<= 1 && !row->next) {
|
if (nc <= 1 && !row->next) {
|
||||||
row->asc = ascent;
|
row->asc = ascent;
|
||||||
row->desc = descent;
|
row->desc = descent;
|
||||||
}
|
}
|
||||||
@ -442,7 +451,7 @@ void MathMatrixInset::Metrics()
|
|||||||
// Vertical positions of each row
|
// Vertical positions of each row
|
||||||
cxrow = row;
|
cxrow = row;
|
||||||
while (cxrow) {
|
while (cxrow) {
|
||||||
for (i= 0; i<nc; i++) {
|
for (i = 0; i < nc; ++i) {
|
||||||
if (cxrow == row || ws[i]<cxrow->w[i]) ws[i]= cxrow->w[i];
|
if (cxrow == row || ws[i]<cxrow->w[i]) ws[i]= cxrow->w[i];
|
||||||
if (cxrow->next == 0 && ws[i] == 0) ws[i] = df_width;
|
if (cxrow->next == 0 && ws[i] == 0) ws[i] = df_width;
|
||||||
}
|
}
|
||||||
@ -461,7 +470,7 @@ void MathMatrixInset::Metrics()
|
|||||||
switch (v_align) {
|
switch (v_align) {
|
||||||
case 't': ascent = row->y; break;
|
case 't': ascent = row->y; break;
|
||||||
case 'b': ascent = h - hl; break;
|
case 'b': ascent = h - hl; break;
|
||||||
default: ascent = (row->next) ? h/2: h - hl; break;
|
default: ascent = (row->next) ? h / 2: h - hl; break;
|
||||||
}
|
}
|
||||||
descent = h - ascent + 2;
|
descent = h - ascent + 2;
|
||||||
|
|
||||||
@ -470,10 +479,10 @@ void MathMatrixInset::Metrics()
|
|||||||
cxrow = row;
|
cxrow = row;
|
||||||
width = MATH_COLSEP;
|
width = MATH_COLSEP;
|
||||||
while (cxrow) {
|
while (cxrow) {
|
||||||
int rg= MATH_COLSEP, ww, lf= 0, *w = cxrow->w;
|
int rg = MATH_COLSEP, ww, lf = 0, * w = cxrow->w;
|
||||||
for (i= 0; i<nc; i++) {
|
for (i = 0; i < nc; ++i) {
|
||||||
bool isvoid = false;
|
bool isvoid = false;
|
||||||
if (w[i]<= 0) {
|
if (w[i] <= 0) {
|
||||||
w[i] = df_width;
|
w[i] = df_width;
|
||||||
isvoid = true;
|
isvoid = true;
|
||||||
}
|
}
|
||||||
@ -493,16 +502,17 @@ void MathMatrixInset::Metrics()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MathAccentInset::MathAccentInset(byte cx, MathedTextCodes f, int cd, short st):
|
|
||||||
MathedInset("", LM_OT_ACCENT, st), c(cx), fn(f), code(cd)
|
MathAccentInset::MathAccentInset(byte cx, MathedTextCodes f, int cd, short st)
|
||||||
|
: MathedInset("", LM_OT_ACCENT, st), c(cx), fn(f), code(cd)
|
||||||
{
|
{
|
||||||
inset = 0;
|
inset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathAccentInset::MathAccentInset(MathedInset *ins, int cd, short st):
|
|
||||||
MathedInset("", LM_OT_ACCENT, st), c(0), fn(LM_TC_MIN), code(cd), inset(ins)
|
MathAccentInset::MathAccentInset(MathedInset *ins, int cd, short st)
|
||||||
{
|
: MathedInset("", LM_OT_ACCENT, st),
|
||||||
}
|
c(0), fn(LM_TC_MIN), code(cd), inset(ins) {}
|
||||||
|
|
||||||
|
|
||||||
MathAccentInset::~MathAccentInset()
|
MathAccentInset::~MathAccentInset()
|
||||||
@ -511,7 +521,8 @@ MathAccentInset::~MathAccentInset()
|
|||||||
delete inset;
|
delete inset;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathAccentInset * MathAccentInset::Clone()
|
|
||||||
|
MathedInset * MathAccentInset::Clone()
|
||||||
{
|
{
|
||||||
MathAccentInset * p;
|
MathAccentInset * p;
|
||||||
|
|
||||||
@ -524,32 +535,24 @@ MathAccentInset * MathAccentInset::Clone()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathBigopInset::MathBigopInset(char const* nam, int id, short st):
|
MathBigopInset::MathBigopInset(char const* nam, int id, short st)
|
||||||
MathedInset(nam, LM_OT_BIGOP, st), sym(id)
|
: MathedInset(nam, LM_OT_BIGOP, st), sym(id)
|
||||||
{
|
{
|
||||||
lims = -1;
|
lims = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MathBigopInset * MathBigopInset::Clone()
|
|
||||||
|
MathedInset * MathBigopInset::Clone()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
MathBigopInset* p = new MathBigopInset(name, sym, GetStyle());
|
|
||||||
return p;
|
|
||||||
#endif
|
|
||||||
return new MathBigopInset(name, sym, GetStyle());
|
return new MathBigopInset(name, sym, GetStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
MathDotsInset::MathDotsInset(char const * nam, int id, short st):
|
|
||||||
MathedInset(nam, LM_OT_DOTS, st), code(id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MathDotsInset * MathDotsInset::Clone()
|
|
||||||
|
MathDotsInset::MathDotsInset(char const * nam, int id, short st)
|
||||||
|
: MathedInset(nam, LM_OT_DOTS, st), code(id) {}
|
||||||
|
|
||||||
|
|
||||||
|
MathedInset * MathDotsInset::Clone()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
MathDotsInset* p = new MathDotsInset(name, code, GetStyle());
|
|
||||||
return p;
|
|
||||||
#endif
|
|
||||||
return new MathDotsInset(name, code, GetStyle());
|
return new MathDotsInset(name, code, GetStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,12 @@
|
|||||||
class MathFuncInset: public MathedInset {
|
class MathFuncInset: public MathedInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathFuncInset(char const * nm, short ot= LM_OT_FUNC, short st= LM_ST_TEXT);
|
MathFuncInset(char const * nm,
|
||||||
|
short ot = LM_OT_FUNC, short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
~MathFuncInset();
|
~MathFuncInset();
|
||||||
///
|
///
|
||||||
MathFuncInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
@ -67,13 +68,13 @@ protected:
|
|||||||
class MathAccentInset: public MathedInset {
|
class MathAccentInset: public MathedInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathAccentInset(byte, MathedTextCodes, int, short st= LM_ST_TEXT);
|
MathAccentInset(byte, MathedTextCodes, int, short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
MathAccentInset(MathedInset *, int, short st= LM_ST_TEXT);
|
MathAccentInset(MathedInset *, int, short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
~MathAccentInset();
|
~MathAccentInset();
|
||||||
///
|
///
|
||||||
MathAccentInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
@ -103,17 +104,17 @@ class MathAccentInset: public MathedInset {
|
|||||||
class MathDotsInset: public MathedInset {
|
class MathDotsInset: public MathedInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathDotsInset(char const *, int, short st= LM_ST_TEXT);
|
MathDotsInset(char const *, int, short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
~MathDotsInset() {}
|
~MathDotsInset() {}
|
||||||
///
|
///
|
||||||
MathDotsInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
void Write(FILE * file);
|
void Write(FILE * file);
|
||||||
///
|
///
|
||||||
void Write(string &file);
|
void Write(string & file);
|
||||||
///
|
///
|
||||||
void Metrics();
|
void Metrics();
|
||||||
protected:
|
protected:
|
||||||
@ -130,7 +131,7 @@ class MathSpaceInset: public MathedInset {
|
|||||||
///
|
///
|
||||||
~MathSpaceInset() {}
|
~MathSpaceInset() {}
|
||||||
///
|
///
|
||||||
MathSpaceInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
@ -157,7 +158,7 @@ class MathBigopInset: public MathedInset {
|
|||||||
///
|
///
|
||||||
~MathBigopInset() {}
|
~MathBigopInset() {}
|
||||||
///
|
///
|
||||||
MathBigopInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
@ -184,17 +185,17 @@ class MathBigopInset: public MathedInset {
|
|||||||
class MathSqrtInset: public MathParInset {
|
class MathSqrtInset: public MathParInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathSqrtInset(short st= LM_ST_TEXT);
|
MathSqrtInset(short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
~MathSqrtInset() {}
|
~MathSqrtInset() {}
|
||||||
///
|
///
|
||||||
MathSqrtInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int x, int baseline);
|
void Draw(int x, int baseline);
|
||||||
///
|
///
|
||||||
void Write(FILE *file);
|
void Write(FILE * file);
|
||||||
///
|
///
|
||||||
void Write(string &file);
|
void Write(string & file);
|
||||||
///
|
///
|
||||||
void Metrics();
|
void Metrics();
|
||||||
///
|
///
|
||||||
@ -210,11 +211,11 @@ class MathSqrtInset: public MathParInset {
|
|||||||
class MathFracInset: public MathParInset {
|
class MathFracInset: public MathParInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathFracInset(short ot= LM_OT_FRAC);
|
MathFracInset(short ot = LM_OT_FRAC);
|
||||||
///
|
///
|
||||||
~MathFracInset();
|
~MathFracInset();
|
||||||
///
|
///
|
||||||
MathFracInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int x, int baseline);
|
void Draw(int x, int baseline);
|
||||||
///
|
///
|
||||||
@ -260,11 +261,11 @@ class MathFracInset: public MathParInset {
|
|||||||
class MathDelimInset: public MathParInset {
|
class MathDelimInset: public MathParInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathDelimInset(int, int, short st= LM_ST_TEXT);
|
MathDelimInset(int, int, short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
~MathDelimInset() {}
|
~MathDelimInset() {}
|
||||||
///
|
///
|
||||||
MathDelimInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
@ -285,11 +286,11 @@ class MathDelimInset: public MathParInset {
|
|||||||
class MathDecorationInset: public MathParInset {
|
class MathDecorationInset: public MathParInset {
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
MathDecorationInset(int, short st= LM_ST_TEXT);
|
MathDecorationInset(int, short st = LM_ST_TEXT);
|
||||||
///
|
///
|
||||||
~MathDecorationInset() {}
|
~MathDecorationInset() {}
|
||||||
///
|
///
|
||||||
MathDecorationInset * Clone();
|
MathedInset * Clone();
|
||||||
///
|
///
|
||||||
void Draw(int, int);
|
void Draw(int, int);
|
||||||
///
|
///
|
||||||
@ -319,18 +320,21 @@ MathFuncInset::~MathFuncInset()
|
|||||||
if (fname && GetType() == LM_OT_UNDEF) delete[] fname;
|
if (fname && GetType() == LM_OT_UNDEF) delete[] fname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool MathFuncInset::GetLimits() const
|
bool MathFuncInset::GetLimits() const
|
||||||
{
|
{
|
||||||
return bool(lims && (GetStyle() == LM_ST_DISPLAY));
|
return bool(lims && (GetStyle() == LM_ST_DISPLAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void MathFuncInset::Write(FILE * file)
|
void MathFuncInset::Write(FILE * file)
|
||||||
{
|
{
|
||||||
fprintf(file, "\\%s ", name);
|
fprintf(file, "\\%s ", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void MathFuncInset::Write(string & file)
|
void MathFuncInset::Write(string & file)
|
||||||
{
|
{
|
||||||
@ -339,6 +343,7 @@ void MathFuncInset::Write(string & file)
|
|||||||
file += ' ';
|
file += ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void MathSpaceInset::Metrics()
|
void MathSpaceInset::Metrics()
|
||||||
{
|
{
|
||||||
@ -349,6 +354,7 @@ void MathSpaceInset::Metrics()
|
|||||||
ascent = 4; descent = 0;
|
ascent = 4; descent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void MathSpaceInset::SetSpace(int sp)
|
void MathSpaceInset::SetSpace(int sp)
|
||||||
{
|
{
|
||||||
@ -356,6 +362,7 @@ void MathSpaceInset::SetSpace(int sp)
|
|||||||
Metrics();
|
Metrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool MathBigopInset::GetLimits() const
|
bool MathBigopInset::GetLimits() const
|
||||||
{
|
{
|
||||||
@ -368,12 +375,14 @@ bool MathBigopInset::GetLimits() const
|
|||||||
return lims > 0;
|
return lims > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void MathBigopInset::SetLimits(bool ls)
|
void MathBigopInset::SetLimits(bool ls)
|
||||||
{
|
{
|
||||||
lims = ls ? 1 : 0;
|
lims = ls ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool MathDecorationInset::GetLimits() const
|
bool MathDecorationInset::GetLimits() const
|
||||||
{
|
{
|
||||||
|
@ -82,8 +82,9 @@ LyXParagraph::LyXParagraph()
|
|||||||
/* this konstruktor inserts the new paragraph in a list */
|
/* this konstruktor inserts the new paragraph in a list */
|
||||||
LyXParagraph::LyXParagraph(LyXParagraph * par)
|
LyXParagraph::LyXParagraph(LyXParagraph * par)
|
||||||
{
|
{
|
||||||
#warning we also need a reserve here
|
text.reserve(500);
|
||||||
#warning this would be a nice place to shrink par
|
par->text.resize(par->text.size());
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i) setCounter(i, 0);
|
for (int i = 0; i < 10; ++i) setCounter(i, 0);
|
||||||
appendix = false;
|
appendix = false;
|
||||||
enumdepth = 0;
|
enumdepth = 0;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <pair.h>
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "filetools.h"
|
#pragma implementation "filetools.h"
|
||||||
@ -48,6 +49,8 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using std::make_pair;
|
||||||
|
|
||||||
extern string system_lyxdir;
|
extern string system_lyxdir;
|
||||||
extern string build_lyxdir;
|
extern string build_lyxdir;
|
||||||
extern string user_lyxdir;
|
extern string user_lyxdir;
|
||||||
@ -962,3 +965,51 @@ bool LyXReadLink(string const & File, string & Link)
|
|||||||
Link = LinkBuffer;
|
Link = LinkBuffer;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef pair<int, string> cmdret;
|
||||||
|
static cmdret do_popen(string const & cmd)
|
||||||
|
{
|
||||||
|
// One question is if we should use popen or
|
||||||
|
// create our own popen based on fork, exec, pipe
|
||||||
|
// of course the best would be to have a
|
||||||
|
// pstream (process stream), with the
|
||||||
|
// variants ipstream, opstream and
|
||||||
|
FILE * inf = popen(cmd.c_str(), "r");
|
||||||
|
string ret;
|
||||||
|
int c = fgetc(inf);
|
||||||
|
while (c != EOF) {
|
||||||
|
ret += static_cast<char>(c);
|
||||||
|
c = fgetc(inf);
|
||||||
|
}
|
||||||
|
int pret = pclose(inf);
|
||||||
|
return make_pair(pret, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string findtexfile(string const & fil, string const & format)
|
||||||
|
{
|
||||||
|
/* There is no problem to extend this function too use other
|
||||||
|
methods to look for files. It could be setup to look
|
||||||
|
in environment paths and also if wanted as a last resort
|
||||||
|
to a recursive find. One of the easier extensions would
|
||||||
|
perhaps be to use the LyX file lookup methods. But! I am
|
||||||
|
going to implement this until I see some demand for it.
|
||||||
|
Lgb
|
||||||
|
*/
|
||||||
|
|
||||||
|
// If fil is a file with absolute path we just return it
|
||||||
|
if (AbsolutePath(fil)) return fil;
|
||||||
|
|
||||||
|
// Check in the current dir.
|
||||||
|
if (FileInfo(OnlyFilename(fil)).exist())
|
||||||
|
return OnlyFilename(fil);
|
||||||
|
|
||||||
|
// No we try to find it using kpsewhich.
|
||||||
|
string kpsecmd = "kpsewhich --format= " + format + " " + OnlyFilename(fil);
|
||||||
|
cmdret c = do_popen(kpsecmd);
|
||||||
|
|
||||||
|
lyxerr << "kpse status = " << c.first << "\n"
|
||||||
|
<< "kpse result = `" << strip(c.second, '\n') << "'" << endl;
|
||||||
|
return c.first != -1 ? strip(c.second, '\n') : string();
|
||||||
|
}
|
||||||
|
@ -286,4 +286,7 @@ string ReplaceEnvironmentPath(string const & path);
|
|||||||
Return True if succesfull, False other wise */
|
Return True if succesfull, False other wise */
|
||||||
bool LyXReadLink(string const & file, string & Link);
|
bool LyXReadLink(string const & file, string & Link);
|
||||||
|
|
||||||
|
/* Uses kpsewhich to find tex files */
|
||||||
|
string findtexfile(string const & fil, string const & format);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user