mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +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>
|
||||
|
||||
* src/mathed/formula.[Ch] (GetCursorPos): add a missing 'const'.
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib> // atoi
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -30,6 +31,8 @@
|
||||
#include "support/path.h"
|
||||
#include "gettext.h"
|
||||
|
||||
using std::ifstream;
|
||||
|
||||
/*
|
||||
* CLASS Chktex
|
||||
*/
|
||||
@ -56,7 +59,7 @@ int Chktex::run(TeXErrors &terr)
|
||||
}
|
||||
|
||||
|
||||
int Chktex::scanLogFile(TeXErrors &terr)
|
||||
int Chktex::scanLogFile(TeXErrors & terr)
|
||||
{
|
||||
string token;
|
||||
int retval = 0;
|
||||
|
@ -17,10 +17,11 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "ImportNoweb.h"
|
||||
#include "lyxrc.h"
|
||||
#include "support/syscall.h"
|
||||
#include "support/filetools.h"
|
||||
#include "bufferlist.h"
|
||||
|
||||
extern LyXRC * lyxrc;
|
||||
@ -46,30 +47,28 @@ Buffer * ImportNoweb::run()
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
// Provide the literate documentclass by parsing the file.
|
||||
//
|
||||
string ImportNoweb::documentclass()
|
||||
{
|
||||
string result = "literate-article"; // Default
|
||||
|
||||
FilePtr inputfile(file, FilePtr::read);
|
||||
if (!inputfile()) return "nofile"; // Should not happen!
|
||||
#warning If you use literate programming you should verify that this works
|
||||
// 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;
|
||||
|
||||
while(!feof(inputfile())) {
|
||||
(void)fgets(buf, BUFSIZE, inputfile());
|
||||
if ((p = strstr(buf, "\\documentclass"))) {
|
||||
while ((*p) && (*p != '{'))
|
||||
p++;
|
||||
q = p++;
|
||||
while ((*q) && (*q != '}'))
|
||||
q++;
|
||||
*q = '\0';
|
||||
result = p;
|
||||
result = "literate-" + result;
|
||||
if (!ifs) return "nofile"; // Should not happen!
|
||||
string line;
|
||||
while (getline(ifs, line)) {
|
||||
int p = line.find("\\documentclass");
|
||||
if (p != string::npos) {
|
||||
p = line.find('{', p);
|
||||
int q = line.find('}', p);
|
||||
result = "literate-" + line.substr(p, q - p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
40
src/LaTeX.C
40
src/LaTeX.C
@ -16,6 +16,7 @@
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
#include <fstream>
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "LaTeX.h"
|
||||
@ -29,7 +30,7 @@
|
||||
#include "minibuffer.h"
|
||||
#include "gettext.h"
|
||||
|
||||
using std::make_pair;
|
||||
using std::ifstream;
|
||||
|
||||
// TODO: in no particular order
|
||||
// - 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)
|
||||
|
@ -24,10 +24,6 @@
|
||||
#include <vector>
|
||||
using std::vector;
|
||||
|
||||
#include <fstream>
|
||||
using std::ifstream;
|
||||
using std::ofstream;
|
||||
|
||||
class MiniBuffer;
|
||||
|
||||
///
|
||||
|
@ -13,6 +13,7 @@
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
#include <fstream>
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "LaTeX.h"
|
||||
@ -27,6 +28,8 @@
|
||||
#include "minibuffer.h"
|
||||
#include "gettext.h"
|
||||
|
||||
using std::ifstream;
|
||||
|
||||
extern BufferList bufferlist;
|
||||
|
||||
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),
|
||||
sp->bw, sp->bh,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
50
src/buffer.C
50
src/buffer.C
@ -219,9 +219,9 @@ bool Buffer::insertLyXFile(string const & filen)
|
||||
// check if file exist
|
||||
FileInfo fi(filename);
|
||||
|
||||
if (!fi.exist() || !fi.readable()) {
|
||||
if (!fi.readable()) {
|
||||
WriteAlert(_("Error!"),
|
||||
_("Cannot open specified file:"),
|
||||
_("Specified file is unreadable: "),
|
||||
MakeDisplayPath(filename, 50));
|
||||
return false;
|
||||
}
|
||||
@ -231,7 +231,7 @@ bool Buffer::insertLyXFile(string const & filen)
|
||||
FilePtr myfile(filename, FilePtr::read);
|
||||
if (!myfile()) {
|
||||
WriteAlert(_("Error!"),
|
||||
_("Cannot open specified file:"),
|
||||
_("Cannot open specified file: "),
|
||||
MakeDisplayPath(filename, 50));
|
||||
return false;
|
||||
}
|
||||
@ -1236,46 +1236,28 @@ bool Buffer::writeFile(string const & filename, bool flag)
|
||||
void Buffer::writeFileAscii(string const & filename, int linelen)
|
||||
{
|
||||
FilePtr file(filename, FilePtr::write);
|
||||
LyXFont
|
||||
font1, font2;
|
||||
LyXFont font1, font2;
|
||||
Inset * inset;
|
||||
LyXParagraph * par = paragraph;
|
||||
char
|
||||
c,
|
||||
footnoteflag = 0,
|
||||
depth = 0;
|
||||
|
||||
string
|
||||
fname1,
|
||||
tmp;
|
||||
|
||||
char c, footnoteflag = 0, depth = 0;
|
||||
string tmp;
|
||||
LyXParagraph::size_type i;
|
||||
int
|
||||
j, h,
|
||||
ltype = 0,
|
||||
ltype_depth = 0,
|
||||
noparbreak = 0,
|
||||
islatex = 0,
|
||||
* clen = 0,
|
||||
actcell = 0,
|
||||
actpos = 0,
|
||||
cell = 0,
|
||||
cells = 0,
|
||||
int j, h, ltype = 0, ltype_depth = 0,
|
||||
* clen = 0, actcell = 0, actpos = 0, cell = 0, cells = 0,
|
||||
currlinelen = 0;
|
||||
long
|
||||
fpos = 0;
|
||||
bool
|
||||
ref_printed = false;
|
||||
long fpos = 0;
|
||||
bool ref_printed = false;
|
||||
|
||||
|
||||
if (!file()) {
|
||||
WriteFSAlert(_("Error: Cannot write file:"), filename);
|
||||
return;
|
||||
}
|
||||
fname1 = TmpFileName();
|
||||
|
||||
string fname1 = TmpFileName();
|
||||
LyXParagraph * par = paragraph;
|
||||
while (par) {
|
||||
noparbreak = 0;
|
||||
islatex = 0;
|
||||
int noparbreak = 0;
|
||||
int islatex = 0;
|
||||
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE ||
|
||||
!par->previous ||
|
||||
par->previous->footnoteflag == LyXParagraph::NO_FOOTNOTE){
|
||||
@ -1366,7 +1348,7 @@ void Buffer::writeFileAscii(string const & filename, int linelen)
|
||||
actcell = 0;
|
||||
cells = par->table->columns;
|
||||
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) {
|
||||
c = par->GetChar(i);
|
||||
if (c == LyXParagraph::META_INSET) {
|
||||
|
@ -39,6 +39,7 @@ extern long int background_pixels;
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
|
||||
#include "form1.h"
|
||||
#include "figinset.h"
|
||||
@ -438,19 +439,19 @@ int FindBmpIndex(figdata *tmpdata)
|
||||
|
||||
static void chpixmap(Pixmap, int, int)
|
||||
{
|
||||
#if 0
|
||||
Display * tempdisp = XOpenDisplay(XDisplayName(0));
|
||||
|
||||
// here read the pixmap and change all colors to those we
|
||||
// have allocated
|
||||
|
||||
XCloseDisplay(tempdisp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void freefigdata(figdata *tmpdata)
|
||||
{
|
||||
int i;
|
||||
|
||||
tmpdata->ref--;
|
||||
if (tmpdata->ref) return;
|
||||
|
||||
@ -468,7 +469,7 @@ static void freefigdata(figdata *tmpdata)
|
||||
|
||||
if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
|
||||
delete tmpdata;
|
||||
i = FindBmpIndex(tmpdata);
|
||||
int i = FindBmpIndex(tmpdata);
|
||||
--bmpinsref;
|
||||
while (i < bmpinsref) {
|
||||
bitmaps[i] = bitmaps[i+1];
|
||||
@ -488,10 +489,8 @@ static void runqueue()
|
||||
}
|
||||
|
||||
while (gsrunning < MAXGS) {
|
||||
queue *p;
|
||||
int pid;
|
||||
char tbuf[384], tbuf2[80];
|
||||
Atom *prop;
|
||||
Atom * prop;
|
||||
int nprop, i;
|
||||
|
||||
if (!gsqueue) {
|
||||
@ -502,18 +501,19 @@ static void runqueue()
|
||||
}
|
||||
return;
|
||||
}
|
||||
p = gsqueue;
|
||||
queue * p = gsqueue;
|
||||
|
||||
if (!p->data) {
|
||||
delete p;
|
||||
continue;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
int pid = fork();
|
||||
|
||||
if (pid == -1) {
|
||||
if (lyxerr.debugging()) {
|
||||
lyxerr << "GS start error! Cannot fork." << endl;
|
||||
lyxerr << "GS start error! Cannot fork."
|
||||
<< endl;
|
||||
}
|
||||
p->data->broken = true;
|
||||
p->data->reading = false;
|
||||
@ -528,26 +528,22 @@ static void runqueue()
|
||||
sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
|
||||
int(getpid()));
|
||||
|
||||
FilePtr f(tbuf, FilePtr::write);
|
||||
fprintf(f, "gsave clippath pathbbox grestore\n"
|
||||
"4 dict begin\n"
|
||||
"/ury exch def /urx exch def /lly exch def "
|
||||
ofstream ofs(tbuf);
|
||||
ofs << "gsave clippath pathbbox grestore\n"
|
||||
<< "4 dict begin\n"
|
||||
<< "/ury exch def /urx exch def /lly exch def "
|
||||
"/llx exch def\n"
|
||||
"%g %g translate\n"
|
||||
"%g rotate\n"
|
||||
"%g %g translate\n"
|
||||
"%g %g scale\n"
|
||||
"%d %d translate\nend\n",
|
||||
p->data->wid / 2.0, p->data->hgh / 2.0,
|
||||
p->data->angle,
|
||||
- (p->data->raw_wid / 2.0), -(p->data->raw_hgh / 2.0),
|
||||
p->rx / 72.0, p->ry / 72.0,
|
||||
-p->ofsx, -p->ofsy
|
||||
);
|
||||
<< p->data->wid / 2.0 << " "
|
||||
<< p->data->hgh / 2.0 << " translate\n"
|
||||
<< p->data->angle << " rotate\n"
|
||||
<< -(p->data->raw_wid / 2.0) << " "
|
||||
<< -(p->data->raw_hgh / 2.0) << " translate\n"
|
||||
<< p->rx / 72.0 << " " << p->ry / 72.0
|
||||
<< " scale\n"
|
||||
<< -p->ofsx << " " << -p->ofsy << " translate\n"
|
||||
<< "end" << endl;
|
||||
ofs.close(); // Don't remove this.
|
||||
|
||||
// DON'T EVER remove this!!
|
||||
f.close(); // was this all? (Lgb)
|
||||
|
||||
// gs process - set ghostview environment first
|
||||
sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
|
||||
figinset_canvas), p->data->bitmap);
|
||||
@ -597,6 +593,7 @@ static void runqueue()
|
||||
<< "] GHOSTVIEW property"
|
||||
" found. Waiting." << endl;
|
||||
}
|
||||
#if 0
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning What is this doing? (wouldn't a sleep(1); work too?')
|
||||
#endif
|
||||
@ -604,6 +601,9 @@ static void runqueue()
|
||||
alarmed = false;
|
||||
signal(SIGALRM, waitalarm);
|
||||
while (!alarmed) pause();
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -1717,9 +1717,10 @@ void InsetFig::Recompute()
|
||||
|
||||
void InsetFig::GetPSSizes()
|
||||
{
|
||||
#warning rewrite this method to use ifstream
|
||||
/* get %%BoundingBox: from postscript file */
|
||||
int lastchar, c;
|
||||
char *p = 0;
|
||||
char * p = 0;
|
||||
|
||||
/* defaults to associated size
|
||||
* ..just in case the PS-file is not readable (Henner, 24-Aug-97)
|
||||
@ -1730,7 +1731,7 @@ void InsetFig::GetPSSizes()
|
||||
pshgh = hgh;
|
||||
|
||||
if (fname.empty()) return;
|
||||
|
||||
|
||||
FilePtr f(fname, FilePtr::read);
|
||||
|
||||
if (!f()) return; // file not found !!!!
|
||||
@ -1752,7 +1753,9 @@ void InsetFig::GetPSSizes()
|
||||
if (c == '%' && lastchar == '%') {
|
||||
p = NextToken(f);
|
||||
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) {
|
||||
float fpsx, fpsy, fpswid, fpshgh;
|
||||
if (fscanf(f, "%f %f %f %f", &fpsx, &fpsy,
|
||||
@ -1769,8 +1772,8 @@ void InsetFig::GetPSSizes()
|
||||
<< psy << ' '
|
||||
<< pswid << ' '
|
||||
<< pshgh << endl;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
c = 0;
|
||||
delete[] p;
|
||||
|
@ -4,8 +4,8 @@
|
||||
(C)1996 by Ivan Schreter
|
||||
*/
|
||||
|
||||
#ifndef _FIGINSET_H
|
||||
#define _FIGINSET_H
|
||||
#ifndef FIGINSET_H
|
||||
#define FIGINSET_H
|
||||
|
||||
#include "form1.h"
|
||||
#include "buffer.h"
|
||||
@ -24,30 +24,30 @@ public:
|
||||
///
|
||||
~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.
|
||||
void Validate(LaTeXFeatures &features) const;
|
||||
void Validate(LaTeXFeatures & features) const;
|
||||
|
||||
/// what appears in the minibuffer when opening
|
||||
char const* EditMessage() {return "Opened figure";}
|
||||
char const * EditMessage() { return "Opened figure"; }
|
||||
///
|
||||
void Edit(int, int);
|
||||
///
|
||||
@ -57,16 +57,16 @@ public:
|
||||
///
|
||||
Inset::Code LyxCode() const;
|
||||
///
|
||||
InsetFig * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
void CallbackFig(long arg);
|
||||
///
|
||||
void Preview(char const *p);
|
||||
void Preview(char const * p);
|
||||
/// browse for file
|
||||
void BrowseFile();
|
||||
|
||||
/// form for user input
|
||||
FD_Figure *form;
|
||||
FD_Figure * form;
|
||||
/// width and height in pixels on screen
|
||||
int wid, hgh;
|
||||
/// width and height in postscript units (1/72 inch)
|
||||
@ -124,14 +124,14 @@ public:
|
||||
int flags;
|
||||
bool subfigure : 1;
|
||||
/// figure reference
|
||||
Figref *figure;
|
||||
Figref * figure;
|
||||
/// temporary flags
|
||||
int pflags;
|
||||
bool psubfigure : 1;
|
||||
private:
|
||||
|
||||
///
|
||||
Buffer *owner;
|
||||
Buffer * owner;
|
||||
/// restore values on the form
|
||||
void RestoreForm();
|
||||
/// recompute screen params
|
||||
@ -177,9 +177,9 @@ struct figdata {
|
||||
///
|
||||
struct Figref {
|
||||
/// figure data (image)
|
||||
figdata *data;
|
||||
figdata * data;
|
||||
/// inset of this figure
|
||||
InsetFig *inset;
|
||||
InsetFig * inset;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -342,6 +343,7 @@ int InsetBibtex::Latex(string &file, signed char /*fragile*/)
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
// This method returns a comma separated list of Bibtex entries
|
||||
string InsetBibtex::getKeys()
|
||||
{
|
||||
@ -350,64 +352,46 @@ string InsetBibtex::getKeys()
|
||||
if (!owner) {
|
||||
owner = current_view->buffer();
|
||||
}
|
||||
|
||||
// We need to create absolute path names for bibliographies
|
||||
// First look for bib-file in same directory as document,
|
||||
// then in all directories listed in environment variable
|
||||
// BIBINPUTS
|
||||
string bibfiles, linebuf, tmp, keys;
|
||||
bibfiles = getContents();
|
||||
bibfiles= split(bibfiles, tmp, ',');
|
||||
|
||||
string tmp, keys;
|
||||
string bibfiles = getContents();
|
||||
bibfiles = split(bibfiles, tmp, ',');
|
||||
while(!tmp.empty()) {
|
||||
if (IsFileReadable(MakeAbsPath(tmp, owner->filepath)+".bib"))
|
||||
tmp = MakeAbsPath(tmp, owner->filepath)+".bib";
|
||||
else {
|
||||
tmp = FileOpenSearch(GetEnvPath("BIBINPUTS"), tmp, "bib");
|
||||
if (tmp.empty())
|
||||
tmp = FileOpenSearch(GetEnvPath("BIBINPUT"),
|
||||
tmp, "bib");
|
||||
}
|
||||
string fil = findtexfile(ChangeExtension(tmp, "bib", false),
|
||||
"bib");
|
||||
lyxerr << "Bibfile: " << fil << endl;
|
||||
// If we didn't find a matching file name just fail silently
|
||||
if (!tmp.empty()) {
|
||||
|
||||
// This is a _very_ simple parser for Bibtex database files.
|
||||
// All it does is to look for lines starting in @ and not
|
||||
// being @preamble and @string entries.
|
||||
if (!fil.empty()) {
|
||||
// This is a _very_ simple parser for Bibtex database
|
||||
// files. All it does is to look for lines starting
|
||||
// in @ and not being @preamble and @string entries.
|
||||
// It does NOT do any syntax checking!
|
||||
FilePtr file(tmp, FilePtr::read);
|
||||
char c;
|
||||
|
||||
// On some systems where feof() is a macro,
|
||||
// the () after file is needed (JMarc)
|
||||
while (! feof(file())) {
|
||||
c = fgetc(file);
|
||||
|
||||
// At end of each line check if line begins with '@'
|
||||
if ( c == '\n') {
|
||||
if (prefixIs(linebuf, "@") ) {
|
||||
linebuf = subst(linebuf,
|
||||
'{', '(');
|
||||
ifstream ifs(fil.c_str());
|
||||
string linebuf;
|
||||
while (getline(ifs, linebuf)) {
|
||||
if (prefixIs(linebuf, "@")) {
|
||||
linebuf = subst(linebuf, '{', '(');
|
||||
linebuf = split(linebuf, tmp, '(');
|
||||
tmp = lowercase(tmp);
|
||||
if (!prefixIs(tmp, "@string")
|
||||
&& !prefixIs(tmp, "@preamble")) {
|
||||
linebuf = split(linebuf,
|
||||
tmp,'(');
|
||||
tmp = lowercase(tmp);
|
||||
if (!prefixIs(tmp, "@string") && !prefixIs(tmp, "@preamble") ) {
|
||||
linebuf = split(linebuf, tmp,',');
|
||||
if (!tmp.empty())
|
||||
keys += strip(tmp) + ", ";
|
||||
tmp, ',');
|
||||
if (!tmp.empty()) {
|
||||
keys += strip(tmp);
|
||||
keys += ", ";
|
||||
}
|
||||
}
|
||||
linebuf.clear();
|
||||
} else {
|
||||
linebuf += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get next file name
|
||||
bibfiles= split(bibfiles, tmp, ',');
|
||||
bibfiles = split(bibfiles, tmp, ',');
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
// BibTeX should have its own dialog. This is provisional.
|
||||
void InsetBibtex::Edit(int, int)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
///
|
||||
~InsetCitation();
|
||||
///
|
||||
InsetCitation * Clone() const {
|
||||
Inset * Clone() const {
|
||||
return new InsetCitation(contents, options);
|
||||
}
|
||||
///
|
||||
@ -62,7 +62,7 @@ public:
|
||||
///
|
||||
~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.
|
||||
void Write(FILE *);
|
||||
///
|
||||
@ -98,7 +98,7 @@ public:
|
||||
InsetBibtex(string const & dbase, string const & style,
|
||||
Buffer *);
|
||||
///
|
||||
InsetBibtex * Clone() const {
|
||||
Inset * Clone() const {
|
||||
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);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
///
|
||||
virtual int DocBook(string & file);
|
||||
///
|
||||
InsetCommand * Clone() const;
|
||||
Inset * Clone() 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);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
///
|
||||
unsigned char Editable() const;
|
||||
///
|
||||
InsetError * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::NO_CODE; }
|
||||
/// 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);
|
||||
ii->setNoLoad(isNoLoad());
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
///
|
||||
~InsetInclude();
|
||||
///
|
||||
InsetInclude * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::INCLUDE_CODE; }
|
||||
/// This is 1 if the childs have labels, 0 otherwise
|
||||
|
@ -29,13 +29,13 @@ struct LaTeXFeatures;
|
||||
class InsetIndex: public InsetCommand {
|
||||
public:
|
||||
///
|
||||
InsetIndex(): InsetCommand("index") {;}
|
||||
InsetIndex() : InsetCommand("index") {}
|
||||
///
|
||||
InsetIndex(string const & key);
|
||||
///
|
||||
~InsetIndex();
|
||||
///
|
||||
InsetIndex * Clone() const { return new InsetIndex(contents);}
|
||||
Inset * Clone() const { return new InsetIndex(contents);}
|
||||
///
|
||||
void Edit(int, int);
|
||||
///
|
||||
@ -48,7 +48,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class InsetPrintIndex: public InsetCommand {
|
||||
class InsetPrintIndex : public InsetCommand {
|
||||
public:
|
||||
///
|
||||
InsetPrintIndex();
|
||||
@ -64,6 +64,7 @@ public:
|
||||
unsigned char Editable() const{
|
||||
return 1;
|
||||
}
|
||||
/// WHY is clone missing? (Lgb)
|
||||
///
|
||||
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);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
in a yellow box. Currently, the Read-function is a terrible hack.
|
||||
Some day in the distant future, this will hopefully be obsoleted by
|
||||
a true comment-environment. */
|
||||
class InsetInfo: public Inset {
|
||||
class InsetInfo : public Inset {
|
||||
public:
|
||||
///
|
||||
InsetInfo();
|
||||
@ -65,7 +65,7 @@ public:
|
||||
///
|
||||
Inset::Code LyxCode() const;
|
||||
///
|
||||
InsetInfo * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
static void CloseInfoCB(FL_OBJECT *, long data);
|
||||
private:
|
||||
|
@ -25,7 +25,7 @@ InsetLabel::InsetLabel(string const & cmd)
|
||||
}
|
||||
|
||||
|
||||
InsetLabel * InsetLabel::Clone() const
|
||||
Inset * InsetLabel::Clone() const
|
||||
{
|
||||
return new InsetLabel(getCommand());
|
||||
}
|
||||
|
@ -20,14 +20,14 @@
|
||||
#include "LString.h"
|
||||
|
||||
///
|
||||
class InsetLabel: public InsetCommand {
|
||||
class InsetLabel : public InsetCommand {
|
||||
public:
|
||||
///
|
||||
InsetLabel(string const & cmd);
|
||||
///
|
||||
InsetLabel() : InsetCommand("label") {}
|
||||
///
|
||||
InsetLabel * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::LABEL_CODE; }
|
||||
///
|
||||
|
@ -24,7 +24,7 @@
|
||||
delete/backspace operations. This is used when you insert a LaTeX
|
||||
figure (done as "\input "), but you still have to type the filename
|
||||
yourself after the inset. */
|
||||
class InsetLatex: public Inset {
|
||||
class InsetLatex : public Inset {
|
||||
public:
|
||||
///
|
||||
InsetLatex();
|
||||
@ -55,7 +55,7 @@ public:
|
||||
///
|
||||
bool Deletable() const;
|
||||
///
|
||||
InsetLatex * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const;
|
||||
private:
|
||||
|
@ -630,7 +630,7 @@ bool InsetLatexAccent::DirectWrite() const
|
||||
}
|
||||
|
||||
|
||||
InsetLatexAccent * InsetLatexAccent::Clone() const
|
||||
Inset * InsetLatexAccent::Clone() const
|
||||
{
|
||||
return new InsetLatexAccent(contents);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
it also can handle other special characters (e.g. Hstroke)
|
||||
Initiated by Ivan Schreter, later modified by Lgb.
|
||||
*/
|
||||
class InsetLatexAccent: public Inset {
|
||||
class InsetLatexAccent : public Inset {
|
||||
public:
|
||||
///
|
||||
InsetLatexAccent();
|
||||
@ -63,7 +63,7 @@ public:
|
||||
///
|
||||
bool DirectWrite() const;
|
||||
///
|
||||
InsetLatexAccent * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode()const;
|
||||
///
|
||||
|
@ -23,21 +23,19 @@
|
||||
|
||||
/** Used to insert table of algorithms
|
||||
*/
|
||||
class InsetLOA: public InsetCommand {
|
||||
class InsetLOA : public InsetCommand {
|
||||
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;
|
||||
///
|
||||
InsetLOA * Clone() const { return new InsetLOA(owner); }
|
||||
Inset * Clone() const { return new InsetLOA(owner); }
|
||||
///
|
||||
string getScreenLabel() const { return _("List of Algorithms"); }
|
||||
|
||||
|
||||
//void Edit(int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 0; // not yet
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
/** Used to insert table of contents
|
||||
*/
|
||||
class InsetLOF: public InsetCommand {
|
||||
class InsetLOF : public InsetCommand {
|
||||
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"); }
|
||||
|
||||
//void Edit(int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 0; // not yet
|
||||
|
@ -23,18 +23,17 @@
|
||||
|
||||
/** Used to insert table of contents
|
||||
*/
|
||||
class InsetLOT: public InsetCommand {
|
||||
class InsetLOT : public InsetCommand {
|
||||
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"); }
|
||||
|
||||
//void Edit(int, int);
|
||||
///
|
||||
unsigned char Editable() const {
|
||||
return 0; // not yet
|
||||
|
@ -24,22 +24,22 @@
|
||||
Useful to load a parent document from a child document and to
|
||||
share parent's properties between preambleless children.
|
||||
*/
|
||||
class InsetParent: public InsetCommand {
|
||||
class InsetParent : public InsetCommand {
|
||||
public:
|
||||
/// Non-standard LyX macro
|
||||
InsetParent(): InsetCommand("lyxparent") { }
|
||||
InsetParent() : InsetCommand("lyxparent") {}
|
||||
///
|
||||
InsetParent(string fn, Buffer * owner= 0);
|
||||
///
|
||||
~InsetParent() {}
|
||||
InsetParent(string fn, Buffer * owner = 0);
|
||||
///
|
||||
int Latex(FILE * 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);
|
||||
///
|
||||
|
@ -309,7 +309,7 @@ void InsetQuotes::Validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
InsetQuotes * InsetQuotes::Clone() const
|
||||
Inset * InsetQuotes::Clone() const
|
||||
{
|
||||
return new InsetQuotes(language, side, times);
|
||||
}
|
||||
|
@ -69,8 +69,6 @@ public:
|
||||
InsetQuotes(string const & str = "eld");
|
||||
/// Create the right quote inset after character c
|
||||
InsetQuotes(char c, BufferParams const & params);
|
||||
///
|
||||
~InsetQuotes() {}; //nothing to do
|
||||
|
||||
///
|
||||
int Ascent(LyXFont const & font) const;
|
||||
@ -97,7 +95,7 @@ public:
|
||||
///
|
||||
void Validate(LaTeXFeatures &) const;
|
||||
///
|
||||
InsetQuotes * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const;
|
||||
private:
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
///
|
||||
~InsetRef();
|
||||
///
|
||||
InsetRef * Clone() const {
|
||||
Inset * Clone() const {
|
||||
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);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
struct LaTeXFeatures;
|
||||
|
||||
/// Used to insert special chars
|
||||
class InsetSpecialChar: public Inset {
|
||||
class InsetSpecialChar : public Inset {
|
||||
public:
|
||||
|
||||
/// The different kinds of special chars we support
|
||||
@ -61,7 +61,7 @@ public:
|
||||
///
|
||||
int DocBook(string & file);
|
||||
///
|
||||
InsetSpecialChar * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
Inset::Code LyxCode() const
|
||||
{
|
||||
|
@ -23,14 +23,14 @@
|
||||
|
||||
/** Used to insert table of contents
|
||||
*/
|
||||
class InsetTOC: public InsetCommand {
|
||||
class InsetTOC : public InsetCommand {
|
||||
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"); }
|
||||
/// On edit, we open the TOC pop-up
|
||||
|
@ -23,7 +23,7 @@ struct LaTeXFeatures;
|
||||
|
||||
/** The url inset
|
||||
*/
|
||||
class InsetUrl: public InsetCommand {
|
||||
class InsetUrl : public InsetCommand {
|
||||
public:
|
||||
///
|
||||
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;
|
||||
}
|
||||
///
|
||||
@ -46,7 +46,7 @@ public:
|
||||
///
|
||||
~InsetUrl();
|
||||
///
|
||||
InsetUrl * Clone() const { return new InsetUrl(getCommand()); }
|
||||
Inset * Clone() const { return new InsetUrl(getCommand()); }
|
||||
///
|
||||
Inset::Code LyxCode() const { return Inset::URL_CODE; }
|
||||
///
|
||||
|
@ -172,7 +172,7 @@ public:
|
||||
class UpdatableInset: public Inset {
|
||||
public:
|
||||
///
|
||||
virtual ~UpdatableInset() {}
|
||||
//virtual ~UpdatableInset() {}
|
||||
///
|
||||
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(),
|
||||
".tex", false));
|
||||
|
||||
FilePtr myfile(s, FilePtr::read);
|
||||
if (myfile() &&
|
||||
FileInfo fi(s);
|
||||
if (fi.readable() &&
|
||||
!AskQuestion(_("File already exists:"),
|
||||
MakeDisplayPath(s, 50),
|
||||
_("Do you want to overwrite the file?"))) {
|
||||
@ -857,8 +857,8 @@ void MenuMakeLinuxDoc(Buffer *buffer)
|
||||
string s = ChangeExtension (buffer->getFileName(),
|
||||
".sgml", false);
|
||||
|
||||
FilePtr myfile(s, FilePtr::read);
|
||||
if (myfile() &&
|
||||
FileInfo fi(s);
|
||||
if (fi.readable() &&
|
||||
!AskQuestion(_("File already exists:"),
|
||||
MakeDisplayPath(s, 50),
|
||||
_("Do you want to overwrite the file?"))) {
|
||||
@ -890,8 +890,8 @@ void MenuMakeDocBook(Buffer *buffer)
|
||||
string s = ChangeExtension (buffer->getFileName(),
|
||||
".sgml", false);
|
||||
|
||||
FilePtr myfile(s, FilePtr::read);
|
||||
if (myfile() &&
|
||||
FileInfo fi(s);
|
||||
if (fi.readable() &&
|
||||
!AskQuestion(_("File already exists:"),
|
||||
MakeDisplayPath(s, 50),
|
||||
_("Do you want to overwrite the file?"))) {
|
||||
@ -917,8 +917,8 @@ void MenuMakeAscii(Buffer *buffer)
|
||||
string s = ChangeExtension (buffer->getFileName(),
|
||||
".txt", false);
|
||||
|
||||
FilePtr myfile(s, FilePtr::read);
|
||||
if (myfile() &&
|
||||
FileInfo fi(s);
|
||||
if (fi.readable() &&
|
||||
!AskQuestion(_("File already exists:"),
|
||||
MakeDisplayPath(s, 50),
|
||||
_("Do you want to overwrite the file?"))) {
|
||||
@ -1086,7 +1086,6 @@ Buffer * NewLyxFile(string const & filename)
|
||||
void InsertAsciiFile(string const & f, bool asParagraph)
|
||||
{
|
||||
string fname = f;
|
||||
LyXParagraph *tmppar;
|
||||
LyXFileDlg fileDlg;
|
||||
|
||||
if (!current_view->getScreen()) return;
|
||||
@ -1101,15 +1100,20 @@ void InsertAsciiFile(string const & f, bool asParagraph)
|
||||
}
|
||||
|
||||
FileInfo fi(fname);
|
||||
FilePtr myfile(fname, FilePtr::read);
|
||||
|
||||
if (!fi.exist() || !fi.readable() || !myfile()) {
|
||||
WriteFSAlert(_("Error! Cannot open specified file:"),
|
||||
if (!fi.readable()) {
|
||||
WriteFSAlert(_("Error! Specified file is unreadable: "),
|
||||
MakeDisplayPath(fname, 50));
|
||||
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);
|
||||
|
||||
// set the end of the string
|
||||
|
@ -421,7 +421,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
|
||||
box = LyXFunc::OK;
|
||||
break;
|
||||
}
|
||||
flag = func_status(flag | box);
|
||||
flag |= box;
|
||||
|
||||
|
||||
return flag;
|
||||
@ -2580,8 +2580,8 @@ void LyXFunc::MenuNew(bool fromTemplate)
|
||||
|
||||
// Check whether the file already exists
|
||||
if (IsLyXFilename(s)) {
|
||||
FilePtr myfile(s, FilePtr::read);
|
||||
if (myfile() &&
|
||||
FileInfo fi(s);
|
||||
if (fi.readable() &&
|
||||
AskQuestion(_("File already exists:"),
|
||||
MakeDisplayPath(s, 50),
|
||||
_("Do you want to open the document?"))) {
|
||||
|
@ -29,7 +29,6 @@ public:
|
||||
ToggleOn = 4,
|
||||
ToggleOff = 8
|
||||
};
|
||||
|
||||
///
|
||||
LyXFunc(LyXView *);
|
||||
|
||||
@ -168,4 +167,10 @@ void LyXFunc::setHintMessage(bool hm)
|
||||
show_sc = hm;
|
||||
}
|
||||
|
||||
inline
|
||||
void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f)
|
||||
{
|
||||
fs = static_cast<LyXFunc::func_status>(fs | f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -39,60 +39,53 @@
|
||||
#include "debug.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 MiniBuffer *minibuffer;
|
||||
extern MiniBuffer * minibuffer;
|
||||
extern void ShowLockedInsetCursor(long, long, int, int);
|
||||
extern void HideLockedInsetCursor(long, long, int, int);
|
||||
extern void FitLockedInsetCursor(long, long, int, int);
|
||||
extern int LockInset(UpdatableInset*);
|
||||
extern int UnlockInset(UpdatableInset*);
|
||||
extern int LockInset(UpdatableInset *);
|
||||
extern int UnlockInset(UpdatableInset *);
|
||||
|
||||
|
||||
extern GC canvasGC, mathGC, mathLineGC, latexGC, cursorGC, mathFrameGC;
|
||||
extern char *mathed_label;
|
||||
extern char * mathed_label;
|
||||
|
||||
extern int mono_video;
|
||||
extern int fast_selection;
|
||||
|
||||
extern BufferView *current_view;
|
||||
extern BufferView * current_view;
|
||||
extern BufferList bufferlist;
|
||||
extern char const *latex_special_chars;
|
||||
extern char const * latex_special_chars;
|
||||
|
||||
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;
|
||||
|
||||
// local global
|
||||
static int sel_x, sel_y;
|
||||
static bool sel_flag;
|
||||
MathedCursor* InsetFormula::mathcursor = 0;
|
||||
MathedCursor * InsetFormula::mathcursor = 0;
|
||||
|
||||
|
||||
int MathedInset::df_asc;
|
||||
int MathedInset::df_des;
|
||||
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)
|
||||
{
|
||||
return (token!= LM_TK_FRAC && token!= LM_TK_SQRT &&
|
||||
!((token == LM_TK_SYM || token == LM_TC_BSYM) && id<255));
|
||||
return (token != LM_TK_FRAC && token != LM_TK_SQRT &&
|
||||
!((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)
|
||||
{
|
||||
@ -157,19 +150,21 @@ LyXFont WhichFont(short type, int size)
|
||||
break;
|
||||
}
|
||||
|
||||
if (type!= LM_TC_TEXTRM)
|
||||
if (type != LM_TC_TEXTRM)
|
||||
f.setColor(LyXFont::MATH);
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
//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[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);
|
||||
|
||||
byte sx[80];
|
||||
if (MathIsBinary(type)) {
|
||||
byte *ps = &sx[0];
|
||||
for (int i= 0; i<ls && i<75; i++) {
|
||||
byte * ps = &sx[0];
|
||||
for (int i = 0; i < ls && i < 75; ++i) {
|
||||
*(ps++) = ' ';
|
||||
*(ps++) = s[i];
|
||||
*(ps++) = ' ';
|
||||
}
|
||||
*(ps++) = '\0';
|
||||
ls = 3*ls;
|
||||
ls *= 3;
|
||||
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 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);
|
||||
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);
|
||||
asc = des = 0;
|
||||
for (int i= 0; i<ls; i++) {
|
||||
for (int i = 0; i < ls; ++i) {
|
||||
if (font.descent(s[i]) > des)
|
||||
des = font.descent(s[i]);
|
||||
if (font.ascent(s[i]) > asc)
|
||||
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);
|
||||
asc = des = 0;
|
||||
des = font.descent(c);
|
||||
asc = font.ascent(c);
|
||||
return asc+des;
|
||||
return asc + des;
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
byte sx[80];
|
||||
if (MathIsBinary(type)) {
|
||||
byte *ps = &sx[0];
|
||||
for (int i= 0; i<ls && i < 75; i++) {
|
||||
byte * ps = &sx[0];
|
||||
for (int i = 0; i < ls && i < 75; ++i) {
|
||||
*(ps++) = ' ';
|
||||
*(ps++) = s[i];
|
||||
*(ps++) = ' ';
|
||||
}
|
||||
// *ps = ' ';
|
||||
ls = 3*ls;
|
||||
ls *= 3;
|
||||
s = &sx[0];
|
||||
}
|
||||
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) ?
|
||||
new MathMatrixInset((MathMatrixInset*)p):
|
||||
@ -309,26 +309,29 @@ InsetFormula::InsetFormula(MathParInset *p)
|
||||
//label = 0;
|
||||
}
|
||||
|
||||
|
||||
InsetFormula::~InsetFormula()
|
||||
{
|
||||
delete par;
|
||||
//if (label) delete label;
|
||||
}
|
||||
|
||||
InsetFormula * InsetFormula::Clone() const
|
||||
|
||||
Inset * InsetFormula::Clone() const
|
||||
{
|
||||
InsetFormula * f = new InsetFormula(par);
|
||||
f->label = label;
|
||||
return f;
|
||||
}
|
||||
|
||||
void InsetFormula::Write(FILE *file)
|
||||
|
||||
void InsetFormula::Write(FILE * file)
|
||||
{
|
||||
fprintf(file, "Formula ");
|
||||
Latex(file, 0);
|
||||
}
|
||||
|
||||
int InsetFormula::Latex(FILE *file, signed char fragile)
|
||||
|
||||
int InsetFormula::Latex(FILE * file, signed char fragile)
|
||||
{
|
||||
int ret = 0;
|
||||
//#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;
|
||||
}
|
||||
|
||||
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
|
||||
// This problem will disapear at 0.13.
|
||||
if (fragile < 0)
|
||||
@ -365,7 +369,7 @@ int InsetFormula::DocBook(string &/*file*/)
|
||||
|
||||
|
||||
// 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
|
||||
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());
|
||||
|
||||
@ -383,7 +387,7 @@ void InsetFormula::Read(LyXLex &lex)
|
||||
mathed_label = 0;
|
||||
mathed_parse(0, 0, &par);
|
||||
par->Metrics();
|
||||
disp_flag = (par->GetType()>0);
|
||||
disp_flag = (par->GetType() > 0);
|
||||
|
||||
// Update line number
|
||||
lex.setLineNo(mathed_parser_lineno());
|
||||
@ -399,45 +403,49 @@ void InsetFormula::Read(LyXLex &lex)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
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();
|
||||
par->Metrics();
|
||||
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
|
||||
unsigned long pm = scr.getForeground();
|
||||
|
||||
lfont_size = f.size();
|
||||
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->Selection()) {
|
||||
int 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);
|
||||
}
|
||||
mathcursor->Draw(pm, (int)x, baseline);
|
||||
mathcursor->Draw(pm, int(x), baseline);
|
||||
} else {
|
||||
// par->Metrics();
|
||||
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) {
|
||||
char s[80];
|
||||
@ -453,7 +461,6 @@ void InsetFormula::Draw(LyXFont f, LyXScreen &scr, int baseline, float &x)
|
||||
} else
|
||||
if (par->GetType() == LM_OT_MPARN) {
|
||||
MathMatrixInset *mt = (MathMatrixInset*)par;
|
||||
//int i= 0;
|
||||
int y;
|
||||
MathedRowSt const* crow = mt->getRowSt();
|
||||
while (crow) {
|
||||
@ -485,7 +492,8 @@ void InsetFormula::Edit(int x, int y)
|
||||
sel_x = sel_y = 0;
|
||||
sel_flag = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void InsetFormula::InsetUnlock()
|
||||
{
|
||||
if (mathcursor) {
|
||||
@ -499,13 +507,15 @@ void InsetFormula::InsetUnlock()
|
||||
UpdateInset(this, false);
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
mathcursor->Interpret(s);
|
||||
UpdateLocal();
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::GetCursorPos(int& x, int& y) const
|
||||
{
|
||||
@ -534,10 +544,12 @@ void InsetFormula::ToggleInsetCursor()
|
||||
cursor_visible = !cursor_visible;
|
||||
}
|
||||
|
||||
void InsetFormula::ShowInsetCursor(){
|
||||
if (!cursor_visible){
|
||||
|
||||
void InsetFormula::ShowInsetCursor()
|
||||
{
|
||||
if (!cursor_visible) {
|
||||
int x, y, asc, desc;
|
||||
if (mathcursor){
|
||||
if (mathcursor) {
|
||||
mathcursor->GetPos(x, y);
|
||||
// x -= par->xo;
|
||||
y -= par->yo;
|
||||
@ -550,11 +562,14 @@ void InsetFormula::ShowInsetCursor(){
|
||||
}
|
||||
}
|
||||
|
||||
void InsetFormula::HideInsetCursor(){
|
||||
|
||||
void InsetFormula::HideInsetCursor()
|
||||
{
|
||||
if (cursor_visible)
|
||||
ToggleInsetCursor();
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::ToggleInsetSelection()
|
||||
{
|
||||
if (!mathcursor)
|
||||
@ -572,14 +587,15 @@ void InsetFormula::ToggleInsetSelection()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::display(bool dspf)
|
||||
{
|
||||
if (dspf!= disp_flag) {
|
||||
if (dspf != disp_flag) {
|
||||
if (dspf) {
|
||||
par->SetType(LM_OT_PAR);
|
||||
par->SetStyle(LM_ST_DISPLAY);
|
||||
} else {
|
||||
if (par->GetType()>= LM_OT_MPAR) {
|
||||
if (par->GetType() >= LM_OT_MPAR) {
|
||||
MathParInset * p = new MathParInset(par);
|
||||
delete par;
|
||||
par = p;
|
||||
@ -588,25 +604,24 @@ void InsetFormula::display(bool dspf)
|
||||
}
|
||||
par->SetType(LM_OT_MIN);
|
||||
par->SetStyle(LM_ST_TEXT);
|
||||
if (!label.empty() && par->GetType()!= LM_OT_MPARN) {
|
||||
if (!label.empty() && par->GetType() != LM_OT_MPARN) {
|
||||
label.clear();
|
||||
}
|
||||
}
|
||||
disp_flag = dspf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int InsetFormula::GetNumberOfLabels() const
|
||||
{
|
||||
// This is dirty, I know. I'll clean it at 0.13
|
||||
if (par->GetType() == LM_OT_MPARN) {
|
||||
MathMatrixInset * mt = (MathMatrixInset*)par;
|
||||
MathMatrixInset * mt = static_cast<MathMatrixInset*>(par);
|
||||
int nl = 0;
|
||||
MathedRowSt const * crow = mt->getRowSt();
|
||||
while (crow) {
|
||||
if (crow->getLabel()) nl++;
|
||||
if (crow->getLabel()) ++nl;
|
||||
crow = crow->getNext();
|
||||
}
|
||||
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.
|
||||
if (par->GetType() == LM_OT_MPARN) {
|
||||
string lab;
|
||||
MathMatrixInset * mt = (MathMatrixInset*)par;
|
||||
int nl= 0;
|
||||
MathMatrixInset * mt = static_cast<MathMatrixInset*>(par);
|
||||
int nl = 0;
|
||||
MathedRowSt const * crow = mt->getRowSt();
|
||||
while (crow) {
|
||||
if (crow->getLabel()) {
|
||||
@ -633,7 +648,7 @@ string InsetFormula::getLabel(int il) const
|
||||
lab = crow->getLabel();
|
||||
break;
|
||||
}
|
||||
nl++;
|
||||
++nl;
|
||||
}
|
||||
crow = crow->getNext();
|
||||
}
|
||||
@ -642,13 +657,13 @@ string InsetFormula::getLabel(int il) const
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
void InsetFormula::UpdateLocal()
|
||||
{
|
||||
par->Metrics(); // To inform lyx kernel the exact size
|
||||
// (there were problems with arrays).
|
||||
UpdateInset(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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*/)
|
||||
{
|
||||
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*/)
|
||||
{
|
||||
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;
|
||||
HideInsetCursor();
|
||||
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 *)
|
||||
{
|
||||
lyxerr[Debug::MATHED] << "Used InsetFormula::InsetKeyPress." << endl;
|
||||
}
|
||||
|
||||
|
||||
// Special Mathed functions
|
||||
bool InsetFormula::SetNumber(bool numbf)
|
||||
{
|
||||
if (disp_flag) {
|
||||
short type = par->GetType();
|
||||
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);
|
||||
return oldf;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
|
||||
bool InsetFormula::LocalDispatch(int action, char const * arg)
|
||||
{
|
||||
// extern char *dispatch_result;
|
||||
MathedTextCodes varcode = LM_TC_MIN;
|
||||
@ -726,10 +746,11 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
bool space_on = false;
|
||||
bool was_selection = mathcursor->Selection();
|
||||
bool result = true;
|
||||
static MathSpaceInset* sp= 0;
|
||||
static MathSpaceInset * sp= 0;
|
||||
|
||||
HideInsetCursor();
|
||||
if (mathcursor->Selection() && (fast_selection || mono_video)) ToggleInsetSelection();
|
||||
if (mathcursor->Selection() && (fast_selection || mono_video))
|
||||
ToggleInsetSelection();
|
||||
|
||||
if (mathcursor->getLastCode() == LM_TC_TEX) {
|
||||
varcode = LM_TC_TEX;
|
||||
@ -790,7 +811,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
if (!mathcursor->Left())
|
||||
break;
|
||||
|
||||
if (!mathcursor-> InMacroMode() && mathcursor->pullArg()) {
|
||||
if (!mathcursor->InMacroMode() && mathcursor->pullArg()) {
|
||||
UpdateInset(this);
|
||||
break;
|
||||
}
|
||||
@ -858,7 +879,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
// Greek keyboard
|
||||
case LFUN_GREEK_TOGGLE:
|
||||
{
|
||||
greek_kb_flag = (greek_kb_flag) ? 0: 2;
|
||||
greek_kb_flag = (greek_kb_flag) ? 0 : 2;
|
||||
if (greek_kb_flag)
|
||||
minibuffer->Set(_("Math greek keyboard on"));
|
||||
else
|
||||
@ -925,7 +946,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
|
||||
case LFUN_MATH_SIZE:
|
||||
if (arg) {
|
||||
latexkeys *l = in_word_set (arg, strlen(arg));
|
||||
latexkeys * l = in_word_set (arg, strlen(arg));
|
||||
int sz = (l) ? l->id: -1;
|
||||
mathcursor->SetSize(sz);
|
||||
UpdateLocal();
|
||||
@ -945,22 +966,22 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
int k, m, n;
|
||||
char s[80], arg2[80];
|
||||
// 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);
|
||||
s[79] = (char)0;
|
||||
s[79] = '\0';
|
||||
|
||||
if (k<1) {
|
||||
if (k < 1) {
|
||||
m = n = 1;
|
||||
} else if (k == 1) {
|
||||
n = 1;
|
||||
}
|
||||
|
||||
MathMatrixInset *p = new MathMatrixInset(m, n);
|
||||
MathMatrixInset * p = new MathMatrixInset(m, n);
|
||||
if (mathcursor && p) {
|
||||
if (k>2 && (int)strlen(s)>m)
|
||||
if (k > 2 && int(strlen(s)) > m)
|
||||
p->SetAlign(s[0], &s[1]);
|
||||
mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
|
||||
UpdateLocal();
|
||||
UpdateLocal();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -970,16 +991,16 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
LockedInsetStoreUndo(Undo::INSERT);
|
||||
char lf[40], rg[40], arg2[40];
|
||||
int ilf = '(', irg = '.';
|
||||
latexkeys *l;
|
||||
latexkeys * l;
|
||||
string vdelim("(){}[]./|");
|
||||
|
||||
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);
|
||||
lf[39] = (char)0; rg[39] = (char)0;
|
||||
lf[39] = '\0'; rg[39] = '\0';
|
||||
|
||||
if (n>0) {
|
||||
if (IsDigit(lf[0]))
|
||||
if (n > 0) {
|
||||
if (isdigit(lf[0]))
|
||||
ilf = atoi(lf);
|
||||
else
|
||||
if (lf[1]) {
|
||||
@ -990,8 +1011,8 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
if (vdelim.find(lf[0]) != string::npos)
|
||||
ilf = lf[0];
|
||||
|
||||
if (n>1) {
|
||||
if (IsDigit(rg[0]))
|
||||
if (n > 1) {
|
||||
if (isdigit(rg[0]))
|
||||
irg = atoi(rg);
|
||||
else
|
||||
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);
|
||||
UpdateLocal();
|
||||
break;
|
||||
@ -1022,11 +1043,11 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
case LFUN_INSERT_LABEL:
|
||||
{
|
||||
LockedInsetStoreUndo(Undo::INSERT);
|
||||
if (par->GetType()<LM_OT_PAR) break;
|
||||
if (par->GetType() < LM_OT_PAR) break;
|
||||
string lb = arg;
|
||||
if (lb.empty())
|
||||
lb = string(askForText(_("Enter new label to insert:")));
|
||||
if (!lb.empty() && lb[0]> ' ') {
|
||||
if (!lb.empty() && lb[0] > ' ') {
|
||||
SetNumber(true);
|
||||
if (par->GetType() == LM_OT_MPARN) {
|
||||
mathcursor->setLabel(lb.c_str());
|
||||
@ -1039,7 +1060,6 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
UpdateLocal();
|
||||
} else
|
||||
label.clear();
|
||||
//label = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1174,8 +1194,10 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
if (was_macro!= mathcursor->InMacroMode()&&action>= 0&&action!= LFUN_BACKSPACE)
|
||||
UpdateLocal();
|
||||
if (was_macro != mathcursor->InMacroMode()
|
||||
&& action >= 0
|
||||
&& action != LFUN_BACKSPACE)
|
||||
UpdateLocal();
|
||||
if (sp && !space_on) sp = 0;
|
||||
if (mathcursor->Selection() || (was_selection && !(fast_selection || mono_video)))
|
||||
ToggleInsetSelection();
|
||||
@ -1192,12 +1214,12 @@ bool InsetFormula::LocalDispatch(int action, char const *arg)
|
||||
void
|
||||
MathFuncInset::Draw(int x, int y)
|
||||
{
|
||||
if (name && name[0]>' ') {
|
||||
if (name && name[0] > ' ') {
|
||||
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
|
||||
font.setLatex(LyXFont::ON);
|
||||
x += (font.textWidth("I", 1)+3)/4;
|
||||
if (mono_video) {
|
||||
int a= font.maxAscent(), d= font.maxDescent();
|
||||
int a = font.maxAscent(), d = font.maxDescent();
|
||||
XFillRectangle (fl_display, pm, getGC(gc_copy),
|
||||
x, y-a,
|
||||
font.textWidth(name, strlen(name)), a+d);
|
||||
@ -1214,24 +1236,26 @@ void MathFuncInset::Metrics()
|
||||
LyXFont font = WhichFont(LM_TC_TEXTRM, size);
|
||||
font.setLatex(LyXFont::ON);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void mathedValidate(LaTeXFeatures &features, MathParInset *par)
|
||||
static
|
||||
void mathedValidate(LaTeXFeatures & features, MathParInset * par)
|
||||
{
|
||||
MathedIter it(par->GetData());
|
||||
|
||||
while (it.OK() && !(features.binom && features.boldsymbol)) {
|
||||
if (it.IsInset()) {
|
||||
if(it.IsActive()) {
|
||||
MathParInset *p = it.GetActiveInset();
|
||||
MathParInset * p = it.GetActiveInset();
|
||||
if (!features.binom && p->GetType() == LM_OT_MACRO &&
|
||||
strcmp(p->GetName(), "binom") == 0) {
|
||||
features.binom = true;
|
||||
} else {
|
||||
for (int i= 0; i<= p->getMaxArgumentIdx(); i++) {
|
||||
for (int i = 0; i <= p->getMaxArgumentIdx(); ++i) {
|
||||
p->setArgumentIdx(i);
|
||||
mathedValidate(features, p);
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
///
|
||||
void Validate(LaTeXFeatures &) const;
|
||||
///
|
||||
InsetFormula * Clone() const;
|
||||
Inset * Clone() const;
|
||||
///
|
||||
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);
|
||||
}
|
||||
|
@ -23,9 +23,6 @@
|
||||
|
||||
#include "formula.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class MathMacroTemplate;
|
||||
|
||||
|
||||
@ -35,49 +32,47 @@ public:
|
||||
///
|
||||
InsetFormulaMacro();
|
||||
///
|
||||
InsetFormulaMacro(string name, int na= 0, bool env= false);
|
||||
InsetFormulaMacro(string name, int na = 0, bool env = false);
|
||||
///
|
||||
~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);
|
||||
///
|
||||
InsetFormulaMacro * Clone() const;
|
||||
Inset * Clone() const;
|
||||
|
||||
/// 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 InsetUnlock();
|
||||
|
||||
bool LocalDispatch(int, char const*);
|
||||
bool LocalDispatch(int, char const *);
|
||||
|
||||
protected:
|
||||
void UpdateLocal();
|
||||
private:
|
||||
bool opened;
|
||||
string name;
|
||||
class MathMacroTemplate* tmacro;
|
||||
class MathMacroTemplate * tmacro;
|
||||
|
||||
};
|
||||
|
||||
|
@ -328,7 +328,7 @@ class MathParInset: public MathedInset {
|
||||
///
|
||||
virtual ~MathParInset();
|
||||
///
|
||||
virtual MathParInset * Clone();
|
||||
virtual MathedInset * Clone();
|
||||
|
||||
/// Draw the object on a drawable
|
||||
virtual void Draw(int x, int baseline);
|
||||
@ -482,7 +482,7 @@ class MathMatrixInset: public MathParInset {
|
||||
///
|
||||
MathMatrixInset(MathMatrixInset *);
|
||||
///
|
||||
MathMatrixInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
virtual ~MathMatrixInset();
|
||||
///
|
||||
|
@ -52,8 +52,8 @@ MathedInset::MathedInset(MathedInset * inset)
|
||||
}
|
||||
|
||||
|
||||
MathFuncInset::MathFuncInset(char const * nm, short ot, short st):
|
||||
MathedInset("", ot, st)
|
||||
MathFuncInset::MathFuncInset(char const * nm, short ot, short st)
|
||||
: MathedInset("", ot, st)
|
||||
{
|
||||
ln = 0;
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
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;
|
||||
ascent = 8;
|
||||
@ -101,7 +96,9 @@ MathParInset::MathParInset(short st, char const * nm, short ot):
|
||||
flag |= LMPF_SCRIPT;
|
||||
}
|
||||
|
||||
MathParInset::MathParInset(MathParInset * p): MathedInset(p)
|
||||
|
||||
MathParInset::MathParInset(MathParInset * p)
|
||||
: MathedInset(p)
|
||||
{
|
||||
flag = p->flag;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
MathedIter it(array);
|
||||
@ -164,16 +156,18 @@ MathSqrtInset * MathSqrtInset::Clone()
|
||||
|
||||
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):
|
||||
MathParInset(st, "", LM_OT_DELIM), left(l), right(r)
|
||||
{
|
||||
}
|
||||
MathDelimInset::MathDelimInset(int l, int r, short st)
|
||||
: MathParInset(st, "", LM_OT_DELIM), left(l), right(r) {}
|
||||
|
||||
MathDelimInset * MathDelimInset::Clone()
|
||||
|
||||
MathedInset * MathDelimInset::Clone()
|
||||
{
|
||||
MathDelimInset * p = new MathDelimInset(left, right, GetStyle());
|
||||
MathedIter it(array);
|
||||
@ -182,13 +176,14 @@ MathDelimInset * MathDelimInset::Clone()
|
||||
}
|
||||
|
||||
|
||||
MathDecorationInset::MathDecorationInset(int d, short st):
|
||||
MathParInset(st, "", LM_OT_DECO), deco(d)
|
||||
MathDecorationInset::MathDecorationInset(int d, short st)
|
||||
: MathParInset(st, "", LM_OT_DECO), deco(d)
|
||||
{
|
||||
upper = (deco!= LM_underline && deco!= LM_underbrace);
|
||||
}
|
||||
|
||||
MathDecorationInset * MathDecorationInset::Clone()
|
||||
|
||||
MathedInset * MathDecorationInset::Clone()
|
||||
{
|
||||
MathDecorationInset * p = new MathDecorationInset(deco, GetStyle());
|
||||
MathedIter it(array);
|
||||
@ -196,7 +191,9 @@ MathDecorationInset * MathDecorationInset::Clone()
|
||||
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
|
||||
@ -208,12 +205,14 @@ MathFracInset::MathFracInset(short ot): MathParInset(LM_ST_TEXT, "frac", ot)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MathFracInset::~MathFracInset()
|
||||
{
|
||||
delete den;
|
||||
}
|
||||
|
||||
MathFracInset * MathFracInset::Clone()
|
||||
|
||||
MathedInset * MathFracInset::Clone()
|
||||
{
|
||||
MathFracInset * p = new MathFracInset(GetType());
|
||||
MathedIter itn(array);
|
||||
@ -224,6 +223,7 @@ MathFracInset * MathFracInset::Clone()
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
bool MathFracInset::setArgumentIdx(int i)
|
||||
{
|
||||
if (i == 0 || i == 1) {
|
||||
@ -238,15 +238,19 @@ void MathFracInset::SetStyle(short st)
|
||||
{
|
||||
MathParInset::SetStyle(st);
|
||||
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)
|
||||
{
|
||||
den->SetData(d);
|
||||
MathParInset::SetData(n);
|
||||
}
|
||||
|
||||
|
||||
void MathFracInset::SetData(LyxArrayBase * d)
|
||||
{
|
||||
if (idx == 0)
|
||||
@ -256,6 +260,7 @@ void MathFracInset::SetData(LyxArrayBase * d)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MathFracInset::GetXY(int & x, int & y) const
|
||||
{
|
||||
if (idx == 0)
|
||||
@ -263,7 +268,8 @@ void MathFracInset::GetXY(int & x, int & y) const
|
||||
else
|
||||
den->GetXY(x, y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
LyxArrayBase * MathFracInset::GetData()
|
||||
{
|
||||
if (idx == 0)
|
||||
@ -275,11 +281,12 @@ LyxArrayBase * MathFracInset::GetData()
|
||||
|
||||
bool MathFracInset::Inside(int x, int y)
|
||||
{
|
||||
int xx = xo - (width-w0)/2;
|
||||
int xx = xo - (width - w0) / 2;
|
||||
|
||||
return (x>= xx && x<= xx+width && 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)
|
||||
{
|
||||
// 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):
|
||||
MathParInset(st, "array", LM_OT_MATRIX), nc(m)
|
||||
MathMatrixInset::MathMatrixInset(int m, int n, short st)
|
||||
: MathParInset(st, "array", LM_OT_MATRIX), nc(m)
|
||||
{
|
||||
ws = new int[nc];
|
||||
v_align = 0;
|
||||
h_align = new char[nc+1];
|
||||
for (int i = 0; i < nc; i++) h_align[i] = 'c';
|
||||
h_align = new char[nc + 1];
|
||||
for (int i = 0; i < nc; ++i) h_align[i] = 'c';
|
||||
h_align[nc] = '\0';
|
||||
nr = 0;
|
||||
row = 0;
|
||||
flag = 15;
|
||||
if (n>0) {
|
||||
if (n > 0) {
|
||||
row = new MathedRowSt(nc+1);
|
||||
MathedXIter it(this);
|
||||
for (int j = 1; j < n; j++) it.addRow();
|
||||
for (int j = 1; j < n; ++j) it.addRow();
|
||||
nr = n;
|
||||
if (nr == 1 && nc>1) {
|
||||
for (int j = 0; j < nc - 1; j++)
|
||||
if (nr == 1 && nc > 1) {
|
||||
for (int j = 0; j < nc - 1; ++j)
|
||||
it.Insert('T', LM_TC_TAB);
|
||||
}
|
||||
} else if (n<0) {
|
||||
row = new MathedRowSt(nc+1);
|
||||
} else if (n < 0) {
|
||||
row = new MathedRowSt(nc + 1);
|
||||
nr = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MathMatrixInset::MathMatrixInset(MathMatrixInset * mt):
|
||||
MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType())
|
||||
MathMatrixInset::MathMatrixInset(MathMatrixInset * mt)
|
||||
: MathParInset(mt->GetStyle(), mt->GetName(), mt->GetType())
|
||||
{
|
||||
nr = 0;
|
||||
nr = 0;
|
||||
nc = mt->nc;
|
||||
ws = new int[nc];
|
||||
h_align = new char[nc+1];
|
||||
h_align = new char[nc + 1];
|
||||
strcpy(h_align, mt->GetAlign(&v_align));
|
||||
MathedIter it;
|
||||
MathedIter it;
|
||||
it.SetData(mt->GetData());
|
||||
array = it.Copy();
|
||||
if (mt->row != 0) {
|
||||
MathedRowSt *r, *ro= 0, *mrow = mt->row;
|
||||
mrow = mt->row;
|
||||
MathedRowSt * r, * ro= 0, * mrow = mt->row;
|
||||
//mrow = mt->row; // This must be redundant...
|
||||
while (mrow) {
|
||||
r = new MathedRowSt(nc+1);
|
||||
r = new MathedRowSt(nc + 1);
|
||||
r->numbered = mrow->numbered;
|
||||
if (mrow->label)
|
||||
r->label = strnew(mrow->label);
|
||||
@ -339,7 +346,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset * mt):
|
||||
ro->next = r;
|
||||
mrow = mrow->next;
|
||||
ro = r;
|
||||
nr++;
|
||||
++nr;
|
||||
}
|
||||
} else
|
||||
row = 0;
|
||||
@ -359,13 +366,14 @@ MathMatrixInset::~MathMatrixInset()
|
||||
}
|
||||
}
|
||||
|
||||
MathMatrixInset * MathMatrixInset::Clone()
|
||||
{
|
||||
MathMatrixInset * mt = new MathMatrixInset(this);
|
||||
return mt;
|
||||
|
||||
MathedInset * MathMatrixInset::Clone()
|
||||
{
|
||||
return new MathMatrixInset(this);
|
||||
}
|
||||
|
||||
void MathMatrixInset::SetAlign(char vv, char const* hh)
|
||||
|
||||
void MathMatrixInset::SetAlign(char vv, char const * hh)
|
||||
{
|
||||
v_align = vv;
|
||||
strncpy(h_align, hh, nc);
|
||||
@ -377,29 +385,29 @@ void MathMatrixInset::SetData(LyxArrayBase * a)
|
||||
{
|
||||
if (!a) return;
|
||||
MathedIter it(a);
|
||||
int nn = nc-1;
|
||||
int nn = nc - 1;
|
||||
nr = 1;
|
||||
// count tabs per row
|
||||
while (it.OK()) {
|
||||
if (it.IsTab()) {
|
||||
if (nn<0) {
|
||||
if (nn < 0) {
|
||||
it.Delete();
|
||||
continue;
|
||||
} else {
|
||||
// it.Next();
|
||||
nn--;
|
||||
--nn;
|
||||
}
|
||||
}
|
||||
if (it.IsCR()) {
|
||||
while (nn>0) {
|
||||
while (nn > 0) {
|
||||
it.Insert(' ', LM_TC_TAB);
|
||||
nn--;
|
||||
--nn;
|
||||
}
|
||||
nn = nc-1;
|
||||
nr++;
|
||||
nn = nc - 1;
|
||||
++nr;
|
||||
}
|
||||
it.Next();
|
||||
}
|
||||
}
|
||||
it.Reset();
|
||||
|
||||
// Automatically inserts tabs around bops
|
||||
@ -413,10 +421,11 @@ void MathMatrixInset::Draw(int x, int baseline)
|
||||
MathParInset::Draw(x, baseline);
|
||||
}
|
||||
|
||||
|
||||
void MathMatrixInset::Metrics()
|
||||
{
|
||||
int i, /*cy,*/ hl, h= 0;
|
||||
MathedRowSt *cprow= 0, *cxrow;
|
||||
int i, hl, h= 0;
|
||||
MathedRowSt * cprow= 0, * cxrow;
|
||||
|
||||
if (!row) {
|
||||
// lyxerr << " MIDA ";
|
||||
@ -427,14 +436,14 @@ void MathMatrixInset::Metrics()
|
||||
// Clean the arrays
|
||||
cxrow = row;
|
||||
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;
|
||||
}
|
||||
|
||||
// Basic metrics
|
||||
MathParInset::Metrics();
|
||||
|
||||
if (nc<= 1 && !row->next) {
|
||||
if (nc <= 1 && !row->next) {
|
||||
row->asc = ascent;
|
||||
row->desc = descent;
|
||||
}
|
||||
@ -442,7 +451,7 @@ void MathMatrixInset::Metrics()
|
||||
// Vertical positions of each row
|
||||
cxrow = row;
|
||||
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->next == 0 && ws[i] == 0) ws[i] = df_width;
|
||||
}
|
||||
@ -461,7 +470,7 @@ void MathMatrixInset::Metrics()
|
||||
switch (v_align) {
|
||||
case 't': ascent = row->y; 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;
|
||||
|
||||
@ -470,10 +479,10 @@ void MathMatrixInset::Metrics()
|
||||
cxrow = row;
|
||||
width = MATH_COLSEP;
|
||||
while (cxrow) {
|
||||
int rg= MATH_COLSEP, ww, lf= 0, *w = cxrow->w;
|
||||
for (i= 0; i<nc; i++) {
|
||||
int rg = MATH_COLSEP, ww, lf = 0, * w = cxrow->w;
|
||||
for (i = 0; i < nc; ++i) {
|
||||
bool isvoid = false;
|
||||
if (w[i]<= 0) {
|
||||
if (w[i] <= 0) {
|
||||
w[i] = df_width;
|
||||
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;
|
||||
}
|
||||
|
||||
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()
|
||||
@ -511,7 +521,8 @@ MathAccentInset::~MathAccentInset()
|
||||
delete inset;
|
||||
}
|
||||
|
||||
MathAccentInset * MathAccentInset::Clone()
|
||||
|
||||
MathedInset * MathAccentInset::Clone()
|
||||
{
|
||||
MathAccentInset * p;
|
||||
|
||||
@ -524,32 +535,24 @@ MathAccentInset * MathAccentInset::Clone()
|
||||
}
|
||||
|
||||
|
||||
MathBigopInset::MathBigopInset(char const* nam, int id, short st):
|
||||
MathedInset(nam, LM_OT_BIGOP, st), sym(id)
|
||||
MathBigopInset::MathBigopInset(char const* nam, int id, short st)
|
||||
: MathedInset(nam, LM_OT_BIGOP, st), sym(id)
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -38,11 +38,12 @@
|
||||
class MathFuncInset: public MathedInset {
|
||||
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 * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
@ -67,13 +68,13 @@ protected:
|
||||
class MathAccentInset: public MathedInset {
|
||||
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 * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
@ -103,17 +104,17 @@ class MathAccentInset: public MathedInset {
|
||||
class MathDotsInset: public MathedInset {
|
||||
public:
|
||||
///
|
||||
MathDotsInset(char const *, int, short st= LM_ST_TEXT);
|
||||
MathDotsInset(char const *, int, short st = LM_ST_TEXT);
|
||||
///
|
||||
~MathDotsInset() {}
|
||||
///
|
||||
MathDotsInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
void Write(FILE * file);
|
||||
///
|
||||
void Write(string &file);
|
||||
void Write(string & file);
|
||||
///
|
||||
void Metrics();
|
||||
protected:
|
||||
@ -130,7 +131,7 @@ class MathSpaceInset: public MathedInset {
|
||||
///
|
||||
~MathSpaceInset() {}
|
||||
///
|
||||
MathSpaceInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
@ -157,7 +158,7 @@ class MathBigopInset: public MathedInset {
|
||||
///
|
||||
~MathBigopInset() {}
|
||||
///
|
||||
MathBigopInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
@ -184,17 +185,17 @@ class MathBigopInset: public MathedInset {
|
||||
class MathSqrtInset: public MathParInset {
|
||||
public:
|
||||
///
|
||||
MathSqrtInset(short st= LM_ST_TEXT);
|
||||
MathSqrtInset(short st = LM_ST_TEXT);
|
||||
///
|
||||
~MathSqrtInset() {}
|
||||
///
|
||||
MathSqrtInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int x, int baseline);
|
||||
///
|
||||
void Write(FILE *file);
|
||||
void Write(FILE * file);
|
||||
///
|
||||
void Write(string &file);
|
||||
void Write(string & file);
|
||||
///
|
||||
void Metrics();
|
||||
///
|
||||
@ -210,11 +211,11 @@ class MathSqrtInset: public MathParInset {
|
||||
class MathFracInset: public MathParInset {
|
||||
public:
|
||||
///
|
||||
MathFracInset(short ot= LM_OT_FRAC);
|
||||
MathFracInset(short ot = LM_OT_FRAC);
|
||||
///
|
||||
~MathFracInset();
|
||||
///
|
||||
MathFracInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int x, int baseline);
|
||||
///
|
||||
@ -260,11 +261,11 @@ class MathFracInset: public MathParInset {
|
||||
class MathDelimInset: public MathParInset {
|
||||
public:
|
||||
///
|
||||
MathDelimInset(int, int, short st= LM_ST_TEXT);
|
||||
MathDelimInset(int, int, short st = LM_ST_TEXT);
|
||||
///
|
||||
~MathDelimInset() {}
|
||||
///
|
||||
MathDelimInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
@ -285,11 +286,11 @@ class MathDelimInset: public MathParInset {
|
||||
class MathDecorationInset: public MathParInset {
|
||||
public:
|
||||
///
|
||||
MathDecorationInset(int, short st= LM_ST_TEXT);
|
||||
MathDecorationInset(int, short st = LM_ST_TEXT);
|
||||
///
|
||||
~MathDecorationInset() {}
|
||||
///
|
||||
MathDecorationInset * Clone();
|
||||
MathedInset * Clone();
|
||||
///
|
||||
void Draw(int, int);
|
||||
///
|
||||
@ -319,18 +320,21 @@ MathFuncInset::~MathFuncInset()
|
||||
if (fname && GetType() == LM_OT_UNDEF) delete[] fname;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool MathFuncInset::GetLimits() const
|
||||
{
|
||||
return bool(lims && (GetStyle() == LM_ST_DISPLAY));
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void MathFuncInset::Write(FILE * file)
|
||||
{
|
||||
fprintf(file, "\\%s ", name);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void MathFuncInset::Write(string & file)
|
||||
{
|
||||
@ -339,6 +343,7 @@ void MathFuncInset::Write(string & file)
|
||||
file += ' ';
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void MathSpaceInset::Metrics()
|
||||
{
|
||||
@ -349,6 +354,7 @@ void MathSpaceInset::Metrics()
|
||||
ascent = 4; descent = 0;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void MathSpaceInset::SetSpace(int sp)
|
||||
{
|
||||
@ -356,6 +362,7 @@ void MathSpaceInset::SetSpace(int sp)
|
||||
Metrics();
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool MathBigopInset::GetLimits() const
|
||||
{
|
||||
@ -368,12 +375,14 @@ bool MathBigopInset::GetLimits() const
|
||||
return lims > 0;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void MathBigopInset::SetLimits(bool ls)
|
||||
{
|
||||
lims = ls ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
bool MathDecorationInset::GetLimits() const
|
||||
{
|
||||
|
@ -82,8 +82,9 @@ LyXParagraph::LyXParagraph()
|
||||
/* this konstruktor inserts the new paragraph in a list */
|
||||
LyXParagraph::LyXParagraph(LyXParagraph * par)
|
||||
{
|
||||
#warning we also need a reserve here
|
||||
#warning this would be a nice place to shrink par
|
||||
text.reserve(500);
|
||||
par->text.resize(par->text.size());
|
||||
|
||||
for (int i = 0; i < 10; ++i) setCounter(i, 0);
|
||||
appendix = false;
|
||||
enumdepth = 0;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <cctype>
|
||||
#include <pair.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "filetools.h"
|
||||
@ -48,6 +49,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
using std::make_pair;
|
||||
|
||||
extern string system_lyxdir;
|
||||
extern string build_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
@ -962,3 +965,51 @@ bool LyXReadLink(string const & File, string & Link)
|
||||
Link = LinkBuffer;
|
||||
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 */
|
||||
bool LyXReadLink(string const & file, string & Link);
|
||||
|
||||
/* Uses kpsewhich to find tex files */
|
||||
string findtexfile(string const & fil, string const & format);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user