finally apply DepTable patch; simplify file browsing in ControlExternal

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3398 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-01-16 22:17:38 +00:00
parent a61a18e2a0
commit 36aa4ee109
12 changed files with 158 additions and 307 deletions

View File

@ -1,3 +1,7 @@
2002-01-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* examples/fr_EtiquetteMath.lyx: removed
2002-01-16 José Matos <jamatos@fep.up.pt>
* layouts/db_stdlayouts.inc: Fix name for caption.

View File

@ -1,162 +0,0 @@
#LyX 1.1 created this file. For more info see http://www.lyx.org/
\lyxformat 218
\textclass article
\language frenchb
\inputencoding latin1
\fontscheme default
\graphics none
\paperfontsize 10
\spacing single
\papersize a4paper
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language french
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle plain
\layout Title
Numéroter et Étiqueter des équations
\begin_inset Info
Informations de révision :
Traduction : Mise à jour Date: 2001/02/16
Original : Révision: 1.3, Date: 2000/11/03
\end_inset
\layout Author
Alejandro Aguilar-Sierra
\begin_float footnote
\layout Standard
Traduction par Adrien
\noun on
Rebollo
\noun default
\family typewriter
<Adrien.Rebollo@wanadoo.fr>
\family default
.
\end_float
\layout Standard
Une équation simple peut être numérotée de deux façons.
La première est d'invoquer la commande LyX
\family typewriter
math-number
\family default
.
Le numéro correspondant
\begin_float footnote
\layout Standard
Ou un symbole # parce que la vraie numérotation n'est pas encore implémentée.
\end_float
apparaîtra à droite après l'équation.
\layout Standard
\begin_inset Formula \begin{equation}
x=y^{2}-3
\end{equation}
\end_inset
\layout Standard
Fréquemment on se référera au numéro de l'équation dans le document.
Il est plus sûr d'assigner une étiquette à l'équation
\begin_float footnote
\layout Standard
On procède de la même façon que pour une étiquette dans le corps du texte,
mais à partir du mode mathématique.
\end_float
, plutôt que d'utiliser un numéro fixé.
Assigner une étiquette à une équation non numérotée la numérotera automatiqueme
nt.
Avec l'étiquette
\series bold
planck
\series default
on peut se référer à l'équation (
\begin_inset LatexCommand \ref{planck}
\end_inset
).
\layout Standard
\begin_inset Formula \begin{equation}
\label{planck}
E=hv
\end{equation}
\end_inset
\layout Standard
Dans le cas d'équations sur plusieurs lignes, chaque ligne est numérotée
séquentiellement.
Il est possible de supprimer le numéro d'une ligne donnée avec la commande
\family typewriter
math-nonumber
\family default
.
Le curseur doit être sur la rangée dont vous voulez ôter la numérotation.
\layout Standard
\begin_inset Formula \begin{eqnarray}
(x+y)(x-y) & = & x^{2}-xy+xy-y^{2}\nonumber \\
& = & x^{2}-y^{2}
\end{eqnarray}
\end_inset
\layout Standard
Il est possible d'étiqueter plus d'une ligne.
Avec l'équation multi-lignes suivante on peut se référer aux équations
(
\begin_inset LatexCommand \ref{eq:gs1}
\end_inset
) et (
\begin_inset LatexCommand \ref{eq:gs2}
\end_inset
) en utilisant les étiquettes correspondantes.
\layout Standard
\begin_inset Formula \begin{eqnarray}
v_{k+1} & = & w_{k}+b_{1}\label{eq:gs1} \\
w_{k+1} & = & v_{k+1}+b_{2}\label{eq:gs2}
\end{eqnarray}
\end_inset
\layout Standard
Pour voir le résultat final veuillez utiliser une visionneuse ou imprimer
ce document.
\the_end

View File

@ -9,7 +9,6 @@ src/converter.C
src/CutAndPaste.C
src/debug.C
src/exporter.C
src/ext_l10n.h
src/figure_form.C
src/figureForm.C
src/FontLoader.C

View File

@ -1,3 +1,9 @@
2001-12-12 Ben Stanley <bds02@uow.edu.au>
* DepTable.h
* DepTable.C: Implement mtime checking to reduce time spent doing
CRCs.
2002-01-16 Juergen Vigna <jug@sad.it>
* tabular.C (GetAdditionalHeight): one of error fixed.

View File

@ -7,6 +7,7 @@
*
* This file is Copyright 1996-2001
* Lars Gullik Bjønnes
* Ben Stanley
*
* ======================================================
*/
@ -35,69 +36,78 @@ using std::ofstream;
using std::ifstream;
using std::endl;
inline bool DepTable::dep_info::changed() const
{
return crc_prev != crc_cur && crc_cur != 0;
}
void DepTable::insert(string const & fi,
bool upd,
unsigned long one,
unsigned long two)
bool upd)
{
// not quite sure if this is the correct place for MakeAbsPath
string f = MakeAbsPath(fi);
if (deplist.find(f) == deplist.end()) {
long mtime = 0;
dep_info di;
di.crc_prev = 0;
if (upd) {
one = two;
two = lyx::sum(f);
lyxerr[Debug::DEPEND] << " CRC..." << flush;
di.crc_cur = lyx::sum(f);
lyxerr[Debug::DEPEND] << "done." << endl;
struct stat f_info;
stat(fi.c_str(), &f_info);
mtime = f_info.st_mtime;
di.mtime_cur = f_info.st_mtime;
} else {
di.crc_cur = 0;
di.mtime_cur = 0;
}
dep_info di;
di.first = one;
di.second = two;
di.mtime = mtime;
#if 0
deplist[f] = make_pair(one, two);
#else
deplist[f] = di;
#endif
} else {
lyxerr[Debug::DEPEND] << " Already in DepTable" << endl;
}
}
void DepTable::update()
{
for (DepList::iterator itr = deplist.begin();
itr != deplist.end();
++itr) {
unsigned long const one = itr->second.second;
unsigned long two = one;
long mtime = itr->second.mtime;
struct stat f_info;
stat(itr->first.c_str(), &f_info);
lyxerr[Debug::DEPEND] << "Updating DepTable..." << endl;
time_t start_time = time(0);
if (mtime != f_info.st_mtime) {
two = lyx::sum(itr->first);
mtime = f_info.st_mtime;
DepList::iterator itr = deplist.begin();
while (itr != deplist.end()) {
dep_info &di = itr->second;
struct stat f_info;
if (0 == stat(itr->first.c_str(), &f_info) ) {
if (di.mtime_cur == f_info.st_mtime) {
di.crc_prev = di.crc_cur;
lyxerr[Debug::DEPEND] << itr->first << " same mtime";
} else {
di.crc_prev = di.crc_cur;
lyxerr[Debug::DEPEND] << itr->first << " CRC... ";
di.crc_cur = lyx::sum(itr->first);
lyxerr[Debug::DEPEND] << "done";
}
} else {
// file doesn't exist
// remove stale files - if it's re-created, it
// will be re-inserted by deplog.
lyxerr[Debug::DEPEND] << itr->first
<< " doesn't exist. removing from DepTable." << endl;
DepList::iterator doomed = itr++;
deplist.erase(doomed);
continue;
}
#if 0
itr->second = make_pair(one, two);
#else
dep_info di;
di.first = one;
di.second = two;
di.mtime = mtime;
itr->second = di;
#endif
if (lyxerr.debugging(Debug::DEPEND)) {
lyxerr << "Update dep: " << itr->first << " "
<< one << " " << two;
if (one != two)
if (di.changed())
lyxerr << " +";
lyxerr << endl;
}
++itr;
}
time_t time_sec = time(0) - start_time;
lyxerr[Debug::DEPEND] << "Finished updating DepTable ("
<< time_sec << " sec)." << endl;
}
@ -106,7 +116,7 @@ bool DepTable::sumchange() const
for (DepList::const_iterator cit = deplist.begin();
cit != deplist.end();
++cit) {
if ((*cit).second.first != cit->second.second) return true;
if ((*cit).second.changed()) return true;
}
return false;
}
@ -118,8 +128,7 @@ bool DepTable::haschanged(string const & f) const
string fil = MakeAbsPath(f);
DepList::const_iterator cit = deplist.find(fil);
if (cit != deplist.end()) {
if (cit->second.first != cit->second.second
&& cit->second.second != 0)
if (cit->second.changed())
return true;
}
return false;
@ -132,7 +141,7 @@ bool DepTable::extchanged(string const & ext) const
cit != deplist.end();
++cit) {
if (suffixIs(cit->first, ext)) {
if (cit->second.first != cit->second.second)
if (cit->second.changed())
return true;
}
}
@ -140,24 +149,53 @@ bool DepTable::extchanged(string const & ext) const
}
bool DepTable::ext_exist(const string& ext ) const
{
for (DepList::const_iterator cit = deplist.begin();
cit != deplist.end(); ++cit ) {
if ( suffixIs(cit->first, ext) ) {
return true;
}
}
return false;
}
bool DepTable::exist(string const & fil) const
{
DepList::const_iterator cit = deplist.find(fil);
if (cit != deplist.end()) return true;
return false;
return deplist.find(fil) != deplist.end();
}
void DepTable::remove_files_with_extension(string const & suf)
{
DepList tmp;
// we want const_iterator (Lgb)
for (DepList::iterator cit = deplist.begin();
cit != deplist.end(); ++cit) {
if (!suffixIs(cit->first, suf))
tmp[cit->first] = cit->second;
DepList::iterator cit = deplist.begin();
while (cit != deplist.end()) {
if (suffixIs(cit->first, suf)) {
// Can't erase the current iterator, but we can increment and then erase.
// deplist is a map so only the erased iterator is invalidated.
DepList::iterator doomed = cit++;
deplist.erase(doomed);
continue;
}
cit++;
}
}
void DepTable::remove_file(string const & filename)
{
DepList::iterator cit = deplist.begin();
while (cit != deplist.end()) {
if (OnlyFilename(cit->first) == filename) {
// Can't erase the current iterator, but we can increment and then erase.
// deplist is a map so only the erased iterator is invalidated.
DepList::iterator doomed = cit++;
deplist.erase(doomed);
continue;
}
cit++;
}
deplist.swap(tmp);
}
@ -167,16 +205,16 @@ void DepTable::write(string const & f) const
for (DepList::const_iterator cit = deplist.begin();
cit != deplist.end(); ++cit) {
if (lyxerr.debugging(Debug::DEPEND)) {
// Store the second (most recently calculated) CRC value.
// The older one is effectively set to 0 upon re-load.
lyxerr << "Write dep: "
<< cit->first << " "
<< cit->second.first << " "
<< cit->second.second << " "
<< cit->second.mtime << endl;
<< cit->second.crc_cur << " "
<< cit->second.mtime_cur << endl;
}
ofs << cit->first << " "
<< cit->second.first << " "
<< cit->second.second << " "
<< cit->second.mtime << endl;
<< cit->second.crc_cur << " "
<< cit->second.mtime_cur << endl;
}
}
@ -185,26 +223,18 @@ void DepTable::read(string const & f)
{
ifstream ifs(f.c_str());
string nome;
unsigned long one = 0;
unsigned long two = 0;
unsigned long mtime = 0;
dep_info di;
// This doesn't change through the loop.
di.crc_prev = 0;
while (ifs >> nome >> one >> two >> mtime) {
while (ifs >> nome >> di.crc_cur >> di.mtime_cur) {
if (lyxerr.debugging(Debug::DEPEND)) {
lyxerr << "Read dep: "
<< nome << " "
<< one << " "
<< two << " "
<< mtime << endl;
<< di.crc_cur << " "
<< di.mtime_cur << endl;
}
dep_info di;
di.first = one;
di.second = two;
di.mtime = mtime;
#if 0
deplist[nome] = make_pair(one, two);
#else
deplist[nome] = di;
#endif
}
}

View File

@ -8,6 +8,7 @@
*
* This file is Copyright 1996-2001
* Lars Gullik Bjønnes
* Ben Stanley
*
* ======================================================
*/
@ -29,9 +30,7 @@ public:
filename. Should we insert files with .sty .cls etc as
extension? */
void insert(string const & f,
bool upd = false,
unsigned long one = 0,
unsigned long two = 0);
bool upd = false);
///
void update();
@ -47,14 +46,23 @@ public:
bool extchanged(string const & ext) const;
///
bool exist(string const & fil) const;
/// returns true if any files with ext exist
bool ext_exist(string const& ext) const;
///
void remove_files_with_extension(string const &);
///
void remove_file(string const &);
private:
///
struct dep_info {
unsigned long first;
unsigned long second;
long mtime;
/// Previously calculated CRC value
unsigned long crc_prev;
/// Current CRC value - only re-computed if mtime has changed.
unsigned long crc_cur;
/// mtime from last time current CRC was calculated.
long mtime_cur;
///
bool changed() const;
};
///
typedef std::map<string, dep_info> DepList;
@ -63,3 +71,4 @@ private:
};
#endif

View File

@ -1,3 +1,7 @@
2002-01-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* ControlExternal.C (Browse): simplify to use browseRelFile
2002-01-16 Angus Leeming <a.leeming@ic.ac.uk>
* ButtonController.tmpl: added // -*- C++ -*-

View File

@ -22,20 +22,21 @@
#pragma implementation
#endif
#include "ViewBase.h"
#include "BufferView.h"
#include "ButtonControllerBase.h"
#include "ControlExternal.h"
#include "ControlInset.tmpl"
#include "buffer.h"
#include "Dialogs.h"
#include "Liason.h"
#include "LyXView.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include "frontends/FileDialog.h"
#include "ViewBase.h"
#include "buffer.h"
#include "frontends/Alert.h"
#include "gettext.h"
#include "BufferView.h"
#include "helper_funcs.h"
#include "lyxrc.h"
#include "support/filetools.h"
#include "support/lstrings.h"
using std::make_pair;
using std::vector;
@ -149,61 +150,21 @@ ExternalTemplate ControlExternal::getTemplate(int i) const
string const ControlExternal::Browse(string const & input) const
{
#ifdef WITH_WARNINGS
#warning Candidate for using browseRelFile
#endif
string buf;
string const title = _("Select external file");
string const bufpath = lv_.buffer()->filePath();
if (!input.empty()) {
buf = MakeAbsPath(input, bufpath);
buf = OnlyPath(buf);
} else {
buf = bufpath;
}
FileDialog fileDlg(&lv_,
_("Select external file"),
LFUN_SELECT_FILE_SYNC,
make_pair(string(_("Document|#o#O")), string(buf)));
/// Determine the template file extension
ExternalTemplate const & et = params().templ;
string regexp = et.fileRegExp;
if (regexp.empty())
regexp = "*";
string pattern = et.fileRegExp;
if (pattern.empty())
pattern = "*";
// FIXME: a temporary hack until the FileDialog interface is updated
regexp += "|";
pattern += "|";
static int once;
string current_path;
pair<string, string> dir1(N_("Documents|#o#O"),
string(lyxrc.document_path));
while (1) {
string const path = (once) ? current_path : buf;
FileDialog::Result result = fileDlg.Select(path, regexp, input);
if (result.second.empty())
return string();
string p = result.second;
buf = MakeRelPath(p, bufpath);
current_path = OnlyPath(p);
once = 1;
if (contains(p, "#") ||
contains(p, "~") ||
contains(p, "$") ||
contains(p, "%")) {
Alert::alert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format
_("'#', '~', '$' or '%'."));
} else
break;
}
return buf;
return browseRelFile(&lv_, input, bufpath, title, pattern, dir1);
}

View File

@ -49,7 +49,7 @@ void ControlInclude::applyParamsToInset()
string const ControlInclude::Browse(string const & in_name, Type in_type)
{
string const title = N_("Select document to include");
string const title = _("Select document to include");
// input TeX, verbatim, or LyX file ?
string pattern;

View File

@ -82,7 +82,8 @@ string const browseFile(LyXView * lv, string const & filename,
pair<string,string> const & dir2)
{
string lastPath = ".";
if (!filename.empty()) lastPath = OnlyPath(filename);
if (!filename.empty())
lastPath = OnlyPath(filename);
FileDialog fileDlg(lv, title, LFUN_SELECT_FILE_SYNC, dir1, dir2);

View File

@ -1,3 +1,7 @@
2002-01-16 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insetbib.C (getFiles): uncomment Path variable.
2002-01-16 Juergen Vigna <jug@sad.it>
* insettabular.C (forceDefaultParagraphs): fixed bug returning value

View File

@ -210,15 +210,10 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os,
}
vector<string> const InsetBibtex::getFiles(Buffer const &) const
vector<string> const InsetBibtex::getFiles(Buffer const & buffer) const
{
// Doesn't appear to be used (Angus, 31 July 2001)
// Path p(buffer->filePath());
#ifdef WITH_WARNINGS
#warning Angus, do you now that this is not supposed to be used but to change path?
// I would say this is needed to find bib files which are in the
// document directory (JMarc 14/01/2002)
#endif
Path p(buffer.filePath());
vector<string> vec;