* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich,
- * Copyright 1995-1999 The LyX Team.
+ * Copyright 1995-2000 The LyX Team.
*
* ====================================================== */
#include <config.h>
-#include <cctype>
-#include <unistd.h>
-#include <csignal>
-#include <cstring>
-#include <cstdlib>
-
#include <fstream>
-using std::ifstream;
+#include <algorithm>
+#include <iostream>
#include "LString.h"
-#include "support/lstrings.h"
-#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_main.h"
#include "lyx_cb.h"
-#include "credits.h"
#include "insets/insetref.h"
-#include "insets/insetquotes.h"
-#if 0
-#include "insets/insetlatex.h"
-#endif
#include "insets/insetlabel.h"
-#include "insets/insetinfo.h"
-#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
#include "lyxfunc.h"
-#include "latexoptions.h"
-#include "lyxfont.h"
#include "minibuffer.h"
#include "combox.h"
#include "bufferlist.h"
-#include "support/filetools.h"
-#include "support/path.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
-#include "LyXView.h" // only because of form_main
+#include "LyXView.h"
+#include "BufferView.h"
#include "lastfiles.h"
+#include "bufferview_funcs.h"
#include "support/FileInfo.h"
-#include "lyxscreen.h"
-#include "debug.h"
#include "support/syscall.h"
-#include "support/lyxlib.h"
+#include "support/filetools.h"
+#include "support/path.h"
#include "lyxserver.h"
#include "FontLoader.h"
#include "lyxrc.h"
#include "lyxtext.h"
-#include "gettext.h"
-#include "layout.h"
+#include "CutAndPaste.h"
+#include "TextCache.h"
+
+using std::ifstream;
+using std::copy;
+using std::back_inserter;
+using std::endl;
+using std::cout;
+using std::ios;
+using std::istream_iterator;
+using std::pair;
+using std::vector;
+using std::sort;
+using std::equal;
extern Combox * combo_language;
+extern Combox * combo_language2;
extern BufferList bufferlist;
extern void show_symbols_form();
extern FD_form_title * fd_form_title;
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 void MenuSendto();
extern LyXServer * lyxserver;
-extern FontLoader fontloader;
// this should be static, but I need it in buffer.C
bool quitting; // flag, that we are quitting the program
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;
Matthias
*/
-void UpdateInset(Inset * inset, bool mark_dirty = true);
+//void UpdateInset(BufferView * bv, Inset * inset, bool mark_dirty = true);
+
/* these functions return 1 if an error occured,
otherwise 0 */
// Now they work only for updatable insets. [Alejandro 080596]
/* this is for asyncron updating. UpdateInsetUpdateList will be called
automatically from LyX. Just insert the Inset into the Updatelist */
-void UpdateInsetUpdateList();
-void PutInsetIntoInsetUpdateList(Inset * inset);
+//void UpdateInsetUpdateList();
+//void PutInsetIntoInsetUpdateList(Inset * inset);
-InsetUpdateStruct * InsetUpdateList = 0;
+//InsetUpdateStruct * InsetUpdateList = 0;
/*
/* some function prototypes */
-int RunLinuxDoc(int, string const &);
+int RunLinuxDoc(BufferView *, int, string const &);
int RunDocBook(int, string const &);
void MenuWrite(Buffer * buf);
void MenuWriteAs(Buffer * buffer);
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;
- if (current_view->getScreen())
- current_view->getScreen()->HideCursor();
-
- 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 */
- XDefineCursor(fl_display, current_view->owner()->getForm()->window,
- cursor);
- 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)
+void ShowMessage(Buffer * buf,
+ string const & msg1,
+ string const & msg2 = string(),
+ string const & msg3 = string(), int delay = 6)
{
- static Cursor cursor;
- static bool cursor_undefined = true;
- if (cursor_undefined){
- cursor = XCreateFontCursor(fl_display, XC_xterm);
- XFlush(fl_display);
- cursor_undefined = false;
+ if (lyxrc.use_gui) {
+ buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
+ msg3, delay);
+ } else {
+ // can somebody think of something more clever? cerr?
+ cout << msg1 << msg2 << msg3 << endl;
}
- 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 */
-
- XUndefineCursor(fl_display, current_view->owner()->getForm()->window);
- 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);
- if (current_view->getWorkArea()->belowmouse)
- SetXtermCursor(current_view->owner()->getForm()->window);
-
- 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)
-{
- fl_set_timer(current_view->owner()->getMainForm()->timer_update, time);
- updatetimer = 1;
}
void MenuWrite(Buffer * buffer)
{
XFlush(fl_display);
- if (!bufferlist.write(buffer)) {
+ if (!buffer->save()) {
string fname = buffer->fileName();
string s = MakeAbsPath(fname);
if (AskQuestion(_("Save failed. Rename and try again?"),
string oldname = fname;
LyXFileDlg fileDlg;
- ProhibitInput();
- fileDlg.SetButton(0, _("Documents"), lyxrc->document_path);
- fileDlg.SetButton(1, _("Templates"), lyxrc->template_path);
+ ProhibitInput(current_view);
+ fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
+ fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
if (!IsLyXFilename(fname))
fname += ".lyx";
OnlyPath(fname),
"*.lyx",
OnlyFilename(fname));
- AllowInput();
+ AllowInput(current_view);
if (fname.empty()) {
- // Can we do without this one?
-#if 0
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled."));
-#endif
return;
}
// Make sure the absolute filename ends with appropriate suffix
buffer->fileName(s);
buffer->markDirty();
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Document renamed to '"),
- MakeDisplayPath(s),
- _("', but not saved..."));
+ ShowMessage(buffer, _("Document renamed to '"),
+ MakeDisplayPath(s), _("', but not saved..."));
}
return;
} // Check whether the file exists
int ret = 0;
if (buffer->isLinuxDoc())
- ret = RunLinuxDoc(1, buffer->fileName());
+ ret = RunLinuxDoc(buffer->getUser(), 1, buffer->fileName());
else if (buffer->isLiterate())
ret = buffer->runLiterate();
else if (buffer->isDocBook())
}
-int MakeDVIOutput(Buffer * buffer)
+int MakeLaTeXOutput(Buffer * buffer)
{
// Who cares?
//if (!bv->text)
// return 1;
-
int ret = 0;
-
string path = OnlyPath(buffer->fileName());
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- if (!buffer->isDviClean()) {
- Path p(path);
- ret = MenuRunLaTeX(buffer);
- }
- return ret;
+
+ Path p(path);
+ ret = MenuRunLaTeX(buffer);
+
+ return ret;
}
string name = orgname;
int result = 0;
- if (MakeDVIOutput(buffer) > 0)
+ if (MakeLaTeXOutput(buffer) > 0)
return false;
/* get DVI-Filename */
if (name.empty())
- name = ChangeExtension(buffer->getLatexName(),
- ".dvi", true);
+ name = ChangeExtension(buffer->getLatexName(), ".dvi");
path = OnlyPath(name);
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
Path p(path);
-
- cmd = command + ' ' + QuoteName(name);
+ // 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;
+ string::size_type i;
+ if ( (i=command.find("$$FName")) != string::npos)
+ {
+ cmd.replace(i,7,QuoteName(name));
+ }
+ else
+ cmd = command + ' ' + QuoteName(name);
Systemcalls one;
// 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
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("Executing command:"), cmd);
+ // CHECK What should we do here?
+ ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(Systemcalls::System, cmd);
} else {
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("Executing command:"), cmd);
+ ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(wait ? Systemcalls::Wait
: Systemcalls::DontWait, cmd);
}
// Returns false if we fail
-bool MenuRunDvips(Buffer * buffer, bool wait = false)
+bool CreatePostscript(Buffer * buffer, bool wait = false)
{
// Who cares?
//if (!bv->text)
// return false;
- ProhibitInput();
+ ProhibitInput(current_view);
// Generate dvi file
- if (MakeDVIOutput(buffer) > 0) {
- AllowInput();
+ if (MakeLaTeXOutput(buffer) > 0) {
+ AllowInput(current_view);
return false;
}
// Generate postscript file
- string psname = ChangeExtension (buffer->fileName(),
- ".ps_tmp", true);
+ string psname = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
string paper;
// Wrong type
char real_papersize = buffer->params.papersize;
if (real_papersize == BufferParams::PAPER_DEFAULT)
- real_papersize = lyxrc->default_papersize;
+ real_papersize = lyxrc.default_papersize;
switch (real_papersize) {
case BufferParams::PAPER_USLETTER:
}
// Make postscript file.
- string command = "dvips " + lyxrc->print_to_file + ' ';
+ string command = lyxrc.dvi_to_ps_command + ' ' + lyxrc.print_to_file + ' ';
command += QuoteName(psname);
if (buffer->params.use_geometry
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
- && !lyxrc->print_paper_dimension_flag.empty()
+ && !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 += lyxrc.print_paper_dimension_flag + ' ';
command += buffer->params.paperwidth + ',';
command += buffer->params.paperheight;
} else if (!paper.empty()
// dvips won't accept -t letter -t landscape. In all other
// cases, include the paper size explicitly.
command += ' ';
- command += lyxrc->print_paper_flag + ' ' + paper;
+ command += lyxrc.print_paper_flag + ' ' + paper;
}
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
command += ' ';
- command += lyxrc->print_landscape_flag;
+ command += lyxrc.print_landscape_flag;
}
// push directorypath, if necessary
string path = OnlyPath(buffer->fileName());
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
Path p(path);
bool ret = RunScript(buffer, wait, command);
- AllowInput();
+ AllowInput(current_view);
return ret;
}
// Returns false if we fail
-bool MenuPreviewPS(Buffer * buffer)
+//bool MenuPreviewPS(Buffer * buffer)
+bool PreviewPostscript(Buffer * buffer)
{
// Who cares?
//if (!bv->text)
// return false;
// Generate postscript file
- if (!MenuRunDvips(buffer, true)) {
+ if (!CreatePostscript(buffer, true)) {
return false;
}
// Start postscript viewer
- ProhibitInput();
- string ps = ChangeExtension (buffer->fileName(),
- ".ps_tmp", true);
+ ProhibitInput(current_view);
+ string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
// push directorypath, if necessary
string path = OnlyPath(buffer->fileName());
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
Path p(path);
- bool ret = RunScript(buffer, false, lyxrc->view_ps_command, ps);
- AllowInput();
+ bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
+ AllowInput(current_view);
return ret;
}
// return;
// Generate postscript file
- if (!MenuRunDvips(buffer, true)) {
+ if (!CreatePostscript(buffer, true)) {
return;
}
// Send fax
- string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true);
+ string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
string path = OnlyPath (buffer->fileName());
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
Path p(path);
- if (!lyxrc->fax_program.empty()) {
- string help2 = subst(lyxrc->fax_program, "$$FName", ps);
+ if (!lyxrc.fax_program.empty()) {
+ string help2 = subst(lyxrc.fax_program, "$$FName", ps);
help2 += " &";
Systemcalls one(Systemcalls::System, help2);
} else
- send_fax(ps, lyxrc->fax_command);
+ send_fax(ps, lyxrc.fax_command);
}
// Returns false if we fail
-bool MenuPreview(Buffer * buffer)
+bool PreviewDVI(Buffer * buffer)
{
// Who cares?
//if (!bv->text)
// return false;
- string paper;
-
- // 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 (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';
- }
-
- // push directorypath, if necessary
- string path = OnlyPath(buffer->fileName());
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
- path = buffer->tmppath;
+ 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';
+ }
}
- Path p(path);
- // Run dvi-viewer
- string command = lyxrc->view_dvi_command + paper ;
+ // 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;
bool ret = RunScript(buffer, false, command);
return ret;
}
+bool AskOverwrite(Buffer * buffer, string const & s)
+{
+ if (lyxrc.use_gui) {
+ // be friendly if there is a gui
+ FileInfo fi(s);
+ if (fi.readable() &&
+ !AskQuestion(_("File already exists:"),
+ MakeDisplayPath(s, 50),
+ _("Do you want to overwrite the file?"))) {
+ ShowMessage(buffer, _("Canceled"));
+ return false;
+ }
+ }
+ return true;
+}
+
+
void MenuMakeLaTeX(Buffer * buffer)
{
// Why care about this?
// Get LaTeX-Filename
string s = buffer->getLatexName(false);
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
- return;
- }
+ if (!AskOverwrite(buffer, s))
+ return;
if (buffer->isDocBook())
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("DocBook does not have a latex backend"));
+ ShowMessage(buffer, _("DocBook does not have a latex backend"));
else {
if (buffer->isLinuxDoc())
- RunLinuxDoc(0, buffer->fileName());
+ RunLinuxDoc(buffer->getUser(), 0, buffer->fileName());
else
buffer->makeLaTeXFile(s, string(), true);
- buffer->getUser()->owner()->getMiniBuffer()->Set(
- _("Nice LaTeX file saved as"), MakeDisplayPath(s));
- buffer->markDviDirty();
+ ShowMessage(buffer, _("Nice LaTeX file saved as"),
+ MakeDisplayPath(s));
}
}
}
// Get LinuxDoc-Filename
- string s = ChangeExtension(buffer->fileName(),
- ".sgml", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
+ string s = ChangeExtension(buffer->fileName(), ".sgml");
+
+ if (!AskOverwrite(buffer, s))
return;
- }
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Building LinuxDoc SGML file `"),
+ ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
MakeDisplayPath(s),"'...");
- buffer->makeLinuxDocFile(s, 65);
+ buffer->makeLinuxDocFile(s, true);
buffer->redraw();
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("LinuxDoc SGML file save as"),
+ ShowMessage(buffer, _("LinuxDoc SGML file save as"),
MakeDisplayPath(s));
}
}
// Get DocBook-Filename
- string s = ChangeExtension(buffer->fileName(),
- ".sgml", false);
-
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
+ string s = ChangeExtension(buffer->fileName(), ".sgml");
+
+ if (!AskOverwrite(buffer, s))
return;
- }
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Building DocBook SGML file `"),
+ ShowMessage(buffer, _("Building DocBook SGML file `"),
MakeDisplayPath(s), "'...");
- buffer->makeDocBookFile(s, 65);
+ buffer->makeDocBookFile(s, true);
buffer->redraw();
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("DocBook SGML file save as"),
+ ShowMessage(buffer, _("DocBook SGML file save as"),
MakeDisplayPath(s));
}
//if (!bv->text) return;
/* get LaTeX-Filename */
- string s = ChangeExtension (buffer->fileName(),
- ".txt", false);
+ string s = ChangeExtension (buffer->fileName(), ".txt");
- FileInfo fi(s);
- if (fi.readable() &&
- !AskQuestion(_("File already exists:"),
- MakeDisplayPath(s, 50),
- _("Do you want to overwrite the file?"))) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Canceled"));
+
+ if (!AskOverwrite(buffer, s))
return;
- }
- buffer->writeFileAscii(s, lyxrc->ascii_linelen);
+ buffer->writeFileAscii(s, lyxrc.ascii_linelen);
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Ascii file saved as"), MakeDisplayPath(s));
+ ShowMessage(buffer, _("Ascii file saved as"), MakeDisplayPath(s));
}
-void MenuPrint(Buffer * buffer)
-{
- // Who cares?
- //if (!bv->text)
- // return;
-
- string input_file = ChangeExtension(buffer->fileName(),
- lyxrc->print_file_extension,
- true);
- 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,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Print"));
- }
-}
-
void MenuMakeHTML(Buffer * buffer)
{
// First, create LaTeX 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);
+ string result = ChangeExtension(file, ".html");
string infile = buffer->getLatexName(false);
- string tmp = lyxrc->html_command;
+ 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) {
+ ShowMessage(buffer, _("Document exported as HTML to file `")
+ + MakeDisplayPath(result) +'\'');
+ } else {
+ ShowMessage(buffer, _("Unable to convert to HTML the file `")
+ + MakeDisplayPath(infile)
+ + '\'');
+ }
+
+}
+
+
+void MenuMakeHTML_LinuxDoc(Buffer * buffer)
+{
+ // First, create LinuxDoc file
+ MenuMakeLinuxDoc(buffer);
+
+ // And now, run the converter
+ string file = buffer->fileName();
+
+ string result = ChangeExtension(file, ".html");
+ string infile = ChangeExtension(file, ".sgml");
+ string tmp = lyxrc.linuxdoc_to_html_command;
+ tmp = subst(tmp, "$$FName", infile);
+ tmp = subst(tmp, "$$OutName", result);
+ Systemcalls one;
+ int res = one.startscript(Systemcalls::System, tmp);
+ if (res == 0) {
+ ShowMessage(buffer,_("Document exported as HTML to file `")
+ + MakeDisplayPath(result) +'\'');
+ } else {
+ ShowMessage(buffer,_("Unable to convert to HTML the file `")
+ + MakeDisplayPath(infile)
+ + '\'');
+ }
+
+}
+
+void MenuMakeHTML_DocBook(Buffer * buffer)
+{
+ // First, create LaTeX file
+ MenuMakeDocBook(buffer);
+
+ // And now, run the converter
+ string file = buffer->fileName();
+ string result = ChangeExtension(file, ".html");
+ string infile = ChangeExtension(file, ".sgml");
+ string tmp = lyxrc.docbook_to_html_command;
tmp = subst(tmp, "$$FName", infile);
tmp = subst(tmp, "$$OutName", result);
Systemcalls one;
int res = one.startscript(Systemcalls::System, tmp);
if (res == 0) {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Document exported as HTML to file `")
+ ShowMessage(buffer,_("Document exported as HTML to file `")
+ MakeDisplayPath(result) +'\'');
} else {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Unable to convert to HTML the file `")
+ ShowMessage(buffer,_("Unable to convert to HTML the file `")
+ MakeDisplayPath(infile)
+ '\'');
}
}
+
void MenuExport(Buffer * buffer, string const & extyp)
{
// latex
// is achieved by temporarily disabling use of
// temp directory. As a side-effect, we get
// *.log and *.aux files also. (Asger)
- bool flag = lyxrc->use_tempdir;
- lyxrc->use_tempdir = false;
+ bool flag = lyxrc.use_tempdir;
+ lyxrc.use_tempdir = false;
MenuRunLaTeX(buffer);
- lyxrc->use_tempdir = flag;
+ lyxrc.use_tempdir = flag;
}
// postscript
else if (extyp == "postscript") {
// Start Print-dialog. Not as good as dvi... Bernhard.
- MenuPrint(buffer);
+ //should start lyxview->getDialogs()->showPrint();
+ // to get same as before
+ // MenuPrint(buffer);
// Since the MenuPrint is a pop-up, we can't use
// the same trick as above. (Asger)
// MISSING: Move of ps-file :-(
else if (extyp == "html") {
MenuMakeHTML(buffer);
}
+ // HTML from linuxdoc
+ else if (extyp == "html-linuxdoc") {
+ MenuMakeHTML_LinuxDoc(buffer);
+ }
+ // HTML from docbook
+ else if (extyp == "html-docbook") {
+ MenuMakeHTML_DocBook(buffer);
+ }
else {
- buffer->getUser()->owner()->getMiniBuffer()->Set(_("Unknown export type: ") + extyp);
+ ShowMessage(buffer, _("Unknown export type: ") + extyp);
}
}
if (!bufferlist.QwriteAll())
return;
- lastfiles->writeFile(lyxrc->lastfiles);
+ lastfiles->writeFile(lyxrc.lastfiles);
// Set a flag that we do quitting from the program,
// so no refreshes are necessary.
-void AutoSave()
+void AutoSave(BufferView * bv)
// should probably be moved into BufferList (Lgb)
// Perfect target for a thread...
{
- if (!current_view->getScreen() || !current_view->available())
+ if (!bv->available())
return;
- if (current_view->buffer()->isBakClean()
- || current_view->buffer()->isReadonly()) {
+ if (bv->buffer()->isBakClean()
+ || bv->buffer()->isReadonly()) {
// We don't save now, but we'll try again later
- current_view->owner()->resetAutosaveTimer();
+ bv->owner()->resetAutosaveTimer();
return;
}
- current_view->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
+ bv->owner()->getMiniBuffer()->Set(_("Autosaving current document..."));
// create autosave filename
- string fname = OnlyPath(current_view->buffer()->fileName());
+ string fname = OnlyPath(bv->buffer()->fileName());
fname += "#";
- fname += OnlyFilename(current_view->buffer()->fileName());
+ fname += OnlyFilename(bv->buffer()->fileName());
fname += "#";
// tmp_ret will be located (usually) in /tmp
// anyway.
bool failed = false;
if (!tmp_ret.empty()) {
- current_view->buffer()->writeFile(tmp_ret, 1);
+ bv->buffer()->writeFile(tmp_ret, 1);
// assume successful write of tmp_ret
if (rename(tmp_ret.c_str(), fname.c_str()) == -1) {
failed = true;
if (failed) {
// failed to write/rename tmp_ret so try writing direct
- if (!current_view->buffer()->writeFile(fname, 1)) {
+ if (!bv->buffer()->writeFile(fname, 1)) {
// It is dangerous to do this in the child,
// but safe in the parent, so...
if (pid == -1)
- current_view->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
+ bv->owner()->getMiniBuffer()->Set(_("Autosave Failed!"));
}
}
if (pid == 0) { // we are the child so...
}
}
- current_view->buffer()->markBakClean();
- current_view->owner()->resetAutosaveTimer();
+ bv->buffer()->markBakClean();
+ bv->owner()->resetAutosaveTimer();
}
//
-// (c) CHT Software Service GmbH
+// Copyright CHT Software Service GmbH
// Uwe C. Schroeder
//
// create new file with template
// Insert ascii file (if filename is empty, prompt for one)
-void InsertAsciiFile(string const & f, bool asParagraph)
+void InsertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
{
string fname = f;
LyXFileDlg fileDlg;
- if (!current_view->getScreen()) return;
+ if (!bv->available()) return;
if (fname.empty()) {
- ProhibitInput();
+ ProhibitInput(bv);
fname = fileDlg.Select(_("File to Insert"),
- current_view->owner()->buffer()->filepath,
+ bv->owner()->buffer()->filepath,
"*");
- AllowInput();
+ AllowInput(bv);
if (fname.empty()) return;
}
MakeDisplayPath(fname, 50));
return;
}
- LyXParagraph * tmppar = new LyXParagraph;
- tmppar->readSimpleWholeFile(ifs);
-
- // set the end of the string
-#ifdef WITH_WARNINGS
-#warning why do we do this?
-#endif
- // I don't think this is needed. Actually it might be plain wrong.
- tmppar->InsertChar(tmppar->text.size() - 1, '\0');
+ ifs.unsetf(ios::skipws);
+ istream_iterator<char> ii(ifs);
+ istream_iterator<char> end;
+ //string tmpstr(ii, end); // yet a reason for using std::string
+ // alternate approach to get the file into a string:
+ string tmpstr;
+ copy(ii, end, back_inserter(tmpstr));
// insert the string
- current_view->getScreen()->HideCursor();
+ current_view->hideCursor();
// clear the selection
- current_view->beforeChange();
+ bv->beforeChange();
if (!asParagraph)
- current_view->text->InsertStringA(tmppar->text);
+ bv->text->InsertStringA(bv, tmpstr);
else
- current_view->text->InsertStringB(tmppar->text);
- delete tmppar;
- current_view->update(1);
+ bv->text->InsertStringB(bv, tmpstr);
+ bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
void MenuInsertLabel(char const * arg)
{
string label = arg;
- ProhibitInput();
+ ProhibitInput(current_view);
if (label.empty()) {
pair<bool, string>
result = askForText(_("Enter new label to insert:"));
new_inset->setContents(label);
current_view->insertInset(new_inset);
}
- AllowInput();
+ AllowInput(current_view);
}
}
-void MenuPasteSelection(char at)
-{
- if (!current_view->getScreen())
- 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,
- current_view->owner()->getForm()->window, 0);
- XFlush(fl_display);
-}
-
-
-// candidate for move to BufferView
-extern "C" void FootCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
-
- current_view->owner()->getMiniBuffer()->Set(_("Inserting Footnote..."));
- current_view->getScreen()->HideCursor();
- current_view->update(-2);
- current_view->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
- current_view->update(1);
-}
-
-
// candidate for move to LyXView
+// This is only used in toolbar.C
void LayoutsCB(int sel, void *)
{
string tmp = tostr(sel);
/*
* SGML Linuxdoc support:
- * (flag == -1) import SGML file
* (flag == 0) make TeX output
* (flag == 1) make dvi output
*/
-int RunLinuxDoc(int flag, string const & filename)
+int RunLinuxDoc(BufferView * bv, int flag, string const & filename)
{
- string name;
string s2;
- string path;
string add_flags;
int errorcode = 0;
/* generate a path-less extension name */
- name = ChangeExtension (filename, ".sgml", true);
- path = OnlyPath (filename);
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
- path = current_view->buffer()->tmppath;
+ string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
+ string path = OnlyPath (filename);
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
+ path = bv->buffer()->tmppath;
}
Path p(path);
- if (flag != -1) {
- if (!current_view->available())
- return 0;
- current_view->buffer()->makeLinuxDocFile(name, 0);
-#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);
- switch (ps) {
- case BufferParams::PAPER_A4PAPER:
- add_flags = "-p a4";
- break;
- case BufferParams::PAPER_USLETTER:
- add_flags = "-p letter";
- break;
- default: /* nothing to be done yet ;-) */ break;
- }
+ if (!bv->available())
+ return 0;
+ bv->buffer()->makeLinuxDocFile(name, false);
+
+ // CHECK remove this once we have a proper geometry class
+
+ BufferParams::PAPER_SIZE ps =
+ static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
+ switch (ps) {
+ case BufferParams::PAPER_A4PAPER:
+ add_flags = "-p a4";
+ break;
+ case BufferParams::PAPER_USLETTER:
+ add_flags = "-p letter";
+ break;
+ default: /* nothing to be done yet ;-) */ break;
}
- ProhibitInput();
+ ProhibitInput(bv);
Systemcalls one;
switch (flag) {
- case -1: /* Import file */
- current_view->owner()->getMiniBuffer()->Set(_("Importing LinuxDoc SGML file `"),
- MakeDisplayPath(filename), "'...");
- s2 = "sgml2lyx " + lyxrc->sgml_extra_options + ' '
- + name;
- if (one.startscript(Systemcalls::System, s2))
- errorcode = 1;
- break;
case 0: /* TeX output asked */
- current_view->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
- s2 = "sgml2latex " + add_flags + " -o tex "
- + lyxrc->sgml_extra_options + ' ' + name;
+ bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to TeX file..."));
+ s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o tex " + ' ' + name;
if (one.startscript(Systemcalls::System, s2))
errorcode = 1;
break;
case 1: /* dvi output asked */
- current_view->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
- s2 = "sgml2latex " + add_flags + " -o dvi "
- + lyxrc->sgml_extra_options + ' ' + name;
+ bv->owner()->getMiniBuffer()->Set(_("Converting LinuxDoc SGML to dvi file..."));
+ s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
- } else
- current_view->buffer()->markDviClean();
+ }
break;
default: /* unknown output */
break;
}
- AllowInput();
+ AllowInput(bv);
- current_view->buffer()->redraw();
+ bv->buffer()->redraw();
return errorcode;
}
int RunDocBook(int flag, string const & filename)
{
/* generate a path-less extension name */
- string name = ChangeExtension (filename, ".sgml", true);
+ string name = OnlyFilename(ChangeExtension (filename, ".sgml"));
string path = OnlyPath (filename);
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = current_view->buffer()->tmppath;
}
Path p(path);
if (!current_view->available())
return 0;
- current_view->buffer()->makeDocBookFile(name, 0);
+ current_view->buffer()->makeDocBookFile(name, false);
// Shall this code go or should it stay? (Lgb)
+ // This code is a placeholder for future implementation. (Jose')
// string add_flags;
// LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->buffer()->params.papersize;
// switch (ps) {
// case BufferParams::PAPER_USLETTER: add_flags = "-p letter"; break;
// default: /* nothing to be done yet ;-) */ break;
// }
- ProhibitInput();
+ ProhibitInput(current_view);
int errorcode = 0;
Systemcalls one;
case 1: /* dvi output asked */
{
current_view->owner()->getMiniBuffer()->Set(_("Converting DocBook SGML to dvi file..."));
- string s2 = "sgmltools --backend dvi " + name;
+ string s2 = lyxrc.docbook_to_dvi_command + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
- } else
- current_view->buffer()->markDviClean();
+ }
}
break;
default: /* unknown output */
break;
}
- AllowInput();
+ AllowInput(current_view);
current_view->buffer()->redraw();
return errorcode;
}
-void BufferView::allFloats(char flag, char figmar)
-{
- if (!available()) return;
-
- LyXCursor cursor = text->cursor;
-
- if (!flag && cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
- && ((figmar
- && cursor.par->footnotekind != LyXParagraph::FOOTNOTE
- && cursor.par->footnotekind != LyXParagraph::MARGIN)
- || (!figmar
- && cursor.par->footnotekind != LyXParagraph::FIG
- && cursor.par->footnotekind != LyXParagraph::TAB
- && cursor.par->footnotekind != LyXParagraph::WIDE_FIG
- && cursor.par->footnotekind != LyXParagraph::WIDE_TAB
- && cursor.par->footnotekind != LyXParagraph::ALGORITHM)))
- toggleFloat();
- else
- beforeChange();
-
- LyXCursor tmpcursor = cursor;
- cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
- cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
-
- LyXParagraph *par = buffer()->paragraph;
- while (par) {
- if (flag) {
- if (par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE
- && ((figmar
- && par->footnotekind != LyXParagraph::FOOTNOTE
- && par->footnotekind != LyXParagraph::MARGIN)
- || (!figmar
- && par->footnotekind != LyXParagraph::FIG
- && par->footnotekind != LyXParagraph::TAB
- && par->footnotekind != LyXParagraph::WIDE_FIG
- && par->footnotekind != LyXParagraph::WIDE_TAB
- && par->footnotekind != LyXParagraph::ALGORITHM
- )
- )
- ) {
- if (par->previous
- && par->previous->footnoteflag !=
- LyXParagraph::CLOSED_FOOTNOTE){ /* should be */
- text->SetCursorIntern(par->previous,
- 0);
- text->OpenFootnote();
- }
- }
- }
- else {
- if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
- && (
- (figmar
- &&
- par->footnotekind != LyXParagraph::FOOTNOTE
- &&
- par->footnotekind != LyXParagraph::MARGIN
- )
- ||
- (!figmar
- &&
- par->footnotekind != LyXParagraph::FIG
- &&
- par->footnotekind != LyXParagraph::TAB
- &&
- par->footnotekind != LyXParagraph::WIDE_FIG
- &&
- par->footnotekind != LyXParagraph::WIDE_TAB
- &&
- par->footnotekind != LyXParagraph::ALGORITHM
- )
- )
- ) {
- text->SetCursorIntern(par, 0);
- text->CloseFootnote();
- }
- }
- par = par->next;
- }
-
- text->SetCursorIntern(cursor.par, cursor.pos);
- redraw();
- fitCursor();
- updateScrollbar();
-}
-
-
void MenuLayoutCharacter()
{
static int ow = -1, oh;
}
-inline void DeactivateParagraphButtons ()
+inline
+void DeactivateParagraphButtons ()
{
fl_deactivate_object (fd_form_paragraph->button_ok);
fl_deactivate_object (fd_form_paragraph->button_apply);
}
-inline void ActivateParagraphButtons ()
+inline
+void ActivateParagraphButtons ()
{
fl_activate_object (fd_form_paragraph->button_ok);
fl_activate_object (fd_form_paragraph->button_apply);
}
-inline void DisableParagraphLayout ()
+inline
+void DisableParagraphLayout ()
{
DeactivateParagraphButtons();
fl_deactivate_object (fd_form_paragraph->input_labelwidth);
}
-inline void EnableParagraphLayout ()
+inline
+void EnableParagraphLayout ()
{
ActivateParagraphButtons();
fl_activate_object (fd_form_paragraph->input_labelwidth);
bool UpdateLayoutParagraph()
{
- if (!current_view->getScreen() || !current_view->available()) {
+ if (!current_view->available()) {
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());
+ 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();
+ int align = current_view->text->cursor.par()->GetAlign();
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist.Style(buf->params.textclass,
- current_view->text->cursor.par->GetLayout()).align;
+ current_view->text->cursor.par()->GetLayout()).align;
switch (align) {
case LYX_ALIGN_RIGHT:
}
fl_set_button(fd_form_paragraph->check_lines_top,
- current_view->text->cursor.par->FirstPhysicalPar()->line_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);
+ 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);
+ 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);
+ current_view->text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
fl_set_button(fd_form_paragraph->check_noindent,
- current_view->text->cursor.par->FirstPhysicalPar()->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()) {
+ 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::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());
+ 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());
+ 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()) {
+ switch (current_view->text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_below,
1);
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());
+ 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());
+ 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);
+ current_view->text->cursor.par()->FirstPhysicalPar()->noindent);
if (current_view->buffer()->isReadonly()) {
DisableParagraphLayout();
bool UpdateLayoutDocument(BufferParams * params)
{
- if (!current_view->getScreen() || !current_view->available()) {
+ if (!current_view->available()) {
if (fd_form_document->form_document->visible)
fl_hide_form(fd_form_document->form_document);
return false;
fl_set_button(fd_form_document->radio_sides_one, 0);
fl_set_button(fd_form_document->radio_sides_two, 0);
- if (params->sides == 2)
- fl_set_button(fd_form_document->radio_sides_two, 1);
- else
+ switch (params->sides) {
+ case LyXTextClass::OneSide:
fl_set_button(fd_form_document->radio_sides_one, 1);
+ break;
+ case LyXTextClass::TwoSides:
+ fl_set_button(fd_form_document->radio_sides_two, 1);
+ break;
+ }
fl_set_button(fd_form_document->radio_columns_one, 0);
fl_set_button(fd_form_document->radio_columns_two, 0);
fl_set_input(fd_form_document->input_spacing, "");
switch (params->spacing.getSpace()) {
+ case Spacing::Default: // nothing bad should happen with this
case Spacing::Single:
{
// \singlespacing
case Spacing::Other:
{
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);
+ //char sval[20];
+ //sprintf(sval, "%g", params->spacing.getValue());
+#ifdef HAVE_SSTREAM
+ std::ostringstream sval;
+ sval << params->spacing.getValue(); // setw?
+ fl_set_input(fd_form_document->input_spacing,
+ sval.str().c_str());
+#else
+ char tval[20];
+ ostrstream sval(tval, 20);
+ sval << params->spacing.getValue() << '\0'; // setw?
+ fl_set_input(fd_form_document->input_spacing, sval.str());
+#endif
break;
}
}
bool UpdateLayoutQuotes()
{
bool update = true;
- if (!current_view->getScreen()
- || !current_view->available()
+ if (!current_view->available()
|| current_view->buffer()->isReadonly())
update = false;
bool UpdateLayoutPreamble()
{
bool update = true;
- if (!current_view->getScreen() || ! current_view->available())
+ if (!current_view->available())
update = false;
if (update) {
return update;
}
+
void MenuLayoutPreamble()
{
static int ow = -1, oh;
void MenuLayoutSave()
{
- if (!current_view->getScreen() || ! current_view->available())
+ if (!current_view->available())
return;
if (AskQuestion(_("Do you want to save the current settings"),
}
-void BufferView::insertNote()
-{
- InsetInfo * new_inset = new InsetInfo();
- insertInset(new_inset);
- new_inset->Edit(0, 0);
-}
-
-
-void BufferView::openStuff()
+// 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(BufferParams const & params)
{
- if (available()) {
- owner()->getMiniBuffer()->Set(_("Open/Close..."));
- getScreen()->HideCursor();
- beforeChange();
- update(-2);
- text->OpenStuff();
- update(0);
- }
-}
-
-
-void BufferView::toggleFloat()
-{
- if (available()) {
- owner()->getMiniBuffer()->Set(_("Open/Close..."));
- getScreen()->HideCursor();
- beforeChange();
- update(-2);
- text->ToggleFootnote();
- update(0);
- }
-}
-
-
-void BufferView::menuUndo()
-{
- if (available()) {
- owner()->getMiniBuffer()->Set(_("Undo"));
- getScreen()->HideCursor();
- beforeChange();
- update(-2);
- if (!text->TextUndo())
- owner()->getMiniBuffer()->Set(_("No further undo information"));
- else
- update(-1);
- }
-}
-
-
-void BufferView::menuRedo()
-{
- if (the_locking_inset) {
- owner()->getMiniBuffer()->Set(_("Redo not yet supported in math mode"));
- return;
- }
-
- if (available()) {
- owner()->getMiniBuffer()->Set(_("Redo"));
- getScreen()->HideCursor();
- beforeChange();
- update(-2);
- if (!text->TextRedo())
- owner()->getMiniBuffer()->Set(_("No further redo information"));
- else
- update(-1);
- }
-}
-
-
-void BufferView::hyphenationPoint()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- InsetSpecialChar * new_inset =
- new InsetSpecialChar(InsetSpecialChar::HYPHENATION);
- insertInset(new_inset);
- }
-}
-
-
-void BufferView::ldots()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- InsetSpecialChar * new_inset =
- new InsetSpecialChar(InsetSpecialChar::LDOTS);
- insertInset(new_inset);
- }
-}
-
-
-void BufferView::endOfSentenceDot()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- InsetSpecialChar * new_inset =
- new InsetSpecialChar(InsetSpecialChar::END_OF_SENTENCE);
- insertInset(new_inset);
- }
-}
-
-
-void BufferView::menuSeparator()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- InsetSpecialChar * new_inset =
- new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR);
- insertInset(new_inset);
- }
-}
-
-
-void BufferView::newline()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- text->InsertChar(LyXParagraph::META_NEWLINE);
- update(-1);
- }
-}
-
-
-void BufferView::protectedBlank()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- text->InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
- update(-1);
- }
-}
-
-
-void BufferView::hfill()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- text->InsertChar(LyXParagraph::META_HFILL);
- update(-1);
- }
-}
-
-
-/* -------> These CB's use ToggleFree() as the (one and only?) font-changer.
- They also show the current font state. */
-
-static
-void ToggleAndShow(LyXFont const &);
-
-
-void FontSizeCB(string const & size)
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setGUISize(size);
- ToggleAndShow(font);
-}
-
-
-void EmphCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setEmph(LyXFont::TOGGLE);
- ToggleAndShow(font);
-}
-
-
-void NounCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setNoun(LyXFont::TOGGLE);
- ToggleAndShow(font);
-}
-
-
-void BoldCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setSeries(LyXFont::BOLD_SERIES);
- ToggleAndShow(font);
-}
-
-
-void UnderlineCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setUnderbar(LyXFont::TOGGLE);
- ToggleAndShow(font);
-}
-
-
-void CodeCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
- ToggleAndShow(font);
-}
-
-
-void SansCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::SANS_FAMILY);
- ToggleAndShow(font);
-}
-
-
-void RomanCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::ROMAN_FAMILY);
- ToggleAndShow(font);
-}
-
-
-void TexCB()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLatex (LyXFont::TOGGLE);
- ToggleAndShow(font);
-}
-
-
-void StyleResetCB()
-{
- LyXFont font(LyXFont::ALL_INHERIT);
- ToggleAndShow(font);
-}
-
-
-/* -------> 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.
- */
-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->
- params.textclass).defaultfont();
- font.reduce(defaultfont);
- state = _("Font: ") + font.stateText();
-
- int depth = current_view->text->GetDepth();
- if (depth > 0)
- state += string(_(", Depth: ")) + tostr(depth);
- }
- return state;
-}
-
-
-// candidate for move to BufferView
-/* -------> Does the actual toggle job of the XxxCB() calls above.
- * Also shows the current font state.
- */
-static
-void ToggleAndShow(LyXFont const & font)
-{
- if (current_view->available()) {
- current_view->getScreen()->HideCursor();
- current_view->update(-2);
- current_view->text->ToggleFree(font, toggleall);
- current_view->update(1);
- }
-}
-
-
-// candidate for move to BufferView
-extern "C" void MarginCB(FL_OBJECT *, long)
-{
- if (current_view->available()) {
- current_view->owner()->getMiniBuffer()->Set(_("Inserting margin note..."));
- current_view->getScreen()->HideCursor();
- current_view->update(-2);
- current_view->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
- current_view->update(1);
- }
-}
-
-
-extern "C" void FigureCB(FL_OBJECT *, long)
-{
- 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"));
- }
-}
-
-
-extern "C" void TableCB(FL_OBJECT *, long)
-{
- if (fd_form_table->form_table->visible) {
- fl_raise_form(fd_form_table->form_table);
- } else {
- fl_show_form(fd_form_table->form_table,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Insert Table"));
- }
-}
-
-
-void BufferView::copyEnvironment()
-{
- if (available()) {
- text->copyEnvironmentType();
- // clear the selection, even if mark_set
- getScreen()->ToggleSelection();
- text->ClearSelection();
- update(-2);
- owner()->getMiniBuffer()->Set(_("Paragraph environment type copied"));
- }
-}
-
-
-void BufferView::pasteEnvironment()
-{
- if (available()) {
- text->pasteEnvironmentType();
- owner()->getMiniBuffer()->Set(_("Paragraph environment type set"));
- update(1);
- }
-}
-
-
-void BufferView::copy()
-{
- if (available()) {
- text->CopySelection();
- // clear the selection, even if mark_set
- getScreen()->ToggleSelection();
- text->ClearSelection();
- update(-2);
- owner()->getMiniBuffer()->Set(_("Copy"));
- }
-}
-
-
-void BufferView::cut()
-{
- if (available()) {
- getScreen()->HideCursor();
- update(-2);
- text->CutSelection();
- update(1);
- owner()->getMiniBuffer()->Set(_("Cut"));
- }
-}
-
-
-void BufferView::paste()
-{
- if (!available()) return;
-
- owner()->getMiniBuffer()->Set(_("Paste"));
- getScreen()->HideCursor();
- // clear the selection
- getScreen()->ToggleSelection();
- text->ClearSelection();
- update(-2);
-
- // paste
- text->PasteSelection();
- update(1);
-
- // clear the selection
- getScreen()->ToggleSelection();
- text->ClearSelection();
- update(-2);
-}
-
-
-// candidate for move to BufferView
-extern "C" void MeltCB(FL_OBJECT *, long)
-{
- if (!current_view->available()) return;
-
- current_view->owner()->getMiniBuffer()->Set(_("Melt"));
- current_view->getScreen()->HideCursor();
- current_view->beforeChange();
- current_view->update(-2);
- current_view->text->MeltFootnoteEnvironment();
- current_view->update(1);
-}
-
-
-// candidate for move to BufferView
-// Change environment depth.
-// if decInc == 0, depth change taking mouse button number into account
-// if decInc == 1, increment depth
-// if decInc == -1, decrement depth
-extern "C" void DepthCB(FL_OBJECT * ob, long decInc)
-{
- int button = 1;
-
- /* When decInc != 0, fake a mouse button. This allows us to
- implement depth-plus and depth-min commands. RVDK_PATCH_5. */
- /* check out wether ob is defined, too (Matthias) */
- if ( decInc < 0 )
- button = 0;
- else if (!decInc && ob) {
- button = fl_get_button_numb(ob);
- }
-
- if (current_view->available()) {
- current_view->getScreen()->HideCursor();
- current_view->update(-2);
- if (button == 1)
- current_view->text->IncDepth();
- else
- current_view->text->DecDepth();
- current_view->update(1);
- current_view->owner()->getMiniBuffer()->Set(_("Changed environment depth"
- " (in possible range, maybe not)"));
- }
-}
-
-
-// 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);
+ LyXFont font(LyXFont::ALL_IGNORE);
int pos = fl_get_choice(fd_form_character->choice_family);
switch(pos) {
pos = fl_get_choice(fd_form_character->choice_color);
switch(pos) {
- case 1: font.setColor(LyXFont::IGNORE_COLOR); break;
- case 2: font.setColor(LyXFont::NONE); break;
- case 3: font.setColor(LyXFont::BLACK); break;
- case 4: font.setColor(LyXFont::WHITE); break;
- case 5: font.setColor(LyXFont::RED); break;
- case 6: font.setColor(LyXFont::GREEN); break;
- case 7: font.setColor(LyXFont::BLUE); break;
- case 8: font.setColor(LyXFont::CYAN); break;
- case 9: font.setColor(LyXFont::MAGENTA); break;
- case 10: font.setColor(LyXFont::YELLOW); break;
- case 11: font.setColor(LyXFont::INHERIT_COLOR); break;
- }
+ 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;
+ }
+
+ int choice = combo_language2->get();
+ if (choice == 1)
+ font.setLanguage(ignore_language);
+ else if (choice == 2)
+ font.setLanguage(params.language_info);
+ else
+ font.setLanguage(&languages[combo_language2->getline()]);
return font;
}
-void FreeCB()
-{
- ToggleAndShow(UserFreeFont());
-}
-
-
/* callbacks for form form_title */
extern "C" void TimerCB(FL_OBJECT *, long)
{
// only if the form still exists
- if (fd_form_title->form_title != 0) {
+ if (lyxrc.show_banner && fd_form_title->form_title != 0) {
if (fd_form_title->form_title->visible) {
fl_hide_form(fd_form_title->form_title);
}
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
noindent = fl_get_button(fd_form_paragraph->check_noindent);
- current_view->text->SetParagraph(line_top,
+ current_view->text->SetParagraph(current_view,
+ line_top,
line_bottom,
pagebreak_top,
pagebreak_bottom,
align,
labelwidthstring,
noindent);
- current_view->update(1);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
current_view->owner()->getMiniBuffer()->Set(_("Paragraph layout set"));
}
// 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);
- ToggleAndShow( UserFreeFont());
+ ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
+ current_view->setState();
toggleall = true;
}
void UpdateDocumentButtons(BufferParams const & params)
{
fl_set_choice(fd_form_document->choice_pagestyle, 1);
-
- if (params.sides == 2)
- fl_set_button(fd_form_document->radio_sides_two, 1);
- else
+
+ switch (params.sides) {
+ case LyXTextClass::OneSide:
fl_set_button(fd_form_document->radio_sides_one, 1);
-
+ break;
+ case LyXTextClass::TwoSides:
+ fl_set_button(fd_form_document->radio_sides_two, 1);
+ break;
+ }
+
if (params.columns == 2)
fl_set_button(fd_form_document->radio_columns_two, 1);
else
extern "C" void ChoiceClassCB(FL_OBJECT * ob, long)
{
- ProhibitInput();
+ ProhibitInput(current_view);
if (textclasslist.Load(fl_get_choice(ob)-1)) {
if (AskQuestion(_("Should I set some parameters to"),
fl_get_choice_text(ob),
fl_set_choice(fd_form_document->choice_class,
current_view->buffer()->params.textclass + 1);
}
- AllowInput();
+ AllowInput(current_view);
}
extern "C" void DocumentApplyCB(FL_OBJECT *, long)
{
bool redo = false;
- BufferParams *params = &(current_view->buffer()->params);
- current_view->buffer()->params.language =
- combo_language->getline();
+ BufferParams * params = &(current_view->buffer()->params);
+
+ Language const * old_language = params->language_info;
+ params->language = combo_language->getline();
+ Languages::iterator lit = languages.find(params->language);
+
+ Language const * new_language;
+ if (lit != languages.end())
+ new_language = &(*lit).second;
+ else
+ new_language = default_language;
+
+ if (current_view->available()) {
+ if (old_language != new_language
+ && old_language->RightToLeft() == new_language->RightToLeft()
+ && !current_view->buffer()->isMultiLingual())
+ current_view->buffer()->ChangeLanguage(old_language,
+ new_language);
+ if (old_language != new_language) {
+ //current_view->buffer()->redraw();
+ redo = true;
+ }
+ }
+ params->language_info = new_language;
// 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 (!current_view->available())
return;
- LyXTextClassList::ClassList::size_type new_class = fl_get_choice(fd_form_document->choice_class) - 1;
+ current_view->text->SetCursor(current_view,
+ current_view->text->cursor.par(),
+ current_view->text->cursor.pos());
+ current_view->setState();
+
+ LyXTextClassList::ClassList::size_type new_class =
+ fl_get_choice(fd_form_document->choice_class) - 1;
+
if (params->textclass != new_class) {
// try to load new_class
if (textclasslist.Load(new_class)) {
// successfully loaded
redo = true;
- current_view->owner()->getMiniBuffer()->Set(_("Converting document to new document class..."));
- int ret = current_view->text->
- SwitchLayoutsBetweenClasses(current_view->buffer()->
- params.textclass,
- new_class,
- current_view->buffer()->
- paragraph);
+ current_view->owner()->getMiniBuffer()->
+ Set(_("Converting document to new document class..."));
+ CutAndPaste cap;
+ int ret = cap.SwitchLayoutsBetweenClasses(
+ current_view->buffer()->params.textclass,
+ new_class,
+ current_view->buffer()->paragraph);
if (ret) {
string s;
current_view->owner()->getMiniBuffer()->Set(_("Document layout set"));
current_view->buffer()->markDirty();
-
+
params->options =
fl_get_input(fd_form_document->input_extra);
-
}
}
-void BufferView::gotoNote()
-{
- if (!getScreen()) return;
-
- getScreen()->HideCursor();
- beforeChange();
- update(-2);
- LyXCursor tmp;
-
- if (!text->GotoNextNote()) {
- if (text->cursor.pos
- || text->cursor.par != text->FirstParagraph()) {
- tmp = text->cursor;
- text->cursor.par = text->FirstParagraph();
- text->cursor.pos = 0;
- if (!text->GotoNextNote()) {
- text->cursor = tmp;
- owner()->getMiniBuffer()->Set(_("No more notes"));
- LyXBell();
- }
- } else {
- owner()->getMiniBuffer()->Set(_("No more notes"));
- LyXBell();
- }
- }
- update(0);
- text->sel_cursor = text->cursor;
-}
-
-
-void BufferView::insertCorrectQuote()
-{
- char c;
-
- if (text->cursor.pos)
- c = text->cursor.par->GetChar(text->cursor.pos - 1);
- else
- c = ' ';
-
- insertInset(new InsetQuotes(c, buffer()->params));
-}
-
-
/* callbacks for form form_quotes */
extern "C" void QuotesApplyCB(FL_OBJECT *, long)
return;
current_view->owner()->getMiniBuffer()->Set(_("Quotes type set"));
- //current_view->buffer()->params.quotes_language =
- // fl_get_choice(fd_form_quotes->choice_quotes_language) - 1;
InsetQuotes::quote_language lga = InsetQuotes::EnglishQ;
switch(fl_get_choice(fd_form_quotes->choice_quotes_language) - 1) {
case 0:
extern "C" void TableApplyCB(FL_OBJECT *, long)
{
- if (!current_view->getScreen())
+ if (!current_view->available())
return;
// check for tables in tables
- if (current_view->text->cursor.par->table){
+ if (current_view->text->cursor.par()->table){
WriteAlert(_("Impossible Operation!"),
_("Cannot insert table in table."),
_("Sorry."));
int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5);
- current_view->getScreen()->HideCursor();
+ current_view->hideCursor();
current_view->beforeChange();
- current_view->update(-2);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
- current_view->text->SetCursorParUndo();
+ current_view->text->SetCursorParUndo(current_view->buffer());
current_view->text->FreezeUndo();
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- if (current_view->text->cursor.par->Last()) {
- current_view->text->CursorLeft();
+ if (current_view->text->cursor.par()->Last()) {
+ current_view->text->CursorLeft(current_view);
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
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 ==
+ current_view->text->SetLayout(current_view, 0); // standard layout
+ if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
current_view->text
- ->SetParagraph(0, 0,
+ ->SetParagraph(current_view, 0, 0,
0, 0,
VSpace (0.3 * current_view->buffer()->
params.spacing.getValue(),
LYX_ALIGN_CENTER,
string(),
0);
- }
- else
+ } else {
current_view->text
- ->SetParagraph(0, 0,
+ ->SetParagraph(current_view, 0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
LYX_ALIGN_CENTER,
string(),
0);
+ }
- current_view->text->cursor.par->table =
+ 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();
+ Language const * lang =
+ current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params);
+ LyXFont font(LyXFont::ALL_INHERIT, lang);
+ for (int i = 0; i < xsize * ysize - 1; ++i) {
+ current_view->text->cursor.par()
+ ->InsertChar(0, LyXParagraph::META_NEWLINE, font);
+ }
+ current_view->text->RedoParagraph(current_view);
current_view->text->UnFreezeUndo();
- current_view->update(1);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
current_view->owner()->getMiniBuffer()->Set(_("Table inserted"));
+ current_view->setState();
}
}
-/* callbacks for form form_print */
-
-extern "C" void PrintCancelCB(FL_OBJECT *, long)
+void Figure()
{
- fl_hide_form(fd_form_print->form_print);
-}
-
-static bool stringOnlyContains (string const & LStr, char const * cset)
-{
- char const * cstr = LStr.c_str() ;
-
- return strspn(cstr, cset) == strlen(cstr) ;
-}
-
-extern "C" void PrintApplyCB(FL_OBJECT *, long)
-{
- if (!current_view->available())
- return;
- Buffer * buffer = current_view->buffer();
- string path = OnlyPath(buffer->fileName());
-
- string pageflag;
- 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
- string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
- pages = subst(pages, '+',',');
- pages = frontStrip(strip(pages)) ;
- while (!pages.empty()) { // a page range was given
- string piece ;
- pages = split (pages, piece, ',') ;
- piece = strip(piece) ;
- piece = frontStrip(piece) ;
- if ( !stringOnlyContains (piece, "0123456789-") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'range of pages'!"));
- return;
- }
- if (piece.find('-') == string::npos) { // not found
- pageflag += lyxrc->print_pagerange_flag + piece + '-' + piece + ' ' ;
- } 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 + ' ' ;
- } else {
- pageflag += lyxrc->print_pagerange_flag + piece + ' ' ;
- }
- }
-
- string copies = frontStrip(strip(fl_get_input(fd_form_print->input_copies)));
- if (!copies.empty()) { // a number of copies was given
- if ( !stringOnlyContains (copies, "0123456789") ) {
- WriteAlert(_("ERROR! Unable to print!"),
- _("Check 'number of copies'!"));
- return;
- }
- if (fl_get_button(fd_form_print->do_unsorted))
- pageflag += lyxrc->print_copies_flag;
- else
- pageflag += lyxrc->print_collcopies_flag;
- pageflag += " " + copies + ' ' ;
- }
-
- string reverseflag;
- if (fl_get_button(fd_form_print->radio_order_reverse))
- reverseflag = lyxrc->print_reverse_flag + ' ';
-
- string orientationflag;
- if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- orientationflag = lyxrc->print_landscape_flag + ' ';
-
- string ps_file = fl_get_input(fd_form_print->input_file);
- string printer = strip(fl_get_input(fd_form_print->input_printer));
-
- string printerflag;
- 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 + ' ';
-
- string extraflags;
- if (!lyxrc->print_extra_options.empty())
- extraflags = lyxrc->print_extra_options + ' ';
-
- string command = lyxrc->print_command + ' '
- + printerflag + pageflag + reverseflag
- + orientationflag + extraflags;
-
- char real_papersize = buffer->params.papersize;
- if (real_papersize == BufferParams::PAPER_DEFAULT)
- real_papersize = lyxrc->default_papersize;
-
- string paper;
- switch (real_papersize) {
- case BufferParams::PAPER_USLETTER:
- paper = "letter";
- 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 an empty value... */
- break;
- }
-
- if (buffer->params.use_geometry
- && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
- && !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()
- && (real_papersize != BufferParams::PAPER_USLETTER ||
- buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
- command += " " + lyxrc->print_paper_flag + " " + paper + " ";
+ 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"));
}
- if (fl_get_button(fd_form_print->radio_file))
- command += lyxrc->print_to_file
- + QuoteName(MakeAbsPath(ps_file, path));
- else if (!lyxrc->print_spool_command.empty())
- command += lyxrc->print_to_file
- + QuoteName(ps_file);
-
- // push directorypath, if necessary
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
- path = buffer->tmppath;
- }
- Path p(path);
-
- bool result;
- if (!lyxrc->print_spool_command.empty() &&
- !fl_get_button(fd_form_print->radio_file)) {
- string command2 = lyxrc->print_spool_command + ' ';
- if (!printer.empty())
- command2 += lyxrc->print_spool_printerprefix
- + printer;
- // 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"));
}
-extern "C" void PrintOKCB(FL_OBJECT * ob, long data)
+void Table()
{
- PrintCancelCB(ob, data);
- PrintApplyCB(ob, data);
+ if (fd_form_table->form_table->visible) {
+ fl_raise_form(fd_form_table->form_table);
+ } else {
+ fl_show_form(fd_form_table->form_table,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
+ _("Insert Table"));
+ }
}
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
if (fl_get_button(fd_form_figure->radio_inline)
- || current_view->text->cursor.par->table) {
+ || current_view->text->cursor.par()->table) {
InsetFig * new_inset = new InsetFig(100, 20, buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
- new_inset->Edit(0, 0);
+ new_inset->Edit(current_view, 0, 0, 0);
return;
}
- current_view->getScreen()->HideCursor();
- current_view->update(-2);
+ current_view->hideCursor();
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
current_view->beforeChange();
- current_view->text->SetCursorParUndo();
+ current_view->text->SetCursorParUndo(current_view->buffer());
current_view->text->FreezeUndo();
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
- if (current_view->text->cursor.par->Last()) {
- current_view->text->CursorLeft();
+ if (current_view->text->cursor.par()->Last()) {
+ current_view->text->CursorLeft(current_view);
- current_view->text->BreakParagraph();
- current_view->update(-1);
+ current_view->text->BreakParagraph(current_view);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
// The standard layout should always be numer 0;
- current_view->text->SetLayout(0);
+ current_view->text->SetLayout(current_view, 0);
- if (current_view->text->cursor.par->footnoteflag ==
+ if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
current_view->text->
- SetParagraph(0, 0,
+ SetParagraph(current_view, 0, 0,
0, 0,
VSpace (0.3 * buffer->params.spacing.getValue(),
LyXLength::CM),
buffer->params.spacing.getValue(),
LyXLength::CM),
LYX_ALIGN_CENTER, string(), 0);
- } else
- current_view->text->SetParagraph(0, 0,
+ } else {
+ current_view->text->SetParagraph(current_view, 0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
LYX_ALIGN_CENTER,
string(),
0);
+ }
- current_view->update(-1);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
Inset * new_inset = new InsetFig(100, 100, buffer);
current_view->insertInset(new_inset);
- new_inset->Edit(0, 0);
- current_view->update(0);
+ new_inset->Edit(current_view, 0, 0, 0);
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
current_view->text->UnFreezeUndo();
+ current_view->setState();
}
extern "C" void ScreenApplyCB(FL_OBJECT *, long)
{
- 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));
+ 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();
-
+
+ // Of course we should only to the resize and the textcahce.clear
+ // if values really changed...but not very important right now. (Lgb)
+
// All buffers will need resize
bufferlist.resize();
-
+ // We also need to empty the textcache so that
+ // the buffer will be formatted correctly after
+ // a zoom change.
+ textcache.clear();
+
current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
}
}
-void LaTeXOptions()
+void LaTeXOptions(BufferView * bv)
{
- if (!current_view->available())
+ if (!bv->available())
return;
fl_set_button(fd_latex_options->accents,
- int(current_view->buffer()->params.allowAccents));
+ int(bv->buffer()->params.allowAccents));
if (fd_latex_options->LaTeXOptions->visible) {
fl_raise_form(fd_latex_options->LaTeXOptions);
// This function runs "configure" and then rereads lyx.defaults to
// reconfigure the automatic settings.
-void Reconfigure()
+void Reconfigure(BufferView * bv)
{
- current_view->owner()->getMiniBuffer()->Set(_("Running configure..."));
+ bv->owner()->getMiniBuffer()->Set(_("Running configure..."));
// Run configure in user lyx directory
Path p(user_lyxdir);
Systemcalls one(Systemcalls::System,
AddName(system_lyxdir, "configure"));
p.pop();
- current_view->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
- lyxrc->read(LibFileSearch(string(), "lyxrc.defaults"));
+ bv->owner()->getMiniBuffer()->Set(_("Reloading configuration..."));
+ lyxrc.read(LibFileSearch(string(), "lyxrc.defaults"));
WriteAlert(_("The system has been reconfigured."),
_("You need to restart LyX to make use of any"),
_("updated document class specifications."));
}
-/* these functions are for the spellchecker */
-char * BufferView::nextWord(float & value)
-{
- if (!available()) {
- value = 1;
- return 0;
- }
-
- char * string = text->SelectNextWord(value);
-
- return string;
-}
-
-
-void BufferView::selectLastWord()
-{
- if (!available()) return;
-
- getScreen()->HideCursor();
- beforeChange();
- text->SelectSelectedWord();
- getScreen()->ToggleSelection(false);
- update(0);
-}
-
-
-void BufferView::endOfSpellCheck()
-{
- if (!available()) return;
-
- getScreen()->HideCursor();
- beforeChange();
- text->SelectSelectedWord();
- text->ClearSelection();
- update(0);
-}
-
-
-void BufferView::replaceWord(string const & replacestring)
-{
- if (!getScreen()) return;
-
- getScreen()->HideCursor();
- update(-2);
-
- /* clear the selection (if there is any) */
- getScreen()->ToggleSelection(false);
- update(-2);
-
- /* clear the selection (if there is any) */
- getScreen()->ToggleSelection(false);
- text->ReplaceSelectionWithString(replacestring.c_str());
-
- text->SetSelectionOverString(replacestring.c_str());
-
- // Go back so that replacement string is also spellchecked
- for (string::size_type i = 0; i < replacestring.length() + 1; ++i) {
- text->CursorLeftIntern();
- }
- update(1);
-}
-// End of spellchecker stuff
-
-
-
//
// Table of Contents
//
-struct TocList {
- int counter[6];
- bool appendix;
- TocList * next;
-};
-
-
-static TocList * toclist = 0;
+static vector<Buffer::TocItem> toclist;
extern "C" void TocSelectCB(FL_OBJECT * ob, long)
if (!current_view->available())
return;
- TocList * tmptoclist = toclist;
- int i = fl_get_browser(ob);
- for (int a = 1; a < i && tmptoclist->next; ++a) {
- tmptoclist = tmptoclist->next;
- }
-
- if (!tmptoclist)
- return;
-
-
- LyXParagraph * par = current_view->buffer()->paragraph;
- 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) {
- current_view->beforeChange();
- current_view->text->SetCursor(par, 0);
+ TocUpdateCB(0, 0);
+ unsigned int choice = fl_get_browser(ob);
+ if (0 < choice && choice - 1 < toclist.size()) {
+ current_view->beforeChange();
+ current_view->text->SetCursor(current_view, toclist[choice-1].par, 0);
current_view->text->sel_cursor =
current_view->text->cursor;
- current_view->update(0);
- }
- else {
+ current_view->update(BufferView::SELECT|BufferView::FITCUR);
+ } else {
WriteAlert(_("Error"),
_("Couldn't find this label"),
_("in current document."));
}
-
}
}
-extern "C" void TocUpdateCB(FL_OBJECT *, long)
+extern "C"
+void TocUpdateCB(FL_OBJECT *, long)
{
- static LyXParagraph * stapar = 0;
- TocList * tmptoclist = 0;
-
- /* deleted the toclist */
- if (toclist){
- while (toclist){
- tmptoclist = toclist->next;
- delete toclist;
- toclist = tmptoclist;
- }
- }
- toclist = 0;
- tmptoclist = toclist;
-
-
- fl_clear_browser(fd_form_toc->browser_toc);
if (!current_view->available()) {
+ toclist.clear();
+ fl_clear_browser(fd_form_toc->browser_toc);
fl_add_browser_line(fd_form_toc->browser_toc,
_("*** No Document ***"));
return;
}
- fl_hide_object(fd_form_toc->browser_toc);
- /* get the table of contents */
- LyXParagraph * par = current_view->buffer()->paragraph;
- char labeltype;
- char * line = new char[200];
- 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) {
- labeltype = textclasslist.Style(current_view->buffer()->params.textclass,
- par->GetLayout()).labeltype;
-
- if (labeltype >= LABEL_COUNTER_CHAPTER
- && labeltype <= LABEL_COUNTER_CHAPTER +
- current_view->buffer()->params.tocdepth) {
- /* insert this into the table of contents */
- /* first indent a little bit */
-
- for (pos = 0;
- pos < (labeltype -
- textclasslist.TextClass(current_view->buffer()->
- params.textclass).maxcounter()) * 4 + 2;
- pos++)
- line[pos] = ' ';
-
- // Then the labestring
- if (!par->labelstring.empty()) {
- string::size_type i = 0;
- while (pos < 199 && i < par->labelstring.length()) {
- line[pos] = par->labelstring[i];
- i++;
- pos++;
- }
- }
-
- line[pos] = ' ';
- ++pos;
-
- /* now the contents */
- LyXParagraph::size_type i = 0;
- while (pos < 199 && i < par->size()) {
- c = par->GetChar(i);
- if (isprint(c) || c >= 128) {
- line[pos] = c;
- pos++;
- }
- ++i;
- }
- 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;
- }
-
- tmptoclist->next = 0;
- int a = 0;
- for (a = 0; a < 6; ++a) {
- tmptoclist->counter[a] = par->GetFirstCounter(a);
- }
- tmptoclist->appendix = par->appendix;
+
+ vector<vector<Buffer::TocItem> > tmp =
+ current_view->buffer()->getTocList();
+ int type = fl_get_choice(fd_form_toc->toctype)-1;
+ //if (toclist == tmp[type])
+ // return;
+ if (toclist.size() == tmp[type].size()) {
+ // Check if all elements are the same.
+ unsigned int i = 0;
+ for (; i < toclist.size(); ++i) {
+ if (toclist[i] != tmp[type][i])
+ break;
}
- par = par->LastPhysicalPar()->Next();
-
+ if (i >= toclist.size()) return;
}
- delete[] line;
+
+ toclist = tmp[type];
+
+ static Buffer * buffer = 0;
+ int topline = 0;
+ int line = 0;
+ if (buffer == current_view->buffer()) {
+ topline = fl_get_browser_topline(fd_form_toc->browser_toc);
+ line = fl_get_browser(fd_form_toc->browser_toc);
+ } else
+ buffer = current_view->buffer();
+
+ fl_clear_browser(fd_form_toc->browser_toc);
+ fl_hide_object(fd_form_toc->browser_toc);
+
+ for (vector<Buffer::TocItem>::const_iterator it = toclist.begin();
+ it != toclist.end(); ++it)
+ fl_add_browser_line(fd_form_toc->browser_toc,
+ (string(4*(*it).depth,' ')+
+ (*it).str).c_str());
+
fl_set_browser_topline(fd_form_toc->browser_toc, topline);
+ fl_select_browser_line(fd_form_toc->browser_toc, line);
fl_show_object(fd_form_toc->browser_toc);
}
if (s.empty())
return;
- if (data == 2) {
+ if (data == 5) {
current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
+ if (!current_view->NoSavedPositions()) {
+ fl_activate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_BLACK);
+ }
return;
- }
-
- string t;
- if (data == 0)
- t += "\\ref";
- else
- t += "\\pageref";
+ } else if (data >= 6) {
+ current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFBACK);
+ if (current_view->NoSavedPositions()) {
+ fl_deactivate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE);
+ }
+ return;
+ }
- if(current_view->buffer()->isSGML())
+ static string const commands[5]
+ = { "\\ref", "\\pageref", "\\vref", "\\vpageref",
+ "\\prettyref"};
+ string t = commands[data];
+
+ if (current_view->buffer()->isSGML())
t += "[" + u + "]" + "{" + s + "}";
else
t += "{" + s + "}";
string currentstr = btmp ? btmp : "";
fl_clear_browser(brow);
+ fl_hide_object(brow);
- string refs = current_view->buffer()->getReferenceList('\n');
- int topline = 1;
+ vector<string> refs = current_view->buffer()->getLabelList();
+ if (fl_get_button(fd_form_ref->sort))
+ sort(refs.begin(),refs.end());
+ for (vector<string>::const_iterator it = refs.begin();
+ it != refs.end(); ++it)
+ fl_add_browser_line(brow, (*it).c_str());
-#if FL_REVISION > 85
- fl_addto_browser_chars(brow, refs.c_str());
+ int topline = 1;
int total_lines = fl_get_browser_maxline(brow);
- for (int i = 1; i <= total_lines ; i++) {
+ for (int i = 1; i <= total_lines ; ++i) {
if (fl_get_browser_line(brow, i) == currentstr) {
topline = i;
break;
}
}
fl_set_browser_topline(brow, topline);
-#else
- // Keep the old ugly code for xforms 0.81 compatibility
- string curr_ref;
- int ref_num = 0;
-
- while(true) {
- curr_ref = refs.token('\n', ref_num);
- if (curr_ref.empty())
- break;
- fl_add_browser_line(brow, curr_ref.c_str());
- ref_num++;
+
+ bool empty = refs.empty();
+ bool sgml = current_view->buffer()->isSGML();
+ bool readonly = current_view->buffer()->isReadonly();
+
+ if (current_view->NoSavedPositions()) {
+ fl_deactivate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_ref->back);
+ fl_set_object_lcol(fd_form_ref->back, FL_BLACK);
}
-#endif
- if (!fl_get_browser_maxline(brow)) {
+ if (empty) {
fl_add_browser_line(brow,
_("*** No labels found in document ***"));
fl_deactivate_object(brow);
+ fl_deactivate_object(fd_form_ref->gotoref);
+ fl_set_object_lcol(fd_form_ref->gotoref, FL_INACTIVE);
} else {
fl_select_browser_line(brow, topline);
fl_activate_object(brow);
+ fl_activate_object(fd_form_ref->gotoref);
+ fl_set_object_lcol(fd_form_ref->gotoref, FL_BLACK);
}
- if (current_view->buffer()->isReadonly()) {
- // 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);
+
+ if (empty || readonly) {
+ fl_deactivate_object(fd_form_ref->ref);
+ fl_set_object_lcol(fd_form_ref->ref, FL_INACTIVE);
+ fl_deactivate_object(fd_form_ref->pageref);
+ fl_set_object_lcol(fd_form_ref->pageref, FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_ref->ref);
+ fl_set_object_lcol(fd_form_ref->ref, FL_BLACK);
+ fl_activate_object(fd_form_ref->pageref);
+ fl_set_object_lcol(fd_form_ref->pageref, FL_BLACK);
}
- if (!current_view->buffer()->isSGML()) {
- fl_deactivate_object(fd_form_ref->ref_name);
- fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
+
+ if (empty || readonly || sgml) {
+ fl_deactivate_object(fd_form_ref->vref);
+ fl_set_object_lcol(fd_form_ref->vref, FL_INACTIVE);
+ fl_deactivate_object(fd_form_ref->vpageref);
+ fl_set_object_lcol(fd_form_ref->vpageref, FL_INACTIVE);
+ fl_deactivate_object(fd_form_ref->prettyref);
+ fl_set_object_lcol(fd_form_ref->prettyref, FL_INACTIVE);
+ } else {
+ fl_activate_object(fd_form_ref->vref);
+ fl_set_object_lcol(fd_form_ref->vref, FL_BLACK);
+ fl_activate_object(fd_form_ref->vpageref);
+ fl_set_object_lcol(fd_form_ref->vpageref, FL_BLACK);
+ fl_activate_object(fd_form_ref->prettyref);
+ fl_set_object_lcol(fd_form_ref->prettyref, FL_BLACK);
}
- else {
+
+ if (sgml) {
fl_activate_object(fd_form_ref->ref_name);
fl_set_object_lcol(fd_form_ref->ref_name, FL_BLACK);
+ } else {
+ fl_deactivate_object(fd_form_ref->ref_name);
+ fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
}
+
+ fl_show_object(brow);
}
{
fl_hide_form(fd_form_ref->form_ref);
}
-
-
-// candidate for move to BufferView
-void UpdateInset(Inset * inset, bool mark_dirty)
-{
- if (!inset)
- return;
-
- /* very first check for locking insets*/
- if (current_view->the_locking_inset == inset) {
- if (current_view->text->UpdateInset(inset)){
- current_view->update();
- if (mark_dirty){
- if (current_view->buffer()->isLyxClean())
- current_view->owner()->getMiniBuffer()->setTimer(4);
- current_view->buffer()->markDirty();
- }
- current_view->updateScrollbar();
- return;
- }
- }
-
- /* first check the current buffer */
- if (current_view->available()){
- current_view->getScreen()->HideCursor();
- current_view->update(-3);
- if (current_view->text->UpdateInset(inset)){
- if (mark_dirty)
- current_view->update(1);
- else
- current_view->update(3);
- return;
- }
- }
-
- // check all buffers
- bufferlist.updateInset(inset, mark_dirty);
-
-}
-
-
-/* these functions return 1 if an error occured,
- otherwise 0 */
-int BufferView::lockInset(UpdatableInset * inset)
-{
- if (!the_locking_inset && inset){
- the_locking_inset = inset;
- return 0;
- }
- return 1;
-}
-
-
-void BufferView::showLockedInsetCursor(long x, long y, int asc, int desc)
-{
- if (the_locking_inset && getScreen()) {
- y += text->cursor.y;
- getScreen()->ShowManualCursor(x, y,
- asc, desc);
- }
-}
-
-
-void BufferView::hideLockedInsetCursor(long x, long y, int asc, int desc)
-{
- if (the_locking_inset && getScreen()) {
- y += text->cursor.y;
- getScreen()->HideManualCursor(x, y,
- asc, desc);
- }
-}
-
-
-void BufferView::fitLockedInsetCursor(long x, long y, int asc, int desc)
-{
- if (the_locking_inset && getScreen()){
- y += text->cursor.y;
- if (getScreen()->FitManualCursor(x, y, asc, desc))
- updateScrollbar();
- }
-}
-
-
-int BufferView::unlockInset(UpdatableInset * inset)
-{
- if (inset && the_locking_inset == inset) {
- inset->InsetUnlock();
- the_locking_inset = 0;
- text->FinishUndo();
- return 0;
- }
- return bufferlist.unlockInset(inset);
-}
-
-
-void BufferView::lockedInsetStoreUndo(Undo::undo_kind kind)
-{
- if (!the_locking_inset)
- return; // shouldn't happen
- if (kind == Undo::EDIT) // in this case insets would not be stored!
- kind = Undo::FINISH;
- text->SetUndo(kind,
- text->cursor.par->
- ParFromPos(text->cursor.pos)->previous,
- text->cursor.par->
- ParFromPos(text->cursor.pos)->next);
-}
-
-
-void PutInsetIntoInsetUpdateList(Inset * inset)
-{
- Assert(inset);
- InsetUpdateStruct * tmp = new InsetUpdateStruct();
- tmp->inset = inset;
- tmp->next = InsetUpdateList;
- InsetUpdateList = tmp;
-}
-
-
-void UpdateInsetUpdateList()
-{
- InsetUpdateStruct * tmp = InsetUpdateList;
- while (tmp) {
- UpdateInset(tmp->inset, false); // "false" because no document change
- tmp = tmp->next;
- }
-
- // delete the update list
- while (InsetUpdateList) {
- tmp = InsetUpdateList;
- InsetUpdateList = InsetUpdateList->next;
- delete tmp;
- }
- InsetUpdateList = 0;
-}
-
-
-#ifdef WITH_WARNINGS
-#warning UGLY!!
-#endif
-// 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
-// a newline in the string and the inserts 'depth'-spaces so that the
-// code is indented in the right way!!!
-void addNewlineAndDepth(string & file, int const depth)
-{
- file += '\n';
- file.append(depth, ' ');
-}