remove reference list from menus, formlog updates, small mathed cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1471 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-02-09 15:54:30 +00:00
parent 3c42eb3ec4
commit e7ca356bf7
12 changed files with 64 additions and 164 deletions

View File

@ -1,3 +1,14 @@
2001-02-09 John Levon <moz@compsoc.man.ac.uk>
* buffer.h:
* buffer.C: rename to getLogName(), handle
build log / latex log nicely
2001-02-09 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* MenuBackend.C:
* MenuBackend.h: remove support for reference menuitem type.
2001-02-07 John Levon <moz@compsoc.man.ac.uk>
* BufferView_pimpl.C: housekeeping

View File

@ -52,7 +52,6 @@ MenuItem::MenuItem(Kind kind, string const & label,
case Documents:
case Lastfiles:
case Toc:
case References:
case ViewFormats:
case UpdateFormats:
case ExportFormats:
@ -93,7 +92,6 @@ Menu & Menu::read(LyXLex & lex)
md_importformats,
md_lastfiles,
md_optitem,
md_references,
md_separator,
md_submenu,
md_toc,
@ -110,7 +108,6 @@ Menu & Menu::read(LyXLex & lex)
{ "item", md_item },
{ "lastfiles", md_lastfiles },
{ "optitem", md_optitem },
{ "references", md_references },
{ "separator", md_separator },
{ "submenu", md_submenu },
{ "toc", md_toc },
@ -157,10 +154,6 @@ Menu & Menu::read(LyXLex & lex)
add(MenuItem(MenuItem::Toc));
break;
case md_references:
add(MenuItem(MenuItem::References));
break;
case md_viewformats:
add(MenuItem(MenuItem::ViewFormats));
break;

View File

@ -44,8 +44,6 @@ public:
Documents,
///
Toc,
///
References,
/** This is a list of viewable formats
typically for the File->View menu. */
ViewFormats,

View File

@ -104,6 +104,7 @@ using std::ios;
using std::setw;
using std::endl;
using std::pair;
using std::make_pair;
using std::vector;
using std::max;
using std::set;
@ -178,32 +179,35 @@ string const Buffer::getLatexName(bool no_path) const
".tex");
}
string const Buffer::getLatexLogName(void) const
pair<Buffer::LogType, string> const Buffer::getLogName(void) const
{
string filename, fname, bname, path;
filename = getLatexName(false);
if (filename.empty())
return string();
return make_pair(Buffer::latexlog, string());
fname = OnlyFilename(ChangeExtension(filename, ".log"));
bname = OnlyFilename(ChangeExtension(filename,
formats.Extension("literate") + ".out"));
path = OnlyPath(filename);
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1))
path = tmppath + "/";
path = tmppath;
lyxerr[Debug::FILES] << "LaTeX Log calculated as : " << path + fname << endl;
fname = AddName(path, OnlyFilename(ChangeExtension(filename, ".log")));
bname = AddName(path, OnlyFilename(ChangeExtension(filename,
formats.Extension("literate") + ".out")));
// If no Latex log or Build log is newer, show Build log
FileInfo f_fi(path + fname), b_fi(path + bname);
FileInfo f_fi(fname), b_fi(bname);
if (b_fi.exist() &&
(!f_fi.exist() || f_fi.getModificationTime() < b_fi.getModificationTime()))
return path + bname;
else
return path + fname;
(!f_fi.exist() || f_fi.getModificationTime() < b_fi.getModificationTime())) {
lyxerr[Debug::FILES] << "Log name calculated as : " << bname << endl;
return make_pair(Buffer::buildlog, bname);
}
lyxerr[Debug::FILES] << "Log name calculated as : " << fname << endl;
return make_pair(Buffer::latexlog, fname);
}
void Buffer::setReadonly(bool flag)

View File

@ -57,6 +57,12 @@ struct DEPCLEAN {
*/
class Buffer {
public:
/// what type of log will getLogName() return ?
enum LogType {
latexlog, /**< LaTeX log */
buildlog /**< Literate build log */
};
///
explicit Buffer(string const & file, bool b = false);
@ -240,10 +246,8 @@ public:
*/
string const getLatexName(bool no_path = true) const;
/**
* get the name of the LaTeX log
*/
string const getLatexLogName(void) const;
/// get the name and type of the log
std::pair<LogType, string> const getLogName(void) const;
/// Change name of buffer. Updates "read-only" flag.
void setFileName(string const & newfile);

View File

@ -1,3 +1,11 @@
2001-02-09 John Levon <moz@compsoc.man.ac.uk>
* FormLog.C: handle Literate build log nicely
2001-02-09 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* Menubar_pimpl.C: remove support for reference menuitem type.
2001-02-07 John Levon <moz@compsoc.man.ac.uk>
* Makefile.am:

View File

@ -41,10 +41,21 @@ void FormLog::update()
if (!dialog_ || !lv_->view()->available())
return;
string const logfile = lv_->view()->buffer()->getLatexLogName();
std::pair<Buffer::LogType, string> const logfile
= lv_->view()->buffer()->getLogName();
fl_clear_browser(dialog_->browser);
if (!fl_load_browser(dialog_->browser, logfile.c_str()))
fl_add_browser_line(dialog_->browser, _("No LaTeX log file found"));
if (logfile.first == Buffer::buildlog) {
fl_set_form_title(dialog_->form, _("Build log"));
if (!fl_load_browser(dialog_->browser, logfile.second.c_str()))
fl_add_browser_line(dialog_->browser,
_("No build log file found"));
return;
}
fl_set_form_title(dialog_->form, _("LaTeX Log"));
if (!fl_load_browser(dialog_->browser, logfile.second.c_str()))
fl_add_browser_line(dialog_->browser,
_("No LaTeX log file found"));
}

View File

@ -367,130 +367,6 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label,
}
void add_references2(int menu, vector<int> & smn, Window win,
vector<string> const & label_list, string const & type)
{
size_type const max_number_of_items = 25;
size_type const max_number_of_items2 = 20;
string::size_type const max_item_length = 40;
string::size_type const max_item_length2 = 20;
if (label_list.size() <= max_number_of_items)
for (size_type i = 0; i < label_list.size(); ++i) {
int const action = (type == "goto")
? lyxaction.getPseudoAction(LFUN_REF_GOTO,
label_list[i])
: lyxaction.getPseudoAction(LFUN_REF_INSERT,
type + "|++||++|"
+ label_list[i]);
string label = label_list[i];
if (label.size() > max_item_length)
label = label.substr(0, max_item_length-1) + "$";
label += "%x" + tostr(action + action_offset);
fl_addtopup(menu, label.c_str());
}
else {
size_type count = 0;
for (size_type i = 0; i < label_list.size();
i += max_number_of_items2) {
++count;
if (count > max_number_of_items) {
fl_addtopup(menu, ". . .%d");
break;
}
size_type j = min(label_list.size(),
i+max_number_of_items2);
string label;
label += (label_list[i].size() > max_item_length2)
? label_list[i].substr(0, max_item_length2-1) + "$"
: label_list[i];
label += "..";
label += (label_list[j-1].size() > max_item_length2)
? label_list[j-1].substr(0, max_item_length2-1) + "$"
: label += label_list[j-1];
int menu2 = get_new_submenu(smn, win);
for (size_type k = i; k < j; ++k) {
int const action = (type == "goto")
? lyxaction.getPseudoAction(LFUN_REF_GOTO,
label_list[k])
: lyxaction.getPseudoAction(LFUN_REF_INSERT,
type + "|++||++|"
+ label_list[k]);
string label2 = label_list[k];
if (label2.size() > max_item_length)
label2 = label2.substr(0, max_item_length-1) + "$";
label2 += "%x" + tostr(action + action_offset);
fl_addtopup(menu2, label2.c_str());
}
label += "%m";
fl_addtopup(menu, label.c_str(), menu2);
}
}
}
void Menubar::Pimpl::add_references(int menu, string const & extra_label,
vector<int> & smn, Window win)
{
//xgettext:no-c-format
static char const * MenuNames[6] = { N_("Insert Reference%m"),
//xgettext:no-c-format
N_("Insert Page Number%m"),
//xgettext:no-c-format
N_("Insert vref%m"),
//xgettext:no-c-format
N_("Insert vpageref%m"),
//xgettext:no-c-format
N_("Insert Pretty Ref%m"),
//xgettext:no-c-format
N_("Goto Reference%m") };
int const EMPTY = 1;
int const SGML = 2;
int const READONLY = 4;
static int MenuFlags[6] = {
EMPTY | READONLY,
EMPTY | READONLY,
EMPTY | READONLY | SGML,
EMPTY | READONLY | SGML,
EMPTY | READONLY | SGML,
EMPTY };
static string const MenuTypes[6] = {
"ref", "pageref", "vref", "vpageref", "prettyref", "goto" };
vector<string> label_list = owner_->buffer()->getLabelList();
int flag = 0;
if (label_list.empty())
flag += EMPTY;
if (owner_->buffer()->isSGML())
flag += SGML;
if (owner_->buffer()->isReadonly())
flag += READONLY;
int max_nonempty = -1;
for (int i = 0; i < 6; ++i)
if ((MenuFlags[i] & flag) == 0)
max_nonempty = i;
for (int i = 0; i < 6; ++i) {
if ((MenuFlags[i] & flag) == 0) {
string label = _(MenuNames[i]);
if (i == max_nonempty)
label += extra_label;
int menu2 = get_new_submenu(smn, win);
add_references2(menu2, smn, win, label_list,
MenuTypes[i]);
fl_addtopup(menu, label.c_str(), menu2);
}
}
}
int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
string const & menu_name,
vector<int> & smn)
@ -633,10 +509,6 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view,
add_toc(menu, extra_label, smn, win);
break;
case MenuItem::References:
add_references(menu, extra_label, smn, win);
break;
case MenuItem::Documents:
case MenuItem::Lastfiles:
case MenuItem::ViewFormats:

View File

@ -1,3 +1,8 @@
2001-02-09 Andre Poenitz <poenitz@HTWM.De>
* math_iter.h: remove unused prototype
* array.h: ditto.
2001-02-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* math_macro.C (draw): add .c_str() to .str() (useful when

View File

@ -78,9 +78,6 @@ public:
/// Insert a character at position pos
void Insert(int pos, byte);
/// Insert a string of lenght dx at position pos
void Insert(int pos, byte *, int dx);
/// Constructs a new array with dx elements starting at pos
byte operator[](const int);

View File

@ -198,8 +198,6 @@ class MathedXIter: public MathedIter {
inline
void GetIncPos(int &, int &) const;
///
byte * GetString(int &) const ;
///
string const GetString() const;
///
int GetX() const;

View File

@ -206,9 +206,8 @@ void MathParInset::Write(ostream & os, bool fragile)
if (l) {
os << '\\' << l->name << ' ';
} else {
#warning This does not compile (Lgb)
//lyxerr << "Illegal symbol code[" << c
// << " " << str.end() - s << " " << data.FCode() << "]";
lyxerr << "Illegal symbol code[" << c
<< " " << str.end() - s << " " << data.FCode() << "]";
}
} else {
// Is there a standard logical XOR?