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 * ====================================================== */
18 #include FORMS_H_LOCATION
20 #include "layout_forms.h"
21 #include "bullet_forms.h"
22 #include "print_form.h"
26 #include "insets/insetref.h"
27 #include "insets/insetlabel.h"
28 #include "insets/figinset.h"
30 #include "minibuffer.h"
32 #include "bufferlist.h"
34 #include "lyx_gui_misc.h"
36 #include "BufferView.h"
37 #include "lastfiles.h"
38 #include "bufferview_funcs.h"
39 #include "support/FileInfo.h"
40 #include "support/syscall.h"
41 #include "support/filetools.h"
42 #include "support/path.h"
43 #include "lyxserver.h"
44 #include "FontLoader.h"
47 #include "CutAndPaste.h"
48 #include "TextCache.h"
52 using std::back_inserter;
56 using std::istream_iterator;
60 extern Combox * combo_language;
61 extern Combox * combo_language2;
62 extern BufferList bufferlist;
63 extern void show_symbols_form();
64 extern FD_form_title * fd_form_title;
65 extern FD_form_paragraph * fd_form_paragraph;
66 extern FD_form_character * fd_form_character;
67 extern FD_form_document * fd_form_document;
68 extern FD_form_quotes * fd_form_quotes;
69 extern FD_form_preamble * fd_form_preamble;
70 extern FD_form_table * fd_form_table;
71 extern FD_form_print * fd_form_print;
72 extern FD_form_figure * fd_form_figure;
73 extern FD_form_screen * fd_form_screen;
74 extern FD_form_toc * fd_form_toc;
75 extern FD_form_ref * fd_form_ref;
76 extern FD_LaTeXOptions * fd_latex_options;
77 extern FD_form_bullet * fd_form_bullet;
79 extern BufferView * current_view; // called too many times in this file...
81 extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
83 extern bool send_fax(string const & fname, string const & sendcmd);
84 extern void MenuSendto();
86 extern LyXServer * lyxserver;
88 // this should be static, but I need it in buffer.C
89 bool quitting; // flag, that we are quitting the program
90 extern bool finished; // all cleanup done just let it run through now.
92 char ascii_type; /* for selection notify callbacks */
94 bool scrolling = false;
96 // This is used to make the dreaded font toggle problem hopefully go
97 // away. Definitely not the best solution, but I think it sorta works.
98 bool toggleall = true;
101 This is the inset locking stuff needed for mathed --------------------
103 an inset can simple call LockInset in it's edit call and *ONLY* in it's
105 Inset::Edit() can only be called by the main lyx module.
107 Then the inset may modify the menu's and/or iconbars.
109 Unlocking is either done by LyX or the inset itself with a UnlockInset-call
111 During the lock, all button and keyboard events will be modified
112 and send to the inset through the following inset-features. Note that
113 Inset::InsetUnlock will be called from inside UnlockInset. It is meant
114 to contain the code for restoring the menus and things like this.
117 virtual void InsetButtonPress(int x, int y, int button);
118 virtual void InsetButtonRelease(int x, int y, int button);
119 virtual void InsetKeyPress(XKeyEvent *ev);
120 virtual void InsetMotionNotify(int x, int y, int state);
121 virtual void InsetUnlock();
123 If a inset wishes any redraw and/or update it just has to call
125 It's is completly irrelevant, where the inset is. UpdateInset will
126 find it in any paragraph in any buffer.
127 Of course the_locking_inset and the insets in the current paragraph/buffer
128 are checked first, so no performance problem should occur.
130 Hope that's ok for the beginning, Alejandro,
131 sorry that I needed so much time,
136 //void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
138 /* these functions return 1 if an error occured,
140 // Now they work only for updatable insets. [Alejandro 080596]
141 //int LockInset(UpdatableInset * inset);
142 void ToggleLockedInsetCursor(long x, long y, int asc, int desc);
143 //void FitLockedInsetCursor(long x, long y, int asc, int desc);
144 //int UnlockInset(UpdatableInset * inset);
145 //void LockedInsetStoreUndo(Undo::undo_kind kind);
147 /* this is for asyncron updating. UpdateInsetUpdateList will be called
148 automatically from LyX. Just insert the Inset into the Updatelist */
149 //void UpdateInsetUpdateList();
150 //void PutInsetIntoInsetUpdateList(Inset * inset);
152 //InsetUpdateStruct * InsetUpdateList = 0;
156 -----------------------------------------------------------------------
159 /* some function prototypes */
161 int RunLinuxDoc(BufferView *, int, string const &);
162 int RunDocBook(int, string const &);
163 void MenuWrite(Buffer * buf);
164 void MenuWriteAs(Buffer * buffer);
165 void MenuReload(Buffer * buf);
166 void MenuLayoutSave();
169 void ShowMessage(Buffer * buf,
171 string const & msg2 = string(),
172 string const & msg3 = string(), int delay = 6)
175 buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
178 // can somebody think of something more clever? cerr?
179 cout << msg1 << msg2 << msg3 << endl;
184 // only called from this file, LyXView and LyXFunc
185 char updatetimer = 0;
188 // only called from BufferView_pimpl and LyXFunc
189 void FreeUpdateTimer()
191 /* a real free timer would be better but I don't know
192 * how to do this with xforms */
197 // Only called from LyXFunc
198 void SetUpdateTimer(float time)
200 fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
213 // should be moved to lyxfunc.C
214 void MenuWrite(Buffer * buffer)
217 if (!buffer->save()) {
218 string fname = buffer->fileName();
219 string s = MakeAbsPath(fname);
220 if (AskQuestion(_("Save failed. Rename and try again?"),
221 MakeDisplayPath(s, 50),
222 _("(If not, document is not saved.)"))) {
226 lastfiles->newFile(buffer->fileName());
231 // should be moved to BufferView.C
232 // Half of this func should be in LyXView, the rest in BufferView.
233 void MenuWriteAs(Buffer * buffer)
235 // Why do we require BufferView::text to be able to write a
236 // document? I see no point in that. (Lgb)
237 //if (!bv->text) return;
239 string fname = buffer->fileName();
240 string oldname = fname;
243 ProhibitInput(current_view);
244 fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
245 fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
247 if (!IsLyXFilename(fname))
250 fname = fileDlg.Select(_("Enter Filename to Save Document as"),
253 OnlyFilename(fname));
254 AllowInput(current_view);
259 // Make sure the absolute filename ends with appropriate suffix
260 string s = MakeAbsPath(fname);
261 if (!IsLyXFilename(s))
264 // Same name as we have already?
266 if (!AskQuestion(_("Same name as document already has:"),
267 MakeDisplayPath(s, 50),
270 // Falls through to name change and save
272 // No, but do we have another file with this name open?
273 else if (bufferlist.exists(s)) {
274 if (AskQuestion(_("Another document with same name open!"),
275 MakeDisplayPath(s, 50),
276 _("Replace with current document?")))
278 bufferlist.close(bufferlist.getBuffer(s));
280 // Ok, change the name of the buffer, but don't save!
284 ShowMessage(buffer, _("Document renamed to '"),
285 MakeDisplayPath(s), _("', but not saved..."));
288 } // Check whether the file exists
291 if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
292 MakeDisplayPath(s, 50),
297 // Ok, change the name of the buffer
301 // Small bug: If the save fails, we have irreversible changed the name
307 int MenuRunLaTeX(Buffer * buffer)
311 if (buffer->isLinuxDoc())
312 ret = RunLinuxDoc(buffer->getUser(), 1, buffer->fileName());
313 else if (buffer->isLiterate())
314 ret = buffer->runLiterate();
315 else if (buffer->isDocBook())
316 ret = RunDocBook(1, buffer->fileName());
318 ret = buffer->runLaTeX();
324 s = _("One error detected");
325 t = _("You should try to fix it.");
328 s += _(" errors detected.");
329 t = _("You should try to fix them.");
331 WriteAlert(_("There were errors during the LaTeX run."), s, t);
337 int MenuBuildProg(Buffer * buffer)
341 if (buffer->isLiterate())
342 ret = buffer->buildProgram();
344 string s = _("Wrong type of document");
345 string t = _("The Build operation is not allowed in this document");
346 WriteAlert(_("There were errors during the Build process."), s, t);
354 s = _("One error detected");
355 t = _("You should try to fix it.");
358 s += _(" errors detected.");
359 t = _("You should try to fix them.");
361 WriteAlert(_("There were errors during the Build process."), s, t);
367 int MenuRunChktex(Buffer * buffer)
371 if (buffer->isSGML()) {
372 WriteAlert(_("Chktex does not work with SGML derived documents."));
375 ret = buffer->runChktex();
381 s = _("No warnings found.");
382 } else if (ret == 1) {
383 s = _("One warning found.");
384 t = _("Use 'Edit->Go to Error' to find it.");
387 s += _(" warnings found.");
388 t = _("Use 'Edit->Go to Error' to find them.");
390 WriteAlert(_("Chktex run successfully"), s, t);
392 WriteAlert(_("Error!"), _("It seems chktex does not work."));
398 int MakeLaTeXOutput(Buffer * buffer)
404 string path = OnlyPath(buffer->fileName());
405 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
406 path = buffer->tmppath;
408 if (!buffer->isDviClean()) {
410 ret = MenuRunLaTeX(buffer);
416 /* wait == false means don't wait for termination */
417 /* wait == true means wait for termination */
418 // The bool should be placed last on the argument line. (Lgb)
419 // Returns false if we fail.
420 bool RunScript(Buffer * buffer, bool wait,
421 string const & command,
422 string const & orgname = string(),
423 bool need_shell = true)
427 string name = orgname;
430 if (MakeLaTeXOutput(buffer) > 0)
432 /* get DVI-Filename */
434 name = ChangeExtension(buffer->getLatexName(), ".dvi");
436 path = OnlyPath(name);
437 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
438 path = buffer->tmppath;
441 // At this point we check whether the command contains the
442 // filename parameter $$FName and if that's the case we
443 // substitute the real file name otherwise the filename is
444 // simply appended. rokrau 1/12/00
447 if ( (i=command.find("$$FName")) != string::npos)
449 cmd.replace(i,7,QuoteName(name));
452 cmd = command + ' ' + QuoteName(name);
461 // OS/2 cmd.exe has another use for '&'
463 // This is not NLS safe, but it's OK, I think.
464 string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
466 // COMSPEC is set, unless user unsets
467 sh = OnlyFilename(GetEnvPath("COMSPEC"));
472 if (contains(sh, "cmd.exe")
473 || contains(sh, "4os2.exe"))
474 cmd = "start /min/n " + cmd;
479 // It seems that, if wait is false, we never get back
480 // the return code of the command. This means that all
481 // the code I added in PrintApplyCB is currently
483 // CHECK What should we do here?
484 ShowMessage(buffer, _("Executing command:"), cmd);
485 result = one.startscript(Systemcalls::System, cmd);
487 ShowMessage(buffer, _("Executing command:"), cmd);
488 result = one.startscript(wait ? Systemcalls::Wait
489 : Systemcalls::DontWait, cmd);
495 // Returns false if we fail
496 bool CreatePostscript(Buffer * buffer, bool wait = false)
502 ProhibitInput(current_view);
505 if (MakeLaTeXOutput(buffer) > 0) {
506 AllowInput(current_view);
509 // Generate postscript file
510 string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
516 char real_papersize = buffer->params.papersize;
517 if (real_papersize == BufferParams::PAPER_DEFAULT)
518 real_papersize = lyxrc.default_papersize;
520 switch (real_papersize) {
521 case BufferParams::PAPER_USLETTER:
524 case BufferParams::PAPER_A3PAPER:
527 case BufferParams::PAPER_A4PAPER:
530 case BufferParams::PAPER_A5PAPER:
533 case BufferParams::PAPER_B5PAPER:
536 case BufferParams::PAPER_EXECUTIVEPAPER:
539 case BufferParams::PAPER_LEGALPAPER:
542 default: /* If nothing else fits, keep an empty value... */
546 // Make postscript file.
547 string command = lyxrc.dvi_to_ps_command + ' ' + lyxrc.print_to_file + ' ';
548 command += QuoteName(psname);
549 if (buffer->params.use_geometry
550 && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
551 && !lyxrc.print_paper_dimension_flag.empty()
552 && !buffer->params.paperwidth.empty()
553 && !buffer->params.paperheight.empty()) {
554 // using a custom papersize
556 command += lyxrc.print_paper_dimension_flag + ' ';
557 command += buffer->params.paperwidth + ',';
558 command += buffer->params.paperheight;
559 } else if (!paper.empty()
560 && (real_papersize != BufferParams::PAPER_USLETTER ||
561 buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
562 // dvips won't accept -t letter -t landscape. In all other
563 // cases, include the paper size explicitly.
565 command += lyxrc.print_paper_flag + ' ' + paper;
567 if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
569 command += lyxrc.print_landscape_flag;
571 // push directorypath, if necessary
572 string path = OnlyPath(buffer->fileName());
573 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
574 path = buffer->tmppath;
577 bool ret = RunScript(buffer, wait, command);
578 AllowInput(current_view);
583 // Returns false if we fail
584 //bool MenuPreviewPS(Buffer * buffer)
585 bool PreviewPostscript(Buffer * buffer)
591 // Generate postscript file
592 if (!CreatePostscript(buffer, true)) {
596 // Start postscript viewer
597 ProhibitInput(current_view);
598 string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
600 // push directorypath, if necessary
601 string path = OnlyPath(buffer->fileName());
602 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
603 path = buffer->tmppath;
606 bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
607 AllowInput(current_view);
612 void MenuFax(Buffer * buffer)
618 // Generate postscript file
619 if (!CreatePostscript(buffer, true)) {
624 string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
626 string path = OnlyPath (buffer->fileName());
627 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
628 path = buffer->tmppath;
631 if (!lyxrc.fax_program.empty()) {
632 string help2 = subst(lyxrc.fax_program, "$$FName", ps);
634 Systemcalls one(Systemcalls::System, help2);
636 send_fax(ps, lyxrc.fax_command);
640 // Returns false if we fail
641 bool PreviewDVI(Buffer * buffer)
647 string paper = lyxrc.view_dvi_paper_option;
648 if (!paper.empty()) {
650 char real_papersize = buffer->params.papersize;
651 if (real_papersize == BufferParams::PAPER_DEFAULT)
652 real_papersize = lyxrc.default_papersize;
654 switch (real_papersize) {
655 case BufferParams::PAPER_USLETTER:
658 case BufferParams::PAPER_A3PAPER:
661 case BufferParams::PAPER_A4PAPER:
664 case BufferParams::PAPER_A5PAPER:
667 case BufferParams::PAPER_B5PAPER:
670 case BufferParams::PAPER_EXECUTIVEPAPER:
671 paper += " foolscap";
673 case BufferParams::PAPER_LEGALPAPER:
676 default: /* If nothing else fits, keep the empty value */
679 if (real_papersize==' ') {
680 // if (paper.empty()) {
681 if (buffer->params.orientation
682 == BufferParams::ORIENTATION_LANDSCAPE)
683 // we HAVE to give a size when the page is in
684 // landscape, so use USletter.
685 paper = " -paper usr";
687 // paper = " -paper " + paper;
688 if (buffer->params.orientation
689 == BufferParams::ORIENTATION_LANDSCAPE)
693 // push directorypath, if necessary
694 string path = OnlyPath(buffer->fileName());
695 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
696 path = buffer->tmppath;
700 string command = lyxrc.view_dvi_command + " " + paper;
701 bool ret = RunScript(buffer, false, command);
706 bool AskOverwrite(Buffer * buffer, string const & s)
709 // be friendly if there is a gui
712 !AskQuestion(_("File already exists:"),
713 MakeDisplayPath(s, 50),
714 _("Do you want to overwrite the file?"))) {
715 ShowMessage(buffer, _("Canceled"));
723 void MenuMakeLaTeX(Buffer * buffer)
725 // Why care about this?
729 // Get LaTeX-Filename
730 string s = buffer->getLatexName(false);
732 if (!AskOverwrite(buffer, s))
735 if (buffer->isDocBook())
736 ShowMessage(buffer, _("DocBook does not have a latex backend"));
738 if (buffer->isLinuxDoc())
739 RunLinuxDoc(buffer->getUser(), 0, buffer->fileName());
741 buffer->makeLaTeXFile(s, string(), true);
742 ShowMessage(buffer, _("Nice LaTeX file saved as"),
744 buffer->markDviDirty();
749 void MenuMakeLinuxDoc(Buffer * buffer)
752 //if (!bv->text) return;
754 if (!buffer->isLinuxDoc()) {
755 WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
759 // Get LinuxDoc-Filename
760 string s = ChangeExtension(buffer->fileName(), ".sgml");
762 if (!AskOverwrite(buffer, s))
765 ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
766 MakeDisplayPath(s),"'...");
768 buffer->makeLinuxDocFile(s, 65);
770 ShowMessage(buffer, _("LinuxDoc SGML file save as"),
775 void MenuMakeDocBook(Buffer * buffer)
778 //if (!bv->text) return;
780 if (!buffer->isDocBook()) {
781 WriteAlert(_("Error!"),
782 _("Document class must be docbook."));
786 // Get DocBook-Filename
787 string s = ChangeExtension(buffer->fileName(), ".sgml");
789 if (!AskOverwrite(buffer, s))
792 ShowMessage(buffer, _("Building DocBook SGML file `"),
793 MakeDisplayPath(s), "'...");
795 buffer->makeDocBookFile(s, 65);
797 ShowMessage(buffer, _("DocBook SGML file save as"),
802 void MenuMakeAscii(Buffer * buffer)
805 //if (!bv->text) return;
807 /* get LaTeX-Filename */
808 string s = ChangeExtension (buffer->fileName(), ".txt");
811 if (!AskOverwrite(buffer, s))
814 buffer->writeFileAscii(s, lyxrc.ascii_linelen);
816 ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s));
820 void MenuPrint(Buffer * buffer)
826 string input_file = OnlyFilename(ChangeExtension(buffer->fileName(),
827 lyxrc.print_file_extension));
828 fl_set_input(fd_form_print->input_file, input_file.c_str());
830 if (fd_form_print->form_print->visible) {
831 fl_raise_form(fd_form_print->form_print);
834 fl_show_form(fd_form_print->form_print,
835 FL_PLACE_MOUSE, FL_FULLBORDER,
841 void MenuMakeHTML(Buffer * buffer)
843 // First, create LaTeX file
844 MenuMakeLaTeX(buffer);
846 // And now, run the converter
847 string file = buffer->fileName();
848 Path path(OnlyPath(file));
849 // the tex file name has to be correct for
850 // latex, but the html file name can be
852 string result = ChangeExtension(file, ".html");
853 string infile = buffer->getLatexName(false);
854 string tmp = lyxrc.html_command;
855 tmp = subst(tmp, "$$FName", infile);
856 tmp = subst(tmp, "$$OutName", result);
858 int res = one.startscript(Systemcalls::System, tmp);
860 ShowMessage(buffer, _("Document exported as HTML to file `")
861 + MakeDisplayPath(result) +'\'');
863 ShowMessage(buffer, _("Unable to convert to HTML the file `")
864 + MakeDisplayPath(infile)
871 void MenuMakeHTML_LinuxDoc(Buffer * buffer)
873 // First, create LinuxDoc file
874 MenuMakeLinuxDoc(buffer);
876 // And now, run the converter
877 string file = buffer->fileName();
879 string result = ChangeExtension(file, ".html");
880 string infile = ChangeExtension(file, ".sgml");
881 string tmp = lyxrc.linuxdoc_to_html_command;
882 tmp = subst(tmp, "$$FName", infile);
883 tmp = subst(tmp, "$$OutName", result);
885 int res = one.startscript(Systemcalls::System, tmp);
887 ShowMessage(buffer,_("Document exported as HTML to file `")
888 + MakeDisplayPath(result) +'\'');
890 ShowMessage(buffer,_("Unable to convert to HTML the file `")
891 + MakeDisplayPath(infile)
897 void MenuMakeHTML_DocBook(Buffer * buffer)
899 // First, create LaTeX file
900 MenuMakeDocBook(buffer);
902 // And now, run the converter
903 string file = buffer->fileName();
904 string result = ChangeExtension(file, ".html");
905 string infile = ChangeExtension(file, ".sgml");
906 string tmp = lyxrc.docbook_to_html_command;
907 tmp = subst(tmp, "$$FName", infile);
908 tmp = subst(tmp, "$$OutName", result);
910 int res = one.startscript(Systemcalls::System, tmp);
912 ShowMessage(buffer,_("Document exported as HTML to file `")
913 + MakeDisplayPath(result) +'\'');
915 ShowMessage(buffer,_("Unable to convert to HTML the file `")
916 + MakeDisplayPath(infile)
923 void MenuExport(Buffer * buffer, string const & extyp)
926 if (extyp == "latex") {
927 // make sure that this buffer is not linuxdoc
928 MenuMakeLaTeX(buffer);
931 else if (extyp == "linuxdoc") {
932 // make sure that this buffer is not latex
933 MenuMakeLinuxDoc(buffer);
936 else if (extyp == "docbook") {
937 // make sure that this buffer is not latex or linuxdoc
938 MenuMakeDocBook(buffer);
941 else if (extyp == "dvi") {
942 // Run LaTeX as "Update dvi..." Bernhard.
943 // We want the dvi in the current directory. This
944 // is achieved by temporarily disabling use of
945 // temp directory. As a side-effect, we get
946 // *.log and *.aux files also. (Asger)
947 bool flag = lyxrc.use_tempdir;
948 lyxrc.use_tempdir = false;
949 MenuRunLaTeX(buffer);
950 lyxrc.use_tempdir = flag;
953 else if (extyp == "postscript") {
954 // Start Print-dialog. Not as good as dvi... Bernhard.
956 // Since the MenuPrint is a pop-up, we can't use
957 // the same trick as above. (Asger)
958 // MISSING: Move of ps-file :-(
959 // And MenuPrint should not be used for this at all...
962 else if (extyp == "ascii") {
963 MenuMakeAscii(buffer);
965 else if (extyp == "custom") {
969 else if (extyp == "html") {
970 MenuMakeHTML(buffer);
972 // HTML from linuxdoc
973 else if (extyp == "html-linuxdoc") {
974 MenuMakeHTML_LinuxDoc(buffer);
977 else if (extyp == "html-docbook") {
978 MenuMakeHTML_DocBook(buffer);
981 ShowMessage(buffer, _("Unknown export type: ") + extyp);
988 lyxerr.debug() << "Running QuitLyX." << endl;
990 if (!bufferlist.QwriteAll())
993 lastfiles->writeFile(lyxrc.lastfiles);
995 // Set a flag that we do quitting from the program,
996 // so no refreshes are necessary.
999 // close buffers first
1000 bufferlist.closeAll();
1002 // do any other cleanup procedures now
1003 lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
1005 DestroyLyXTmpDir(system_tempdir);
1012 void AutoSave(BufferView * bv)
1013 // should probably be moved into BufferList (Lgb)
1014 // Perfect target for a thread...
1016 if (!bv->available())
1019 if (bv->buffer()->isBakClean()
1020 || bv->buffer()->isReadonly()) {
1021 // We don't save now, but we'll try again later
1022 bv->owner()->resetAutosaveTimer();
1026 bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
1028 // create autosave filename
1029 string fname = OnlyPath(bv->buffer()->fileName());
1031 fname += OnlyFilename(bv->buffer()->fileName());
1034 // tmp_ret will be located (usually) in /tmp
1035 // will that be a problem?
1036 string tmp_ret = tmpnam(0);
1038 pid_t pid = fork(); // If you want to debug the autosave
1039 // you should set pid to -1, and comment out the
1041 if (pid == 0 || pid == -1) {
1042 // pid = -1 signifies that lyx was unable
1043 // to fork. But we will do the save
1045 bool failed = false;
1046 if (!tmp_ret.empty()) {
1047 bv->buffer()->writeFile(tmp_ret, 1);
1048 // assume successful write of tmp_ret
1049 if (rename(tmp_ret.c_str(), fname.c_str()) == -1) {
1051 // most likely couldn't move between filesystems
1052 // unless write of tmp_ret failed
1053 // so remove tmp file (if it exists)
1054 remove(tmp_ret.c_str());
1061 // failed to write/rename tmp_ret so try writing direct
1062 if (!bv->buffer()->writeFile(fname, 1)) {
1063 // It is dangerous to do this in the child,
1064 // but safe in the parent, so...
1066 bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
1069 if (pid == 0) { // we are the child so...
1074 bv->buffer()->markBakClean();
1075 bv->owner()->resetAutosaveTimer();
1080 // Copyright CHT Software Service GmbH
1083 // create new file with template
1086 Buffer * NewLyxFile(string const & filename)
1088 // Split argument by :
1090 string tmpname = split(filename, name, ':');
1091 #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
1092 if (name.length() == 1
1093 && isalpha(static_cast<unsigned char>(name[0]))
1094 && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
1096 name += token(tmpname, ':', 0);
1097 tmpname = split(tmpname, ':');
1100 lyxerr.debug() << "Arg is " << filename
1101 << "\nName is " << name
1102 << "\nTemplate is " << tmpname << endl;
1104 // find a free buffer
1105 Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
1107 lastfiles->newFile(tmpbuf->fileName());
1112 // Insert ascii file (if filename is empty, prompt for one)
1113 void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
1118 if (!bv->available()) return;
1120 if (fname.empty()) {
1122 fname = fileDlg.Select(_("File to Insert"),
1123 bv->owner()->buffer()->filepath,
1126 if (fname.empty()) return;
1131 if (!fi.readable()) {
1132 WriteFSAlert(_("Error! Specified file is unreadable: "),
1133 MakeDisplayPath(fname, 50));
1137 ifstream ifs(fname.c_str());
1139 WriteFSAlert(_("Error! Cannot open specified file: "),
1140 MakeDisplayPath(fname, 50));
1144 ifs.unsetf(ios::skipws);
1145 istream_iterator<char> ii(ifs);
1146 istream_iterator<char> end;
1147 //string tmpstr(ii, end); // yet a reason for using std::string
1148 // alternate approach to get the file into a string:
1150 copy(ii, end, back_inserter(tmpstr));
1151 // insert the string
1152 current_view->hideCursor();
1154 // clear the selection
1157 bv->text->InsertStringA(tmpstr);
1159 bv->text->InsertStringB(tmpstr);
1164 void MenuShowTableOfContents()
1166 static int ow = -1, oh;
1169 if (fd_form_toc->form_toc->visible) {
1170 fl_raise_form(fd_form_toc->form_toc);
1172 fl_show_form(fd_form_toc->form_toc,
1173 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1174 _("Table Of Contents"));
1176 ow = fd_form_toc->form_toc->w;
1177 oh = fd_form_toc->form_toc->h;
1179 fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
1184 void MenuInsertLabel(char const * arg)
1187 ProhibitInput(current_view);
1188 if (label.empty()) {
1190 result = askForText(_("Enter new label to insert:"));
1192 label = frontStrip(strip(result.second));
1195 if (!label.empty()) {
1196 InsetLabel * new_inset = new InsetLabel;
1197 new_inset->setContents(label);
1198 current_view->insertInset(new_inset);
1200 AllowInput(current_view);
1204 void MenuInsertRef()
1206 static int ow = -1, oh;
1209 if (fd_form_ref->form_ref->visible) {
1210 fl_raise_form(fd_form_ref->form_ref);
1212 fl_show_form(fd_form_ref->form_ref,
1213 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1214 _("Insert Reference"));
1216 ow = fd_form_ref->form_ref->w;
1217 oh = fd_form_ref->form_ref->h;
1219 fl_set_form_minsize(fd_form_ref->form_ref, ow, oh);
1224 void MenuPasteSelection(char at)
1226 if (!current_view->available())
1231 Atom data_prop = XInternAtom(fl_display,
1234 if (data_prop == None)
1236 XConvertSelection(fl_display,
1237 XA_PRIMARY, XA_STRING, data_prop,
1238 current_view->owner()->getForm()->window, 0);
1245 // candidate for move to LyXView
1246 // This is only used in toolbar.C
1247 void LayoutsCB(int sel, void *)
1249 string tmp = tostr(sel);
1250 current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
1256 * SGML Linuxdoc support:
1257 * (flag == 0) make TeX output
1258 * (flag == 1) make dvi output
1260 int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
1267 /* generate a path-less extension name */
1268 string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
1269 string path = OnlyPath (filename);
1270 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
1271 path = bv->buffer()->tmppath;
1275 if (!bv->available())
1277 bv->buffer()->makeLinuxDocFile(name, 0);
1279 // CHECK remove this once we have a proper geometry class
1281 BufferParams::PAPER_SIZE ps =
1282 static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
1284 case BufferParams::PAPER_A4PAPER:
1285 add_flags = "-p a4";
1287 case BufferParams::PAPER_USLETTER:
1288 add_flags = "-p letter";
1290 default: /* nothing to be done yet ;-) */ break;
1297 case 0: /* TeX output asked */
1298 bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
1299 s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name;
1300 if (one.startscript(Systemcalls::System, s2))
1303 case 1: /* dvi output asked */
1304 bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
1305 s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
1306 if (one.startscript(Systemcalls::System, s2)) {
1309 bv->buffer()->markDviClean();
1311 default: /* unknown output */
1317 bv->buffer()->redraw();
1323 * SGML DocBook support:
1324 * (flag == 1) make dvi output
1326 int RunDocBook(int flag, string const & filename)
1328 /* generate a path-less extension name */
1329 string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
1330 string path = OnlyPath (filename);
1331 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
1332 path = current_view->buffer()->tmppath;
1336 if (!current_view->available())
1339 current_view->buffer()->makeDocBookFile(name, 0);
1341 // Shall this code go or should it stay? (Lgb)
1342 // This code is a placeholder for future implementation. (Jose')
1343 // string add_flags;
1344 // LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize;
1346 // case BufferParams::PAPER_A4PAPER: add_flags = "-p a4"; break;
1347 // case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break;
1348 // default: /* nothing to be done yet ;-) */ break;
1350 ProhibitInput(current_view);
1355 case 1: /* dvi output asked */
1357 current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file..."));
1358 string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
1359 if (one.startscript(Systemcalls::System, s2)) {
1362 current_view->buffer()->markDviClean();
1365 default: /* unknown output */
1369 AllowInput(current_view);
1371 current_view->buffer()->redraw();
1376 void MenuLayoutCharacter()
1378 static int ow = -1, oh;
1380 if (fd_form_character->form_character->visible) {
1381 fl_raise_form(fd_form_character->form_character);
1383 fl_show_form(fd_form_character->form_character,
1384 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
1385 _("Character Style"));
1387 ow = fd_form_character->form_character->w;
1388 oh = fd_form_character->form_character->h;
1390 fl_set_form_minsize(fd_form_character->form_character, ow, oh);
1396 void DeactivateParagraphButtons ()
1398 fl_deactivate_object (fd_form_paragraph->button_ok);
1399 fl_deactivate_object (fd_form_paragraph->button_apply);
1400 fl_set_object_lcol (fd_form_paragraph->button_ok, FL_INACTIVE);
1401 fl_set_object_lcol (fd_form_paragraph->button_apply, FL_INACTIVE);
1406 void ActivateParagraphButtons ()
1408 fl_activate_object (fd_form_paragraph->button_ok);
1409 fl_activate_object (fd_form_paragraph->button_apply);
1410 fl_set_object_lcol (fd_form_paragraph->button_ok, FL_BLACK);
1411 fl_set_object_lcol (fd_form_paragraph->button_apply, FL_BLACK);
1416 void DisableParagraphLayout ()
1418 DeactivateParagraphButtons();
1419 fl_deactivate_object (fd_form_paragraph->input_labelwidth);
1420 fl_deactivate_object (fd_form_paragraph->check_lines_top);
1421 fl_deactivate_object (fd_form_paragraph->check_lines_bottom);
1422 fl_deactivate_object (fd_form_paragraph->check_pagebreaks_top);
1423 fl_deactivate_object (fd_form_paragraph->check_pagebreaks_bottom);
1424 fl_deactivate_object (fd_form_paragraph->check_noindent);
1425 fl_deactivate_object (fd_form_paragraph->group_radio_alignment);
1426 fl_deactivate_object (fd_form_paragraph->radio_align_right);
1427 fl_deactivate_object (fd_form_paragraph->radio_align_left);
1428 fl_deactivate_object (fd_form_paragraph->radio_align_block);
1429 fl_deactivate_object (fd_form_paragraph->radio_align_center);
1430 fl_deactivate_object (fd_form_paragraph->input_space_above);
1431 fl_deactivate_object (fd_form_paragraph->input_space_below);
1432 fl_deactivate_object (fd_form_paragraph->choice_space_above);
1433 fl_deactivate_object (fd_form_paragraph->choice_space_below);
1434 fl_deactivate_object (fd_form_paragraph->check_space_above);
1435 fl_deactivate_object (fd_form_paragraph->check_space_below);
1440 void EnableParagraphLayout ()
1442 ActivateParagraphButtons();
1443 fl_activate_object (fd_form_paragraph->input_labelwidth);
1444 fl_activate_object (fd_form_paragraph->check_lines_top);
1445 fl_activate_object (fd_form_paragraph->check_lines_bottom);
1446 fl_activate_object (fd_form_paragraph->check_pagebreaks_top);
1447 fl_activate_object (fd_form_paragraph->check_pagebreaks_bottom);
1448 fl_activate_object (fd_form_paragraph->check_noindent);
1449 fl_activate_object (fd_form_paragraph->group_radio_alignment);
1450 fl_activate_object (fd_form_paragraph->radio_align_right);
1451 fl_activate_object (fd_form_paragraph->radio_align_left);
1452 fl_activate_object (fd_form_paragraph->radio_align_block);
1453 fl_activate_object (fd_form_paragraph->radio_align_center);
1454 fl_activate_object (fd_form_paragraph->input_space_above);
1455 fl_activate_object (fd_form_paragraph->input_space_below);
1456 fl_activate_object (fd_form_paragraph->choice_space_above);
1457 fl_activate_object (fd_form_paragraph->choice_space_below);
1458 fl_activate_object (fd_form_paragraph->check_space_above);
1459 fl_activate_object (fd_form_paragraph->check_space_below);
1463 bool UpdateLayoutParagraph()
1465 if (!current_view->available()) {
1466 if (fd_form_paragraph->form_paragraph->visible)
1467 fl_hide_form(fd_form_paragraph->form_paragraph);
1471 Buffer * buf = current_view->buffer();
1473 fl_set_input(fd_form_paragraph->input_labelwidth,
1474 current_view->text->cursor.par->GetLabelWidthString().c_str());
1475 fl_set_button(fd_form_paragraph->radio_align_right, 0);
1476 fl_set_button(fd_form_paragraph->radio_align_left, 0);
1477 fl_set_button(fd_form_paragraph->radio_align_center, 0);
1478 fl_set_button(fd_form_paragraph->radio_align_block, 0);
1480 int align = current_view->text->cursor.par->GetAlign();
1481 if (align == LYX_ALIGN_LAYOUT)
1482 align = textclasslist.Style(buf->params.textclass,
1483 current_view->text->cursor.par->GetLayout()).align;
1486 case LYX_ALIGN_RIGHT:
1487 fl_set_button(fd_form_paragraph->radio_align_right, 1);
1489 case LYX_ALIGN_LEFT:
1490 fl_set_button(fd_form_paragraph->radio_align_left, 1);
1492 case LYX_ALIGN_CENTER:
1493 fl_set_button(fd_form_paragraph->radio_align_center, 1);
1496 fl_set_button(fd_form_paragraph->radio_align_block, 1);
1500 fl_set_button(fd_form_paragraph->check_lines_top,
1501 current_view->text->cursor.par->FirstPhysicalPar()->line_top);
1502 fl_set_button(fd_form_paragraph->check_lines_bottom,
1503 current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
1504 fl_set_button(fd_form_paragraph->check_pagebreaks_top,
1505 current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
1506 fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
1507 current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
1508 fl_set_button(fd_form_paragraph->check_noindent,
1509 current_view->text->cursor.par->FirstPhysicalPar()->noindent);
1510 fl_set_input (fd_form_paragraph->input_space_above, "");
1512 switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
1514 fl_set_choice (fd_form_paragraph->choice_space_above, 1);
1516 case VSpace::DEFSKIP:
1517 fl_set_choice (fd_form_paragraph->choice_space_above, 2);
1519 case VSpace::SMALLSKIP:
1520 fl_set_choice (fd_form_paragraph->choice_space_above, 3);
1522 case VSpace::MEDSKIP:
1523 fl_set_choice (fd_form_paragraph->choice_space_above, 4);
1525 case VSpace::BIGSKIP:
1526 fl_set_choice (fd_form_paragraph->choice_space_above, 5);
1529 fl_set_choice (fd_form_paragraph->choice_space_above, 6);
1531 case VSpace::LENGTH:
1532 fl_set_choice (fd_form_paragraph->choice_space_above, 7);
1533 fl_set_input (fd_form_paragraph->input_space_above,
1534 current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
1537 fl_set_button (fd_form_paragraph->check_space_above,
1538 current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
1539 fl_set_input (fd_form_paragraph->input_space_below, "");
1540 switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
1542 fl_set_choice (fd_form_paragraph->choice_space_below,
1545 case VSpace::DEFSKIP:
1546 fl_set_choice (fd_form_paragraph->choice_space_below,
1549 case VSpace::SMALLSKIP:
1550 fl_set_choice (fd_form_paragraph->choice_space_below,
1553 case VSpace::MEDSKIP:
1554 fl_set_choice (fd_form_paragraph->choice_space_below,
1557 case VSpace::BIGSKIP:
1558 fl_set_choice (fd_form_paragraph->choice_space_below,
1562 fl_set_choice (fd_form_paragraph->choice_space_below,
1565 case VSpace::LENGTH:
1566 fl_set_choice (fd_form_paragraph->choice_space_below,
1568 fl_set_input (fd_form_paragraph->input_space_below,
1569 current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
1572 fl_set_button (fd_form_paragraph->check_space_below,
1573 current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
1575 fl_set_button(fd_form_paragraph->check_noindent,
1576 current_view->text->cursor.par->FirstPhysicalPar()->noindent);
1578 if (current_view->buffer()->isReadonly()) {
1579 DisableParagraphLayout();
1581 EnableParagraphLayout();
1587 void MenuLayoutParagraph()
1589 if (UpdateLayoutParagraph()) {
1590 if (fd_form_paragraph->form_paragraph->visible) {
1591 fl_raise_form(fd_form_paragraph->form_paragraph);
1593 fl_show_form(fd_form_paragraph->form_paragraph,
1594 FL_PLACE_MOUSE, FL_FULLBORDER,
1595 _("Paragraph Environment"));
1602 void DeactivateDocumentButtons ()
1604 fl_deactivate_object (fd_form_document->button_ok);
1605 fl_deactivate_object (fd_form_document->button_apply);
1606 fl_set_object_lcol (fd_form_document->button_ok, FL_INACTIVE);
1607 fl_set_object_lcol (fd_form_document->button_apply, FL_INACTIVE);
1612 void ActivateDocumentButtons ()
1614 fl_activate_object (fd_form_document->button_ok);
1615 fl_activate_object (fd_form_document->button_apply);
1616 fl_set_object_lcol (fd_form_document->button_ok, FL_BLACK);
1617 fl_set_object_lcol (fd_form_document->button_apply, FL_BLACK);
1622 void DisableDocumentLayout ()
1624 DeactivateDocumentButtons ();
1625 fl_deactivate_object (fd_form_document->group_radio_separation);
1626 fl_deactivate_object (fd_form_document->radio_indent);
1627 fl_deactivate_object (fd_form_document->radio_skip);
1628 fl_deactivate_object (fd_form_document->choice_class);
1629 fl_deactivate_object (fd_form_document->choice_pagestyle);
1630 fl_deactivate_object (fd_form_document->choice_fonts);
1631 fl_deactivate_object (fd_form_document->choice_fontsize);
1632 fl_deactivate_object (fd_form_document->input_float_placement);
1633 fl_deactivate_object (fd_form_document->choice_postscript_driver);
1634 fl_deactivate_object (fd_form_document->choice_inputenc);
1635 fl_deactivate_object (fd_form_document->group_radio_sides);
1636 fl_deactivate_object (fd_form_document->radio_sides_one);
1637 fl_deactivate_object (fd_form_document->radio_sides_two);
1638 fl_deactivate_object (fd_form_document->group_radio_columns);
1639 fl_deactivate_object (fd_form_document->radio_columns_one);
1640 fl_deactivate_object (fd_form_document->radio_columns_two);
1641 fl_deactivate_object (fd_form_document->input_extra);
1642 fl_deactivate_object (fd_form_document->choice_language);
1643 combo_language->deactivate();
1644 fl_deactivate_object (fd_form_document->input_default_skip);
1645 fl_deactivate_object (fd_form_document->choice_default_skip);
1646 fl_deactivate_object (fd_form_document->slider_secnumdepth);
1647 fl_deactivate_object (fd_form_document->slider_tocdepth);
1648 fl_deactivate_object (fd_form_document->choice_spacing);
1649 fl_deactivate_object (fd_form_document->input_spacing);
1650 fl_deactivate_object (fd_form_document->check_use_amsmath);
1655 void EnableDocumentLayout ()
1657 ActivateDocumentButtons ();
1658 fl_activate_object (fd_form_document->group_radio_separation);
1659 fl_activate_object (fd_form_document->radio_indent);
1660 fl_activate_object (fd_form_document->radio_skip);
1661 fl_activate_object (fd_form_document->choice_class);
1662 fl_activate_object (fd_form_document->choice_pagestyle);
1663 fl_activate_object (fd_form_document->choice_fonts);
1664 fl_activate_object (fd_form_document->choice_fontsize);
1665 fl_activate_object (fd_form_document->input_float_placement);
1666 fl_activate_object (fd_form_document->choice_postscript_driver);
1667 fl_activate_object (fd_form_document->choice_inputenc);
1668 fl_activate_object (fd_form_document->group_radio_sides);
1669 fl_activate_object (fd_form_document->radio_sides_one);
1670 fl_activate_object (fd_form_document->radio_sides_two);
1671 fl_activate_object (fd_form_document->group_radio_columns);
1672 fl_activate_object (fd_form_document->radio_columns_one);
1673 fl_activate_object (fd_form_document->radio_columns_two);
1674 fl_activate_object (fd_form_document->input_extra);
1675 fl_activate_object (fd_form_document->choice_language);
1676 combo_language->activate();
1677 fl_activate_object (fd_form_document->input_default_skip);
1678 fl_activate_object (fd_form_document->choice_default_skip);
1679 fl_activate_object (fd_form_document->slider_secnumdepth);
1680 fl_activate_object (fd_form_document->slider_tocdepth);
1681 fl_activate_object (fd_form_document->choice_spacing);
1682 fl_activate_object (fd_form_document->input_spacing);
1683 fl_activate_object (fd_form_document->check_use_amsmath);
1687 bool UpdateLayoutDocument(BufferParams * params)
1689 if (!current_view->available()) {
1690 if (fd_form_document->form_document->visible)
1691 fl_hide_form(fd_form_document->form_document);
1696 params = ¤t_view->buffer()->params;
1697 LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
1699 fl_set_choice_text(fd_form_document->choice_class,
1700 textclasslist.DescOfClass(params->textclass).c_str());
1701 combo_language->select_text(params->language.c_str());
1703 fl_set_choice_text(fd_form_document->choice_fonts,
1704 params->fonts.c_str());
1705 fl_set_choice_text(fd_form_document->choice_inputenc,
1706 params->inputenc.c_str());
1707 fl_set_choice_text(fd_form_document->choice_postscript_driver,
1708 params->graphicsDriver.c_str());
1710 // ale970405+lasgoutt970513
1711 fl_clear_choice(fd_form_document->choice_fontsize);
1712 fl_addto_choice(fd_form_document->choice_fontsize, "default");
1713 fl_addto_choice(fd_form_document->choice_fontsize,
1714 tclass.opt_fontsize().c_str());
1715 fl_set_choice(fd_form_document->choice_fontsize,
1716 tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
1718 // ale970405+lasgoutt970513
1719 fl_clear_choice(fd_form_document->choice_pagestyle);
1720 fl_addto_choice(fd_form_document->choice_pagestyle, "default");
1721 fl_addto_choice(fd_form_document->choice_pagestyle,
1722 tclass.opt_pagestyle().c_str());
1724 fl_set_choice(fd_form_document->choice_pagestyle,
1725 tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
1727 fl_set_button(fd_form_document->radio_indent, 0);
1728 fl_set_button(fd_form_document->radio_skip, 0);
1731 fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath);
1733 if (params->paragraph_separation == BufferParams::PARSEP_INDENT)
1734 fl_set_button(fd_form_document->radio_indent, 1);
1736 fl_set_button(fd_form_document->radio_skip, 1);
1738 switch (params->getDefSkip().kind()) {
1739 case VSpace::SMALLSKIP:
1740 fl_set_choice (fd_form_document->choice_default_skip, 1);
1742 case VSpace::MEDSKIP:
1743 fl_set_choice (fd_form_document->choice_default_skip, 2);
1745 case VSpace::BIGSKIP:
1746 fl_set_choice (fd_form_document->choice_default_skip, 3);
1748 case VSpace::LENGTH:
1749 fl_set_choice (fd_form_document->choice_default_skip, 4);
1750 fl_set_input (fd_form_document->input_default_skip,
1751 params->getDefSkip().asLyXCommand().c_str());
1754 fl_set_choice (fd_form_document->choice_default_skip, 2);
1758 fl_set_button(fd_form_document->radio_sides_one, 0);
1759 fl_set_button(fd_form_document->radio_sides_two, 0);
1761 switch (params->sides) {
1762 case LyXTextClass::OneSide:
1763 fl_set_button(fd_form_document->radio_sides_one, 1);
1765 case LyXTextClass::TwoSides:
1766 fl_set_button(fd_form_document->radio_sides_two, 1);
1770 fl_set_button(fd_form_document->radio_columns_one, 0);
1771 fl_set_button(fd_form_document->radio_columns_two, 0);
1773 if (params->columns == 2)
1774 fl_set_button(fd_form_document->radio_columns_two, 1);
1776 fl_set_button(fd_form_document->radio_columns_one, 1);
1778 fl_set_input(fd_form_document->input_spacing, "");
1779 switch (params->spacing.getSpace()) {
1780 case Spacing::Default: // nothing bad should happen with this
1781 case Spacing::Single:
1784 fl_set_choice(fd_form_document->choice_spacing, 1);
1787 case Spacing::Onehalf:
1790 fl_set_choice(fd_form_document->choice_spacing, 2);
1793 case Spacing::Double:
1796 fl_set_choice(fd_form_document->choice_spacing, 3);
1799 case Spacing::Other:
1801 fl_set_choice(fd_form_document->choice_spacing, 4);
1803 //sprintf(sval, "%g", params->spacing.getValue());
1805 std::ostringstream sval;
1806 sval << params->spacing.getValue(); // setw?
1807 fl_set_input(fd_form_document->input_spacing,
1808 sval.str().c_str());
1811 ostrstream sval(tval, 20);
1812 sval << params->spacing.getValue() << '\0'; // setw?
1813 fl_set_input(fd_form_document->input_spacing, sval.str());
1820 fl_set_counter_value(fd_form_document->slider_secnumdepth,
1821 params->secnumdepth);
1822 fl_set_counter_value(fd_form_document->slider_tocdepth,
1824 if (!params->float_placement.empty()) { // buffer local (Lgb)
1825 fl_set_input(fd_form_document->input_float_placement,
1826 params->float_placement.c_str());
1828 fl_set_input(fd_form_document->input_float_placement, "");
1830 if (!params->options.empty())
1831 fl_set_input(fd_form_document->input_extra,
1832 params->options.c_str());
1834 fl_set_input(fd_form_document->input_extra, "");
1836 if (current_view->buffer()->isSGML()) {
1837 // bullets not used in SGML derived documents
1838 fl_deactivate_object(fd_form_document->button_bullets);
1839 fl_set_object_lcol(fd_form_document->button_bullets,
1842 fl_activate_object(fd_form_document->button_bullets);
1843 fl_set_object_lcol(fd_form_document->button_bullets,
1847 if (current_view->buffer()->isReadonly()) {
1848 DisableDocumentLayout();
1850 EnableDocumentLayout();
1857 void MenuLayoutDocument()
1859 if (UpdateLayoutDocument()) {
1860 if (fd_form_document->form_document->visible) {
1861 fl_raise_form(fd_form_document->form_document);
1863 fl_show_form(fd_form_document->form_document,
1864 FL_PLACE_MOUSE, FL_FULLBORDER,
1865 _("Document Layout"));
1871 bool UpdateLayoutQuotes()
1874 if (!current_view->available()
1875 || current_view->buffer()->isReadonly())
1879 fl_set_choice(fd_form_quotes->choice_quotes_language,
1880 current_view->buffer()->params.quotes_language + 1);
1881 fl_set_button(fd_form_quotes->radio_single, 0);
1882 fl_set_button(fd_form_quotes->radio_double, 0);
1884 if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ)
1885 fl_set_button(fd_form_quotes->radio_single, 1);
1887 fl_set_button(fd_form_quotes->radio_double, 1);
1888 } else if (fd_form_quotes->form_quotes->visible) {
1889 fl_hide_form(fd_form_quotes->form_quotes);
1895 void MenuLayoutQuotes()
1897 if (UpdateLayoutQuotes()) {
1898 if (fd_form_quotes->form_quotes->visible) {
1899 fl_raise_form(fd_form_quotes->form_quotes);
1901 fl_show_form(fd_form_quotes->form_quotes,
1902 FL_PLACE_MOUSE, FL_FULLBORDER,
1909 bool UpdateLayoutPreamble()
1912 if (!current_view->available())
1916 fl_set_input(fd_form_preamble->input_preamble,
1917 current_view->buffer()->params.preamble.c_str());
1919 if (current_view->buffer()->isReadonly()) {
1920 fl_deactivate_object(fd_form_preamble->input_preamble);
1921 fl_deactivate_object(fd_form_preamble->button_ok);
1922 fl_deactivate_object(fd_form_preamble->button_apply);
1923 fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
1924 fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
1927 fl_activate_object(fd_form_preamble->input_preamble);
1928 fl_activate_object(fd_form_preamble->button_ok);
1929 fl_activate_object(fd_form_preamble->button_apply);
1930 fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
1931 fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
1933 } else if (fd_form_preamble->form_preamble->visible) {
1934 fl_hide_form(fd_form_preamble->form_preamble);
1940 void MenuLayoutPreamble()
1942 static int ow = -1, oh;
1944 if (UpdateLayoutPreamble()) {
1945 if (fd_form_preamble->form_preamble->visible) {
1946 fl_raise_form(fd_form_preamble->form_preamble);
1948 fl_show_form(fd_form_preamble->form_preamble,
1949 FL_PLACE_MOUSE | FL_FREE_SIZE,
1951 _("LaTeX Preamble"));
1953 ow = fd_form_preamble->form_preamble->w;
1954 oh = fd_form_preamble->form_preamble->h;
1956 fl_set_form_minsize(fd_form_preamble->form_preamble,
1963 void MenuLayoutSave()
1965 if (!current_view->available())
1968 if (AskQuestion(_("Do you want to save the current settings"),
1969 _("for Character, Document, Paper and Quotes"),
1970 _("as default for new documents?")))
1971 current_view->buffer()->saveParamsAsDefaults();
1975 // This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
1976 // Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
1977 LyXFont UserFreeFont()
1979 LyXFont font(LyXFont::ALL_IGNORE);
1981 int pos = fl_get_choice(fd_form_character->choice_family);
1983 case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
1984 case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
1985 case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
1986 case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
1987 case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
1990 pos = fl_get_choice(fd_form_character->choice_series);
1992 case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
1993 case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
1994 case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
1995 case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
1998 pos = fl_get_choice(fd_form_character->choice_shape);
2000 case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
2001 case 2: font.setShape(LyXFont::UP_SHAPE); break;
2002 case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
2003 case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
2004 case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
2005 case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
2008 pos = fl_get_choice(fd_form_character->choice_size);
2010 case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
2011 case 2: font.setSize(LyXFont::SIZE_TINY); break;
2012 case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
2013 case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
2014 case 5: font.setSize(LyXFont::SIZE_SMALL); break;
2015 case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
2016 case 7: font.setSize(LyXFont::SIZE_LARGE); break;
2017 case 8: font.setSize(LyXFont::SIZE_LARGER); break;
2018 case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
2019 case 10: font.setSize(LyXFont::SIZE_HUGE); break;
2020 case 11: font.setSize(LyXFont::SIZE_HUGER); break;
2021 case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
2022 case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
2023 case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
2026 pos = fl_get_choice(fd_form_character->choice_bar);
2028 case 1: font.setEmph(LyXFont::IGNORE);
2029 font.setUnderbar(LyXFont::IGNORE);
2030 font.setNoun(LyXFont::IGNORE);
2031 font.setLatex(LyXFont::IGNORE);
2033 case 2: font.setEmph(LyXFont::TOGGLE); break;
2034 case 3: font.setUnderbar(LyXFont::TOGGLE); break;
2035 case 4: font.setNoun(LyXFont::TOGGLE); break;
2036 case 5: font.setLatex(LyXFont::TOGGLE); break;
2037 case 6: font.setEmph(LyXFont::INHERIT);
2038 font.setUnderbar(LyXFont::INHERIT);
2039 font.setNoun(LyXFont::INHERIT);
2040 font.setLatex(LyXFont::INHERIT);
2044 pos = fl_get_choice(fd_form_character->choice_color);
2046 case 1: font.setColor(LColor::ignore); break;
2047 case 2: font.setColor(LColor::none); break;
2048 case 3: font.setColor(LColor::black); break;
2049 case 4: font.setColor(LColor::white); break;
2050 case 5: font.setColor(LColor::red); break;
2051 case 6: font.setColor(LColor::green); break;
2052 case 7: font.setColor(LColor::blue); break;
2053 case 8: font.setColor(LColor::cyan); break;
2054 case 9: font.setColor(LColor::magenta); break;
2055 case 10: font.setColor(LColor::yellow); break;
2056 case 11: font.setColor(LColor::inherit); break;
2059 string language = combo_language2->getline();
2060 Languages::iterator lit = languages.find(language);
2061 if (lit != languages.end())
2062 font.setLanguage(&(*lit).second);
2064 font.setLanguage(ignore_language);
2073 /* callbacks for form form_title */
2074 extern "C" void TimerCB(FL_OBJECT *, long)
2076 // only if the form still exists
2077 if (lyxrc.show_banner && fd_form_title->form_title != 0) {
2078 if (fd_form_title->form_title->visible) {
2079 fl_hide_form(fd_form_title->form_title);
2081 fl_free_form(fd_form_title->form_title);
2082 fd_form_title->form_title = 0;
2087 /* callbacks for form form_paragraph */
2089 extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long )
2091 // "Synchronize" the choices and input fields, making it
2092 // impossible to commit senseless data.
2094 FD_form_paragraph const * fp = fd_form_paragraph;
2096 if (obj == fp->choice_space_above) {
2097 if (fl_get_choice (fp->choice_space_above) != 7) {
2098 fl_set_input (fp->input_space_above, "");
2099 ActivateParagraphButtons();
2101 } else if (obj == fp->choice_space_below) {
2102 if (fl_get_choice (fp->choice_space_below) != 7) {
2103 fl_set_input (fp->input_space_below, "");
2104 ActivateParagraphButtons();
2106 } else if (obj == fp->input_space_above) {
2107 string input = fl_get_input (fp->input_space_above);
2109 if (input.empty()) {
2110 fl_set_choice (fp->choice_space_above, 1);
2111 ActivateParagraphButtons();
2113 else if (isValidGlueLength (input)) {
2114 fl_set_choice (fp->choice_space_above, 7);
2115 ActivateParagraphButtons();
2118 fl_set_choice (fp->choice_space_above, 7);
2119 DeactivateParagraphButtons();
2121 } else if (obj == fp->input_space_below) {
2122 string input = fl_get_input (fp->input_space_below);
2124 if (input.empty()) {
2125 fl_set_choice (fp->choice_space_below, 1);
2126 ActivateParagraphButtons();
2128 else if (isValidGlueLength (input)) {
2129 fl_set_choice (fp->choice_space_below, 7);
2130 ActivateParagraphButtons();
2133 fl_set_choice (fp->choice_space_below, 7);
2134 DeactivateParagraphButtons();
2140 extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
2142 if (!current_view->available())
2145 VSpace space_top, space_bottom;
2147 string labelwidthstring;
2150 // If a vspace kind is "Length" but there's no text in
2151 // the input field, reset the kind to "None".
2152 if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
2153 && !*(fl_get_input (fd_form_paragraph->input_space_above))) {
2154 fl_set_choice (fd_form_paragraph->choice_space_above, 1);
2156 if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7
2157 && !*(fl_get_input (fd_form_paragraph->input_space_below))) {
2158 fl_set_choice (fd_form_paragraph->choice_space_below, 1);
2161 bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
2162 bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
2163 bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
2164 bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
2165 switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
2166 case 1: space_top = VSpace(VSpace::NONE); break;
2167 case 2: space_top = VSpace(VSpace::DEFSKIP); break;
2168 case 3: space_top = VSpace(VSpace::SMALLSKIP); break;
2169 case 4: space_top = VSpace(VSpace::MEDSKIP); break;
2170 case 5: space_top = VSpace(VSpace::BIGSKIP); break;
2171 case 6: space_top = VSpace(VSpace::VFILL); break;
2172 case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break;
2174 if (fl_get_button (fd_form_paragraph->check_space_above))
2175 space_top.setKeep (true);
2176 switch (fl_get_choice (fd_form_paragraph->choice_space_below)) {
2177 case 1: space_bottom = VSpace(VSpace::NONE); break;
2178 case 2: space_bottom = VSpace(VSpace::DEFSKIP); break;
2179 case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break;
2180 case 4: space_bottom = VSpace(VSpace::MEDSKIP); break;
2181 case 5: space_bottom = VSpace(VSpace::BIGSKIP); break;
2182 case 6: space_bottom = VSpace(VSpace::VFILL); break;
2183 case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break;
2185 if (fl_get_button (fd_form_paragraph->check_space_below))
2186 space_bottom.setKeep (true);
2188 if (fl_get_button(fd_form_paragraph->radio_align_left))
2189 align = LYX_ALIGN_LEFT;
2190 else if (fl_get_button(fd_form_paragraph->radio_align_right))
2191 align = LYX_ALIGN_RIGHT;
2192 else if (fl_get_button(fd_form_paragraph->radio_align_center))
2193 align = LYX_ALIGN_CENTER;
2195 align = LYX_ALIGN_BLOCK;
2197 labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
2198 noindent = fl_get_button(fd_form_paragraph->check_noindent);
2200 current_view->text->SetParagraph(line_top,
2209 current_view->update(1);
2210 current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
2214 extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
2216 fl_hide_form(fd_form_paragraph->form_paragraph);
2220 extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
2222 ParagraphApplyCB(ob, data);
2223 ParagraphCancelCB(ob, data);
2227 /* callbacks for form form_character */
2229 extern "C" void CharacterApplyCB(FL_OBJECT *, long)
2231 // we set toggleall locally here, since it should be true for
2232 // all other uses of ToggleAndShow() (JMarc)
2233 toggleall = fl_get_button(fd_form_character->check_toggle_all);
2234 ToggleAndShow(current_view, UserFreeFont());
2235 current_view->setState();
2240 extern "C" void CharacterCloseCB(FL_OBJECT *, long)
2242 fl_hide_form(fd_form_character->form_character);
2246 extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
2248 CharacterApplyCB(ob, data);
2249 CharacterCloseCB(ob, data);
2253 /* callbacks for form form_document */
2255 void UpdateDocumentButtons(BufferParams const & params)
2257 fl_set_choice(fd_form_document->choice_pagestyle, 1);
2259 switch (params.sides) {
2260 case LyXTextClass::OneSide:
2261 fl_set_button(fd_form_document->radio_sides_one, 1);
2263 case LyXTextClass::TwoSides:
2264 fl_set_button(fd_form_document->radio_sides_two, 1);
2268 if (params.columns == 2)
2269 fl_set_button(fd_form_document->radio_columns_two, 1);
2271 fl_set_button(fd_form_document->radio_columns_one, 1);
2273 fl_set_input(fd_form_document->input_extra, params.options.c_str());
2274 fl_set_counter_value(fd_form_document->slider_secnumdepth,
2275 params.secnumdepth);
2276 fl_set_counter_value(fd_form_document->slider_tocdepth,
2281 extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
2283 ProhibitInput(current_view);
2284 if (textclasslist.Load(fl_get_choice(ob)-1)) {
2285 if (AskQuestion(_("Should I set some parameters to"),
2286 fl_get_choice_text(ob),
2287 _("the defaults of this document class?"))) {
2288 BufferParams params = BufferParams();
2289 params.textclass = fl_get_choice(ob)-1;
2290 params.useClassDefaults();
2291 UpdateLayoutDocument(¶ms);
2292 UpdateDocumentButtons(params);
2295 // unable to load new style
2296 WriteAlert(_("Conversion Errors!"),
2297 _("Unable to switch to new document class."),
2298 _("Reverting to original document class."));
2299 fl_set_choice(fd_form_document->choice_class,
2300 current_view->buffer()->params.textclass + 1);
2302 AllowInput(current_view);
2306 extern "C" void DocumentDefskipCB(FL_OBJECT * obj, long)
2308 // "Synchronize" the choice and the input field, so that it
2309 // is impossible to commit senseless data.
2310 FD_form_document const * fd = fd_form_document;
2312 if (obj == fd->choice_default_skip) {
2313 if (fl_get_choice (fd->choice_default_skip) != 4) {
2314 fl_set_input (fd->input_default_skip, "");
2315 ActivateDocumentButtons();
2317 } else if (obj == fd->input_default_skip) {
2319 char const * input = fl_get_input (fd->input_default_skip);
2322 fl_set_choice (fd->choice_default_skip, 2);
2323 ActivateDocumentButtons();
2324 } else if (isValidGlueLength (input)) {
2325 fl_set_choice (fd->choice_default_skip, 4);
2326 ActivateDocumentButtons();
2328 fl_set_choice (fd->choice_default_skip, 4);
2329 DeactivateDocumentButtons();
2335 extern "C" void DocumentSpacingCB(FL_OBJECT * obj, long)
2337 // "Synchronize" the choice and the input field, so that it
2338 // is impossible to commit senseless data.
2339 FD_form_document const * fd = fd_form_document;
2341 if (obj == fd->choice_spacing
2342 && fl_get_choice (fd->choice_spacing) != 4) {
2343 fl_set_input(fd->input_spacing, "");
2344 } else if (obj == fd->input_spacing) {
2346 const char* input = fl_get_input (fd->input_spacing);
2349 fl_set_choice (fd->choice_spacing, 1);
2351 fl_set_choice (fd->choice_spacing, 4);
2357 extern "C" void DocumentApplyCB(FL_OBJECT *, long)
2360 BufferParams * params = &(current_view->buffer()->params);
2362 Language const * old_language = params->language_info;
2363 params->language = combo_language->getline();
2364 Languages::iterator lit = languages.find(params->language);
2366 Language const * new_language;
2367 if (lit != languages.end())
2368 new_language = &(*lit).second;
2370 new_language = default_language;
2372 if (current_view->available()) {
2373 if (old_language != new_language &&
2374 old_language->RightToLeft == new_language->RightToLeft &&
2375 ! current_view->buffer()->isMultiLingual() ) {
2376 current_view->buffer()->ChangeLanguage(old_language,
2378 current_view->buffer()->redraw();
2381 params->language_info = new_language;
2383 // If default skip is a "Length" but there's no text in the
2384 // input field, reset the kind to "Medskip", which is the default.
2385 if (fl_get_choice (fd_form_document->choice_default_skip) == 4
2386 && !*(fl_get_input (fd_form_document->input_default_skip))) {
2387 fl_set_choice (fd_form_document->choice_default_skip, 2);
2390 /* this shouldn't be done automatically IMO. For example I write german
2391 * documents with an american keyboard very often. Matthias */
2393 /* ChangeKeymap(buffer->parameters.language, TRUE, false,
2394 fl_get_choice(fd_form_document->choice_language)); */
2396 fl_get_choice_text(fd_form_document->choice_fonts);
2398 fl_get_choice_text(fd_form_document->choice_inputenc);
2400 fl_get_choice_text(fd_form_document->choice_fontsize);
2402 fl_get_choice_text(fd_form_document->choice_pagestyle);
2403 params->graphicsDriver =
2404 fl_get_choice_text(fd_form_document->choice_postscript_driver);
2405 params->use_amsmath =
2406 fl_get_button(fd_form_document->check_use_amsmath);
2408 if (!current_view->available())
2411 current_view->text->SetCursor(current_view->text->cursor.par,
2412 current_view->text->cursor.pos);
2413 current_view->setState();
2415 LyXTextClassList::ClassList::size_type new_class =
2416 fl_get_choice(fd_form_document->choice_class) - 1;
2418 if (params->textclass != new_class) {
2419 // try to load new_class
2420 if (textclasslist.Load(new_class)) {
2421 // successfully loaded
2423 current_view->owner()->getMiniBuffer()->
2424 Set(_("Converting document to new document class..."));
2426 int ret = cap.SwitchLayoutsBetweenClasses(
2427 current_view->buffer()->params.textclass,
2429 current_view->buffer()->paragraph);
2434 s = _("One paragraph couldn't be converted");
2437 s += _(" paragraphs couldn't be converted");
2439 WriteAlert(_("Conversion Errors!"), s,
2440 _("into chosen document class"));
2443 params->textclass = new_class;
2445 // problem changing class -- warn user and retain old style
2446 WriteAlert(_("Conversion Errors!"),
2447 _("Unable to switch to new document class."),
2448 _("Reverting to original document class."));
2449 fl_set_choice(fd_form_document->choice_class, params->textclass + 1);
2453 char tmpsep = params->paragraph_separation;
2454 if (fl_get_button(fd_form_document->radio_indent))
2455 params->paragraph_separation = BufferParams::PARSEP_INDENT;
2457 params->paragraph_separation = BufferParams::PARSEP_SKIP;
2458 if (tmpsep != params->paragraph_separation)
2461 VSpace tmpdefskip = params->getDefSkip();
2462 switch (fl_get_choice (fd_form_document->choice_default_skip)) {
2463 case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break;
2464 case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
2465 case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break;
2466 case 4: params->setDefSkip(
2467 VSpace (LyXGlueLength (fl_get_input
2468 (fd_form_document->input_default_skip))));
2470 // DocumentDefskipCB assures that this never happens
2471 default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
2473 if (!(tmpdefskip == params->getDefSkip()))
2476 if (fl_get_button(fd_form_document->radio_columns_two))
2477 params->columns = 2;
2479 params->columns = 1;
2480 if (fl_get_button(fd_form_document->radio_sides_two))
2481 params->sides = LyXTextClass::TwoSides;
2483 params->sides = LyXTextClass::OneSide;
2485 Spacing tmpSpacing = params->spacing;
2486 switch(fl_get_choice(fd_form_document->choice_spacing)) {
2488 lyxerr.debug() << "Spacing: SINGLE" << endl;
2489 params->spacing.set(Spacing::Single);
2492 lyxerr.debug() << "Spacing: ONEHALF" << endl;
2493 params->spacing.set(Spacing::Onehalf);
2496 lyxerr.debug() << "Spacing: DOUBLE" << endl;
2497 params->spacing.set(Spacing::Double);
2500 lyxerr.debug() << "Spacing: OTHER" << endl;
2501 params->spacing.set(Spacing::Other,
2502 fl_get_input(fd_form_document->input_spacing));
2505 if (tmpSpacing != params->spacing)
2508 signed char tmpchar =
2509 static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
2510 if (params->secnumdepth != tmpchar)
2512 params->secnumdepth = tmpchar;
2515 static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
2517 params->float_placement =
2518 fl_get_input(fd_form_document->input_float_placement);
2520 // More checking should be done to ensure the string doesn't have
2521 // spaces or illegal placement characters in it. (thornley)
2524 current_view->redoCurrentBuffer();
2526 current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
2527 current_view->buffer()->markDirty();
2530 fl_get_input(fd_form_document->input_extra);
2535 extern "C" void DocumentCancelCB(FL_OBJECT *, long)
2537 fl_hide_form(fd_form_document->form_document);
2541 extern "C" void DocumentOKCB(FL_OBJECT * ob, long data)
2543 DocumentCancelCB(ob, data);
2544 DocumentApplyCB(ob, data);
2548 extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
2551 // bullet callbacks etc. in bullet_panel.C -- ARRae
2555 /* callbacks for form form_quotes */
2557 extern "C" void QuotesApplyCB(FL_OBJECT *, long)
2559 if (!current_view->available())
2562 current_view->owner()->getMiniBuffer()->Set(_("Quotes type set"));
2563 InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
2564 switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
2566 lga = InsetQuotes::EnglishQ;
2569 lga = InsetQuotes::SwedishQ;
2572 lga = InsetQuotes::GermanQ;
2575 lga = InsetQuotes::PolishQ;
2578 lga = InsetQuotes::FrenchQ;
2581 lga = InsetQuotes::DanishQ;
2584 current_view->buffer()->params.quotes_language = lga;
2585 if (fl_get_button(fd_form_quotes->radio_single))
2586 current_view->buffer()->
2587 params.quotes_times = InsetQuotes::SingleQ;
2589 current_view->buffer()->
2590 params.quotes_times = InsetQuotes::DoubleQ;
2594 extern "C" void QuotesCancelCB(FL_OBJECT *, long)
2596 fl_hide_form(fd_form_quotes->form_quotes);
2600 extern "C" void QuotesOKCB(FL_OBJECT * ob, long data)
2602 QuotesApplyCB(ob, data);
2603 QuotesCancelCB(ob, data);
2608 /* callbacks for form form_preamble */
2610 extern "C" void PreambleCancelCB(FL_OBJECT *, long)
2612 fl_hide_form(fd_form_preamble->form_preamble);
2616 extern "C" void PreambleApplyCB(FL_OBJECT *, long)
2618 if (!current_view->available())
2621 current_view->buffer()->params.preamble =
2622 fl_get_input(fd_form_preamble->input_preamble);
2623 current_view->buffer()->markDirty();
2624 current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
2628 extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
2630 PreambleApplyCB(ob, data);
2631 PreambleCancelCB(ob, data);
2635 /* callbacks for form form_table */
2637 extern "C" void TableApplyCB(FL_OBJECT *, long)
2639 if (!current_view->available())
2642 // check for tables in tables
2643 if (current_view->text->cursor.par->table){
2644 WriteAlert(_("Impossible Operation!"),
2645 _("Cannot insert table in table."),
2650 current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
2652 int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
2653 int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
2656 current_view->hideCursor();
2657 current_view->beforeChange();
2658 current_view->update(-2);
2660 current_view->text->SetCursorParUndo();
2661 current_view->text->FreezeUndo();
2663 current_view->text->BreakParagraph();
2664 current_view->update(-1);
2666 if (current_view->text->cursor.par->Last()) {
2667 current_view->text->CursorLeft();
2669 current_view->text->BreakParagraph();
2670 current_view->update(-1);
2673 current_view->text->current_font.setLatex(LyXFont::OFF);
2674 //if (!fl_get_button(fd_form_table->check_latex)){
2675 // insert the new wysiwy table
2676 current_view->text->SetLayout(0); // standard layout
2677 if (current_view->text->cursor.par->footnoteflag ==
2678 LyXParagraph::NO_FOOTNOTE) {
2680 ->SetParagraph(0, 0,
2682 VSpace (0.3 * current_view->buffer()->
2683 params.spacing.getValue(),
2685 VSpace (0.3 * current_view->buffer()->
2686 params.spacing.getValue(),
2693 ->SetParagraph(0, 0,
2695 VSpace(VSpace::NONE),
2696 VSpace(VSpace::NONE),
2702 current_view->text->cursor.par->table =
2703 new LyXTable(xsize, ysize);
2705 Language const * lang =
2706 current_view->text->cursor.par->getParLanguage();
2707 LyXFont font(LyXFont::ALL_INHERIT, lang);
2708 for (int i = 0; i < xsize * ysize - 1; ++i) {
2709 current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
2710 current_view->text->cursor.par->SetFont(0, font);
2712 current_view->text->RedoParagraph();
2714 current_view->text->UnFreezeUndo();
2716 current_view->update(1);
2717 current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
2718 current_view->setState();
2722 extern "C" void TableCancelCB(FL_OBJECT *, long)
2724 fl_hide_form(fd_form_table->form_table);
2728 extern "C" void TableOKCB(FL_OBJECT * ob, long data)
2730 TableApplyCB(ob, data);
2731 TableCancelCB(ob, data);
2735 /* callbacks for form form_print */
2737 extern "C" void PrintCancelCB(FL_OBJECT *, long)
2739 fl_hide_form(fd_form_print->form_print);
2744 bool stringOnlyContains (string const & LStr, char const * cset)
2746 return LStr.find_first_not_of(cset) == string::npos;
2750 extern "C" void PrintApplyCB(FL_OBJECT *, long)
2752 if (!current_view->available())
2754 Buffer * buffer = current_view->buffer();
2755 string path = OnlyPath(buffer->fileName());
2758 if (fl_get_button(fd_form_print->radio_even_pages))
2759 pageflag = lyxrc.print_evenpage_flag + ' ';
2760 else if (fl_get_button(fd_form_print->radio_odd_pages))
2761 pageflag = lyxrc.print_oddpage_flag + ' ';
2763 // Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
2764 // User may give a page (range) list
2765 // User may print multiple (unsorted) copies
2766 string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
2767 pages = subst(pages, '+',',');
2768 pages = frontStrip(strip(pages)) ;
2769 while (!pages.empty()) { // a page range was given
2771 pages = split (pages, piece, ',') ;
2772 piece = strip(piece) ;
2773 piece = frontStrip(piece) ;
2774 if ( !stringOnlyContains (piece, "0123456789-") ) {
2775 WriteAlert(_("ERROR! Unable to print!"),
2776 _("Check 'range of pages'!"));
2779 if (piece.find('-') == string::npos) { // not found
2780 pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
2781 } else if (suffixIs(piece, "-") ) { // missing last page
2782 pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
2783 } else if (prefixIs(piece, "-") ) { // missing first page
2784 pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
2786 pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
2790 string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
2791 if (!copies.empty()) { // a number of copies was given
2792 if ( !stringOnlyContains (copies, "0123456789") ) {
2793 WriteAlert(_("ERROR! Unable to print!"),
2794 _("Check 'number of copies'!"));
2797 if (fl_get_button(fd_form_print->do_unsorted))
2798 pageflag += lyxrc.print_copies_flag;
2800 pageflag += lyxrc.print_collcopies_flag;
2801 pageflag += " " + copies + ' ' ;
2805 if (fl_get_button(fd_form_print->radio_order_reverse))
2806 reverseflag = lyxrc.print_reverse_flag + ' ';
2808 string orientationflag;
2809 if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
2810 orientationflag = lyxrc.print_landscape_flag + ' ';
2812 string ps_file = fl_get_input(fd_form_print->input_file);
2813 string printer = strip(fl_get_input(fd_form_print->input_printer));
2816 if (lyxrc.print_adapt_output // printer name should be passed to dvips
2817 && ! printer.empty()) // a printer name has been given
2818 printerflag = lyxrc.print_to_printer + printer + ' ';
2821 if (!lyxrc.print_extra_options.empty())
2822 extraflags = lyxrc.print_extra_options + ' ';
2824 string command = lyxrc.print_command + ' '
2825 + printerflag + pageflag + reverseflag
2826 + orientationflag + extraflags;
2828 char real_papersize = buffer->params.papersize;
2829 if (real_papersize == BufferParams::PAPER_DEFAULT)
2830 real_papersize = lyxrc.default_papersize;
2833 switch (real_papersize) {
2834 case BufferParams::PAPER_USLETTER:
2837 case BufferParams::PAPER_A3PAPER:
2840 case BufferParams::PAPER_A4PAPER:
2843 case BufferParams::PAPER_A5PAPER:
2846 case BufferParams::PAPER_B5PAPER:
2849 case BufferParams::PAPER_EXECUTIVEPAPER:
2852 case BufferParams::PAPER_LEGALPAPER:
2855 default: /* If nothing else fits, keep an empty value... */
2859 if (buffer->params.use_geometry
2860 && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
2861 && !lyxrc.print_paper_dimension_flag.empty()
2862 && !buffer->params.paperwidth.empty()
2863 && !buffer->params.paperheight.empty()) {
2864 // using a custom papersize
2866 command += lyxrc.print_paper_dimension_flag + ' ';
2867 command += buffer->params.paperwidth + ',';
2868 command += buffer->params.paperheight + ' ';
2869 } else if (!lyxrc.print_paper_flag.empty()
2871 && (real_papersize != BufferParams::PAPER_USLETTER ||
2872 buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
2873 command += " " + lyxrc.print_paper_flag + " " + paper + " ";
2875 if (fl_get_button(fd_form_print->radio_file))
2876 command += lyxrc.print_to_file
2877 + QuoteName(MakeAbsPath(ps_file, path));
2878 else if (!lyxrc.print_spool_command.empty())
2879 command += lyxrc.print_to_file
2880 + QuoteName(ps_file);
2882 // push directorypath, if necessary
2883 if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
2884 path = buffer->tmppath;
2889 if (!lyxrc.print_spool_command.empty() &&
2890 !fl_get_button(fd_form_print->radio_file)) {
2891 string command2 = lyxrc.print_spool_command + ' ';
2892 if (!printer.empty())
2893 command2 += lyxrc.print_spool_printerprefix
2895 // First run dvips and, if succesful, then spool command
2896 if ((result = RunScript(buffer, true, command))) {
2897 result = RunScript(buffer, false, command2, ps_file);
2900 result = RunScript(buffer, false, command);
2903 WriteAlert(_("Error:"),
2904 _("Unable to print"),
2905 _("Check that your parameters are correct"));
2909 extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
2911 PrintCancelCB(ob, data);
2912 PrintApplyCB(ob, data);
2918 if (fd_form_figure->form_figure->visible) {
2919 fl_raise_form(fd_form_figure->form_figure);
2921 fl_show_form(fd_form_figure->form_figure,
2922 FL_PLACE_MOUSE, FL_FULLBORDER,
2923 _("Insert Figure"));
2930 if (fd_form_table->form_table->visible) {
2931 fl_raise_form(fd_form_table->form_table);
2933 fl_show_form(fd_form_table->form_table,
2934 FL_PLACE_MOUSE, FL_FULLBORDER,
2940 /* callbacks for form form_figure */
2941 extern "C" void FigureApplyCB(FL_OBJECT *, long)
2943 if (!current_view->available())
2946 Buffer * buffer = current_view->buffer();
2947 if(buffer->isReadonly()) // paranoia
2950 current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
2951 if (fl_get_button(fd_form_figure->radio_inline)
2952 || current_view->text->cursor.par->table) {
2953 InsetFig * new_inset = new InsetFig(100, 20, buffer);
2954 current_view->insertInset(new_inset);
2955 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
2956 new_inset->Edit(current_view, 0, 0, 0);
2960 current_view->hideCursor();
2961 current_view->update(-2);
2962 current_view->beforeChange();
2964 current_view->text->SetCursorParUndo();
2965 current_view->text->FreezeUndo();
2967 current_view->text->BreakParagraph();
2968 current_view->update(-1);
2970 if (current_view->text->cursor.par->Last()) {
2971 current_view->text->CursorLeft();
2973 current_view->text->BreakParagraph();
2974 current_view->update(-1);
2977 // The standard layout should always be numer 0;
2978 current_view->text->SetLayout(0);
2980 if (current_view->text->cursor.par->footnoteflag ==
2981 LyXParagraph::NO_FOOTNOTE) {
2982 current_view->text->
2985 VSpace (0.3 * buffer->params.spacing.getValue(),
2988 buffer->params.spacing.getValue(),
2990 LYX_ALIGN_CENTER, string(), 0);
2992 current_view->text->SetParagraph(0, 0,
2994 VSpace(VSpace::NONE),
2995 VSpace(VSpace::NONE),
3001 current_view->update(-1);
3003 Inset * new_inset = new InsetFig(100, 100, buffer);
3004 current_view->insertInset(new_inset);
3005 new_inset->Edit(current_view, 0, 0, 0);
3006 current_view->update(0);
3007 current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
3008 current_view->text->UnFreezeUndo();
3009 current_view->setState();
3013 extern "C" void FigureCancelCB(FL_OBJECT *, long)
3015 fl_hide_form(fd_form_figure->form_figure);
3019 extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
3021 FigureApplyCB(ob, data);
3022 FigureCancelCB(ob, data);
3026 extern "C" void ScreenApplyCB(FL_OBJECT *, long)
3028 lyxrc.roman_font_name = fl_get_input(fd_form_screen->input_roman);
3029 lyxrc.sans_font_name = fl_get_input(fd_form_screen->input_sans);
3030 lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
3031 lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
3032 lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
3033 fontloader.update();
3035 // Of course we should only to the resize and the textcahce.clear
3036 // if values really changed...but not very important right now. (Lgb)
3038 // All buffers will need resize
3039 bufferlist.resize();
3040 // We also need to empty the textcache so that
3041 // the buffer will be formatted correctly after
3045 current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
3049 extern "C" void ScreenCancelCB(FL_OBJECT *, long)
3051 fl_hide_form(fd_form_screen->form_screen);
3055 extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
3057 ScreenCancelCB(ob, data);
3058 ScreenApplyCB(ob, data);
3062 void LaTeXOptions(BufferView * bv)
3064 if (!bv->available())
3067 fl_set_button(fd_latex_options->accents,
3068 int(bv->buffer()->params.allowAccents));
3070 if (fd_latex_options->LaTeXOptions->visible) {
3071 fl_raise_form(fd_latex_options->LaTeXOptions);
3073 fl_show_form(fd_latex_options->LaTeXOptions,
3074 FL_PLACE_MOUSE, FL_FULLBORDER,
3075 _("LaTeX Options"));
3080 // This function runs "configure" and then rereads lyx.defaults to
3081 // reconfigure the automatic settings.
3082 void Reconfigure(BufferView * bv)
3084 bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
3086 // Run configure in user lyx directory
3087 Path p(user_lyxdir);
3088 Systemcalls one(Systemcalls::System,
3089 AddName(system_lyxdir, "configure"));
3091 bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
3092 lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
3093 WriteAlert(_("The system has been reconfigured."),
3094 _("You need to restart LyX to make use of any"),
3095 _("updated document class specifications."));
3100 // Table of Contents
3110 static TocList * toclist = 0;
3113 extern "C" void TocSelectCB(FL_OBJECT * ob, long)
3115 if (!current_view->available())
3118 TocList * tmptoclist = toclist;
3119 int i = fl_get_browser(ob);
3120 for (int a = 1; a < i && tmptoclist->next; ++a) {
3121 tmptoclist = tmptoclist->next;
3128 LyXParagraph * par = current_view->buffer()->paragraph;
3129 while (par && (par->GetFirstCounter(0) != tmptoclist->counter[0] ||
3130 par->GetFirstCounter(1) != tmptoclist->counter[1] ||
3131 par->GetFirstCounter(2) != tmptoclist->counter[2] ||
3132 par->GetFirstCounter(3) != tmptoclist->counter[3] ||
3133 par->GetFirstCounter(4) != tmptoclist->counter[4] ||
3134 par->GetFirstCounter(5) != tmptoclist->counter[5] ||
3135 par->appendix != tmptoclist->appendix)) {
3136 par = par->LastPhysicalPar()->Next();
3140 current_view->beforeChange();
3141 current_view->text->SetCursor(par, 0);
3142 current_view->text->sel_cursor =
3143 current_view->text->cursor;
3144 current_view->update(0);
3147 WriteAlert(_("Error"),
3148 _("Couldn't find this label"),
3149 _("in current document."));
3155 extern "C" void TocCancelCB(FL_OBJECT *, long)
3157 fl_hide_form(fd_form_toc->form_toc);
3161 extern "C" void TocUpdateCB(FL_OBJECT *, long)
3163 static LyXParagraph * stapar = 0;
3164 TocList * tmptoclist = 0;
3166 /* deleted the toclist */
3169 tmptoclist = toclist->next;
3171 toclist = tmptoclist;
3175 tmptoclist = toclist;
3178 fl_clear_browser(fd_form_toc->browser_toc);
3179 if (!current_view->available()) {
3180 fl_add_browser_line(fd_form_toc->browser_toc,
3181 _("*** No Document ***"));
3184 fl_hide_object(fd_form_toc->browser_toc);
3185 /* get the table of contents */
3186 LyXParagraph * par = current_view->buffer()->paragraph;
3188 char * line = new char[200];
3194 topline = fl_get_browser_topline(fd_form_toc->browser_toc);
3198 labeltype = textclasslist.Style(current_view->buffer()->params.textclass,
3199 par->GetLayout()).labeltype;
3201 if (labeltype >= LABEL_COUNTER_CHAPTER
3202 && labeltype <= LABEL_COUNTER_CHAPTER +
3203 current_view->buffer()->params.tocdepth) {
3204 /* insert this into the table of contents */
3205 /* first indent a little bit */
3209 textclasslist.TextClass(current_view->buffer()->
3210 params.textclass).maxcounter()) * 4 + 2;
3214 // Then the labestring
3215 if (!par->labelstring.empty()) {
3216 string::size_type i = 0;
3217 while (pos < 199 && i < par->labelstring.length()) {
3218 line[pos] = par->labelstring[i];
3228 /* now the contents */
3229 LyXParagraph::size_type i = 0;
3230 while (pos < 199 && i < par->size()) {
3231 c = par->GetChar(i);
3232 if (isprint(c) || c >= 128) {
3238 if (par->isRightToLeftPar())
3239 reverse(line + pos0, line + pos);
3242 fl_add_browser_line(fd_form_toc->browser_toc, line);
3244 /* make a toclist entry */
3246 tmptoclist = new TocList;
3247 toclist = tmptoclist;
3249 tmptoclist->next = new TocList;
3250 tmptoclist = tmptoclist->next;
3253 tmptoclist->next = 0;
3255 for (a = 0; a < 6; ++a) {
3256 tmptoclist->counter[a] = par->GetFirstCounter(a);
3258 tmptoclist->appendix = par->appendix;
3260 par = par->LastPhysicalPar()->Next();
3264 fl_set_browser_topline(fd_form_toc->browser_toc, topline);
3265 fl_show_object(fd_form_toc->browser_toc);
3269 /* callbacks for form form_ref */
3270 extern "C" void RefSelectCB(FL_OBJECT *, long data)
3272 if (!current_view->available())
3276 fl_get_browser_line(fd_form_ref->browser_ref,
3277 fl_get_browser(fd_form_ref->browser_ref));
3278 string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
3284 current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
3294 if(current_view->buffer()->isSGML())
3295 t += "[" + u + "]" + "{" + s + "}";
3300 new InsetRef(t, current_view->buffer());
3301 current_view->insertInset(new_inset);
3305 extern "C" void RefUpdateCB(FL_OBJECT *, long)
3307 if (!current_view->available()) {
3308 fl_clear_browser(fd_form_ref->browser_ref);
3312 FL_OBJECT * brow = fd_form_ref->browser_ref;
3314 // Get the current line, in order to restore it later
3315 char const * const btmp = fl_get_browser_line(brow,
3316 fl_get_browser(brow));
3317 string currentstr = btmp ? btmp : "";
3319 fl_clear_browser(brow);
3321 string refs = current_view->buffer()->getReferenceList('\n');
3324 fl_addto_browser_chars(brow, refs.c_str());
3325 int total_lines = fl_get_browser_maxline(brow);
3326 for (int i = 1; i <= total_lines ; ++i) {
3327 if (fl_get_browser_line(brow, i) == currentstr) {
3332 fl_set_browser_topline(brow, topline);
3334 if (!fl_get_browser_maxline(brow)) {
3335 fl_add_browser_line(brow,
3336 _("*** No labels found in document ***"));
3337 fl_deactivate_object(brow);
3339 fl_select_browser_line(brow, topline);
3340 fl_activate_object(brow);
3342 if (current_view->buffer()->isReadonly()) {
3343 // would be better to de/activate insert buttons
3344 // but that's more work... besides this works. ARRae
3345 fl_hide_form(fd_form_ref->form_ref);
3347 if (!current_view->buffer()->isSGML()) {
3348 fl_deactivate_object(fd_form_ref->ref_name);
3349 fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
3352 fl_activate_object(fd_form_ref->ref_name);
3353 fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
3358 extern "C" void RefHideCB(FL_OBJECT *, long)
3360 fl_hide_form(fd_form_ref->form_ref);