// all these externs should eventually be removed.
extern BufferList bufferlist;
-extern void SmallUpdate(signed char);
-extern unsigned char GetCurrentTextClass();
-extern void BeforeChange();
extern void MenuExport(Buffer *, string const &);
extern LyXAction lyxaction;
filename = file;
filepath = OnlyPath(file);
paragraph = 0;
-#ifndef MOVE_TEXT
- text = 0;
-#endif
- the_locking_inset = 0;
lyx_clean = true;
bak_clean = true;
dvi_clean_orgd = false; // Heinrich Bauer, 23/03/98
dvi_clean_tmpd = false; // Heinrich Bauer, 23/03/98
dep_clean = 0;
read_only = ronly;
- inset_slept = false;
users = 0;
lyxvc.buffer(this);
if (read_only || (lyxrc && lyxrc->use_tempdir)) {
par = tmppar;
}
paragraph = 0;
-#ifndef MOVE_TEXT
- delete text;
-#endif
}
}
-// candidate for move to BufferView
-void Buffer::InsetUnlock()
-{
- if (the_locking_inset) {
- if (!inset_slept) the_locking_inset->InsetUnlock();
- the_locking_inset = 0;
-#ifdef MOVE_TEXT
- users->text->FinishUndo();
-#else
- text->FinishUndo();
-#endif
- inset_slept = false;
- }
-}
-
-
-// candidate for move to BufferView
// Inserts a file into current document
-bool Buffer::insertLyXFile(string const & filen)
+bool BufferView::insertLyXFile(string const & filen)
//
// (c) CHT Software Service GmbH
// Uwe C. Schroeder
{
if (filen.empty()) return false;
- string filename = MakeAbsPath(filen);
+ string fname = MakeAbsPath(filen);
// check if file exist
- FileInfo fi(filename);
+ FileInfo fi(fname);
if (!fi.readable()) {
WriteAlert(_("Error!"),
_("Specified file is unreadable: "),
- MakeDisplayPath(filename, 50));
+ MakeDisplayPath(fname, 50));
return false;
}
- BeforeChange();
+ beforeChange();
- FilePtr myfile(filename, FilePtr::read);
- if (!myfile()) {
+ ifstream ifs(fname.c_str());
+ if (!ifs) {
WriteAlert(_("Error!"),
_("Cannot open specified file: "),
- MakeDisplayPath(filename, 50));
+ MakeDisplayPath(fname, 50));
return false;
}
LyXLex lex(0, 0);
- lex.setFile(myfile);
- int c = fgetc(myfile());
- ungetc(c, myfile);
+ lex.setStream(ifs);
+ char c; ifs.get(c);
+ ifs.putback(c);
bool res = true;
-#ifdef MOVE_TEXT
if (c == '#') {
lyxerr.debug() << "Will insert file with header" << endl;
- res = readFile(lex, users->text->cursor.par);
+ res = buffer()->readFile(lex, text->cursor.par);
} else {
lyxerr.debug() << "Will insert file without header" << endl;
- res = readLyXformat2(lex, users->text->cursor.par);
+ res = buffer()->readLyXformat2(lex, text->cursor.par);
}
-#else
- if (c == '#') {
- lyxerr.debug() << "Will insert file with header" << endl;
- res = readFile(lex, text->cursor.par);
- } else {
- lyxerr.debug() << "Will insert file without header" << endl;
- res = readLyXformat2(lex, text->cursor.par);
- }
-#endif
+
resize();
return res;
}
if(!par) {
par = new LyXParagraph;
} else {
-#ifdef MOVE_TEXT
users->text->BreakParagraph();
return_par = users->text->FirstParagraph();
-#else
- text->BreakParagraph();
- return_par = text->FirstParagraph();
-#endif
pos = 0;
markDirty();
// We don't want to adopt the parameters from the
continue;
else if (token[0] != '\\') {
int n = token.length();
- for (int i = 0; i < n; i++) {
+ for (int i = 0; i < n; ++i) {
par->InsertChar(pos, token[i]);
par->SetFont(pos, font);
- pos++;
+ ++pos;
}
} else if (token == "\\i") {
inset = new InsetLatexAccent;
font = LyXFont(LyXFont::ALL_INHERIT);
} else if (token == "\\begin_float") {
tmpret = lex.FindToken(string_footnotekinds);
- if (tmpret == -1) tmpret++;
+ if (tmpret == -1) ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT)
footnotekind = static_cast<LyXParagraph::footnote_kind>(tmpret); // bad
if (footnotekind == LyXParagraph::FOOTNOTE
else
footnoteflag = LyXParagraph::OPEN_FOOTNOTE;
} else if (token == "\\begin_deeper") {
- depth++;
+ ++depth;
} else if (token == "\\end_deeper") {
if (!depth) {
lex.printError("\\end_deeper: "
"depth is already null");
}
else
- depth--;
+ --depth;
} else if (token == "\\begin_preamble") {
params.readPreamble(lex);
} else if (token == "\\textclass") {
lex.EatLine();
- pair<bool, LyXTextClassList::ClassList::size_type> pp =
+ pair<bool, LyXTextClassList::size_type> pp =
textclasslist.NumberOfClass(lex.GetString());
if (pp.first) {
params.textclass = pp.second;
lex.EatLine();
params.options = lex.GetString();
} else if (token == "\\language") {
- params.readLanguage(lex);
+ params.readLanguage(lex);
} else if (token == "\\fontencoding") {
lex.EatLine();
} else if (token == "\\inputencoding") {
} else if (token == "\\defskip") {
lex.nextToken();
params.defskip = VSpace(lex.GetString());
- } else if (token == "\\no_isolatin1") {
+ } else if (token == "\\no_isolatin1") { // obsolete
lex.nextToken();
- } else if (token == "\\no_babel") {
+ } else if (token == "\\no_babel") { // obsolete
lex.nextToken();
- } else if (token == "\\no_epsfig") {
+ } else if (token == "\\no_epsfig") { // obsolete
lex.nextToken();
} else if (token == "\\epsfig") { // obsolete
// Indeed it is obsolete, but we HAVE to be backwards
} else if (token == "\\tocdepth") {
lex.nextToken();
params.tocdepth = lex.GetInteger();
- } else if (token == "\\baselinestretch") { // now obsolete
+ } else if (token == "\\baselinestretch") { // obsolete
lex.nextToken(); // should not be used directly
// anymore.
// Will probably keep a kind of support just for
} else if (token == "\\float_placement") {
lex.nextToken();
params.float_placement = lex.GetString();
- } else if (token == "\\cursor") {
+ } else if (token == "\\cursor") { // obsolete
// this is obsolete, so we just skip it.
lex.nextToken();
} else if (token == "\\family") {
} else if (token == "\\align") {
tmpret = lex.FindToken(string_align);
if (tmpret == -1) tmpret++;
- if (tmpret != LYX_LAYOUT_DEFAULT) {
+ if (tmpret != LYX_LAYOUT_DEFAULT) { // tmpret != 99 ???
tmpret2 = 1;
- for (; tmpret>0; tmpret--)
+ for (; tmpret > 0; --tmpret)
tmpret2 = tmpret2 * 2;
par->align = LyXAlignment(tmpret2);
}
- } else if (token == "\\added_space_top"){
+ } else if (token == "\\added_space_top") {
lex.nextToken();
par->added_space_top = lex.GetString();
} else if (token == "\\added_space_bottom") {
par->InsertInset(pos, inset);
par->SetFont(pos, font);
pos++;
+#if 0
} else if (tmptok == "Label") {
// Kept for compability. Remove in 0.13.
if (lex.EatLine()) {
par->SetFont(pos, font);
pos++;
}
+#endif
} else if (tmptok == "Info") {
inset = new InsetInfo;
inset->Read(lex);
if (!inscmd.getOptions().empty() || !inscmd.getContents().empty()) {
inset = new InsetRef(inscmd, this);
}
- /* This condition comes from a temporary solution
- to the latexdel ref inset that was transformed to an empty ref
- inset plus the body surronded by latexdel insets */
+ // This condition comes from a
+ // temporary solution to the latexdel
+ // ref inset that was transformed to
+ // an empty ref inset plus the body
+ // surronded by latexdel insets
else {
string cont, opt, tmptmptok, cmdname;
lex.next();
inset = new InsetPrintIndex(this);
} else if (inscmd.getCmdName() == "lyxparent") {
inset = new InsetParent(inscmd.getContents(), this);
- } else
+ }
+#if 0
+ // Do we need this at all now?
+ else
// The following three are only for compatibility
if (inscmd.getCmdName() == "-") {
inset = new InsetSpecialChar(InsetSpecialChar::HYPHENATION);
inset = new InsetSpecialChar(InsetSpecialChar::LDOTS);
} else
inset = inscmd.Clone();
+#endif
if (inset) {
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
- pos++;
+ ++pos;
}
}
} else if (token == "\\InsetQuotes") {
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
- pos++;
+ ++pos;
#if 0
} else if (token == "\\InsetLatex") {
inset = new InsetLatex;
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\InsetLatexDel") {
lex.printError(_("Warning: Ignoring Old Inset"));
#endif
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\SpecialChar") {
inset = new InsetSpecialChar;
inset->Read(lex);
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\Figure") {
inset = new InsetFig(100, 100, this);
inset->Read(lex);
par->InsertChar(pos, LyXParagraph::META_INSET);
par->InsertInset(pos, inset);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\newline") {
par->InsertChar(pos, LyXParagraph::META_NEWLINE);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\LyXTable") {
par->table = new LyXTable(lex);
} else if (token == "\\hfill") {
par->InsertChar(pos, LyXParagraph::META_HFILL);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\protected_separator") {
par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR);
par->SetFont(pos, font);
- pos++;
+ ++pos;
} else if (token == "\\bibitem") { // ale970302
if (!par->bibkey)
par->bibkey = new InsetBibKey;
}else if (token == "\\backslash") {
par->InsertChar(pos, '\\');
par->SetFont(pos, font);
- pos++;
+ ++pos;
}else if (token == "\\the_end") {
the_end_read = true;
} else {
lex.printError("Unknown token `$$Token'. "
"Inserting as text.");
int n = token.length();
- for (int i = 0; i < n; i++) {
+ for (int i = 0; i < n; ++i) {
par->InsertChar(pos, token[i]);
par->SetFont(pos, font);
- pos++;
+ ++pos;
}
}
}
// Returns false if unsuccesful
-bool Buffer::writeFile(string const & filename, bool flag)
+bool Buffer::writeFile(string const & fname, bool flag)
{
// if flag is false writeFile will not create any GUI
// warnings, only cerr.
// Needed for autosave in background or panic save (Matthias 120496)
- if (read_only && (filename == this->filename)) {
+ if (read_only && (fname == filename)) {
// Here we should come with a question if we should
// perform the write anyway.
if (flag)
lyxerr << _("Error! Document is read-only: ")
- << filename << endl;
+ << fname << endl;
else
WriteAlert(_("Error! Document is read-only: "),
- filename);
+ fname);
return false;
}
- FileInfo finfo(filename);
+ FileInfo finfo(fname);
if (finfo.exist() && !finfo.writable()) {
// Here we should come with a question if we should
// try to do the save anyway. (i.e. do a chmod first)
if (flag)
lyxerr << _("Error! Cannot write file: ")
- << filename << endl;
+ << fname << endl;
else
WriteFSAlert(_("Error! Cannot write file: "),
- filename);
+ fname);
return false;
}
- ofstream ofs(filename.c_str());
+ ofstream ofs(fname.c_str());
if (!ofs) {
if (flag)
lyxerr << _("Error! Cannot open file: ")
- << filename << endl;
+ << fname << endl;
else
WriteFSAlert(_("Error! Cannot open file: "),
- filename);
+ fname);
return false;
}
// The top of the file should not be written by params.
}
-void Buffer::writeFileAscii(string const & filename, int linelen)
+void Buffer::writeFileAscii(string const & fname, int linelen)
{
LyXFont font1, font2;
Inset * inset;
long fpos = 0;
bool ref_printed = false;
- ofstream ofs(filename.c_str());
+ ofstream ofs(fname.c_str());
if (!ofs) {
- WriteFSAlert(_("Error: Cannot write file:"), filename);
+ WriteFSAlert(_("Error: Cannot write file:"), fname);
return;
}
}
-void Buffer::makeLaTeXFile(string const & filename,
+void Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
bool nice, bool only_body)
{
lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
- params.textclass = GetCurrentTextClass();
+
+ // How the **** can this be needed?
+ //params.textclass = current_view->buffer()->params.textclass;
+
niceFile = nice; // this will be used by Insetincludes.
tex_code_break_column = lyxrc->ascii_linelen;
LyXTextClass const & tclass =
textclasslist.TextClass(params.textclass);
- ofstream ofs(filename.c_str());
+ ofstream ofs(fname.c_str());
if (!ofs) {
- WriteFSAlert(_("Error: Cannot open file: "), filename);
+ WriteFSAlert(_("Error: Cannot open file: "), fname);
return;
}
string LFile;
if (!only_body && nice) {
- LFile += "%% This LaTeX-file was created by <";
- LFile += userName + "> " + date();
- LFile += "%% LyX 1.0 (C) 1995-1999 by Matthias Ettrich and the LyX Team\n";
- LFile += "\n%% Do not edit this file unless you know what you are doing.\n";
- texrow.newline();
- texrow.newline();
+ LFile += "%% " LYX_DOCVERSION " created this file. "
+ "For more info, see http://www.lyx.org/.\n";
+ LFile += "%% Do not edit unless you really know what you are doing.\n";
texrow.newline();
texrow.newline();
}
lyxerr.debug() << "lyx header finished" << endl;
// There are a few differences between nice LaTeX and usual files:
- // usual is \batchmode, uses \listfiles and has a
+ // usual is \batchmode and has a
// special input@path to allow the including of figures
// with either \input or \includegraphics (what figinsets do).
// batchmode is not set if there is a tex_code_break_column.
LFile += "\\batchmode\n"; // changed
// from \nonstopmode
texrow.newline();
- // We don't need listfiles anymore
- //LFile += "\\listfiles\n";
- //texrow.newline();
}
if (!original_path.empty()) {
LFile += "\\makeatletter\n";
void Buffer::sgmlOpenTag(ostream & os, int depth,
string const & latexname) const
{
- static char * space[] = {" "," ", " ", " ", " ", " ",
- " ",
- " ", " ", " ",
- " "};
-
- os << space[depth] << "<" << latexname << ">\n";
+ os << string(depth, ' ') << "<" << latexname << ">\n";
}
void Buffer::sgmlCloseTag(ostream & os, int depth,
string const & latexname) const
{
- static char * space[] = {" ", " ", " ", " ", " ",
- " ", " ", " ",
- " ", " ", " "};
-
- os << space[depth] << "</" << latexname << ">\n";
+ os << string(depth, ' ') << "</" << latexname << ">\n";
}
-void Buffer::makeLinuxDocFile(string const & filename, int column)
+void Buffer::makeLinuxDocFile(string const & fname, int column)
{
LyXParagraph * par = paragraph;
int depth = 0; /* paragraph depth */
- ofstream ofs(filename.c_str());
+ ofstream ofs(fname.c_str());
if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), filename);
+ WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return;
}
while (par) {
int desc_on = 0; /* description mode*/
LyXLayout const & style =
- textclasslist.Style(GetCurrentTextClass(),
+ textclasslist.Style(users->buffer()->params.textclass,
par->layout);
par->AutoDeleteInsets();
}
}
- /* environment tag closing */
+ // environment tag closing
for( ; depth > par->depth; --depth) {
sgmlCloseTag(ofs, depth, environment_stack[depth]);
environment_stack[depth].clear();
}
- /* write opening SGML tags */
+ // write opening SGML tags
switch(style.latextype) {
case LATEX_PARAGRAPH:
if(depth == par->depth
void Buffer::push_tag(ostream & os, char const * tag,
int & pos, char stack[5][3])
{
- int j;
-
/* pop all previous tags */
- for (j = pos; j >= 0; --j)
+ for (int j = pos; j >= 0; --j)
os << "</" << stack[j] << ">";
/* add new tag */
sprintf(stack[++pos], "%s", tag);
/* push all tags */
- for (j = 0; j <= pos; ++j)
- os << "<" << stack[j] << ">";
+ for (int i = 0; i <= pos; ++i)
+ os << "<" << stack[i] << ">";
}
void Buffer::pop_tag(ostream & os, char const * tag,
int & pos, char stack[5][3])
{
- int j;
-
// pop all tags till specified one
- for (j = pos; (j >= 0) && (strcmp(stack[j], tag)); --j)
+ for (int j = pos; (j >= 0) && (strcmp(stack[j], tag)); --j)
os << "</" << stack[j] << ">";
// closes the tag
os << "</" << tag << ">";
// push all tags, but the specified one
- for (j = j + 1; j <= pos; ++j) {
- os << "<" << stack[j] << ">";
- strcpy(stack[j-1], stack[j]);
+ for (int i = 0; i <= pos; ++i) {
+ os << "<" << stack[i] << ">";
+ strcpy(stack[i - 1], stack[i]);
}
--pos;
}
enum { MAX_NEST_LEVEL = 25};
-void Buffer::makeDocBookFile(string const & filename, int column)
+void Buffer::makeDocBookFile(string const & fname, int column)
{
LyXParagraph * par = paragraph;
tex_code_break_column = column;
- ofstream ofs(filename.c_str());
+ ofstream ofs(fname.c_str());
if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), filename);
+ WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return;
}
- //ResetTexRow();
texrow.reset();
ofs << "<!doctype " << top_element
while (par) {
int desc_on= 0; /* description mode*/
- LyXLayout const & style = textclasslist.Style(GetCurrentTextClass(),
+ LyXLayout const & style = textclasslist.Style(users->buffer()->params.textclass,
par->layout);
par->AutoDeleteInsets();
}
-// candidate for move to BufferView
-bool Buffer::removeAutoInsets()
+bool BufferView::removeAutoInsets()
{
- LyXParagraph *par = paragraph;
+ LyXParagraph * par = buffer()->paragraph;
-#ifdef MOVE_TEXT
- LyXCursor cursor = users->text->cursor;
-#else
LyXCursor cursor = text->cursor;
-#endif
LyXCursor tmpcursor = cursor;
cursor.par = tmpcursor.par->ParFromPos(tmpcursor.pos);
cursor.pos = tmpcursor.par->PositionInParFromPos(tmpcursor.pos);
if (par->AutoDeleteInsets()){
a = true;
if (par->footnoteflag != LyXParagraph::CLOSED_FOOTNOTE){
-#ifdef MOVE_TEXT
- /* this is possible now, since SetCursor takes
- care about footnotes */
- users->text->SetCursorIntern(par, 0);
- users->text->RedoParagraphs(users->text->cursor, users->text->cursor.par->Next());
- users->text->FullRebreak();
-#else
- /* this is possible now, since SetCursor takes
- care about footnotes */
+ // this is possible now, since SetCursor takes
+ // care about footnotes
text->SetCursorIntern(par, 0);
- text->RedoParagraphs(text->cursor, text->cursor.par->Next());
+ text->RedoParagraphs(text->cursor,
+ text->cursor.par->Next());
text->FullRebreak();
-#endif
}
}
par = par->next;
}
- /* avoid forbidden cursor positions caused by error removing */
+ // avoid forbidden cursor positions caused by error removing
if (cursor.pos > cursor.par->Last())
cursor.pos = cursor.par->Last();
-#ifdef MOVE_TEXT
- users->text->SetCursorIntern(cursor.par, cursor.pos);
-#else
text->SetCursorIntern(cursor.par, cursor.pos);
-#endif
return a;
}
int Buffer::runLaTeX()
{
-#ifdef MOVE_TEXT
if (!users->text) return 0;
-#else
- if (!text) return 0;
-#endif
ProhibitInput();
users->owner()->getMiniBuffer()->Set(_("Running LaTeX..."));
// Remove all error insets
- bool a = removeAutoInsets();
+ bool a = users->removeAutoInsets();
// Always generate the LaTeX file
makeLaTeXFile(name, org_path, false);
} else if ((res & LaTeX::ERRORS)) {
users->owner()->getMiniBuffer()->Set(_("Done"));
// Insert all errors as errors boxes
- insertErrors(terr);
+ users->insertErrors(terr);
// Dvi should also be kept dirty if the latex run
// ends up with errors. However it should be possible
int Buffer::runLiterate()
{
-#ifdef MOVE_TEXT
if (!users->text) return 0;
-#else
- if (!text) return 0;
-#endif
ProhibitInput();
users->owner()->getMiniBuffer()->Set(_("Running Literate..."));
// Remove all error insets
- bool a = removeAutoInsets();
+ bool a = users->removeAutoInsets();
// generate the Literate file if necessary
if (!isDviClean() || a) {
} else if ((res & Literate::ERRORS)) {
users->owner()->getMiniBuffer()->Set(_("Done"));
// Insert all errors as errors boxes
- insertErrors(terr);
+ users->insertErrors(terr);
// Dvi should also be kept dirty if the latex run
// ends up with errors. However it should be possible
int Buffer::buildProgram()
{
-#ifdef MOVE_TEXT
if (!users->text) return 0;
-#else
- if (!text) return 0;
-#endif
ProhibitInput();
users->owner()->getMiniBuffer()->Set(_("Building Program..."));
// Remove all error insets
- bool a = removeAutoInsets();
+ bool a = users->removeAutoInsets();
// generate the LaTeX file if necessary
if (!isNwClean() || a) {
} else if ((res & Literate::ERRORS)) {
users->owner()->getMiniBuffer()->Set(_("Done"));
// Insert all errors as errors boxes
- insertErrors(terr);
+ users->insertErrors(terr);
// Literate files should also be kept dirty if the literate
// command run ends up with errors.
// Other flags: -wall -v0 -x
int Buffer::runChktex()
{
-#ifdef MOVE_TEXT
if (!users->text) return 0;
-#else
- if (!text) return 0;
-#endif
ProhibitInput();
users->owner()->getMiniBuffer()->Set(_("Running chktex..."));
// Remove all error insets
- bool a = removeAutoInsets();
+ bool a = users->removeAutoInsets();
// Generate the LaTeX file if neccessary
if (!isDviClean() || a) {
_("Could not run with file:"), name);
} else if (res > 0) {
// Insert all errors as errors boxes
- insertErrors(terr);
+ users->insertErrors(terr);
}
// if we removed error insets before we ran chktex or if we inserted
}
-extern void AllFloats(char, char);
-
-
-// candidate for move to BufferView
-void Buffer::insertErrors(TeXErrors & terr)
+void BufferView::insertErrors(TeXErrors & terr)
{
-#ifdef MOVE_TEXT
- // Save the cursor position
- LyXCursor cursor = users->text->cursor;
-#else
// Save the cursor position
LyXCursor cursor = text->cursor;
-#endif
// This is drastic, but it's the only fix, I could find. (Asger)
- AllFloats(1, 0);
- AllFloats(1, 1);
+ allFloats(1, 0);
+ allFloats(1, 1);
for (TeXErrors::Errors::const_iterator cit = terr.begin();
cit != terr.end();
int tmpid = -1;
int tmppos = -1;
- texrow.getIdFromRow(errorrow, tmpid, tmppos);
+ buffer()->texrow.getIdFromRow(errorrow, tmpid, tmppos);
LyXParagraph * texrowpar = 0;
-#ifdef MOVE_TEXT
- if (tmpid == -1) {
- texrowpar = users->text->FirstParagraph();
- tmppos = 0;
- } else {
- texrowpar = users->text->GetParFromID(tmpid);
- }
-#else
if (tmpid == -1) {
texrowpar = text->FirstParagraph();
tmppos = 0;
} else {
texrowpar = text->GetParFromID(tmpid);
}
-#endif
if (texrowpar == 0)
continue;
InsetError * new_inset = new InsetError(msgtxt);
-#ifdef MOVE_TEXT
- users->text->SetCursorIntern(texrowpar, tmppos);
- users->text->InsertInset(new_inset);
- users->text->FullRebreak();
- }
- // Restore the cursor position
- users->text->SetCursorIntern(cursor.par, cursor.pos);
-#else
text->SetCursorIntern(texrowpar, tmppos);
text->InsertInset(new_inset);
text->FullRebreak();
}
// Restore the cursor position
text->SetCursorIntern(cursor.par, cursor.pos);
-#endif
}
-// candidate for move to BufferView
-void Buffer::setCursorFromRow (int row)
+void BufferView::setCursorFromRow(int row)
{
int tmpid = -1;
int tmppos = -1;
- texrow.getIdFromRow(row, tmpid, tmppos);
+ buffer()->texrow.getIdFromRow(row, tmpid, tmppos);
LyXParagraph * texrowpar;
-#ifdef MOVE_TEXT
- if (tmpid == -1) {
- texrowpar = users->text->FirstParagraph();
- tmppos = 0;
- } else {
- texrowpar = users->text->GetParFromID(tmpid);
- }
- users->text->SetCursor(texrowpar, tmppos);
-#else
if (tmpid == -1) {
texrowpar = text->FirstParagraph();
tmppos = 0;
texrowpar = text->GetParFromID(tmpid);
}
text->SetCursor(texrowpar, tmppos);
-#endif
}
}
-#ifndef MOVE_TEXT
-// candidate for move to BufferView
-void Buffer::update(signed char f)
-{
- if (!users) return;
-
- users->owner()->updateLayoutChoice();
- if (!text->selection && f > -3)
- text->sel_cursor = text->cursor;
-
- FreeUpdateTimer();
- text->FullRebreak();
-
- users->update();
-
- if (f != 3 && f != -3) {
- users->fitCursor();
- users->updateScrollbar();
- }
-
- if (f == 1 || f == -1) {
- if (isLyxClean()) {
- markDirty();
- users->owner()->getMiniBuffer()->setTimer(4);
- } else {
- markDirty();
- }
- }
-}
-#endif
-
void Buffer::validate(LaTeXFeatures & features)
{
LyXParagraph * par = paragraph;
}
#endif
-#ifdef MOVE_TEXT
-// candidate for move to BufferView
-void Buffer::insertInset(Inset * inset, string const & lout,
- bool no_table)
-{
- // check for table/list in tables
- if (no_table && users->text->cursor.par->table){
- WriteAlert(_("Impossible Operation!"),
- _("Cannot insert table/list in table."),
- _("Sorry."));
- return;
- }
- // not quite sure if we want this...
- users->text->SetCursorParUndo();
- users->text->FreezeUndo();
-
- BeforeChange();
- if (!lout.empty()) {
- users->update(-2);
- users->text->BreakParagraph();
- users->update(-1);
-
- if (users->text->cursor.par->Last()) {
- users->text->CursorLeft();
-
- users->text->BreakParagraph();
- users->update(-1);
- }
-
- int lay = textclasslist.NumberOfLayout(params.textclass,
- lout).second;
- if (lay == -1) // layout not found
- // use default layout "Standard" (0)
- lay = 0;
-
- users->text->SetLayout(lay);
-
- users->text->SetParagraph(0, 0,
- 0, 0,
- VSpace(VSpace::NONE), VSpace(VSpace::NONE),
- LYX_ALIGN_LAYOUT,
- string(),
- 0);
- users->update(-1);
-
- users->text->current_font.setLatex(LyXFont::OFF);
- }
-
- users->text->InsertInset(inset);
- users->update(-1);
- users->text->UnFreezeUndo();
-}
-#else
-void Buffer::insertInset(Inset * inset, string const & lout,
+void BufferView::insertInset(Inset * inset, string const & lout,
bool no_table)
{
// check for table/list in tables
text->SetCursorParUndo();
text->FreezeUndo();
- BeforeChange();
+ beforeChange();
if (!lout.empty()) {
update(-2);
text->BreakParagraph();
update(-1);
}
- int lay = textclasslist.NumberOfLayout(params.textclass,
+ int lay = textclasslist.NumberOfLayout(buffer()->params.textclass,
lout).second;
if (lay == -1) // layout not found
// use default layout "Standard" (0)
text->UnFreezeUndo();
}
-#endif
+
// Open and lock an updatable inset
-// candidate for move to BufferView
-void Buffer::open_new_inset(UpdatableInset * new_inset)
+void BufferView::open_new_inset(UpdatableInset * new_inset)
{
-#ifdef MOVE_TEXT
- BeforeChange();
- users->text->FinishUndo();
- insertInset(new_inset);
- users->text->CursorLeft();
- users->update(1);
- new_inset->Edit(0, 0);
-#else
- BeforeChange();
+ beforeChange();
text->FinishUndo();
insertInset(new_inset);
text->CursorLeft();
update(1);
new_inset->Edit(0, 0);
-#endif
}
-/* This function should be in Buffer because it's a buffer's property (ale) */
+// This function should be in Buffer because it's a buffer's property (ale)
string Buffer::getIncludeonlyList(char delim)
{
string lst;
}
-/* This is also a buffer property (ale) */
+// This is also a buffer property (ale)
string Buffer::getReferenceList(char delim)
{
/// if this is a child document and the parent is already loaded
}
-/* This is also a buffer property (ale) */
+// This is also a buffer property (ale)
string Buffer::getBibkeyList(char delim)
{
/// if this is a child document and the parent is already loaded
if (inset-> LyxCode() == Inset::BIBTEX_CODE) {
if (!bibkeys.empty())
bibkeys += delim;
- bibkeys += static_cast<InsetBibtex*>(inset)->getKeys();
+ bibkeys += static_cast<InsetBibtex*>(inset)->getKeys(delim);
} else if (inset-> LyxCode() == Inset::INCLUDE_CODE) {
- string bk = static_cast<InsetInclude*>(inset)->getKeys();
+ string bk = static_cast<InsetInclude*>(inset)->getKeys(delim);
if (!bk.empty()) {
if (!bibkeys.empty())
bibkeys += delim;
}
-// candidate for move to BufferView
/* This is also a buffer property (ale) */
// Not so sure about that. a goto Label function can not be buffer local, just
// think how this will work in a multiwindo/buffer environment, all the
// cursors in all the views showing this buffer will move. (Lgb)
// OK, then no cursor action should be allowed in buffer. (ale)
-bool Buffer::gotoLabel(string const & label)
+bool BufferView::gotoLabel(string const & label)
{
- LyXParagraph * par = paragraph;
+ LyXParagraph * par = buffer()->paragraph;
LyXParagraph::size_type pos;
Inset * inset;
while (par) {
while ((inset = par->ReturnNextInsetPointer(pos))){
for (int i = 0; i < inset->GetNumberOfLabels(); i++) {
if (label == inset->getLabel(i)) {
-#ifdef MOVE_TEXT
- BeforeChange();
- users->text->SetCursor(par, pos);
- users->text->sel_cursor = users->text->cursor;
- users->update(0);
- return true;
-#else
- BeforeChange();
+ beforeChange();
text->SetCursor(par, pos);
text->sel_cursor = text->cursor;
update(0);
return true;
-#endif
}
}
pos++;
}
}
-void Buffer::Dispatch(const string & command)
+
+void Buffer::Dispatch(string const & command)
{
// Split command string into command and argument
string cmd, line = frontStrip(command);
Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str());
}
-void Buffer::Dispatch(int action, const string & argument)
+
+void Buffer::Dispatch(int action, string const & argument)
{
switch (action) {
case LFUN_EXPORT:
MenuExport(this, argument);
break;
- break;
default:
lyxerr << "A truly unknown func!" << endl;
break;
} // end of switch
-
}