X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffrontends%2Fcontrollers%2FControlTexinfo.C;h=7694773600a4fb9e684573baeef32858d1981097;hb=98ebb778411f39db1d144234b5b8bb944c3c05b2;hp=040192ce35becb13c33de9872a43035b0bc661fc;hpb=435d527581277fab8b1aa67888f17d8439d07693;p=lyx.git diff --git a/src/frontends/controllers/ControlTexinfo.C b/src/frontends/controllers/ControlTexinfo.C index 040192ce35..7694773600 100644 --- a/src/frontends/controllers/ControlTexinfo.C +++ b/src/frontends/controllers/ControlTexinfo.C @@ -1,129 +1,100 @@ -/* This file is part of - * ====================================================== +/** + * \file ControlTexinfo.cpp + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor + * \author Herbert Voß * - * Copyright 2001 The LyX Team. - * - * ====================================================== - * - * \file ControlTexinfo.C - * \author Herbert Voss + * Full author contact details are available in file CREDITS. */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - -#include "ViewBase.h" -#include "ButtonControllerBase.h" #include "ControlTexinfo.h" -#include "Dialogs.h" -#include "frontends/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" +#include "funcrequest.h" -extern string user_lyxdir; // home of *Files.lst +#include "support/filetools.h" +#include -ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d) - : ControlDialogBI(lv, d) -{ - d_.showTexinfo.connect(SigC::slot(this, &ControlTexinfo::show)); -} +using std::string; +using std::vector; + +namespace lyx { +using support::onlyFilename; -// build filelists of all availabe bst/cls/sty-files. done through -// kpsewhich and an external script, saved in *Files.lst -void ControlTexinfo::rescanStyles() const +namespace frontend { + +void getTexFileList(ControlTexinfo::texFileSuffix type, + std::vector & list, bool withPath) { - // Run rescan in user lyx directory - Path p(user_lyxdir); - Systemcall one; - one.startscript(Systemcall::Wait, - LibFileSearch("scripts", "TeXFiles.sh")); - p.pop(); + string filename; + switch (type) { + case ControlTexinfo::bst: + filename = "bstFiles.lst"; + break; + case ControlTexinfo::cls: + filename = "clsFiles.lst"; + break; + case ControlTexinfo::sty: + filename = "styFiles.lst"; + break; + } + getTexFileList(filename, list); + if (list.empty()) { + // build filelists of all availabe bst/cls/sty-files. + // Done through kpsewhich and an external script, + // saved in *Files.lst + rescanTexStyles(); + getTexFileList(filename, list); + } + if (withPath) + return; + vector::iterator it = list.begin(); + vector::iterator end = list.end(); + for (; it != end; ++it) { + *it = onlyFilename(*it); + } + // sort on filename only (no path) + std::sort(list.begin(), list.end()); } -void ControlTexinfo::runTexhash() const -{ - // Run texhash in user lyx directory - Path p(user_lyxdir); +ControlTexinfo::ControlTexinfo(Dialog & parent) + : Dialog::Controller(parent) +{} - //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.")); +void ControlTexinfo::viewFile(string const & filename) const +{ + string const arg = "file " + filename; + kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, arg)); } -namespace { - -string const sortEntries(string & str_in) +string const ControlTexinfo::getClassOptions(string const & filename) const { - std::vector dbase = getVectorFromString(str_in,"\n"); - std::sort(dbase.begin(), dbase.end()); // sort entries - std::vector::iterator p = - std::unique(dbase.begin(), dbase.end()); // compact - dbase.erase(p, dbase.end()); // shrink - return getStringFromVector(dbase,"\n"); + return getListOfOptions(filename, "cls"); } -} //namespace anon - -string const -ControlTexinfo::getContents(texFileSuffix type, bool withFullPath) const +string const ControlTexinfo::getFileType(ControlTexinfo::texFileSuffix type) const { - static string const bstFilename("bstFiles.lst"); - static string const clsFilename("clsFiles.lst"); - static string const styFilename("styFiles.lst"); - - string filename; + string ftype; switch (type) { - case bst: - filename = bstFilename; + case ControlTexinfo::bst: + ftype = "bst"; break; - case cls: - filename = clsFilename; + case ControlTexinfo::cls: + ftype = "cls"; break; - case sty: - filename = styFilename; + case ControlTexinfo::sty: + ftype = "sty"; 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"); + return ftype; } -void ControlTexinfo::viewFile(string const filename) const -{ - lv_.getDialogs()->showFile(filename); -} +} // namespace frontend +} // namespace lyx