mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Merge Herbert's bibtex patch; it doesn't introduce any new bugs and
it's nice ... Herbert please look at the bugs I reported concerning when there is no cls etc. list please. For this and FormTexinfo git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4442 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
60b905b885
commit
eef71b8439
@ -1,3 +1,8 @@
|
|||||||
|
2002-06-18 Herbert Voss <voss@perce.de>
|
||||||
|
|
||||||
|
* tex_helpers.[Ch]: move functions from ControlTexinfo into this
|
||||||
|
helperstuff. Now the bibtex gui can use some of these functions
|
||||||
|
|
||||||
2002-06-18 John Levon <moz@compsoc.man.ac.uk>
|
2002-06-18 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
* ControlGraphics.C: just make the mask *.*
|
* ControlGraphics.C: just make the mask *.*
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "lyxrc.h"
|
#include "lyxrc.h"
|
||||||
#include "helper_funcs.h"
|
#include "helper_funcs.h"
|
||||||
|
#include "tex_helpers.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
@ -35,6 +36,7 @@ ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ControlBibtex::applyParamsToInset()
|
void ControlBibtex::applyParamsToInset()
|
||||||
{
|
{
|
||||||
if (params().getContents() != inset()->params().getContents())
|
if (params().getContents() != inset()->params().getContents())
|
||||||
@ -63,3 +65,15 @@ string const ControlBibtex::Browse(string const & in_name,
|
|||||||
return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
|
return browseRelFile(&lv_, in_name, lv_.buffer()->filePath(),
|
||||||
title, pattern, dir1);
|
title, pattern, dir1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const ControlBibtex::getBibStyles() const
|
||||||
|
{
|
||||||
|
return getTexFileList("bstFiles.lst", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlBibtex::rescanBibStyles() const
|
||||||
|
{
|
||||||
|
rescanTexStyles();
|
||||||
|
}
|
||||||
|
@ -31,7 +31,12 @@ public:
|
|||||||
ControlBibtex(LyXView &, Dialogs &);
|
ControlBibtex(LyXView &, Dialogs &);
|
||||||
/// Browse for a file
|
/// Browse for a file
|
||||||
string const Browse(string const &, string const &, string const &);
|
string const Browse(string const &, string const &, string const &);
|
||||||
|
/// get the list of bst files
|
||||||
|
string const getBibStyles() const;
|
||||||
|
/// build filelists of all availabe bst/cls/sty-files. done through
|
||||||
|
/// kpsewhich and an external script, saved in *Files.lst
|
||||||
|
void rescanBibStyles() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Dispatch the changed parameters to the kernel.
|
/// Dispatch the changed parameters to the kernel.
|
||||||
virtual void applyParamsToInset();
|
virtual void applyParamsToInset();
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "helper_funcs.h"
|
#include "helper_funcs.h"
|
||||||
|
#include "tex_helpers.h"
|
||||||
|
|
||||||
#include "frontends/LyXView.h"
|
#include "frontends/LyXView.h"
|
||||||
|
|
||||||
#include "support/filetools.h" // FileSearch
|
#include "support/filetools.h" // FileSearch
|
||||||
#include "support/systemcall.h"
|
|
||||||
#include "support/path.h"
|
#include "support/path.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
@ -42,86 +42,41 @@ ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
|
|||||||
// kpsewhich and an external script, saved in *Files.lst
|
// kpsewhich and an external script, saved in *Files.lst
|
||||||
void ControlTexinfo::rescanStyles() const
|
void ControlTexinfo::rescanStyles() const
|
||||||
{
|
{
|
||||||
// Run rescan in user lyx directory
|
rescanTexStyles();
|
||||||
Path p(user_lyxdir);
|
|
||||||
Systemcall one;
|
|
||||||
one.startscript(Systemcall::Wait,
|
|
||||||
LibFileSearch("scripts", "TeXFiles.sh"));
|
|
||||||
p.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlTexinfo::runTexhash() const
|
void ControlTexinfo::runTexhash() const
|
||||||
{
|
{
|
||||||
// Run texhash in user lyx directory
|
texhash();
|
||||||
Path p(user_lyxdir);
|
|
||||||
|
|
||||||
//path to texhash through system
|
|
||||||
Systemcall one;
|
|
||||||
one.startscript(Systemcall::Wait, "texhash");
|
|
||||||
|
|
||||||
p.pop();
|
|
||||||
// Alert::alert(_("texhash run!"),
|
|
||||||
// _("rebuilding of the TeX-tree could only be successfull"),
|
|
||||||
// _("if you have had user-write-permissions to the tex-dir."));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
string const sortEntries(string & str_in)
|
|
||||||
{
|
|
||||||
std::vector<string> dbase = getVectorFromString(str_in,"\n");
|
|
||||||
std::sort(dbase.begin(), dbase.end()); // sort entries
|
|
||||||
std::vector<string>::iterator p =
|
|
||||||
std::unique(dbase.begin(), dbase.end()); // compact
|
|
||||||
dbase.erase(p, dbase.end()); // shrink
|
|
||||||
return getStringFromVector(dbase,"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace anon
|
|
||||||
|
|
||||||
|
|
||||||
string const
|
string const
|
||||||
ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
|
ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const
|
||||||
{
|
{
|
||||||
static string const bstFilename("bstFiles.lst");
|
|
||||||
static string const clsFilename("clsFiles.lst");
|
|
||||||
static string const styFilename("styFiles.lst");
|
|
||||||
|
|
||||||
string filename;
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case bst:
|
case bst:
|
||||||
filename = bstFilename;
|
return getTexFileList("bstFiles.lst", withFullPath);
|
||||||
break;
|
break;
|
||||||
case cls:
|
case cls:
|
||||||
filename = clsFilename;
|
return getTexFileList("clsFiles.lst", withFullPath);
|
||||||
break;
|
break;
|
||||||
case sty:
|
case sty:
|
||||||
filename = styFilename;
|
return getTexFileList("styFiles.lst", withFullPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return string();
|
||||||
string fileContents = GetFileContents(LibFileSearch(string(),filename));
|
|
||||||
// everything ok?
|
|
||||||
if (!fileContents.empty()) {
|
|
||||||
if (withFullPath)
|
|
||||||
return(sortEntries(fileContents));
|
|
||||||
else {
|
|
||||||
int Entries = 1;
|
|
||||||
string dummy = OnlyFilename(token(fileContents,'\n',1));
|
|
||||||
string contents = dummy;
|
|
||||||
do {
|
|
||||||
dummy = OnlyFilename(token(fileContents,'\n',++Entries));
|
|
||||||
contents += ("\n"+dummy);
|
|
||||||
} while (!dummy.empty());
|
|
||||||
return(sortEntries(contents));
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
return _("Missing filelist. try Rescan");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlTexinfo::viewFile(string const filename) const
|
void ControlTexinfo::viewFile(string const filename) const
|
||||||
{
|
{
|
||||||
lv_.getDialogs()->showFile(filename);
|
lv_.getDialogs()->showFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const ControlTexinfo::getClassOptions(string const & filename) const
|
||||||
|
{
|
||||||
|
return getListOfOptions(filename, "cls");
|
||||||
|
}
|
||||||
|
@ -30,13 +30,15 @@ public:
|
|||||||
enum texFileSuffix {cls, sty, bst};
|
enum texFileSuffix {cls, sty, bst};
|
||||||
///
|
///
|
||||||
ControlTexinfo(LyXView &, Dialogs &);
|
ControlTexinfo(LyXView &, Dialogs &);
|
||||||
///
|
/// show contents af a file
|
||||||
void viewFile(string const filename) const;
|
void viewFile(string const filename) const;
|
||||||
///
|
/// show all classoptions
|
||||||
|
string const getClassOptions(string const & filename) const;
|
||||||
|
/// build new cls bst sty - lists
|
||||||
void rescanStyles() const;
|
void rescanStyles() const;
|
||||||
///
|
/// build new bst sty cls lists
|
||||||
void runTexhash() const;
|
void runTexhash() const;
|
||||||
///
|
/// read filecontents
|
||||||
string const getContents(texFileSuffix type, bool withPath) const;
|
string const getContents(texFileSuffix type, bool withPath) const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ libcontrollers_la_SOURCES= \
|
|||||||
character.h \
|
character.h \
|
||||||
frnt_lang.C \
|
frnt_lang.C \
|
||||||
frnt_lang.h \
|
frnt_lang.h \
|
||||||
|
tex_helpers.C \
|
||||||
|
tex_helpers.h \
|
||||||
ButtonController.h \
|
ButtonController.h \
|
||||||
ButtonControllerBase.C \
|
ButtonControllerBase.C \
|
||||||
ButtonControllerBase.h \
|
ButtonControllerBase.h \
|
||||||
|
125
src/frontends/controllers/tex_helpers.C
Normal file
125
src/frontends/controllers/tex_helpers.C
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/**
|
||||||
|
* \file tex_helpers.C
|
||||||
|
* Copyright 1995-2002 the LyX Team
|
||||||
|
* Read the file COPYING
|
||||||
|
*
|
||||||
|
* \author Herbert Voss <voss@lyx.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
#include <vector.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
|
#include "tex_helpers.h"
|
||||||
|
#include "support/filetools.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "support/lstrings.h"
|
||||||
|
#include "support/systemcall.h"
|
||||||
|
#include "support/path.h"
|
||||||
|
#include "support/lyxalgo.h"
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
|
using std::sort;
|
||||||
|
using std::unique;
|
||||||
|
|
||||||
|
extern string user_lyxdir; // home of *Files.lst
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
vector<string> listWithoutPath(vector<string> & dbase)
|
||||||
|
{
|
||||||
|
vector<string>::iterator it = dbase.begin();
|
||||||
|
vector<string>::iterator end = dbase.end();
|
||||||
|
for (; it != end; ++it)
|
||||||
|
*it = OnlyFilename(*it);
|
||||||
|
return dbase;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// build filelists of all availabe bst/cls/sty-files. done through
|
||||||
|
// kpsewhich and an external script, saved in *Files.lst
|
||||||
|
void rescanTexStyles()
|
||||||
|
{
|
||||||
|
// Run rescan in user lyx directory
|
||||||
|
Path p(user_lyxdir);
|
||||||
|
Systemcall one;
|
||||||
|
one.startscript(Systemcall::Wait,
|
||||||
|
LibFileSearch("scripts", "TeXFiles.sh"));
|
||||||
|
p.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void texhash()
|
||||||
|
{
|
||||||
|
// Run texhash in user lyx directory
|
||||||
|
Path p(user_lyxdir);
|
||||||
|
|
||||||
|
//path to texhash through system
|
||||||
|
Systemcall one;
|
||||||
|
one.startscript(Systemcall::Wait,"texhash");
|
||||||
|
p.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
string const getTexFileList(string const & filename, bool withFullPath)
|
||||||
|
{
|
||||||
|
vector<string> dbase = getVectorFromString(
|
||||||
|
GetFileContents(LibFileSearch(string(),filename)), "\n");
|
||||||
|
lyx::eliminate_duplicates(dbase);
|
||||||
|
string const str_out = withFullPath ?
|
||||||
|
getStringFromVector(dbase, "\n") :
|
||||||
|
getStringFromVector(listWithoutPath(dbase), "\n");
|
||||||
|
// everything ok?
|
||||||
|
if (str_out.empty())
|
||||||
|
return _("Missing filelist. try Rescan");
|
||||||
|
return str_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const getListOfOptions(string const & classname,
|
||||||
|
string const & type)
|
||||||
|
{
|
||||||
|
string const filename = getTexFileFromList(classname,type);
|
||||||
|
string optionList = string();
|
||||||
|
std::ifstream is(filename.c_str());
|
||||||
|
while (is) {
|
||||||
|
string s;
|
||||||
|
is >> s;
|
||||||
|
if (contains(s,"DeclareOption")) {
|
||||||
|
s = s.substr(s.find("DeclareOption"));
|
||||||
|
s = split(s,'{'); // cut front
|
||||||
|
s = token(s,'}',0); // cut end
|
||||||
|
// FIXME: why is this commented out ?
|
||||||
|
// s = s.substr(0, s.find('}')+1); // format entry
|
||||||
|
optionList += (s + '\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return optionList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string const getTexFileFromList(string const & file,
|
||||||
|
string const & type)
|
||||||
|
{
|
||||||
|
string const file_ = (type == "cls") ? file + ".cls" : file + ".sty";
|
||||||
|
|
||||||
|
lyxerr << "Search for classfile " << file_ << endl;
|
||||||
|
|
||||||
|
string const lstfile = (type == "cls") ? "clsFiles.lst" : "styFiles.lst";
|
||||||
|
string const allClasses = GetFileContents(LibFileSearch(string(), lstfile));
|
||||||
|
int entries = 0;
|
||||||
|
string classfile = token(allClasses, '\n', entries);
|
||||||
|
int count = 0;
|
||||||
|
while ((!contains(classfile, file) ||
|
||||||
|
(OnlyFilename(classfile) != file)) &&
|
||||||
|
(++count < 1000)) {
|
||||||
|
classfile = token(allClasses, '\n', ++entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now we have filename with full path
|
||||||
|
lyxerr << "with full path: " << classfile << endl;
|
||||||
|
return classfile;
|
||||||
|
}
|
30
src/frontends/controllers/tex_helpers.h
Normal file
30
src/frontends/controllers/tex_helpers.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* \file tex_helpers.h
|
||||||
|
* Copyright 1995-2002 the LyX Team
|
||||||
|
* Read the file COPYING
|
||||||
|
*
|
||||||
|
* \author Herbert Voss <voss@lyx.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TEX_HELPERS_H
|
||||||
|
#define TEX_HELPERS_H
|
||||||
|
|
||||||
|
// build filelists of all availabe bst/cls/sty-files. done through
|
||||||
|
// kpsewhich and an external script, saved in *Files.lst
|
||||||
|
void rescanTexStyles();
|
||||||
|
|
||||||
|
/// rebuild the textree
|
||||||
|
void texhash();
|
||||||
|
|
||||||
|
/// return one of the three texfiles
|
||||||
|
string const getTexFileList(string const & filename, bool withFullPath);
|
||||||
|
|
||||||
|
/// get the options of stylefile
|
||||||
|
string const getListOfOptions(string const & classname,
|
||||||
|
string const & type);
|
||||||
|
|
||||||
|
/// get a class with full path from the list
|
||||||
|
string const getTexFileFromList(string const & classname,
|
||||||
|
string const & type);
|
||||||
|
|
||||||
|
#endif // TEX_HELPERS_H
|
@ -1,3 +1,15 @@
|
|||||||
|
2002-06-20 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
|
* FormBibtex.C: use new lyx::eliminate_duplicates
|
||||||
|
|
||||||
|
2002-06-20 Herbert Voss <voss@perce.de>
|
||||||
|
|
||||||
|
* FormBibtex.C:
|
||||||
|
* forms/form_bibtex.fd: give better support for choosing the
|
||||||
|
bibstyle (new browserfield with the available bibstyles).
|
||||||
|
move some code of ControlTexinfo into a helper
|
||||||
|
file support/tex-helpers to use some of the functions
|
||||||
|
|
||||||
2002-06-20 John Levon <moz@compsoc.man.ac.uk>
|
2002-06-20 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
* XWorkArea.h:
|
* XWorkArea.h:
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "support/LAssert.h"
|
#include "support/LAssert.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
#include "support/filetools.h"
|
#include "support/filetools.h"
|
||||||
|
#include "support/lyxalgo.h"
|
||||||
|
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -57,6 +58,8 @@ void FormBibtex::build()
|
|||||||
bc().addReadOnly(dialog_->button_database_browse);
|
bc().addReadOnly(dialog_->button_database_browse);
|
||||||
bc().addReadOnly(dialog_->input_database);
|
bc().addReadOnly(dialog_->input_database);
|
||||||
bc().addReadOnly(dialog_->button_style_browse);
|
bc().addReadOnly(dialog_->button_style_browse);
|
||||||
|
bc().addReadOnly(dialog_->button_style_choose);
|
||||||
|
bc().addReadOnly(dialog_->button_rescan);
|
||||||
bc().addReadOnly(dialog_->input_style);
|
bc().addReadOnly(dialog_->input_style);
|
||||||
bc().addReadOnly(dialog_->check_bibtotoc);
|
bc().addReadOnly(dialog_->check_bibtotoc);
|
||||||
|
|
||||||
@ -64,14 +67,21 @@ void FormBibtex::build()
|
|||||||
string str = _("The database you want to cite from. Insert it without the default extension \".bib\". If you insert it with the browser, LyX strips the extension. Several databases must be separated by a comma: \"natbib, books\".");
|
string str = _("The database you want to cite from. Insert it without the default extension \".bib\". If you insert it with the browser, LyX strips the extension. Several databases must be separated by a comma: \"natbib, books\".");
|
||||||
tooltips().init(dialog_->button_database_browse, str);
|
tooltips().init(dialog_->button_database_browse, str);
|
||||||
|
|
||||||
str = _("Browse your directory for BibTeX stylefiles.");
|
str = _("Browse your directory for BibTeX stylefiles");
|
||||||
tooltips().init(dialog_->button_style_browse, str);
|
tooltips().init(dialog_->button_style_browse, str);
|
||||||
|
|
||||||
str = _("The BibTeX style to use (only one allowed). Insert it without the default extension \".bst\" and without path. Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX tree. In \"View->TeX Information\" you can list all installed styles.");
|
str = _("The BibTeX style to use (only one allowed). Insert it without the default extension \".bst\" and without path or choose one from the browsers list. Most of the bibstyles are stored in $TEXMF/bibtex/bst. $TEXMF is the root dir of the local TeX tree.");
|
||||||
tooltips().init(dialog_->input_style, str);
|
tooltips().init(dialog_->input_style, str);
|
||||||
|
|
||||||
str = _("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default).");
|
str = _("Activate this option if you want the bibliography to appear in the Table of Contents (which doesn't happen by default)");
|
||||||
tooltips().init(dialog_->check_bibtotoc, str);
|
tooltips().init(dialog_->check_bibtotoc, str);
|
||||||
|
|
||||||
|
str = _("Choose a BibTeX style from the browsers list");
|
||||||
|
tooltips().init(dialog_->button_style_choose, str);
|
||||||
|
|
||||||
|
str = _("Updates your TeX system for a new bibstyle list. Only the styles which are in directories where TeX finds them are listed!");
|
||||||
|
tooltips().init(dialog_->button_rescan, str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,8 +92,8 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long)
|
|||||||
string const in_name = fl_get_input(dialog_->input_database);
|
string const in_name = fl_get_input(dialog_->input_database);
|
||||||
string out_name =
|
string out_name =
|
||||||
controller().Browse("",
|
controller().Browse("",
|
||||||
_("Select Database"),
|
_("Select Database"),
|
||||||
_("*.bib| BibTeX Databases (*.bib)"));
|
_("*.bib| BibTeX Databases (*.bib)"));
|
||||||
if (!out_name.empty()) {
|
if (!out_name.empty()) {
|
||||||
// add the database to any existing ones
|
// add the database to any existing ones
|
||||||
if (!in_name.empty())
|
if (!in_name.empty())
|
||||||
@ -93,22 +103,28 @@ ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT * ob, long)
|
|||||||
fl_set_input(dialog_->input_database, out_name.c_str());
|
fl_set_input(dialog_->input_database, out_name.c_str());
|
||||||
fl_unfreeze_form(form());
|
fl_unfreeze_form(form());
|
||||||
}
|
}
|
||||||
}
|
} else if (ob == dialog_->button_style_browse) {
|
||||||
|
|
||||||
if (ob == dialog_->button_style_browse) {
|
|
||||||
string const in_name = fl_get_input(dialog_->input_style);
|
string const in_name = fl_get_input(dialog_->input_style);
|
||||||
string out_name =
|
string out_name =
|
||||||
controller().Browse(in_name,
|
controller().Browse(in_name,
|
||||||
_("Select BibTeX-Style"),
|
_("Select BibTeX-Style"),
|
||||||
_("*.bst| BibTeX Styles (*.bst)"));
|
_("*.bst| BibTeX Styles (*.bst)"));
|
||||||
if (!out_name.empty()) {
|
if (!out_name.empty()) {
|
||||||
fl_freeze_form(form());
|
fl_freeze_form(form());
|
||||||
fl_set_input(dialog_->input_style, out_name.c_str());
|
fl_set_input(dialog_->input_style, out_name.c_str());
|
||||||
fl_unfreeze_form(form());
|
fl_unfreeze_form(form());
|
||||||
}
|
}
|
||||||
}
|
} else if (ob == dialog_->button_style_choose) {
|
||||||
|
unsigned int selection = fl_get_browser(dialog_->browser_styles);
|
||||||
|
string const out_name =
|
||||||
|
fl_get_browser_line(dialog_->browser_styles, selection);
|
||||||
|
fl_set_input(dialog_->input_style,
|
||||||
|
ChangeExtension(out_name, string()).c_str());
|
||||||
|
} else if (ob == dialog_->button_rescan)
|
||||||
|
controller().rescanBibStyles();
|
||||||
|
|
||||||
if (!compare(fl_get_input(dialog_->input_database),"")) {
|
// with an empty database nothing makes sense ...
|
||||||
|
if (!compare(fl_get_input(dialog_->input_database), "")) {
|
||||||
return ButtonPolicy::SMI_NOOP;
|
return ButtonPolicy::SMI_NOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,43 +138,35 @@ void FormBibtex::update()
|
|||||||
controller().params().getContents().c_str());
|
controller().params().getContents().c_str());
|
||||||
string bibtotoc = "bibtotoc";
|
string bibtotoc = "bibtotoc";
|
||||||
string bibstyle (controller().params().getOptions().c_str());
|
string bibstyle (controller().params().getOptions().c_str());
|
||||||
if (prefixIs(bibstyle,bibtotoc)) { // bibtotoc exists?
|
if (prefixIs(bibstyle, bibtotoc)) { // bibtotoc exists?
|
||||||
fl_set_button(dialog_->check_bibtotoc,1);
|
fl_set_button(dialog_->check_bibtotoc,1);
|
||||||
if (contains(bibstyle,',')) { // bibstyle exists?
|
if (contains(bibstyle, ',')) { // bibstyle exists?
|
||||||
bibstyle = split(bibstyle,bibtotoc,',');
|
bibstyle = split(bibstyle, bibtotoc, ',');
|
||||||
} else {
|
} else {
|
||||||
bibstyle = "";
|
bibstyle = string();
|
||||||
}
|
}
|
||||||
|
|
||||||
fl_set_input(dialog_->input_style,bibstyle.c_str());
|
fl_set_input(dialog_->input_style, bibstyle.c_str());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fl_set_button(dialog_->check_bibtotoc,0);
|
fl_set_button(dialog_->check_bibtotoc,0);
|
||||||
fl_set_input(dialog_->input_style,bibstyle.c_str());
|
fl_set_input(dialog_->input_style, bibstyle.c_str());
|
||||||
}
|
}
|
||||||
|
string const str =
|
||||||
|
controller().getBibStyles();
|
||||||
|
fl_add_browser_line(dialog_->browser_styles, str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// Remove all duplicate entries in c.
|
|
||||||
// Taken stright out of Stroustrup
|
|
||||||
template<class C>
|
|
||||||
void eliminate_duplicates(C & c)
|
|
||||||
{
|
|
||||||
sort(c.begin(), c.end());
|
|
||||||
typename C::iterator p = std::unique(c.begin(), c.end());
|
|
||||||
c.erase(p, c.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string const unique_and_no_extensions(string const & str_in)
|
string const unique_and_no_extensions(string const & str_in)
|
||||||
{
|
{
|
||||||
vector<string> dbase = getVectorFromString(str_in);
|
vector<string> dbase = getVectorFromString(str_in);
|
||||||
for (vector<string>::iterator it = dbase.begin();
|
for (vector<string>::iterator it = dbase.begin();
|
||||||
it != dbase.end(); ++it) {
|
it != dbase.end(); ++it) {
|
||||||
*it = ChangeExtension(*it, "");
|
*it = ChangeExtension(*it, string());
|
||||||
}
|
}
|
||||||
eliminate_duplicates(dbase);
|
lyx::eliminate_duplicates(dbase);
|
||||||
return getStringFromVector(dbase);
|
return getStringFromVector(dbase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +196,7 @@ void FormBibtex::apply()
|
|||||||
|
|
||||||
if (bibtotoc && (!bibstyle.empty())) {
|
if (bibtotoc && (!bibstyle.empty())) {
|
||||||
// both bibtotoc and style
|
// both bibtotoc and style
|
||||||
controller().params().setOptions("bibtotoc,"+bibstyle);
|
controller().params().setOptions("bibtotoc," + bibstyle);
|
||||||
|
|
||||||
} else if (bibtotoc) {
|
} else if (bibtotoc) {
|
||||||
// bibtotoc and no style
|
// bibtotoc and no style
|
||||||
|
@ -9,14 +9,14 @@ SnapGrid: 1
|
|||||||
|
|
||||||
=============== FORM ===============
|
=============== FORM ===============
|
||||||
Name: form_bibtex
|
Name: form_bibtex
|
||||||
Width: 450
|
Width: 312
|
||||||
Height: 160
|
Height: 358
|
||||||
Number of Objects: 8
|
Number of Objects: 11
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: FL_BOX
|
class: FL_BOX
|
||||||
type: UP_BOX
|
type: UP_BOX
|
||||||
box: 0 0 450 160
|
box: 0 0 312 358
|
||||||
boxtype: FL_UP_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_COL1
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_CENTER
|
alignment: FL_ALIGN_CENTER
|
||||||
@ -34,10 +34,10 @@ argument:
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_INPUT
|
class: FL_INPUT
|
||||||
type: NORMAL_INPUT
|
type: NORMAL_INPUT
|
||||||
box: 90 10 245 30
|
box: 15 29 164 28
|
||||||
boxtype: FL_DOWN_BOX
|
boxtype: FL_DOWN_BOX
|
||||||
colors: FL_COL1 FL_MCOL
|
colors: FL_COL1 FL_MCOL
|
||||||
alignment: FL_ALIGN_LEFT
|
alignment: FL_ALIGN_TOP_LEFT
|
||||||
style: FL_NORMAL_STYLE
|
style: FL_NORMAL_STYLE
|
||||||
size: FL_NORMAL_SIZE
|
size: FL_NORMAL_SIZE
|
||||||
lcol: FL_BLACK
|
lcol: FL_BLACK
|
||||||
@ -52,7 +52,7 @@ argument: 0
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_BUTTON
|
class: FL_BUTTON
|
||||||
type: RETURN_BUTTON
|
type: RETURN_BUTTON
|
||||||
box: 250 120 90 30
|
box: 12 316 90 30
|
||||||
boxtype: FL_UP_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_COL1
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_CENTER
|
alignment: FL_ALIGN_CENTER
|
||||||
@ -70,7 +70,7 @@ argument: 3
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_BUTTON
|
class: FL_BUTTON
|
||||||
type: NORMAL_BUTTON
|
type: NORMAL_BUTTON
|
||||||
box: 350 120 90 30
|
box: 112 316 90 30
|
||||||
boxtype: FL_UP_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_COL1
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_CENTER
|
alignment: FL_ALIGN_CENTER
|
||||||
@ -88,10 +88,10 @@ argument: 2
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_INPUT
|
class: FL_INPUT
|
||||||
type: NORMAL_INPUT
|
type: NORMAL_INPUT
|
||||||
box: 90 45 245 30
|
box: 14 80 166 26
|
||||||
boxtype: FL_DOWN_BOX
|
boxtype: FL_DOWN_BOX
|
||||||
colors: FL_COL1 FL_MCOL
|
colors: FL_COL1 FL_MCOL
|
||||||
alignment: FL_ALIGN_LEFT
|
alignment: FL_ALIGN_TOP_LEFT
|
||||||
style: FL_NORMAL_STYLE
|
style: FL_NORMAL_STYLE
|
||||||
size: FL_NORMAL_SIZE
|
size: FL_NORMAL_SIZE
|
||||||
lcol: FL_BLACK
|
lcol: FL_BLACK
|
||||||
@ -106,7 +106,7 @@ argument: 0
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_BUTTON
|
class: FL_BUTTON
|
||||||
type: NORMAL_BUTTON
|
type: NORMAL_BUTTON
|
||||||
box: 340 10 100 29
|
box: 192 29 100 29
|
||||||
boxtype: FL_UP_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_COL1
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_CENTER
|
alignment: FL_ALIGN_CENTER
|
||||||
@ -124,7 +124,61 @@ argument: 0
|
|||||||
--------------------
|
--------------------
|
||||||
class: FL_BUTTON
|
class: FL_BUTTON
|
||||||
type: NORMAL_BUTTON
|
type: NORMAL_BUTTON
|
||||||
box: 340 45 100 30
|
box: 195 167 100 30
|
||||||
|
boxtype: FL_UP_BOX
|
||||||
|
colors: FL_COL1 FL_COL1
|
||||||
|
alignment: FL_ALIGN_CENTER
|
||||||
|
style: FL_NORMAL_STYLE
|
||||||
|
size: FL_DEFAULT_SIZE
|
||||||
|
lcol: FL_BLACK
|
||||||
|
label: Choose|#C
|
||||||
|
shortcut:
|
||||||
|
resize: FL_RESIZE_ALL
|
||||||
|
gravity: FL_NoGravity FL_NoGravity
|
||||||
|
name: button_style_choose
|
||||||
|
callback: C_FormBaseInputCB
|
||||||
|
argument: 0
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
class: FL_CHECKBUTTON
|
||||||
|
type: PUSH_BUTTON
|
||||||
|
box: 12 258 30 30
|
||||||
|
boxtype: FL_NO_BOX
|
||||||
|
colors: FL_COL1 FL_YELLOW
|
||||||
|
alignment: FL_ALIGN_CENTER
|
||||||
|
style: FL_NORMAL_STYLE
|
||||||
|
size: FL_DEFAULT_SIZE
|
||||||
|
lcol: FL_BLACK
|
||||||
|
label: Add bibliography to TOC|#A
|
||||||
|
shortcut:
|
||||||
|
resize: FL_RESIZE_ALL
|
||||||
|
gravity: FL_NoGravity FL_NoGravity
|
||||||
|
name: check_bibtotoc
|
||||||
|
callback: C_FormBaseInputCB
|
||||||
|
argument: 0
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
class: FL_BROWSER
|
||||||
|
type: HOLD_BROWSER
|
||||||
|
box: 14 129 168 111
|
||||||
|
boxtype: FL_DOWN_BOX
|
||||||
|
colors: FL_COL1 FL_YELLOW
|
||||||
|
alignment: FL_ALIGN_TOP_LEFT
|
||||||
|
style: FL_NORMAL_STYLE
|
||||||
|
size: FL_NORMAL_SIZE
|
||||||
|
lcol: FL_BLACK
|
||||||
|
label: Available Styles|#v
|
||||||
|
shortcut:
|
||||||
|
resize: FL_RESIZE_ALL
|
||||||
|
gravity: FL_NoGravity FL_NoGravity
|
||||||
|
name: browser_styles
|
||||||
|
callback: C_FormBaseInputCB
|
||||||
|
argument: 0
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
class: FL_BUTTON
|
||||||
|
type: NORMAL_BUTTON
|
||||||
|
box: 192 79 100 30
|
||||||
boxtype: FL_UP_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_COL1
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_CENTER
|
alignment: FL_ALIGN_CENTER
|
||||||
@ -140,20 +194,20 @@ callback: C_FormBaseInputCB
|
|||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
--------------------
|
--------------------
|
||||||
class: FL_CHECKBUTTON
|
class: FL_BUTTON
|
||||||
type: PUSH_BUTTON
|
type: NORMAL_BUTTON
|
||||||
box: 90 80 30 30
|
box: 196 208 100 30
|
||||||
boxtype: FL_NO_BOX
|
boxtype: FL_UP_BOX
|
||||||
colors: FL_COL1 FL_YELLOW
|
colors: FL_COL1 FL_COL1
|
||||||
alignment: FL_ALIGN_CENTER
|
alignment: FL_ALIGN_CENTER
|
||||||
style: FL_NORMAL_STYLE
|
style: FL_NORMAL_STYLE
|
||||||
size: FL_DEFAULT_SIZE
|
size: FL_DEFAULT_SIZE
|
||||||
lcol: FL_BLACK
|
lcol: FL_BLACK
|
||||||
label: Add bibliography to TOC|#A
|
label: Update List|#U
|
||||||
shortcut:
|
shortcut:
|
||||||
resize: FL_RESIZE_ALL
|
resize: FL_RESIZE_ALL
|
||||||
gravity: FL_NoGravity FL_NoGravity
|
gravity: FL_NoGravity FL_NoGravity
|
||||||
name: check_bibtotoc
|
name: button_rescan
|
||||||
callback: C_FormBaseInputCB
|
callback: C_FormBaseInputCB
|
||||||
argument: 0
|
argument: 0
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2002-06-19 John Levon <moz@compsoc.man.ac.uk>
|
||||||
|
|
||||||
|
* lyxalgo.h: add eliminate_duplicates
|
||||||
|
|
||||||
2002-06-17 Herbert Voss <voss@perce.de>
|
2002-06-17 Herbert Voss <voss@perce.de>
|
||||||
|
|
||||||
* filetools.[C]: (readBB_from_PSFile) add a helperfunc
|
* filetools.[C]: (readBB_from_PSFile) add a helperfunc
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
* \author unknown
|
* \author unknown
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef LYX_ALGO_H
|
#ifndef LYX_ALGO_H
|
||||||
#define LYX_ALGO_H
|
#define LYX_ALGO_H
|
||||||
|
|
||||||
@ -87,6 +85,15 @@ count (Iterator first, Iterator last, T const & value)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove all duplicate entries in c.
|
||||||
|
template<class C>
|
||||||
|
void eliminate_duplicates(C & c)
|
||||||
|
{
|
||||||
|
std::sort(c.begin(), c.end());
|
||||||
|
typename C::iterator p = std::unique(c.begin(), c.end());
|
||||||
|
c.erase(p, c.end());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif // LYX_ALGO_H
|
#endif // LYX_ALGO_H
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
|
||||||
template<class R, class C, class A>
|
template<class R, class C, class A>
|
||||||
class class_fun_t {
|
class class_fun_t {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user