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 FORMS_H_LOCATION
|
|
|
|
#include "lyx.h"
|
|
|
|
#include "layout_forms.h"
|
|
|
|
#include "bullet_forms.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 "lyxrc.h"
|
|
|
|
#include "lyxtext.h"
|
2000-04-10 14:29:05 +00:00
|
|
|
#include "CutAndPaste.h"
|
2000-08-30 03:40:51 +00:00
|
|
|
#include "exporter.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-05-20 21:37:05 +00:00
|
|
|
using std::equal;
|
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_figure * fd_form_figure;
|
|
|
|
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 &);
|
2000-08-08 15:36:25 +00:00
|
|
|
bool MenuWrite(Buffer * buf);
|
2000-07-26 13:43:16 +00:00
|
|
|
bool MenuWriteAs(Buffer * buffer);
|
1999-11-26 06:57:35 +00:00
|
|
|
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,
|
2000-08-30 04:38:32 +00:00
|
|
|
string const & msg2,
|
|
|
|
string const & msg3, int delay)
|
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
|
|
|
|
|
|
|
//
|
|
|
|
// Menu callbacks
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// File menu
|
|
|
|
//
|
|
|
|
|
|
|
|
// should be moved to lyxfunc.C
|
2000-08-08 15:36:25 +00:00
|
|
|
bool 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-08-08 15:36:25 +00:00
|
|
|
return MenuWriteAs(buffer);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-08-08 15:36:25 +00:00
|
|
|
return false;
|
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
|
|
|
}
|
2000-08-08 15:36:25 +00:00
|
|
|
return true;
|
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.
|
2000-07-26 13:43:16 +00:00
|
|
|
bool 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";
|
|
|
|
|
2000-07-26 13:43:16 +00:00
|
|
|
if (buffer->isUnnamed()) {
|
|
|
|
fname = fileDlg.Select(_("Enter Filename to Save Document as"),
|
|
|
|
"",
|
|
|
|
"*.lyx",
|
|
|
|
"");
|
|
|
|
} else {
|
|
|
|
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()) {
|
2000-07-26 13:43:16 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
// 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?")))
|
2000-07-26 13:43:16 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
// 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
|
|
|
}
|
2000-07-26 13:43:16 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
} // 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?")))
|
2000-07-26 13:43:16 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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();
|
2000-08-08 15:36:25 +00:00
|
|
|
bool unnamed = buffer->isUnnamed();
|
2000-07-26 13:43:16 +00:00
|
|
|
buffer->setUnnamed(false);
|
1999-09-27 18:44:28 +00:00
|
|
|
// And save
|
|
|
|
// Small bug: If the save fails, we have irreversible changed the name
|
|
|
|
// of the document.
|
2000-08-08 15:36:25 +00:00
|
|
|
// Hope this is fixed this way! (Jug)
|
|
|
|
if (!MenuWrite(buffer)) {
|
|
|
|
buffer->fileName(oldname);
|
|
|
|
buffer->setUnnamed(unnamed);
|
|
|
|
ShowMessage(buffer, _("Document could not be saved!"),
|
|
|
|
_("Holding the old name."), MakeDisplayPath(oldname));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// now remove the oldname autosave file if existant!
|
|
|
|
removeAutosaveFile(oldname);
|
2000-07-26 13:43:16 +00:00
|
|
|
return true;
|
2000-08-08 15:36:25 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
#ifndef NEW_EXPORT
|
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;
|
|
|
|
}
|
2000-08-30 03:40:51 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
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-08-30 03:40:51 +00:00
|
|
|
#ifndef NEW_EXPORT
|
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;
|
|
|
|
}
|
2000-06-20 12:49:14 +00:00
|
|
|
|
|
|
|
Path p(path);
|
|
|
|
ret = MenuRunLaTeX(buffer);
|
|
|
|
|
|
|
|
return ret;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
2000-08-30 03:40:51 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
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
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
#ifdef NEW_EXPORT
|
|
|
|
// Generate postscript file
|
|
|
|
if (!Exporter::Export(buffer, "ps", true))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Send fax
|
|
|
|
string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
|
|
|
|
".ps"));
|
|
|
|
#else
|
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"));
|
2000-08-30 03:40:51 +00:00
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
#ifndef NEW_EXPORT
|
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-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
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
buffer->makeLinuxDocFile(s, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
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
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
buffer->makeDocBookFile(s, true);
|
1999-12-10 00:07:59 +00:00
|
|
|
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-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.
|
2000-06-12 11:27:15 +00:00
|
|
|
//should start lyxview->getDialogs()->showPrint();
|
|
|
|
// to get same as before
|
|
|
|
// MenuPrint(buffer);
|
1999-12-15 17:42:22 +00:00
|
|
|
// 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") {
|
2000-07-26 14:08:09 +00:00
|
|
|
if (buffer->isLinuxDoc())
|
|
|
|
MenuMakeHTML_LinuxDoc(buffer);
|
|
|
|
else if (buffer->isDocBook())
|
|
|
|
MenuMakeHTML_DocBook(buffer);
|
|
|
|
else
|
|
|
|
MenuMakeHTML(buffer);
|
2000-03-20 18:55:57 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2000-08-30 03:40:51 +00:00
|
|
|
#endif
|
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-08-08 15:36:25 +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-07-24 21:49:58 +00:00
|
|
|
#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
|
|
|
|
// We use this until the compilers get better...
|
|
|
|
vector<char> tmp;
|
|
|
|
copy(ii, end, back_inserter(tmp));
|
|
|
|
string tmpstr(tmp.begin(), tmp.end());
|
|
|
|
#else
|
|
|
|
// This is what we want to use and what we will use once the
|
|
|
|
// compilers get good enough.
|
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));
|
2000-07-24 21:49:58 +00:00
|
|
|
#endif
|
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-06-12 11:27:15 +00:00
|
|
|
bv->text->InsertStringA(bv, tmpstr);
|
1999-12-10 00:07:59 +00:00
|
|
|
else
|
2000-06-12 11:27:15 +00:00
|
|
|
bv->text->InsertStringB(bv, tmpstr);
|
|
|
|
bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
void MenuInsertLabel(string const & arg)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-09-14 17:53:12 +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()) {
|
2000-08-04 13:12:30 +00:00
|
|
|
InsetCommandParams p( "label", label );
|
|
|
|
InsetLabel * inset = new InsetLabel( p );
|
|
|
|
current_view->insertInset( 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
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
2000-09-14 14:37:21 +00:00
|
|
|
void LayoutsCB(int sel, void *, Combox *)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
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,
|
2000-09-19 11:18:35 +00:00
|
|
|
tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 03:40:51 +00:00
|
|
|
#ifndef NEW_EXPORT
|
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;
|
2000-07-01 12:54:45 +00:00
|
|
|
bv->buffer()->makeLinuxDocFile(name, false);
|
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;
|
2000-06-20 12:49:14 +00:00
|
|
|
}
|
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;
|
|
|
|
|
2000-07-01 12:54:45 +00:00
|
|
|
current_view->buffer()->makeDocBookFile(name, false);
|
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;
|
2000-06-20 12:49:14 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
2000-08-30 03:40:51 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
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-09-14 17:53:12 +00:00
|
|
|
static inline
|
2000-03-07 01:14:37 +00:00
|
|
|
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-09-14 17:53:12 +00:00
|
|
|
static inline
|
2000-03-07 01:14:37 +00:00
|
|
|
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-09-14 17:53:12 +00:00
|
|
|
static inline
|
2000-03-07 01:14:37 +00:00
|
|
|
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-09-14 17:53:12 +00:00
|
|
|
static inline
|
2000-03-07 01:14:37 +00:00
|
|
|
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();
|
2000-07-19 08:37:26 +00:00
|
|
|
LyXText * text = 0;
|
|
|
|
if (current_view->the_locking_inset)
|
|
|
|
text = current_view->the_locking_inset->getLyXText(current_view);
|
|
|
|
if (!text)
|
|
|
|
text = current_view->text;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
fl_set_input(fd_form_paragraph->input_labelwidth,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->GetLabelWidthString().c_str());
|
1999-12-10 00:07:59 +00:00
|
|
|
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);
|
|
|
|
|
2000-07-19 08:37:26 +00:00
|
|
|
int align = text->cursor.par()->GetAlign();
|
1999-12-10 00:07:59 +00:00
|
|
|
if (align == LYX_ALIGN_LAYOUT)
|
|
|
|
align = textclasslist.Style(buf->params.textclass,
|
2000-07-19 08:37:26 +00:00
|
|
|
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;
|
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_button(fd_form_paragraph->check_lines_top,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->line_top);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_button(fd_form_paragraph->check_lines_bottom,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->line_bottom);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->noindent);
|
2000-07-19 17:16:27 +00:00
|
|
|
#else
|
|
|
|
fl_set_button(fd_form_paragraph->check_lines_top,
|
|
|
|
text->cursor.par()->line_top);
|
|
|
|
fl_set_button(fd_form_paragraph->check_lines_bottom,
|
|
|
|
text->cursor.par()->line_bottom);
|
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
|
|
|
|
text->cursor.par()->pagebreak_top);
|
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
|
|
|
|
text->cursor.par()->pagebreak_bottom);
|
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
|
|
|
text->cursor.par()->noindent);
|
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_input (fd_form_paragraph->input_space_above, "");
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
|
|
#ifndef NEW_INSETS
|
2000-07-19 08:37:26 +00:00
|
|
|
switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
|
2000-07-19 17:16:27 +00:00
|
|
|
#else
|
|
|
|
switch (text->cursor.par()->added_space_top.kind()) {
|
|
|
|
#endif
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
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:
|
2000-07-19 17:16:27 +00:00
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 7);
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_input (fd_form_paragraph->input_space_above,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str());
|
2000-07-19 17:16:27 +00:00
|
|
|
#else
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_above,
|
|
|
|
text->cursor.par()->added_space_top.length().asString().c_str());
|
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_button (fd_form_paragraph->check_space_above,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->added_space_top.keep());
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_input (fd_form_paragraph->input_space_below, "");
|
2000-07-19 08:37:26 +00:00
|
|
|
switch (text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
|
2000-07-19 17:16:27 +00:00
|
|
|
#else
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_above,
|
|
|
|
text->cursor.par()->added_space_top.keep());
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_below, "");
|
|
|
|
switch (text->cursor.par()->added_space_bottom.kind()) {
|
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
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,
|
2000-07-19 17:16:27 +00:00
|
|
|
7);
|
|
|
|
#ifndef NEW_INSETS
|
1999-12-10 00:07:59 +00:00
|
|
|
fl_set_input (fd_form_paragraph->input_space_below,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
|
1999-12-10 00:07:59 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_below,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep());
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
2000-07-19 08:37:26 +00:00
|
|
|
text->cursor.par()->FirstPhysicalPar()->noindent);
|
2000-07-19 17:16:27 +00:00
|
|
|
#else
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_below,
|
|
|
|
text->cursor.par()->added_space_bottom.length().asString().c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_below,
|
|
|
|
text->cursor.par()->added_space_bottom.keep());
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
|
|
|
text->cursor.par()->noindent);
|
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-08-18 14:36:12 +00:00
|
|
|
#ifdef USE_OLD_DOCUMENT_LAYOUT
|
2000-09-14 17:53:12 +00:00
|
|
|
static inline
|
1999-09-27 18:44:28 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
static inline
|
1999-09-27 18:44:28 +00:00
|
|
|
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
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
static inline
|
1999-09-27 18:44:28 +00:00
|
|
|
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
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
static inline
|
1999-09-27 18:44:28 +00:00
|
|
|
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-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());
|
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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-08-18 14:36:12 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2000-09-14 17:53:12 +00:00
|
|
|
LyXFont const UserFreeFont(BufferParams const & params)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
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-06-22 09:30:43 +00:00
|
|
|
int choice = combo_language2->get();
|
|
|
|
if (choice == 1)
|
|
|
|
font.setLanguage(ignore_language);
|
|
|
|
else if (choice == 2)
|
|
|
|
font.setLanguage(params.language_info);
|
|
|
|
else
|
|
|
|
font.setLanguage(&languages[combo_language2->getline()]);
|
2000-04-17 14:00:18 +00:00
|
|
|
|
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
|
|
|
|
2000-07-19 08:37:26 +00:00
|
|
|
LyXText * text = 0;
|
|
|
|
if (current_view->the_locking_inset)
|
|
|
|
text = current_view->the_locking_inset->getLyXText(current_view);
|
|
|
|
if (!text)
|
|
|
|
text = current_view->text;
|
|
|
|
text->SetParagraph(current_view,
|
|
|
|
line_top,
|
|
|
|
line_bottom,
|
|
|
|
pagebreak_top,
|
|
|
|
pagebreak_bottom,
|
|
|
|
space_top,
|
|
|
|
space_bottom,
|
|
|
|
align,
|
|
|
|
labelwidthstring,
|
|
|
|
noindent);
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
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-06-22 09:30:43 +00:00
|
|
|
ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-18 14:36:12 +00:00
|
|
|
#ifdef USE_OLD_DOCUMENT_LAYOUT
|
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()) {
|
2000-06-08 23:16:16 +00:00
|
|
|
if (old_language != new_language
|
|
|
|
&& old_language->RightToLeft() == new_language->RightToLeft()
|
|
|
|
&& !current_view->buffer()->isMultiLingual())
|
2000-04-10 21:40:13 +00:00
|
|
|
current_view->buffer()->ChangeLanguage(old_language,
|
|
|
|
new_language);
|
2000-05-30 19:31:11 +00:00
|
|
|
if (old_language != new_language) {
|
2000-06-08 23:16:16 +00:00
|
|
|
//current_view->buffer()->redraw();
|
2000-05-30 19:31:11 +00:00
|
|
|
redo = true;
|
2000-04-10 21:40:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->SetCursor(current_view,
|
|
|
|
current_view->text->cursor.par(),
|
2000-06-08 23:16:16 +00:00
|
|
|
current_view->text->cursor.pos());
|
2000-04-10 21:40:13 +00:00
|
|
|
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();
|
2000-06-08 23:16:16 +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);
|
|
|
|
}
|
2000-08-18 14:36:12 +00:00
|
|
|
#else
|
|
|
|
// this is needed for now!
|
|
|
|
extern "C" void ChoiceClassCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void DocumentDefskipCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void DocumentSpacingCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void DocumentApplyCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void DocumentCancelCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void DocumentOKCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void DocumentBulletsCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void QuotesApplyCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void QuotesCancelCB(FL_OBJECT *, long) {}
|
|
|
|
extern "C" void QuotesOKCB(FL_OBJECT *, long) {}
|
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
|
2000-07-19 17:16:27 +00:00
|
|
|
extern "C"
|
|
|
|
void TableApplyCB(FL_OBJECT *, long)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
2000-07-21 18:47:54 +00:00
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-09-23 04:57:18 +00:00
|
|
|
int const ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
|
|
|
|
int const xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->SetCursorParUndo(current_view->buffer());
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->FreezeUndo();
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->BreakParagraph(current_view);
|
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
if (current_view->text->cursor.par()->Last()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->CursorLeft(current_view);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->BreakParagraph(current_view);
|
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
current_view->text->current_font.setLatex(LyXFont::OFF);
|
|
|
|
//if (!fl_get_button(fd_form_table->check_latex)){
|
|
|
|
// insert the new wysiwy table
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->SetLayout(current_view, 0); // standard layout
|
2000-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
2000-06-08 23:16:16 +00:00
|
|
|
if (current_view->text->cursor.par()->footnoteflag ==
|
1999-12-10 00:07:59 +00:00
|
|
|
LyXParagraph::NO_FOOTNOTE) {
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text
|
2000-06-12 11:27:15 +00:00
|
|
|
->SetParagraph(current_view, 0, 0,
|
1999-12-10 00:07:59 +00:00
|
|
|
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-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text
|
2000-06-12 11:27:15 +00:00
|
|
|
->SetParagraph(current_view, 0, 0,
|
1999-12-10 00:07:59 +00:00
|
|
|
0, 0,
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
2000-07-21 18:47:54 +00:00
|
|
|
#endif
|
2000-03-17 10:14:46 +00:00
|
|
|
Language const * lang =
|
2000-06-08 23:16:16 +00:00
|
|
|
current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
|
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) {
|
2000-06-28 13:35:52 +00:00
|
|
|
current_view->text->cursor.par()
|
|
|
|
->InsertChar(0, LyXParagraph::META_NEWLINE, font);
|
2000-03-17 10:14:46 +00:00
|
|
|
}
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->RedoParagraph(current_view);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->UnFreezeUndo();
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
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
|
|
|
|
|
|
|
|
2000-07-19 17:16:27 +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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-19 17:16:27 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
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 */
|
2000-07-19 17:16:27 +00:00
|
|
|
extern "C"
|
|
|
|
void FigureApplyCB(FL_OBJECT *, long)
|
1999-12-10 00:07:59 +00:00
|
|
|
{
|
|
|
|
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..."));
|
2000-09-23 04:57:18 +00:00
|
|
|
if (fl_get_button(fd_form_figure->radio_inline)) {
|
1999-12-10 00:07:59 +00:00
|
|
|
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();
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR);
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->SetCursorParUndo(current_view->buffer());
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->FreezeUndo();
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->BreakParagraph(current_view);
|
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-08 23:16:16 +00:00
|
|
|
if (current_view->text->cursor.par()->Last()) {
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->CursorLeft(current_view);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->BreakParagraph(current_view);
|
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// The standard layout should always be numer 0;
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->SetLayout(current_view, 0);
|
2000-07-19 17:16:27 +00:00
|
|
|
|
|
|
|
#ifndef NEW_INSETS
|
2000-06-08 23:16:16 +00:00
|
|
|
if (current_view->text->cursor.par()->footnoteflag ==
|
1999-12-10 00:07:59 +00:00
|
|
|
LyXParagraph::NO_FOOTNOTE) {
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->
|
2000-06-12 11:27:15 +00:00
|
|
|
SetParagraph(current_view, 0, 0,
|
1999-12-10 00:07:59 +00:00
|
|
|
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-07-19 17:16:27 +00:00
|
|
|
#ifndef NEW_INSETS
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->text->SetParagraph(current_view, 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
|
|
|
}
|
2000-07-19 17:16:27 +00:00
|
|
|
#endif
|
1999-12-10 00:07:59 +00:00
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
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);
|
2000-06-12 11:27:15 +00:00
|
|
|
current_view->update(BufferView::SELECT|BufferView::FITCUR);
|
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-09-27 18:44:28 +00:00
|
|
|
// 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."));
|
|
|
|
}
|