/* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich * Copyright 1995-2000 The LyX Team. * * ====================================================== */ #include #ifdef __GNUG__ #pragma implementation #endif #include "insetlabel.h" #include "support/LOstream.h" #include "lyx_gui_misc.h" //askForText #include "support/lstrings.h" //frontStrip, strip #include "lyxtext.h" #include "buffer.h" using std::ostream; using std::vector; using std::pair; /* Label. Used to insert a label automatically */ InsetLabel::InsetLabel(string const & cmd) { scanCommand(cmd); } Inset * InsetLabel::Clone() const { return new InsetLabel(getCommand()); } vector InsetLabel::getLabelList() const { return vector(1,contents); } void InsetLabel::Edit(BufferView * bv, int, int, unsigned int) { if(bv->buffer()->isReadonly()) { WarnReadonly(bv->buffer()->fileName()); return; } pair result = askForText(_("Enter label:"), contents); if (result.first) { string new_contents = frontStrip(strip(result.second)); if (!new_contents.empty() && contents != new_contents) { bool flag = bv->ChangeRefs(contents,new_contents); contents = new_contents; bv->text->RedoParagraph(); if (flag) { bv->redraw(); bv->fitCursor(); //bv->updateScrollbar(); } else bv->update(1); } } } int InsetLabel::Latex(ostream & os, bool /*fragile*/, bool /*fs*/) const { os << escape(getCommand()); return 0; } int InsetLabel::Ascii(ostream & os) const { os << "<" << getContents() << ">"; return 0; } int InsetLabel::Linuxdoc(ostream & os) const { os << "