1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich,
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
17 #include FORMS_H_LOCATION
19 #include "layout_forms.h"
22 #include "insets/insetlabel.h"
23 #include "insets/figinset.h"
25 #include "minibuffer.h"
27 #include "bufferlist.h"
29 #include "lyx_gui_misc.h"
31 #include "lastfiles.h"
32 #include "bufferview_funcs.h"
33 #include "support/FileInfo.h"
34 #include "support/syscall.h"
35 #include "support/filetools.h"
36 #include "support/path.h"
42 using std::back_inserter;
46 using std::istream_iterator;
52 extern Combox * combo_language;
53 extern Combox * combo_language2;
54 extern BufferList bufferlist;
55 extern void show_symbols_form();
56 extern FD_form_character * fd_form_character;
57 extern FD_form_preamble * fd_form_preamble;
58 extern FD_form_figure * fd_form_figure;
60 extern BufferView * current_view; // called too many times in this file...
62 extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
65 extern bool send_fax(string const & fname, string const & sendcmd);
68 extern void MenuSendto();
70 // this should be static, but I need it in buffer.C
71 bool quitting; // flag, that we are quitting the program
72 extern bool finished; // all cleanup done just let it run through now.
74 char ascii_type; /* for selection notify callbacks */
76 bool scrolling = false;
78 // This is used to make the dreaded font toggle problem hopefully go
79 // away. Definitely not the best solution, but I think it sorta works.
80 bool toggleall = true;
83 This is the inset locking stuff needed for mathed --------------------
85 an inset can simple call LockInset in it's edit call and *ONLY* in it's
87 Inset::Edit() can only be called by the main lyx module.
89 Then the inset may modify the menu's and/or iconbars.
91 Unlocking is either done by LyX or the inset itself with a UnlockInset-call
93 During the lock, all button and keyboard events will be modified
94 and send to the inset through the following inset-features. Note that
95 Inset::InsetUnlock will be called from inside UnlockInset. It is meant
96 to contain the code for restoring the menus and things like this.
99 virtual void InsetButtonPress(int x, int y, int button);
100 virtual void InsetButtonRelease(int x, int y, int button);
101 virtual void InsetKeyPress(XKeyEvent *ev);
102 virtual void InsetMotionNotify(int x, int y, int state);
103 virtual void InsetUnlock();
105 If a inset wishes any redraw and/or update it just has to call
107 It's is completly irrelevant, where the inset is. UpdateInset will
108 find it in any paragraph in any buffer.
109 Of course the_locking_inset and the insets in the current paragraph/buffer
110 are checked first, so no performance problem should occur.
112 Hope that's ok for the beginning, Alejandro,
113 sorry that I needed so much time,
118 //void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
120 /* these functions return 1 if an error occured,
122 // Now they work only for updatable insets. [Alejandro 080596]
123 //int LockInset(UpdatableInset * inset);
124 void ToggleLockedInsetCursor(int x, int y, int asc, int desc);
125 //void FitLockedInsetCursor(long x, long y, int asc, int desc);
126 //int UnlockInset(UpdatableInset * inset);
127 //void LockedInsetStoreUndo(Undo::undo_kind kind);
129 /* this is for asyncron updating. UpdateInsetUpdateList will be called
130 automatically from LyX. Just insert the Inset into the Updatelist */
131 //void UpdateInsetUpdateList();
132 //void PutInsetIntoInsetUpdateList(Inset * inset);
134 //InsetUpdateStruct * InsetUpdateList = 0;
138 -----------------------------------------------------------------------
142 void ShowMessage(Buffer const * buf,
145 string const & msg3, int delay)
148 buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
151 lyxerr << msg1 << msg2 << msg3 << endl;
163 // should be moved to lyxfunc.C
164 bool MenuWrite(BufferView * bv, Buffer * buffer)
166 XFlush(fl_get_display());
167 if (!buffer->save()) {
168 string const fname = buffer->fileName();
169 string const s = MakeAbsPath(fname);
170 if (AskQuestion(_("Save failed. Rename and try again?"),
171 MakeDisplayPath(s, 50),
172 _("(If not, document is not saved.)"))) {
173 return MenuWriteAs(bv, buffer);
177 lastfiles->newFile(buffer->fileName());
183 // should be moved to BufferView.C
184 // Half of this func should be in LyXView, the rest in BufferView.
185 bool MenuWriteAs(BufferView * bv, Buffer * buffer)
187 // Why do we require BufferView::text to be able to write a
188 // document? I see no point in that. (Lgb)
189 //if (!bv->text) return;
191 string fname = buffer->fileName();
192 string oldname = fname;
196 fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
197 fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
199 if (!IsLyXFilename(fname))
202 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
205 OnlyFilename(fname));
212 // Make sure the absolute filename ends with appropriate suffix
213 string s = MakeAbsPath(fname);
214 if (!IsLyXFilename(s))
217 // Same name as we have already?
218 if (!buffer->isUnnamed() && s == oldname) {
219 if (!AskQuestion(_("Same name as document already has:"),
220 MakeDisplayPath(s, 50),
223 // Falls through to name change and save
225 // No, but do we have another file with this name open?
226 else if (!buffer->isUnnamed() && bufferlist.exists(s)) {
227 if (AskQuestion(_("Another document with same name open!"),
228 MakeDisplayPath(s, 50),
229 _("Replace with current document?")))
231 bufferlist.close(bufferlist.getBuffer(s));
233 // Ok, change the name of the buffer, but don't save!
234 buffer->setFileName(s);
237 ShowMessage(buffer, _("Document renamed to '"),
238 MakeDisplayPath(s), _("', but not saved..."));
241 } // Check whether the file exists
243 FileInfo const myfile(s);
244 if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
245 MakeDisplayPath(s, 50),
250 // Ok, change the name of the buffer
251 buffer->setFileName(s);
253 bool unnamed = buffer->isUnnamed();
254 buffer->setUnnamed(false);
256 // Small bug: If the save fails, we have irreversible changed the name
258 // Hope this is fixed this way! (Jug)
259 if (!MenuWrite(bv, buffer)) {
260 buffer->setFileName(oldname);
261 buffer->setUnnamed(unnamed);
262 ShowMessage(buffer, _("Document could not be saved!"),
263 _("Holding the old name."), MakeDisplayPath(oldname));
266 // now remove the oldname autosave file if existant!
267 removeAutosaveFile(oldname);
272 int MenuRunChktex(Buffer * buffer)
276 if (buffer->isSGML()) {
277 WriteAlert(_("Chktex does not work with SGML derived documents."));
280 ret = buffer->runChktex();
286 s = _("No warnings found.");
287 } else if (ret == 1) {
288 s = _("One warning found.");
289 t = _("Use 'Edit->Go to Error' to find it.");
292 s += _(" warnings found.");
293 t = _("Use 'Edit->Go to Error' to find them.");
295 WriteAlert(_("Chktex run successfully"), s, t);
297 WriteAlert(_("Error!"), _("It seems chktex does not work."));
304 void MenuFax(Buffer * buffer)
306 // Generate postscript file
307 if (!Exporter::Export(buffer, "ps", true))
311 string const ps = OnlyFilename(ChangeExtension(buffer->fileName(),
314 string path = OnlyPath (buffer->fileName());
315 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
316 path = buffer->tmppath;
319 if (!lyxrc.fax_program.empty()) {
320 string help2 = subst(lyxrc.fax_program, "$$FName", ps);
322 Systemcalls one(Systemcalls::System, help2);
324 send_fax(ps, lyxrc.fax_command);
331 lyxerr.debug() << "Running QuitLyX." << endl;
334 if (!bufferlist.QwriteAll())
337 lastfiles->writeFile(lyxrc.lastfiles);
340 // Set a flag that we do quitting from the program,
341 // so no refreshes are necessary.
344 // close buffers first
345 bufferlist.closeAll();
347 // do any other cleanup procedures now
348 lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
350 DestroyLyXTmpDir(system_tempdir);
357 void AutoSave(BufferView * bv)
358 // should probably be moved into BufferList (Lgb)
359 // Perfect target for a thread...
361 if (!bv->available())
364 if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
365 // We don't save now, but we'll try again later
366 bv->owner()->resetAutosaveTimer();
370 bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
372 // create autosave filename
373 string fname = OnlyPath(bv->buffer()->fileName());
375 fname += OnlyFilename(bv->buffer()->fileName());
378 // tmp_ret will be located (usually) in /tmp
379 // will that be a problem?
380 pid_t const pid = fork(); // If you want to debug the autosave
381 // you should set pid to -1, and comment out the
383 if (pid == 0 || pid == -1) {
384 // pid = -1 signifies that lyx was unable
385 // to fork. But we will do the save
389 string const tmp_ret = lyx::tempName(string(), "lyxauto");
390 if (!tmp_ret.empty()) {
391 bv->buffer()->writeFile(tmp_ret, 1);
392 // assume successful write of tmp_ret
393 if (!lyx::rename(tmp_ret, fname)) {
395 // most likely couldn't move between filesystems
396 // unless write of tmp_ret failed
397 // so remove tmp file (if it exists)
398 lyx::unlink(tmp_ret);
405 // failed to write/rename tmp_ret so try writing direct
406 if (!bv->buffer()->writeFile(fname, 1)) {
407 // It is dangerous to do this in the child,
408 // but safe in the parent, so...
410 bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
413 if (pid == 0) { // we are the child so...
418 bv->buffer()->markBakClean();
419 bv->owner()->resetAutosaveTimer();
424 // Copyright CHT Software Service GmbH
427 // create new file with template
430 Buffer * NewLyxFile(string const & filename)
432 // Split argument by :
434 string tmpname = split(filename, name, ':');
435 #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
436 if (name.length() == 1
437 && isalpha(static_cast<unsigned char>(name[0]))
438 && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
440 name += token(tmpname, ':', 0);
441 tmpname = split(tmpname, ':');
444 lyxerr.debug() << "Arg is " << filename
445 << "\nName is " << name
446 << "\nTemplate is " << tmpname << endl;
448 // find a free buffer
449 Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
451 lastfiles->newFile(tmpbuf->fileName());
456 // Insert ascii file (if filename is empty, prompt for one)
457 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
462 if (!bv->available()) return;
466 fname = fileDlg.Select(_("File to Insert"),
467 bv->owner()->buffer()->filepath,
470 if (fname.empty()) return;
475 if (!fi.readable()) {
476 WriteFSAlert(_("Error! Specified file is unreadable: "),
477 MakeDisplayPath(fname, 50));
481 ifstream ifs(fname.c_str());
483 WriteFSAlert(_("Error! Cannot open specified file: "),
484 MakeDisplayPath(fname, 50));
488 ifs.unsetf(ios::skipws);
489 istream_iterator<char> ii(ifs);
490 istream_iterator<char> end;
491 #if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
492 // We use this until the compilers get better...
494 copy(ii, end, back_inserter(tmp));
495 string const tmpstr(tmp.begin(), tmp.end());
497 // This is what we want to use and what we will use once the
498 // compilers get good enough.
499 //string tmpstr(ii, end); // yet a reason for using std::string
500 // alternate approach to get the file into a string:
502 copy(ii, end, back_inserter(tmpstr));
507 // clear the selection
510 bv->text->InsertStringA(bv, tmpstr);
512 bv->text->InsertStringB(bv, tmpstr);
513 bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
517 void MenuInsertLabel(BufferView * bv, string const & arg)
524 bv->text->cursor.par()->FirstPhysicalPar();
526 LyXParagraph * par = bv->text->cursor.par();
528 LyXLayout const * layout =
529 &textclasslist.Style(bv->buffer()->params.textclass,
532 if (layout->latextype == LATEX_PARAGRAPH && par->previous) {
534 LyXParagraph * par2 = par->previous->FirstPhysicalPar();
536 LyXParagraph * par2 = par->previous;
538 LyXLayout const * layout2 =
539 &textclasslist.Style(bv->buffer()->params.textclass,
541 if (layout2->latextype != LATEX_PARAGRAPH) {
546 string text = layout->latexname().substr(0, 3);
547 if (layout->latexname() == "theorem")
548 text = "thm"; // Create a correct prefix for prettyref
550 if (par->footnoteflag==LyXParagraph::OPEN_FOOTNOTE)
551 switch (par->footnotekind) {
552 case LyXParagraph::FIG:
553 case LyXParagraph::WIDE_FIG:
556 case LyXParagraph::TAB:
557 case LyXParagraph::WIDE_TAB:
560 case LyXParagraph::ALGORITHM:
563 case LyXParagraph::FOOTNOTE:
564 case LyXParagraph::MARGIN:
569 if (layout->latextype == LATEX_PARAGRAPH ||
570 lyxrc.label_init_length < 0)
572 string par_text = par->String(bv->buffer(), false);
573 for (int i = 0; i < lyxrc.label_init_length; ++i) {
574 if (par_text.empty())
577 par_text = split(par_text, head, ' ');
579 text += '-'; // Is it legal to use spaces in
584 pair<bool, string> result =
585 askForText(_("Enter new label to insert:"), text);
587 label = frontStrip(strip(result.second));
590 if (!label.empty()) {
591 InsetCommandParams p( "label", label );
592 InsetLabel * inset = new InsetLabel( p );
593 bv->insertInset( inset );
599 // This is _only_ used in Toolbar_pimpl.C, move it there and get rid of
600 // current_view. (Lgb)
601 void LayoutsCB(int sel, void *, Combox *)
603 string const tmp = tostr(sel);
604 current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
609 void MenuLayoutCharacter()
611 static int ow = -1, oh;
613 if (fd_form_character->form_character->visible) {
614 fl_raise_form(fd_form_character->form_character);
616 fl_show_form(fd_form_character->form_character,
617 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
618 _("Character Style"));
620 ow = fd_form_character->form_character->w;
621 oh = fd_form_character->form_character->h;
623 fl_set_form_minsize(fd_form_character->form_character, ow, oh);
628 bool UpdateLayoutPreamble(BufferView * bv)
631 if (!bv->available())
635 fl_set_input(fd_form_preamble->input_preamble,
636 bv->buffer()->params.preamble.c_str());
638 if (bv->buffer()->isReadonly()) {
639 fl_deactivate_object(fd_form_preamble->input_preamble);
640 fl_deactivate_object(fd_form_preamble->button_ok);
641 fl_deactivate_object(fd_form_preamble->button_apply);
642 fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
643 fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
645 fl_activate_object(fd_form_preamble->input_preamble);
646 fl_activate_object(fd_form_preamble->button_ok);
647 fl_activate_object(fd_form_preamble->button_apply);
648 fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
649 fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
651 } else if (fd_form_preamble->form_preamble->visible) {
652 fl_hide_form(fd_form_preamble->form_preamble);
658 void MenuLayoutPreamble()
660 static int ow = -1, oh;
662 if (UpdateLayoutPreamble(current_view)) {
663 if (fd_form_preamble->form_preamble->visible) {
664 fl_raise_form(fd_form_preamble->form_preamble);
666 fl_show_form(fd_form_preamble->form_preamble,
667 FL_PLACE_MOUSE | FL_FREE_SIZE,
669 _("LaTeX Preamble"));
671 ow = fd_form_preamble->form_preamble->w;
672 oh = fd_form_preamble->form_preamble->h;
674 fl_set_form_minsize(fd_form_preamble->form_preamble,
681 void MenuLayoutSave(BufferView * bv)
683 if (!bv->available())
686 if (AskQuestion(_("Do you want to save the current settings"),
687 _("for Character, Document, Paper and Quotes"),
688 _("as default for new documents?")))
689 bv->buffer()->saveParamsAsDefaults();
693 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
694 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
695 LyXFont const UserFreeFont(BufferParams const & params)
697 LyXFont font(LyXFont::ALL_IGNORE);
699 int pos = fl_get_choice(fd_form_character->choice_family);
701 case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
702 case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
703 case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
704 case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
705 case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
708 pos = fl_get_choice(fd_form_character->choice_series);
710 case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
711 case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
712 case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
713 case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
716 pos = fl_get_choice(fd_form_character->choice_shape);
718 case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
719 case 2: font.setShape(LyXFont::UP_SHAPE); break;
720 case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
721 case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
722 case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
723 case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
726 pos = fl_get_choice(fd_form_character->choice_size);
728 case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
729 case 2: font.setSize(LyXFont::SIZE_TINY); break;
730 case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
731 case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
732 case 5: font.setSize(LyXFont::SIZE_SMALL); break;
733 case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
734 case 7: font.setSize(LyXFont::SIZE_LARGE); break;
735 case 8: font.setSize(LyXFont::SIZE_LARGER); break;
736 case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
737 case 10: font.setSize(LyXFont::SIZE_HUGE); break;
738 case 11: font.setSize(LyXFont::SIZE_HUGER); break;
739 case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
740 case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
741 case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
744 pos = fl_get_choice(fd_form_character->choice_bar);
746 case 1: font.setEmph(LyXFont::IGNORE);
747 font.setUnderbar(LyXFont::IGNORE);
748 font.setNoun(LyXFont::IGNORE);
749 font.setLatex(LyXFont::IGNORE);
751 case 2: font.setEmph(LyXFont::TOGGLE); break;
752 case 3: font.setUnderbar(LyXFont::TOGGLE); break;
753 case 4: font.setNoun(LyXFont::TOGGLE); break;
754 case 5: font.setLatex(LyXFont::TOGGLE); break;
755 case 6: font.setEmph(LyXFont::INHERIT);
756 font.setUnderbar(LyXFont::INHERIT);
757 font.setNoun(LyXFont::INHERIT);
758 font.setLatex(LyXFont::INHERIT);
762 pos = fl_get_choice(fd_form_character->choice_color);
764 case 1: font.setColor(LColor::ignore); break;
765 case 2: font.setColor(LColor::none); break;
766 case 3: font.setColor(LColor::black); break;
767 case 4: font.setColor(LColor::white); break;
768 case 5: font.setColor(LColor::red); break;
769 case 6: font.setColor(LColor::green); break;
770 case 7: font.setColor(LColor::blue); break;
771 case 8: font.setColor(LColor::cyan); break;
772 case 9: font.setColor(LColor::magenta); break;
773 case 10: font.setColor(LColor::yellow); break;
774 case 11: font.setColor(LColor::inherit); break;
777 int const choice = combo_language2->get();
779 font.setLanguage(ignore_language);
780 else if (choice == 2)
781 font.setLanguage(params.language);
783 font.setLanguage(languages.getLanguage(combo_language2->getline()));
789 /* callbacks for form form_character */
792 void CharacterApplyCB(FL_OBJECT *, long)
794 // we set toggleall locally here, since it should be true for
795 // all other uses of ToggleAndShow() (JMarc)
796 toggleall = fl_get_button(fd_form_character->check_toggle_all);
797 ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
798 current_view->setState();
804 void CharacterCloseCB(FL_OBJECT *, long)
806 fl_hide_form(fd_form_character->form_character);
811 void CharacterOKCB(FL_OBJECT * ob, long data)
813 CharacterApplyCB(ob, data);
814 CharacterCloseCB(ob, data);
818 /* callbacks for form form_preamble */
821 void PreambleCancelCB(FL_OBJECT *, long)
823 fl_hide_form(fd_form_preamble->form_preamble);
828 void PreambleApplyCB(FL_OBJECT *, long)
830 if (!current_view->available())
833 current_view->buffer()->params.preamble =
834 fl_get_input(fd_form_preamble->input_preamble);
835 current_view->buffer()->markDirty();
836 current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
841 void PreambleOKCB(FL_OBJECT * ob, long data)
843 PreambleApplyCB(ob, data);
844 PreambleCancelCB(ob, data);
850 if (fd_form_figure->form_figure->visible) {
851 fl_raise_form(fd_form_figure->form_figure);
853 fl_show_form(fd_form_figure->form_figure,
854 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
860 /* callbacks for form form_figure */
862 void FigureApplyCB(FL_OBJECT *, long)
864 if (!current_view->available())
867 Buffer * buffer = current_view->buffer();
868 if (buffer->isReadonly()) // paranoia
871 current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
872 if (fl_get_button(fd_form_figure->radio_inline)) {
873 InsetFig * new_inset = new InsetFig(100, 20, *buffer);
874 current_view->insertInset(new_inset);
875 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
876 new_inset->Edit(current_view, 0, 0, 0);
880 current_view->hideCursor();
881 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR);
882 current_view->beforeChange();
884 current_view->text->SetCursorParUndo(current_view->buffer());
885 current_view->text->FreezeUndo();
887 current_view->text->BreakParagraph(current_view);
888 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
890 if (current_view->text->cursor.par()->Last()) {
891 current_view->text->CursorLeft(current_view);
893 current_view->text->BreakParagraph(current_view);
894 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
897 // The standard layout should always be numer 0;
898 current_view->text->SetLayout(current_view, 0);
901 if (current_view->text->cursor.par()->footnoteflag ==
902 LyXParagraph::NO_FOOTNOTE) {
905 SetParagraph(current_view, 0, 0,
907 VSpace (0.3 * buffer->params.spacing.getValue(),
910 buffer->params.spacing.getValue(),
912 LYX_ALIGN_CENTER, string(), 0);
915 current_view->text->SetParagraph(current_view, 0, 0,
917 VSpace(VSpace::NONE),
918 VSpace(VSpace::NONE),
925 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
927 Inset * new_inset = new InsetFig(100, 100, *buffer);
928 current_view->insertInset(new_inset);
929 new_inset->Edit(current_view, 0, 0, 0);
930 current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR);
931 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
932 current_view->text->UnFreezeUndo();
933 current_view->setState();
937 extern "C" void FigureCancelCB(FL_OBJECT *, long)
939 fl_hide_form(fd_form_figure->form_figure);
943 extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
945 FigureApplyCB(ob, data);
946 FigureCancelCB(ob, data);
950 // This function runs "configure" and then rereads lyx.defaults to
951 // reconfigure the automatic settings.
952 void Reconfigure(BufferView * bv)
954 bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
956 // Run configure in user lyx directory
958 Systemcalls one(Systemcalls::System,
959 AddName(system_lyxdir, "configure"));
961 bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
962 lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
963 WriteAlert(_("The system has been reconfigured."),
964 _("You need to restart LyX to make use of any"),
965 _("updated document class specifications."));