1999-09-27 18:44:28 +00:00
|
|
|
/* This file is part of
|
1999-11-15 12:01:38 +00:00
|
|
|
* ======================================================
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
|
|
|
* Copyright 1995 Matthias Ettrich,
|
2000-02-04 09:38:32 +00:00
|
|
|
* Copyright 1995-2000 The LyX Team.
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2000-01-06 11:35:29 +00:00
|
|
|
#include <fstream>
|
2000-03-20 18:55:57 +00:00
|
|
|
#include <algorithm>
|
2000-04-08 17:02:02 +00:00
|
|
|
#include <iostream>
|
2000-03-16 04:29:22 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
#include "lyx.h"
|
|
|
|
#include "layout_forms.h"
|
|
|
|
#include "bullet_forms.h"
|
|
|
|
#include "print_form.h"
|
|
|
|
#include "form1.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "lyx_main.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyx_cb.h"
|
|
|
|
#include "insets/insetref.h"
|
|
|
|
#include "insets/insetlabel.h"
|
|
|
|
#include "insets/figinset.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "minibuffer.h"
|
|
|
|
#include "combox.h"
|
|
|
|
#include "bufferlist.h"
|
|
|
|
#include "filedlg.h"
|
|
|
|
#include "lyx_gui_misc.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "LyXView.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "BufferView.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lastfiles.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "bufferview_funcs.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/FileInfo.h"
|
|
|
|
#include "support/syscall.h"
|
2000-04-12 14:20:08 +00:00
|
|
|
#include "support/filetools.h"
|
|
|
|
#include "support/path.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxserver.h"
|
|
|
|
#include "FontLoader.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "lyxtext.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
#include "CutAndPaste.h"
|
2000-04-27 09:10:51 +00:00
|
|
|
#include "TextCache.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
using std::ifstream;
|
|
|
|
using std::copy;
|
|
|
|
using std::back_inserter;
|
|
|
|
using std::endl;
|
|
|
|
using std::cout;
|
|
|
|
using std::ios;
|
|
|
|
using std::istream_iterator;
|
2000-04-04 00:19:15 +00:00
|
|
|
using std::pair;
|
2000-05-19 16:46:01 +00:00
|
|
|
using std::vector;
|
|
|
|
using std::sort;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern Combox * combo_language;
|
2000-04-17 14:00:18 +00:00
|
|
|
extern Combox * combo_language2;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern BufferList bufferlist;
|
|
|
|
extern void show_symbols_form();
|
1999-11-26 06:57:35 +00:00
|
|
|
extern FD_form_title * fd_form_title;
|
|
|
|
extern FD_form_paragraph * fd_form_paragraph;
|
|
|
|
extern FD_form_character * fd_form_character;
|
|
|
|
extern FD_form_document * fd_form_document;
|
|
|
|
extern FD_form_quotes * fd_form_quotes;
|
|
|
|
extern FD_form_preamble * fd_form_preamble;
|
|
|
|
extern FD_form_table * fd_form_table;
|
|
|
|
extern FD_form_print * fd_form_print;
|
|
|
|
extern FD_form_figure * fd_form_figure;
|
|
|
|
extern FD_form_screen * fd_form_screen;
|
|
|
|
extern FD_form_toc * fd_form_toc;
|
|
|
|
extern FD_form_ref * fd_form_ref;
|
|
|
|
extern FD_LaTeXOptions * fd_latex_options;
|
|
|
|
extern FD_form_bullet * fd_form_bullet;
|
|
|
|
|
|
|
|
extern BufferView * current_view; // called too many times in this file...
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern bool send_fax(string const & fname, string const & sendcmd);
|
1999-12-15 17:42:22 +00:00
|
|
|
extern void MenuSendto();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern LyXServer * lyxserver;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// this should be static, but I need it in buffer.C
|
|
|
|
bool quitting; // flag, that we are quitting the program
|
|
|
|
extern bool finished; // all cleanup done just let it run through now.
|
|
|
|
|
|
|
|
char ascii_type; /* for selection notify callbacks */
|
|
|
|
|
|
|
|
bool scrolling = false;
|
|
|
|
|
|
|
|
// This is used to make the dreaded font toggle problem hopefully go
|
|
|
|
// away. Definitely not the best solution, but I think it sorta works.
|
|
|
|
bool toggleall = true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
This is the inset locking stuff needed for mathed --------------------
|
|
|
|
|
|
|
|
an inset can simple call LockInset in it's edit call and *ONLY* in it's
|
|
|
|
edit call.
|
|
|
|
Inset::Edit() can only be called by the main lyx module.
|
|
|
|
|
|
|
|
Then the inset may modify the menu's and/or iconbars.
|
|
|
|
|
|
|
|
Unlocking is either done by LyX or the inset itself with a UnlockInset-call
|
|
|
|
|
|
|
|
During the lock, all button and keyboard events will be modified
|
|
|
|
and send to the inset through the following inset-features. Note that
|
|
|
|
Inset::InsetUnlock will be called from inside UnlockInset. It is meant
|
|
|
|
to contain the code for restoring the menus and things like this.
|
|
|
|
|
|
|
|
|
|
|
|
virtual void InsetButtonPress(int x, int y, int button);
|
|
|
|
virtual void InsetButtonRelease(int x, int y, int button);
|
|
|
|
virtual void InsetKeyPress(XKeyEvent *ev);
|
|
|
|
virtual void InsetMotionNotify(int x, int y, int state);
|
|
|
|
virtual void InsetUnlock();
|
|
|
|
|
|
|
|
If a inset wishes any redraw and/or update it just has to call
|
|
|
|
UpdateInset(this).
|
|
|
|
It's is completly irrelevant, where the inset is. UpdateInset will
|
|
|
|
find it in any paragraph in any buffer.
|
|
|
|
Of course the_locking_inset and the insets in the current paragraph/buffer
|
|
|
|
are checked first, so no performance problem should occur.
|
|
|
|
|
|
|
|
Hope that's ok for the beginning, Alejandro,
|
|
|
|
sorry that I needed so much time,
|
|
|
|
|
|
|
|
Matthias
|
|
|
|
*/
|
|
|
|
|
2000-02-23 16:39:03 +00:00
|
|
|
//void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* these functions return 1 if an error occured,
|
|
|
|
otherwise 0 */
|
|
|
|
// Now they work only for updatable insets. [Alejandro 080596]
|
2000-01-08 21:02:58 +00:00
|
|
|
//int LockInset(UpdatableInset * inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
void ToggleLockedInsetCursor(long x, long y, int asc, int desc);
|
2000-01-08 21:02:58 +00:00
|
|
|
//void FitLockedInsetCursor(long x, long y, int asc, int desc);
|
|
|
|
//int UnlockInset(UpdatableInset * inset);
|
|
|
|
//void LockedInsetStoreUndo(Undo::undo_kind kind);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/* this is for asyncron updating. UpdateInsetUpdateList will be called
|
|
|
|
automatically from LyX. Just insert the Inset into the Updatelist */
|
2000-02-23 16:39:03 +00:00
|
|
|
//void UpdateInsetUpdateList();
|
|
|
|
//void PutInsetIntoInsetUpdateList(Inset * inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-02-23 16:39:03 +00:00
|
|
|
//InsetUpdateStruct * InsetUpdateList = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* some function prototypes */
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
int RunLinuxDoc(BufferView *, int, string const &);
|
1999-10-02 16:21:10 +00:00
|
|
|
int RunDocBook(int, string const &);
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuWrite(Buffer * buf);
|
|
|
|
void MenuWriteAs(Buffer * buffer);
|
|
|
|
void MenuReload(Buffer * buf);
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutSave();
|
|
|
|
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
void ShowMessage(Buffer * buf,
|
|
|
|
string const & msg1,
|
|
|
|
string const & msg2 = string(),
|
|
|
|
string const & msg3 = string(), int delay = 6)
|
2000-03-20 16:37:50 +00:00
|
|
|
{
|
|
|
|
if (lyxrc.use_gui) {
|
2000-03-28 02:18:55 +00:00
|
|
|
buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
|
|
|
|
msg3, delay);
|
|
|
|
} else {
|
2000-03-20 16:37:50 +00:00
|
|
|
// can somebody think of something more clever? cerr?
|
|
|
|
cout << msg1 << msg2 << msg3 << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
// only called from this file, LyXView and LyXFunc
|
|
|
|
char updatetimer = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
// only called from BufferView_pimpl and LyXFunc
|
1999-09-27 18:44:28 +00:00
|
|
|
void FreeUpdateTimer()
|
|
|
|
{
|
|
|
|
/* a real free timer would be better but I don't know
|
|
|
|
* how to do this with xforms */
|
|
|
|
updatetimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
// Only called from LyXFunc
|
1999-09-27 18:44:28 +00:00
|
|
|
void SetUpdateTimer(float time)
|
|
|
|
{
|
1999-12-19 22:35:36 +00:00
|
|
|
fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
|
1999-09-27 18:44:28 +00:00
|
|
|
updatetimer = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Menu callbacks
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// File menu
|
|
|
|
//
|
|
|
|
|
|
|
|
// should be moved to lyxfunc.C
|
2000-01-07 03:42:16 +00:00
|
|
|
void MenuWrite(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
XFlush(fl_display);
|
2000-03-20 14:49:54 +00:00
|
|
|
if (!buffer->save()) {
|
2000-01-07 03:42:16 +00:00
|
|
|
string fname = buffer->fileName();
|
1999-10-02 16:21:10 +00:00
|
|
|
string s = MakeAbsPath(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (AskQuestion(_("Save failed. Rename and try again?"),
|
1999-12-16 06:43:25 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("(If not, document is not saved.)"))) {
|
2000-01-07 03:42:16 +00:00
|
|
|
MenuWriteAs(buffer);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-01-07 03:42:16 +00:00
|
|
|
lastfiles->newFile(buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// should be moved to BufferView.C
|
2000-01-07 03:42:16 +00:00
|
|
|
// Half of this func should be in LyXView, the rest in BufferView.
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuWriteAs(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Why do we require BufferView::text to be able to write a
|
|
|
|
// document? I see no point in that. (Lgb)
|
|
|
|
//if (!bv->text) return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
string fname = buffer->fileName();
|
1999-10-02 16:21:10 +00:00
|
|
|
string oldname = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
LyXFileDlg fileDlg;
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(current_view);
|
2000-03-12 10:35:05 +00:00
|
|
|
fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
|
|
|
|
fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!IsLyXFilename(fname))
|
|
|
|
fname += ".lyx";
|
|
|
|
|
|
|
|
fname = fileDlg.Select(_("Enter Filename to Save Document as"),
|
|
|
|
OnlyPath(fname),
|
|
|
|
"*.lyx",
|
|
|
|
OnlyFilename(fname));
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fname.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Make sure the absolute filename ends with appropriate suffix
|
1999-11-15 12:01:38 +00:00
|
|
|
string s = MakeAbsPath(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!IsLyXFilename(s))
|
|
|
|
s += ".lyx";
|
|
|
|
|
|
|
|
// Same name as we have already?
|
|
|
|
if (s == oldname) {
|
|
|
|
if (!AskQuestion(_("Same name as document already has:"),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Save anyway?")))
|
|
|
|
return;
|
|
|
|
// Falls through to name change and save
|
|
|
|
}
|
|
|
|
// No, but do we have another file with this name open?
|
|
|
|
else if (bufferlist.exists(s)) {
|
|
|
|
if (AskQuestion(_("Another document with same name open!"),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Replace with current document?")))
|
|
|
|
{
|
|
|
|
bufferlist.close(bufferlist.getBuffer(s));
|
|
|
|
|
|
|
|
// Ok, change the name of the buffer, but don't save!
|
1999-12-10 00:07:59 +00:00
|
|
|
buffer->fileName(s);
|
1999-09-27 18:44:28 +00:00
|
|
|
buffer->markDirty();
|
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Document renamed to '"),
|
|
|
|
MakeDisplayPath(s), _("', but not saved..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
} // Check whether the file exists
|
|
|
|
else {
|
|
|
|
FileInfo myfile(s);
|
|
|
|
if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Replace file?")))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok, change the name of the buffer
|
1999-12-10 00:07:59 +00:00
|
|
|
buffer->fileName(s);
|
1999-09-27 18:44:28 +00:00
|
|
|
buffer->markDirty();
|
|
|
|
// And save
|
|
|
|
// Small bug: If the save fails, we have irreversible changed the name
|
|
|
|
// of the document.
|
|
|
|
MenuWrite(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int MenuRunLaTeX(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (buffer->isLinuxDoc())
|
2000-03-17 10:14:46 +00:00
|
|
|
ret = RunLinuxDoc(buffer->getUser(), 1, buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
else if (buffer->isLiterate())
|
|
|
|
ret = buffer->runLiterate();
|
|
|
|
else if (buffer->isDocBook())
|
1999-12-10 00:07:59 +00:00
|
|
|
ret = RunDocBook(1, buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
|
|
|
ret = buffer->runLaTeX();
|
|
|
|
|
|
|
|
if (ret > 0) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string s;
|
|
|
|
string t;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (ret == 1) {
|
|
|
|
s = _("One error detected");
|
|
|
|
t = _("You should try to fix it.");
|
|
|
|
} else {
|
1999-10-19 16:48:35 +00:00
|
|
|
s += tostr(ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
s += _(" errors detected.");
|
|
|
|
t = _("You should try to fix them.");
|
|
|
|
}
|
|
|
|
WriteAlert(_("There were errors during the LaTeX run."), s, t);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int MenuBuildProg(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-26 06:57:35 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (buffer->isLiterate())
|
|
|
|
ret = buffer->buildProgram();
|
|
|
|
else {
|
|
|
|
string s = _("Wrong type of document");
|
|
|
|
string t = _("The Build operation is not allowed in this document");
|
|
|
|
WriteAlert(_("There were errors during the Build process."), s, t);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret > 0) {
|
|
|
|
string s;
|
|
|
|
string t;
|
|
|
|
if (ret == 1) {
|
|
|
|
s = _("One error detected");
|
|
|
|
t = _("You should try to fix it.");
|
|
|
|
} else {
|
|
|
|
s += tostr(ret);
|
|
|
|
s += _(" errors detected.");
|
|
|
|
t = _("You should try to fix them.");
|
|
|
|
}
|
|
|
|
WriteAlert(_("There were errors during the Build process."), s, t);
|
|
|
|
}
|
|
|
|
return ret;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int MenuRunChktex(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (buffer->isSGML()) {
|
|
|
|
WriteAlert(_("Chktex does not work with SGML derived documents."));
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
ret = buffer->runChktex();
|
|
|
|
|
|
|
|
if (ret >= 0) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string s;
|
|
|
|
string t;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
s = _("No warnings found.");
|
|
|
|
} else if (ret == 1) {
|
|
|
|
s = _("One warning found.");
|
|
|
|
t = _("Use 'Edit->Go to Error' to find it.");
|
|
|
|
} else {
|
1999-10-19 16:48:35 +00:00
|
|
|
s += tostr(ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
s += _(" warnings found.");
|
|
|
|
t = _("Use 'Edit->Go to Error' to find them.");
|
|
|
|
}
|
|
|
|
WriteAlert(_("Chktex run successfully"), s, t);
|
|
|
|
} else {
|
1999-11-15 12:01:38 +00:00
|
|
|
WriteAlert(_("Error!"), _("It seems chktex does not work."));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
int MakeLaTeXOutput(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return 1;
|
1999-09-27 18:44:28 +00:00
|
|
|
int ret = 0;
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
|
|
|
if (!buffer->isDviClean()) {
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
ret = MenuRunLaTeX(buffer);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* wait == false means don't wait for termination */
|
|
|
|
/* wait == true means wait for termination */
|
|
|
|
// The bool should be placed last on the argument line. (Lgb)
|
|
|
|
// Returns false if we fail.
|
1999-11-02 21:19:58 +00:00
|
|
|
bool RunScript(Buffer * buffer, bool wait,
|
1999-11-26 06:57:35 +00:00
|
|
|
string const & command,
|
|
|
|
string const & orgname = string(),
|
1999-11-15 12:01:38 +00:00
|
|
|
bool need_shell = true)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string path;
|
|
|
|
string cmd;
|
1999-11-15 12:01:38 +00:00
|
|
|
string name = orgname;
|
1999-09-27 18:44:28 +00:00
|
|
|
int result = 0;
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
if (MakeLaTeXOutput(buffer) > 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
/* get DVI-Filename */
|
|
|
|
if (name.empty())
|
2000-05-11 16:12:46 +00:00
|
|
|
name = ChangeExtension(buffer->getLatexName(), ".dvi");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
path = OnlyPath(name);
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
2000-02-15 13:30:49 +00:00
|
|
|
// At this point we check whether the command contains the
|
|
|
|
// filename parameter $$FName and if that's the case we
|
|
|
|
// substitute the real file name otherwise the filename is
|
|
|
|
// simply appended. rokrau 1/12/00
|
|
|
|
cmd = command;
|
2000-03-28 02:18:55 +00:00
|
|
|
string::size_type i;
|
|
|
|
if ( (i=command.find("$$FName")) != string::npos)
|
2000-02-15 13:30:49 +00:00
|
|
|
{
|
|
|
|
cmd.replace(i,7,QuoteName(name));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cmd = command + ' ' + QuoteName(name);
|
1999-12-03 13:51:01 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
Systemcalls one;
|
|
|
|
|
|
|
|
if (need_shell) {
|
|
|
|
#ifndef __EMX__
|
|
|
|
if (!wait)
|
|
|
|
cmd += " &";
|
|
|
|
#else
|
|
|
|
// OS/2 cmd.exe has another use for '&'
|
|
|
|
if (!wait) {
|
|
|
|
// This is not NLS safe, but it's OK, I think.
|
1999-10-02 16:21:10 +00:00
|
|
|
string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
|
1999-09-27 18:44:28 +00:00
|
|
|
if (sh.empty()) {
|
|
|
|
// COMSPEC is set, unless user unsets
|
1999-10-02 16:21:10 +00:00
|
|
|
sh = OnlyFilename(GetEnvPath("COMSPEC"));
|
1999-09-27 18:44:28 +00:00
|
|
|
if (sh.empty())
|
|
|
|
sh = "cmd.exe";
|
|
|
|
}
|
1999-11-01 04:22:28 +00:00
|
|
|
sh = lowercase(sh);
|
|
|
|
if (contains(sh, "cmd.exe")
|
|
|
|
|| contains(sh, "4os2.exe"))
|
1999-09-27 18:44:28 +00:00
|
|
|
cmd = "start /min/n " + cmd;
|
|
|
|
else
|
|
|
|
cmd += " &";
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// It seems that, if wait is false, we never get back
|
|
|
|
// the return code of the command. This means that all
|
|
|
|
// the code I added in PrintApplyCB is currently
|
|
|
|
// useless...
|
2000-04-26 13:57:28 +00:00
|
|
|
// CHECK What should we do here?
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Executing command:"), cmd);
|
1999-10-12 21:37:10 +00:00
|
|
|
result = one.startscript(Systemcalls::System, cmd);
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Executing command:"), cmd);
|
1999-10-12 21:37:10 +00:00
|
|
|
result = one.startscript(wait ? Systemcalls::Wait
|
1999-12-16 06:43:25 +00:00
|
|
|
: Systemcalls::DontWait, cmd);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-01-07 03:42:16 +00:00
|
|
|
return result == 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns false if we fail
|
2000-01-11 01:59:00 +00:00
|
|
|
bool CreatePostscript(Buffer * buffer, bool wait = false)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Generate dvi file
|
2000-01-11 01:59:00 +00:00
|
|
|
if (MakeLaTeXOutput(buffer) > 0) {
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Generate postscript file
|
2000-05-11 16:12:46 +00:00
|
|
|
string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
|
|
|
|
".ps_tmp"));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string paper;
|
2000-01-07 03:42:16 +00:00
|
|
|
|
|
|
|
// Wrong type
|
1999-09-27 18:44:28 +00:00
|
|
|
char real_papersize = buffer->params.papersize;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
2000-03-12 10:35:05 +00:00
|
|
|
real_papersize = lyxrc.default_papersize;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
switch (real_papersize) {
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_USLETTER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "letter";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A3PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a3";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A4PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a4";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A5PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a5";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_B5PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "b5";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_EXECUTIVEPAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "foolscap";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_LEGALPAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "legal";
|
|
|
|
break;
|
|
|
|
default: /* If nothing else fits, keep an empty value... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make postscript file.
|
2000-03-12 10:35:05 +00:00
|
|
|
string command = lyxrc.dvi_to_ps_command + ' ' + lyxrc.print_to_file + ' ';
|
1999-12-03 13:51:01 +00:00
|
|
|
command += QuoteName(psname);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (buffer->params.use_geometry
|
1999-11-15 12:01:38 +00:00
|
|
|
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
2000-03-12 10:35:05 +00:00
|
|
|
&& !lyxrc.print_paper_dimension_flag.empty()
|
1999-09-27 18:44:28 +00:00
|
|
|
&& !buffer->params.paperwidth.empty()
|
|
|
|
&& !buffer->params.paperheight.empty()) {
|
|
|
|
// using a custom papersize
|
|
|
|
command += ' ';
|
2000-03-12 10:35:05 +00:00
|
|
|
command += lyxrc.print_paper_dimension_flag + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
command += buffer->params.paperwidth + ',';
|
|
|
|
command += buffer->params.paperheight;
|
|
|
|
} else if (!paper.empty()
|
1999-11-15 12:01:38 +00:00
|
|
|
&& (real_papersize != BufferParams::PAPER_USLETTER ||
|
|
|
|
buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// dvips won't accept -t letter -t landscape. In all other
|
|
|
|
// cases, include the paper size explicitly.
|
|
|
|
command += ' ';
|
2000-03-12 10:35:05 +00:00
|
|
|
command += lyxrc.print_paper_flag + ' ' + paper;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
|
1999-09-27 18:44:28 +00:00
|
|
|
command += ' ';
|
2000-03-12 10:35:05 +00:00
|
|
|
command += lyxrc.print_landscape_flag;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
// push directorypath, if necessary
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
|
1999-09-27 18:44:28 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
bool ret = RunScript(buffer, wait, command);
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns false if we fail
|
2000-01-11 01:59:00 +00:00
|
|
|
//bool MenuPreviewPS(Buffer * buffer)
|
|
|
|
bool PreviewPostscript(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Generate postscript file
|
2000-01-11 01:59:00 +00:00
|
|
|
if (!CreatePostscript(buffer, true)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start postscript viewer
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(current_view);
|
2000-05-11 16:12:46 +00:00
|
|
|
string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
|
|
|
|
".ps_tmp"));
|
1999-09-27 18:44:28 +00:00
|
|
|
// push directorypath, if necessary
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
|
1999-09-27 18:44:28 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
2000-03-12 10:35:05 +00:00
|
|
|
bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuFax(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Generate postscript file
|
2000-01-11 01:59:00 +00:00
|
|
|
if (!CreatePostscript(buffer, true)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send fax
|
2000-05-11 16:12:46 +00:00
|
|
|
string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
|
|
|
|
".ps_tmp"));
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath (buffer->fileName());
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
2000-03-12 10:35:05 +00:00
|
|
|
if (!lyxrc.fax_program.empty()) {
|
|
|
|
string help2 = subst(lyxrc.fax_program, "$$FName", ps);
|
1999-09-27 18:44:28 +00:00
|
|
|
help2 += " &";
|
|
|
|
Systemcalls one(Systemcalls::System, help2);
|
|
|
|
} else
|
2000-03-12 10:35:05 +00:00
|
|
|
send_fax(ps, lyxrc.fax_command);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns false if we fail
|
2000-01-11 01:59:00 +00:00
|
|
|
bool PreviewDVI(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return false;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
string paper = lyxrc.view_dvi_paper_option;
|
2000-02-15 13:30:49 +00:00
|
|
|
if (!paper.empty()) {
|
|
|
|
// wrong type
|
|
|
|
char real_papersize = buffer->params.papersize;
|
|
|
|
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
2000-03-12 10:35:05 +00:00
|
|
|
real_papersize = lyxrc.default_papersize;
|
2000-02-15 13:30:49 +00:00
|
|
|
|
|
|
|
switch (real_papersize) {
|
|
|
|
case BufferParams::PAPER_USLETTER:
|
|
|
|
paper += " us";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_A3PAPER:
|
|
|
|
paper += " a3";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_A4PAPER:
|
|
|
|
paper += " a4";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_A5PAPER:
|
|
|
|
paper += " a5";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_B5PAPER:
|
|
|
|
paper += " b5";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_EXECUTIVEPAPER:
|
|
|
|
paper += " foolscap";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_LEGALPAPER:
|
|
|
|
paper += " legal";
|
|
|
|
break;
|
|
|
|
default: /* If nothing else fits, keep the empty value */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (real_papersize==' ') {
|
|
|
|
// if (paper.empty()) {
|
|
|
|
if (buffer->params.orientation
|
|
|
|
== BufferParams::ORIENTATION_LANDSCAPE)
|
|
|
|
// we HAVE to give a size when the page is in
|
|
|
|
// landscape, so use USletter.
|
|
|
|
paper = " -paper usr";
|
|
|
|
} else {
|
|
|
|
// paper = " -paper " + paper;
|
|
|
|
if (buffer->params.orientation
|
|
|
|
== BufferParams::ORIENTATION_LANDSCAPE)
|
|
|
|
paper+= 'r';
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-02-15 13:30:49 +00:00
|
|
|
// push directorypath, if necessary
|
|
|
|
string path = OnlyPath(buffer->fileName());
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
2000-02-15 13:30:49 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
|
|
|
Path p(path);
|
|
|
|
// Run dvi-viewer
|
2000-03-12 10:35:05 +00:00
|
|
|
string command = lyxrc.view_dvi_command + " " + paper;
|
1999-09-27 18:44:28 +00:00
|
|
|
bool ret = RunScript(buffer, false, command);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
bool AskOverwrite(Buffer * buffer, string const & s)
|
|
|
|
{
|
|
|
|
if (lyxrc.use_gui) {
|
|
|
|
// be friendly if there is a gui
|
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
!AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to overwrite the file?"))) {
|
|
|
|
ShowMessage(buffer, _("Canceled"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
|
1999-11-02 21:19:58 +00:00
|
|
|
void MenuMakeLaTeX(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Why care about this?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Get LaTeX-Filename
|
1999-12-20 17:38:37 +00:00
|
|
|
string s = buffer->getLatexName(false);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
if (!AskOverwrite(buffer, s))
|
|
|
|
return;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (buffer->isDocBook())
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("DocBook does not have a latex backend"));
|
1999-12-10 00:07:59 +00:00
|
|
|
else {
|
|
|
|
if (buffer->isLinuxDoc())
|
2000-03-17 10:14:46 +00:00
|
|
|
RunLinuxDoc(buffer->getUser(), 0, buffer->fileName());
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
|
|
|
buffer->makeLaTeXFile(s, string(), true);
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Nice LaTeX file saved as"),
|
|
|
|
MakeDisplayPath(s));
|
1999-12-10 00:07:59 +00:00
|
|
|
buffer->markDviDirty();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuMakeLinuxDoc(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text) return;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (!buffer->isLinuxDoc()) {
|
|
|
|
WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Get LinuxDoc-Filename
|
2000-05-11 16:12:46 +00:00
|
|
|
string s = ChangeExtension(buffer->fileName(), ".sgml");
|
2000-03-20 16:37:50 +00:00
|
|
|
|
|
|
|
if (!AskOverwrite(buffer, s))
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
|
2000-01-07 03:42:16 +00:00
|
|
|
MakeDisplayPath(s),"'...");
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
buffer->makeLinuxDocFile(s, 65);
|
|
|
|
buffer->redraw();
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("LinuxDoc SGML file save as"),
|
2000-01-07 03:42:16 +00:00
|
|
|
MakeDisplayPath(s));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuMakeDocBook(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text) return;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (!buffer->isDocBook()) {
|
|
|
|
WriteAlert(_("Error!"),
|
|
|
|
_("Document class must be docbook."));
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Get DocBook-Filename
|
2000-05-11 16:12:46 +00:00
|
|
|
string s = ChangeExtension(buffer->fileName(), ".sgml");
|
2000-03-20 16:37:50 +00:00
|
|
|
|
|
|
|
if (!AskOverwrite(buffer, s))
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Building DocBook SGML file `"),
|
2000-01-07 03:42:16 +00:00
|
|
|
MakeDisplayPath(s), "'...");
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
buffer->makeDocBookFile(s, 65);
|
|
|
|
buffer->redraw();
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("DocBook SGML file save as"),
|
2000-01-07 03:42:16 +00:00
|
|
|
MakeDisplayPath(s));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuMakeAscii(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text) return;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
/* get LaTeX-Filename */
|
2000-05-11 16:12:46 +00:00
|
|
|
string s = ChangeExtension (buffer->fileName(), ".txt");
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
|
|
|
|
if (!AskOverwrite(buffer, s))
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
buffer->writeFileAscii(s, lyxrc.ascii_linelen);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuPrint(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2000-05-11 16:12:46 +00:00
|
|
|
string input_file = OnlyFilename(ChangeExtension(buffer->fileName(),
|
|
|
|
lyxrc.print_file_extension));
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_input(fd_form_print->input_file, input_file.c_str());
|
|
|
|
|
|
|
|
if (fd_form_print->form_print->visible) {
|
|
|
|
fl_raise_form(fd_form_print->form_print);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_show_form(fd_form_print->form_print,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Print"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
|
1999-12-15 17:42:22 +00:00
|
|
|
void MenuMakeHTML(Buffer * buffer)
|
|
|
|
{
|
|
|
|
// First, create LaTeX file
|
|
|
|
MenuMakeLaTeX(buffer);
|
|
|
|
|
|
|
|
// And now, run the converter
|
|
|
|
string file = buffer->fileName();
|
|
|
|
Path path(OnlyPath(file));
|
|
|
|
// the tex file name has to be correct for
|
|
|
|
// latex, but the html file name can be
|
|
|
|
// anything.
|
2000-05-11 16:12:46 +00:00
|
|
|
string result = ChangeExtension(file, ".html");
|
1999-12-20 17:38:37 +00:00
|
|
|
string infile = buffer->getLatexName(false);
|
2000-03-12 10:35:05 +00:00
|
|
|
string tmp = lyxrc.html_command;
|
1999-12-15 17:42:22 +00:00
|
|
|
tmp = subst(tmp, "$$FName", infile);
|
|
|
|
tmp = subst(tmp, "$$OutName", result);
|
|
|
|
Systemcalls one;
|
|
|
|
int res = one.startscript(Systemcalls::System, tmp);
|
|
|
|
if (res == 0) {
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Document exported as HTML to file `")
|
2000-01-07 03:42:16 +00:00
|
|
|
+ MakeDisplayPath(result) +'\'');
|
1999-12-15 17:42:22 +00:00
|
|
|
} else {
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Unable to convert to HTML the file `")
|
2000-01-07 03:42:16 +00:00
|
|
|
+ MakeDisplayPath(infile)
|
|
|
|
+ '\'');
|
1999-12-15 17:42:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
|
2000-03-20 18:55:57 +00:00
|
|
|
void MenuMakeHTML_LinuxDoc(Buffer * buffer)
|
|
|
|
{
|
|
|
|
// First, create LinuxDoc file
|
|
|
|
MenuMakeLinuxDoc(buffer);
|
|
|
|
|
|
|
|
// And now, run the converter
|
|
|
|
string file = buffer->fileName();
|
|
|
|
|
2000-05-11 16:12:46 +00:00
|
|
|
string result = ChangeExtension(file, ".html");
|
|
|
|
string infile = ChangeExtension(file, ".sgml");
|
2000-03-20 18:55:57 +00:00
|
|
|
string tmp = lyxrc.linuxdoc_to_html_command;
|
|
|
|
tmp = subst(tmp, "$$FName", infile);
|
|
|
|
tmp = subst(tmp, "$$OutName", result);
|
|
|
|
Systemcalls one;
|
|
|
|
int res = one.startscript(Systemcalls::System, tmp);
|
|
|
|
if (res == 0) {
|
|
|
|
ShowMessage(buffer,_("Document exported as HTML to file `")
|
|
|
|
+ MakeDisplayPath(result) +'\'');
|
|
|
|
} else {
|
|
|
|
ShowMessage(buffer,_("Unable to convert to HTML the file `")
|
|
|
|
+ MakeDisplayPath(infile)
|
|
|
|
+ '\'');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuMakeHTML_DocBook(Buffer * buffer)
|
|
|
|
{
|
|
|
|
// First, create LaTeX file
|
|
|
|
MenuMakeDocBook(buffer);
|
|
|
|
|
|
|
|
// And now, run the converter
|
|
|
|
string file = buffer->fileName();
|
2000-05-11 16:12:46 +00:00
|
|
|
string result = ChangeExtension(file, ".html");
|
|
|
|
string infile = ChangeExtension(file, ".sgml");
|
2000-03-20 18:55:57 +00:00
|
|
|
string tmp = lyxrc.docbook_to_html_command;
|
|
|
|
tmp = subst(tmp, "$$FName", infile);
|
|
|
|
tmp = subst(tmp, "$$OutName", result);
|
|
|
|
Systemcalls one;
|
|
|
|
int res = one.startscript(Systemcalls::System, tmp);
|
|
|
|
if (res == 0) {
|
|
|
|
ShowMessage(buffer,_("Document exported as HTML to file `")
|
|
|
|
+ MakeDisplayPath(result) +'\'');
|
|
|
|
} else {
|
|
|
|
ShowMessage(buffer,_("Unable to convert to HTML the file `")
|
|
|
|
+ MakeDisplayPath(infile)
|
|
|
|
+ '\'');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
|
1999-12-15 17:42:22 +00:00
|
|
|
void MenuExport(Buffer * buffer, string const & extyp)
|
|
|
|
{
|
|
|
|
// latex
|
|
|
|
if (extyp == "latex") {
|
1999-12-16 06:43:25 +00:00
|
|
|
// make sure that this buffer is not linuxdoc
|
1999-12-15 17:42:22 +00:00
|
|
|
MenuMakeLaTeX(buffer);
|
|
|
|
}
|
|
|
|
// linuxdoc
|
|
|
|
else if (extyp == "linuxdoc") {
|
|
|
|
// make sure that this buffer is not latex
|
|
|
|
MenuMakeLinuxDoc(buffer);
|
|
|
|
}
|
|
|
|
// docbook
|
|
|
|
else if (extyp == "docbook") {
|
1999-12-16 06:43:25 +00:00
|
|
|
// make sure that this buffer is not latex or linuxdoc
|
1999-12-15 17:42:22 +00:00
|
|
|
MenuMakeDocBook(buffer);
|
|
|
|
}
|
|
|
|
// dvi
|
|
|
|
else if (extyp == "dvi") {
|
1999-12-16 06:43:25 +00:00
|
|
|
// Run LaTeX as "Update dvi..." Bernhard.
|
|
|
|
// We want the dvi in the current directory. This
|
|
|
|
// is achieved by temporarily disabling use of
|
|
|
|
// temp directory. As a side-effect, we get
|
|
|
|
// *.log and *.aux files also. (Asger)
|
2000-03-12 10:35:05 +00:00
|
|
|
bool flag = lyxrc.use_tempdir;
|
|
|
|
lyxrc.use_tempdir = false;
|
1999-12-15 17:42:22 +00:00
|
|
|
MenuRunLaTeX(buffer);
|
2000-03-12 10:35:05 +00:00
|
|
|
lyxrc.use_tempdir = flag;
|
1999-12-15 17:42:22 +00:00
|
|
|
}
|
|
|
|
// postscript
|
|
|
|
else if (extyp == "postscript") {
|
1999-12-16 06:43:25 +00:00
|
|
|
// Start Print-dialog. Not as good as dvi... Bernhard.
|
1999-12-15 17:42:22 +00:00
|
|
|
MenuPrint(buffer);
|
|
|
|
// Since the MenuPrint is a pop-up, we can't use
|
|
|
|
// the same trick as above. (Asger)
|
|
|
|
// MISSING: Move of ps-file :-(
|
2000-01-07 03:42:16 +00:00
|
|
|
// And MenuPrint should not be used for this at all...
|
1999-12-15 17:42:22 +00:00
|
|
|
}
|
|
|
|
// ascii
|
|
|
|
else if (extyp == "ascii") {
|
|
|
|
MenuMakeAscii(buffer);
|
|
|
|
}
|
|
|
|
else if (extyp == "custom") {
|
|
|
|
MenuSendto();
|
|
|
|
}
|
|
|
|
// HTML
|
|
|
|
else if (extyp == "html") {
|
|
|
|
MenuMakeHTML(buffer);
|
|
|
|
}
|
2000-03-20 18:55:57 +00:00
|
|
|
// HTML from linuxdoc
|
|
|
|
else if (extyp == "html-linuxdoc") {
|
|
|
|
MenuMakeHTML_LinuxDoc(buffer);
|
|
|
|
}
|
|
|
|
// HTML from docbook
|
|
|
|
else if (extyp == "html-docbook") {
|
|
|
|
MenuMakeHTML_DocBook(buffer);
|
|
|
|
}
|
1999-12-15 17:42:22 +00:00
|
|
|
else {
|
2000-03-20 16:37:50 +00:00
|
|
|
ShowMessage(buffer, _("Unknown export type: ") + extyp);
|
1999-12-15 17:42:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
void QuitLyX()
|
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Running QuitLyX." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!bufferlist.QwriteAll())
|
|
|
|
return;
|
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
lastfiles->writeFile(lyxrc.lastfiles);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Set a flag that we do quitting from the program,
|
|
|
|
// so no refreshes are necessary.
|
|
|
|
quitting = true;
|
|
|
|
|
|
|
|
// close buffers first
|
|
|
|
bufferlist.closeAll();
|
|
|
|
|
|
|
|
// do any other cleanup procedures now
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
DestroyLyXTmpDir(system_tempdir);
|
|
|
|
|
|
|
|
finished = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
void AutoSave(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
// should probably be moved into BufferList (Lgb)
|
|
|
|
// Perfect target for a thread...
|
|
|
|
{
|
2000-04-11 22:55:29 +00:00
|
|
|
if (!bv->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
if (bv->buffer()->isBakClean()
|
|
|
|
|| bv->buffer()->isReadonly()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// We don't save now, but we'll try again later
|
2000-04-11 22:55:29 +00:00
|
|
|
bv->owner()->resetAutosaveTimer();
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// create autosave filename
|
2000-04-11 22:55:29 +00:00
|
|
|
string fname = OnlyPath(bv->buffer()->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
fname += "#";
|
2000-04-11 22:55:29 +00:00
|
|
|
fname += OnlyFilename(bv->buffer()->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
fname += "#";
|
|
|
|
|
|
|
|
// tmp_ret will be located (usually) in /tmp
|
|
|
|
// will that be a problem?
|
1999-10-02 16:21:10 +00:00
|
|
|
string tmp_ret = tmpnam(0);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
pid_t pid = fork(); // If you want to debug the autosave
|
|
|
|
// you should set pid to -1, and comment out the
|
|
|
|
// fork.
|
|
|
|
if (pid == 0 || pid == -1) {
|
|
|
|
// pid = -1 signifies that lyx was unable
|
|
|
|
// to fork. But we will do the save
|
|
|
|
// anyway.
|
|
|
|
bool failed = false;
|
|
|
|
if (!tmp_ret.empty()) {
|
2000-04-11 22:55:29 +00:00
|
|
|
bv->buffer()->writeFile(tmp_ret, 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
// assume successful write of tmp_ret
|
|
|
|
if (rename(tmp_ret.c_str(), fname.c_str()) == -1) {
|
|
|
|
failed = true;
|
|
|
|
// most likely couldn't move between filesystems
|
|
|
|
// unless write of tmp_ret failed
|
|
|
|
// so remove tmp file (if it exists)
|
|
|
|
remove(tmp_ret.c_str());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (failed) {
|
|
|
|
// failed to write/rename tmp_ret so try writing direct
|
2000-04-11 22:55:29 +00:00
|
|
|
if (!bv->buffer()->writeFile(fname, 1)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// It is dangerous to do this in the child,
|
|
|
|
// but safe in the parent, so...
|
|
|
|
if (pid == -1)
|
2000-04-11 22:55:29 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pid == 0) { // we are the child so...
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
bv->buffer()->markBakClean();
|
|
|
|
bv->owner()->resetAutosaveTimer();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
2000-03-09 03:36:48 +00:00
|
|
|
// Copyright CHT Software Service GmbH
|
1999-09-27 18:44:28 +00:00
|
|
|
// Uwe C. Schroeder
|
|
|
|
//
|
|
|
|
// create new file with template
|
|
|
|
// SERVERCMD !
|
|
|
|
//
|
1999-10-02 16:21:10 +00:00
|
|
|
Buffer * NewLyxFile(string const & filename)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// Split argument by :
|
1999-10-02 16:21:10 +00:00
|
|
|
string name;
|
1999-11-01 04:22:28 +00:00
|
|
|
string tmpname = split(filename, name, ':');
|
1999-09-27 18:44:28 +00:00
|
|
|
#ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
|
1999-11-01 04:22:28 +00:00
|
|
|
if (name.length() == 1
|
|
|
|
&& isalpha(static_cast<unsigned char>(name[0]))
|
|
|
|
&& (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
|
1999-09-27 18:44:28 +00:00
|
|
|
name += ':';
|
1999-11-01 04:22:28 +00:00
|
|
|
name += token(tmpname, ':', 0);
|
|
|
|
tmpname = split(tmpname, ':');
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
#endif
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Arg is " << filename
|
|
|
|
<< "\nName is " << name
|
|
|
|
<< "\nTemplate is " << tmpname << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// find a free buffer
|
1999-11-26 06:57:35 +00:00
|
|
|
Buffer * tmpbuf = bufferlist.newFile(name, tmpname);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (tmpbuf)
|
1999-12-10 00:07:59 +00:00
|
|
|
lastfiles->newFile(tmpbuf->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
return tmpbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Insert ascii file (if filename is empty, prompt for one)
|
2000-03-17 10:14:46 +00:00
|
|
|
void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string fname = f;
|
1999-09-27 18:44:28 +00:00
|
|
|
LyXFileDlg fileDlg;
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
if (!bv->available()) return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fname.empty()) {
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(bv);
|
1999-09-27 18:44:28 +00:00
|
|
|
fname = fileDlg.Select(_("File to Insert"),
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->owner()->buffer()->filepath,
|
1999-09-27 18:44:28 +00:00
|
|
|
"*");
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(bv);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fname.empty()) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FileInfo fi(fname);
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
if (!fi.readable()) {
|
|
|
|
WriteFSAlert(_("Error! Specified file is unreadable: "),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(fname, 50));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-11-24 22:14:46 +00:00
|
|
|
|
2000-01-06 02:44:26 +00:00
|
|
|
ifstream ifs(fname.c_str());
|
|
|
|
if (!ifs) {
|
1999-11-24 22:14:46 +00:00
|
|
|
WriteFSAlert(_("Error! Cannot open specified file: "),
|
|
|
|
MakeDisplayPath(fname, 50));
|
|
|
|
return;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
ifs.unsetf(ios::skipws);
|
|
|
|
istream_iterator<char> ii(ifs);
|
|
|
|
istream_iterator<char> end;
|
2000-03-17 10:14:46 +00:00
|
|
|
//string tmpstr(ii, end); // yet a reason for using std::string
|
2000-03-16 04:29:22 +00:00
|
|
|
// alternate approach to get the file into a string:
|
2000-03-17 10:14:46 +00:00
|
|
|
string tmpstr;
|
|
|
|
copy(ii, end, back_inserter(tmpstr));
|
1999-09-27 18:44:28 +00:00
|
|
|
// insert the string
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// clear the selection
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
if (!asParagraph)
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->text->InsertStringA(tmpstr);
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->text->InsertStringB(tmpstr);
|
|
|
|
bv->update(1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuShowTableOfContents()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
TocUpdateCB(0, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_toc->form_toc->visible) {
|
|
|
|
fl_raise_form(fd_form_toc->form_toc);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_toc->form_toc,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
|
|
|
_("Table Of Contents"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_toc->form_toc->w;
|
|
|
|
oh = fd_form_toc->form_toc->h;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuInsertLabel(char const * arg)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string label = arg;
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(current_view);
|
1999-12-30 02:35:43 +00:00
|
|
|
if (label.empty()) {
|
|
|
|
pair<bool, string>
|
|
|
|
result = askForText(_("Enter new label to insert:"));
|
|
|
|
if (result.first) {
|
|
|
|
label = frontStrip(strip(result.second));
|
|
|
|
}
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!label.empty()) {
|
1999-11-22 16:19:48 +00:00
|
|
|
InsetLabel * new_inset = new InsetLabel;
|
1999-09-27 18:44:28 +00:00
|
|
|
new_inset->setContents(label);
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuInsertRef()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
RefUpdateCB(0, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_ref->form_ref->visible) {
|
|
|
|
fl_raise_form(fd_form_ref->form_ref);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_ref->form_ref,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
|
|
|
_("Insert Reference"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_ref->form_ref->w;
|
|
|
|
oh = fd_form_ref->form_ref->h;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_form_minsize(fd_form_ref->form_ref, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuPasteSelection(char at)
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ascii_type = at;
|
|
|
|
|
|
|
|
Atom data_prop = XInternAtom(fl_display,
|
|
|
|
"LyX_Primary",
|
|
|
|
false);
|
|
|
|
if (data_prop == None)
|
|
|
|
return;
|
|
|
|
XConvertSelection(fl_display,
|
|
|
|
XA_PRIMARY, XA_STRING, data_prop,
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getForm()->window, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
XFlush(fl_display);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// candidate for move to LyXView
|
2000-02-04 09:38:32 +00:00
|
|
|
// This is only used in toolbar.C
|
1999-09-27 18:44:28 +00:00
|
|
|
void LayoutsCB(int sel, void *)
|
|
|
|
{
|
1999-10-19 10:32:10 +00:00
|
|
|
string tmp = tostr(sel);
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
|
1999-12-16 06:43:25 +00:00
|
|
|
tmp.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SGML Linuxdoc support:
|
|
|
|
* (flag == 0) make TeX output
|
|
|
|
* (flag == 1) make dvi output
|
|
|
|
*/
|
2000-03-17 10:14:46 +00:00
|
|
|
int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string s2;
|
|
|
|
string add_flags;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
int errorcode = 0;
|
|
|
|
|
|
|
|
/* generate a path-less extension name */
|
2000-05-11 16:12:46 +00:00
|
|
|
string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
|
2000-03-17 10:14:46 +00:00
|
|
|
string path = OnlyPath (filename);
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
2000-03-17 10:14:46 +00:00
|
|
|
path = bv->buffer()->tmppath;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-17 17:17:43 +00:00
|
|
|
if (!bv->available())
|
|
|
|
return 0;
|
|
|
|
bv->buffer()->makeLinuxDocFile(name, 0);
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
|
|
// CHECK remove this once we have a proper geometry class
|
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
BufferParams::PAPER_SIZE ps =
|
|
|
|
static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
|
2000-03-17 17:17:43 +00:00
|
|
|
switch (ps) {
|
|
|
|
case BufferParams::PAPER_A4PAPER:
|
|
|
|
add_flags = "-p a4";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_USLETTER:
|
|
|
|
add_flags = "-p letter";
|
|
|
|
break;
|
|
|
|
default: /* nothing to be done yet ;-) */ break;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(bv);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
Systemcalls one;
|
|
|
|
switch (flag) {
|
|
|
|
case 0: /* TeX output asked */
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
|
2000-03-20 18:55:57 +00:00
|
|
|
s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name;
|
1999-10-12 21:37:10 +00:00
|
|
|
if (one.startscript(Systemcalls::System, s2))
|
1999-09-27 18:44:28 +00:00
|
|
|
errorcode = 1;
|
|
|
|
break;
|
|
|
|
case 1: /* dvi output asked */
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
|
2000-03-20 18:55:57 +00:00
|
|
|
s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
|
1999-10-12 21:37:10 +00:00
|
|
|
if (one.startscript(Systemcalls::System, s2)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
errorcode = 1;
|
|
|
|
} else
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->buffer()->markDviClean();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
default: /* unknown output */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(bv);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
bv->buffer()->redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
return errorcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SGML DocBook support:
|
|
|
|
* (flag == 1) make dvi output
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
int RunDocBook(int flag, string const & filename)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
/* generate a path-less extension name */
|
2000-05-11 16:12:46 +00:00
|
|
|
string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
|
1999-11-26 06:57:35 +00:00
|
|
|
string path = OnlyPath (filename);
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
1999-11-09 23:52:04 +00:00
|
|
|
path = current_view->buffer()->tmppath;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!current_view->available())
|
|
|
|
return 0;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
current_view->buffer()->makeDocBookFile(name, 0);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
|
|
// Shall this code go or should it stay? (Lgb)
|
2000-03-20 18:55:57 +00:00
|
|
|
// This code is a placeholder for future implementation. (Jose')
|
1999-11-04 01:40:20 +00:00
|
|
|
// string add_flags;
|
1999-11-09 23:52:04 +00:00
|
|
|
// LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize;
|
1999-11-04 01:40:20 +00:00
|
|
|
// switch (ps) {
|
1999-11-15 12:01:38 +00:00
|
|
|
// case BufferParams::PAPER_A4PAPER: add_flags = "-p a4"; break;
|
|
|
|
// case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break;
|
1999-11-04 01:40:20 +00:00
|
|
|
// default: /* nothing to be done yet ;-) */ break;
|
|
|
|
// }
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int errorcode = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
Systemcalls one;
|
|
|
|
switch (flag) {
|
|
|
|
case 1: /* dvi output asked */
|
1999-11-26 06:57:35 +00:00
|
|
|
{
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file..."));
|
2000-03-20 18:55:57 +00:00
|
|
|
string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
|
1999-10-12 21:37:10 +00:00
|
|
|
if (one.startscript(Systemcalls::System, s2)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
errorcode = 1;
|
|
|
|
} else
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDviClean();
|
1999-11-26 06:57:35 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
default: /* unknown output */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
return errorcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuLayoutCharacter()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_character->form_character->visible) {
|
|
|
|
fl_raise_form(fd_form_character->form_character);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_character->form_character,
|
1999-11-15 12:01:38 +00:00
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Character Style"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_character->form_character->w;
|
|
|
|
oh = fd_form_character->form_character->h;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_form_minsize(fd_form_character->form_character, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-07 01:14:37 +00:00
|
|
|
inline
|
|
|
|
void DeactivateParagraphButtons ()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_deactivate_object (fd_form_paragraph->button_ok);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->button_apply);
|
|
|
|
fl_set_object_lcol (fd_form_paragraph->button_ok, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol (fd_form_paragraph->button_apply, FL_INACTIVE);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
2000-03-07 01:14:37 +00:00
|
|
|
inline
|
|
|
|
void ActivateParagraphButtons ()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_activate_object (fd_form_paragraph->button_ok);
|
|
|
|
fl_activate_object (fd_form_paragraph->button_apply);
|
|
|
|
fl_set_object_lcol (fd_form_paragraph->button_ok, FL_BLACK);
|
|
|
|
fl_set_object_lcol (fd_form_paragraph->button_apply, FL_BLACK);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
2000-03-07 01:14:37 +00:00
|
|
|
inline
|
|
|
|
void DisableParagraphLayout ()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
DeactivateParagraphButtons();
|
|
|
|
fl_deactivate_object (fd_form_paragraph->input_labelwidth);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_lines_top);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_lines_bottom);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_pagebreaks_top);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_pagebreaks_bottom);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_noindent);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->group_radio_alignment);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->radio_align_right);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->radio_align_left);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->radio_align_block);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->radio_align_center);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->input_space_above);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->input_space_below);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->choice_space_above);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->choice_space_below);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_space_above);
|
|
|
|
fl_deactivate_object (fd_form_paragraph->check_space_below);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
2000-03-07 01:14:37 +00:00
|
|
|
inline
|
|
|
|
void EnableParagraphLayout ()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
fl_activate_object (fd_form_paragraph->input_labelwidth);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_lines_top);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_lines_bottom);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_pagebreaks_top);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_pagebreaks_bottom);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_noindent);
|
|
|
|
fl_activate_object (fd_form_paragraph->group_radio_alignment);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_right);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_left);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_block);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_center);
|
|
|
|
fl_activate_object (fd_form_paragraph->input_space_above);
|
|
|
|
fl_activate_object (fd_form_paragraph->input_space_below);
|
|
|
|
fl_activate_object (fd_form_paragraph->choice_space_above);
|
|
|
|
fl_activate_object (fd_form_paragraph->choice_space_below);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_space_above);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_space_below);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
bool UpdateLayoutParagraph()
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()) {
|
1999-12-10 00:07:59 +00:00
|
|
|
if (fd_form_paragraph->form_paragraph->visible)
|
|
|
|
fl_hide_form(fd_form_paragraph->form_paragraph);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffer * buf = current_view->buffer();
|
|
|
|
|
|
|
|
fl_set_input(fd_form_paragraph->input_labelwidth,
|
|
|
|
current_view->text->cursor.par->GetLabelWidthString().c_str());
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_right, 0);
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_left, 0);
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_center, 0);
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_block, 0);
|
|
|
|
|
|
|
|
int align = current_view->text->cursor.par->GetAlign();
|
|
|
|
if (align == LYX_ALIGN_LAYOUT)
|
|
|
|
align = textclasslist.Style(buf->params.textclass,
|
1999-12-16 06:43:25 +00:00
|
|
|
current_view->text->cursor.par->GetLayout()).align;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
switch (align) {
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_right, 1);
|
|
|
|
break;
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_left, 1);
|
|
|
|
break;
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_center, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_block, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_set_button(fd_form_paragraph->check_lines_top,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->line_top);
|
|
|
|
fl_set_button(fd_form_paragraph->check_lines_bottom,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
|
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
|
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
|
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->noindent);
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_above, "");
|
|
|
|
|
|
|
|
switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
|
|
|
|
case VSpace::NONE:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
|
|
|
|
break;
|
|
|
|
case VSpace::DEFSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 2);
|
|
|
|
break;
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 3);
|
|
|
|
break;
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 4);
|
|
|
|
break;
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 5);
|
|
|
|
break;
|
|
|
|
case VSpace::VFILL:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 6);
|
|
|
|
break;
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 7);
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_above,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_above,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_below, "");
|
|
|
|
switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
|
|
|
|
case VSpace::NONE:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
1);
|
|
|
|
break;
|
|
|
|
case VSpace::DEFSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
2);
|
|
|
|
break;
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
3);
|
|
|
|
break;
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
4);
|
|
|
|
break;
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
5);
|
|
|
|
break;
|
|
|
|
case VSpace::VFILL:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
6);
|
|
|
|
break;
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
7);
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_below,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_below,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
|
|
|
|
|
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->noindent);
|
|
|
|
|
|
|
|
if (current_view->buffer()->isReadonly()) {
|
|
|
|
DisableParagraphLayout();
|
|
|
|
} else {
|
|
|
|
EnableParagraphLayout();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutParagraph()
|
|
|
|
{
|
|
|
|
if (UpdateLayoutParagraph()) {
|
|
|
|
if (fd_form_paragraph->form_paragraph->visible) {
|
|
|
|
fl_raise_form(fd_form_paragraph->form_paragraph);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_paragraph->form_paragraph,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Paragraph Environment"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void DeactivateDocumentButtons ()
|
|
|
|
{
|
|
|
|
fl_deactivate_object (fd_form_document->button_ok);
|
|
|
|
fl_deactivate_object (fd_form_document->button_apply);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_ok, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_apply, FL_INACTIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void ActivateDocumentButtons ()
|
|
|
|
{
|
|
|
|
fl_activate_object (fd_form_document->button_ok);
|
|
|
|
fl_activate_object (fd_form_document->button_apply);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_ok, FL_BLACK);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_apply, FL_BLACK);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline
|
|
|
|
void DisableDocumentLayout ()
|
|
|
|
{
|
|
|
|
DeactivateDocumentButtons ();
|
|
|
|
fl_deactivate_object (fd_form_document->group_radio_separation);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_indent);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_skip);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_class);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_pagestyle);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_fonts);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_fontsize);
|
|
|
|
fl_deactivate_object (fd_form_document->input_float_placement);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_postscript_driver);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_inputenc);
|
|
|
|
fl_deactivate_object (fd_form_document->group_radio_sides);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_sides_one);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_sides_two);
|
|
|
|
fl_deactivate_object (fd_form_document->group_radio_columns);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_columns_one);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_columns_two);
|
|
|
|
fl_deactivate_object (fd_form_document->input_extra);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_language);
|
|
|
|
combo_language->deactivate();
|
|
|
|
fl_deactivate_object (fd_form_document->input_default_skip);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_default_skip);
|
|
|
|
fl_deactivate_object (fd_form_document->slider_secnumdepth);
|
|
|
|
fl_deactivate_object (fd_form_document->slider_tocdepth);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_spacing);
|
|
|
|
fl_deactivate_object (fd_form_document->input_spacing);
|
|
|
|
fl_deactivate_object (fd_form_document->check_use_amsmath);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline
|
|
|
|
void EnableDocumentLayout ()
|
|
|
|
{
|
|
|
|
ActivateDocumentButtons ();
|
|
|
|
fl_activate_object (fd_form_document->group_radio_separation);
|
|
|
|
fl_activate_object (fd_form_document->radio_indent);
|
|
|
|
fl_activate_object (fd_form_document->radio_skip);
|
|
|
|
fl_activate_object (fd_form_document->choice_class);
|
|
|
|
fl_activate_object (fd_form_document->choice_pagestyle);
|
|
|
|
fl_activate_object (fd_form_document->choice_fonts);
|
|
|
|
fl_activate_object (fd_form_document->choice_fontsize);
|
|
|
|
fl_activate_object (fd_form_document->input_float_placement);
|
|
|
|
fl_activate_object (fd_form_document->choice_postscript_driver);
|
|
|
|
fl_activate_object (fd_form_document->choice_inputenc);
|
|
|
|
fl_activate_object (fd_form_document->group_radio_sides);
|
|
|
|
fl_activate_object (fd_form_document->radio_sides_one);
|
|
|
|
fl_activate_object (fd_form_document->radio_sides_two);
|
|
|
|
fl_activate_object (fd_form_document->group_radio_columns);
|
|
|
|
fl_activate_object (fd_form_document->radio_columns_one);
|
|
|
|
fl_activate_object (fd_form_document->radio_columns_two);
|
|
|
|
fl_activate_object (fd_form_document->input_extra);
|
|
|
|
fl_activate_object (fd_form_document->choice_language);
|
|
|
|
combo_language->activate();
|
|
|
|
fl_activate_object (fd_form_document->input_default_skip);
|
|
|
|
fl_activate_object (fd_form_document->choice_default_skip);
|
|
|
|
fl_activate_object (fd_form_document->slider_secnumdepth);
|
|
|
|
fl_activate_object (fd_form_document->slider_tocdepth);
|
|
|
|
fl_activate_object (fd_form_document->choice_spacing);
|
|
|
|
fl_activate_object (fd_form_document->input_spacing);
|
|
|
|
fl_activate_object (fd_form_document->check_use_amsmath);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
|
|
|
bool UpdateLayoutDocument(BufferParams * params)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_document->form_document->visible)
|
|
|
|
fl_hide_form(fd_form_document->form_document);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
if (params == 0)
|
1999-11-09 23:52:04 +00:00
|
|
|
params = ¤t_view->buffer()->params;
|
1999-11-04 01:40:20 +00:00
|
|
|
LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_choice_text(fd_form_document->choice_class,
|
1999-11-04 01:40:20 +00:00
|
|
|
textclasslist.DescOfClass(params->textclass).c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
combo_language->select_text(params->language.c_str());
|
|
|
|
|
|
|
|
fl_set_choice_text(fd_form_document->choice_fonts,
|
|
|
|
params->fonts.c_str());
|
|
|
|
fl_set_choice_text(fd_form_document->choice_inputenc,
|
|
|
|
params->inputenc.c_str());
|
|
|
|
fl_set_choice_text(fd_form_document->choice_postscript_driver,
|
|
|
|
params->graphicsDriver.c_str());
|
|
|
|
|
|
|
|
// ale970405+lasgoutt970513
|
|
|
|
fl_clear_choice(fd_form_document->choice_fontsize);
|
|
|
|
fl_addto_choice(fd_form_document->choice_fontsize, "default");
|
|
|
|
fl_addto_choice(fd_form_document->choice_fontsize,
|
1999-11-04 01:40:20 +00:00
|
|
|
tclass.opt_fontsize().c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_choice(fd_form_document->choice_fontsize,
|
1999-11-04 01:40:20 +00:00
|
|
|
tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// ale970405+lasgoutt970513
|
|
|
|
fl_clear_choice(fd_form_document->choice_pagestyle);
|
|
|
|
fl_addto_choice(fd_form_document->choice_pagestyle, "default");
|
|
|
|
fl_addto_choice(fd_form_document->choice_pagestyle,
|
1999-11-04 01:40:20 +00:00
|
|
|
tclass.opt_pagestyle().c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_choice(fd_form_document->choice_pagestyle,
|
1999-11-04 01:40:20 +00:00
|
|
|
tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_button(fd_form_document->radio_indent, 0);
|
|
|
|
fl_set_button(fd_form_document->radio_skip, 0);
|
|
|
|
|
|
|
|
|
|
|
|
fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath);
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
if (params->paragraph_separation == BufferParams::PARSEP_INDENT)
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_document->radio_indent, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_document->radio_skip, 1);
|
|
|
|
|
|
|
|
switch (params->getDefSkip().kind()) {
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 1);
|
|
|
|
break;
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 2);
|
|
|
|
break;
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 3);
|
|
|
|
break;
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 4);
|
|
|
|
fl_set_input (fd_form_document->input_default_skip,
|
|
|
|
params->getDefSkip().asLyXCommand().c_str());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_set_button(fd_form_document->radio_sides_one, 0);
|
|
|
|
fl_set_button(fd_form_document->radio_sides_two, 0);
|
|
|
|
|
2000-01-28 11:50:57 +00:00
|
|
|
switch (params->sides) {
|
|
|
|
case LyXTextClass::OneSide:
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_document->radio_sides_one, 1);
|
2000-01-28 11:50:57 +00:00
|
|
|
break;
|
|
|
|
case LyXTextClass::TwoSides:
|
|
|
|
fl_set_button(fd_form_document->radio_sides_two, 1);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_button(fd_form_document->radio_columns_one, 0);
|
|
|
|
fl_set_button(fd_form_document->radio_columns_two, 0);
|
|
|
|
|
|
|
|
if (params->columns == 2)
|
|
|
|
fl_set_button(fd_form_document->radio_columns_two, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_document->radio_columns_one, 1);
|
|
|
|
|
|
|
|
fl_set_input(fd_form_document->input_spacing, "");
|
|
|
|
switch (params->spacing.getSpace()) {
|
2000-04-11 22:55:29 +00:00
|
|
|
case Spacing::Default: // nothing bad should happen with this
|
1999-09-27 18:44:28 +00:00
|
|
|
case Spacing::Single:
|
1999-11-26 06:57:35 +00:00
|
|
|
{
|
|
|
|
// \singlespacing
|
|
|
|
fl_set_choice(fd_form_document->choice_spacing, 1);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
case Spacing::Onehalf:
|
1999-11-26 06:57:35 +00:00
|
|
|
{
|
|
|
|
// \onehalfspacing
|
|
|
|
fl_set_choice(fd_form_document->choice_spacing, 2);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
case Spacing::Double:
|
1999-11-26 06:57:35 +00:00
|
|
|
{
|
|
|
|
// \ doublespacing
|
|
|
|
fl_set_choice(fd_form_document->choice_spacing, 3);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
case Spacing::Other:
|
1999-11-26 06:57:35 +00:00
|
|
|
{
|
|
|
|
fl_set_choice(fd_form_document->choice_spacing, 4);
|
2000-03-08 01:45:25 +00:00
|
|
|
//char sval[20];
|
|
|
|
//sprintf(sval, "%g", params->spacing.getValue());
|
|
|
|
#ifdef HAVE_SSTREAM
|
2000-04-04 00:19:15 +00:00
|
|
|
std::ostringstream sval;
|
2000-03-08 01:45:25 +00:00
|
|
|
sval << params->spacing.getValue(); // setw?
|
|
|
|
fl_set_input(fd_form_document->input_spacing,
|
|
|
|
sval.str().c_str());
|
|
|
|
#else
|
|
|
|
char tval[20];
|
|
|
|
ostrstream sval(tval, 20);
|
|
|
|
sval << params->spacing.getValue() << '\0'; // setw?
|
|
|
|
fl_set_input(fd_form_document->input_spacing, sval.str());
|
|
|
|
#endif
|
1999-11-26 06:57:35 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fl_set_counter_value(fd_form_document->slider_secnumdepth,
|
|
|
|
params->secnumdepth);
|
|
|
|
fl_set_counter_value(fd_form_document->slider_tocdepth,
|
|
|
|
params->tocdepth);
|
|
|
|
if (!params->float_placement.empty()) { // buffer local (Lgb)
|
|
|
|
fl_set_input(fd_form_document->input_float_placement,
|
|
|
|
params->float_placement.c_str());
|
|
|
|
} else {
|
|
|
|
fl_set_input(fd_form_document->input_float_placement, "");
|
|
|
|
}
|
|
|
|
if (!params->options.empty())
|
|
|
|
fl_set_input(fd_form_document->input_extra,
|
|
|
|
params->options.c_str());
|
|
|
|
else
|
|
|
|
fl_set_input(fd_form_document->input_extra, "");
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isSGML()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// bullets not used in SGML derived documents
|
|
|
|
fl_deactivate_object(fd_form_document->button_bullets);
|
|
|
|
fl_set_object_lcol(fd_form_document->button_bullets,
|
|
|
|
FL_INACTIVE);
|
|
|
|
} else {
|
|
|
|
fl_activate_object(fd_form_document->button_bullets);
|
|
|
|
fl_set_object_lcol(fd_form_document->button_bullets,
|
|
|
|
FL_BLACK);
|
|
|
|
}
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isReadonly()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
DisableDocumentLayout();
|
|
|
|
} else {
|
|
|
|
EnableDocumentLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutDocument()
|
|
|
|
{
|
|
|
|
if (UpdateLayoutDocument()) {
|
|
|
|
if (fd_form_document->form_document->visible) {
|
|
|
|
fl_raise_form(fd_form_document->form_document);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_document->form_document,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Document Layout"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UpdateLayoutQuotes()
|
|
|
|
{
|
|
|
|
bool update = true;
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()
|
1999-11-09 23:52:04 +00:00
|
|
|
|| current_view->buffer()->isReadonly())
|
1999-09-27 18:44:28 +00:00
|
|
|
update = false;
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
fl_set_choice(fd_form_quotes->choice_quotes_language,
|
1999-12-16 06:43:25 +00:00
|
|
|
current_view->buffer()->params.quotes_language + 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_quotes->radio_single, 0);
|
|
|
|
fl_set_button(fd_form_quotes->radio_double, 0);
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ)
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_quotes->radio_single, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_quotes->radio_double, 1);
|
|
|
|
} else if (fd_form_quotes->form_quotes->visible) {
|
|
|
|
fl_hide_form(fd_form_quotes->form_quotes);
|
|
|
|
}
|
|
|
|
return update;
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutQuotes()
|
|
|
|
{
|
|
|
|
if (UpdateLayoutQuotes()) {
|
|
|
|
if (fd_form_quotes->form_quotes->visible) {
|
|
|
|
fl_raise_form(fd_form_quotes->form_quotes);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_quotes->form_quotes,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Quotes"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UpdateLayoutPreamble()
|
|
|
|
{
|
|
|
|
bool update = true;
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-16 06:43:25 +00:00
|
|
|
update = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (update) {
|
|
|
|
fl_set_input(fd_form_preamble->input_preamble,
|
1999-12-16 06:43:25 +00:00
|
|
|
current_view->buffer()->params.preamble.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isReadonly()) {
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_deactivate_object(fd_form_preamble->input_preamble);
|
|
|
|
fl_deactivate_object(fd_form_preamble->button_ok);
|
|
|
|
fl_deactivate_object(fd_form_preamble->button_apply);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_activate_object(fd_form_preamble->input_preamble);
|
|
|
|
fl_activate_object(fd_form_preamble->button_ok);
|
|
|
|
fl_activate_object(fd_form_preamble->button_apply);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else if (fd_form_preamble->form_preamble->visible) {
|
|
|
|
fl_hide_form(fd_form_preamble->form_preamble);
|
|
|
|
}
|
|
|
|
return update;
|
|
|
|
}
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutPreamble()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (UpdateLayoutPreamble()) {
|
|
|
|
if (fd_form_preamble->form_preamble->visible) {
|
|
|
|
fl_raise_form(fd_form_preamble->form_preamble);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_preamble->form_preamble,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE,
|
|
|
|
FL_FULLBORDER,
|
|
|
|
_("LaTeX Preamble"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_preamble->form_preamble->w;
|
|
|
|
oh = fd_form_preamble->form_preamble->h;
|
|
|
|
}
|
|
|
|
fl_set_form_minsize(fd_form_preamble->form_preamble,
|
1999-11-15 12:01:38 +00:00
|
|
|
ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutSave()
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (AskQuestion(_("Do you want to save the current settings"),
|
|
|
|
_("for Character, Document, Paper and Quotes"),
|
|
|
|
_("as default for new documents?")))
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->saveParamsAsDefaults();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
|
|
|
|
// Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
|
|
|
|
LyXFont UserFreeFont()
|
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int pos = fl_get_choice(fd_form_character->choice_family);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
|
|
|
|
case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
|
|
|
|
case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
|
|
|
|
case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
|
|
|
|
case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_series);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
|
|
|
|
case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
|
|
|
|
case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
|
|
|
|
case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_shape);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
|
|
|
|
case 2: font.setShape(LyXFont::UP_SHAPE); break;
|
|
|
|
case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
|
|
|
|
case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
|
|
|
|
case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
|
|
|
|
case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_size);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
|
|
|
|
case 2: font.setSize(LyXFont::SIZE_TINY); break;
|
|
|
|
case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
|
|
|
|
case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
|
|
|
|
case 5: font.setSize(LyXFont::SIZE_SMALL); break;
|
|
|
|
case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
|
|
|
|
case 7: font.setSize(LyXFont::SIZE_LARGE); break;
|
|
|
|
case 8: font.setSize(LyXFont::SIZE_LARGER); break;
|
|
|
|
case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
|
|
|
|
case 10: font.setSize(LyXFont::SIZE_HUGE); break;
|
|
|
|
case 11: font.setSize(LyXFont::SIZE_HUGER); break;
|
|
|
|
case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
|
|
|
|
case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
|
|
|
|
case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_bar);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setEmph(LyXFont::IGNORE);
|
|
|
|
font.setUnderbar(LyXFont::IGNORE);
|
|
|
|
font.setNoun(LyXFont::IGNORE);
|
|
|
|
font.setLatex(LyXFont::IGNORE);
|
|
|
|
break;
|
|
|
|
case 2: font.setEmph(LyXFont::TOGGLE); break;
|
|
|
|
case 3: font.setUnderbar(LyXFont::TOGGLE); break;
|
|
|
|
case 4: font.setNoun(LyXFont::TOGGLE); break;
|
|
|
|
case 5: font.setLatex(LyXFont::TOGGLE); break;
|
|
|
|
case 6: font.setEmph(LyXFont::INHERIT);
|
|
|
|
font.setUnderbar(LyXFont::INHERIT);
|
|
|
|
font.setNoun(LyXFont::INHERIT);
|
|
|
|
font.setLatex(LyXFont::INHERIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_color);
|
2000-02-10 17:53:36 +00:00
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setColor(LColor::ignore); break;
|
|
|
|
case 2: font.setColor(LColor::none); break;
|
|
|
|
case 3: font.setColor(LColor::black); break;
|
|
|
|
case 4: font.setColor(LColor::white); break;
|
|
|
|
case 5: font.setColor(LColor::red); break;
|
|
|
|
case 6: font.setColor(LColor::green); break;
|
|
|
|
case 7: font.setColor(LColor::blue); break;
|
|
|
|
case 8: font.setColor(LColor::cyan); break;
|
|
|
|
case 9: font.setColor(LColor::magenta); break;
|
|
|
|
case 10: font.setColor(LColor::yellow); break;
|
|
|
|
case 11: font.setColor(LColor::inherit); break;
|
|
|
|
}
|
2000-02-17 19:59:08 +00:00
|
|
|
|
2000-04-17 14:00:18 +00:00
|
|
|
string language = combo_language2->getline();
|
|
|
|
Languages::iterator lit = languages.find(language);
|
|
|
|
if (lit != languages.end())
|
|
|
|
font.setLanguage(&(*lit).second);
|
|
|
|
else
|
|
|
|
font.setLanguage(ignore_language);
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_title */
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TimerCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// only if the form still exists
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.show_banner && fd_form_title->form_title != 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_title->form_title->visible) {
|
|
|
|
fl_hide_form(fd_form_title->form_title);
|
|
|
|
}
|
|
|
|
fl_free_form(fd_form_title->form_title);
|
1999-10-02 16:21:10 +00:00
|
|
|
fd_form_title->form_title = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_paragraph */
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long )
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// "Synchronize" the choices and input fields, making it
|
|
|
|
// impossible to commit senseless data.
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
FD_form_paragraph const * fp = fd_form_paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (obj == fp->choice_space_above) {
|
|
|
|
if (fl_get_choice (fp->choice_space_above) != 7) {
|
|
|
|
fl_set_input (fp->input_space_above, "");
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fp->choice_space_below) {
|
|
|
|
if (fl_get_choice (fp->choice_space_below) != 7) {
|
|
|
|
fl_set_input (fp->input_space_below, "");
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fp->input_space_above) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string input = fl_get_input (fp->input_space_above);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (input.empty()) {
|
|
|
|
fl_set_choice (fp->choice_space_above, 1);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else if (isValidGlueLength (input)) {
|
|
|
|
fl_set_choice (fp->choice_space_above, 7);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_set_choice (fp->choice_space_above, 7);
|
|
|
|
DeactivateParagraphButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fp->input_space_below) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string input = fl_get_input (fp->input_space_below);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (input.empty()) {
|
|
|
|
fl_set_choice (fp->choice_space_below, 1);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else if (isValidGlueLength (input)) {
|
|
|
|
fl_set_choice (fp->choice_space_below, 7);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_set_choice (fp->choice_space_below, 7);
|
|
|
|
DeactivateParagraphButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
VSpace space_top, space_bottom;
|
1999-11-04 01:40:20 +00:00
|
|
|
LyXAlignment align;
|
1999-10-02 16:21:10 +00:00
|
|
|
string labelwidthstring;
|
1999-09-27 18:44:28 +00:00
|
|
|
bool noindent;
|
|
|
|
|
|
|
|
// If a vspace kind is "Length" but there's no text in
|
|
|
|
// the input field, reset the kind to "None".
|
|
|
|
if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
|
|
|
|
&& !*(fl_get_input (fd_form_paragraph->input_space_above))) {
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
|
|
|
|
}
|
|
|
|
if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7
|
|
|
|
&& !*(fl_get_input (fd_form_paragraph->input_space_below))) {
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below, 1);
|
|
|
|
}
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
|
|
|
|
bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
|
|
|
|
bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
|
|
|
|
bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
|
|
|
|
case 1: space_top = VSpace(VSpace::NONE); break;
|
|
|
|
case 2: space_top = VSpace(VSpace::DEFSKIP); break;
|
|
|
|
case 3: space_top = VSpace(VSpace::SMALLSKIP); break;
|
|
|
|
case 4: space_top = VSpace(VSpace::MEDSKIP); break;
|
|
|
|
case 5: space_top = VSpace(VSpace::BIGSKIP); break;
|
|
|
|
case 6: space_top = VSpace(VSpace::VFILL); break;
|
|
|
|
case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break;
|
|
|
|
}
|
|
|
|
if (fl_get_button (fd_form_paragraph->check_space_above))
|
1999-12-16 06:43:25 +00:00
|
|
|
space_top.setKeep (true);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (fl_get_choice (fd_form_paragraph->choice_space_below)) {
|
|
|
|
case 1: space_bottom = VSpace(VSpace::NONE); break;
|
|
|
|
case 2: space_bottom = VSpace(VSpace::DEFSKIP); break;
|
|
|
|
case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break;
|
|
|
|
case 4: space_bottom = VSpace(VSpace::MEDSKIP); break;
|
|
|
|
case 5: space_bottom = VSpace(VSpace::BIGSKIP); break;
|
|
|
|
case 6: space_bottom = VSpace(VSpace::VFILL); break;
|
|
|
|
case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break;
|
|
|
|
}
|
|
|
|
if (fl_get_button (fd_form_paragraph->check_space_below))
|
1999-12-16 06:43:25 +00:00
|
|
|
space_bottom.setKeep (true);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fl_get_button(fd_form_paragraph->radio_align_left))
|
|
|
|
align = LYX_ALIGN_LEFT;
|
|
|
|
else if (fl_get_button(fd_form_paragraph->radio_align_right))
|
|
|
|
align = LYX_ALIGN_RIGHT;
|
|
|
|
else if (fl_get_button(fd_form_paragraph->radio_align_center))
|
|
|
|
align = LYX_ALIGN_CENTER;
|
|
|
|
else
|
|
|
|
align = LYX_ALIGN_BLOCK;
|
|
|
|
|
|
|
|
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
|
|
|
|
noindent = fl_get_button(fd_form_paragraph->check_noindent);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->SetParagraph(line_top,
|
|
|
|
line_bottom,
|
|
|
|
pagebreak_top,
|
|
|
|
pagebreak_bottom,
|
|
|
|
space_top,
|
|
|
|
space_bottom,
|
|
|
|
align,
|
|
|
|
labelwidthstring,
|
|
|
|
noindent);
|
|
|
|
current_view->update(1);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_paragraph->form_paragraph);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
ParagraphApplyCB(ob, data);
|
|
|
|
ParagraphCancelCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_character */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void CharacterApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// we set toggleall locally here, since it should be true for
|
|
|
|
// all other uses of ToggleAndShow() (JMarc)
|
|
|
|
toggleall = fl_get_button(fd_form_character->check_toggle_all);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, UserFreeFont());
|
2000-04-17 14:00:18 +00:00
|
|
|
current_view->setState();
|
1999-09-27 18:44:28 +00:00
|
|
|
toggleall = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void CharacterCloseCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_character->form_character);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
CharacterApplyCB(ob, data);
|
|
|
|
CharacterCloseCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_document */
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void UpdateDocumentButtons(BufferParams const & params)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_set_choice(fd_form_document->choice_pagestyle, 1);
|
2000-01-28 11:50:57 +00:00
|
|
|
|
|
|
|
switch (params.sides) {
|
|
|
|
case LyXTextClass::OneSide:
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_document->radio_sides_one, 1);
|
2000-01-28 11:50:57 +00:00
|
|
|
break;
|
|
|
|
case LyXTextClass::TwoSides:
|
|
|
|
fl_set_button(fd_form_document->radio_sides_two, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (params.columns == 2)
|
|
|
|
fl_set_button(fd_form_document->radio_columns_two, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_document->radio_columns_one, 1);
|
|
|
|
|
|
|
|
fl_set_input(fd_form_document->input_extra, params.options.c_str());
|
|
|
|
fl_set_counter_value(fd_form_document->slider_secnumdepth,
|
|
|
|
params.secnumdepth);
|
|
|
|
fl_set_counter_value(fd_form_document->slider_tocdepth,
|
|
|
|
params.tocdepth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-04-11 22:55:29 +00:00
|
|
|
ProhibitInput(current_view);
|
1999-11-04 01:40:20 +00:00
|
|
|
if (textclasslist.Load(fl_get_choice(ob)-1)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (AskQuestion(_("Should I set some parameters to"),
|
|
|
|
fl_get_choice_text(ob),
|
|
|
|
_("the defaults of this document class?"))) {
|
|
|
|
BufferParams params = BufferParams();
|
|
|
|
params.textclass = fl_get_choice(ob)-1;
|
|
|
|
params.useClassDefaults();
|
|
|
|
UpdateLayoutDocument(¶ms);
|
|
|
|
UpdateDocumentButtons(params);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// unable to load new style
|
|
|
|
WriteAlert(_("Conversion Errors!"),
|
|
|
|
_("Unable to switch to new document class."),
|
|
|
|
_("Reverting to original document class."));
|
|
|
|
fl_set_choice(fd_form_document->choice_class,
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->buffer()->params.textclass + 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-04-11 22:55:29 +00:00
|
|
|
AllowInput(current_view);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void DocumentDefskipCB(FL_OBJECT * obj, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// "Synchronize" the choice and the input field, so that it
|
|
|
|
// is impossible to commit senseless data.
|
1999-11-26 06:57:35 +00:00
|
|
|
FD_form_document const * fd = fd_form_document;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (obj == fd->choice_default_skip) {
|
|
|
|
if (fl_get_choice (fd->choice_default_skip) != 4) {
|
|
|
|
fl_set_input (fd->input_default_skip, "");
|
|
|
|
ActivateDocumentButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fd->input_default_skip) {
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
char const * input = fl_get_input (fd->input_default_skip);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!*input) {
|
|
|
|
fl_set_choice (fd->choice_default_skip, 2);
|
|
|
|
ActivateDocumentButtons();
|
|
|
|
} else if (isValidGlueLength (input)) {
|
|
|
|
fl_set_choice (fd->choice_default_skip, 4);
|
|
|
|
ActivateDocumentButtons();
|
|
|
|
} else {
|
|
|
|
fl_set_choice (fd->choice_default_skip, 4);
|
|
|
|
DeactivateDocumentButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void DocumentSpacingCB(FL_OBJECT * obj, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// "Synchronize" the choice and the input field, so that it
|
|
|
|
// is impossible to commit senseless data.
|
1999-11-26 06:57:35 +00:00
|
|
|
FD_form_document const * fd = fd_form_document;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (obj == fd->choice_spacing
|
|
|
|
&& fl_get_choice (fd->choice_spacing) != 4) {
|
|
|
|
fl_set_input(fd->input_spacing, "");
|
|
|
|
} else if (obj == fd->input_spacing) {
|
|
|
|
|
|
|
|
const char* input = fl_get_input (fd->input_spacing);
|
|
|
|
|
|
|
|
if (!*input) {
|
|
|
|
fl_set_choice (fd->choice_spacing, 1);
|
|
|
|
} else {
|
|
|
|
fl_set_choice (fd->choice_spacing, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void DocumentApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
bool redo = false;
|
2000-02-04 09:38:32 +00:00
|
|
|
BufferParams * params = &(current_view->buffer()->params);
|
2000-03-17 10:14:46 +00:00
|
|
|
|
2000-04-10 21:40:13 +00:00
|
|
|
Language const * old_language = params->language_info;
|
2000-03-17 10:14:46 +00:00
|
|
|
params->language = combo_language->getline();
|
|
|
|
Languages::iterator lit = languages.find(params->language);
|
2000-04-26 13:57:28 +00:00
|
|
|
|
|
|
|
Language const * new_language;
|
2000-03-17 10:14:46 +00:00
|
|
|
if (lit != languages.end())
|
2000-04-10 21:40:13 +00:00
|
|
|
new_language = &(*lit).second;
|
2000-03-17 10:14:46 +00:00
|
|
|
else
|
2000-04-10 21:40:13 +00:00
|
|
|
new_language = default_language;
|
|
|
|
|
|
|
|
if (current_view->available()) {
|
|
|
|
if (old_language != new_language &&
|
|
|
|
old_language->RightToLeft == new_language->RightToLeft &&
|
|
|
|
! current_view->buffer()->isMultiLingual() ) {
|
|
|
|
current_view->buffer()->ChangeLanguage(old_language,
|
|
|
|
new_language);
|
|
|
|
current_view->buffer()->redraw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
params->language_info = new_language;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// If default skip is a "Length" but there's no text in the
|
|
|
|
// input field, reset the kind to "Medskip", which is the default.
|
|
|
|
if (fl_get_choice (fd_form_document->choice_default_skip) == 4
|
|
|
|
&& !*(fl_get_input (fd_form_document->input_default_skip))) {
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this shouldn't be done automatically IMO. For example I write german
|
|
|
|
* documents with an american keyboard very often. Matthias */
|
|
|
|
|
|
|
|
/* ChangeKeymap(buffer->parameters.language, TRUE, false,
|
|
|
|
fl_get_choice(fd_form_document->choice_language)); */
|
1999-11-15 12:01:38 +00:00
|
|
|
params->fonts =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_choice_text(fd_form_document->choice_fonts);
|
1999-11-15 12:01:38 +00:00
|
|
|
params->inputenc =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_choice_text(fd_form_document->choice_inputenc);
|
1999-11-15 12:01:38 +00:00
|
|
|
params->fontsize =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_choice_text(fd_form_document->choice_fontsize);
|
1999-11-15 12:01:38 +00:00
|
|
|
params->pagestyle =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_choice_text(fd_form_document->choice_pagestyle);
|
1999-11-15 12:01:38 +00:00
|
|
|
params->graphicsDriver =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_choice_text(fd_form_document->choice_postscript_driver);
|
1999-11-15 12:01:38 +00:00
|
|
|
params->use_amsmath =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_button(fd_form_document->check_use_amsmath);
|
|
|
|
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
2000-04-10 21:40:13 +00:00
|
|
|
|
|
|
|
current_view->text->SetCursor(current_view->text->cursor.par,
|
|
|
|
current_view->text->cursor.pos);
|
|
|
|
current_view->setState();
|
2000-02-03 19:51:27 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
LyXTextClassList::ClassList::size_type new_class =
|
|
|
|
fl_get_choice(fd_form_document->choice_class) - 1;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (params->textclass != new_class) {
|
|
|
|
// try to load new_class
|
1999-11-04 01:40:20 +00:00
|
|
|
if (textclasslist.Load(new_class)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// successfully loaded
|
|
|
|
redo = true;
|
2000-04-10 14:29:05 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->
|
|
|
|
Set(_("Converting document to new document class..."));
|
|
|
|
CutAndPaste cap;
|
|
|
|
int ret = cap.SwitchLayoutsBetweenClasses(
|
|
|
|
current_view->buffer()->params.textclass,
|
|
|
|
new_class,
|
|
|
|
current_view->buffer()->paragraph);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (ret) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string s;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (ret == 1)
|
|
|
|
s = _("One paragraph couldn't be converted");
|
1999-09-27 18:44:28 +00:00
|
|
|
else {
|
1999-10-19 16:48:35 +00:00
|
|
|
s += tostr(ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
s += _(" paragraphs couldn't be converted");
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
WriteAlert(_("Conversion Errors!"), s,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("into chosen document class"));
|
|
|
|
}
|
|
|
|
|
|
|
|
params->textclass = new_class;
|
|
|
|
} else {
|
|
|
|
// problem changing class -- warn user and retain old style
|
|
|
|
WriteAlert(_("Conversion Errors!"),
|
|
|
|
_("Unable to switch to new document class."),
|
|
|
|
_("Reverting to original document class."));
|
|
|
|
fl_set_choice(fd_form_document->choice_class, params->textclass + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char tmpsep = params->paragraph_separation;
|
|
|
|
if (fl_get_button(fd_form_document->radio_indent))
|
1999-11-15 12:01:38 +00:00
|
|
|
params->paragraph_separation = BufferParams::PARSEP_INDENT;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
params->paragraph_separation = BufferParams::PARSEP_SKIP;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (tmpsep != params->paragraph_separation)
|
|
|
|
redo = true;
|
|
|
|
|
|
|
|
VSpace tmpdefskip = params->getDefSkip();
|
|
|
|
switch (fl_get_choice (fd_form_document->choice_default_skip)) {
|
|
|
|
case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break;
|
|
|
|
case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
|
|
|
|
case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break;
|
|
|
|
case 4: params->setDefSkip(
|
|
|
|
VSpace (LyXGlueLength (fl_get_input
|
|
|
|
(fd_form_document->input_default_skip))));
|
|
|
|
break;
|
|
|
|
// DocumentDefskipCB assures that this never happens
|
|
|
|
default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
|
|
|
|
}
|
|
|
|
if (!(tmpdefskip == params->getDefSkip()))
|
|
|
|
redo = true;
|
|
|
|
|
|
|
|
if (fl_get_button(fd_form_document->radio_columns_two))
|
|
|
|
params->columns = 2;
|
|
|
|
else
|
|
|
|
params->columns = 1;
|
|
|
|
if (fl_get_button(fd_form_document->radio_sides_two))
|
1999-11-04 01:40:20 +00:00
|
|
|
params->sides = LyXTextClass::TwoSides;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-11-04 01:40:20 +00:00
|
|
|
params->sides = LyXTextClass::OneSide;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
Spacing tmpSpacing = params->spacing;
|
|
|
|
switch(fl_get_choice(fd_form_document->choice_spacing)) {
|
|
|
|
case 1:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: SINGLE" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Single);
|
|
|
|
break;
|
|
|
|
case 2:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: ONEHALF" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Onehalf);
|
|
|
|
break;
|
|
|
|
case 3:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: DOUBLE" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Double);
|
|
|
|
break;
|
|
|
|
case 4:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: OTHER" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Other,
|
|
|
|
fl_get_input(fd_form_document->input_spacing));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tmpSpacing != params->spacing)
|
|
|
|
redo = true;
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
signed char tmpchar =
|
|
|
|
static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
|
1999-09-27 18:44:28 +00:00
|
|
|
if (params->secnumdepth != tmpchar)
|
|
|
|
redo = true;
|
|
|
|
params->secnumdepth = tmpchar;
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
params->tocdepth =
|
|
|
|
static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
params->float_placement =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_input(fd_form_document->input_float_placement);
|
|
|
|
|
|
|
|
// More checking should be done to ensure the string doesn't have
|
|
|
|
// spaces or illegal placement characters in it. (thornley)
|
|
|
|
|
|
|
|
if (redo)
|
|
|
|
current_view->redoCurrentBuffer();
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDirty();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
params->options =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_input(fd_form_document->input_extra);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void DocumentCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_document->form_document);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void DocumentOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
DocumentCancelCB(ob, data);
|
|
|
|
DocumentApplyCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
bulletForm();
|
|
|
|
// bullet callbacks etc. in bullet_panel.C -- ARRae
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_quotes */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void QuotesApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Quotes type set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
|
|
|
|
switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
|
|
|
|
case 0:
|
|
|
|
lga = InsetQuotes::EnglishQ;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
lga = InsetQuotes::SwedishQ;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
lga = InsetQuotes::GermanQ;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
lga = InsetQuotes::PolishQ;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
lga = InsetQuotes::FrenchQ;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
lga = InsetQuotes::DanishQ;
|
|
|
|
break;
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->params.quotes_language = lga;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_button(fd_form_quotes->radio_single))
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->
|
1999-09-27 18:44:28 +00:00
|
|
|
params.quotes_times = InsetQuotes::SingleQ;
|
|
|
|
else
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->
|
1999-09-27 18:44:28 +00:00
|
|
|
params.quotes_times = InsetQuotes::DoubleQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void QuotesCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_quotes->form_quotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void QuotesOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
QuotesApplyCB(ob, data);
|
|
|
|
QuotesCancelCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_preamble */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PreambleCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_preamble->form_preamble);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PreambleApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
current_view->buffer()->params.preamble =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_input(fd_form_preamble->input_preamble);
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDirty();
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
PreambleApplyCB(ob, data);
|
|
|
|
PreambleCancelCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_table */
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
extern "C" void TableApplyCB(FL_OBJECT *, long)
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// check for tables in tables
|
|
|
|
if (current_view->text->cursor.par->table){
|
|
|
|
WriteAlert(_("Impossible Operation!"),
|
|
|
|
_("Cannot insert table in table."),
|
|
|
|
_("Sorry."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
|
|
|
|
int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
|
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->update(-2);
|
|
|
|
|
|
|
|
current_view->text->SetCursorParUndo();
|
|
|
|
current_view->text->FreezeUndo();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
|
|
|
|
if (current_view->text->cursor.par->Last()) {
|
|
|
|
current_view->text->CursorLeft();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_view->text->current_font.setLatex(LyXFont::OFF);
|
|
|
|
//if (!fl_get_button(fd_form_table->check_latex)){
|
|
|
|
// insert the new wysiwy table
|
|
|
|
current_view->text->SetLayout(0); // standard layout
|
|
|
|
if (current_view->text->cursor.par->footnoteflag ==
|
|
|
|
LyXParagraph::NO_FOOTNOTE) {
|
|
|
|
current_view->text
|
|
|
|
->SetParagraph(0, 0,
|
|
|
|
0, 0,
|
|
|
|
VSpace (0.3 * current_view->buffer()->
|
|
|
|
params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
VSpace (0.3 * current_view->buffer()->
|
|
|
|
params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text
|
|
|
|
->SetParagraph(0, 0,
|
|
|
|
0, 0,
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->cursor.par->table =
|
|
|
|
new LyXTable(xsize, ysize);
|
|
|
|
|
2000-03-17 10:14:46 +00:00
|
|
|
Language const * lang =
|
|
|
|
current_view->text->cursor.par->getParLanguage();
|
2000-04-26 13:57:28 +00:00
|
|
|
LyXFont font(LyXFont::ALL_INHERIT, lang);
|
2000-03-17 10:14:46 +00:00
|
|
|
for (int i = 0; i < xsize * ysize - 1; ++i) {
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
|
2000-03-17 10:14:46 +00:00
|
|
|
current_view->text->cursor.par->SetFont(0, font);
|
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->RedoParagraph();
|
|
|
|
|
|
|
|
current_view->text->UnFreezeUndo();
|
|
|
|
|
|
|
|
current_view->update(1);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TableCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_table->form_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void TableOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
TableApplyCB(ob, data);
|
|
|
|
TableCancelCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_print */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PrintCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_print->form_print);
|
|
|
|
}
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
bool stringOnlyContains (string const & LStr, char const * cset)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-04-04 00:19:15 +00:00
|
|
|
return LStr.find_first_not_of(cset) == string::npos;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PrintApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
1999-11-26 06:57:35 +00:00
|
|
|
Buffer * buffer = current_view->buffer();
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string pageflag;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_button(fd_form_print->radio_even_pages))
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag = lyxrc.print_evenpage_flag + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
else if (fl_get_button(fd_form_print->radio_odd_pages))
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag = lyxrc.print_oddpage_flag + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
|
|
|
|
// User may give a page (range) list
|
|
|
|
// User may print multiple (unsorted) copies
|
1999-10-26 23:33:30 +00:00
|
|
|
string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
|
|
|
|
pages = subst(pages, '+',',');
|
|
|
|
pages = frontStrip(strip(pages)) ;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (!pages.empty()) { // a page range was given
|
1999-10-02 16:21:10 +00:00
|
|
|
string piece ;
|
|
|
|
pages = split (pages, piece, ',') ;
|
|
|
|
piece = strip(piece) ;
|
|
|
|
piece = frontStrip(piece) ;
|
|
|
|
if ( !stringOnlyContains (piece, "0123456789-") ) {
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("ERROR! Unable to print!"),
|
1999-12-16 06:43:25 +00:00
|
|
|
_("Check 'range of pages'!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-10-02 16:21:10 +00:00
|
|
|
if (piece.find('-') == string::npos) { // not found
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag += lyxrc.print_pagerange_flag + piece + '-' + piece + ' ' ;
|
1999-10-02 16:21:10 +00:00
|
|
|
} else if (suffixIs(piece, "-") ) { // missing last page
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag += lyxrc.print_pagerange_flag + piece + "1000 ";
|
1999-10-02 16:21:10 +00:00
|
|
|
} else if (prefixIs(piece, "-") ) { // missing first page
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag += lyxrc.print_pagerange_flag + '1' + piece + ' ' ;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag += lyxrc.print_pagerange_flag + piece + ' ' ;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!copies.empty()) { // a number of copies was given
|
1999-10-02 16:21:10 +00:00
|
|
|
if ( !stringOnlyContains (copies, "0123456789") ) {
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("ERROR! Unable to print!"),
|
1999-12-16 06:43:25 +00:00
|
|
|
_("Check 'number of copies'!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fl_get_button(fd_form_print->do_unsorted))
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag += lyxrc.print_copies_flag;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
2000-03-12 10:35:05 +00:00
|
|
|
pageflag += lyxrc.print_collcopies_flag;
|
1999-09-27 18:44:28 +00:00
|
|
|
pageflag += " " + copies + ' ' ;
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string reverseflag;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_button(fd_form_print->radio_order_reverse))
|
2000-03-12 10:35:05 +00:00
|
|
|
reverseflag = lyxrc.print_reverse_flag + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string orientationflag;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
2000-03-12 10:35:05 +00:00
|
|
|
orientationflag = lyxrc.print_landscape_flag + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-03 13:51:01 +00:00
|
|
|
string ps_file = fl_get_input(fd_form_print->input_file);
|
1999-10-02 16:21:10 +00:00
|
|
|
string printer = strip(fl_get_input(fd_form_print->input_printer));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string printerflag;
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.print_adapt_output // printer name should be passed to dvips
|
1999-09-27 18:44:28 +00:00
|
|
|
&& ! printer.empty()) // a printer name has been given
|
2000-03-12 10:35:05 +00:00
|
|
|
printerflag = lyxrc.print_to_printer + printer + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string extraflags;
|
2000-03-12 10:35:05 +00:00
|
|
|
if (!lyxrc.print_extra_options.empty())
|
|
|
|
extraflags = lyxrc.print_extra_options + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-03-12 10:35:05 +00:00
|
|
|
string command = lyxrc.print_command + ' '
|
1999-09-27 18:44:28 +00:00
|
|
|
+ printerflag + pageflag + reverseflag
|
|
|
|
+ orientationflag + extraflags;
|
|
|
|
|
|
|
|
char real_papersize = buffer->params.papersize;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
2000-03-12 10:35:05 +00:00
|
|
|
real_papersize = lyxrc.default_papersize;
|
1999-11-26 06:57:35 +00:00
|
|
|
|
|
|
|
string paper;
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (real_papersize) {
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_USLETTER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "letter";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A3PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a3";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A4PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a4";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A5PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a5";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_B5PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "b5";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_EXECUTIVEPAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "foolscap";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_LEGALPAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "legal";
|
|
|
|
break;
|
|
|
|
default: /* If nothing else fits, keep an empty value... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer->params.use_geometry
|
1999-11-15 12:01:38 +00:00
|
|
|
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
2000-03-12 10:35:05 +00:00
|
|
|
&& !lyxrc.print_paper_dimension_flag.empty()
|
1999-09-27 18:44:28 +00:00
|
|
|
&& !buffer->params.paperwidth.empty()
|
|
|
|
&& !buffer->params.paperheight.empty()) {
|
|
|
|
// using a custom papersize
|
|
|
|
command += ' ';
|
2000-03-12 10:35:05 +00:00
|
|
|
command += lyxrc.print_paper_dimension_flag + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
command += buffer->params.paperwidth + ',';
|
|
|
|
command += buffer->params.paperheight + ' ';
|
2000-03-12 10:35:05 +00:00
|
|
|
} else if (!lyxrc.print_paper_flag.empty()
|
1999-09-27 18:44:28 +00:00
|
|
|
&& !paper.empty()
|
1999-11-15 12:01:38 +00:00
|
|
|
&& (real_papersize != BufferParams::PAPER_USLETTER ||
|
|
|
|
buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
|
2000-03-12 10:35:05 +00:00
|
|
|
command += " " + lyxrc.print_paper_flag + " " + paper + " ";
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
if (fl_get_button(fd_form_print->radio_file))
|
2000-03-12 10:35:05 +00:00
|
|
|
command += lyxrc.print_to_file
|
1999-12-16 06:43:25 +00:00
|
|
|
+ QuoteName(MakeAbsPath(ps_file, path));
|
2000-03-12 10:35:05 +00:00
|
|
|
else if (!lyxrc.print_spool_command.empty())
|
|
|
|
command += lyxrc.print_to_file
|
1999-12-03 13:51:01 +00:00
|
|
|
+ QuoteName(ps_file);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// push directorypath, if necessary
|
2000-03-12 10:35:05 +00:00
|
|
|
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
|
1999-09-27 18:44:28 +00:00
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
bool result;
|
2000-03-12 10:35:05 +00:00
|
|
|
if (!lyxrc.print_spool_command.empty() &&
|
1999-09-27 18:44:28 +00:00
|
|
|
!fl_get_button(fd_form_print->radio_file)) {
|
2000-03-12 10:35:05 +00:00
|
|
|
string command2 = lyxrc.print_spool_command + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!printer.empty())
|
2000-03-12 10:35:05 +00:00
|
|
|
command2 += lyxrc.print_spool_printerprefix
|
1999-12-16 06:43:25 +00:00
|
|
|
+ printer;
|
1999-09-27 18:44:28 +00:00
|
|
|
// First run dvips and, if succesful, then spool command
|
|
|
|
if ((result = RunScript(buffer, true, command))) {
|
|
|
|
result = RunScript(buffer, false, command2, ps_file);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
result = RunScript(buffer, false, command);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
WriteAlert(_("Error:"),
|
|
|
|
_("Unable to print"),
|
|
|
|
_("Check that your parameters are correct"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
PrintCancelCB(ob, data);
|
1999-11-15 12:01:38 +00:00
|
|
|
PrintApplyCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-12 14:20:08 +00:00
|
|
|
void Figure()
|
|
|
|
{
|
|
|
|
if (fd_form_figure->form_figure->visible) {
|
|
|
|
fl_raise_form(fd_form_figure->form_figure);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_figure->form_figure,
|
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
|
|
|
_("Insert Figure"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Table()
|
|
|
|
{
|
|
|
|
if (fd_form_table->form_table->visible) {
|
|
|
|
fl_raise_form(fd_form_table->form_table);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_table->form_table,
|
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
|
|
|
_("Insert Table"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/* callbacks for form form_figure */
|
1999-12-10 00:07:59 +00:00
|
|
|
extern "C" void FigureApplyCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Buffer * buffer = current_view->buffer();
|
|
|
|
if(buffer->isReadonly()) // paranoia
|
|
|
|
return;
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
|
1999-12-10 00:07:59 +00:00
|
|
|
if (fl_get_button(fd_form_figure->radio_inline)
|
|
|
|
|| current_view->text->cursor.par->table) {
|
|
|
|
InsetFig * new_inset = new InsetFig(100, 20, buffer);
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
|
2000-02-25 12:06:15 +00:00
|
|
|
new_inset->Edit(current_view, 0, 0, 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->update(-2);
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->SetCursorParUndo();
|
|
|
|
current_view->text->FreezeUndo();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
|
|
|
|
if (current_view->text->cursor.par->Last()) {
|
|
|
|
current_view->text->CursorLeft();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// The standard layout should always be numer 0;
|
|
|
|
current_view->text->SetLayout(0);
|
|
|
|
|
|
|
|
if (current_view->text->cursor.par->footnoteflag ==
|
|
|
|
LyXParagraph::NO_FOOTNOTE) {
|
|
|
|
current_view->text->
|
|
|
|
SetParagraph(0, 0,
|
|
|
|
0, 0,
|
|
|
|
VSpace (0.3 * buffer->params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
VSpace (0.3 *
|
|
|
|
buffer->params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
LYX_ALIGN_CENTER, string(), 0);
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->SetParagraph(0, 0,
|
1999-12-16 06:43:25 +00:00
|
|
|
0, 0,
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->update(-1);
|
|
|
|
|
|
|
|
Inset * new_inset = new InsetFig(100, 100, buffer);
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
2000-02-25 12:06:15 +00:00
|
|
|
new_inset->Edit(current_view, 0, 0, 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->update(0);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->UnFreezeUndo();
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void FigureCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_figure->form_figure);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
FigureApplyCB(ob, data);
|
|
|
|
FigureCancelCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ScreenApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-03-12 10:35:05 +00:00
|
|
|
lyxrc.roman_font_name = fl_get_input(fd_form_screen->input_roman);
|
|
|
|
lyxrc.sans_font_name = fl_get_input(fd_form_screen->input_sans);
|
|
|
|
lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
|
|
|
|
lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
|
|
|
|
lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
|
1999-09-27 18:44:28 +00:00
|
|
|
fontloader.update();
|
2000-04-27 09:10:51 +00:00
|
|
|
|
|
|
|
// Of course we should only to the resize and the textcahce.clear
|
|
|
|
// if values really changed...but not very important right now. (Lgb)
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// All buffers will need resize
|
|
|
|
bufferlist.resize();
|
2000-04-27 09:10:51 +00:00
|
|
|
// We also need to empty the textcache so that
|
|
|
|
// the buffer will be formatted correctly after
|
|
|
|
// a zoom change.
|
|
|
|
textcache.clear();
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ScreenCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_screen->form_screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
ScreenCancelCB(ob, data);
|
|
|
|
ScreenApplyCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void LaTeXOptions(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (!bv->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
fl_set_button(fd_latex_options->accents,
|
2000-02-04 09:38:32 +00:00
|
|
|
int(bv->buffer()->params.allowAccents));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fd_latex_options->LaTeXOptions->visible) {
|
|
|
|
fl_raise_form(fd_latex_options->LaTeXOptions);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_latex_options->LaTeXOptions,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("LaTeX Options"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This function runs "configure" and then rereads lyx.defaults to
|
|
|
|
// reconfigure the automatic settings.
|
2000-02-04 09:38:32 +00:00
|
|
|
void Reconfigure(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Run configure in user lyx directory
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(user_lyxdir);
|
1999-09-27 18:44:28 +00:00
|
|
|
Systemcalls one(Systemcalls::System,
|
1999-12-16 06:43:25 +00:00
|
|
|
AddName(system_lyxdir, "configure"));
|
1999-10-13 17:32:46 +00:00
|
|
|
p.pop();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
|
2000-03-12 10:35:05 +00:00
|
|
|
lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("The system has been reconfigured."),
|
|
|
|
_("You need to restart LyX to make use of any"),
|
|
|
|
_("updated document class specifications."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Table of Contents
|
|
|
|
//
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
static vector<Buffer::TocItem> toclist;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void TocSelectCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
TocUpdateCB(0, 0);
|
|
|
|
unsigned int choice = fl_get_browser(ob);
|
|
|
|
if (0 < choice && choice - 1 < toclist.size()) {
|
|
|
|
current_view->beforeChange();
|
|
|
|
current_view->text->SetCursor(toclist[choice-1].par, 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->sel_cursor =
|
|
|
|
current_view->text->cursor;
|
|
|
|
current_view->update(0);
|
2000-05-19 16:46:01 +00:00
|
|
|
} else {
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("Error"),
|
|
|
|
_("Couldn't find this label"),
|
|
|
|
_("in current document."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TocCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_toc->form_toc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TocUpdateCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available()) {
|
2000-05-19 16:46:01 +00:00
|
|
|
toclist.clear();
|
|
|
|
fl_clear_browser(fd_form_toc->browser_toc);
|
1999-11-26 06:57:35 +00:00
|
|
|
fl_add_browser_line(fd_form_toc->browser_toc,
|
|
|
|
_("*** No Document ***"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
|
|
vector<vector<Buffer::TocItem> > tmp =
|
|
|
|
current_view->buffer()->getTocList();
|
|
|
|
if (toclist == tmp[0])
|
|
|
|
return;
|
|
|
|
toclist = tmp[0];
|
|
|
|
|
|
|
|
static Buffer * buffer = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
int topline = 0;
|
2000-05-19 16:46:01 +00:00
|
|
|
int line = 0;
|
|
|
|
if (buffer == current_view->buffer()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
topline = fl_get_browser_topline(fd_form_toc->browser_toc);
|
2000-05-19 16:46:01 +00:00
|
|
|
line = fl_get_browser(fd_form_toc->browser_toc);
|
|
|
|
} else
|
|
|
|
buffer = current_view->buffer();
|
|
|
|
|
|
|
|
fl_clear_browser(fd_form_toc->browser_toc);
|
|
|
|
fl_hide_object(fd_form_toc->browser_toc);
|
|
|
|
|
|
|
|
for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
|
|
|
|
it != toclist.end(); ++it)
|
|
|
|
fl_add_browser_line(fd_form_toc->browser_toc,
|
|
|
|
(string(4*(*it).depth,' ')+
|
|
|
|
(*it).str).c_str());
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_browser_topline(fd_form_toc->browser_toc, topline);
|
2000-05-19 16:46:01 +00:00
|
|
|
fl_select_browser_line(fd_form_toc->browser_toc, line);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_show_object(fd_form_toc->browser_toc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_ref */
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void RefSelectCB(FL_OBJECT *, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
string s =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_browser_line(fd_form_ref->browser_ref,
|
|
|
|
fl_get_browser(fd_form_ref->browser_ref));
|
1999-10-02 16:21:10 +00:00
|
|
|
string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (s.empty())
|
|
|
|
return;
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
if (data >= 5) {
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
static string const commands[5]
|
|
|
|
= { "\\ref", "\\pageref", "\\vref", "\\vpageref",
|
|
|
|
"\\prettyref"};
|
|
|
|
string t = commands[data];
|
|
|
|
|
|
|
|
if (current_view->buffer()->isSGML())
|
1999-09-27 18:44:28 +00:00
|
|
|
t += "[" + u + "]" + "{" + s + "}";
|
|
|
|
else
|
|
|
|
t += "{" + s + "}";
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
Inset * new_inset =
|
1999-11-09 23:52:04 +00:00
|
|
|
new InsetRef(t, current_view->buffer());
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void RefUpdateCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available()) {
|
|
|
|
fl_clear_browser(fd_form_ref->browser_ref);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FL_OBJECT * brow = fd_form_ref->browser_ref;
|
|
|
|
|
|
|
|
// Get the current line, in order to restore it later
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * const btmp = fl_get_browser_line(brow,
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_get_browser(brow));
|
1999-11-15 12:01:38 +00:00
|
|
|
string currentstr = btmp ? btmp : "";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_clear_browser(brow);
|
2000-05-19 16:46:01 +00:00
|
|
|
fl_hide_object(brow);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
vector<string> refs = current_view->buffer()->getLabelList();
|
|
|
|
if (fl_get_button(fd_form_ref->sort))
|
|
|
|
sort(refs.begin(),refs.end());
|
|
|
|
for (vector<string>::const_iterator it = refs.begin();
|
|
|
|
it != refs.end(); ++it)
|
|
|
|
fl_add_browser_line(brow, (*it).c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-05-19 16:46:01 +00:00
|
|
|
int topline = 1;
|
1999-09-27 18:44:28 +00:00
|
|
|
int total_lines = fl_get_browser_maxline(brow);
|
2000-01-24 18:34:46 +00:00
|
|
|
for (int i = 1; i <= total_lines ; ++i) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_browser_line(brow, i) == currentstr) {
|
|
|
|
topline = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fl_set_browser_topline(brow, topline);
|
|
|
|
|
|
|
|
if (!fl_get_browser_maxline(brow)) {
|
|
|
|
fl_add_browser_line(brow,
|
|
|
|
_("*** No labels found in document ***"));
|
|
|
|
fl_deactivate_object(brow);
|
|
|
|
} else {
|
|
|
|
fl_select_browser_line(brow, topline);
|
|
|
|
fl_activate_object(brow);
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isReadonly()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// would be better to de/activate insert buttons
|
|
|
|
// but that's more work... besides this works. ARRae
|
|
|
|
fl_hide_form(fd_form_ref->form_ref);
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
if (!current_view->buffer()->isSGML()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_deactivate_object(fd_form_ref->ref_name);
|
|
|
|
fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
|
|
fl_activate_object(fd_form_ref->vref);
|
|
|
|
fl_set_object_lcol(fd_form_ref->vref, FL_BLACK);
|
|
|
|
fl_activate_object(fd_form_ref->vpageref);
|
|
|
|
fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK);
|
|
|
|
fl_activate_object(fd_form_ref->prettyref);
|
|
|
|
fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK);
|
|
|
|
} else {
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_activate_object(fd_form_ref->ref_name);
|
|
|
|
fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
|
2000-05-19 16:46:01 +00:00
|
|
|
|
|
|
|
fl_deactivate_object(fd_form_ref->vref);
|
|
|
|
fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
|
|
|
|
fl_deactivate_object(fd_form_ref->vpageref);
|
|
|
|
fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
|
|
|
|
fl_deactivate_object(fd_form_ref->prettyref);
|
|
|
|
fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-05-19 16:46:01 +00:00
|
|
|
fl_show_object(brow);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void RefHideCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_ref->form_ref);
|
|
|
|
}
|