- // insert the string
- bv->hideCursor();
-
- // clear the selection
- bv->beforeChange(bv->text);
- if (!asParagraph)
- bv->text->InsertStringA(bv, tmpstr);
- else
- bv->text->InsertStringB(bv, tmpstr);
- bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-}
-
-
-void MenuInsertLabel(BufferView * bv, string const & arg)
-{
- string label(arg);
- ProhibitInput(bv);
- if (label.empty()) {
-#ifndef NEW_INSETS
- LyXParagraph * par =
- bv->text->cursor.par()->FirstPhysicalPar();
-#else
- LyXParagraph * par = bv->text->cursor.par();
-#endif
- LyXLayout const * layout =
- &textclasslist.Style(bv->buffer()->params.textclass,
- par->GetLayout());
-
-#ifndef NEW_INSETS
- if (layout->latextype == LATEX_PARAGRAPH && par->previous_) {
- LyXParagraph * par2 = par->previous_->FirstPhysicalPar();
-#else
- if (layout->latextype == LATEX_PARAGRAPH && par->previous()) {
- LyXParagraph * par2 = par->previous();
-#endif
- LyXLayout const * layout2 =
- &textclasslist.Style(bv->buffer()->params.textclass,
- par2->GetLayout());
- if (layout2->latextype != LATEX_PARAGRAPH) {
- par = par2;
- layout = layout2;
- }
- }
- string text = layout->latexname().substr(0, 3);
- if (layout->latexname() == "theorem")
- text = "thm"; // Create a correct prefix for prettyref
-#ifndef NEW_INSETS
- if (par->footnoteflag==LyXParagraph::OPEN_FOOTNOTE)
- switch (par->footnotekind) {
- case LyXParagraph::FIG:
- case LyXParagraph::WIDE_FIG:
- text = "fig";
- break;
- case LyXParagraph::TAB:
- case LyXParagraph::WIDE_TAB:
- text = "tab";
- break;
- case LyXParagraph::ALGORITHM:
- text = "alg";
- break;
- case LyXParagraph::FOOTNOTE:
- case LyXParagraph::MARGIN:
- break;
- }
-#endif
- text += ":";
- if (layout->latextype == LATEX_PARAGRAPH ||
- lyxrc.label_init_length < 0)
- text.erase();
- string par_text = par->String(bv->buffer(), false);
- for (int i = 0; i < lyxrc.label_init_length; ++i) {
- if (par_text.empty())
- break;
- string head;
- par_text = split(par_text, head, ' ');
- if (i > 0)
- text += '-'; // Is it legal to use spaces in
- // labels ?
- text += head;
- }
-
- pair<bool, string> result =
- askForText(_("Enter new label to insert:"), text);
- if (result.first) {
- label = frontStrip(strip(result.second));
- }
- }
- if (!label.empty()) {
- InsetCommandParams p( "label", label );
- InsetLabel * inset = new InsetLabel( p );
- bv->insertInset( inset );
- }
- AllowInput(bv);
-}
-
-
-void MenuLayoutSave(BufferView * bv)
-{
- if (!bv->available())
- return;
-
- if (AskQuestion(_("Do you want to save the current settings"),
- _("for Character, Document, Paper and Quotes"),
- _("as default for new documents?")))
- bv->buffer()->saveParamsAsDefaults();
-}
-
-
-void Figure()
-{
- if (fd_form_figure->form_figure->visible) {
- fl_raise_form(fd_form_figure->form_figure);
- } else {
- fl_show_form(fd_form_figure->form_figure,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
- _("Insert Figure"));
- }
-}
-
-
-/* callbacks for form form_figure */
-extern "C"
-void FigureApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- Buffer * buffer = current_view->buffer();
- if (buffer->isReadonly()) // paranoia
- return;
-
- current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
- if (fl_get_button(fd_form_figure->radio_inline)) {
- InsetFig * new_inset = new InsetFig(100, 20, *buffer);
- current_view->insertInset(new_inset);
- current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
- new_inset->Edit(current_view, 0, 0, 0);
- return;
- }
-
- current_view->hideCursor();
- current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR);
- current_view->beforeChange(current_view->text);
-
- current_view->text->SetCursorParUndo(current_view->buffer());
- current_view->text->FreezeUndo();
-
- current_view->text->BreakParagraph(current_view);
- current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
-#ifndef NEW_INSETS
- if (current_view->text->cursor.par()->Last()) {
-#else
- if (current_view->text->cursor.par()->size()) {
-#endif
- current_view->text->CursorLeft(current_view);
-
- current_view->text->BreakParagraph(current_view);
- current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- }
-
- // The standard layout should always be numer 0;
- current_view->text->SetLayout(current_view, 0);
-
-#ifndef NEW_INSETS
- if (current_view->text->cursor.par()->footnoteflag ==
- LyXParagraph::NO_FOOTNOTE) {
-#endif
- current_view->text->
- SetParagraph(current_view, 0, 0,
- 0, 0,
- VSpace (0.3 * buffer->params.spacing.getValue(),
- LyXLength::CM),
- VSpace (0.3 *
- buffer->params.spacing.getValue(),
- LyXLength::CM),
- LYX_ALIGN_CENTER, string(), 0);
-#ifndef NEW_INSETS
- } else {
- current_view->text->SetParagraph(current_view, 0, 0,
- 0, 0,
- VSpace(VSpace::NONE),
- VSpace(VSpace::NONE),
- LYX_ALIGN_CENTER,
- string(),
- 0);
- }
-#endif
-
- current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-
- Inset * new_inset = new InsetFig(100, 100, *buffer);
- current_view->insertInset(new_inset);
- new_inset->Edit(current_view, 0, 0, 0);
- current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR);
- current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
- current_view->text->UnFreezeUndo();
- current_view->setState();
-}
-