#include <fstream>
#include <algorithm>
+#include <iostream>
-#include "LString.h"
-#include "support/lstrings.h"
-#include "lyx_main.h"
+//#include "LString.h"
#include FORMS_H_LOCATION
#include "lyx.h"
#include "layout_forms.h"
#include "bullet_forms.h"
-#include "print_form.h"
#include "form1.h"
-#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"
#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"
-#include "support/filetools.h"
-#include "support/path.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
#include "LyXView.h"
+#include "BufferView.h"
#include "lastfiles.h"
+#include "bufferview_funcs.h"
#include "support/FileInfo.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 "language.h"
+#include "CutAndPaste.h"
+#include "exporter.h"
using std::ifstream;
using std::copy;
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 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...
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;
int RunLinuxDoc(BufferView *, int, string const &);
int RunDocBook(int, string const &);
-void MenuWrite(Buffer * buf);
-void MenuWriteAs(Buffer * buffer);
+bool MenuWrite(Buffer * buf);
+bool MenuWriteAs(Buffer * buffer);
void MenuReload(Buffer * buf);
void MenuLayoutSave();
void ShowMessage(Buffer * buf,
string const & msg1,
- string const & msg2 = string(),
- string const & msg3 = string(), int delay = 6)
+ string const & msg2,
+ string const & msg3, int delay)
{
if (lyxrc.use_gui) {
buf->getUser()->owner()->getMiniBuffer()->Set(msg1, msg2,
}
}
-// 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;
- current_view->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)
-{
- static Cursor cursor;
- static bool cursor_undefined = true;
- if (cursor_undefined){
- cursor = XCreateFontCursor(fl_display, XC_xterm);
- XFlush(fl_display);
- cursor_undefined = false;
- }
- 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);
-
- // What to do about this? (Lgb)
- if (current_view->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;
-}
-
//
// Menu callbacks
//
// should be moved to lyxfunc.C
-void MenuWrite(Buffer * buffer)
+bool MenuWrite(Buffer * buffer)
{
XFlush(fl_display);
if (!buffer->save()) {
if (AskQuestion(_("Save failed. Rename and try again?"),
MakeDisplayPath(s, 50),
_("(If not, document is not saved.)"))) {
- MenuWriteAs(buffer);
+ return MenuWriteAs(buffer);
}
+ return false;
} else {
lastfiles->newFile(buffer->fileName());
}
+ return true;
}
// should be moved to BufferView.C
// Half of this func should be in LyXView, the rest in BufferView.
-void MenuWriteAs(Buffer * buffer)
+bool MenuWriteAs(Buffer * buffer)
{
// Why do we require BufferView::text to be able to write a
// document? I see no point in that. (Lgb)
string oldname = fname;
LyXFileDlg fileDlg;
- ProhibitInput();
+ ProhibitInput(current_view);
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 (buffer->isUnnamed()) {
+ fname = fileDlg.Select(_("Enter Filename to Save Document as"),
+ "",
+ "*.lyx",
+ "");
+ } else {
+ fname = fileDlg.Select(_("Enter Filename to Save Document as"),
+ OnlyPath(fname),
+ "*.lyx",
+ OnlyFilename(fname));
+ }
+ AllowInput(current_view);
if (fname.empty()) {
- return;
+ return false;
}
// Make sure the absolute filename ends with appropriate suffix
string s = MakeAbsPath(fname);
if (!AskQuestion(_("Same name as document already has:"),
MakeDisplayPath(s, 50),
_("Save anyway?")))
- return;
+ return false;
// Falls through to name change and save
}
// No, but do we have another file with this name open?
ShowMessage(buffer, _("Document renamed to '"),
MakeDisplayPath(s), _("', but not saved..."));
}
- return;
+ return false;
} // Check whether the file exists
else {
FileInfo myfile(s);
if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
MakeDisplayPath(s, 50),
_("Replace file?")))
- return;
+ return false;
}
// Ok, change the name of the buffer
buffer->fileName(s);
buffer->markDirty();
+ bool unnamed = buffer->isUnnamed();
+ buffer->setUnnamed(false);
// And save
// Small bug: If the save fails, we have irreversible changed the name
// of the document.
- MenuWrite(buffer);
-}
-
+ // Hope this is fixed this way! (Jug)
+ if (!MenuWrite(buffer)) {
+ buffer->fileName(oldname);
+ buffer->setUnnamed(unnamed);
+ ShowMessage(buffer, _("Document could not be saved!"),
+ _("Holding the old name."), MakeDisplayPath(oldname));
+ return false;
+ }
+ // now remove the oldname autosave file if existant!
+ removeAutosaveFile(oldname);
+ return true;
+}
+#ifndef NEW_EXPORT
int MenuRunLaTeX(Buffer * buffer)
{
int ret = 0;
}
return ret;
}
-
+#endif
int MenuBuildProg(Buffer * buffer)
{
return ret;
}
-
+#ifndef NEW_EXPORT
int MakeLaTeXOutput(Buffer * buffer)
{
// Who cares?
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;
}
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)) {
// 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
+ // CHECK What should we do here?
ShowMessage(buffer, _("Executing command:"), cmd);
result = one.startscript(Systemcalls::System, cmd);
} else {
//if (!bv->text)
// return false;
- ProhibitInput();
+ ProhibitInput(current_view);
// Generate dvi file
if (MakeLaTeXOutput(buffer) > 0) {
- AllowInput();
+ 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;
}
Path p(path);
bool ret = RunScript(buffer, wait, command);
- AllowInput();
+ AllowInput(current_view);
return ret;
}
}
// 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)){
}
Path p(path);
bool ret = RunScript(buffer, false, lyxrc.view_ps_command, ps);
- AllowInput();
+ AllowInput(current_view);
return ret;
}
-
+#endif
void MenuFax(Buffer * buffer)
{
//if (!bv->text)
// return;
+#ifdef NEW_EXPORT
+ // Generate postscript file
+ if (!Exporter::Export(buffer, "ps", true))
+ return;
+
+ // Send fax
+ string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps"));
+#else
// Generate postscript file
if (!CreatePostscript(buffer, true)) {
return;
}
// Send fax
- string ps = ChangeExtension (buffer->fileName(), ".ps_tmp", true);
+ string ps = OnlyFilename(ChangeExtension (buffer->fileName(),
+ ".ps_tmp"));
+#endif
string path = OnlyPath (buffer->fileName());
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
+#ifndef NEW_EXPORT
// Returns false if we fail
bool PreviewDVI(Buffer * buffer)
{
return true;
}
+
void MenuMakeLaTeX(Buffer * buffer)
{
// Why care about this?
buffer->makeLaTeXFile(s, string(), true);
ShowMessage(buffer, _("Nice LaTeX file saved as"),
MakeDisplayPath(s));
- buffer->markDviDirty();
}
}
}
// Get LinuxDoc-Filename
- string s = ChangeExtension(buffer->fileName(),
- ".sgml", false);
+ string s = ChangeExtension(buffer->fileName(), ".sgml");
if (!AskOverwrite(buffer, s))
return;
ShowMessage(buffer, _("Building LinuxDoc SGML file `"),
MakeDisplayPath(s),"'...");
- buffer->makeLinuxDocFile(s, 65);
+ buffer->makeLinuxDocFile(s, true);
buffer->redraw();
ShowMessage(buffer, _("LinuxDoc SGML file save as"),
MakeDisplayPath(s));
}
// Get DocBook-Filename
- string s = ChangeExtension(buffer->fileName(),
- ".sgml", false);
+ string s = ChangeExtension(buffer->fileName(), ".sgml");
if (!AskOverwrite(buffer, s))
return;
ShowMessage(buffer, _("Building DocBook SGML file `"),
MakeDisplayPath(s), "'...");
- buffer->makeDocBookFile(s, 65);
+ buffer->makeDocBookFile(s, true);
buffer->redraw();
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");
if (!AskOverwrite(buffer, 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;
tmp = subst(tmp, "$$FName", infile);
}
+
void MenuMakeHTML_LinuxDoc(Buffer * buffer)
{
// First, create LinuxDoc file
// And now, run the converter
string file = buffer->fileName();
- string result = ChangeExtension(file, ".html", false);
- string infile = ChangeExtension(file, ".sgml", false);
+ 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);
// And now, run the converter
string file = buffer->fileName();
- string result = ChangeExtension(file, ".html", false);
- string infile = ChangeExtension(file, ".sgml", false);
+ 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);
}
+
void MenuExport(Buffer * buffer, string const & extyp)
{
// latex
// 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 :-(
}
// HTML
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);
+ if (buffer->isLinuxDoc())
+ MenuMakeHTML_LinuxDoc(buffer);
+ else if (buffer->isDocBook())
+ MenuMakeHTML_DocBook(buffer);
+ else
+ MenuMakeHTML(buffer);
}
else {
ShowMessage(buffer, _("Unknown export type: ") + extyp);
}
}
+#endif
void QuitLyX()
-void AutoSave()
+void AutoSave(BufferView * bv)
// should probably be moved into BufferList (Lgb)
// Perfect target for a thread...
{
- if (!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();
}
if (!bv->available()) return;
if (fname.empty()) {
- ProhibitInput();
+ ProhibitInput(bv);
fname = fileDlg.Select(_("File to Insert"),
bv->owner()->buffer()->filepath,
"*");
- AllowInput();
+ AllowInput(bv);
if (fname.empty()) return;
}
ifs.unsetf(ios::skipws);
istream_iterator<char> ii(ifs);
istream_iterator<char> end;
+#if !defined(USE_INCLUDED_STRING) && !defined(STD_STRING_IS_GOOD)
+ // We use this until the compilers get better...
+ vector<char> tmp;
+ copy(ii, end, back_inserter(tmp));
+ string tmpstr(tmp.begin(), tmp.end());
+#else
+ // This is what we want to use and what we will use once the
+ // compilers get good enough.
//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));
+#endif
// insert the string
current_view->hideCursor();
// clear the selection
bv->beforeChange();
if (!asParagraph)
- bv->text->InsertStringA(tmpstr);
+ bv->text->InsertStringA(bv, tmpstr);
else
- bv->text->InsertStringB(tmpstr);
- bv->update(1);
-}
-
-
-void MenuShowTableOfContents()
-{
- static int ow = -1, oh;
-
- TocUpdateCB(0, 0);
- 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"));
- if (ow < 0) {
- ow = fd_form_toc->form_toc->w;
- oh = fd_form_toc->form_toc->h;
- }
- fl_set_form_minsize(fd_form_toc->form_toc, ow, oh);
- }
+ 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:"));
}
}
if (!label.empty()) {
- InsetLabel * new_inset = new InsetLabel;
- new_inset->setContents(label);
- current_view->insertInset(new_inset);
- }
- AllowInput();
-}
-
-
-void MenuInsertRef()
-{
- static int ow = -1, oh;
-
- RefUpdateCB(0, 0);
- 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"));
- if (ow < 0) {
- ow = fd_form_ref->form_ref->w;
- oh = fd_form_ref->form_ref->h;
- }
- fl_set_form_minsize(fd_form_ref->form_ref, ow, oh);
+ InsetCommandParams p( "label", label );
+ InsetLabel * inset = new InsetLabel( p );
+ current_view->insertInset( inset );
}
-}
-
-
-void MenuPasteSelection(char at)
-{
- if (!current_view->available())
- 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
-void Foot(BufferView * bv)
-{
- if (!bv->available())
- return;
-
- bv->owner()->getMiniBuffer()
- ->Set(_("Inserting Footnote..."));
- bv->hideCursor();
- bv->update(-2);
- bv->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
- bv->update(1);
+ AllowInput(current_view);
}
tmp.c_str());
}
-
+#ifndef NEW_EXPORT
/*
* SGML Linuxdoc support:
* (flag == 0) make TeX output
int errorcode = 0;
/* 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)) {
path = bv->buffer()->tmppath;
if (!bv->available())
return 0;
- bv->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>(bv->buffer()->params.papersize);
+ 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";
default: /* nothing to be done yet ;-) */ break;
}
- ProhibitInput();
+ ProhibitInput(bv);
Systemcalls one;
switch (flag) {
s2 = lyxrc.linuxdoc_to_latex_command + ' ' + add_flags + " -o dvi " + ' ' + name;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
- } else
- bv->buffer()->markDviClean();
+ }
break;
default: /* unknown output */
break;
}
- AllowInput();
+ AllowInput(bv);
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)) {
path = current_view->buffer()->tmppath;
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')
// 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;
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;
}
-
+#endif
void MenuLayoutCharacter()
{
}
Buffer * buf = current_view->buffer();
+ LyXText * text = 0;
+ if (current_view->the_locking_inset)
+ text = current_view->the_locking_inset->getLyXText(current_view);
+ if (!text)
+ text = current_view->text;
fl_set_input(fd_form_paragraph->input_labelwidth,
- current_view->text->cursor.par->GetLabelWidthString().c_str());
+ 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 = text->cursor.par()->GetAlign();
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist.Style(buf->params.textclass,
- current_view->text->cursor.par->GetLayout()).align;
+ text->cursor.par()->GetLayout()).align;
switch (align) {
case LYX_ALIGN_RIGHT:
fl_set_button(fd_form_paragraph->radio_align_block, 1);
break;
}
-
+
+#ifndef NEW_INSETS
+ fl_set_button(fd_form_paragraph->check_lines_top,
+ text->cursor.par()->FirstPhysicalPar()->line_top);
+
+ fl_set_button(fd_form_paragraph->check_lines_bottom,
+ text->cursor.par()->FirstPhysicalPar()->line_bottom);
+
+ fl_set_button(fd_form_paragraph->check_pagebreaks_top,
+ text->cursor.par()->FirstPhysicalPar()->pagebreak_top);
+
+ fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
+ text->cursor.par()->FirstPhysicalPar()->pagebreak_bottom);
+ fl_set_button(fd_form_paragraph->check_noindent,
+ text->cursor.par()->FirstPhysicalPar()->noindent);
+#else
fl_set_button(fd_form_paragraph->check_lines_top,
- current_view->text->cursor.par->FirstPhysicalPar()->line_top);
+ text->cursor.par()->line_top);
fl_set_button(fd_form_paragraph->check_lines_bottom,
- current_view->text->cursor.par->FirstPhysicalPar()->line_bottom);
+ text->cursor.par()->line_bottom);
fl_set_button(fd_form_paragraph->check_pagebreaks_top,
- current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_top);
+ text->cursor.par()->pagebreak_top);
fl_set_button(fd_form_paragraph->check_pagebreaks_bottom,
- current_view->text->cursor.par->FirstPhysicalPar()->pagebreak_bottom);
+ text->cursor.par()->pagebreak_bottom);
fl_set_button(fd_form_paragraph->check_noindent,
- current_view->text->cursor.par->FirstPhysicalPar()->noindent);
+ text->cursor.par()->noindent);
+#endif
fl_set_input (fd_form_paragraph->input_space_above, "");
-
- switch (current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.kind()) {
+
+#ifndef NEW_INSETS
+ switch (text->cursor.par()->FirstPhysicalPar()->added_space_top.kind()) {
+#else
+ switch (text->cursor.par()->added_space_top.kind()) {
+#endif
+
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_above, 1);
break;
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_choice (fd_form_paragraph->choice_space_above, 7);
+#ifndef NEW_INSETS
fl_set_input (fd_form_paragraph->input_space_above,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.length().asString().c_str());
+ text->cursor.par()->FirstPhysicalPar()->added_space_top.length().asString().c_str());
+#else
+ fl_set_input (fd_form_paragraph->input_space_above,
+ text->cursor.par()->added_space_top.length().asString().c_str());
+#endif
break;
}
+#ifndef NEW_INSETS
+ fl_set_button (fd_form_paragraph->check_space_above,
+ text->cursor.par()->FirstPhysicalPar()->added_space_top.keep());
+ fl_set_input (fd_form_paragraph->input_space_below, "");
+ switch (text->cursor.par()->FirstPhysicalPar()->added_space_bottom.kind()) {
+#else
fl_set_button (fd_form_paragraph->check_space_above,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_top.keep());
+ text->cursor.par()->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 (text->cursor.par()->added_space_bottom.kind()) {
+#endif
case VSpace::NONE:
fl_set_choice (fd_form_paragraph->choice_space_below,
1);
break;
case VSpace::LENGTH:
fl_set_choice (fd_form_paragraph->choice_space_below,
- 7);
+ 7);
+#ifndef NEW_INSETS
fl_set_input (fd_form_paragraph->input_space_below,
- current_view->text->cursor.par->FirstPhysicalPar()->added_space_bottom.length().asString().c_str());
+ 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());
+ text->cursor.par()->FirstPhysicalPar()->added_space_bottom.keep());
fl_set_button(fd_form_paragraph->check_noindent,
- current_view->text->cursor.par->FirstPhysicalPar()->noindent);
+ text->cursor.par()->FirstPhysicalPar()->noindent);
+#else
+ fl_set_input (fd_form_paragraph->input_space_below,
+ text->cursor.par()->added_space_bottom.length().asString().c_str());
+ break;
+ }
+ fl_set_button (fd_form_paragraph->check_space_below,
+ text->cursor.par()->added_space_bottom.keep());
+ fl_set_button(fd_form_paragraph->check_noindent,
+ text->cursor.par()->noindent);
+#endif
if (current_view->buffer()->isReadonly()) {
DisableParagraphLayout();
} else {
}
}
-
+#ifdef USE_OLD_DOCUMENT_LAYOUT
inline
void DeactivateDocumentButtons ()
{
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
//char sval[20];
//sprintf(sval, "%g", params->spacing.getValue());
#ifdef HAVE_SSTREAM
- ostringstream sval;
+ std::ostringstream sval;
sval << params->spacing.getValue(); // setw?
fl_set_input(fd_form_document->input_spacing,
sval.str().c_str());
}
}
}
+#endif
bool UpdateLayoutPreamble()
}
-/* -------> These CB's use ToggleFree() as the (one and only?) font-changer.
- They also show the current font state. */
-
-static
-void ToggleAndShow(BufferView *, LyXFont const &);
-
-
-void FontSize(string const & size)
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setGUISize(size);
- ToggleAndShow(current_view, font);
-}
-
-
-void Emph()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setEmph(LyXFont::TOGGLE);
- ToggleAndShow(current_view, font);
-}
-
-
-void Noun()
+// 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)
{
LyXFont font(LyXFont::ALL_IGNORE);
- font.setNoun(LyXFont::TOGGLE);
- ToggleAndShow(current_view, font);
-}
+ int pos = fl_get_choice(fd_form_character->choice_family);
+ 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;
+ }
-void Bold()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setSeries(LyXFont::BOLD_SERIES);
- ToggleAndShow(current_view, font);
-}
-
+ 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;
+ }
-void Underline()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setUnderbar(LyXFont::TOGGLE);
- ToggleAndShow(current_view, font);
-}
+ 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;
+ }
-void Code()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::TYPEWRITER_FAMILY); // no good
- ToggleAndShow(current_view, font);
-}
-
-
-void Sans()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::SANS_FAMILY);
- ToggleAndShow(current_view, font);
-}
-
-
-void Roman()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setFamily(LyXFont::ROMAN_FAMILY);
- ToggleAndShow(current_view, font);
-}
-
-
-void Tex()
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- font.setLatex (LyXFont::TOGGLE);
- ToggleAndShow(current_view, font);
-}
-
-void LangCB(string const & l)
-{
- LyXFont font(LyXFont::ALL_IGNORE);
- Languages::iterator lit = languages.find(l);
- if (lit != languages.end()) {
- font.setLanguage(&(*lit).second);
- ToggleAndShow(current_view, font);
- } else
- WriteAlert(_("Error! unknown language"),l);
-}
-
-
-void StyleReset()
-{
- LyXFont font(LyXFont::ALL_INHERIT);
- ToggleAndShow(current_view, 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(BufferView * bv, LyXFont const & font)
-{
- if (bv->available()) {
- bv->hideCursor();
- bv->update(-2);
- if (bv->the_locking_inset)
- bv->the_locking_inset->SetFont(bv, font, toggleall);
- else
- bv->text->ToggleFree(font, toggleall);
- bv->update(1);
- }
-}
-
-
-// candidate for move to BufferView
-void Margin(BufferView * bv)
-{
- if (bv->available()) {
- bv->owner()->getMiniBuffer()->Set(_("Inserting margin note..."));
- bv->hideCursor();
- bv->update(-2);
- bv->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
- bv->update(1);
- }
-}
-
-
-void Figure()
-{
- if (fd_form_figure->form_figure->visible) {
- fl_raise_form(fd_form_figure->form_figure);
- } else {
- fl_show_form(fd_form_figure->form_figure,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Insert Figure"));
- }
-}
-
-
-void Table()
-{
- if (fd_form_table->form_table->visible) {
- fl_raise_form(fd_form_table->form_table);
- } else {
- fl_show_form(fd_form_table->form_table,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("Insert Table"));
- }
-}
-
-
-// candidate for move to BufferView
-void Melt(BufferView * bv)
-{
- if (!bv->available()) return;
-
- bv->owner()->getMiniBuffer()->Set(_("Melt"));
- bv->hideCursor();
- bv->beforeChange();
- bv->update(-2);
- bv->text->MeltFootnoteEnvironment();
- bv->update(1);
-}
-
-
-// candidate for move to BufferView
-// Change environment depth.
-// if decInc >= 0, increment depth
-// if decInc < 0, decrement depth
-void changeDepth(BufferView * bv, int decInc)
-{
- if (!bv->available()) return;
-
- bv->hideCursor();
- 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)"));
-}
-
-
-// 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);
-
- int pos = fl_get_choice(fd_form_character->choice_family);
- 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_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);
switch(pos) {
case 11: font.setColor(LColor::inherit); break;
}
- return font;
-}
-
+ 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()]);
-void Free()
-{
- ToggleAndShow(current_view, UserFreeFont());
+ return font;
}
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
noindent = fl_get_button(fd_form_paragraph->check_noindent);
- current_view->text->SetParagraph(line_top,
- line_bottom,
- pagebreak_top,
- pagebreak_bottom,
- space_top,
- space_bottom,
- align,
- labelwidthstring,
- noindent);
- current_view->update(1);
+ LyXText * text = 0;
+ if (current_view->the_locking_inset)
+ text = current_view->the_locking_inset->getLyXText(current_view);
+ if (!text)
+ text = current_view->text;
+ text->SetParagraph(current_view,
+ line_top,
+ line_bottom,
+ pagebreak_top,
+ pagebreak_bottom,
+ space_top,
+ space_bottom,
+ align,
+ labelwidthstring,
+ noindent);
+ 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(current_view, UserFreeFont());
+ ToggleAndShow(current_view, UserFreeFont(current_view->buffer()->params));
+ current_view->setState();
toggleall = true;
}
}
+#ifdef USE_OLD_DOCUMENT_LAYOUT
/* callbacks for form form_document */
-
void UpdateDocumentButtons(BufferParams const & params)
{
fl_set_choice(fd_form_document->choice_pagestyle, 1);
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);
}
bool redo = false;
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())
- params->language_info = &(*lit).second;
+ new_language = &(*lit).second;
else
- params->language_info = default_language;
+ 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;
- if (lyxrc.rtl_support) {
- current_view->text->SetCursor(current_view->text->cursor.par,
- current_view->text->cursor.pos);
- current_view->setState();
- }
+
+ 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 (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);
-
}
// bullet callbacks etc. in bullet_panel.C -- ARRae
}
-
/* callbacks for form form_quotes */
extern "C" void QuotesApplyCB(FL_OBJECT *, long)
QuotesApplyCB(ob, data);
QuotesCancelCB(ob, data);
}
-
+#else
+// this is needed for now!
+extern "C" void ChoiceClassCB(FL_OBJECT *, long) {}
+extern "C" void DocumentDefskipCB(FL_OBJECT *, long) {}
+extern "C" void DocumentSpacingCB(FL_OBJECT *, long) {}
+extern "C" void DocumentApplyCB(FL_OBJECT *, long) {}
+extern "C" void DocumentCancelCB(FL_OBJECT *, long) {}
+extern "C" void DocumentOKCB(FL_OBJECT *, long) {}
+extern "C" void DocumentBulletsCB(FL_OBJECT *, long) {}
+extern "C" void QuotesApplyCB(FL_OBJECT *, long) {}
+extern "C" void QuotesCancelCB(FL_OBJECT *, long) {}
+extern "C" void QuotesOKCB(FL_OBJECT *, long) {}
+#endif
/* callbacks for form form_preamble */
/* callbacks for form form_table */
-extern "C" void TableApplyCB(FL_OBJECT *, long)
+extern "C"
+void TableApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
-
+
+#ifndef NEW_TABULAR
// 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."));
return;
}
-
+#endif
current_view->owner()->getMiniBuffer()->Set(_("Inserting table..."));
int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5);
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
+#ifndef NEW_INSETS
+ if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
+#endif
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);
+#ifndef NEW_INSETS
} else {
current_view->text
- ->SetParagraph(0, 0,
+ ->SetParagraph(current_view, 0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
string(),
0);
}
-
- current_view->text->cursor.par->table =
+#endif
+#ifndef NEW_TABULAR
+ current_view->text->cursor.par()->table =
new LyXTable(xsize, ysize);
-
+#endif
Language const * lang =
- current_view->text->cursor.par->getParLanguage();
- LyXFont font(LyXFont::ALL_INHERIT,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);
- current_view->text->cursor.par->SetFont(0, font);
+ current_view->text->cursor.par()
+ ->InsertChar(0, LyXParagraph::META_NEWLINE, font);
}
- current_view->text->RedoParagraph();
+ 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();
}
-extern "C" void TableCancelCB(FL_OBJECT *, long)
+extern "C"
+void TableCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_table->form_table);
}
-extern "C" void TableOKCB(FL_OBJECT * ob, long data)
+extern "C"
+void TableOKCB(FL_OBJECT * ob, long data)
{
TableApplyCB(ob, data);
TableCancelCB(ob, data);
}
-/* callbacks for form form_print */
-
-extern "C" void PrintCancelCB(FL_OBJECT *, long)
-{
- 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)
+void Figure()
{
- 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 (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 (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 (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"));
+ }
}
/* callbacks for form form_figure */
-extern "C" void FigureApplyCB(FL_OBJECT *, long)
+extern "C"
+void FigureApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
current_view->owner()->getMiniBuffer()->Set(_("Inserting figure..."));
if (fl_get_button(fd_form_figure->radio_inline)
- || current_view->text->cursor.par->table) {
+#ifndef NEW_TABULAR
+ || current_view->text->cursor.par()->table
+#endif
+ ) {
InsetFig * new_inset = new InsetFig(100, 20, buffer);
current_view->insertInset(new_inset);
current_view->owner()->getMiniBuffer()->Set(_("Figure inserted"));
}
current_view->hideCursor();
- current_view->update(-2);
+ 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);
-
- if (current_view->text->cursor.par->footnoteflag ==
+ current_view->text->SetLayout(current_view, 0);
+
+#ifndef NEW_INSETS
+ if (current_view->text->cursor.par()->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
+#endif
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);
+#ifndef NEW_INSETS
} else {
- current_view->text->SetParagraph(0, 0,
+ current_view->text->SetParagraph(current_view, 0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
string(),
0);
}
+#endif
- 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(current_view, 0, 0, 0);
- current_view->update(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));
- fontloader.update();
-
- // All buffers will need resize
- bufferlist.resize();
-
- current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
-}
-
-
-extern "C" void ScreenCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_screen->form_screen);
-}
-
-
-extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
-{
- ScreenCancelCB(ob, data);
- ScreenApplyCB(ob, data);
-}
-
-
-void LaTeXOptions(BufferView * bv)
-{
- if (!bv->available())
- return;
-
- fl_set_button(fd_latex_options->accents,
- int(bv->buffer()->params.allowAccents));
-
- if (fd_latex_options->LaTeXOptions->visible) {
- fl_raise_form(fd_latex_options->LaTeXOptions);
- } else {
- fl_show_form(fd_latex_options->LaTeXOptions,
- FL_PLACE_MOUSE, FL_FULLBORDER,
- _("LaTeX Options"));
- }
-}
-
-
// This function runs "configure" and then rereads lyx.defaults to
// reconfigure the automatic settings.
void Reconfigure(BufferView * bv)
_("You need to restart LyX to make use of any"),
_("updated document class specifications."));
}
-
-
-//
-// Table of Contents
-//
-
-struct TocList {
- int counter[6];
- bool appendix;
- TocList * next;
-};
-
-
-static TocList * toclist = 0;
-
-
-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);
- current_view->text->sel_cursor =
- current_view->text->cursor;
- current_view->update(0);
- }
- else {
- WriteAlert(_("Error"),
- _("Couldn't find this label"),
- _("in current document."));
- }
-
-}
-
-
-extern "C" void TocCancelCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_toc->form_toc);
-}
-
-
-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()) {
- 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;
- }
- 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 */
-extern "C" void RefSelectCB(FL_OBJECT *, long data)
-{
- if (!current_view->available())
- return;
-
- string s =
- fl_get_browser_line(fd_form_ref->browser_ref,
- fl_get_browser(fd_form_ref->browser_ref));
- string u = frontStrip(strip(fl_get_input(fd_form_ref->ref_name)));
-
- if (s.empty())
- return;
-
- if (data == 2) {
- current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
- return;
- }
-
- string t;
- if (data == 0)
- t += "\\ref";
- else
- t += "\\pageref";
-
- if(current_view->buffer()->isSGML())
- t += "[" + u + "]" + "{" + s + "}";
- else
- t += "{" + s + "}";
-
- Inset * new_inset =
- new InsetRef(t, current_view->buffer());
- current_view->insertInset(new_inset);
-}
-
-
-extern "C" void RefUpdateCB(FL_OBJECT *, long)
-{
- 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
- char const * const btmp = fl_get_browser_line(brow,
- fl_get_browser(brow));
- string currentstr = btmp ? btmp : "";
-
- fl_clear_browser(brow);
-
- string refs = current_view->buffer()->getReferenceList('\n');
- int topline = 1;
-
- fl_addto_browser_chars(brow, refs.c_str());
- int total_lines = fl_get_browser_maxline(brow);
- 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);
-
- 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);
- }
- 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 (!current_view->buffer()->isSGML()) {
- 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);
- }
-}
-
-
-extern "C" void RefHideCB(FL_OBJECT *, long)
-{
- fl_hide_form(fd_form_ref->form_ref);
-}