mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
d0a3af12d9
I'm committing all the little, but uncontroversial, changes that have built up in my tree. This will result in an almost total recompilation for you all but will mean that things are less painfull when the other changes go in! * Rename files syscall.[Ch] as systemcall.[Ch]. * Rename class Systemcalls as class Systemcall as one instance of the class represents a single child process. Remove the default constructor too. * Add a running() method to class Timeout. Results in recompilation of almost the entire tree because pretty well everything depends on LyXView.h which #includes "frontends/Timeout.h", so... * Make the Timeout instances in classes LyXView and minibuffer pointers, allowing us to forward declare class Timeout. * Add LFUN_FORKS_SHOW and LFUN_FORKS_KILL to commandtags.h in anticipation of something wonderful! * Add a signal showForks to Dialogs.h, again anticipating some real code. * wrap the structs firster, seconder in frontends/controllers/helper_funcs.h in a namespace to prevent a clash with similarly named structs in support/lyxalgo.h As you see, lots of irritating bits and pieces which don't make much sense in themselves but do in light of the other changes I've got here. I'll post the big changes to the list for proper perusal. Angus git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3566 a592a061-630c-0410-9148-cb99ea01b6c8
131 lines
3.0 KiB
C
131 lines
3.0 KiB
C
/* 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/systemcall.h"
|
|
#include "support/path.h"
|
|
#include "helper_funcs.h"
|
|
#include "support/lstrings.h"
|
|
|
|
extern string user_lyxdir; // home of *Files.lst
|
|
|
|
|
|
ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
|
|
: ControlDialogBI(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
|
|
void ControlTexinfo::rescanStyles() const
|
|
{
|
|
// Run rescan in user lyx directory
|
|
Path p(user_lyxdir);
|
|
Systemcall one;
|
|
one.startscript(Systemcall::Wait,
|
|
LibFileSearch("scripts", "TeXFiles.sh"));
|
|
p.pop();
|
|
}
|
|
|
|
|
|
void ControlTexinfo::runTexhash() const
|
|
{
|
|
// Run texhash in user lyx directory
|
|
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
|
|
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:
|
|
filename = styFilename;
|
|
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
|
|
{
|
|
lv_.getDialogs()->showFile(filename);
|
|
}
|
|
|