From e7ca356bf7f6060b1ec23763f4333358e36f1355 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 9 Feb 2001 15:54:30 +0000 Subject: [PATCH] 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 --- src/ChangeLog | 11 +++ src/MenuBackend.C | 7 -- src/MenuBackend.h | 2 - src/buffer.C | 28 +++--- src/buffer.h | 12 ++- src/frontends/xforms/ChangeLog | 8 ++ src/frontends/xforms/FormLog.C | 17 +++- src/frontends/xforms/Menubar_pimpl.C | 128 --------------------------- src/mathed/ChangeLog | 5 ++ src/mathed/array.h | 3 - src/mathed/math_iter.h | 2 - src/mathed/math_write.C | 5 +- 12 files changed, 64 insertions(+), 164 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b6cb3d8c40..8d1b80c717 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2001-02-09 John Levon + + * buffer.h: + * buffer.C: rename to getLogName(), handle + build log / latex log nicely + +2001-02-09 Jean-Marc Lasgouttes + + * MenuBackend.C: + * MenuBackend.h: remove support for reference menuitem type. + 2001-02-07 John Levon * BufferView_pimpl.C: housekeeping diff --git a/src/MenuBackend.C b/src/MenuBackend.C index a73b2aa175..53cdc1200d 100644 --- a/src/MenuBackend.C +++ b/src/MenuBackend.C @@ -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; diff --git a/src/MenuBackend.h b/src/MenuBackend.h index 192c45d5c4..d21df33408 100644 --- a/src/MenuBackend.h +++ b/src/MenuBackend.h @@ -44,8 +44,6 @@ public: Documents, /// Toc, - /// - References, /** This is a list of viewable formats typically for the File->View menu. */ ViewFormats, diff --git a/src/buffer.C b/src/buffer.C index ed641b4110..f4c92268c5 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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 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) diff --git a/src/buffer.h b/src/buffer.h index b717a78051..15aecd6062 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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 const getLogName(void) const; /// Change name of buffer. Updates "read-only" flag. void setFileName(string const & newfile); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 8d49e1fe8a..63f7215407 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,11 @@ +2001-02-09 John Levon + + * FormLog.C: handle Literate build log nicely + +2001-02-09 Jean-Marc Lasgouttes + + * Menubar_pimpl.C: remove support for reference menuitem type. + 2001-02-07 John Levon * Makefile.am: diff --git a/src/frontends/xforms/FormLog.C b/src/frontends/xforms/FormLog.C index e85e324a69..d8accd95ff 100644 --- a/src/frontends/xforms/FormLog.C +++ b/src/frontends/xforms/FormLog.C @@ -41,10 +41,21 @@ void FormLog::update() if (!dialog_ || !lv_->view()->available()) return; - string const logfile = lv_->view()->buffer()->getLatexLogName(); + std::pair 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")); } diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index 91daef413b..6a26b0f450 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -367,130 +367,6 @@ void Menubar::Pimpl::add_toc(int menu, string const & extra_label, } -void add_references2(int menu, vector & smn, Window win, - vector 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 & 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 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 & 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: diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index aa81690a58..6f0382b2b9 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2001-02-09 Andre Poenitz + + * math_iter.h: remove unused prototype + * array.h: ditto. + 2001-02-08 Jean-Marc Lasgouttes * math_macro.C (draw): add .c_str() to .str() (useful when diff --git a/src/mathed/array.h b/src/mathed/array.h index 1a33d6438c..4be93b9bfc 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -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); diff --git a/src/mathed/math_iter.h b/src/mathed/math_iter.h index c6e89231f6..dc19a7f43c 100644 --- a/src/mathed/math_iter.h +++ b/src/mathed/math_iter.h @@ -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; diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index e0e436924d..e19aaf0ca8 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -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?