2001-10-09 15:20:10 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
*
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* \file ControlTexinfo.C
|
|
|
|
* \author Herbert Voss <voss@lyx.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "ViewBase.h"
|
|
|
|
#include "ButtonControllerBase.h"
|
|
|
|
#include "ControlTexinfo.h"
|
|
|
|
#include "Dialogs.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "support/filetools.h" // FileSearch
|
|
|
|
#include "support/syscall.h"
|
|
|
|
#include "support/path.h"
|
2001-10-10 16:45:05 +00:00
|
|
|
#include "helper_funcs.h"
|
|
|
|
#include "support/lstrings.h"
|
2001-10-09 15:20:10 +00:00
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
extern string user_lyxdir; // home of *Files.lst
|
2001-10-09 15:20:10 +00:00
|
|
|
|
|
|
|
ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
|
|
|
|
: ControlDialog<ControlConnectBI>(lv, d)
|
|
|
|
{
|
|
|
|
d_.showTexinfo.connect(SigC::slot(this, &ControlTexinfo::show));
|
|
|
|
}
|
|
|
|
|
|
|
|
// build filelists of all availabe bst/cls/sty-files. done through
|
|
|
|
// kpsewhich and an external script, saved in *Files.lst
|
2001-10-10 16:45:05 +00:00
|
|
|
void ControlTexinfo::rescanStyles() const
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
|
|
|
// Run rescan in user lyx directory
|
|
|
|
Path p(user_lyxdir);
|
|
|
|
Systemcalls one(Systemcalls::System,
|
2001-10-10 16:45:05 +00:00
|
|
|
LibFileSearch("scripts", "TeXFiles.sh"));
|
2001-10-09 15:20:10 +00:00
|
|
|
p.pop();
|
|
|
|
}
|
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
|
|
|
|
void ControlTexinfo::runTexhash() const
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
|
|
|
// Run texhash in user lyx directory
|
|
|
|
Path p(user_lyxdir);
|
|
|
|
|
|
|
|
//path to texhash through system
|
|
|
|
Systemcalls one(Systemcalls::System,"texhash");
|
|
|
|
p.pop();
|
2001-11-26 10:19:58 +00:00
|
|
|
// Alert::alert(_("texhash run!"),
|
2001-10-09 15:20:10 +00:00
|
|
|
// _("rebuilding of the TeX-tree could only be successfull"),
|
|
|
|
// _("if you have had user-write-permissions to the tex-dir."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
string const sortEntries(string & str_in)
|
|
|
|
{
|
|
|
|
std::vector<string> dbase = getVectorFromString(str_in,"\n");
|
2001-11-20 15:32:11 +00:00
|
|
|
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
|
2001-10-10 16:45:05 +00:00
|
|
|
return getStringFromVector(dbase,"\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace anon
|
|
|
|
|
|
|
|
|
|
|
|
string 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) {
|
|
|
|
case bst:
|
|
|
|
filename = bstFilename;
|
|
|
|
break;
|
|
|
|
case cls:
|
|
|
|
filename = clsFilename;
|
|
|
|
break;
|
|
|
|
case sty:
|
2001-10-12 08:15:47 +00:00
|
|
|
filename = styFilename;
|
2001-10-10 16:45:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
|
|
|
lv_.getDialogs()->showFile(filename);
|
|
|
|
}
|
|
|
|
|
2001-10-10 16:45:05 +00:00
|
|
|
|
|
|
|
void ControlTexinfo::help() const
|
2001-10-09 15:20:10 +00:00
|
|
|
{
|
2001-10-10 16:45:05 +00:00
|
|
|
lv_.getDialogs()->showFile(i18nLibFileSearch("help","Texinfo.hlp"));
|
2001-10-09 15:20:10 +00:00
|
|
|
}
|