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"
23 //#include "insets/insetref.h"
24 #include "insets/insetlabel.h"
25 #include "insets/figinset.h"
27 #include "minibuffer.h"
29 #include "bufferlist.h"
31 #include "lyx_gui_misc.h"
33 //#include "BufferView.h"
34 #include "lastfiles.h"
35 #include "bufferview_funcs.h"
36 #include "support/FileInfo.h"
37 #include "support/syscall.h"
38 #include "support/filetools.h"
39 #include "support/path.h"
40 //#include "support/lyxlib.h"
41 //#include "lyxserver.h"
44 //#include "CutAndPaste.h"
45 //#include "exporter.h"
49 using std::back_inserter;
53 using std::istream_iterator;
59 extern Combox * combo_language;
60 extern Combox * combo_language2;
61 extern BufferList bufferlist;
62 extern void show_symbols_form();
63 extern FD_form_title * fd_form_title;
64 extern FD_form_character * fd_form_character;
65 extern FD_form_preamble * fd_form_preamble;
66 extern FD_form_figure * fd_form_figure;
68 extern BufferView * current_view; // called too many times in this file...
70 extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
73 extern bool send_fax(string const & fname, string const & sendcmd);
76 extern void MenuSendto();
78 //extern LyXServer * lyxserver;
80 // this should be static, but I need it in buffer.C
81 bool quitting; // flag, that we are quitting the program
82 extern bool finished; // all cleanup done just let it run through now.
84 char ascii_type; /* for selection notify callbacks */
86 bool scrolling = false;
88 // This is used to make the dreaded font toggle problem hopefully go
89 // away. Definitely not the best solution, but I think it sorta works.
90 bool toggleall = true;
93 This is the inset locking stuff needed for mathed --------------------
95 an inset can simple call LockInset in it's edit call and *ONLY* in it's
97 Inset::Edit() can only be called by the main lyx module.
99 Then the inset may modify the menu's and/or iconbars.
101 Unlocking is either done by LyX or the inset itself with a UnlockInset-call
103 During the lock, all button and keyboard events will be modified
104 and send to the inset through the following inset-features. Note that
105 Inset::InsetUnlock will be called from inside UnlockInset. It is meant
106 to contain the code for restoring the menus and things like this.
109 virtual void InsetButtonPress(int x, int y, int button);
110 virtual void InsetButtonRelease(int x, int y, int button);
111 virtual void InsetKeyPress(XKeyEvent *ev);
112 virtual void InsetMotionNotify(int x, int y, int state);
113 virtual void InsetUnlock();
115 If a inset wishes any redraw and/or update it just has to call
117 It's is completly irrelevant, where the inset is. UpdateInset will
118 find it in any paragraph in any buffer.
119 Of course the_locking_inset and the insets in the current paragraph/buffer
120 are checked first, so no performance problem should occur.
122 Hope that's ok for the beginning, Alejandro,
123 sorry that I needed so much time,
128 //void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
130 /* these functions return 1 if an error occured,
132 // Now they work only for updatable insets. [Alejandro 080596]
133 //int LockInset(UpdatableInset * inset);
134 void ToggleLockedInsetCursor(int x, int y, int asc, int desc);
135 //void FitLockedInsetCursor(long x, long y, int asc, int desc);
136 //int UnlockInset(UpdatableInset * inset);
137 //void LockedInsetStoreUndo(Undo::undo_kind kind);
139 /* this is for asyncron updating. UpdateInsetUpdateList will be called
140 automatically from LyX. Just insert the Inset into the Updatelist */
141 //void UpdateInsetUpdateList();
142 //void PutInsetIntoInsetUpdateList(Inset * inset);
144 //InsetUpdateStruct * InsetUpdateList = 0;
148 -----------------------------------------------------------------------
151 /* some function prototypes */
153 int RunLinuxDoc(BufferView *, int, string const &);
154 int RunDocBook(int, string const &);
155 bool MenuWrite(Buffer * buf);
156 bool MenuWriteAs(Buffer * buffer);
157 void MenuReload(Buffer * buf);
158 void MenuLayoutSave();
161 void ShowMessage(Buffer const * buf,
164 string const & msg3, int delay)
167 buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
170 lyxerr << msg1 << msg2 << msg3 << endl;
182 // should be moved to lyxfunc.C
183 bool MenuWrite(Buffer * buffer)
185 XFlush(fl_get_display());
186 if (!buffer->save()) {
187 string fname = buffer->fileName();
188 string s = MakeAbsPath(fname);
189 if (AskQuestion(_("Save failed. Rename and try again?"),
190 MakeDisplayPath(s, 50),
191 _("(If not, document is not saved.)"))) {
192 return MenuWriteAs(buffer);
196 lastfiles->newFile(buffer->fileName());
202 // should be moved to BufferView.C
203 // Half of this func should be in LyXView, the rest in BufferView.
204 bool MenuWriteAs(Buffer * buffer)
206 // Why do we require BufferView::text to be able to write a
207 // document? I see no point in that. (Lgb)
208 //if (!bv->text) return;
210 string fname = buffer->fileName();
211 string oldname = fname;
214 ProhibitInput(current_view);
215 fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
216 fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
218 if (!IsLyXFilename(fname))
221 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
224 OnlyFilename(fname));
226 AllowInput(current_view);
231 // Make sure the absolute filename ends with appropriate suffix
232 string s = MakeAbsPath(fname);
233 if (!IsLyXFilename(s))
236 // Same name as we have already?
237 if (!buffer->isUnnamed() && s == oldname) {
238 if (!AskQuestion(_("Same name as document already has:"),
239 MakeDisplayPath(s, 50),
242 // Falls through to name change and save
244 // No, but do we have another file with this name open?
245 else if (!buffer->isUnnamed() && bufferlist.exists(s)) {
246 if (AskQuestion(_("Another document with same name open!"),
247 MakeDisplayPath(s, 50),
248 _("Replace with current document?")))
250 bufferlist.close(bufferlist.getBuffer(s));
252 // Ok, change the name of the buffer, but don't save!
253 buffer->setFileName(s);
256 ShowMessage(buffer, _("Document renamed to '"),
257 MakeDisplayPath(s), _("', but not saved..."));
260 } // Check whether the file exists
263 if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
264 MakeDisplayPath(s, 50),
269 // Ok, change the name of the buffer
270 buffer->setFileName(s);
272 bool unnamed = buffer->isUnnamed();
273 buffer->setUnnamed(false);
275 // Small bug: If the save fails, we have irreversible changed the name
277 // Hope this is fixed this way! (Jug)
278 if (!MenuWrite(buffer)) {
279 buffer->setFileName(oldname);
280 buffer->setUnnamed(unnamed);
281 ShowMessage(buffer, _("Document could not be saved!"),
282 _("Holding the old name."), MakeDisplayPath(oldname));
285 // now remove the oldname autosave file if existant!
286 removeAutosaveFile(oldname);
291 int MenuRunChktex(Buffer * buffer)
295 if (buffer->isSGML()) {
296 WriteAlert(_("Chktex does not work with SGML derived documents."));
299 ret = buffer->runChktex();
305 s = _("No warnings found.");
306 } else if (ret == 1) {
307 s = _("One warning found.");
308 t = _("Use 'Edit->Go to Error' to find it.");
311 s += _(" warnings found.");
312 t = _("Use 'Edit->Go to Error' to find them.");
314 WriteAlert(_("Chktex run successfully"), s, t);
316 WriteAlert(_("Error!"), _("It seems chktex does not work."));
322 void MenuFax(Buffer * buffer)
324 // Generate postscript file
325 if (!Exporter::Export(buffer, "ps", true))
329 string const ps = OnlyFilename(ChangeExtension(buffer->fileName(),
332 string path = OnlyPath (buffer->fileName());
333 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
334 path = buffer->tmppath;
337 if (!lyxrc.fax_program.empty()) {
338 string help2 = subst(lyxrc.fax_program, "$$FName", ps);
340 Systemcalls one(Systemcalls::System, help2);
342 send_fax(ps, lyxrc.fax_command);
349 lyxerr.debug() << "Running QuitLyX." << endl;
351 if (!bufferlist.QwriteAll())
354 lastfiles->writeFile(lyxrc.lastfiles);
356 // Set a flag that we do quitting from the program,
357 // so no refreshes are necessary.
360 // close buffers first
361 bufferlist.closeAll();
363 // do any other cleanup procedures now
364 lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
366 DestroyLyXTmpDir(system_tempdir);
373 void AutoSave(BufferView * bv)
374 // should probably be moved into BufferList (Lgb)
375 // Perfect target for a thread...
377 if (!bv->available())
380 if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
381 // We don't save now, but we'll try again later
382 bv->owner()->resetAutosaveTimer();
386 bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
388 // create autosave filename
389 string fname = OnlyPath(bv->buffer()->fileName());
391 fname += OnlyFilename(bv->buffer()->fileName());
394 // tmp_ret will be located (usually) in /tmp
395 // will that be a problem?
396 pid_t pid = fork(); // If you want to debug the autosave
397 // you should set pid to -1, and comment out the
399 if (pid == 0 || pid == -1) {
400 // pid = -1 signifies that lyx was unable
401 // to fork. But we will do the save
405 string tmp_ret = lyx::tempName();
406 if (!tmp_ret.empty()) {
407 bv->buffer()->writeFile(tmp_ret, 1);
408 // assume successful write of tmp_ret
409 if (lyx::rename(tmp_ret, fname)) {
411 // most likely couldn't move between filesystems
412 // unless write of tmp_ret failed
413 // so remove tmp file (if it exists)
414 lyx::unlink(tmp_ret);
421 // failed to write/rename tmp_ret so try writing direct
422 if (!bv->buffer()->writeFile(fname, 1)) {
423 // It is dangerous to do this in the child,
424 // but safe in the parent, so...
426 bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
429 if (pid == 0) { // we are the child so...
434 bv->buffer()->markBakClean();
435 bv->owner()->resetAutosaveTimer();
440 // Copyright CHT Software Service GmbH
443 // create new file with template
446 Buffer * NewLyxFile(string const & filename)
448 // Split argument by :
450 string tmpname = split(filename, name, ':');
451 #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
452 if (name.length() == 1
453 && isalpha(static_cast<unsigned char>(name[0]))
454 && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
456 name += token(tmpname, ':', 0);
457 tmpname = split(tmpname, ':');
460 lyxerr.debug() << "Arg is " << filename
461 << "\nName is " << name
462 << "\nTemplate is " << tmpname << endl;
464 // find a free buffer
465 Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
467 lastfiles->newFile(tmpbuf->fileName());
472 // Insert ascii file (if filename is empty, prompt for one)
473 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
478 if (!bv->available()) return;
482 fname = fileDlg.Select(_("File to Insert"),
483 bv->owner()->buffer()->filepath,
486 if (fname.empty()) return;
491 if (!fi.readable()) {
492 WriteFSAlert(_("Error! Specified file is unreadable: "),
493 MakeDisplayPath(fname, 50));
497 ifstream ifs(fname.c_str());
499 WriteFSAlert(_("Error! Cannot open specified file: "),
500 MakeDisplayPath(fname, 50));
504 ifs.unsetf(ios::skipws);
505 istream_iterator<char> ii(ifs);
506 istream_iterator<char> end;
507 #if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
508 // We use this until the compilers get better...
510 copy(ii, end, back_inserter(tmp));
511 string tmpstr(tmp.begin(), tmp.end());
513 // This is what we want to use and what we will use once the
514 // compilers get good enough.
515 //string tmpstr(ii, end); // yet a reason for using std::string
516 // alternate approach to get the file into a string:
518 copy(ii, end, back_inserter(tmpstr));
523 // clear the selection
526 bv->text->InsertStringA(bv, tmpstr);
528 bv->text->InsertStringB(bv, tmpstr);
529 bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
533 void MenuInsertLabel(string const & arg)
536 ProhibitInput(current_view);
539 result = askForText(_("Enter new label to insert:"));
541 label = frontStrip(strip(result.second));
544 if (!label.empty()) {
545 InsetCommandParams p( "label", label );
546 InsetLabel * inset = new InsetLabel( p );
547 current_view->insertInset( inset );
549 AllowInput(current_view);
553 // This is _only_ used in Toolbar_pimpl.C, move it there and get rid of
554 // current_view. (Lgb)
555 void LayoutsCB(int sel, void *, Combox *)
557 string tmp = tostr(sel);
558 current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
563 void MenuLayoutCharacter()
565 static int ow = -1, oh;
567 if (fd_form_character->form_character->visible) {
568 fl_raise_form(fd_form_character->form_character);
570 fl_show_form(fd_form_character->form_character,
571 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
572 _("Character Style"));
574 ow = fd_form_character->form_character->w;
575 oh = fd_form_character->form_character->h;
577 fl_set_form_minsize(fd_form_character->form_character, ow, oh);
582 bool UpdateLayoutPreamble()
585 if (!current_view->available())
589 fl_set_input(fd_form_preamble->input_preamble,
590 current_view->buffer()->params.preamble.c_str());
592 if (current_view->buffer()->isReadonly()) {
593 fl_deactivate_object(fd_form_preamble->input_preamble);
594 fl_deactivate_object(fd_form_preamble->button_ok);
595 fl_deactivate_object(fd_form_preamble->button_apply);
596 fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
597 fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
600 fl_activate_object(fd_form_preamble->input_preamble);
601 fl_activate_object(fd_form_preamble->button_ok);
602 fl_activate_object(fd_form_preamble->button_apply);
603 fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
604 fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
606 } else if (fd_form_preamble->form_preamble->visible) {
607 fl_hide_form(fd_form_preamble->form_preamble);
613 void MenuLayoutPreamble()
615 static int ow = -1, oh;
617 if (UpdateLayoutPreamble()) {
618 if (fd_form_preamble->form_preamble->visible) {
619 fl_raise_form(fd_form_preamble->form_preamble);
621 fl_show_form(fd_form_preamble->form_preamble,
622 FL_PLACE_MOUSE | FL_FREE_SIZE,
624 _("LaTeX Preamble"));
626 ow = fd_form_preamble->form_preamble->w;
627 oh = fd_form_preamble->form_preamble->h;
629 fl_set_form_minsize(fd_form_preamble->form_preamble,
636 void MenuLayoutSave()
638 if (!current_view->available())
641 if (AskQuestion(_("Do you want to save the current settings"),
642 _("for Character, Document, Paper and Quotes"),
643 _("as default for new documents?")))
644 current_view->buffer()->saveParamsAsDefaults();
648 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
649 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
650 LyXFont const UserFreeFont(BufferParams const & params)
652 LyXFont font(LyXFont::ALL_IGNORE);
654 int pos = fl_get_choice(fd_form_character->choice_family);
656 case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
657 case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
658 case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
659 case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
660 case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
663 pos = fl_get_choice(fd_form_character->choice_series);
665 case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
666 case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
667 case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
668 case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
671 pos = fl_get_choice(fd_form_character->choice_shape);
673 case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
674 case 2: font.setShape(LyXFont::UP_SHAPE); break;
675 case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
676 case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
677 case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
678 case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
681 pos = fl_get_choice(fd_form_character->choice_size);
683 case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
684 case 2: font.setSize(LyXFont::SIZE_TINY); break;
685 case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
686 case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
687 case 5: font.setSize(LyXFont::SIZE_SMALL); break;
688 case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
689 case 7: font.setSize(LyXFont::SIZE_LARGE); break;
690 case 8: font.setSize(LyXFont::SIZE_LARGER); break;
691 case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
692 case 10: font.setSize(LyXFont::SIZE_HUGE); break;
693 case 11: font.setSize(LyXFont::SIZE_HUGER); break;
694 case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
695 case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
696 case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
699 pos = fl_get_choice(fd_form_character->choice_bar);
701 case 1: font.setEmph(LyXFont::IGNORE);
702 font.setUnderbar(LyXFont::IGNORE);
703 font.setNoun(LyXFont::IGNORE);
704 font.setLatex(LyXFont::IGNORE);
706 case 2: font.setEmph(LyXFont::TOGGLE); break;
707 case 3: font.setUnderbar(LyXFont::TOGGLE); break;
708 case 4: font.setNoun(LyXFont::TOGGLE); break;
709 case 5: font.setLatex(LyXFont::TOGGLE); break;
710 case 6: font.setEmph(LyXFont::INHERIT);
711 font.setUnderbar(LyXFont::INHERIT);
712 font.setNoun(LyXFont::INHERIT);
713 font.setLatex(LyXFont::INHERIT);
717 pos = fl_get_choice(fd_form_character->choice_color);
719 case 1: font.setColor(LColor::ignore); break;
720 case 2: font.setColor(LColor::none); break;
721 case 3: font.setColor(LColor::black); break;
722 case 4: font.setColor(LColor::white); break;
723 case 5: font.setColor(LColor::red); break;
724 case 6: font.setColor(LColor::green); break;
725 case 7: font.setColor(LColor::blue); break;
726 case 8: font.setColor(LColor::cyan); break;
727 case 9: font.setColor(LColor::magenta); break;
728 case 10: font.setColor(LColor::yellow); break;
729 case 11: font.setColor(LColor::inherit); break;
732 int const choice = combo_language2->get();
734 font.setLanguage(ignore_language);
735 else if (choice == 2)
736 font.setLanguage(params.language);
738 font.setLanguage(languages.getLanguage(combo_language2->getline()));
744 /* callbacks for form form_title */
745 extern "C" void TimerCB(FL_OBJECT *, long)
747 // only if the form still exists
748 if (lyxrc.show_banner
750 && fd_form_title->form_title) {
751 if (fd_form_title->form_title->visible) {
752 fl_hide_form(fd_form_title->form_title);
754 fl_free_form(fd_form_title->form_title);
755 fd_form_title->form_title = 0;
760 /* callbacks for form form_character */
762 extern "C" void CharacterApplyCB(FL_OBJECT *, long)
764 // we set toggleall locally here, since it should be true for
765 // all other uses of ToggleAndShow() (JMarc)
766 toggleall = fl_get_button(fd_form_character->check_toggle_all);
767 ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
768 current_view->setState();
773 extern "C" void CharacterCloseCB(FL_OBJECT *, long)
775 fl_hide_form(fd_form_character->form_character);
779 extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
781 CharacterApplyCB(ob, data);
782 CharacterCloseCB(ob, data);
786 /* callbacks for form form_preamble */
788 extern "C" void PreambleCancelCB(FL_OBJECT *, long)
790 fl_hide_form(fd_form_preamble->form_preamble);
794 extern "C" void PreambleApplyCB(FL_OBJECT *, long)
796 if (!current_view->available())
799 current_view->buffer()->params.preamble =
800 fl_get_input(fd_form_preamble->input_preamble);
801 current_view->buffer()->markDirty();
802 current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
806 extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
808 PreambleApplyCB(ob, data);
809 PreambleCancelCB(ob, data);
815 if (fd_form_figure->form_figure->visible) {
816 fl_raise_form(fd_form_figure->form_figure);
818 fl_show_form(fd_form_figure->form_figure,
819 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
825 /* callbacks for form form_figure */
827 void FigureApplyCB(FL_OBJECT *, long)
829 if (!current_view->available())
832 Buffer * buffer = current_view->buffer();
833 if (buffer->isReadonly()) // paranoia
836 current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
837 if (fl_get_button(fd_form_figure->radio_inline)) {
838 InsetFig * new_inset = new InsetFig(100, 20, *buffer);
839 current_view->insertInset(new_inset);
840 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
841 new_inset->Edit(current_view, 0, 0, 0);
845 current_view->hideCursor();
846 current_view->update(BufferView::SELECT|BufferView::FITCUR);
847 current_view->beforeChange();
849 current_view->text->SetCursorParUndo(current_view->buffer());
850 current_view->text->FreezeUndo();
852 current_view->text->BreakParagraph(current_view);
853 current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
855 if (current_view->text->cursor.par()->Last()) {
856 current_view->text->CursorLeft(current_view);
858 current_view->text->BreakParagraph(current_view);
859 current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
862 // The standard layout should always be numer 0;
863 current_view->text->SetLayout(current_view, 0);
866 if (current_view->text->cursor.par()->footnoteflag ==
867 LyXParagraph::NO_FOOTNOTE) {
870 SetParagraph(current_view, 0, 0,
872 VSpace (0.3 * buffer->params.spacing.getValue(),
875 buffer->params.spacing.getValue(),
877 LYX_ALIGN_CENTER, string(), 0);
880 current_view->text->SetParagraph(current_view, 0, 0,
882 VSpace(VSpace::NONE),
883 VSpace(VSpace::NONE),
890 current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
892 Inset * new_inset = new InsetFig(100, 100, *buffer);
893 current_view->insertInset(new_inset);
894 new_inset->Edit(current_view, 0, 0, 0);
895 current_view->update(BufferView::SELECT|BufferView::FITCUR);
896 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
897 current_view->text->UnFreezeUndo();
898 current_view->setState();
902 extern "C" void FigureCancelCB(FL_OBJECT *, long)
904 fl_hide_form(fd_form_figure->form_figure);
908 extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
910 FigureApplyCB(ob, data);
911 FigureCancelCB(ob, data);
915 // This function runs "configure" and then rereads lyx.defaults to
916 // reconfigure the automatic settings.
917 void Reconfigure(BufferView * bv)
919 bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
921 // Run configure in user lyx directory
923 Systemcalls one(Systemcalls::System,
924 AddName(system_lyxdir, "configure"));
926 bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
927 lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
928 WriteAlert(_("The system has been reconfigured."),
929 _("You need to restart LyX to make use of any"),
930 _("updated document class specifications."));