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>
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <cctype>
|
1999-09-27 18:44:28 +00:00
|
|
|
#include <unistd.h>
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <csignal>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-01-06 11:35:29 +00:00
|
|
|
#include <fstream>
|
|
|
|
using std::ifstream;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "LString.h"
|
1999-10-19 10:32:10 +00:00
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyx_main.h"
|
|
|
|
#include FORMS_H_LOCATION
|
|
|
|
#include "lyx.h"
|
|
|
|
#include "layout_forms.h"
|
|
|
|
#include "bullet_forms.h"
|
|
|
|
#include "print_form.h"
|
|
|
|
#include "form1.h"
|
|
|
|
#include "spellchecker.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "lyx_cb.h"
|
|
|
|
#include "credits.h"
|
|
|
|
#include "insets/insetref.h"
|
|
|
|
#include "insets/insetquotes.h"
|
|
|
|
#include "insets/insetlabel.h"
|
|
|
|
#include "insets/figinset.h"
|
|
|
|
#include "lyxfunc.h"
|
|
|
|
#include "latexoptions.h"
|
|
|
|
#include "lyxfont.h"
|
|
|
|
#include "minibuffer.h"
|
|
|
|
#include "combox.h"
|
|
|
|
#include "bufferlist.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
1999-10-13 17:32:46 +00:00
|
|
|
#include "support/path.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "filedlg.h"
|
|
|
|
#include "lyx_gui_misc.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "LyXView.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lastfiles.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/FileInfo.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
#include "debug.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/syscall.h"
|
|
|
|
#include "support/lyxlib.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxserver.h"
|
|
|
|
#include "FontLoader.h"
|
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "gettext.h"
|
1999-11-04 01:40:20 +00:00
|
|
|
#include "layout.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern Combox * combo_language;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern BufferList bufferlist;
|
|
|
|
extern void show_symbols_form();
|
1999-11-26 06:57:35 +00:00
|
|
|
extern FD_form_title * fd_form_title;
|
|
|
|
extern FD_form_paragraph * fd_form_paragraph;
|
|
|
|
extern FD_form_character * fd_form_character;
|
|
|
|
extern FD_form_document * fd_form_document;
|
|
|
|
extern FD_form_quotes * fd_form_quotes;
|
|
|
|
extern FD_form_preamble * fd_form_preamble;
|
|
|
|
extern FD_form_table * fd_form_table;
|
|
|
|
extern FD_form_print * fd_form_print;
|
|
|
|
extern FD_form_figure * fd_form_figure;
|
|
|
|
extern FD_form_screen * fd_form_screen;
|
|
|
|
extern FD_form_toc * fd_form_toc;
|
|
|
|
extern FD_form_ref * fd_form_ref;
|
|
|
|
extern FD_LaTeXOptions * fd_latex_options;
|
|
|
|
extern FD_form_bullet * fd_form_bullet;
|
|
|
|
|
|
|
|
extern BufferView * current_view; // called too many times in this file...
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
extern void DeleteSimpleCutBuffer(); /* for the cleanup when exiting */
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern bool send_fax(string const & fname, string const & sendcmd);
|
1999-12-15 17:42:22 +00:00
|
|
|
extern void MenuSendto();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern LyXServer * lyxserver;
|
1999-09-27 18:44:28 +00:00
|
|
|
extern FontLoader fontloader;
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
char updatetimer = 0;
|
|
|
|
|
|
|
|
/* whether the work area should get callbacks */
|
|
|
|
bool input_prohibited = false;
|
|
|
|
|
|
|
|
/* the selection possible is needed, that only motion events are
|
|
|
|
* used, where the bottom press event was on the drawing area too */
|
|
|
|
bool selection_possible = 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 */
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
int RunLinuxDoc(int, string const &);
|
|
|
|
int RunDocBook(int, string const &);
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuWrite(Buffer * buf);
|
|
|
|
void MenuWriteAs(Buffer * buffer);
|
|
|
|
void MenuReload(Buffer * buf);
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutSave();
|
|
|
|
|
|
|
|
|
|
|
|
// How should this actually work? Should it prohibit input in all BufferViews,
|
|
|
|
// or just in the current one? If "just the current one", then it should be
|
|
|
|
// placed in BufferView. If "all BufferViews" then LyXGUI (I think) should
|
|
|
|
// run "ProhibitInput" on all LyXViews which will run prohibitInput on all
|
|
|
|
// BufferViews. Or is it perhaps just the (input in) BufferViews in the
|
|
|
|
// current LyxView that should be prohibited (Lgb) (This applies to
|
|
|
|
// "AllowInput" as well.)
|
|
|
|
void ProhibitInput()
|
|
|
|
{
|
|
|
|
input_prohibited = true;
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
static Cursor cursor;
|
|
|
|
static bool cursor_undefined = true;
|
|
|
|
|
|
|
|
if (cursor_undefined){
|
|
|
|
cursor = XCreateFontCursor(fl_display, XC_watch);
|
|
|
|
XFlush(fl_display);
|
|
|
|
cursor_undefined = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the cursor to the watch for all forms and the canvas */
|
1999-12-19 22:35:36 +00:00
|
|
|
XDefineCursor(fl_display, current_view->owner()->getForm()->window,
|
|
|
|
cursor);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_paragraph->form_paragraph->visible)
|
|
|
|
XDefineCursor(fl_display,
|
|
|
|
fd_form_paragraph->form_paragraph->window,
|
|
|
|
cursor);
|
|
|
|
if (fd_form_character->form_character->visible)
|
|
|
|
XDefineCursor(fl_display,
|
|
|
|
fd_form_character->form_character->window,
|
|
|
|
cursor);
|
|
|
|
|
|
|
|
XFlush(fl_display);
|
|
|
|
fl_deactivate_all_forms();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Should find a way to move this into BufferView.C
|
|
|
|
void SetXtermCursor(Window win)
|
|
|
|
{
|
|
|
|
static Cursor cursor;
|
1999-11-26 06:57:35 +00:00
|
|
|
static bool cursor_undefined = true;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (cursor_undefined){
|
|
|
|
cursor = XCreateFontCursor(fl_display, XC_xterm);
|
|
|
|
XFlush(fl_display);
|
1999-11-26 06:57:35 +00:00
|
|
|
cursor_undefined = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
XDefineCursor(fl_display, win, cursor);
|
|
|
|
XFlush(fl_display);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AllowInput()
|
|
|
|
{
|
|
|
|
input_prohibited = false;
|
|
|
|
|
|
|
|
/* reset the cursor from the watch for all forms and the canvas */
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
XUndefineCursor(fl_display, current_view->owner()->getForm()->window);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_paragraph->form_paragraph->visible)
|
|
|
|
XUndefineCursor(fl_display,
|
|
|
|
fd_form_paragraph->form_paragraph->window);
|
|
|
|
if (fd_form_character->form_character->visible)
|
|
|
|
XUndefineCursor(fl_display,
|
|
|
|
fd_form_character->form_character->window);
|
2000-02-23 16:39:03 +00:00
|
|
|
|
2000-02-15 14:28:15 +00:00
|
|
|
// What to do about this? (Lgb)
|
2000-02-23 16:39:03 +00:00
|
|
|
if (current_view->belowMouse())
|
1999-12-19 22:35:36 +00:00
|
|
|
SetXtermCursor(current_view->owner()->getForm()->window);
|
2000-02-23 16:39:03 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
XFlush(fl_display);
|
|
|
|
fl_activate_all_forms();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void FreeUpdateTimer()
|
|
|
|
{
|
|
|
|
/* a real free timer would be better but I don't know
|
|
|
|
* how to do this with xforms */
|
|
|
|
updatetimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SetUpdateTimer(float time)
|
|
|
|
{
|
1999-12-19 22:35:36 +00:00
|
|
|
fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
|
1999-09-27 18:44:28 +00:00
|
|
|
updatetimer = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Menu callbacks
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// File menu
|
|
|
|
//
|
|
|
|
|
|
|
|
// should be moved to lyxfunc.C
|
2000-01-07 03:42:16 +00:00
|
|
|
void MenuWrite(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
XFlush(fl_display);
|
2000-02-22 00:36:17 +00:00
|
|
|
if (!buffer->save(lyxrc->make_backup)) {
|
2000-01-07 03:42:16 +00:00
|
|
|
string fname = buffer->fileName();
|
1999-10-02 16:21:10 +00:00
|
|
|
string s = MakeAbsPath(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (AskQuestion(_("Save failed. Rename and try again?"),
|
1999-12-16 06:43:25 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("(If not, document is not saved.)"))) {
|
2000-01-07 03:42:16 +00:00
|
|
|
MenuWriteAs(buffer);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else {
|
2000-01-07 03:42:16 +00:00
|
|
|
lastfiles->newFile(buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// should be moved to BufferView.C
|
2000-01-07 03:42:16 +00:00
|
|
|
// Half of this func should be in LyXView, the rest in BufferView.
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuWriteAs(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Why do we require BufferView::text to be able to write a
|
|
|
|
// document? I see no point in that. (Lgb)
|
|
|
|
//if (!bv->text) return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
string fname = buffer->fileName();
|
1999-10-02 16:21:10 +00:00
|
|
|
string oldname = fname;
|
1999-09-27 18:44:28 +00:00
|
|
|
LyXFileDlg fileDlg;
|
|
|
|
|
|
|
|
ProhibitInput();
|
|
|
|
fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
|
|
|
|
fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
|
|
|
|
|
|
|
|
if (!IsLyXFilename(fname))
|
|
|
|
fname += ".lyx";
|
|
|
|
|
|
|
|
fname = fileDlg.Select(_("Enter Filename to Save Document as"),
|
|
|
|
OnlyPath(fname),
|
|
|
|
"*.lyx",
|
|
|
|
OnlyFilename(fname));
|
|
|
|
AllowInput();
|
|
|
|
|
|
|
|
if (fname.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Make sure the absolute filename ends with appropriate suffix
|
1999-11-15 12:01:38 +00:00
|
|
|
string s = MakeAbsPath(fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!IsLyXFilename(s))
|
|
|
|
s += ".lyx";
|
|
|
|
|
|
|
|
// Same name as we have already?
|
|
|
|
if (s == oldname) {
|
|
|
|
if (!AskQuestion(_("Same name as document already has:"),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Save anyway?")))
|
|
|
|
return;
|
|
|
|
// Falls through to name change and save
|
|
|
|
}
|
|
|
|
// No, but do we have another file with this name open?
|
|
|
|
else if (bufferlist.exists(s)) {
|
|
|
|
if (AskQuestion(_("Another document with same name open!"),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Replace with current document?")))
|
|
|
|
{
|
|
|
|
bufferlist.close(bufferlist.getBuffer(s));
|
|
|
|
|
|
|
|
// Ok, change the name of the buffer, but don't save!
|
1999-12-10 00:07:59 +00:00
|
|
|
buffer->fileName(s);
|
1999-09-27 18:44:28 +00:00
|
|
|
buffer->markDirty();
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Document renamed to '"),
|
1999-09-27 18:44:28 +00:00
|
|
|
MakeDisplayPath(s),
|
|
|
|
_("', but not saved..."));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
} // Check whether the file exists
|
|
|
|
else {
|
|
|
|
FileInfo myfile(s);
|
|
|
|
if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
|
1999-11-15 12:01:38 +00:00
|
|
|
MakeDisplayPath(s, 50),
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Replace file?")))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok, change the name of the buffer
|
1999-12-10 00:07:59 +00:00
|
|
|
buffer->fileName(s);
|
1999-09-27 18:44:28 +00:00
|
|
|
buffer->markDirty();
|
|
|
|
// And save
|
|
|
|
// Small bug: If the save fails, we have irreversible changed the name
|
|
|
|
// of the document.
|
|
|
|
MenuWrite(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int MenuRunLaTeX(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (buffer->isLinuxDoc())
|
1999-12-10 00:07:59 +00:00
|
|
|
ret = RunLinuxDoc(1, buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
else if (buffer->isLiterate())
|
|
|
|
ret = buffer->runLiterate();
|
|
|
|
else if (buffer->isDocBook())
|
1999-12-10 00:07:59 +00:00
|
|
|
ret = RunDocBook(1, buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
|
|
|
ret = buffer->runLaTeX();
|
|
|
|
|
|
|
|
if (ret > 0) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string s;
|
|
|
|
string t;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (ret == 1) {
|
|
|
|
s = _("One error detected");
|
|
|
|
t = _("You should try to fix it.");
|
|
|
|
} else {
|
1999-10-19 16:48:35 +00:00
|
|
|
s += tostr(ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
s += _(" errors detected.");
|
|
|
|
t = _("You should try to fix them.");
|
|
|
|
}
|
|
|
|
WriteAlert(_("There were errors during the LaTeX run."), s, t);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int MenuBuildProg(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-26 06:57:35 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (buffer->isLiterate())
|
|
|
|
ret = buffer->buildProgram();
|
|
|
|
else {
|
|
|
|
string s = _("Wrong type of document");
|
|
|
|
string t = _("The Build operation is not allowed in this document");
|
|
|
|
WriteAlert(_("There were errors during the Build process."), s, t);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret > 0) {
|
|
|
|
string s;
|
|
|
|
string t;
|
|
|
|
if (ret == 1) {
|
|
|
|
s = _("One error detected");
|
|
|
|
t = _("You should try to fix it.");
|
|
|
|
} else {
|
|
|
|
s += tostr(ret);
|
|
|
|
s += _(" errors detected.");
|
|
|
|
t = _("You should try to fix them.");
|
|
|
|
}
|
|
|
|
WriteAlert(_("There were errors during the Build process."), s, t);
|
|
|
|
}
|
|
|
|
return ret;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int MenuRunChktex(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (buffer->isSGML()) {
|
|
|
|
WriteAlert(_("Chktex does not work with SGML derived documents."));
|
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
ret = buffer->runChktex();
|
|
|
|
|
|
|
|
if (ret >= 0) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string s;
|
|
|
|
string t;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
s = _("No warnings found.");
|
|
|
|
} else if (ret == 1) {
|
|
|
|
s = _("One warning found.");
|
|
|
|
t = _("Use 'Edit->Go to Error' to find it.");
|
|
|
|
} else {
|
1999-10-19 16:48:35 +00:00
|
|
|
s += tostr(ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
s += _(" warnings found.");
|
|
|
|
t = _("Use 'Edit->Go to Error' to find them.");
|
|
|
|
}
|
|
|
|
WriteAlert(_("Chktex run successfully"), s, t);
|
|
|
|
} else {
|
1999-11-15 12:01:38 +00:00
|
|
|
WriteAlert(_("Error!"), _("It seems chktex does not work."));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
int MakeLaTeXOutput(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return 1;
|
1999-09-27 18:44:28 +00:00
|
|
|
int ret = 0;
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
|
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
|
|
|
if (!buffer->isDviClean()) {
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
ret = MenuRunLaTeX(buffer);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* wait == false means don't wait for termination */
|
|
|
|
/* wait == true means wait for termination */
|
|
|
|
// The bool should be placed last on the argument line. (Lgb)
|
|
|
|
// Returns false if we fail.
|
1999-11-02 21:19:58 +00:00
|
|
|
bool RunScript(Buffer * buffer, bool wait,
|
1999-11-26 06:57:35 +00:00
|
|
|
string const & command,
|
|
|
|
string const & orgname = string(),
|
1999-11-15 12:01:38 +00:00
|
|
|
bool need_shell = true)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string path;
|
|
|
|
string cmd;
|
1999-11-15 12:01:38 +00:00
|
|
|
string name = orgname;
|
1999-09-27 18:44:28 +00:00
|
|
|
int result = 0;
|
|
|
|
|
2000-01-11 01:59:00 +00:00
|
|
|
if (MakeLaTeXOutput(buffer) > 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
return false;
|
|
|
|
/* get DVI-Filename */
|
|
|
|
if (name.empty())
|
1999-12-03 13:51:01 +00:00
|
|
|
name = ChangeExtension(buffer->getLatexName(),
|
1999-09-27 18:44:28 +00:00
|
|
|
".dvi", true);
|
|
|
|
|
|
|
|
path = OnlyPath(name);
|
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
|
|
|
|
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;
|
|
|
|
std::string::size_type i;
|
|
|
|
if ( (i=command.find("$$FName")) != std::string::npos)
|
|
|
|
{
|
|
|
|
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...
|
|
|
|
#ifdef WITH_WARNINGS
|
|
|
|
#warning What should we do here?
|
|
|
|
#endif
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(
|
1999-12-19 22:35:36 +00:00
|
|
|
_("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-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(
|
1999-12-19 22:35:36 +00:00
|
|
|
_("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
|
|
|
|
|
|
|
ProhibitInput();
|
|
|
|
|
|
|
|
// Generate dvi file
|
2000-01-11 01:59:00 +00:00
|
|
|
if (MakeLaTeXOutput(buffer) > 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
AllowInput();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Generate postscript file
|
1999-12-10 00:07:59 +00:00
|
|
|
string psname = ChangeExtension (buffer->fileName(),
|
1999-12-16 06:43:25 +00:00
|
|
|
".ps_tmp", true);
|
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)
|
1999-09-27 18:44:28 +00:00
|
|
|
real_papersize = lyxrc->default_papersize;
|
|
|
|
|
|
|
|
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-01-11 01:59:00 +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
|
1999-09-27 18:44:28 +00:00
|
|
|
&& !lyxrc->print_paper_dimension_flag.empty()
|
|
|
|
&& !buffer->params.paperwidth.empty()
|
|
|
|
&& !buffer->params.paperheight.empty()) {
|
|
|
|
// using a custom papersize
|
|
|
|
command += ' ';
|
|
|
|
command += lyxrc->print_paper_dimension_flag + ' ';
|
|
|
|
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 += ' ';
|
|
|
|
command += lyxrc->print_paper_flag + ' ' + paper;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
|
1999-09-27 18:44:28 +00:00
|
|
|
command += ' ';
|
|
|
|
command += lyxrc->print_landscape_flag;
|
|
|
|
}
|
|
|
|
// push directorypath, if necessary
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
|
|
|
|
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);
|
|
|
|
AllowInput();
|
|
|
|
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
|
|
|
|
ProhibitInput();
|
1999-12-10 00:07:59 +00:00
|
|
|
string ps = ChangeExtension (buffer->fileName(),
|
1999-12-16 06:43:25 +00:00
|
|
|
".ps_tmp", true);
|
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());
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
|
|
|
|
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, false, lyxrc->view_ps_command, ps);
|
|
|
|
AllowInput();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuFax(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Generate postscript file
|
2000-01-11 01:59:00 +00:00
|
|
|
if (!CreatePostscript(buffer, true)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send fax
|
1999-12-10 00:07:59 +00:00
|
|
|
string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true);
|
|
|
|
string path = OnlyPath (buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
|
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!lyxrc->fax_program.empty()) {
|
1999-10-26 23:33:30 +00:00
|
|
|
string help2 = subst(lyxrc->fax_program, "$$FName", ps);
|
1999-09-27 18:44:28 +00:00
|
|
|
help2 += " &";
|
|
|
|
Systemcalls one(Systemcalls::System, help2);
|
|
|
|
} else
|
1999-11-15 12:01:38 +00:00
|
|
|
send_fax(ps, lyxrc->fax_command);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns false if we fail
|
2000-01-11 01:59:00 +00:00
|
|
|
bool PreviewDVI(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return false;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2000-02-15 13:30:49 +00:00
|
|
|
string paper = lyxrc->view_dvi_paper_option;
|
|
|
|
if (!paper.empty()) {
|
|
|
|
// wrong type
|
|
|
|
char real_papersize = buffer->params.papersize;
|
|
|
|
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
|
|
|
real_papersize = lyxrc->default_papersize;
|
|
|
|
|
|
|
|
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());
|
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
|
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
|
|
|
Path p(path);
|
|
|
|
// Run dvi-viewer
|
|
|
|
string command = lyxrc->view_dvi_command + " " + paper;
|
1999-09-27 18:44:28 +00:00
|
|
|
bool ret = RunScript(buffer, false, command);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
!AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to overwrite the file?"))) {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
1999-12-16 06:43:25 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (buffer->isDocBook())
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(
|
1999-12-19 22:35:36 +00:00
|
|
|
_("DocBook does not have a latex backend"));
|
1999-12-10 00:07:59 +00:00
|
|
|
else {
|
|
|
|
if (buffer->isLinuxDoc())
|
|
|
|
RunLinuxDoc(0, buffer->fileName());
|
|
|
|
else
|
|
|
|
buffer->makeLaTeXFile(s, string(), true);
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(
|
1999-12-19 22:35:36 +00:00
|
|
|
_("Nice LaTeX file saved as"), MakeDisplayPath(s));
|
1999-12-10 00:07:59 +00:00
|
|
|
buffer->markDviDirty();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuMakeLinuxDoc(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text) return;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
if (!buffer->isLinuxDoc()) {
|
|
|
|
WriteAlert(_("Error!"), _("Document class must be linuxdoc."));
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
// Get LinuxDoc-Filename
|
2000-01-07 03:42:16 +00:00
|
|
|
string s = ChangeExtension(buffer->fileName(),
|
|
|
|
".sgml", false);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
!AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to overwrite the file?"))) {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Building LinuxDoc SGML file `"),
|
|
|
|
MakeDisplayPath(s),"'...");
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
buffer->makeLinuxDocFile(s, 65);
|
|
|
|
buffer->redraw();
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("LinuxDoc SGML file save as"),
|
|
|
|
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-01-07 03:42:16 +00:00
|
|
|
string s = ChangeExtension(buffer->fileName(),
|
|
|
|
".sgml", false);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
!AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to overwrite the file?"))) {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Building DocBook SGML file `"),
|
|
|
|
MakeDisplayPath(s), "'...");
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
buffer->makeDocBookFile(s, 65);
|
|
|
|
buffer->redraw();
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("DocBook SGML file save as"),
|
|
|
|
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 */
|
|
|
|
string s = ChangeExtension (buffer->fileName(),
|
|
|
|
".txt", false);
|
|
|
|
|
|
|
|
FileInfo fi(s);
|
|
|
|
if (fi.readable() &&
|
|
|
|
!AskQuestion(_("File already exists:"),
|
|
|
|
MakeDisplayPath(s, 50),
|
|
|
|
_("Do you want to overwrite the file?"))) {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
buffer->writeFileAscii(s, lyxrc->ascii_linelen);
|
|
|
|
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Ascii file saved as"), MakeDisplayPath(s));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuPrint(Buffer * buffer)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-01-07 03:42:16 +00:00
|
|
|
// Who cares?
|
|
|
|
//if (!bv->text)
|
|
|
|
// return;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
string input_file = ChangeExtension(buffer->fileName(),
|
1999-12-16 06:43:25 +00:00
|
|
|
lyxrc->print_file_extension,
|
|
|
|
true);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_input(fd_form_print->input_file, input_file.c_str());
|
|
|
|
|
|
|
|
if (fd_form_print->form_print->visible) {
|
|
|
|
fl_raise_form(fd_form_print->form_print);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_show_form(fd_form_print->form_print,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Print"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
string result = ChangeExtension(file, ".html", false);
|
1999-12-20 17:38:37 +00:00
|
|
|
string infile = buffer->getLatexName(false);
|
1999-12-15 17:42:22 +00:00
|
|
|
string tmp = lyxrc->html_command;
|
|
|
|
tmp = subst(tmp, "$$FName", infile);
|
|
|
|
tmp = subst(tmp, "$$OutName", result);
|
|
|
|
Systemcalls one;
|
|
|
|
int res = one.startscript(Systemcalls::System, tmp);
|
|
|
|
if (res == 0) {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Document exported as HTML to file `")
|
|
|
|
+ MakeDisplayPath(result) +'\'');
|
1999-12-15 17:42:22 +00:00
|
|
|
} else {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Unable to convert to HTML the file `")
|
|
|
|
+ MakeDisplayPath(infile)
|
|
|
|
+ '\'');
|
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)
|
1999-12-15 17:42:22 +00:00
|
|
|
bool flag = lyxrc->use_tempdir;
|
|
|
|
lyxrc->use_tempdir = false;
|
|
|
|
MenuRunLaTeX(buffer);
|
|
|
|
lyxrc->use_tempdir = flag;
|
|
|
|
}
|
|
|
|
// postscript
|
|
|
|
else if (extyp == "postscript") {
|
1999-12-16 06:43:25 +00:00
|
|
|
// Start Print-dialog. Not as good as dvi... Bernhard.
|
1999-12-15 17:42:22 +00:00
|
|
|
MenuPrint(buffer);
|
|
|
|
// Since the MenuPrint is a pop-up, we can't use
|
|
|
|
// the same trick as above. (Asger)
|
|
|
|
// MISSING: Move of ps-file :-(
|
2000-01-07 03:42:16 +00:00
|
|
|
// And MenuPrint should not be used for this at all...
|
1999-12-15 17:42:22 +00:00
|
|
|
}
|
|
|
|
// ascii
|
|
|
|
else if (extyp == "ascii") {
|
|
|
|
MenuMakeAscii(buffer);
|
|
|
|
}
|
|
|
|
else if (extyp == "custom") {
|
|
|
|
MenuSendto();
|
|
|
|
}
|
|
|
|
// HTML
|
|
|
|
else if (extyp == "html") {
|
|
|
|
MenuMakeHTML(buffer);
|
|
|
|
}
|
|
|
|
else {
|
2000-01-07 03:42:16 +00:00
|
|
|
buffer->getUser()->owner()->getMiniBuffer()->Set(_("Unknown export type: ") + extyp);
|
1999-12-15 17:42:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
void QuitLyX()
|
|
|
|
{
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Running QuitLyX." << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!bufferlist.QwriteAll())
|
|
|
|
return;
|
|
|
|
|
|
|
|
lastfiles->writeFile(lyxrc->lastfiles);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AutoSave()
|
|
|
|
// should probably be moved into BufferList (Lgb)
|
|
|
|
// Perfect target for a thread...
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isBakClean()
|
|
|
|
|| current_view->buffer()->isReadonly()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// We don't save now, but we'll try again later
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->owner()->resetAutosaveTimer();
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// create autosave filename
|
1999-12-10 00:07:59 +00:00
|
|
|
string fname = OnlyPath(current_view->buffer()->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
fname += "#";
|
1999-12-10 00:07:59 +00:00
|
|
|
fname += OnlyFilename(current_view->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()) {
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->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
|
1999-11-09 23:52:04 +00:00
|
|
|
if (!current_view->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)
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pid == 0) { // we are the child so...
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markBakClean();
|
|
|
|
current_view->owner()->resetAutosaveTimer();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// (c) CHT Software Service GmbH
|
|
|
|
// 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)
|
1999-10-02 16:21:10 +00:00
|
|
|
void InsertAsciiFile(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-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()) return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fname.empty()) {
|
|
|
|
ProhibitInput();
|
|
|
|
fname = fileDlg.Select(_("File to Insert"),
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->owner()->buffer()->filepath,
|
1999-09-27 18:44:28 +00:00
|
|
|
"*");
|
|
|
|
AllowInput();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
LyXParagraph * tmppar = new LyXParagraph;
|
2000-01-06 02:44:26 +00:00
|
|
|
tmppar->readSimpleWholeFile(ifs);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// set the end of the string
|
1999-12-01 14:41:31 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
1999-11-15 12:01:38 +00:00
|
|
|
#warning why do we do this?
|
1999-12-01 14:41:31 +00:00
|
|
|
#endif
|
1999-11-04 01:40:20 +00:00
|
|
|
// I don't think this is needed. Actually it might be plain wrong.
|
1999-11-26 06:57:35 +00:00
|
|
|
tmppar->InsertChar(tmppar->text.size() - 1, '\0');
|
1999-11-15 12:01:38 +00:00
|
|
|
|
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-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
if (!asParagraph)
|
|
|
|
current_view->text->InsertStringA(tmppar->text);
|
|
|
|
else
|
|
|
|
current_view->text->InsertStringB(tmppar->text);
|
|
|
|
delete tmppar;
|
|
|
|
current_view->update(1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuShowTableOfContents()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
TocUpdateCB(0, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_toc->form_toc->visible) {
|
|
|
|
fl_raise_form(fd_form_toc->form_toc);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_toc->form_toc,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
|
|
|
_("Table Of Contents"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_toc->form_toc->w;
|
|
|
|
oh = fd_form_toc->form_toc->h;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void MenuInsertLabel(char const * arg)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string label = arg;
|
1999-09-27 18:44:28 +00:00
|
|
|
ProhibitInput();
|
1999-12-30 02:35:43 +00:00
|
|
|
if (label.empty()) {
|
|
|
|
pair<bool, string>
|
|
|
|
result = askForText(_("Enter new label to insert:"));
|
|
|
|
if (result.first) {
|
|
|
|
label = frontStrip(strip(result.second));
|
|
|
|
}
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!label.empty()) {
|
1999-11-22 16:19:48 +00:00
|
|
|
InsetLabel * new_inset = new InsetLabel;
|
1999-09-27 18:44:28 +00:00
|
|
|
new_inset->setContents(label);
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
AllowInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuInsertRef()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
RefUpdateCB(0, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_ref->form_ref->visible) {
|
|
|
|
fl_raise_form(fd_form_ref->form_ref);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_ref->form_ref,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
|
|
|
_("Insert Reference"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_ref->form_ref->w;
|
|
|
|
oh = fd_form_ref->form_ref->h;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_form_minsize(fd_form_ref->form_ref, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuPasteSelection(char at)
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ascii_type = at;
|
|
|
|
|
|
|
|
Atom data_prop = XInternAtom(fl_display,
|
|
|
|
"LyX_Primary",
|
|
|
|
false);
|
|
|
|
if (data_prop == None)
|
|
|
|
return;
|
|
|
|
XConvertSelection(fl_display,
|
|
|
|
XA_PRIMARY, XA_STRING, data_prop,
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getForm()->window, 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
XFlush(fl_display);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// candidate for move to BufferView
|
2000-02-04 09:38:32 +00:00
|
|
|
void Foot(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (!bv->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->owner()->getMiniBuffer()
|
|
|
|
->Set(_("Inserting Footnote..."));
|
2000-02-17 19:59:08 +00:00
|
|
|
bv->hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->update(-2);
|
|
|
|
bv->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
|
|
|
|
bv->update(1);
|
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
|
1999-09-27 18:44:28 +00:00
|
|
|
void LayoutsCB(int sel, void *)
|
|
|
|
{
|
1999-10-19 10:32:10 +00:00
|
|
|
string tmp = tostr(sel);
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
|
1999-12-16 06:43:25 +00:00
|
|
|
tmp.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SGML Linuxdoc support:
|
|
|
|
* (flag == -1) import SGML file
|
|
|
|
* (flag == 0) make TeX output
|
|
|
|
* (flag == 1) make dvi output
|
|
|
|
*/
|
1999-10-02 16:21:10 +00:00
|
|
|
int RunLinuxDoc(int flag, string const & filename)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-10-02 16:21:10 +00:00
|
|
|
string name;
|
|
|
|
string s2;
|
|
|
|
string path;
|
|
|
|
string add_flags;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
int errorcode = 0;
|
|
|
|
|
|
|
|
/* generate a path-less extension name */
|
|
|
|
name = ChangeExtension (filename, ".sgml", true);
|
|
|
|
path = OnlyPath (filename);
|
|
|
|
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 (flag != -1) {
|
|
|
|
if (!current_view->available())
|
|
|
|
return 0;
|
1999-11-15 12:01:38 +00:00
|
|
|
current_view->buffer()->makeLinuxDocFile(name, 0);
|
1999-11-17 15:05:26 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
|
|
|
#warning remove this once we have a proper geometry class
|
|
|
|
#endif
|
|
|
|
BufferParams::PAPER_SIZE ps = static_cast<BufferParams::PAPER_SIZE>(current_view->buffer()->params.papersize);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (ps) {
|
1999-11-22 16:19:48 +00:00
|
|
|
case BufferParams::PAPER_A4PAPER:
|
|
|
|
add_flags = "-p a4";
|
|
|
|
break;
|
|
|
|
case BufferParams::PAPER_USLETTER:
|
|
|
|
add_flags = "-p letter";
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
default: /* nothing to be done yet ;-) */ break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProhibitInput();
|
|
|
|
|
|
|
|
Systemcalls one;
|
|
|
|
switch (flag) {
|
|
|
|
case -1: /* Import file */
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Importing LinuxDoc SGML file `"),
|
1999-09-27 18:44:28 +00:00
|
|
|
MakeDisplayPath(filename), "'...");
|
|
|
|
s2 = "sgml2lyx " + lyxrc->sgml_extra_options + ' '
|
|
|
|
+ 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 0: /* TeX output asked */
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
s2 = "sgml2latex " + add_flags + " -o tex "
|
|
|
|
+ lyxrc->sgml_extra_options + ' ' + 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 */
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
s2 = "sgml2latex " + add_flags + " -o dvi "
|
|
|
|
+ lyxrc->sgml_extra_options + ' ' + name;
|
1999-10-12 21:37:10 +00:00
|
|
|
if (one.startscript(Systemcalls::System, s2)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
errorcode = 1;
|
|
|
|
} else
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDviClean();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
default: /* unknown output */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
AllowInput();
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->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 */
|
1999-11-26 06:57:35 +00:00
|
|
|
string name = ChangeExtension (filename, ".sgml", true);
|
|
|
|
string path = OnlyPath (filename);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
|
1999-11-09 23:52:04 +00:00
|
|
|
path = current_view->buffer()->tmppath;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (!current_view->available())
|
|
|
|
return 0;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
current_view->buffer()->makeDocBookFile(name, 0);
|
1999-11-04 01:40:20 +00:00
|
|
|
|
|
|
|
// Shall this code go or should it stay? (Lgb)
|
|
|
|
// 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;
|
|
|
|
// }
|
1999-09-27 18:44:28 +00:00
|
|
|
ProhibitInput();
|
|
|
|
|
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..."));
|
1999-11-26 06:57:35 +00:00
|
|
|
string s2 = "sgmltools --backend dvi " + name;
|
1999-10-12 21:37:10 +00:00
|
|
|
if (one.startscript(Systemcalls::System, s2)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
errorcode = 1;
|
|
|
|
} else
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDviClean();
|
1999-11-26 06:57:35 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
default: /* unknown output */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
AllowInput();
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->redraw();
|
1999-09-27 18:44:28 +00:00
|
|
|
return errorcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MenuLayoutCharacter()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_character->form_character->visible) {
|
|
|
|
fl_raise_form(fd_form_character->form_character);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_character->form_character,
|
1999-11-15 12:01:38 +00:00
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Character Style"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_character->form_character->w;
|
|
|
|
oh = fd_form_character->form_character->h;
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_set_form_minsize(fd_form_character->form_character, ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline void DeactivateParagraphButtons ()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline void ActivateParagraphButtons ()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline void DisableParagraphLayout ()
|
|
|
|
{
|
|
|
|
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
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline void EnableParagraphLayout ()
|
|
|
|
{
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
fl_activate_object (fd_form_paragraph->input_labelwidth);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_lines_top);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_lines_bottom);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_pagebreaks_top);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_pagebreaks_bottom);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_noindent);
|
|
|
|
fl_activate_object (fd_form_paragraph->group_radio_alignment);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_right);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_left);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_block);
|
|
|
|
fl_activate_object (fd_form_paragraph->radio_align_center);
|
|
|
|
fl_activate_object (fd_form_paragraph->input_space_above);
|
|
|
|
fl_activate_object (fd_form_paragraph->input_space_below);
|
|
|
|
fl_activate_object (fd_form_paragraph->choice_space_above);
|
|
|
|
fl_activate_object (fd_form_paragraph->choice_space_below);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_space_above);
|
|
|
|
fl_activate_object (fd_form_paragraph->check_space_below);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
bool UpdateLayoutParagraph()
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()) {
|
1999-12-10 00:07:59 +00:00
|
|
|
if (fd_form_paragraph->form_paragraph->visible)
|
|
|
|
fl_hide_form(fd_form_paragraph->form_paragraph);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffer * buf = current_view->buffer();
|
|
|
|
|
|
|
|
fl_set_input(fd_form_paragraph->input_labelwidth,
|
|
|
|
current_view->text->cursor.par->GetLabelWidthString().c_str());
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_right, 0);
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_left, 0);
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_center, 0);
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_block, 0);
|
|
|
|
|
|
|
|
int align = current_view->text->cursor.par->GetAlign();
|
|
|
|
if (align == LYX_ALIGN_LAYOUT)
|
|
|
|
align = textclasslist.Style(buf->params.textclass,
|
1999-12-16 06:43:25 +00:00
|
|
|
current_view->text->cursor.par->GetLayout()).align;
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
switch (align) {
|
|
|
|
case LYX_ALIGN_RIGHT:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_right, 1);
|
|
|
|
break;
|
|
|
|
case LYX_ALIGN_LEFT:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_left, 1);
|
|
|
|
break;
|
|
|
|
case LYX_ALIGN_CENTER:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_center, 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fl_set_button(fd_form_paragraph->radio_align_block, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_set_button(fd_form_paragraph->check_lines_top,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->line_top);
|
|
|
|
fl_set_button(fd_form_paragraph->check_lines_bottom,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
|
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
|
|
|
|
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
|
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->noindent);
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_above, "");
|
|
|
|
|
|
|
|
switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
|
|
|
|
case VSpace::NONE:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
|
|
|
|
break;
|
|
|
|
case VSpace::DEFSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 2);
|
|
|
|
break;
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 3);
|
|
|
|
break;
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 4);
|
|
|
|
break;
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 5);
|
|
|
|
break;
|
|
|
|
case VSpace::VFILL:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 6);
|
|
|
|
break;
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 7);
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_above,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_above,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_below, "");
|
|
|
|
switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.kind()) {
|
|
|
|
case VSpace::NONE:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
1);
|
|
|
|
break;
|
|
|
|
case VSpace::DEFSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
2);
|
|
|
|
break;
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
3);
|
|
|
|
break;
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
4);
|
|
|
|
break;
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
5);
|
|
|
|
break;
|
|
|
|
case VSpace::VFILL:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
6);
|
|
|
|
break;
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below,
|
|
|
|
7);
|
|
|
|
fl_set_input (fd_form_paragraph->input_space_below,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fl_set_button (fd_form_paragraph->check_space_below,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.keep());
|
|
|
|
|
|
|
|
fl_set_button(fd_form_paragraph->check_noindent,
|
|
|
|
current_view->text->cursor.par->FirstPhysicalPar()->noindent);
|
|
|
|
|
|
|
|
if (current_view->buffer()->isReadonly()) {
|
|
|
|
DisableParagraphLayout();
|
|
|
|
} else {
|
|
|
|
EnableParagraphLayout();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutParagraph()
|
|
|
|
{
|
|
|
|
if (UpdateLayoutParagraph()) {
|
|
|
|
if (fd_form_paragraph->form_paragraph->visible) {
|
|
|
|
fl_raise_form(fd_form_paragraph->form_paragraph);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_paragraph->form_paragraph,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Paragraph Environment"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void DeactivateDocumentButtons ()
|
|
|
|
{
|
|
|
|
fl_deactivate_object (fd_form_document->button_ok);
|
|
|
|
fl_deactivate_object (fd_form_document->button_apply);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_ok, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_apply, FL_INACTIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void ActivateDocumentButtons ()
|
|
|
|
{
|
|
|
|
fl_activate_object (fd_form_document->button_ok);
|
|
|
|
fl_activate_object (fd_form_document->button_apply);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_ok, FL_BLACK);
|
|
|
|
fl_set_object_lcol (fd_form_document->button_apply, FL_BLACK);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline
|
|
|
|
void DisableDocumentLayout ()
|
|
|
|
{
|
|
|
|
DeactivateDocumentButtons ();
|
|
|
|
fl_deactivate_object (fd_form_document->group_radio_separation);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_indent);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_skip);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_class);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_pagestyle);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_fonts);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_fontsize);
|
|
|
|
fl_deactivate_object (fd_form_document->input_float_placement);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_postscript_driver);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_inputenc);
|
|
|
|
fl_deactivate_object (fd_form_document->group_radio_sides);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_sides_one);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_sides_two);
|
|
|
|
fl_deactivate_object (fd_form_document->group_radio_columns);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_columns_one);
|
|
|
|
fl_deactivate_object (fd_form_document->radio_columns_two);
|
|
|
|
fl_deactivate_object (fd_form_document->input_extra);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_language);
|
|
|
|
combo_language->deactivate();
|
|
|
|
fl_deactivate_object (fd_form_document->input_default_skip);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_default_skip);
|
|
|
|
fl_deactivate_object (fd_form_document->slider_secnumdepth);
|
|
|
|
fl_deactivate_object (fd_form_document->slider_tocdepth);
|
|
|
|
fl_deactivate_object (fd_form_document->choice_spacing);
|
|
|
|
fl_deactivate_object (fd_form_document->input_spacing);
|
|
|
|
fl_deactivate_object (fd_form_document->check_use_amsmath);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
inline
|
|
|
|
void EnableDocumentLayout ()
|
|
|
|
{
|
|
|
|
ActivateDocumentButtons ();
|
|
|
|
fl_activate_object (fd_form_document->group_radio_separation);
|
|
|
|
fl_activate_object (fd_form_document->radio_indent);
|
|
|
|
fl_activate_object (fd_form_document->radio_skip);
|
|
|
|
fl_activate_object (fd_form_document->choice_class);
|
|
|
|
fl_activate_object (fd_form_document->choice_pagestyle);
|
|
|
|
fl_activate_object (fd_form_document->choice_fonts);
|
|
|
|
fl_activate_object (fd_form_document->choice_fontsize);
|
|
|
|
fl_activate_object (fd_form_document->input_float_placement);
|
|
|
|
fl_activate_object (fd_form_document->choice_postscript_driver);
|
|
|
|
fl_activate_object (fd_form_document->choice_inputenc);
|
|
|
|
fl_activate_object (fd_form_document->group_radio_sides);
|
|
|
|
fl_activate_object (fd_form_document->radio_sides_one);
|
|
|
|
fl_activate_object (fd_form_document->radio_sides_two);
|
|
|
|
fl_activate_object (fd_form_document->group_radio_columns);
|
|
|
|
fl_activate_object (fd_form_document->radio_columns_one);
|
|
|
|
fl_activate_object (fd_form_document->radio_columns_two);
|
|
|
|
fl_activate_object (fd_form_document->input_extra);
|
|
|
|
fl_activate_object (fd_form_document->choice_language);
|
|
|
|
combo_language->activate();
|
|
|
|
fl_activate_object (fd_form_document->input_default_skip);
|
|
|
|
fl_activate_object (fd_form_document->choice_default_skip);
|
|
|
|
fl_activate_object (fd_form_document->slider_secnumdepth);
|
|
|
|
fl_activate_object (fd_form_document->slider_tocdepth);
|
|
|
|
fl_activate_object (fd_form_document->choice_spacing);
|
|
|
|
fl_activate_object (fd_form_document->input_spacing);
|
|
|
|
fl_activate_object (fd_form_document->check_use_amsmath);
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
|
|
|
bool UpdateLayoutDocument(BufferParams * params)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_document->form_document->visible)
|
|
|
|
fl_hide_form(fd_form_document->form_document);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
if (params == 0)
|
1999-11-09 23:52:04 +00:00
|
|
|
params = ¤t_view->buffer()->params;
|
1999-11-04 01:40:20 +00:00
|
|
|
LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_choice_text(fd_form_document->choice_class,
|
1999-11-04 01:40:20 +00:00
|
|
|
textclasslist.DescOfClass(params->textclass).c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
combo_language->select_text(params->language.c_str());
|
|
|
|
|
|
|
|
fl_set_choice_text(fd_form_document->choice_fonts,
|
|
|
|
params->fonts.c_str());
|
|
|
|
fl_set_choice_text(fd_form_document->choice_inputenc,
|
|
|
|
params->inputenc.c_str());
|
|
|
|
fl_set_choice_text(fd_form_document->choice_postscript_driver,
|
|
|
|
params->graphicsDriver.c_str());
|
|
|
|
|
|
|
|
// ale970405+lasgoutt970513
|
|
|
|
fl_clear_choice(fd_form_document->choice_fontsize);
|
|
|
|
fl_addto_choice(fd_form_document->choice_fontsize, "default");
|
|
|
|
fl_addto_choice(fd_form_document->choice_fontsize,
|
1999-11-04 01:40:20 +00:00
|
|
|
tclass.opt_fontsize().c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_choice(fd_form_document->choice_fontsize,
|
1999-11-04 01:40:20 +00:00
|
|
|
tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// ale970405+lasgoutt970513
|
|
|
|
fl_clear_choice(fd_form_document->choice_pagestyle);
|
|
|
|
fl_addto_choice(fd_form_document->choice_pagestyle, "default");
|
|
|
|
fl_addto_choice(fd_form_document->choice_pagestyle,
|
1999-11-04 01:40:20 +00:00
|
|
|
tclass.opt_pagestyle().c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_choice(fd_form_document->choice_pagestyle,
|
1999-11-04 01:40:20 +00:00
|
|
|
tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_button(fd_form_document->radio_indent, 0);
|
|
|
|
fl_set_button(fd_form_document->radio_skip, 0);
|
|
|
|
|
|
|
|
|
|
|
|
fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath);
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
if (params->paragraph_separation == BufferParams::PARSEP_INDENT)
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_document->radio_indent, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_document->radio_skip, 1);
|
|
|
|
|
|
|
|
switch (params->getDefSkip().kind()) {
|
|
|
|
case VSpace::SMALLSKIP:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 1);
|
|
|
|
break;
|
|
|
|
case VSpace::MEDSKIP:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 2);
|
|
|
|
break;
|
|
|
|
case VSpace::BIGSKIP:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 3);
|
|
|
|
break;
|
|
|
|
case VSpace::LENGTH:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 4);
|
|
|
|
fl_set_input (fd_form_document->input_default_skip,
|
|
|
|
params->getDefSkip().asLyXCommand().c_str());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fl_set_choice (fd_form_document->choice_default_skip, 2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fl_set_button(fd_form_document->radio_sides_one, 0);
|
|
|
|
fl_set_button(fd_form_document->radio_sides_two, 0);
|
|
|
|
|
2000-01-28 11:50:57 +00:00
|
|
|
switch (params->sides) {
|
|
|
|
case LyXTextClass::OneSide:
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_document->radio_sides_one, 1);
|
2000-01-28 11:50:57 +00:00
|
|
|
break;
|
|
|
|
case LyXTextClass::TwoSides:
|
|
|
|
fl_set_button(fd_form_document->radio_sides_two, 1);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_set_button(fd_form_document->radio_columns_one, 0);
|
|
|
|
fl_set_button(fd_form_document->radio_columns_two, 0);
|
|
|
|
|
|
|
|
if (params->columns == 2)
|
|
|
|
fl_set_button(fd_form_document->radio_columns_two, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_document->radio_columns_one, 1);
|
|
|
|
|
|
|
|
fl_set_input(fd_form_document->input_spacing, "");
|
|
|
|
switch (params->spacing.getSpace()) {
|
|
|
|
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);
|
|
|
|
char sval[20];
|
|
|
|
sprintf(sval, "%g", params->spacing.getValue());
|
|
|
|
fl_set_input(fd_form_document->input_spacing, sval);
|
|
|
|
break;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fl_set_counter_value(fd_form_document->slider_secnumdepth,
|
|
|
|
params->secnumdepth);
|
|
|
|
fl_set_counter_value(fd_form_document->slider_tocdepth,
|
|
|
|
params->tocdepth);
|
|
|
|
if (!params->float_placement.empty()) { // buffer local (Lgb)
|
|
|
|
fl_set_input(fd_form_document->input_float_placement,
|
|
|
|
params->float_placement.c_str());
|
|
|
|
} else {
|
|
|
|
fl_set_input(fd_form_document->input_float_placement, "");
|
|
|
|
}
|
|
|
|
if (!params->options.empty())
|
|
|
|
fl_set_input(fd_form_document->input_extra,
|
|
|
|
params->options.c_str());
|
|
|
|
else
|
|
|
|
fl_set_input(fd_form_document->input_extra, "");
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isSGML()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// bullets not used in SGML derived documents
|
|
|
|
fl_deactivate_object(fd_form_document->button_bullets);
|
|
|
|
fl_set_object_lcol(fd_form_document->button_bullets,
|
|
|
|
FL_INACTIVE);
|
|
|
|
} else {
|
|
|
|
fl_activate_object(fd_form_document->button_bullets);
|
|
|
|
fl_set_object_lcol(fd_form_document->button_bullets,
|
|
|
|
FL_BLACK);
|
|
|
|
}
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isReadonly()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
DisableDocumentLayout();
|
|
|
|
} else {
|
|
|
|
EnableDocumentLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutDocument()
|
|
|
|
{
|
|
|
|
if (UpdateLayoutDocument()) {
|
|
|
|
if (fd_form_document->form_document->visible) {
|
|
|
|
fl_raise_form(fd_form_document->form_document);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_document->form_document,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Document Layout"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UpdateLayoutQuotes()
|
|
|
|
{
|
|
|
|
bool update = true;
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available()
|
1999-11-09 23:52:04 +00:00
|
|
|
|| current_view->buffer()->isReadonly())
|
1999-09-27 18:44:28 +00:00
|
|
|
update = false;
|
|
|
|
|
|
|
|
if (update) {
|
|
|
|
fl_set_choice(fd_form_quotes->choice_quotes_language,
|
1999-12-16 06:43:25 +00:00
|
|
|
current_view->buffer()->params.quotes_language + 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_quotes->radio_single, 0);
|
|
|
|
fl_set_button(fd_form_quotes->radio_double, 0);
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ)
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_quotes->radio_single, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_quotes->radio_double, 1);
|
|
|
|
} else if (fd_form_quotes->form_quotes->visible) {
|
|
|
|
fl_hide_form(fd_form_quotes->form_quotes);
|
|
|
|
}
|
|
|
|
return update;
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutQuotes()
|
|
|
|
{
|
|
|
|
if (UpdateLayoutQuotes()) {
|
|
|
|
if (fd_form_quotes->form_quotes->visible) {
|
|
|
|
fl_raise_form(fd_form_quotes->form_quotes);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_quotes->form_quotes,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Quotes"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool UpdateLayoutPreamble()
|
|
|
|
{
|
|
|
|
bool update = true;
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-16 06:43:25 +00:00
|
|
|
update = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (update) {
|
|
|
|
fl_set_input(fd_form_preamble->input_preamble,
|
1999-12-16 06:43:25 +00:00
|
|
|
current_view->buffer()->params.preamble.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isReadonly()) {
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_deactivate_object(fd_form_preamble->input_preamble);
|
|
|
|
fl_deactivate_object(fd_form_preamble->button_ok);
|
|
|
|
fl_deactivate_object(fd_form_preamble->button_apply);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_ok, FL_INACTIVE);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_apply, FL_INACTIVE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_activate_object(fd_form_preamble->input_preamble);
|
|
|
|
fl_activate_object(fd_form_preamble->button_ok);
|
|
|
|
fl_activate_object(fd_form_preamble->button_apply);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_ok, FL_BLACK);
|
|
|
|
fl_set_object_lcol(fd_form_preamble->button_apply, FL_BLACK);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
} else if (fd_form_preamble->form_preamble->visible) {
|
|
|
|
fl_hide_form(fd_form_preamble->form_preamble);
|
|
|
|
}
|
|
|
|
return update;
|
|
|
|
}
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutPreamble()
|
|
|
|
{
|
1999-10-25 14:50:26 +00:00
|
|
|
static int ow = -1, oh;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (UpdateLayoutPreamble()) {
|
|
|
|
if (fd_form_preamble->form_preamble->visible) {
|
|
|
|
fl_raise_form(fd_form_preamble->form_preamble);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_preamble->form_preamble,
|
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE,
|
|
|
|
FL_FULLBORDER,
|
|
|
|
_("LaTeX Preamble"));
|
1999-10-25 14:50:26 +00:00
|
|
|
if (ow < 0) {
|
|
|
|
ow = fd_form_preamble->form_preamble->w;
|
|
|
|
oh = fd_form_preamble->form_preamble->h;
|
|
|
|
}
|
|
|
|
fl_set_form_minsize(fd_form_preamble->form_preamble,
|
1999-11-15 12:01:38 +00:00
|
|
|
ow, oh);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
void MenuLayoutSave()
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-16 06:43:25 +00:00
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (AskQuestion(_("Do you want to save the current settings"),
|
|
|
|
_("for Character, Document, Paper and Quotes"),
|
|
|
|
_("as default for new documents?")))
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->saveParamsAsDefaults();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------> These CB's use ToggleFree() as the (one and only?) font-changer.
|
|
|
|
They also show the current font state. */
|
|
|
|
|
|
|
|
static
|
2000-02-04 09:38:32 +00:00
|
|
|
void ToggleAndShow(BufferView *, LyXFont const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void FontSize(string const & size)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setGUISize(size);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Emph()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setEmph(LyXFont::TOGGLE);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Noun()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setNoun(LyXFont::TOGGLE);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Bold()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setSeries(LyXFont::BOLD_SERIES);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Underline()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setUnderbar(LyXFont::TOGGLE);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Code()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Sans()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setFamily(LyXFont::SANS_FAMILY);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Roman()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setFamily(LyXFont::ROMAN_FAMILY);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Tex()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setLatex (LyXFont::TOGGLE);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-02-03 19:51:27 +00:00
|
|
|
void RTLCB()
|
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
font.setDirection (LyXFont::TOGGLE_DIR);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
2000-02-03 19:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void StyleReset()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_INHERIT);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, font);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -------> Returns the current font and depth by printing a message. In the
|
|
|
|
* future perhaps we could try to implement a callback to the button-bar.
|
|
|
|
* That is, `light' the bold button when the font is currently bold, etc.
|
|
|
|
*/
|
1999-12-10 00:07:59 +00:00
|
|
|
string CurrentState()
|
|
|
|
{
|
|
|
|
string state;
|
|
|
|
if (current_view->available()) {
|
|
|
|
// I think we should only show changes from the default
|
|
|
|
// font. (Asger)
|
|
|
|
Buffer * buffer = current_view->buffer();
|
|
|
|
LyXFont font = current_view->text->real_current_font;
|
|
|
|
LyXFont defaultfont = textclasslist.TextClass(buffer->
|
1999-12-16 06:43:25 +00:00
|
|
|
params.textclass).defaultfont();
|
1999-12-10 00:07:59 +00:00
|
|
|
font.reduce(defaultfont);
|
|
|
|
state = _("Font: ") + font.stateText();
|
|
|
|
|
|
|
|
int depth = current_view->text->GetDepth();
|
|
|
|
if (depth > 0)
|
|
|
|
state += string(_(", Depth: ")) + tostr(depth);
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// candidate for move to BufferView
|
1999-09-27 18:44:28 +00:00
|
|
|
/* -------> Does the actual toggle job of the XxxCB() calls above.
|
|
|
|
* Also shows the current font state.
|
|
|
|
*/
|
|
|
|
static
|
2000-02-04 09:38:32 +00:00
|
|
|
void ToggleAndShow(BufferView * bv, LyXFont const & font)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (bv->available()) {
|
2000-02-17 19:59:08 +00:00
|
|
|
bv->hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->update(-2);
|
2000-02-25 12:06:15 +00:00
|
|
|
if (bv->the_locking_inset)
|
2000-02-25 16:05:26 +00:00
|
|
|
bv->the_locking_inset->SetFont(bv, font, toggleall);
|
2000-02-25 12:06:15 +00:00
|
|
|
else
|
|
|
|
bv->text->ToggleFree(font, toggleall);
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->update(1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// candidate for move to BufferView
|
2000-02-04 09:38:32 +00:00
|
|
|
void Margin(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (bv->available()) {
|
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Inserting margin note..."));
|
2000-02-17 19:59:08 +00:00
|
|
|
bv->hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->update(-2);
|
|
|
|
bv->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
|
|
|
|
bv->update(1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Figure()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
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"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Table()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (fd_form_table->form_table->visible) {
|
|
|
|
fl_raise_form(fd_form_table->form_table);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_form_table->form_table,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("Insert Table"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// candidate for move to BufferView
|
2000-02-04 09:38:32 +00:00
|
|
|
void Melt(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (!bv->available()) return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Melt"));
|
2000-02-17 19:59:08 +00:00
|
|
|
bv->hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->beforeChange();
|
|
|
|
bv->update(-2);
|
|
|
|
bv->text->MeltFootnoteEnvironment();
|
|
|
|
bv->update(1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// candidate for move to BufferView
|
1999-09-27 18:44:28 +00:00
|
|
|
// Change environment depth.
|
2000-02-04 09:38:32 +00:00
|
|
|
// if decInc >= 0, increment depth
|
|
|
|
// if decInc < 0, decrement depth
|
|
|
|
void changeDepth(BufferView * bv, int decInc)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (!bv->available()) return;
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
bv->hideCursor();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->update(-2);
|
|
|
|
if (decInc >= 0)
|
|
|
|
bv->text->IncDepth();
|
|
|
|
else
|
|
|
|
bv->text->DecDepth();
|
|
|
|
bv->update(1);
|
|
|
|
bv->owner()->getMiniBuffer()
|
|
|
|
->Set(_("Changed environment depth"
|
|
|
|
" (in possible range, maybe not)"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This is both GUI and LyXFont dependent. Don't know where to put it. (Asger)
|
|
|
|
// Well, it's mostly GUI dependent, so I guess it will stay here. (Asger)
|
|
|
|
LyXFont UserFreeFont()
|
|
|
|
{
|
|
|
|
LyXFont font(LyXFont::ALL_IGNORE);
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
int pos = fl_get_choice(fd_form_character->choice_family);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setFamily(LyXFont::IGNORE_FAMILY); break;
|
|
|
|
case 2: font.setFamily(LyXFont::ROMAN_FAMILY); break;
|
|
|
|
case 3: font.setFamily(LyXFont::SANS_FAMILY); break;
|
|
|
|
case 4: font.setFamily(LyXFont::TYPEWRITER_FAMILY); break;
|
|
|
|
case 5: font.setFamily(LyXFont::INHERIT_FAMILY); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_series);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setSeries(LyXFont::IGNORE_SERIES); break;
|
|
|
|
case 2: font.setSeries(LyXFont::MEDIUM_SERIES); break;
|
|
|
|
case 3: font.setSeries(LyXFont::BOLD_SERIES); break;
|
|
|
|
case 4: font.setSeries(LyXFont::INHERIT_SERIES); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_shape);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setShape(LyXFont::IGNORE_SHAPE); break;
|
|
|
|
case 2: font.setShape(LyXFont::UP_SHAPE); break;
|
|
|
|
case 3: font.setShape(LyXFont::ITALIC_SHAPE); break;
|
|
|
|
case 4: font.setShape(LyXFont::SLANTED_SHAPE); break;
|
|
|
|
case 5: font.setShape(LyXFont::SMALLCAPS_SHAPE); break;
|
|
|
|
case 6: font.setShape(LyXFont::INHERIT_SHAPE); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_size);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setSize(LyXFont::IGNORE_SIZE); break;
|
|
|
|
case 2: font.setSize(LyXFont::SIZE_TINY); break;
|
|
|
|
case 3: font.setSize(LyXFont::SIZE_SCRIPT); break;
|
|
|
|
case 4: font.setSize(LyXFont::SIZE_FOOTNOTE); break;
|
|
|
|
case 5: font.setSize(LyXFont::SIZE_SMALL); break;
|
|
|
|
case 6: font.setSize(LyXFont::SIZE_NORMAL); break;
|
|
|
|
case 7: font.setSize(LyXFont::SIZE_LARGE); break;
|
|
|
|
case 8: font.setSize(LyXFont::SIZE_LARGER); break;
|
|
|
|
case 9: font.setSize(LyXFont::SIZE_LARGEST); break;
|
|
|
|
case 10: font.setSize(LyXFont::SIZE_HUGE); break;
|
|
|
|
case 11: font.setSize(LyXFont::SIZE_HUGER); break;
|
|
|
|
case 12: font.setSize(LyXFont::INCREASE_SIZE); break;
|
|
|
|
case 13: font.setSize(LyXFont::DECREASE_SIZE); break;
|
|
|
|
case 14: font.setSize(LyXFont::INHERIT_SIZE); break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_bar);
|
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setEmph(LyXFont::IGNORE);
|
|
|
|
font.setUnderbar(LyXFont::IGNORE);
|
|
|
|
font.setNoun(LyXFont::IGNORE);
|
|
|
|
font.setLatex(LyXFont::IGNORE);
|
|
|
|
break;
|
|
|
|
case 2: font.setEmph(LyXFont::TOGGLE); break;
|
|
|
|
case 3: font.setUnderbar(LyXFont::TOGGLE); break;
|
|
|
|
case 4: font.setNoun(LyXFont::TOGGLE); break;
|
|
|
|
case 5: font.setLatex(LyXFont::TOGGLE); break;
|
|
|
|
case 6: font.setEmph(LyXFont::INHERIT);
|
|
|
|
font.setUnderbar(LyXFont::INHERIT);
|
|
|
|
font.setNoun(LyXFont::INHERIT);
|
|
|
|
font.setLatex(LyXFont::INHERIT);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = fl_get_choice(fd_form_character->choice_color);
|
2000-02-10 17:53:36 +00:00
|
|
|
switch(pos) {
|
|
|
|
case 1: font.setColor(LColor::ignore); break;
|
|
|
|
case 2: font.setColor(LColor::none); break;
|
|
|
|
case 3: font.setColor(LColor::black); break;
|
|
|
|
case 4: font.setColor(LColor::white); break;
|
|
|
|
case 5: font.setColor(LColor::red); break;
|
|
|
|
case 6: font.setColor(LColor::green); break;
|
|
|
|
case 7: font.setColor(LColor::blue); break;
|
|
|
|
case 8: font.setColor(LColor::cyan); break;
|
|
|
|
case 9: font.setColor(LColor::magenta); break;
|
|
|
|
case 10: font.setColor(LColor::yellow); break;
|
|
|
|
case 11: font.setColor(LColor::inherit); break;
|
|
|
|
}
|
2000-02-17 19:59:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void Free()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, UserFreeFont());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 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
|
1999-10-02 16:21:10 +00:00
|
|
|
if (fd_form_title->form_title != 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fd_form_title->form_title->visible) {
|
|
|
|
fl_hide_form(fd_form_title->form_title);
|
|
|
|
}
|
|
|
|
fl_free_form(fd_form_title->form_title);
|
1999-10-02 16:21:10 +00:00
|
|
|
fd_form_title->form_title = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_paragraph */
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void ParagraphVSpaceCB(FL_OBJECT * obj, long )
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// "Synchronize" the choices and input fields, making it
|
|
|
|
// impossible to commit senseless data.
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
FD_form_paragraph const * fp = fd_form_paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (obj == fp->choice_space_above) {
|
|
|
|
if (fl_get_choice (fp->choice_space_above) != 7) {
|
|
|
|
fl_set_input (fp->input_space_above, "");
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fp->choice_space_below) {
|
|
|
|
if (fl_get_choice (fp->choice_space_below) != 7) {
|
|
|
|
fl_set_input (fp->input_space_below, "");
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fp->input_space_above) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string input = fl_get_input (fp->input_space_above);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (input.empty()) {
|
|
|
|
fl_set_choice (fp->choice_space_above, 1);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else if (isValidGlueLength (input)) {
|
|
|
|
fl_set_choice (fp->choice_space_above, 7);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_set_choice (fp->choice_space_above, 7);
|
|
|
|
DeactivateParagraphButtons();
|
|
|
|
}
|
|
|
|
} else if (obj == fp->input_space_below) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string input = fl_get_input (fp->input_space_below);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (input.empty()) {
|
|
|
|
fl_set_choice (fp->choice_space_below, 1);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else if (isValidGlueLength (input)) {
|
|
|
|
fl_set_choice (fp->choice_space_below, 7);
|
|
|
|
ActivateParagraphButtons();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_set_choice (fp->choice_space_below, 7);
|
|
|
|
DeactivateParagraphButtons();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
VSpace space_top, space_bottom;
|
1999-11-04 01:40:20 +00:00
|
|
|
LyXAlignment align;
|
1999-10-02 16:21:10 +00:00
|
|
|
string labelwidthstring;
|
1999-09-27 18:44:28 +00:00
|
|
|
bool noindent;
|
|
|
|
|
|
|
|
// If a vspace kind is "Length" but there's no text in
|
|
|
|
// the input field, reset the kind to "None".
|
|
|
|
if (fl_get_choice (fd_form_paragraph->choice_space_above) == 7
|
|
|
|
&& !*(fl_get_input (fd_form_paragraph->input_space_above))) {
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
|
|
|
|
}
|
|
|
|
if (fl_get_choice (fd_form_paragraph->choice_space_below) == 7
|
|
|
|
&& !*(fl_get_input (fd_form_paragraph->input_space_below))) {
|
|
|
|
fl_set_choice (fd_form_paragraph->choice_space_below, 1);
|
|
|
|
}
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
|
|
|
|
bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
|
|
|
|
bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
|
|
|
|
bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
|
|
|
|
case 1: space_top = VSpace(VSpace::NONE); break;
|
|
|
|
case 2: space_top = VSpace(VSpace::DEFSKIP); break;
|
|
|
|
case 3: space_top = VSpace(VSpace::SMALLSKIP); break;
|
|
|
|
case 4: space_top = VSpace(VSpace::MEDSKIP); break;
|
|
|
|
case 5: space_top = VSpace(VSpace::BIGSKIP); break;
|
|
|
|
case 6: space_top = VSpace(VSpace::VFILL); break;
|
|
|
|
case 7: space_top = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_above))); break;
|
|
|
|
}
|
|
|
|
if (fl_get_button (fd_form_paragraph->check_space_above))
|
1999-12-16 06:43:25 +00:00
|
|
|
space_top.setKeep (true);
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (fl_get_choice (fd_form_paragraph->choice_space_below)) {
|
|
|
|
case 1: space_bottom = VSpace(VSpace::NONE); break;
|
|
|
|
case 2: space_bottom = VSpace(VSpace::DEFSKIP); break;
|
|
|
|
case 3: space_bottom = VSpace(VSpace::SMALLSKIP); break;
|
|
|
|
case 4: space_bottom = VSpace(VSpace::MEDSKIP); break;
|
|
|
|
case 5: space_bottom = VSpace(VSpace::BIGSKIP); break;
|
|
|
|
case 6: space_bottom = VSpace(VSpace::VFILL); break;
|
|
|
|
case 7: space_bottom = VSpace(LyXGlueLength (fl_get_input (fd_form_paragraph->input_space_below))); break;
|
|
|
|
}
|
|
|
|
if (fl_get_button (fd_form_paragraph->check_space_below))
|
1999-12-16 06:43:25 +00:00
|
|
|
space_bottom.setKeep (true);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fl_get_button(fd_form_paragraph->radio_align_left))
|
|
|
|
align = LYX_ALIGN_LEFT;
|
|
|
|
else if (fl_get_button(fd_form_paragraph->radio_align_right))
|
|
|
|
align = LYX_ALIGN_RIGHT;
|
|
|
|
else if (fl_get_button(fd_form_paragraph->radio_align_center))
|
|
|
|
align = LYX_ALIGN_CENTER;
|
|
|
|
else
|
|
|
|
align = LYX_ALIGN_BLOCK;
|
|
|
|
|
|
|
|
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
|
|
|
|
noindent = fl_get_button(fd_form_paragraph->check_noindent);
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->SetParagraph(line_top,
|
|
|
|
line_bottom,
|
|
|
|
pagebreak_top,
|
|
|
|
pagebreak_bottom,
|
|
|
|
space_top,
|
|
|
|
space_bottom,
|
|
|
|
align,
|
|
|
|
labelwidthstring,
|
|
|
|
noindent);
|
|
|
|
current_view->update(1);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_paragraph->form_paragraph);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
ParagraphApplyCB(ob, data);
|
|
|
|
ParagraphCancelCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_character */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void CharacterApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// we set toggleall locally here, since it should be true for
|
|
|
|
// all other uses of ToggleAndShow() (JMarc)
|
|
|
|
toggleall = fl_get_button(fd_form_character->check_toggle_all);
|
2000-02-04 09:38:32 +00:00
|
|
|
ToggleAndShow(current_view, UserFreeFont());
|
1999-09-27 18:44:28 +00:00
|
|
|
toggleall = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void CharacterCloseCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_character->form_character);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
CharacterApplyCB(ob, data);
|
|
|
|
CharacterCloseCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_document */
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
void UpdateDocumentButtons(BufferParams const & params)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_set_choice(fd_form_document->choice_pagestyle, 1);
|
2000-01-28 11:50:57 +00:00
|
|
|
|
|
|
|
switch (params.sides) {
|
|
|
|
case LyXTextClass::OneSide:
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_set_button(fd_form_document->radio_sides_one, 1);
|
2000-01-28 11:50:57 +00:00
|
|
|
break;
|
|
|
|
case LyXTextClass::TwoSides:
|
|
|
|
fl_set_button(fd_form_document->radio_sides_two, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (params.columns == 2)
|
|
|
|
fl_set_button(fd_form_document->radio_columns_two, 1);
|
|
|
|
else
|
|
|
|
fl_set_button(fd_form_document->radio_columns_one, 1);
|
|
|
|
|
|
|
|
fl_set_input(fd_form_document->input_extra, params.options.c_str());
|
|
|
|
fl_set_counter_value(fd_form_document->slider_secnumdepth,
|
|
|
|
params.secnumdepth);
|
|
|
|
fl_set_counter_value(fd_form_document->slider_tocdepth,
|
|
|
|
params.tocdepth);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
ProhibitInput();
|
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
|
|
|
}
|
|
|
|
AllowInput();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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);
|
1999-11-15 12:01:38 +00:00
|
|
|
current_view->buffer()->params.language =
|
1999-09-27 18:44:28 +00:00
|
|
|
combo_language->getline();
|
|
|
|
|
|
|
|
// 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-02-03 19:51:27 +00:00
|
|
|
if (lyxrc->rtl_support) {
|
|
|
|
current_view->text->SetCursor(current_view->text->cursor.par,
|
|
|
|
current_view->text->cursor.pos);
|
2000-02-17 19:59:08 +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;
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Converting document to new document class..."));
|
1999-12-10 00:07:59 +00:00
|
|
|
int ret = current_view->text->
|
|
|
|
SwitchLayoutsBetweenClasses(current_view->buffer()->
|
|
|
|
params.textclass,
|
|
|
|
new_class,
|
|
|
|
current_view->buffer()->
|
|
|
|
paragraph);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
if (ret) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string s;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (ret == 1)
|
|
|
|
s = _("One paragraph couldn't be converted");
|
1999-09-27 18:44:28 +00:00
|
|
|
else {
|
1999-10-19 16:48:35 +00:00
|
|
|
s += tostr(ret);
|
1999-09-27 18:44:28 +00:00
|
|
|
s += _(" paragraphs couldn't be converted");
|
|
|
|
}
|
1999-11-15 12:01:38 +00:00
|
|
|
WriteAlert(_("Conversion Errors!"), s,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("into chosen document class"));
|
|
|
|
}
|
|
|
|
|
|
|
|
params->textclass = new_class;
|
|
|
|
} else {
|
|
|
|
// problem changing class -- warn user and retain old style
|
|
|
|
WriteAlert(_("Conversion Errors!"),
|
|
|
|
_("Unable to switch to new document class."),
|
|
|
|
_("Reverting to original document class."));
|
|
|
|
fl_set_choice(fd_form_document->choice_class, params->textclass + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char tmpsep = params->paragraph_separation;
|
|
|
|
if (fl_get_button(fd_form_document->radio_indent))
|
1999-11-15 12:01:38 +00:00
|
|
|
params->paragraph_separation = BufferParams::PARSEP_INDENT;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
params->paragraph_separation = BufferParams::PARSEP_SKIP;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (tmpsep != params->paragraph_separation)
|
|
|
|
redo = true;
|
|
|
|
|
|
|
|
VSpace tmpdefskip = params->getDefSkip();
|
|
|
|
switch (fl_get_choice (fd_form_document->choice_default_skip)) {
|
|
|
|
case 1: params->setDefSkip(VSpace(VSpace::SMALLSKIP)); break;
|
|
|
|
case 2: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
|
|
|
|
case 3: params->setDefSkip(VSpace(VSpace::BIGSKIP)); break;
|
|
|
|
case 4: params->setDefSkip(
|
|
|
|
VSpace (LyXGlueLength (fl_get_input
|
|
|
|
(fd_form_document->input_default_skip))));
|
|
|
|
break;
|
|
|
|
// DocumentDefskipCB assures that this never happens
|
|
|
|
default: params->setDefSkip(VSpace(VSpace::MEDSKIP)); break;
|
|
|
|
}
|
|
|
|
if (!(tmpdefskip == params->getDefSkip()))
|
|
|
|
redo = true;
|
|
|
|
|
|
|
|
if (fl_get_button(fd_form_document->radio_columns_two))
|
|
|
|
params->columns = 2;
|
|
|
|
else
|
|
|
|
params->columns = 1;
|
|
|
|
if (fl_get_button(fd_form_document->radio_sides_two))
|
1999-11-04 01:40:20 +00:00
|
|
|
params->sides = LyXTextClass::TwoSides;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-11-04 01:40:20 +00:00
|
|
|
params->sides = LyXTextClass::OneSide;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
Spacing tmpSpacing = params->spacing;
|
|
|
|
switch(fl_get_choice(fd_form_document->choice_spacing)) {
|
|
|
|
case 1:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: SINGLE" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Single);
|
|
|
|
break;
|
|
|
|
case 2:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: ONEHALF" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Onehalf);
|
|
|
|
break;
|
|
|
|
case 3:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: DOUBLE" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Double);
|
|
|
|
break;
|
|
|
|
case 4:
|
1999-10-07 18:44:17 +00:00
|
|
|
lyxerr.debug() << "Spacing: OTHER" << endl;
|
1999-09-27 18:44:28 +00:00
|
|
|
params->spacing.set(Spacing::Other,
|
|
|
|
fl_get_input(fd_form_document->input_spacing));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tmpSpacing != params->spacing)
|
|
|
|
redo = true;
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
signed char tmpchar =
|
|
|
|
static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
|
1999-09-27 18:44:28 +00:00
|
|
|
if (params->secnumdepth != tmpchar)
|
|
|
|
redo = true;
|
|
|
|
params->secnumdepth = tmpchar;
|
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
params->tocdepth =
|
|
|
|
static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
params->float_placement =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_input(fd_form_document->input_float_placement);
|
|
|
|
|
|
|
|
// More checking should be done to ensure the string doesn't have
|
|
|
|
// spaces or illegal placement characters in it. (thornley)
|
|
|
|
|
|
|
|
if (redo)
|
|
|
|
current_view->redoCurrentBuffer();
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDirty();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
params->options =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_input(fd_form_document->input_extra);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void DocumentCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_document->form_document);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void DocumentOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
DocumentCancelCB(ob, data);
|
|
|
|
DocumentApplyCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
bulletForm();
|
|
|
|
// bullet callbacks etc. in bullet_panel.C -- ARRae
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_quotes */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void QuotesApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Quotes type set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
|
|
|
|
switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
|
|
|
|
case 0:
|
|
|
|
lga = InsetQuotes::EnglishQ;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
lga = InsetQuotes::SwedishQ;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
lga = InsetQuotes::GermanQ;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
lga = InsetQuotes::PolishQ;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
lga = InsetQuotes::FrenchQ;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
lga = InsetQuotes::DanishQ;
|
|
|
|
break;
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->params.quotes_language = lga;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_button(fd_form_quotes->radio_single))
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->
|
1999-09-27 18:44:28 +00:00
|
|
|
params.quotes_times = InsetQuotes::SingleQ;
|
|
|
|
else
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->
|
1999-09-27 18:44:28 +00:00
|
|
|
params.quotes_times = InsetQuotes::DoubleQ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void QuotesCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_quotes->form_quotes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void QuotesOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
QuotesApplyCB(ob, data);
|
|
|
|
QuotesCancelCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_preamble */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PreambleCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_preamble->form_preamble);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PreambleApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
current_view->buffer()->params.preamble =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_input(fd_form_preamble->input_preamble);
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->markDirty();
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("LaTeX preamble set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void PreambleOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
PreambleApplyCB(ob, data);
|
|
|
|
PreambleCancelCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_table */
|
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
extern "C" void TableApplyCB(FL_OBJECT *, long)
|
|
|
|
{
|
2000-02-17 19:59:08 +00:00
|
|
|
if (!current_view->available())
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// check for tables in tables
|
|
|
|
if (current_view->text->cursor.par->table){
|
|
|
|
WriteAlert(_("Impossible Operation!"),
|
|
|
|
_("Cannot insert table in table."),
|
|
|
|
_("Sorry."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
|
|
|
|
int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
|
|
|
|
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->update(-2);
|
|
|
|
|
|
|
|
current_view->text->SetCursorParUndo();
|
|
|
|
current_view->text->FreezeUndo();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
|
|
|
|
if (current_view->text->cursor.par->Last()) {
|
|
|
|
current_view->text->CursorLeft();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
current_view->text->current_font.setLatex(LyXFont::OFF);
|
|
|
|
//if (!fl_get_button(fd_form_table->check_latex)){
|
|
|
|
// insert the new wysiwy table
|
|
|
|
current_view->text->SetLayout(0); // standard layout
|
|
|
|
if (current_view->text->cursor.par->footnoteflag ==
|
|
|
|
LyXParagraph::NO_FOOTNOTE) {
|
|
|
|
current_view->text
|
|
|
|
->SetParagraph(0, 0,
|
|
|
|
0, 0,
|
|
|
|
VSpace (0.3 * current_view->buffer()->
|
|
|
|
params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
VSpace (0.3 * current_view->buffer()->
|
|
|
|
params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text
|
|
|
|
->SetParagraph(0, 0,
|
|
|
|
0, 0,
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->cursor.par->table =
|
|
|
|
new LyXTable(xsize, ysize);
|
|
|
|
|
|
|
|
for (int i = 0; i < xsize * ysize - 1; ++i)
|
|
|
|
current_view->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
|
|
|
|
current_view->text->RedoParagraph();
|
|
|
|
|
|
|
|
current_view->text->UnFreezeUndo();
|
|
|
|
|
|
|
|
current_view->update(1);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TableCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_table->form_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void TableOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
TableApplyCB(ob, data);
|
|
|
|
TableCancelCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_print */
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PrintCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_print->form_print);
|
|
|
|
}
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
|
|
|
static
|
|
|
|
bool stringOnlyContains (string const & LStr, char const * cset)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * cstr = LStr.c_str() ;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
return strspn(cstr, cset) == strlen(cstr) ;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void PrintApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
1999-11-26 06:57:35 +00:00
|
|
|
Buffer * buffer = current_view->buffer();
|
1999-12-10 00:07:59 +00:00
|
|
|
string path = OnlyPath(buffer->fileName());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string pageflag;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_button(fd_form_print->radio_even_pages))
|
|
|
|
pageflag = lyxrc->print_evenpage_flag + ' ';
|
|
|
|
else if (fl_get_button(fd_form_print->radio_odd_pages))
|
|
|
|
pageflag = lyxrc->print_oddpage_flag + ' ';
|
|
|
|
|
|
|
|
// Changes by Stephan Witt (stephan.witt@beusen.de), 19-Jan-99
|
|
|
|
// User may give a page (range) list
|
|
|
|
// User may print multiple (unsorted) copies
|
1999-10-26 23:33:30 +00:00
|
|
|
string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
|
|
|
|
pages = subst(pages, '+',',');
|
|
|
|
pages = frontStrip(strip(pages)) ;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (!pages.empty()) { // a page range was given
|
1999-10-02 16:21:10 +00:00
|
|
|
string piece ;
|
|
|
|
pages = split (pages, piece, ',') ;
|
|
|
|
piece = strip(piece) ;
|
|
|
|
piece = frontStrip(piece) ;
|
|
|
|
if ( !stringOnlyContains (piece, "0123456789-") ) {
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("ERROR! Unable to print!"),
|
1999-12-16 06:43:25 +00:00
|
|
|
_("Check 'range of pages'!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-10-02 16:21:10 +00:00
|
|
|
if (piece.find('-') == string::npos) { // not found
|
1999-09-27 18:44:28 +00:00
|
|
|
pageflag += lyxrc->print_pagerange_flag + piece + '-' + piece + ' ' ;
|
1999-10-02 16:21:10 +00:00
|
|
|
} else if (suffixIs(piece, "-") ) { // missing last page
|
|
|
|
pageflag += lyxrc->print_pagerange_flag + piece + "1000 ";
|
|
|
|
} else if (prefixIs(piece, "-") ) { // missing first page
|
|
|
|
pageflag += lyxrc->print_pagerange_flag + '1' + piece + ' ' ;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
|
|
|
pageflag += lyxrc->print_pagerange_flag + piece + ' ' ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!copies.empty()) { // a number of copies was given
|
1999-10-02 16:21:10 +00:00
|
|
|
if ( !stringOnlyContains (copies, "0123456789") ) {
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("ERROR! Unable to print!"),
|
1999-12-16 06:43:25 +00:00
|
|
|
_("Check 'number of copies'!"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fl_get_button(fd_form_print->do_unsorted))
|
|
|
|
pageflag += lyxrc->print_copies_flag;
|
|
|
|
else
|
|
|
|
pageflag += lyxrc->print_collcopies_flag;
|
|
|
|
pageflag += " " + copies + ' ' ;
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string reverseflag;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_button(fd_form_print->radio_order_reverse))
|
|
|
|
reverseflag = lyxrc->print_reverse_flag + ' ';
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string orientationflag;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
1999-09-27 18:44:28 +00:00
|
|
|
orientationflag = lyxrc->print_landscape_flag + ' ';
|
|
|
|
|
1999-12-03 13:51:01 +00:00
|
|
|
string ps_file = fl_get_input(fd_form_print->input_file);
|
1999-10-02 16:21:10 +00:00
|
|
|
string printer = strip(fl_get_input(fd_form_print->input_printer));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string printerflag;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (lyxrc->print_adapt_output // printer name should be passed to dvips
|
|
|
|
&& ! printer.empty()) // a printer name has been given
|
|
|
|
printerflag = lyxrc->print_to_printer + printer + ' ';
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string extraflags;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!lyxrc->print_extra_options.empty())
|
|
|
|
extraflags = lyxrc->print_extra_options + ' ';
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string command = lyxrc->print_command + ' '
|
1999-09-27 18:44:28 +00:00
|
|
|
+ printerflag + pageflag + reverseflag
|
|
|
|
+ orientationflag + extraflags;
|
|
|
|
|
|
|
|
char real_papersize = buffer->params.papersize;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
1999-09-27 18:44:28 +00:00
|
|
|
real_papersize = lyxrc->default_papersize;
|
1999-11-26 06:57:35 +00:00
|
|
|
|
|
|
|
string paper;
|
1999-09-27 18:44:28 +00:00
|
|
|
switch (real_papersize) {
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_USLETTER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "letter";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A3PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a3";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A4PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a4";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_A5PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "a5";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_B5PAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "b5";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_EXECUTIVEPAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "foolscap";
|
|
|
|
break;
|
1999-11-15 12:01:38 +00:00
|
|
|
case BufferParams::PAPER_LEGALPAPER:
|
1999-09-27 18:44:28 +00:00
|
|
|
paper = "legal";
|
|
|
|
break;
|
|
|
|
default: /* If nothing else fits, keep an empty value... */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buffer->params.use_geometry
|
1999-11-15 12:01:38 +00:00
|
|
|
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
1999-09-27 18:44:28 +00:00
|
|
|
&& !lyxrc->print_paper_dimension_flag.empty()
|
|
|
|
&& !buffer->params.paperwidth.empty()
|
|
|
|
&& !buffer->params.paperheight.empty()) {
|
|
|
|
// using a custom papersize
|
|
|
|
command += ' ';
|
|
|
|
command += lyxrc->print_paper_dimension_flag + ' ';
|
|
|
|
command += buffer->params.paperwidth + ',';
|
|
|
|
command += buffer->params.paperheight + ' ';
|
|
|
|
} else if (!lyxrc->print_paper_flag.empty()
|
|
|
|
&& !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
|
|
|
command += " " + lyxrc->print_paper_flag + " " + paper + " ";
|
|
|
|
}
|
|
|
|
if (fl_get_button(fd_form_print->radio_file))
|
1999-12-03 13:51:01 +00:00
|
|
|
command += lyxrc->print_to_file
|
1999-12-16 06:43:25 +00:00
|
|
|
+ QuoteName(MakeAbsPath(ps_file, path));
|
1999-09-27 18:44:28 +00:00
|
|
|
else if (!lyxrc->print_spool_command.empty())
|
|
|
|
command += lyxrc->print_to_file
|
1999-12-03 13:51:01 +00:00
|
|
|
+ QuoteName(ps_file);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// push directorypath, if necessary
|
|
|
|
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
|
|
|
|
path = buffer->tmppath;
|
|
|
|
}
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(path);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
bool result;
|
|
|
|
if (!lyxrc->print_spool_command.empty() &&
|
|
|
|
!fl_get_button(fd_form_print->radio_file)) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string command2 = lyxrc->print_spool_command + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!printer.empty())
|
|
|
|
command2 += lyxrc->print_spool_printerprefix
|
1999-12-16 06:43:25 +00:00
|
|
|
+ printer;
|
1999-09-27 18:44:28 +00:00
|
|
|
// First run dvips and, if succesful, then spool command
|
|
|
|
if ((result = RunScript(buffer, true, command))) {
|
|
|
|
result = RunScript(buffer, false, command2, ps_file);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
result = RunScript(buffer, false, command);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
WriteAlert(_("Error:"),
|
|
|
|
_("Unable to print"),
|
|
|
|
_("Check that your parameters are correct"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
PrintCancelCB(ob, data);
|
1999-11-15 12:01:38 +00:00
|
|
|
PrintApplyCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_figure */
|
1999-12-10 00:07:59 +00:00
|
|
|
extern "C" void FigureApplyCB(FL_OBJECT *, long)
|
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Buffer * buffer = current_view->buffer();
|
|
|
|
if(buffer->isReadonly()) // paranoia
|
|
|
|
return;
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
|
1999-12-10 00:07:59 +00:00
|
|
|
if (fl_get_button(fd_form_figure->radio_inline)
|
|
|
|
|| current_view->text->cursor.par->table) {
|
|
|
|
InsetFig * new_inset = new InsetFig(100, 20, buffer);
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
|
2000-02-25 12:06:15 +00:00
|
|
|
new_inset->Edit(current_view, 0, 0, 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->hideCursor();
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->update(-2);
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->text->SetCursorParUndo();
|
|
|
|
current_view->text->FreezeUndo();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
|
|
|
|
if (current_view->text->cursor.par->Last()) {
|
|
|
|
current_view->text->CursorLeft();
|
|
|
|
|
|
|
|
current_view->text->BreakParagraph();
|
|
|
|
current_view->update(-1);
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-12-10 00:07:59 +00:00
|
|
|
// The standard layout should always be numer 0;
|
|
|
|
current_view->text->SetLayout(0);
|
|
|
|
|
|
|
|
if (current_view->text->cursor.par->footnoteflag ==
|
|
|
|
LyXParagraph::NO_FOOTNOTE) {
|
|
|
|
current_view->text->
|
|
|
|
SetParagraph(0, 0,
|
|
|
|
0, 0,
|
|
|
|
VSpace (0.3 * buffer->params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
VSpace (0.3 *
|
|
|
|
buffer->params.spacing.getValue(),
|
|
|
|
LyXLength::CM),
|
|
|
|
LYX_ALIGN_CENTER, string(), 0);
|
2000-02-04 09:38:32 +00:00
|
|
|
} else {
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->SetParagraph(0, 0,
|
1999-12-16 06:43:25 +00:00
|
|
|
0, 0,
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
VSpace(VSpace::NONE),
|
|
|
|
LYX_ALIGN_CENTER,
|
|
|
|
string(),
|
|
|
|
0);
|
2000-02-04 09:38:32 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
|
|
|
|
current_view->update(-1);
|
|
|
|
|
|
|
|
Inset * new_inset = new InsetFig(100, 100, buffer);
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
2000-02-25 12:06:15 +00:00
|
|
|
new_inset->Edit(current_view, 0, 0, 0);
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->update(0);
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->UnFreezeUndo();
|
2000-02-17 19:59:08 +00:00
|
|
|
current_view->setState();
|
1999-12-10 00:07:59 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void FigureCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_figure->form_figure);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
FigureApplyCB(ob, data);
|
|
|
|
FigureCancelCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ScreenApplyCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
lyxrc->roman_font_name = fl_get_input(fd_form_screen->input_roman);
|
|
|
|
lyxrc->sans_font_name = fl_get_input(fd_form_screen->input_sans);
|
|
|
|
lyxrc->typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
|
|
|
|
lyxrc->font_norm = fl_get_input(fd_form_screen->input_font_norm);
|
|
|
|
lyxrc->zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
|
|
|
|
fontloader.update();
|
|
|
|
|
|
|
|
// All buffers will need resize
|
|
|
|
bufferlist.resize();
|
|
|
|
|
1999-12-19 22:35:36 +00:00
|
|
|
current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void ScreenCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_screen->form_screen);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-15 12:01:38 +00:00
|
|
|
ScreenCancelCB(ob, data);
|
|
|
|
ScreenApplyCB(ob, data);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-02-04 09:38:32 +00:00
|
|
|
void LaTeXOptions(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
if (!bv->available())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
fl_set_button(fd_latex_options->accents,
|
2000-02-04 09:38:32 +00:00
|
|
|
int(bv->buffer()->params.allowAccents));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (fd_latex_options->LaTeXOptions->visible) {
|
|
|
|
fl_raise_form(fd_latex_options->LaTeXOptions);
|
|
|
|
} else {
|
|
|
|
fl_show_form(fd_latex_options->LaTeXOptions,
|
1999-10-25 14:50:26 +00:00
|
|
|
FL_PLACE_MOUSE, FL_FULLBORDER,
|
1999-09-27 18:44:28 +00:00
|
|
|
_("LaTeX Options"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This function runs "configure" and then rereads lyx.defaults to
|
|
|
|
// reconfigure the automatic settings.
|
2000-02-04 09:38:32 +00:00
|
|
|
void Reconfigure(BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Run configure in user lyx directory
|
1999-10-13 17:32:46 +00:00
|
|
|
Path p(user_lyxdir);
|
1999-09-27 18:44:28 +00:00
|
|
|
Systemcalls one(Systemcalls::System,
|
1999-12-16 06:43:25 +00:00
|
|
|
AddName(system_lyxdir, "configure"));
|
1999-10-13 17:32:46 +00:00
|
|
|
p.pop();
|
2000-02-04 09:38:32 +00:00
|
|
|
bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
|
1999-12-01 00:57:31 +00:00
|
|
|
lyxrc->read(LibFileSearch(string(), "lyxrc.defaults"));
|
1999-09-27 18:44:28 +00:00
|
|
|
WriteAlert(_("The system has been reconfigured."),
|
|
|
|
_("You need to restart LyX to make use of any"),
|
|
|
|
_("updated document class specifications."));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Table of Contents
|
|
|
|
//
|
|
|
|
|
|
|
|
struct TocList {
|
|
|
|
int counter[6];
|
|
|
|
bool appendix;
|
1999-11-26 06:57:35 +00:00
|
|
|
TocList * next;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
static TocList * toclist = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
extern "C" void TocSelectCB(FL_OBJECT * ob, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
TocList * tmptoclist = toclist;
|
1999-09-27 18:44:28 +00:00
|
|
|
int i = fl_get_browser(ob);
|
1999-11-26 06:57:35 +00:00
|
|
|
for (int a = 1; a < i && tmptoclist->next; ++a) {
|
1999-09-27 18:44:28 +00:00
|
|
|
tmptoclist = tmptoclist->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tmptoclist)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
1999-11-26 06:57:35 +00:00
|
|
|
LyXParagraph * par = current_view->buffer()->paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (par && (par->GetFirstCounter(0) != tmptoclist->counter[0] ||
|
|
|
|
par->GetFirstCounter(1) != tmptoclist->counter[1] ||
|
|
|
|
par->GetFirstCounter(2) != tmptoclist->counter[2] ||
|
|
|
|
par->GetFirstCounter(3) != tmptoclist->counter[3] ||
|
|
|
|
par->GetFirstCounter(4) != tmptoclist->counter[4] ||
|
|
|
|
par->GetFirstCounter(5) != tmptoclist->counter[5] ||
|
|
|
|
par->appendix != tmptoclist->appendix)) {
|
|
|
|
par = par->LastPhysicalPar()->Next();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par) {
|
2000-01-07 03:42:16 +00:00
|
|
|
current_view->beforeChange();
|
1999-12-10 00:07:59 +00:00
|
|
|
current_view->text->SetCursor(par, 0);
|
|
|
|
current_view->text->sel_cursor =
|
|
|
|
current_view->text->cursor;
|
|
|
|
current_view->update(0);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
WriteAlert(_("Error"),
|
|
|
|
_("Couldn't find this label"),
|
|
|
|
_("in current document."));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TocCancelCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_toc->form_toc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void TocUpdateCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-11-04 01:40:20 +00:00
|
|
|
static LyXParagraph * stapar = 0;
|
|
|
|
TocList * tmptoclist = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/* deleted the toclist */
|
|
|
|
if (toclist){
|
|
|
|
while (toclist){
|
|
|
|
tmptoclist = toclist->next;
|
|
|
|
delete toclist;
|
|
|
|
toclist = tmptoclist;
|
|
|
|
}
|
|
|
|
}
|
1999-10-02 16:21:10 +00:00
|
|
|
toclist = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
tmptoclist = toclist;
|
|
|
|
|
|
|
|
|
|
|
|
fl_clear_browser(fd_form_toc->browser_toc);
|
|
|
|
if (!current_view->available()) {
|
1999-11-26 06:57:35 +00:00
|
|
|
fl_add_browser_line(fd_form_toc->browser_toc,
|
|
|
|
_("*** No Document ***"));
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
fl_hide_object(fd_form_toc->browser_toc);
|
|
|
|
/* get the table of contents */
|
1999-11-09 23:52:04 +00:00
|
|
|
LyXParagraph * par = current_view->buffer()->paragraph;
|
1999-09-27 18:44:28 +00:00
|
|
|
char labeltype;
|
1999-11-04 01:40:20 +00:00
|
|
|
char * line = new char[200];
|
1999-09-27 18:44:28 +00:00
|
|
|
int pos = 0;
|
|
|
|
unsigned char c;
|
|
|
|
int topline = 0;
|
|
|
|
|
|
|
|
if (stapar == par)
|
|
|
|
topline = fl_get_browser_topline(fd_form_toc->browser_toc);
|
|
|
|
stapar = par;
|
|
|
|
|
|
|
|
while (par) {
|
1999-11-09 23:52:04 +00:00
|
|
|
labeltype = textclasslist.Style(current_view->buffer()->params.textclass,
|
1999-12-16 06:43:25 +00:00
|
|
|
par->GetLayout()).labeltype;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
if (labeltype >= LABEL_COUNTER_CHAPTER
|
|
|
|
&& labeltype <= LABEL_COUNTER_CHAPTER +
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->buffer()->params.tocdepth) {
|
1999-09-27 18:44:28 +00:00
|
|
|
/* insert this into the table of contents */
|
|
|
|
/* first indent a little bit */
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
for (pos = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
pos < (labeltype -
|
1999-11-09 23:52:04 +00:00
|
|
|
textclasslist.TextClass(current_view->buffer()->
|
1999-12-16 06:43:25 +00:00
|
|
|
params.textclass).maxcounter()) * 4 + 2;
|
2000-01-24 18:34:46 +00:00
|
|
|
++pos)
|
1999-09-27 18:44:28 +00:00
|
|
|
line[pos] = ' ';
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
// Then the labestring
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!par->labelstring.empty()) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string::size_type i = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
while (pos < 199 && i < par->labelstring.length()) {
|
|
|
|
line[pos] = par->labelstring[i];
|
2000-01-24 18:34:46 +00:00
|
|
|
++i;
|
|
|
|
++pos;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
line[pos] = ' ';
|
1999-12-10 00:07:59 +00:00
|
|
|
++pos;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-04 01:40:20 +00:00
|
|
|
/* now the contents */
|
|
|
|
LyXParagraph::size_type i = 0;
|
|
|
|
while (pos < 199 && i < par->size()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
c = par->GetChar(i);
|
1999-11-04 01:40:20 +00:00
|
|
|
if (isprint(c) || c >= 128) {
|
1999-09-27 18:44:28 +00:00
|
|
|
line[pos] = c;
|
2000-01-24 18:34:46 +00:00
|
|
|
++pos;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-12-10 00:07:59 +00:00
|
|
|
++i;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
line[pos] = '\0';
|
|
|
|
fl_add_browser_line(fd_form_toc->browser_toc, line);
|
|
|
|
|
|
|
|
/* make a toclist entry */
|
|
|
|
if (!tmptoclist){
|
|
|
|
tmptoclist = new TocList;
|
|
|
|
toclist = tmptoclist;
|
|
|
|
} else {
|
|
|
|
tmptoclist->next = new TocList;
|
|
|
|
tmptoclist = tmptoclist->next;
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
tmptoclist->next = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
int a = 0;
|
1999-12-10 00:07:59 +00:00
|
|
|
for (a = 0; a < 6; ++a) {
|
1999-09-27 18:44:28 +00:00
|
|
|
tmptoclist->counter[a] = par->GetFirstCounter(a);
|
|
|
|
}
|
|
|
|
tmptoclist->appendix = par->appendix;
|
|
|
|
}
|
|
|
|
par = par->LastPhysicalPar()->Next();
|
|
|
|
|
|
|
|
}
|
|
|
|
delete[] line;
|
|
|
|
fl_set_browser_topline(fd_form_toc->browser_toc, topline);
|
|
|
|
fl_show_object(fd_form_toc->browser_toc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* callbacks for form form_ref */
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void RefSelectCB(FL_OBJECT *, long data)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available())
|
|
|
|
return;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
string s =
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_get_browser_line(fd_form_ref->browser_ref,
|
|
|
|
fl_get_browser(fd_form_ref->browser_ref));
|
1999-10-02 16:21:10 +00:00
|
|
|
string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
if (s.empty())
|
|
|
|
return;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
if (data == 2) {
|
1999-11-09 23:52:04 +00:00
|
|
|
current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
string t;
|
1999-11-15 12:01:38 +00:00
|
|
|
if (data == 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
t += "\\ref";
|
|
|
|
else
|
|
|
|
t += "\\pageref";
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
if(current_view->buffer()->isSGML())
|
1999-09-27 18:44:28 +00:00
|
|
|
t += "[" + u + "]" + "{" + s + "}";
|
|
|
|
else
|
|
|
|
t += "{" + s + "}";
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
Inset * new_inset =
|
1999-11-09 23:52:04 +00:00
|
|
|
new InsetRef(t, current_view->buffer());
|
2000-01-08 21:02:58 +00:00
|
|
|
current_view->insertInset(new_inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void RefUpdateCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (!current_view->available()) {
|
|
|
|
fl_clear_browser(fd_form_ref->browser_ref);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FL_OBJECT * brow = fd_form_ref->browser_ref;
|
|
|
|
|
|
|
|
// Get the current line, in order to restore it later
|
1999-11-15 12:01:38 +00:00
|
|
|
char const * const btmp = fl_get_browser_line(brow,
|
1999-12-16 06:43:25 +00:00
|
|
|
fl_get_browser(brow));
|
1999-11-15 12:01:38 +00:00
|
|
|
string currentstr = btmp ? btmp : "";
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
fl_clear_browser(brow);
|
|
|
|
|
1999-11-09 23:52:04 +00:00
|
|
|
string refs = current_view->buffer()->getReferenceList('\n');
|
1999-09-27 18:44:28 +00:00
|
|
|
int topline = 1;
|
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
fl_addto_browser_chars(brow, refs.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
int total_lines = fl_get_browser_maxline(brow);
|
2000-01-24 18:34:46 +00:00
|
|
|
for (int i = 1; i <= total_lines ; ++i) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (fl_get_browser_line(brow, i) == currentstr) {
|
|
|
|
topline = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fl_set_browser_topline(brow, topline);
|
|
|
|
|
|
|
|
if (!fl_get_browser_maxline(brow)) {
|
|
|
|
fl_add_browser_line(brow,
|
|
|
|
_("*** No labels found in document ***"));
|
|
|
|
fl_deactivate_object(brow);
|
|
|
|
} else {
|
|
|
|
fl_select_browser_line(brow, topline);
|
|
|
|
fl_activate_object(brow);
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
if (current_view->buffer()->isReadonly()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// would be better to de/activate insert buttons
|
|
|
|
// but that's more work... besides this works. ARRae
|
|
|
|
fl_hide_form(fd_form_ref->form_ref);
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
if (!current_view->buffer()->isSGML()) {
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_deactivate_object(fd_form_ref->ref_name);
|
|
|
|
fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fl_activate_object(fd_form_ref->ref_name);
|
|
|
|
fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-19 15:06:30 +00:00
|
|
|
extern "C" void RefHideCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
fl_hide_form(fd_form_ref->form_ref);
|
|
|
|
}
|
|
|
|
|
1999-10-28 15:19:59 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
1999-09-27 18:44:28 +00:00
|
|
|
#warning UGLY!!
|
1999-10-28 15:19:59 +00:00
|
|
|
#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
// I know we shouldn't put anything in here but this seems the fastest
|
|
|
|
// way to do this (and the cleanest for now). This function just inserts
|
1999-10-02 16:21:10 +00:00
|
|
|
// a newline in the string and the inserts 'depth'-spaces so that the
|
1999-09-27 18:44:28 +00:00
|
|
|
// code is indented in the right way!!!
|
1999-11-05 06:02:34 +00:00
|
|
|
void addNewlineAndDepth(string & file, int const depth)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
1999-12-16 06:43:25 +00:00
|
|
|
file += '\n';
|
|
|
|
file.append(depth, ' ');
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|