X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetlabel.C;h=590b50a65dd85f6a5218a630da96d86c7524a6c1;hb=4a5b7a5952ad2381fcdf4830511293e184c7c5a1;hp=8e1bbe75f4ecf181bfb98b94e9fb6d2d775d0663;hpb=d0655188bcdbaeccc1fbcbb5ab997841da7ea6e1;p=lyx.git diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 8e1bbe75f4..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-2000 The LyX Team. + * Copyright 1995-2001 The LyX Team. * * ====================================================== */ @@ -16,10 +16,13 @@ #include "insetlabel.h" #include "support/LOstream.h" -#include "lyx_gui_misc.h" //askForText +#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; @@ -28,87 +31,68 @@ using std::pair; /* Label. Used to insert a label automatically */ -InsetLabel::InsetLabel(InsetCommandParams const & p) +InsetLabel::InsetLabel(InsetCommandParams const & p, bool) : InsetCommand(p) {} vector const InsetLabel::getLabelList() const { - return vector(1,getContents()); + return vector(1, getContents()); } -void InsetLabel::Edit(BufferView * bv, int, int, unsigned int) +void InsetLabel::edit(BufferView * bv, int, int, unsigned int) { - if (bv->buffer()->isReadonly()) { - WarnReadonly(bv->buffer()->fileName()); - return; - } - - pair result = askForText(_("Enter label:"), getContents()); + 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->ChangeRefs(getContents(),new_contents); - setContents( new_contents ); - bv->text->RedoParagraph(bv); + bool flag = bv->ChangeRefsIfUnique(getContents(), + new_contents); + setContents(new_contents); + bv->text->redoParagraph(bv); if (flag) { bv->redraw(); bv->fitCursor(); - //bv->updateScrollbar(); } else - bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); } } } -int InsetLabel::Latex(Buffer const *, ostream & os, +void InsetLabel::edit(BufferView * bv, bool) +{ + edit(bv, 0, 0, 0); +} + + +int InsetLabel::latex(Buffer const *, ostream & os, bool /*fragile*/, bool /*fs*/) const { os << escape(getCommand()); return 0; } -int InsetLabel::Ascii(Buffer const *, ostream & os, int linelen) const +int InsetLabel::ascii(Buffer const *, ostream & os, int) const { os << "<" << getContents() << ">"; return 0; } -int InsetLabel::Linuxdoc(Buffer const *, ostream & os) const +int InsetLabel::linuxdoc(Buffer const *, ostream & os) const { os << "