#endif
#include "xformsBC.h"
-#include "ControlTexinfo.h"
#include "FormTexinfo.h"
#include "form_texinfo.h"
#include "gettext.h"
#include "debug.h"
-#include "helper_funcs.h"
#include "xforms_helpers.h"
-#include "support/lstrings.h"
-#include "support/filetools.h"
#include "support/LAssert.h"
-
-extern string user_lyxdir; // home of *Files.lst
namespace {
-string const bstFilename("bstFiles.lst");
-string const clsFilename("clsFiles.lst");
-string const styFilename("styFiles.lst");
-string const errorMessage =_("Missing filelist. try Rescan");
-
// C function wrapper, required by xforms.
extern "C"
int C_FormTexinfoFeedbackCB(FL_OBJECT * ob, int event,
typedef FormCB<ControlTexinfo, FormDB<FD_form_texinfo> > base_class;
FormTexinfo::FormTexinfo(ControlTexinfo & c)
: base_class(c, _("TeX Infos")),
- warningPosted(false), activeStyle(FormTexinfo::cls)
+ warningPosted(false), activeStyle(ControlTexinfo::cls)
{}
fl_set_browser_fontstyle(dialog_->browser,FL_FIXED_STYLE);
// with Path is default
fl_set_button(dialog_->button_fullPath, 1);
- updateStyles(FormTexinfo::cls);
+ updateStyles(ControlTexinfo::cls);
setPreHandler(dialog_->button_rescan);
setPreHandler(dialog_->button_view);
controller().help();
} else if (ob == dialog_->radio_cls) {
- updateStyles(FormTexinfo::cls);
+ updateStyles(ControlTexinfo::cls);
} else if (ob == dialog_->radio_sty) {
- updateStyles(FormTexinfo::sty);
+ updateStyles(ControlTexinfo::sty);
} else if (ob == dialog_->radio_bst) {
- updateStyles(FormTexinfo::bst);
+ updateStyles(ControlTexinfo::bst);
} else if (ob == dialog_->button_rescan) {
// build new *Files.lst
return ButtonPolicy::SMI_VALID;
}
-
-namespace {
-
-string const sortEntries(string & str_in)
-{
- std::vector<string> dbase = getVectorFromString(str_in,"\n");
- std::sort(dbase.begin(), dbase.end()); // sort entries
- return getStringFromVector(dbase,"\n");
-}
-
-string const getContents(string const filename, bool withFullPath)
-{
- string fileContents = GetFileContents(AddName(user_lyxdir,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 errorMessage;
-}
-
-} // namespace anon
-
-
-void FormTexinfo::updateStyles(FormTexinfo::texFileSuffix whichStyle)
+void FormTexinfo::updateStyles(ControlTexinfo::texFileSuffix whichStyle)
{
fl_clear_browser(dialog_->browser);
bool const withFullPath = fl_get_button(dialog_->button_fullPath);
- switch (whichStyle) {
- case FormTexinfo::bst:
- {
- string const str = getContents(bstFilename, withFullPath);
- fl_add_browser_line(dialog_->browser, str.c_str());
- break;
-
- }
- case FormTexinfo::cls:
- {
- string const str = getContents(clsFilename, withFullPath);
- fl_add_browser_line(dialog_->browser, str.c_str());
- break;
- }
- case FormTexinfo::sty:
- {
- string const str = getContents(styFilename, withFullPath);
- fl_add_browser_line(dialog_->browser, str.c_str());
- break;
- }
- }
+ string const str =
+ controller().getContents(whichStyle, withFullPath);
+ fl_add_browser_line(dialog_->browser, str.c_str());
activeStyle = whichStyle;
}
string str;
if (ob == dialog_->button_rescan) {
- str = _("run rescan ...");
+ str = _("starts rescan ...");
} else if (ob == dialog_->button_fullPath) {
str = _("View full path or only file name");
} else if (ob == dialog_->button_texhash) {
- str = _("run texhash and rescan...");
+ str = _("starts texhash and rescan...");
} else if (ob == dialog_->button_view) {
- str = _("select a file to view");
+ str = _("views a selected file");
}