+2001-03-12 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+
+ * buffer.h: add some typedefs
+ * buffer.C (getLists): use them
+ (getLists): renamed from getTocList.
+ add a counter for the different float types and use it in the
+ generated string.
+ (getLists): use the same counter for the NEW_INSETS and the "non"
+ NEW_INSETS
+
+ * lyx_cb.h: remove unused items, includes, using etc.
+
+ * ShareContainer.h: remove some commented code, add more comments
+ and "documentation".
+
2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* buffer.C (getTocList): make the list also when NEW_INSETS is
#include <boost/utility.hpp>
#include <boost/smart_ptr.hpp>
-///
+/// Share objects between several users.
+/**
+ This class can be used to reduce memory consuption when you have a lot
+ of equal objects used all over you code.
+
+ \author Lars Gullik Bjønnes
+*/
template<class Share>
class ShareContainer : public noncopyable {
public:
typedef std::vector<boost::shared_ptr<Share> > Params;
///
typedef typename Params::value_type value_type;
- ///
+ /// Return a shared_ptr that points to a element equal to ps.
value_type
get(Share const & ps) const {
// First see if we already have this ps in the container
// some (one) unique elemements some times
// but we should gain a lot in speed.
clean();
- //std::sort(params.rbegin(), params.rend(), comp());
} else {
// yes we have it already
tmp = *it;
- // move it forward
+ // move it forward - optimization
+ // makes the next find faster.
if (it != params.begin())
swap(*it, *(it - 1));
}
return tmp;
}
private:
- ///
+ /// A functor returning true if the elements are equal.
struct isEqual {
isEqual(Share const & s) : p_(s) {}
bool operator()(value_type const & p1) const {
private:
Share const & p_;
};
- ///
- //struct comp {
- // int operator()(value_type const & p1,
- // value_type const & p2) const {
- // return p1.use_count() < p2.use_count();
- // }
- //};
- ///
+ /// A functor returning true if the element is unque.
struct isUnique {
bool operator()(value_type const & p) const {
return p.unique();
}
};
- ///
+ /** Remove all unique items.
+ This removes all elements from params that is only referenced
+ from the private container. This can be considered a memory
+ optimizaton.
+ */
void clean() const {
- // Remove all unique items. (i.e. entries that only
- // exists in the conatainer and does not have a
- // corresponding paragrah.
Params::iterator it = std::remove_if(params.begin(),
params.end(),
isUnique());
params.erase(it, params.end());
}
- ///
+ /// The actual container.
mutable Params params;
};
#endif
}
-map<string, vector<Buffer::TocItem> > const Buffer::getTocList() const
+Buffer::Lists const Buffer::getLists() const
{
-#ifndef NEW_INSETS
- int figs = 0;
- int tables = 0;
- int algs = 0;
-#endif
- map<string, vector<TocItem> > l;
+ map<string, int> count;
+ Lists l;
LyXParagraph * par = paragraph;
while (par) {
#ifndef NEW_INSETS
case LyXParagraph::FIG:
case LyXParagraph::WIDE_FIG:
{
- tmp.str = tostr(++figs) + ". "
+ count["figs"]++;
+ tmp.str = tostr(count["figs"]) + ". "
+ tmp.str;
- map<string, vector<TocItem> >::iterator it = l.find("LOF");
+ Lists::iterator it = l.find("LOF");
if (it == l.end()) {
- vector<TocItem> vti;
+ SingleList vti;
vti.push_back(tmp);
l["LOF"] = vti;
} else {
case LyXParagraph::TAB:
case LyXParagraph::WIDE_TAB:
{
- tmp.str = tostr(++tables) + ". "
+ count["tables"]++;
+ tmp.str = tostr(count["tables"]) + ". "
+ tmp.str;
- map<string, vector<TocItem> >::iterator it = l.find("LOT");
+ Lists::iterator it = l.find("LOT");
if (it == l.end()) {
- vector<TocItem> vti;
+ SingleList vti;
vti.push_back(tmp);
l["LOT"] = vti;
} else {
case LyXParagraph::ALGORITHM:
{
- tmp.str = tostr(++algs) + ". "
+ count["algs"]++;
+ tmp.str = tostr(count["algs"]) + ". "
+ tmp.str;
- map<string, vector<TocItem> >::iterator it = l.find("LOA");
+ Lists::iterator it = l.find("LOA");
if (it == l.end()) {
- vector<TocItem> vti;
+ SingleList vti;
vti.push_back(tmp);
l["LOA"] = vti;
} else {
labeltype -
textclasslist.TextClass(params.textclass).maxcounter());
tmp.str = par->String(this, true);
- map<string, vector<TocItem> >::iterator it = l.find("TOC");
+ Lists::iterator it = l.find("TOC");
if (it == l.end()) {
- vector<TocItem> vti;
+ SingleList vti;
vti.push_back(tmp);
l["TOC"] = vti;
} else {
#ifdef NEW_INSETS
// For each paragrph, traverse its insets and look for
// FLOAT_CODE
+
LyXParagraph::inset_iterator it =
par->inset_iterator_begin();
LyXParagraph::inset_iterator end =
InsetFloat * il =
static_cast<InsetFloat*>(*it);
- //lyxerr << "Found a float!" << endl;
string const type = il->type();
+
// Now find the caption in the float...
// We now tranverse the paragraphs of
// the inset...
LyXParagraph * tmp = il->inset->par;
while (tmp) {
if (tmp->layout == cap) {
+ count[type]++;
TocItem ti;
ti.par = tmp;
ti.depth = 0;
- ti.str = tmp->String(this, false);
- map<string, vector<TocItem> >::iterator it = l.find(type);
+ ti.str = tostr(count[type]) + ". " + tmp->String(this, false);
+ Lists::iterator it = l.find(type);
if (it == l.end()) {
- vector<TocItem> vti;
+ SingleList vti;
vti.push_back(ti);
l[type] = vti;
} else {
}
tmp = tmp->next();
}
-
}
}
} else {
// This is also a buffer property (ale)
-vector<pair<string,string> > const Buffer::getBibkeyList()
+vector<pair<string, string> > const Buffer::getBibkeyList()
{
/// if this is a child document and the parent is already loaded
/// Use the parent's list instead [ale990412]
string str;
};
///
- std::map<string, std::vector<TocItem> > const getTocList() const;
+ typedef std::vector<TocItem> SingleList;
+ ///
+ typedef std::map<string, SingleList> Lists;
+ ///
+ Lists const getLists() const;
///
std::vector<string> const getLabelList();
+2001-03-12 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+
+ * FormToc.h: use Buffer::typedef
+
+ * Menubar_pimpl.C (add_toc): use the Buffer::typedefs
+ * FormToc.C (build): ditto
+ (updateToc): ditto
+
2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* FormToc.C (build): implement for dynamic number of lists
fl_addto_choice(dialog_->choice_toc_type,
_(" TOC | LOF | LOT | LOA "));
#else
- map<string, vector<Buffer::TocItem> > tmp =
- lv_->view()->buffer()->getTocList();
- string types;
- map<string, vector<Buffer::TocItem> >::const_iterator cit = tmp.begin();
- map<string, vector<Buffer::TocItem> >::const_iterator end = tmp.end();
+ Buffer::Lists const tmp = lv_->view()->buffer()->getLists();
+ Buffer::Lists::const_iterator cit = tmp.begin();
+ Buffer::Lists::const_iterator end = tmp.end();
for (; cit != end; ++cit) {
fl_addto_choice(dialog_->choice_toc_type, cit->first.c_str());
}
return;
}
- map<string, vector<Buffer::TocItem> > tmp =
- lv_->view()->buffer()->getTocList();
- //int type = fl_get_choice( dialog_->choice_toc_type ) - 1;
- string type = fl_get_choice_item_text(dialog_->choice_toc_type,
- fl_get_choice(dialog_->choice_toc_type));
+ Buffer::Lists tmp = lv_->view()->buffer()->getLists();
+ string const type =
+ fl_get_choice_item_text(dialog_->choice_toc_type,
+ fl_get_choice(dialog_->choice_toc_type));
- map<string, vector<Buffer::TocItem> >::iterator it = tmp.find(type);
+ Buffer::Lists::iterator it = tmp.find(type);
if (it != tmp.end()) {
// Check if all elements are the same.
fl_clear_browser(dialog_->browser_toc);
- vector<Buffer::TocItem>::const_iterator cit = toclist.begin();
- vector<Buffer::TocItem>::const_iterator end = toclist.end();
+ Buffer::SingleList::const_iterator cit = toclist.begin();
+ Buffer::SingleList::const_iterator end = toclist.end();
for (; cit != end; ++cit) {
string const line = string(4 * cit->depth, ' ') + cit->str;
/// Real GUI implementation.
FD_form_toc * dialog_;
///
- std::vector<Buffer::TocItem> toclist;
+ Buffer::SingleList toclist;
};
#endif
toc_list[0], 0, toc_list[0].size(), 0);
#else
#warning Fix Me! (Lgb)
- map<string, vector<Buffer::TocItem> > toc_list =
- owner_->buffer()->getTocList();
-
- map<string, vector<Buffer::TocItem> >::const_iterator cit =
- toc_list.begin();
- map<string, vector<Buffer::TocItem> >::const_iterator end =
- toc_list.end();
+ Buffer::Lists toc_list = owner_->buffer()->getLists();
+ Buffer::Lists::const_iterator cit = toc_list.begin();
+ Buffer::Lists::const_iterator end = toc_list.end();
for (; cit != end; ++cit) {
// Handle this elsewhere
if (cit->first == "TOC") continue;
int menu2 = get_new_submenu(smn, win);
- vector<Buffer::TocItem>::const_iterator ccit =
- cit->second.begin();
- vector<Buffer::TocItem>::const_iterator eend =
- cit->second.end();
+ Buffer::SingleList::const_iterator ccit = cit->second.begin();
+ Buffer::SingleList::const_iterator eend = cit->second.end();
for (; ccit != eend; ++ccit) {
- int const action = lyxaction.getPseudoAction(LFUN_GOTO_PARAGRAPH, tostr(ccit->par->id()));
+ int const action =
+ lyxaction
+ .getPseudoAction(LFUN_GOTO_PARAGRAPH,
+ tostr(ccit->par->id()));
string label = fixlabel(ccit->str);
label = limit_string_length(label);
label += "%x" + tostr(action + action_offset);
+2001-03-12 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
+
+ * insettoc.C (Ascii): use the Buffer typedefs
+
2001-03-11 Lars Gullik Bjønnes <larsbj@trylle.birdstep.com>
* insettoc.C (Ascii): implement for dynamic number of lists
else
type = "LOT";
- map<string, vector<Buffer::TocItem> > const toc_list =
- buffer->getTocList();
- map<string, vector<Buffer::TocItem> >::const_iterator cit =
+ Buffer::Lists const toc_list = buffer->getLists();
+ Buffer::Lists::const_iterator cit =
toc_list.find(type);
if (cit != toc_list.end()) {
- vector<Buffer::TocItem>::const_iterator ccit =
- cit->second.begin();
- vector<Buffer::TocItem>::const_iterator end =
- cit->second.end();
+ Buffer::SingleList::const_iterator ccit = cit->second.begin();
+ Buffer::SingleList::const_iterator end = cit->second.end();
for (; ccit != end; ++ccit)
os << string(4 * ccit->depth, ' ')
<< ccit->str << endl;
#include "lyx_cb.h"
#include "insets/insetlabel.h"
#include "insets/figinset.h"
-#include "lyxfunc.h"
#include "minibuffer.h"
-#include "combox.h"
#include "bufferlist.h"
#include "frontends/FileDialog.h"
#include "lyx_gui_misc.h"
#include "lyxrc.h"
#include "lyxtext.h"
+using std::vector;
using std::ifstream;
using std::copy;
-using std::back_inserter;
using std::endl;
-using std::cout;
-using std::ios;
+using std::back_inserter;
using std::istream_iterator;
using std::pair;
using std::make_pair;
-using std::vector;
-using std::sort;
-using std::equal;
extern BufferList bufferlist;
-extern void show_symbols_form();
extern FD_form_figure * fd_form_figure;
extern BufferView * current_view; // called too many times in this file...
-extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
-
-extern void MenuSendto();
-
// this should be static, but I need it in buffer.C
bool quitting; // flag, that we are quitting the program
extern bool finished; // all cleanup done just let it run through now.
-char ascii_type; /* for selection notify callbacks */
-
-bool scrolling = false;
-
/*
This is the inset locking stuff needed for mathed --------------------
if (filename.empty()) {
- FileDialog fileDlg(bv->owner(), _("Choose a filename to save document as"),
+ FileDialog fileDlg(bv->owner(),
+ _("Choose a filename to save document as"),
LFUN_WRITEAS,
- make_pair(string(_("Documents")), string(lyxrc.document_path)),
- make_pair(string(_("Templates")), string(lyxrc.template_path)));
+ make_pair(string(_("Documents")),
+ string(lyxrc.document_path)),
+ make_pair(string(_("Templates")),
+ string(lyxrc.template_path)));
if (!IsLyXFilename(fname))
fname += ".lyx";
- FileDialog::Result result = fileDlg.Select(OnlyPath(fname), _("*.lyx|LyX Documents (*.lyx)"), OnlyFilename(fname));
+ FileDialog::Result result =
+ fileDlg.Select(OnlyPath(fname),
+ _("*.lyx|LyX Documents (*.lyx)"),
+ OnlyFilename(fname));
if (result.first == FileDialog::Later)
return false;
} else
fname = filename;
-
// Same name as we have already?
if (!buffer->isUnnamed() && fname == oldname) {
if (!AskQuestion(_("Same name as document already has:"),
}
-extern "C" void FigureCancelCB(FL_OBJECT *, long)
+extern "C"
+void FigureCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_figure->form_figure);
}
-extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
+extern "C"
+void FigureOKCB(FL_OBJECT * ob, long data)
{
FigureApplyCB(ob, data);
FigureCancelCB(ob, data);
#define LYX_CB_H
#include "LString.h"
-#include "lyxfont.h"
-class BufferParams;
+class Buffer;
class BufferView;
-class Combox;
///
extern bool quitting;
-///
-extern bool toggleall;
-// When still false after reading lyxrc, warn user
-//about failing \bind_file command. RVDK_PATCH_5
-///
-extern bool BindFileSet;
///
void ShowMessage(Buffer const * buf,
string const & msg1,
///
bool MenuWrite(BufferView * bv, Buffer * buffer);
/// write the given file, or ask if no name given
-bool WriteAs(BufferView * bv, Buffer * buffer, const string & filename = string());
+bool WriteAs(BufferView * bv, Buffer * buffer,
+ string const & filename = string());
///
int MenuRunChktex(Buffer * buffer);
///
///
void MenuInsertLabel(BufferView * bv, string const & arg);
///
-void MenuLayoutCharacter();
-///
void MenuLayoutSave(BufferView * bv);
///
void Figure();
///
void Reconfigure(BufferView * bv);
-
-
#endif