/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich,
* Copyright 1995-1999 The LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
#include <cstdlib>
#include "LString.h"
+#include "support/lstrings.h"
#include "lyx_main.h"
#include FORMS_H_LOCATION
#include "lyx.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 "combox.h"
#include "bufferlist.h"
#include "support/filetools.h"
-#include "pathstack.h"
+#include "support/path.h"
#include "filedlg.h"
#include "lyx_gui_misc.h"
#include "LyXView.h" // only because of form_main
#include "lyxrc.h"
#include "lyxtext.h"
#include "gettext.h"
+#include "layout.h"
extern MiniBuffer *minibuffer;
extern Combox *combo_language;
// Shouldn't this question be directed to the buffer?
// Indeed it should. Asger.
{
- return current_view->currentBuffer()->params.textclass;
+ return current_view->buffer()->params.textclass;
}
void BeforeChange()
{
current_view->getScreen()->ToggleSelection();
- current_view->currentBuffer()->text->ClearSelection();
+ current_view->buffer()->text->ClearSelection();
FreeUpdateTimer();
}
current_view->getScreen()->SmallUpdate();
if (current_view->getScreen()->TopCursorVisible()
!= current_view->getScreen()->first){
- current_view->currentBuffer()->update(f);
+ current_view->buffer()->update(f);
return;
}
current_view->fitCursor();
current_view->updateScrollbar();
- if (!current_view->currentBuffer()->text->selection)
- current_view->currentBuffer()->text->sel_cursor =
- current_view->currentBuffer()->text->cursor;
+ if (!current_view->buffer()->text->selection)
+ current_view->buffer()->text->sel_cursor =
+ current_view->buffer()->text->cursor;
- if (f==1 || f==-1) {
- if (current_view->currentBuffer()->isLyxClean()) {
- current_view->currentBuffer()->markDirty();
+ if (f == 1 || f == -1) {
+ if (current_view->buffer()->isLyxClean()) {
+ current_view->buffer()->markDirty();
minibuffer->setTimer(4);
}
else {
- current_view->currentBuffer()->markDirty();
+ current_view->buffer()->markDirty();
}
}
}
string fname = buf->getFileName();
string s = MakeAbsPath(fname);
if (AskQuestion(_("Save failed. Rename and try again?"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("(If not, document is not saved.)"))) {
MenuWriteAs(buf);
}
}
// Make sure the absolute filename ends with appropriate suffix
- string s= MakeAbsPath(fname);
+ string s = MakeAbsPath(fname);
if (!IsLyXFilename(s))
s += ".lyx";
// Same name as we have already?
if (s == oldname) {
if (!AskQuestion(_("Same name as document already has:"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Save anyway?")))
return;
// Falls through to name change and save
// No, but do we have another file with this name open?
else if (bufferlist.exists(s)) {
if (AskQuestion(_("Another document with same name open!"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Replace with current document?")))
{
bufferlist.close(bufferlist.getBuffer(s));
else {
FileInfo myfile(s);
if (myfile.isOK() && !AskQuestion(_("Document already exists:"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Replace file?")))
return;
}
MenuWrite(buffer);
}
-#if 0
-extern bool gsworking();
-#endif
int MenuRunLaTeX(Buffer *buffer)
{
int ret = 0;
-#if 0
- if (gsworking()) {
- WriteAlert(_("Sorry, can't do this while pictures are being rendered."),
- _("Please wait a few seconds for this to finish and try again."),
- _("(or kill runaway gs processes by hand and try again.)"));
- return 1;
- }
- extern pid_t isp_pid; // from spellchecker.C
- if(isp_pid != -1)
- {
- WriteAlert(_("Can't do this while the spellchecker is running."),
- _("Stop the spellchecker first."));
- return 1;
- }
-#endif
-
if (buffer->isLinuxDoc())
ret = RunLinuxDoc(1, buffer->getFileName());
else if (buffer->isLiterate())
s = _("One error detected");
t = _("You should try to fix it.");
} else {
- s += ret;
+ s += tostr(ret);
s += _(" errors detected.");
t = _("You should try to fix them.");
}
s = _("One error detected");
t = _("You should try to fix it.");
} else {
- s += ret;
+ s += tostr(ret);
s += _(" errors detected.");
t = _("You should try to fix them.");
}
s = _("One warning found.");
t = _("Use 'Edit->Go to Error' to find it.");
} else {
- s += ret;
+ s += tostr(ret);
s += _(" warnings found.");
t = _("Use 'Edit->Go to Error' to find them.");
}
WriteAlert(_("Chktex run successfully"), s, t);
} else {
- WriteAlert(_("Error!"),_("It seems chktex does not work."));
+ WriteAlert(_("Error!"), _("It seems chktex does not work."));
}
return ret;
}
path = buffer->tmppath;
}
if (!buffer->isDviClean()) {
- PathPush(path);
+ Path p(path);
ret = MenuRunLaTeX(buffer);
- PathPop();
}
return ret;
}
/* wait == true means wait for termination */
// The bool should be placed last on the argument line. (Lgb)
// Returns false if we fail.
-bool RunScript(Buffer *buffer, bool wait,
+bool RunScript(Buffer * buffer, bool wait,
string const & command, string const & orgname = string(),
- bool need_shell=true)
+ bool need_shell = true)
{
string path;
string cmd;
- string name= orgname;
+ string name = orgname;
int result = 0;
if (MakeDVIOutput(buffer) > 0)
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
cmd = command + ' ' + SpaceLess(name);
Systemcalls one;
if (sh.empty())
sh = "cmd.exe";
}
- sh = lowercase(sh);
- if (sh.contains("cmd.exe") || sh.contains("4os2.exe"))
+ sh = lowercase(sh);
+ if (contains(sh, "cmd.exe")
+ || contains(sh, "4os2.exe"))
cmd = "start /min/n " + cmd;
else
cmd += " &";
result = one.startscript(wait ? Systemcalls::Wait
: Systemcalls::DontWait, cmd);
}
- PathPop();
- return (result==0);
+ return (result == 0);
}
// Returns false if we fail
-bool MenuRunDvips(Buffer *buffer, bool wait=false)
+bool MenuRunDvips(Buffer *buffer, bool wait = false)
{
if (!buffer->text)
return false;
string paper;
char real_papersize = buffer->params.papersize;
- if (real_papersize == PAPER_DEFAULT)
+ if (real_papersize == BufferParams::PAPER_DEFAULT)
real_papersize = lyxrc->default_papersize;
switch (real_papersize) {
- case PAPER_USLETTER:
+ case BufferParams::PAPER_USLETTER:
paper = "letter";
break;
- case PAPER_A3PAPER:
+ case BufferParams::PAPER_A3PAPER:
paper = "a3";
break;
- case PAPER_A4PAPER:
+ case BufferParams::PAPER_A4PAPER:
paper = "a4";
break;
- case PAPER_A5PAPER:
+ case BufferParams::PAPER_A5PAPER:
paper = "a5";
break;
- case PAPER_B5PAPER:
+ case BufferParams::PAPER_B5PAPER:
paper = "b5";
break;
- case PAPER_EXECUTIVEPAPER:
+ case BufferParams::PAPER_EXECUTIVEPAPER:
paper = "foolscap";
break;
- case PAPER_LEGALPAPER:
+ case BufferParams::PAPER_LEGALPAPER:
paper = "legal";
break;
default: /* If nothing else fits, keep an empty value... */
string command = "dvips " + lyxrc->print_to_file + ' ';
command += SpaceLess(ps);
if (buffer->params.use_geometry
- && buffer->params.papersize2 == VM_PAPER_CUSTOM
+ && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
&& !lyxrc->print_paper_dimension_flag.empty()
&& !buffer->params.paperwidth.empty()
&& !buffer->params.paperheight.empty()) {
command += buffer->params.paperwidth + ',';
command += buffer->params.paperheight;
} else if (!paper.empty()
- && (real_papersize != PAPER_USLETTER ||
- buffer->params.orientation == ORIENTATION_PORTRAIT)) {
+ && (real_papersize != BufferParams::PAPER_USLETTER ||
+ buffer->params.orientation == BufferParams::ORIENTATION_PORTRAIT)) {
// dvips won't accept -t letter -t landscape. In all other
// cases, include the paper size explicitly.
command += ' ';
command += lyxrc->print_paper_flag + ' ' + paper;
}
- if (buffer->params.orientation == ORIENTATION_LANDSCAPE) {
+ if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE) {
command += ' ';
command += lyxrc->print_landscape_flag;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool ret = RunScript(buffer, wait, command);
AllowInput();
- PathPop();
return ret;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool ret = RunScript(buffer, false, lyxrc->view_ps_command, ps);
- PathPop();
AllowInput();
return ret;
}
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
if (!lyxrc->fax_program.empty()) {
- string help2 = lyxrc->fax_program;
- subst(help2, "$$FName",ps);
+ string help2 = subst(lyxrc->fax_program, "$$FName", ps);
help2 += " &";
Systemcalls one(Systemcalls::System, help2);
} else
- send_fax(ps,lyxrc->fax_command);
- PathPop();
+ send_fax(ps, lyxrc->fax_command);
}
string paper;
char real_papersize = buffer->params.papersize;
- if (real_papersize == PAPER_DEFAULT)
+ if (real_papersize == BufferParams::PAPER_DEFAULT)
real_papersize = lyxrc->default_papersize;
switch (real_papersize) {
- case PAPER_USLETTER:
+ case BufferParams::PAPER_USLETTER:
paper = "us";
break;
- case PAPER_A3PAPER:
+ case BufferParams::PAPER_A3PAPER:
paper = "a3";
break;
- case PAPER_A4PAPER:
+ case BufferParams::PAPER_A4PAPER:
paper = "a4";
break;
- case PAPER_A5PAPER:
+ case BufferParams::PAPER_A5PAPER:
paper = "a5";
break;
- case PAPER_B5PAPER:
+ case BufferParams::PAPER_B5PAPER:
paper = "b5";
break;
- case PAPER_EXECUTIVEPAPER:
+ case BufferParams::PAPER_EXECUTIVEPAPER:
paper = "foolscap";
break;
- case PAPER_LEGALPAPER:
+ case BufferParams::PAPER_LEGALPAPER:
paper = "legal";
break;
default: /* If nothing else fits, keep the empty value */
}
if (paper.empty()) {
- if (buffer->params.orientation == ORIENTATION_LANDSCAPE)
+ 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 == ORIENTATION_LANDSCAPE)
- paper+='r';
+ if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
+ paper+= 'r';
}
// push directorypath, if necessary
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
// Run dvi-viewer
string command = lyxrc->view_dvi_command + paper ;
bool ret = RunScript(buffer, false, command);
- PathPop();
return ret;
}
-void MenuMakeLaTeX(Buffer *buffer)
+void MenuMakeLaTeX(Buffer * buffer)
{
if (buffer->text) {
// Get LaTeX-Filename
FilePtr myfile(s, FilePtr::read);
if (myfile() &&
!AskQuestion(_("File already exists:"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Do you want to overwrite the file?"))) {
minibuffer->Set(_("Canceled"));
return;
FilePtr myfile(s, FilePtr::read);
if (myfile() &&
!AskQuestion(_("File already exists:"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Do you want to overwrite the file?"))) {
minibuffer->Set(_("Canceled"));
return;
FilePtr myfile(s, FilePtr::read);
if (myfile() &&
!AskQuestion(_("File already exists:"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Do you want to overwrite the file?"))) {
minibuffer->Set(_("Canceled"));
return;
FilePtr myfile(s, FilePtr::read);
if (myfile() &&
!AskQuestion(_("File already exists:"),
- MakeDisplayPath(s,50),
+ MakeDisplayPath(s, 50),
_("Do you want to overwrite the file?"))) {
minibuffer->Set(_("Canceled"));
return;
}
else {
fl_show_form(fd_form_print->form_print,
- FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
_("Print"));
}
}
if (!current_view->getScreen() || !current_view->available())
return;
- if (current_view->currentBuffer()->isBakClean()
- || current_view->currentBuffer()->isReadonly()) {
+ if (current_view->buffer()->isBakClean()
+ || current_view->buffer()->isReadonly()) {
// We don't save now, but we'll try again later
- current_view->getOwner()->resetAutosaveTimer();
+ current_view->owner()->resetAutosaveTimer();
return;
}
minibuffer->Set(_("Autosaving current document..."));
// create autosave filename
- string fname = OnlyPath(current_view->currentBuffer()->getFileName());
+ string fname = OnlyPath(current_view->buffer()->getFileName());
fname += "#";
- fname += OnlyFilename(current_view->currentBuffer()->getFileName());
+ fname += OnlyFilename(current_view->buffer()->getFileName());
fname += "#";
// tmp_ret will be located (usually) in /tmp
// anyway.
bool failed = false;
if (!tmp_ret.empty()) {
- current_view->currentBuffer()->writeFile(tmp_ret, 1);
+ current_view->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->currentBuffer()->writeFile(fname,
- 1)) {
+ if (!current_view->buffer()->writeFile(fname, 1)) {
// It is dangerous to do this in the child,
// but safe in the parent, so...
if (pid == -1)
}
}
- current_view->currentBuffer()->markBakClean();
- current_view->getOwner()->resetAutosaveTimer();
+ current_view->buffer()->markBakClean();
+ current_view->owner()->resetAutosaveTimer();
}
{
// Split argument by :
string name;
- string tmpname=split(filename, name, ':');
+ string tmpname = split(filename, name, ':');
#ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
- if (name.length() == 1 && isalpha((unsigned char) name[0]) &&
- (tmpname.prefixIs("/") || tmpname.prefixIs("\\"))) {
+ if (name.length() == 1
+ && isalpha(static_cast<unsigned char>(name[0]))
+ && (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
name += ':';
- name += tmpname.token(':');
- tmpname = split(tmpname, ':');
+ name += token(tmpname, ':', 0);
+ tmpname = split(tmpname, ':');
}
#endif
lyxerr.debug() << "Arg is " << filename
<< "\nTemplate is " << tmpname << endl;
// find a free buffer
- Buffer *tmpbuf = bufferlist.newFile(name,tmpname);
+ Buffer *tmpbuf = bufferlist.newFile(name, tmpname);
if (tmpbuf)
lastfiles->newFile(tmpbuf->getFileName());
return tmpbuf;
if (fname.empty()) {
ProhibitInput();
fname = fileDlg.Select(_("File to Insert"),
- current_view->getOwner()->currentBuffer()->filepath,
+ current_view->owner()->buffer()->filepath,
"*");
AllowInput();
if (fname.empty()) return;
if (!fi.exist() || !fi.readable() || !myfile()) {
WriteFSAlert(_("Error! Cannot open specified file:"),
- MakeDisplayPath(fname,50));
+ MakeDisplayPath(fname, 50));
return;
}
- tmppar = new LyXParagraph();
+ tmppar = new LyXParagraph;
tmppar->readSimpleWholeFile(myfile);
// set the end of the string
- tmppar->InsertChar(tmppar->last-1,'\0');
-
+#warning why do we do this?
+ // I don't think this is needed. Actually it might be plain wrong.
+ tmppar->InsertChar(tmppar->text.size() - 1,'\0');
+
// insert the string
current_view->getScreen()->HideCursor();
// clear the selection
BeforeChange();
if (!asParagraph)
- current_view->currentBuffer()->text->InsertStringA(tmppar->text);
+ current_view->buffer()->text->InsertStringA(tmppar->text);
else
- current_view->currentBuffer()->text->InsertStringB(tmppar->text);
+ current_view->buffer()->text->InsertStringB(tmppar->text);
delete tmppar;
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->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);
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);
}
}
-void MenuInsertLabel(const char *arg)
+void MenuInsertLabel(char const *arg)
{
string label = arg;
ProhibitInput();
- //string label = fl_show_input(_("Enter new label to insert:"),"");
+ //string label = fl_show_input(_("Enter new label to insert:"), "");
if (label.empty())
label = frontStrip(strip(askForText(_("Enter new label to insert:"))));
if (!label.empty()) {
InsetLabel *new_inset = new InsetLabel;
new_inset->setContents(label);
- current_view->currentBuffer()->insertInset(new_inset);
+ current_view->buffer()->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);
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);
}
}
}
-void FootCB(FL_OBJECT*, long)
+extern "C" void FootCB(FL_OBJECT*, long)
{
if (!current_view->available())
return;
minibuffer->Set(_("Inserting Footnote..."));
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->InsertFootnoteEnvironment(LyXParagraph::FOOTNOTE);
+ current_view->buffer()->update(1);
}
void LayoutsCB(int sel, void *)
{
- string tmp;
- tmp += sel;
- current_view->getOwner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
+ string tmp = tostr(sel);
+ current_view->owner()->getLyXFunc()->Dispatch(LFUN_LAYOUTNO,
tmp.c_str());
}
name = ChangeExtension (filename, ".sgml", true);
path = OnlyPath (filename);
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
- path = current_view->currentBuffer()->tmppath;
+ path = current_view->buffer()->tmppath;
}
- PathPush (path);
+ Path p(path);
if (flag != -1) {
if (!current_view->available())
return 0;
- current_view->currentBuffer()->makeLinuxDocFile(name,0);
- LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->currentBuffer()->params.papersize;
+ current_view->buffer()->makeLinuxDocFile(name, 0);
+ BufferParams::PAPER_SIZE ps = current_view->buffer()->params.papersize;
switch (ps) {
- case PAPER_A4PAPER: add_flags = "-p a4"; break;
- case PAPER_USLETTER: add_flags = "-p letter"; break;
+ 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 (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
} else
- current_view->currentBuffer()->markDviClean();
+ current_view->buffer()->markDviClean();
break;
default: /* unknown output */
break;
}
- PathPop();
AllowInput();
- current_view->currentBuffer()->redraw();
+ current_view->buffer()->redraw();
return errorcode;
}
name = ChangeExtension (filename, ".sgml", true);
path = OnlyPath (filename);
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
- path = current_view->currentBuffer()->tmppath;
+ path = current_view->buffer()->tmppath;
}
- PathPush (path);
+ Path p(path);
if (!current_view->available())
return 0;
- current_view->currentBuffer()->makeDocBookFile(name,0);
-#if 0
- string add_flags;
- LYX_PAPER_SIZE ps = (LYX_PAPER_SIZE) current_view->currentBuffer()->params.papersize;
- switch (ps) {
- case PAPER_A4PAPER: add_flags = "-p a4"; break;
- case PAPER_USLETTER: add_flags = "-p letter"; break;
- default: /* nothing to be done yet ;-) */ break;
- }
-#endif
+ current_view->buffer()->makeDocBookFile(name, 0);
+
+ // Shall this code go or should it stay? (Lgb)
+// string add_flags;
+// LYX_PAPER_SIZE ps = (LYX_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;
+// }
ProhibitInput();
Systemcalls one;
if (one.startscript(Systemcalls::System, s2)) {
errorcode = 1;
} else
- current_view->currentBuffer()->markDviClean();
+ current_view->buffer()->markDviClean();
break;
default: /* unknown output */
break;
}
- PathPop();
AllowInput();
- current_view->currentBuffer()->redraw();
+ current_view->buffer()->redraw();
return errorcode;
}
if (!current_view->available())
return;
- LyXCursor cursor = current_view->currentBuffer()->text->cursor;
+ LyXCursor cursor = current_view->buffer()->text->cursor;
if (!flag && cursor.par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& ((figmar
cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
- LyXParagraph *par = current_view->currentBuffer()->paragraph;
+ LyXParagraph *par = current_view->buffer()->paragraph;
while (par) {
if (flag) {
if (par->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE
)
){
if (par->previous
- && par->previous->footnoteflag !=
+ && par->previous->footnoteflag !=
LyXParagraph::CLOSED_FOOTNOTE){ /* should be */
- current_view->currentBuffer()->text->SetCursorIntern(par->previous,
+ current_view->buffer()->text->SetCursorIntern(par->previous,
0);
- current_view->currentBuffer()->text->OpenFootnote();
+ current_view->buffer()->text->OpenFootnote();
}
}
}
)
)
){
- current_view->currentBuffer()->text->SetCursorIntern(par, 0);
- current_view->currentBuffer()->text->CloseFootnote();
+ current_view->buffer()->text->SetCursorIntern(par, 0);
+ current_view->buffer()->text->CloseFootnote();
}
}
par = par->next;
}
- current_view->currentBuffer()->text->SetCursorIntern(cursor.par, cursor.pos);
+ current_view->buffer()->text->SetCursorIntern(cursor.par, cursor.pos);
current_view->redraw();
current_view->fitCursor();
current_view->updateScrollbar();
void MenuLayoutCharacter()
{
+ static int ow = -1, oh;
+
if (fd_form_character->form_character->visible) {
fl_raise_form(fd_form_character->form_character);
} else {
fl_show_form(fd_form_character->form_character,
- FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
_("Character Style"));
+ if (ow < 0) {
+ ow = fd_form_character->form_character->w;
+ oh = fd_form_character->form_character->h;
+ }
+ fl_set_form_minsize(fd_form_character->form_character, ow, oh);
}
}
return false;
}
- Buffer * buf = current_view->currentBuffer();
+ Buffer * buf = current_view->buffer();
fl_set_input(fd_form_paragraph->input_labelwidth,
buf->text->cursor.par->GetLabelWidthString().c_str());
int align = buf->text->cursor.par->GetAlign();
if (align == LYX_ALIGN_LAYOUT)
- align = lyxstyle.Style(buf->params.textclass,
- buf->text->cursor.par->GetLayout())->align;
+ align = textclasslist.Style(buf->params.textclass,
+ buf->text->cursor.par->GetLayout()).align;
switch (align) {
case LYX_ALIGN_RIGHT:
fl_set_button(fd_form_paragraph->check_noindent,
buf->text->cursor.par->FirstPhysicalPar()->noindent);
- if (current_view->currentBuffer()->isReadonly()) {
+ if (current_view->buffer()->isReadonly()) {
DisableParagraphLayout();
} else {
EnableParagraphLayout();
fl_raise_form(fd_form_paragraph->form_paragraph);
} else {
fl_show_form(fd_form_paragraph->form_paragraph,
- FL_PLACE_MOUSE | FL_FREE_SIZE,FL_FULLBORDER,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
_("Paragraph Environment"));
}
}
}
if (params == 0)
- params = ¤t_view->currentBuffer()->params;
- LyXTextClass *tclass = lyxstyle.TextClass(params->textclass);
+ params = ¤t_view->buffer()->params;
+ LyXTextClass const & tclass = textclasslist.TextClass(params->textclass);
fl_set_choice_text(fd_form_document->choice_class,
- lyxstyle.DescOfClass(params->textclass).c_str());
+ textclasslist.DescOfClass(params->textclass).c_str());
combo_language->select_text(params->language.c_str());
fl_set_choice_text(fd_form_document->choice_fonts,
fl_clear_choice(fd_form_document->choice_fontsize);
fl_addto_choice(fd_form_document->choice_fontsize, "default");
fl_addto_choice(fd_form_document->choice_fontsize,
- tclass->opt_fontsize.c_str());
+ tclass.opt_fontsize().c_str());
fl_set_choice(fd_form_document->choice_fontsize,
- tokenPos(tclass->opt_fontsize, '|', params->fontsize) + 2);
+ tokenPos(tclass.opt_fontsize(), '|', params->fontsize) + 2);
// ale970405+lasgoutt970513
fl_clear_choice(fd_form_document->choice_pagestyle);
fl_addto_choice(fd_form_document->choice_pagestyle, "default");
fl_addto_choice(fd_form_document->choice_pagestyle,
- tclass->opt_pagestyle.c_str());
+ tclass.opt_pagestyle().c_str());
fl_set_choice(fd_form_document->choice_pagestyle,
- tokenPos(tclass->opt_pagestyle, '|', params->pagestyle) + 2);
+ tokenPos(tclass.opt_pagestyle(), '|', params->pagestyle) + 2);
fl_set_button(fd_form_document->radio_indent, 0);
fl_set_button(fd_form_document->radio_skip, 0);
fl_set_button(fd_form_document->check_use_amsmath, params->use_amsmath);
- if (params->paragraph_separation == LYX_PARSEP_INDENT)
+ if (params->paragraph_separation == BufferParams::PARSEP_INDENT)
fl_set_button(fd_form_document->radio_indent, 1);
else
fl_set_button(fd_form_document->radio_skip, 1);
{
fl_set_choice(fd_form_document->choice_spacing, 4);
char sval[20];
- sprintf(sval,"%g",params->spacing.getValue());
+ sprintf(sval, "%g", params->spacing.getValue());
fl_set_input(fd_form_document->input_spacing, sval);
break;
}
else
fl_set_input(fd_form_document->input_extra, "");
- if (current_view->currentBuffer()->isSGML()) {
+ if (current_view->buffer()->isSGML()) {
// bullets not used in SGML derived documents
fl_deactivate_object(fd_form_document->button_bullets);
fl_set_object_lcol(fd_form_document->button_bullets,
FL_BLACK);
}
- if (current_view->currentBuffer()->isReadonly()) {
+ if (current_view->buffer()->isReadonly()) {
DisableDocumentLayout();
} else {
EnableDocumentLayout();
fl_raise_form(fd_form_document->form_document);
} else {
fl_show_form(fd_form_document->form_document,
- FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_FULLBORDER,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
_("Document Layout"));
}
}
bool update = true;
if (!current_view->getScreen()
|| !current_view->available()
- || current_view->currentBuffer()->isReadonly())
+ || current_view->buffer()->isReadonly())
update = false;
if (update) {
fl_set_choice(fd_form_quotes->choice_quotes_language,
- current_view->currentBuffer()->params.quotes_language + 1);
+ current_view->buffer()->params.quotes_language + 1);
fl_set_button(fd_form_quotes->radio_single, 0);
fl_set_button(fd_form_quotes->radio_double, 0);
- if (current_view->currentBuffer()->params.quotes_times == InsetQuotes::SingleQ)
+ if (current_view->buffer()->params.quotes_times == InsetQuotes::SingleQ)
fl_set_button(fd_form_quotes->radio_single, 1);
else
fl_set_button(fd_form_quotes->radio_double, 1);
fl_raise_form(fd_form_quotes->form_quotes);
} else {
fl_show_form(fd_form_quotes->form_quotes,
- FL_PLACE_MOUSE | FL_FREE_SIZE,
- FL_FULLBORDER,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
_("Quotes"));
}
}
if (update) {
fl_set_input(fd_form_preamble->input_preamble,
- current_view->currentBuffer()->params.preamble.c_str());
+ current_view->buffer()->params.preamble.c_str());
- if (current_view->currentBuffer()->isReadonly()) {
+ if (current_view->buffer()->isReadonly()) {
fl_deactivate_object(fd_form_preamble->input_preamble);
fl_deactivate_object(fd_form_preamble->button_ok);
fl_deactivate_object(fd_form_preamble->button_apply);
void MenuLayoutPreamble()
{
+ static int ow = -1, oh;
+
if (UpdateLayoutPreamble()) {
if (fd_form_preamble->form_preamble->visible) {
fl_raise_form(fd_form_preamble->form_preamble);
FL_PLACE_MOUSE | FL_FREE_SIZE,
FL_FULLBORDER,
_("LaTeX Preamble"));
+ if (ow < 0) {
+ ow = fd_form_preamble->form_preamble->w;
+ oh = fd_form_preamble->form_preamble->h;
+ }
+ fl_set_form_minsize(fd_form_preamble->form_preamble,
+ ow, oh);
}
}
}
if (AskQuestion(_("Do you want to save the current settings"),
_("for Character, Document, Paper and Quotes"),
_("as default for new documents?")))
- current_view->currentBuffer()->saveParamsAsDefaults();
+ current_view->buffer()->saveParamsAsDefaults();
}
void NoteCB()
{
InsetInfo *new_inset = new InsetInfo();
- current_view->currentBuffer()->insertInset(new_inset);
- new_inset->Edit(0,0);
- //current_view->currentBuffer()->update(-1);
+ current_view->buffer()->insertInset(new_inset);
+ new_inset->Edit(0, 0);
+ //current_view->buffer()->update(-1);
}
minibuffer->Set(_("Open/Close..."));
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->OpenStuff();
- current_view->currentBuffer()->update(0);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->OpenStuff();
+ current_view->buffer()->update(0);
}
}
minibuffer->Set(_("Open/Close..."));
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->ToggleFootnote();
- current_view->currentBuffer()->update(0);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->ToggleFootnote();
+ current_view->buffer()->update(0);
}
}
void MenuUndo()
{
-/* if (current_view->currentBuffer()->the_locking_inset) {
+/* if (current_view->buffer()->the_locking_inset) {
minibuffer->Set(_("Undo not yet supported in math mode"));
return;
}*/
minibuffer->Set(_("Undo"));
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
- if (!current_view->currentBuffer()->text->TextUndo())
+ current_view->buffer()->update(-2);
+ if (!current_view->buffer()->text->TextUndo())
minibuffer->Set(_("No further undo information"));
else
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->update(-1);
}
}
void MenuRedo()
{
- if (current_view->currentBuffer()->the_locking_inset) {
+ if (current_view->buffer()->the_locking_inset) {
minibuffer->Set(_("Redo not yet supported in math mode"));
return;
}
minibuffer->Set(_("Redo"));
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
- if (!current_view->currentBuffer()->text->TextRedo())
+ current_view->buffer()->update(-2);
+ if (!current_view->buffer()->text->TextRedo())
minibuffer->Set(_("No further redo information"));
else
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->update(-1);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
InsetSpecialChar *new_inset =
new InsetSpecialChar(InsetSpecialChar::HYPHENATION);
- current_view->currentBuffer()->insertInset(new_inset);
- //current_view->currentBuffer()->update(-1);
+ current_view->buffer()->insertInset(new_inset);
+ //current_view->buffer()->update(-1);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
InsetSpecialChar *new_inset =
new InsetSpecialChar(InsetSpecialChar::LDOTS);
- current_view->currentBuffer()->insertInset(new_inset);
+ current_view->buffer()->insertInset(new_inset);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
InsetSpecialChar *new_inset =
new InsetSpecialChar(InsetSpecialChar::END_OF_SENTENCE);
- current_view->currentBuffer()->insertInset(new_inset);
+ current_view->buffer()->insertInset(new_inset);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
InsetSpecialChar *new_inset =
new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR);
- current_view->currentBuffer()->insertInset(new_inset);
- //current_view->currentBuffer()->update(-1);
+ current_view->buffer()->insertInset(new_inset);
+ //current_view->buffer()->update(-1);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->InsertChar(LYX_META_NEWLINE);
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->InsertChar(LyXParagraph::META_NEWLINE);
+ current_view->buffer()->update(-1);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->InsertChar(LYX_META_PROTECTED_SEPARATOR);
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR);
+ current_view->buffer()->update(-1);
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->InsertChar(LYX_META_HFILL);
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->InsertChar(LyXParagraph::META_HFILL);
+ current_view->buffer()->update(-1);
}
}
if (current_view->available()) {
// I think we should only show changes from the default
// font. (Asger)
- Buffer * buffer = current_view->currentBuffer();
+ Buffer * buffer = current_view->buffer();
LyXFont font = buffer->text->real_current_font;
- LyXFont defaultfont = lyxstyle.TextClass(buffer->
- params.textclass)->defaultfont;
+ LyXFont defaultfont = textclasslist.TextClass(buffer->
+ params.textclass).defaultfont();
font.reduce(defaultfont);
state = _("Font: ") + font.stateText();
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->ToggleFree(font, toggleall);
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->ToggleFree(font, toggleall);
+ current_view->buffer()->update(1);
}
// removed since it overrides the ToggleFree Message about the style
// Since Styles are more "High Level" than raw fonts I think the user
}
-void MarginCB(FL_OBJECT *, long)
+extern "C" void MarginCB(FL_OBJECT *, long)
{
if (current_view->available()) {
minibuffer->Set(_("Inserting margin note..."));
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->InsertFootnoteEnvironment(LyXParagraph::MARGIN);
+ current_view->buffer()->update(1);
}
}
-void FigureCB(FL_OBJECT *, long)
+extern "C" void FigureCB(FL_OBJECT *, long)
{
if (fd_form_figure->form_figure->visible) {
fl_raise_form(fd_form_figure->form_figure);
}
-void TableCB(FL_OBJECT *, long)
+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_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
_("Insert Table"));
}
}
void CopyEnvironmentCB()
{
if (current_view->available()) {
- current_view->currentBuffer()->text->copyEnvironmentType();
+ current_view->buffer()->text->copyEnvironmentType();
/* clear the selection, even if mark_set */
current_view->getScreen()->ToggleSelection();
- current_view->currentBuffer()->text->ClearSelection();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->text->ClearSelection();
+ current_view->buffer()->update(-2);
minibuffer->Set(_("Paragraph environment type copied"));
}
}
void PasteEnvironmentCB()
{
if (current_view->available()) {
- current_view->currentBuffer()->text->pasteEnvironmentType();
+ current_view->buffer()->text->pasteEnvironmentType();
minibuffer->Set(_("Paragraph environment type set"));
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
}
}
void CopyCB()
{
if (current_view->available()) {
- current_view->currentBuffer()->text->CopySelection();
+ current_view->buffer()->text->CopySelection();
/* clear the selection, even if mark_set */
current_view->getScreen()->ToggleSelection();
- current_view->currentBuffer()->text->ClearSelection();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->text->ClearSelection();
+ current_view->buffer()->update(-2);
minibuffer->Set(_("Copy"));
}
}
{
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->CutSelection();
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->CutSelection();
+ current_view->buffer()->update(1);
minibuffer->Set(_("Cut"));
}
}
current_view->getScreen()->HideCursor();
/* clear the selection */
current_view->getScreen()->ToggleSelection();
- current_view->currentBuffer()->text->ClearSelection();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->text->ClearSelection();
+ current_view->buffer()->update(-2);
/* paste */
- current_view->currentBuffer()->text->PasteSelection();
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->text->PasteSelection();
+ current_view->buffer()->update(1);
/* clear the selection */
current_view->getScreen()->ToggleSelection();
- current_view->currentBuffer()->text->ClearSelection();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->text->ClearSelection();
+ current_view->buffer()->update(-2);
}
-void MeltCB(FL_OBJECT *, long)
+extern "C" void MeltCB(FL_OBJECT *, long)
{
if (!current_view->available()) return;
minibuffer->Set(_("Melt"));
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
- current_view->currentBuffer()->text->MeltFootnoteEnvironment();
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(-2);
+ current_view->buffer()->text->MeltFootnoteEnvironment();
+ current_view->buffer()->update(1);
}
// if decInc == 0, depth change taking mouse button number into account
// if decInc == 1, increment depth
// if decInc == -1, decrement depth
-void DepthCB(FL_OBJECT *ob, long decInc)
+extern "C" void DepthCB(FL_OBJECT *ob, long decInc)
{
int button = 1;
if (current_view->available()) {
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
if (button == 1)
- current_view->currentBuffer()->text->IncDepth();
+ current_view->buffer()->text->IncDepth();
else
- current_view->currentBuffer()->text->DecDepth();
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->text->DecDepth();
+ current_view->buffer()->update(1);
minibuffer->Set(_("Changed environment depth"
" (in possible range, maybe not)"));
}
/* callbacks for form form_title */
-void TimerCB(FL_OBJECT *, long)
+extern "C" void TimerCB(FL_OBJECT *, long)
{
// only if the form still exists
if (fd_form_title->form_title != 0) {
/* callbacks for form form_paragraph */
-void ParagraphVSpaceCB(FL_OBJECT* obj, long )
+extern "C" void ParagraphVSpaceCB(FL_OBJECT* obj, long )
{
// "Synchronize" the choices and input fields, making it
// impossible to commit senseless data.
}
-void ParagraphApplyCB(FL_OBJECT *, long)
+extern "C" void ParagraphApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
- bool line_top, line_bottom;
- bool pagebreak_top, pagebreak_bottom;
VSpace space_top, space_bottom;
- char align;
+ LyXAlignment align;
string labelwidthstring;
bool noindent;
fl_set_choice (fd_form_paragraph->choice_space_below, 1);
}
- line_top = fl_get_button(fd_form_paragraph->check_lines_top);
- line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
- pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
- pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
+ bool line_top = fl_get_button(fd_form_paragraph->check_lines_top);
+ bool line_bottom = fl_get_button(fd_form_paragraph->check_lines_bottom);
+ bool pagebreak_top = fl_get_button(fd_form_paragraph->check_pagebreaks_top);
+ bool pagebreak_bottom = fl_get_button(fd_form_paragraph->check_pagebreaks_bottom);
switch (fl_get_choice (fd_form_paragraph->choice_space_above)) {
case 1: space_top = VSpace(VSpace::NONE); break;
case 2: space_top = VSpace(VSpace::DEFSKIP); break;
labelwidthstring = fl_get_input(fd_form_paragraph->input_labelwidth);
noindent = fl_get_button(fd_form_paragraph->check_noindent);
- current_view->currentBuffer()->text->SetParagraph(line_top,
+ current_view->buffer()->text->SetParagraph(line_top,
line_bottom,
pagebreak_top,
pagebreak_bottom,
align,
labelwidthstring,
noindent);
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
minibuffer->Set(_("Paragraph layout set"));
}
-void ParagraphCancelCB(FL_OBJECT *, long)
+extern "C" void ParagraphCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_paragraph->form_paragraph);
}
-void ParagraphOKCB(FL_OBJECT *ob, long data)
+extern "C" void ParagraphOKCB(FL_OBJECT *ob, long data)
{
ParagraphApplyCB(ob, data);
ParagraphCancelCB(ob, data);
/* callbacks for form form_character */
-void CharacterApplyCB(FL_OBJECT *, long)
+extern "C" void CharacterApplyCB(FL_OBJECT *, long)
{
// we set toggleall locally here, since it should be true for
// all other uses of ToggleAndShow() (JMarc)
}
-void CharacterCloseCB(FL_OBJECT *, long)
+extern "C" void CharacterCloseCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_character->form_character);
}
-void CharacterOKCB(FL_OBJECT *ob, long data)
+extern "C" void CharacterOKCB(FL_OBJECT *ob, long data)
{
- CharacterApplyCB(ob,data);
- CharacterCloseCB(ob,data);
+ CharacterApplyCB(ob, data);
+ CharacterCloseCB(ob, data);
}
}
-void ChoiceClassCB(FL_OBJECT *ob, long)
+extern "C" void ChoiceClassCB(FL_OBJECT *ob, long)
{
ProhibitInput();
- if (lyxstyle.Load(fl_get_choice(ob)-1)) {
+ if (textclasslist.Load(fl_get_choice(ob)-1)) {
if (AskQuestion(_("Should I set some parameters to"),
fl_get_choice_text(ob),
_("the defaults of this document class?"))) {
}
-void DocumentDefskipCB(FL_OBJECT *obj, long)
+extern "C" void DocumentDefskipCB(FL_OBJECT *obj, long)
{
// "Synchronize" the choice and the input field, so that it
// is impossible to commit senseless data.
}
-void DocumentSpacingCB(FL_OBJECT *obj, long)
+extern "C" void DocumentSpacingCB(FL_OBJECT *obj, long)
{
// "Synchronize" the choice and the input field, so that it
// is impossible to commit senseless data.
}
-void DocumentApplyCB(FL_OBJECT *, long)
+extern "C" void DocumentApplyCB(FL_OBJECT *, long)
{
bool redo = false;
- BufferParams *params = &(current_view->currentBuffer()->params);
- current_view->currentBuffer()->params.language =
+ BufferParams *params = &(current_view->buffer()->params);
+ current_view->buffer()->params.language =
combo_language->getline();
// If default skip is a "Length" but there's no text in the
/* ChangeKeymap(buffer->parameters.language, TRUE, false,
fl_get_choice(fd_form_document->choice_language)); */
- params->fonts =
+ params->fonts =
fl_get_choice_text(fd_form_document->choice_fonts);
- params->inputenc =
+ params->inputenc =
fl_get_choice_text(fd_form_document->choice_inputenc);
- params->fontsize =
+ params->fontsize =
fl_get_choice_text(fd_form_document->choice_fontsize);
- params->pagestyle =
+ params->pagestyle =
fl_get_choice_text(fd_form_document->choice_pagestyle);
- params->graphicsDriver =
+ params->graphicsDriver =
fl_get_choice_text(fd_form_document->choice_postscript_driver);
- params->use_amsmath =
+ params->use_amsmath =
fl_get_button(fd_form_document->check_use_amsmath);
if (!current_view->available())
return;
- char new_class = fl_get_choice(fd_form_document->choice_class) - 1;
+ 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 (lyxstyle.Load(new_class)) {
+ if (textclasslist.Load(new_class)) {
// successfully loaded
redo = true;
minibuffer->Set(_("Converting document to new document class..."));
- int ret = current_view->currentBuffer()->
+ int ret = current_view->buffer()->
text->
- SwitchLayoutsBetweenClasses(current_view->currentBuffer()->
+ SwitchLayoutsBetweenClasses(current_view->buffer()->
params.textclass,
new_class,
- current_view->currentBuffer()->
+ current_view->buffer()->
paragraph);
if (ret){
string s;
- if (ret==1)
- s= _("One paragraph couldn't be converted");
+ if (ret == 1)
+ s = _("One paragraph couldn't be converted");
else {
- s += ret;
+ s += tostr(ret);
s += _(" paragraphs couldn't be converted");
}
- WriteAlert(_("Conversion Errors!"),s,
+ WriteAlert(_("Conversion Errors!"), s,
_("into chosen document class"));
}
char tmpsep = params->paragraph_separation;
if (fl_get_button(fd_form_document->radio_indent))
- params->paragraph_separation = LYX_PARSEP_INDENT;
+ params->paragraph_separation = BufferParams::PARSEP_INDENT;
else
- params->paragraph_separation = LYX_PARSEP_SKIP;
+ params->paragraph_separation = BufferParams::PARSEP_SKIP;
if (tmpsep != params->paragraph_separation)
redo = true;
else
params->columns = 1;
if (fl_get_button(fd_form_document->radio_sides_two))
- params->sides = 2;
+ params->sides = LyXTextClass::TwoSides;
else
- params->sides = 1;
+ params->sides = LyXTextClass::OneSide;
Spacing tmpSpacing = params->spacing;
switch(fl_get_choice(fd_form_document->choice_spacing)) {
if (tmpSpacing != params->spacing)
redo = true;
- signed char tmpchar = (signed char)
- fl_get_counter_value(fd_form_document->slider_secnumdepth);;
+ signed char tmpchar =
+ static_cast<signed char>(fl_get_counter_value(fd_form_document->slider_secnumdepth));
if (params->secnumdepth != tmpchar)
redo = true;
params->secnumdepth = tmpchar;
- params->tocdepth = (signed char)
- fl_get_counter_value(fd_form_document->slider_tocdepth);;
+ params->tocdepth =
+ static_cast<int>(fl_get_counter_value(fd_form_document->slider_tocdepth));
- params->float_placement =
+ params->float_placement =
fl_get_input(fd_form_document->input_float_placement);
// More checking should be done to ensure the string doesn't have
current_view->redoCurrentBuffer();
minibuffer->Set(_("Document layout set"));
- current_view->currentBuffer()->markDirty();
+ current_view->buffer()->markDirty();
- params->options =
+ params->options =
fl_get_input(fd_form_document->input_extra);
}
-void DocumentCancelCB(FL_OBJECT *, long)
+extern "C" void DocumentCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_document->form_document);
}
-void DocumentOKCB(FL_OBJECT *ob, long data)
+extern "C" void DocumentOKCB(FL_OBJECT *ob, long data)
{
- DocumentCancelCB(ob,data);
- DocumentApplyCB(ob,data);
+ DocumentCancelCB(ob, data);
+ DocumentApplyCB(ob, data);
}
-void DocumentBulletsCB(FL_OBJECT *, long)
+extern "C" void DocumentBulletsCB(FL_OBJECT *, long)
{
bulletForm();
// bullet callbacks etc. in bullet_panel.C -- ARRae
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
LyXCursor tmp;
- if (!current_view->currentBuffer()->text->GotoNextNote()) {
- if (current_view->currentBuffer()->text->cursor.pos
- || current_view->currentBuffer()->text->cursor.par !=
- current_view->currentBuffer()->text->FirstParagraph())
+ if (!current_view->buffer()->text->GotoNextNote()) {
+ if (current_view->buffer()->text->cursor.pos
+ || current_view->buffer()->text->cursor.par !=
+ current_view->buffer()->text->FirstParagraph())
{
- tmp = current_view->currentBuffer()->text->cursor;
- current_view->currentBuffer()->text->cursor.par =
- current_view->currentBuffer()->text->FirstParagraph();
- current_view->currentBuffer()->text->cursor.pos = 0;
- if (!current_view->currentBuffer()->text->GotoNextNote()) {
- current_view->currentBuffer()->text->cursor = tmp;
+ tmp = current_view->buffer()->text->cursor;
+ current_view->buffer()->text->cursor.par =
+ current_view->buffer()->text->FirstParagraph();
+ current_view->buffer()->text->cursor.pos = 0;
+ if (!current_view->buffer()->text->GotoNextNote()) {
+ current_view->buffer()->text->cursor = tmp;
minibuffer->Set(_("No more notes"));
LyXBell();
}
LyXBell();
}
}
- current_view->currentBuffer()->update(0);
- current_view->currentBuffer()->text->sel_cursor =
- current_view->currentBuffer()->text->cursor;
+ current_view->buffer()->update(0);
+ current_view->buffer()->text->sel_cursor =
+ current_view->buffer()->text->cursor;
}
void InsertCorrectQuote()
{
- Buffer *cbuffer = current_view->currentBuffer();
+ Buffer *cbuffer = current_view->buffer();
char c;
if (cbuffer->text->cursor.pos )
/* callbacks for form form_quotes */
-void QuotesApplyCB(FL_OBJECT *, long)
+extern "C" void QuotesApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
minibuffer->Set(_("Quotes type set"));
- //current_view->currentBuffer()->params.quotes_language =
+ //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) {
lga = InsetQuotes::DanishQ;
break;
}
- current_view->currentBuffer()->params.quotes_language = lga;
+ current_view->buffer()->params.quotes_language = lga;
if (fl_get_button(fd_form_quotes->radio_single))
- current_view->currentBuffer()->
+ current_view->buffer()->
params.quotes_times = InsetQuotes::SingleQ;
else
- current_view->currentBuffer()->
+ current_view->buffer()->
params.quotes_times = InsetQuotes::DoubleQ;
}
-void QuotesCancelCB(FL_OBJECT *, long)
+extern "C" void QuotesCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_quotes->form_quotes);
}
-void QuotesOKCB(FL_OBJECT *ob, long data)
+extern "C" void QuotesOKCB(FL_OBJECT *ob, long data)
{
QuotesApplyCB(ob, data);
QuotesCancelCB(ob, data);
/* callbacks for form form_preamble */
-void PreambleCancelCB(FL_OBJECT *, long)
+extern "C" void PreambleCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_preamble->form_preamble);
}
-void PreambleApplyCB(FL_OBJECT *, long)
+extern "C" void PreambleApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
- current_view->currentBuffer()->params.preamble =
+ current_view->buffer()->params.preamble =
fl_get_input(fd_form_preamble->input_preamble);
- current_view->currentBuffer()->markDirty();
+ current_view->buffer()->markDirty();
minibuffer->Set(_("LaTeX preamble set"));
}
-void PreambleOKCB(FL_OBJECT *ob, long data)
+extern "C" void PreambleOKCB(FL_OBJECT *ob, long data)
{
PreambleApplyCB(ob, data);
PreambleCancelCB(ob, data);
/* callbacks for form form_table */
-void TableApplyCB(FL_OBJECT *, long)
+extern "C" void TableApplyCB(FL_OBJECT *, long)
{
- int xsize,ysize;
+ int xsize, ysize;
if (!current_view->getScreen())
return;
// check for tables in tables
- if (current_view->currentBuffer()->text->cursor.par->table){
+ if (current_view->buffer()->text->cursor.par->table){
WriteAlert(_("Impossible Operation!"),
_("Cannot insert table in table."),
_("Sorry."));
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
- current_view->currentBuffer()->text->SetCursorParUndo();
- current_view->currentBuffer()->text->FreezeUndo();
+ current_view->buffer()->text->SetCursorParUndo();
+ current_view->buffer()->text->FreezeUndo();
- current_view->currentBuffer()->text->BreakParagraph();
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->text->BreakParagraph();
+ current_view->buffer()->update(-1);
- if (current_view->currentBuffer()->text->cursor.par->Last()) {
- current_view->currentBuffer()->text->CursorLeft();
+ if (current_view->buffer()->text->cursor.par->Last()) {
+ current_view->buffer()->text->CursorLeft();
- current_view->currentBuffer()->text->BreakParagraph();
- current_view->currentBuffer()->update(-1);
+ current_view->buffer()->text->BreakParagraph();
+ current_view->buffer()->update(-1);
}
- current_view->currentBuffer()->text->current_font.setLatex(LyXFont::OFF);
+ current_view->buffer()->text->current_font.setLatex(LyXFont::OFF);
//if (!fl_get_button(fd_form_table->check_latex)){
// insert the new wysiwy table
- current_view->currentBuffer()->text->SetLayout(0); // standard layout
- if (current_view->currentBuffer()->text->cursor.par->footnoteflag ==
+ current_view->buffer()->text->SetLayout(0); // standard layout
+ if (current_view->buffer()->text->cursor.par->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
- current_view->currentBuffer()->
+ current_view->buffer()->
text->SetParagraph(0, 0,
0, 0,
- VSpace (0.3 * current_view->currentBuffer()->
+ VSpace (0.3 * current_view->buffer()->
params.spacing.getValue(),
LyXLength::CM),
- VSpace (0.3 * current_view->currentBuffer()->
+ VSpace (0.3 * current_view->buffer()->
params.spacing.getValue(),
LyXLength::CM),
LYX_ALIGN_CENTER,
0);
}
else
- current_view->currentBuffer()->text->SetParagraph(0, 0,
+ current_view->buffer()->text->SetParagraph(0, 0,
0, 0,
VSpace(VSpace::NONE),
VSpace(VSpace::NONE),
string(),
0);
- current_view->currentBuffer()->text->cursor.par->table = new LyXTable(xsize, ysize);
+ current_view->buffer()->text->cursor.par->table = new LyXTable(xsize, ysize);
int i;
- for (i=0; i<xsize * ysize - 1; i++)
- current_view->currentBuffer()->text->cursor.par->InsertChar(0,LYX_META_NEWLINE);
- current_view->currentBuffer()->text->RedoParagraph();
+ for (i = 0; i<xsize * ysize - 1; i++)
+ current_view->buffer()->text->cursor.par->InsertChar(0, LyXParagraph::META_NEWLINE);
+ current_view->buffer()->text->RedoParagraph();
- current_view->currentBuffer()->text->UnFreezeUndo();
+ current_view->buffer()->text->UnFreezeUndo();
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
minibuffer->Set(_("Table inserted"));
}
-void TableCancelCB(FL_OBJECT *, long)
+extern "C" void TableCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_table->form_table);
}
-void TableOKCB(FL_OBJECT *ob, long data)
+extern "C" void TableOKCB(FL_OBJECT *ob, long data)
{
- TableApplyCB(ob,data);
- TableCancelCB(ob,data);
+ TableApplyCB(ob, data);
+ TableCancelCB(ob, data);
}
/* callbacks for form form_print */
-void PrintCancelCB(FL_OBJECT *, long)
+extern "C" void PrintCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_print->form_print);
}
-static bool stringOnlyContains (string const & LStr, const char * cset)
+static bool stringOnlyContains (string const & LStr, char const * cset)
{
- const char * cstr = LStr.c_str() ;
+ char const * cstr = LStr.c_str() ;
- return strspn(cstr,cset) == strlen(cstr) ;
+ return strspn(cstr, cset) == strlen(cstr) ;
}
-void PrintApplyCB(FL_OBJECT *, long)
+extern "C" void PrintApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
- Buffer *buffer = current_view->currentBuffer();
+ Buffer *buffer = current_view->buffer();
string path = OnlyPath(buffer->getFileName());
string pageflag;
// 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 = fl_get_input(fd_form_print->input_pages);
- subst(pages, ';',',');
- subst(pages, '+',',');
- pages = strip (pages) ;
- pages = frontStrip (pages) ;
+ 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, ',') ;
reverseflag = lyxrc->print_reverse_flag + ' ';
string orientationflag;
- if (buffer->params.orientation == ORIENTATION_LANDSCAPE)
+ if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
orientationflag = lyxrc->print_landscape_flag + ' ';
string ps_file = SpaceLess(fl_get_input(fd_form_print->input_file));
+ orientationflag + extraflags;
char real_papersize = buffer->params.papersize;
- if (real_papersize == PAPER_DEFAULT)
+ if (real_papersize == BufferParams::PAPER_DEFAULT)
real_papersize = lyxrc->default_papersize;
string
paper;
switch (real_papersize) {
- case PAPER_USLETTER:
+ case BufferParams::PAPER_USLETTER:
paper = "letter";
break;
- case PAPER_A3PAPER:
+ case BufferParams::PAPER_A3PAPER:
paper = "a3";
break;
- case PAPER_A4PAPER:
+ case BufferParams::PAPER_A4PAPER:
paper = "a4";
break;
- case PAPER_A5PAPER:
+ case BufferParams::PAPER_A5PAPER:
paper = "a5";
break;
- case PAPER_B5PAPER:
+ case BufferParams::PAPER_B5PAPER:
paper = "b5";
break;
- case PAPER_EXECUTIVEPAPER:
+ case BufferParams::PAPER_EXECUTIVEPAPER:
paper = "foolscap";
break;
- case PAPER_LEGALPAPER:
+ case BufferParams::PAPER_LEGALPAPER:
paper = "legal";
break;
default: /* If nothing else fits, keep an empty value... */
}
if (buffer->params.use_geometry
- && buffer->params.papersize2 == VM_PAPER_CUSTOM
+ && buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
&& !lyxrc->print_paper_dimension_flag.empty()
&& !buffer->params.paperwidth.empty()
&& !buffer->params.paperheight.empty()) {
command += buffer->params.paperheight + ' ';
} else if (!lyxrc->print_paper_flag.empty()
&& !paper.empty()
- && (real_papersize != PAPER_USLETTER ||
- buffer->params.orientation == ORIENTATION_PORTRAIT)) {
+ && (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))
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
path = buffer->tmppath;
}
- PathPush(path);
+ Path p(path);
bool result;
if (!lyxrc->print_spool_command.empty() &&
}
} else
result = RunScript(buffer, false, command);
- PathPop();
if (!result)
WriteAlert(_("Error:"),
}
-void PrintOKCB(FL_OBJECT *ob, long data)
+extern "C" void PrintOKCB(FL_OBJECT *ob, long data)
{
PrintCancelCB(ob, data);
- PrintApplyCB(ob,data);
+ PrintApplyCB(ob, data);
}
/* callbacks for form form_figure */
-void FigureApplyCB(FL_OBJECT *, long)
+extern "C" void FigureApplyCB(FL_OBJECT *, long)
{
if (!current_view->available())
return;
- Buffer * buffer = current_view->currentBuffer();
+ Buffer * buffer = current_view->buffer();
if(buffer->isReadonly()) // paranoia
return;
// The standard layout should always be numer 0;
buffer->text->SetLayout(0);
- if (buffer->text->cursor.par->footnoteflag ==
+ if (buffer->text->cursor.par->footnoteflag ==
LyXParagraph::NO_FOOTNOTE) {
buffer->text->SetParagraph(0, 0,
0, 0,
}
-void FigureCancelCB(FL_OBJECT *, long)
+extern "C" void FigureCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_figure->form_figure);
}
-void FigureOKCB(FL_OBJECT *ob, long data)
+extern "C" void FigureOKCB(FL_OBJECT *ob, long data)
{
- FigureApplyCB(ob,data);
- FigureCancelCB(ob,data);
+ FigureApplyCB(ob, data);
+ FigureCancelCB(ob, data);
}
-void ScreenApplyCB(FL_OBJECT *, long)
+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);
}
-void ScreenCancelCB(FL_OBJECT *, long)
+extern "C" void ScreenCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_screen->form_screen);
}
-void ScreenOKCB(FL_OBJECT *ob, long data)
+extern "C" void ScreenOKCB(FL_OBJECT *ob, long data)
{
- ScreenCancelCB(ob,data);
- ScreenApplyCB(ob,data);
+ ScreenCancelCB(ob, data);
+ ScreenApplyCB(ob, data);
}
return;
fl_set_button(fd_latex_options->accents,
- (int)current_view->currentBuffer()->params.allowAccents);
+ (int)current_view->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_FREE_SIZE, FL_FULLBORDER,
+ FL_PLACE_MOUSE, FL_FULLBORDER,
_("LaTeX Options"));
}
}
minibuffer->Set(_("Running configure..."));
// Run configure in user lyx directory
- PathPush(user_lyxdir);
+ Path p(user_lyxdir);
Systemcalls one(Systemcalls::System,
- AddName(system_lyxdir,"configure"));
- PathPop();
+ AddName(system_lyxdir, "configure"));
+ p.pop();
minibuffer->Set(_("Reloading configuration..."));
lyxrc->Read(LibFileSearch(string(), "lyxrc.defaults"));
WriteAlert(_("The system has been reconfigured."),
return 0;
}
- char* string = current_view->currentBuffer()->text->SelectNextWord(value);
+ char* string = current_view->buffer()->text->SelectNextWord(value);
return string;
}
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->text->SelectSelectedWord();
+ current_view->buffer()->text->SelectSelectedWord();
current_view->getScreen()->ToggleSelection(false);
- current_view->currentBuffer()->update(0);
+ current_view->buffer()->update(0);
}
current_view->getScreen()->HideCursor();
BeforeChange();
- current_view->currentBuffer()->text->SelectSelectedWord();
- current_view->currentBuffer()->text->ClearSelection();
- current_view->currentBuffer()->update(0);
+ current_view->buffer()->text->SelectSelectedWord();
+ current_view->buffer()->text->ClearSelection();
+ current_view->buffer()->update(0);
}
return;
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-2);
+ current_view->buffer()->update(-2);
/* clear the selection (if there is any) */
current_view->getScreen()->ToggleSelection(false);
- current_view->currentBuffer()->text->
+ current_view->buffer()->text->
ReplaceSelectionWithString(replacestring.c_str());
- current_view->currentBuffer()->text->SetSelectionOverString(replacestring.c_str());
+ current_view->buffer()->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) {
- current_view->currentBuffer()->text->CursorLeftIntern();
+ current_view->buffer()->text->CursorLeftIntern();
}
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
}
// End of spellchecker stuff
static TocList* toclist = 0;
-void TocSelectCB(FL_OBJECT *ob, long)
+extern "C" void TocSelectCB(FL_OBJECT *ob, long)
{
if (!current_view->available())
return;
int i = fl_get_browser(ob);
int a = 0;
- for (a=1; a<i && tmptoclist->next; a++){
+ for (a = 1; a<i && tmptoclist->next; a++){
tmptoclist = tmptoclist->next;
}
return;
- LyXParagraph *par = current_view->currentBuffer()->paragraph;
+ 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] ||
if (par) {
BeforeChange();
- current_view->currentBuffer()->text->SetCursor(par, 0);
- current_view->currentBuffer()->text->sel_cursor =
- current_view->currentBuffer()->text->cursor;
- current_view->currentBuffer()->update(0);
+ current_view->buffer()->text->SetCursor(par, 0);
+ current_view->buffer()->text->sel_cursor =
+ current_view->buffer()->text->cursor;
+ current_view->buffer()->update(0);
}
else {
WriteAlert(_("Error"),
}
-void TocCancelCB(FL_OBJECT *, long)
+extern "C" void TocCancelCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_toc->form_toc);
}
-void TocUpdateCB(FL_OBJECT *, long)
+extern "C" void TocUpdateCB(FL_OBJECT *, long)
{
- static LyXParagraph* stapar = 0;
- TocList *tmptoclist = 0;
+ static LyXParagraph * stapar = 0;
+ TocList * tmptoclist = 0;
/* deleted the toclist */
if (toclist){
}
fl_hide_object(fd_form_toc->browser_toc);
/* get the table of contents */
- LyXParagraph *par = current_view->currentBuffer()->paragraph;
+ LyXParagraph * par = current_view->buffer()->paragraph;
char labeltype;
- char* line = new char[200];
- //int i = 0;
+ char * line = new char[200];
int pos = 0;
unsigned char c;
int topline = 0;
stapar = par;
while (par) {
- labeltype = lyxstyle.Style(current_view->currentBuffer()->params.textclass,
- par->GetLayout())->labeltype;
+ labeltype = textclasslist.Style(current_view->buffer()->params.textclass,
+ par->GetLayout()).labeltype;
if (labeltype >= LABEL_COUNTER_CHAPTER
&& labeltype <= LABEL_COUNTER_CHAPTER +
- current_view->currentBuffer()->params.tocdepth) {
+ current_view->buffer()->params.tocdepth) {
/* insert this into the table of contents */
/* first indent a little bit */
- for (pos=0;
+ for (pos = 0;
pos < (labeltype -
- lyxstyle.TextClass(current_view->currentBuffer()->
- params.textclass)->maxcounter) * 4 + 2;
+ textclasslist.TextClass(current_view->buffer()->
+ params.textclass).maxcounter()) * 4 + 2;
pos++)
line[pos] = ' ';
// Then the labestring
- //i = 0;
if (!par->labelstring.empty()) {
string::size_type i = 0;
while (pos < 199 && i < par->labelstring.length()) {
line[pos] = ' ';
pos++;
- /* now the contents */
- int i = 0;
- while (pos < 199 && i < par->last) {
+ /* now the contents */
+ LyXParagraph::size_type i = 0;
+ while (pos < 199 && i < par->size()) {
c = par->GetChar(i);
- if (isprint((unsigned char) c) || c >= 128) {
+ if (isprint(c) || c >= 128) {
line[pos] = c;
pos++;
}
tmptoclist->next = 0;
int a = 0;
- for (a=0; a<6; a++){
+ for (a = 0; a<6; a++){
tmptoclist->counter[a] = par->GetFirstCounter(a);
}
tmptoclist->appendix = par->appendix;
/* callbacks for form form_ref */
-void RefSelectCB(FL_OBJECT *, long data)
+extern "C" void RefSelectCB(FL_OBJECT *, long data)
{
if (!current_view->available())
return;
- string s =
+ 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->getOwner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
+ if (data == 2) {
+ current_view->owner()->getLyXFunc()->Dispatch(LFUN_REFGOTO, s.c_str());
return;
}
string t;
- if (data==0)
+ if (data == 0)
t += "\\ref";
else
t += "\\pageref";
- if(current_view->currentBuffer()->isSGML())
+ if(current_view->buffer()->isSGML())
t += "[" + u + "]" + "{" + s + "}";
else
t += "{" + s + "}";
- Inset *new_inset =
- new InsetRef(t, current_view->currentBuffer());
- current_view->currentBuffer()->insertInset(new_inset);
+ Inset *new_inset =
+ new InsetRef(t, current_view->buffer());
+ current_view->buffer()->insertInset(new_inset);
}
-void RefUpdateCB(FL_OBJECT *, long)
+extern "C" void RefUpdateCB(FL_OBJECT *, long)
{
if (!current_view->available()) {
fl_clear_browser(fd_form_ref->browser_ref);
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,
+ char const * const btmp = fl_get_browser_line(brow,
fl_get_browser(brow));
- string currentstr=btmp ? btmp : "";
+ string currentstr = btmp ? btmp : "";
//string currentstr = fl_get_browser_line(brow,
// fl_get_browser(brow));
fl_clear_browser(brow);
- string refs = current_view->currentBuffer()->getReferenceList('\n');
+ string refs = current_view->buffer()->getReferenceList('\n');
int topline = 1;
#if FL_REVISION > 85
- fl_addto_browser_chars(brow,refs.c_str());
+ 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) {
int ref_num = 0;
while(true) {
- curr_ref = refs.token('\n',ref_num);
+ curr_ref = refs.token('\n', ref_num);
if (curr_ref.empty())
break;
- fl_add_browser_line(brow,curr_ref.c_str());
+ fl_add_browser_line(brow, curr_ref.c_str());
ref_num++;
}
#endif
fl_select_browser_line(brow, topline);
fl_activate_object(brow);
}
- if (current_view->currentBuffer()->isReadonly()) {
+ 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->currentBuffer()->isSGML()) {
+ if (!current_view->buffer()->isSGML()) {
fl_deactivate_object(fd_form_ref->ref_name);
fl_set_object_lcol(fd_form_ref->ref_name, FL_INACTIVE);
}
}
-void RefHideCB(FL_OBJECT *, long)
+extern "C" void RefHideCB(FL_OBJECT *, long)
{
fl_hide_form(fd_form_ref->form_ref);
}
return;
/* very first check for locking insets*/
- if (current_view->currentBuffer()->the_locking_inset == inset){
- if (current_view->currentBuffer()->text->UpdateInset(inset)){
+ if (current_view->buffer()->the_locking_inset == inset){
+ if (current_view->buffer()->text->UpdateInset(inset)){
current_view->update();
if (mark_dirty){
- if (current_view->currentBuffer()->isLyxClean())
+ if (current_view->buffer()->isLyxClean())
minibuffer->setTimer(4);
- current_view->currentBuffer()->markDirty();
+ current_view->buffer()->markDirty();
}
current_view->updateScrollbar();
return;
/* first check the current buffer */
if (current_view->available()){
current_view->getScreen()->HideCursor();
- current_view->currentBuffer()->update(-3);
- if (current_view->currentBuffer()->text->UpdateInset(inset)){
+ current_view->buffer()->update(-3);
+ if (current_view->buffer()->text->UpdateInset(inset)){
if (mark_dirty)
- current_view->currentBuffer()->update(1);
+ current_view->buffer()->update(1);
else
- current_view->currentBuffer()->update(3);
+ current_view->buffer()->update(3);
return;
}
}
otherwise 0 */
int LockInset(UpdatableInset* inset)
{
- if (!current_view->currentBuffer()->the_locking_inset && inset){
- current_view->currentBuffer()->the_locking_inset = inset;
+ if (!current_view->buffer()->the_locking_inset && inset){
+ current_view->buffer()->the_locking_inset = inset;
return 0;
}
return 1;
void ShowLockedInsetCursor(long x, long y, int asc, int desc)
{
- if (current_view->currentBuffer()->the_locking_inset &&
+ if (current_view->buffer()->the_locking_inset &&
current_view->getScreen()){
- y += current_view->currentBuffer()->text->cursor.y;
+ y += current_view->buffer()->text->cursor.y;
current_view->getScreen()->ShowManualCursor(x, y,
asc, desc);
}
void HideLockedInsetCursor(long x, long y, int asc, int desc)
{
- if (current_view->currentBuffer()->the_locking_inset &&
+ if (current_view->buffer()->the_locking_inset &&
current_view->getScreen()){
- y += current_view->currentBuffer()->text->cursor.y;
+ y += current_view->buffer()->text->cursor.y;
current_view->getScreen()->HideManualCursor(x, y,
asc, desc);
}
void FitLockedInsetCursor(long x, long y, int asc, int desc)
{
- if (current_view->currentBuffer()->the_locking_inset &&
+ if (current_view->buffer()->the_locking_inset &&
current_view->getScreen()){
- y += current_view->currentBuffer()->text->cursor.y;
+ y += current_view->buffer()->text->cursor.y;
if (current_view->getScreen()->FitManualCursor(x, y, asc, desc))
current_view->updateScrollbar();
}
int UnlockInset(UpdatableInset* inset)
{
if (inset &&
- current_view->currentBuffer()->the_locking_inset == inset){
+ current_view->buffer()->the_locking_inset == inset){
inset->InsetUnlock();
- current_view->currentBuffer()->the_locking_inset = 0;
- current_view->currentBuffer()->text->FinishUndo();
+ current_view->buffer()->the_locking_inset = 0;
+ current_view->buffer()->text->FinishUndo();
return 0;
}
return bufferlist.unlockInset(inset);
void LockedInsetStoreUndo(Undo::undo_kind kind)
{
- if (!current_view->currentBuffer()->the_locking_inset)
+ if (!current_view->buffer()->the_locking_inset)
return; // shouldn't happen
if (kind == Undo::EDIT) // in this case insets would not be stored!
kind = Undo::FINISH;
- current_view->currentBuffer()->text->SetUndo(kind,
- current_view->currentBuffer()->text->cursor.par->
- ParFromPos(current_view->currentBuffer()->text->cursor.pos)->previous,
- current_view->currentBuffer()->text->cursor.par->
- ParFromPos(current_view->currentBuffer()->text->cursor.pos)->next);
+ current_view->buffer()->text->SetUndo(kind,
+ current_view->buffer()->text->cursor.par->
+ ParFromPos(current_view->buffer()->text->cursor.pos)->previous,
+ current_view->buffer()->text->cursor.par->
+ ParFromPos(current_view->buffer()->text->cursor.pos)->next);
}
tmp = tmp->next;
}
- /* delete the update list */
+ // delete the update list
while (InsetUpdateList) {
tmp = InsetUpdateList;
InsetUpdateList = InsetUpdateList->next;
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)
+void addNewlineAndDepth(string & file, int const depth)
{
file += '\n';
- for (int j=0;j< depth;j++)
- file += ' ';
+ file.append(depth, ' ');
}