X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetlabel.C;h=590b50a65dd85f6a5218a630da96d86c7524a6c1;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=697a524079e1da3088df8820d33eb4218134d388;hpb=a9b448a027036c65c40b372bd19e02f243d1f1ab;p=lyx.git diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 697a524079..590b50a65d 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. + * Copyright 1995-2001 The LyX Team. * * ====================================================== */ @@ -15,79 +15,84 @@ #endif #include "insetlabel.h" +#include "support/LOstream.h" +#include "frontends/Alert.h" +#include "support/lstrings.h" //frontStrip, strip +#include "lyxtext.h" +#include "buffer.h" +#include "gettext.h" +#include "BufferView.h" +#include "support/lstrings.h" + +using std::ostream; +using std::vector; +using std::pair; /* Label. Used to insert a label automatically */ -InsetLabel::InsetLabel(string const & cmd) -{ - scanCommand(cmd); -} +InsetLabel::InsetLabel(InsetCommandParams const & p, bool) + : InsetCommand(p) +{} -Inset * InsetLabel::Clone() const +vector const InsetLabel::getLabelList() const { - return new InsetLabel(getCommand()); + return vector(1, getContents()); } -int InsetLabel::GetNumberOfLabels() const +void InsetLabel::edit(BufferView * bv, int, int, unsigned int) { - return 1; + pair result = Alert::askForText(_("Enter label:"), getContents()); + if (result.first) { + string new_contents = frontStrip(strip(result.second)); + if (!new_contents.empty() && + getContents() != new_contents) { + bv->buffer()->markDirty(); + bool flag = bv->ChangeRefsIfUnique(getContents(), + new_contents); + setContents(new_contents); + bv->text->redoParagraph(bv); + if (flag) { + bv->redraw(); + bv->fitCursor(); + } else + bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + } + } } -string InsetLabel::getLabel(int) const +void InsetLabel::edit(BufferView * bv, bool) { - return contents; + edit(bv, 0, 0, 0); } -int InsetLabel::Latex(ostream & os, signed char /*fragile*/) const +int InsetLabel::latex(Buffer const *, ostream & os, + bool /*fragile*/, bool /*fs*/) const { os << escape(getCommand()); return 0; } - -#ifndef USE_OSTREAM_ONLY -int InsetLabel::Latex(string & file, signed char /*fragile*/) const +int InsetLabel::ascii(Buffer const *, ostream & os, int) const { - file += escape(getCommand()); + os << "<" << getContents() << ">"; return 0; } -#endif -int InsetLabel::Linuxdoc(string & file) const +int InsetLabel::linuxdoc(Buffer const *, ostream & os) const { - file += "