From: Lars Gullik Bjønnes Date: Mon, 24 Apr 2000 20:58:23 +0000 (+0000) Subject: several small patches and some fixes, read the ChangeLog X-Git-Tag: 1.6.10~22288 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c6150425e56563ab9bb311b5785efc5e9d4928da;p=features.git several small patches and some fixes, read the ChangeLog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@688 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 641e243b0e..ff85cbf8f3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2000-04-23 Dekel Tsur + + * A lot of files: Added Ascii(ostream &) methods to all inset + classes. Used when exporting to ASCII. + + * src/buffer.C (writeFileAscii,RoffAsciiTable) + * src/paragraph.C (RoffContTableRows): Use the Ascii() methods + instead of Latex() + + * src/text2.C (ToggleFree): Disabled implicit word selection when + there is a change in the language + + * src/insets/insetspecialchar.C (Linuxdoc,DocBook): Fixed a bug: + no output was generated for end-of-sentence inset. + + * src/insets/lyxinset.h + * src/buffer.C + * src/lyxfunc.C + * src/paragraph.C: Removed the insetnumber code + + * src/text.C (SelectWordWhenUnderCursor): Cleaned the code. + +2000-04-22 Lars Gullik Bjønnes + + * src/buffer.C (parseSingleLyXformat2Token): remove no_isolatin1, + no_babel and no_epsfig completely from the file. + (parseSingleLyXformat2Token): add handling for per-paragraph + spacing as written by klyx. + + * src/insets/figinset.C: applied patch by Andre. Made it work with + ostringstream too. + 2000-04-20 Juergen Vigna * src/insets/insettext.C (cutSelection): diff --git a/src/BufferView2.C b/src/BufferView2.C index 6bb8540835..64e0c2ec81 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -508,14 +508,8 @@ void BufferView::newline() if (available()) { hideCursor(); update(-2); -#if 0 - InsetSpecialChar * new_inset = - new InsetSpecialChar(InsetSpecialChar::NEWLINE); - insertInset(new_inset); -#else text->InsertChar(LyXParagraph::META_NEWLINE); update(-1); -#endif } } @@ -525,14 +519,9 @@ void BufferView::protectedBlank() if (available()) { hideCursor(); update(-2); -#if 1 InsetSpecialChar * new_inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); insertInset(new_inset); -#else - text->InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR); - update(-1); -#endif } } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 40564cfffd..300c386f14 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -939,7 +939,8 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, unsigned int button) * If hit, the coordinates are changed relative to the inset. * Otherwise coordinates are not changed, and false is returned. */ -Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y, unsigned int /* button */) +Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y, + unsigned int /* button */) { if (!screen) return 0; @@ -948,9 +949,10 @@ Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y, unsigned int /* butto LyXCursor cursor; bv_->text->SetCursorFromCoordinates(cursor, x, y_tmp); +#if 0 // Are you planning to use this Jürgen? (Lgb) bool move_cursor = ((cursor.par != bv_->text->cursor.par) || (cursor.pos != bv_->text->cursor.pos)); - +#endif if (cursor.pos < cursor.par->Last() && cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET && cursor.par->GetInset(cursor.pos) diff --git a/src/buffer.C b/src/buffer.C index 683b58d361..d33996681b 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -69,7 +69,6 @@ #include "insets/insetspecialchar.h" #include "insets/figinset.h" #include "insets/insettext.h" -//#include "insets/insetnumber.h" #include "insets/insetert.h" #include "insets/insetgraphics.h" #include "insets/insetfoot.h" @@ -301,27 +300,26 @@ bool Buffer::readLyXformat2(LyXLex & lex, LyXParagraph * par) } -bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, - LyXParagraph *& return_par, - string const & token, int & pos, - char & depth, LyXFont & font, - LyXParagraph::footnote_flag & footnoteflag, - LyXParagraph::footnote_kind & footnotekind) +bool +Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, + LyXParagraph *& return_par, + string const & token, int & pos, + char & depth, LyXFont & font, + LyXParagraph::footnote_flag & footnoteflag, + LyXParagraph::footnote_kind & footnotekind) { - Inset * inset = 0; int tmpret, tmpret2; - string tmptok; bool the_end_read = false; - + if (token[0] != '\\') { - int n = token.length(); - for (int i = 0; i < n; ++i) { - par->InsertChar(pos, token[i]); + for (string::const_iterator cit = token.begin(); + cit != token.end(); ++cit) { + par->InsertChar(pos, (*cit)); par->SetFont(pos, font); ++pos; } } else if (token == "\\i") { - inset = new InsetLatexAccent; + Inset * inset = new InsetLatexAccent; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); @@ -343,7 +341,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, if (pp.first) { par->layout = pp.second; } else { // layout not found - // use default layout "Standard" (0) + // use default layout "Standard" (0) par->layout = 0; } // Test whether the layout is obsolete. @@ -458,14 +456,6 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } else if (token == "\\defskip") { lex.nextToken(); params.defskip = VSpace(lex.GetString()); -#if 0 - } else if (token == "\\no_isolatin1") { // obsolete - lex.nextToken(); - } else if (token == "\\no_babel") { // obsolete - lex.nextToken(); - } else if (token == "\\no_epsfig") { // obsolete - lex.nextToken(); -#endif } else if (token == "\\epsfig") { // obsolete // Indeed it is obsolete, but we HAVE to be backwards // compatible until 0.14, because otherwise all figures @@ -625,15 +615,18 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } else if (token == "\\tocdepth") { lex.nextToken(); params.tocdepth = lex.GetInteger(); +#if 0 } else if (token == "\\baselinestretch") { // obsolete lex.nextToken(); // should not be used directly // anymore. // Will probably keep a kind of support just for // compability. params.spacing.set(Spacing::Other, lex.GetFloat()); +#endif } else if (token == "\\spacing") { lex.next(); string tmp = strip(lex.GetString()); + Spacing::Space tmp_space = Spacing::Default; if (tmp == "single") { params.spacing.set(Spacing::Single); } else if (tmp == "onehalf") { @@ -647,6 +640,13 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } else { lex.printError("Unknown spacing token: '$$Token'"); } + // Small hack so that files written with klyx will be + // parsed correctly. + if (return_par) { + par->spacing.set(tmp_space); + } else { + params.spacing.set(tmp_space); + } } else if (token == "\\paragraph_spacing") { lex.next(); string tmp = strip(lex.GetString()); @@ -666,9 +666,11 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } else if (token == "\\float_placement") { lex.nextToken(); params.float_placement = lex.GetString(); +#if 0 } else if (token == "\\cursor") { // obsolete // this is obsolete, so we just skip it. lex.nextToken(); +#endif } else if (token == "\\family") { lex.next(); font.setLyXFamily(lex.GetString()); @@ -704,6 +706,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, font.setLanguage(params.language_info); lex.printError("Unknown language `$$Token'"); } +#if 0 } else if (token == "\\direction") { // obsolete if (format >= 2.16) lex.printError("Command \\direction is obsolete"); @@ -718,6 +721,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, font.setLanguage(params.language_info); else lex.printError("Unknown direction `$$Token'"); +#endif } else if (token == "\\emph") { lex.next(); font.setEmph(font.setLyXMisc(lex.GetString())); @@ -784,89 +788,80 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, //the inset isn't it? Lgb. } else if (token == "\\begin_inset") { lex.next(); - tmptok = lex.GetString(); + string tmptok = lex.GetString(); /* test the different insets */ if (tmptok == "Quotes") { - inset = new InsetQuotes; + Inset * inset = new InsetQuotes; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "\\i") { - inset = new InsetLatexAccent; + Inset * inset = new InsetLatexAccent; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "FormulaMacro") { - inset = new InsetFormulaMacro; + Inset * inset = new InsetFormulaMacro; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "Formula") { - inset = new InsetFormula; + Inset * inset = new InsetFormula; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "Figure") { - inset = new InsetFig(100, 100, this); + Inset * inset = new InsetFig(100, 100, this); inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "Info") { - inset = new InsetInfo; + Inset * inset = new InsetInfo; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "Include") { - inset = new InsetInclude(string(), this); + Inset * inset = new InsetInclude(string(), this); inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "ERT") { - inset = new InsetERT(this); + Inset * inset = new InsetERT(this); inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "Text") { - inset = new InsetText(this); + Inset * inset = new InsetText(this); inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; -#if 0 - } else if (tmptok == "Number") { - inset = new InsetNumber(this); - inset->Read(lex); - par->InsertChar(pos, LyXParagraph::META_INSET); - par->InsertInset(pos, inset); - par->SetFont(pos, font); - ++pos; -#endif } else if (tmptok == "Foot") { - inset = new InsetFoot(this); + Inset * inset = new InsetFoot(this); inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (tmptok == "GRAPHICS") { - inset = new InsetGraphics; + Inset * inset = new InsetGraphics; //inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); @@ -874,6 +869,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } else if (tmptok == "LatexCommand") { InsetCommand inscmd; inscmd.Read(lex); + Inset * inset; if (inscmd.getCmdName() == "cite") { inset = new InsetCitation(inscmd.getContents(), inscmd.getOptions()); } else if (inscmd.getCmdName() == "bibitem") { @@ -973,14 +969,16 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } } } else if (token == "\\InsetQuotes") { - inset = new InsetQuotes; + lyxerr << "InsetQuotes" << endl; + Inset * inset = new InsetQuotes; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; } else if (token == "\\InsetFormula") { - inset = new InsetFormula; + lyxerr << "InsetFormula" << endl; + Inset * inset = new InsetFormula; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); @@ -992,8 +990,7 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->GetLayout()); // Insets don't make sense in a free-spacing context! ---Kayvan - if (layout.free_spacing) - { + if (layout.free_spacing) { if (lex.IsOK()) { string next_token; lex.next(); @@ -1008,13 +1005,11 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, lex.printError("Token `$$Token' " "is in free space " "paragraph layout!"); - pos--; + --pos; } } - } - else - { - inset = new InsetSpecialChar; + } else { + Inset * inset = new InsetSpecialChar; inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); @@ -1022,22 +1017,16 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, } ++pos; } else if (token == "\\Figure") { - inset = new InsetFig(100, 100, this); + lyxerr << "Figure" << endl; + Inset * inset = new InsetFig(100, 100, this); inset->Read(lex); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); ++pos; - } else if (token == "\\newline") { // soon obsolete -#if 1 + } else if (token == "\\newline") { par->InsertChar(pos, LyXParagraph::META_NEWLINE); par->SetFont(pos, font); -#else - inset = new InsetSpecialChar(InsetSpecialChar::NEWLINE); - par->InsertChar(pos, LyXParagraph::META_INSET); - par->InsertInset(pos, inset); - par->SetFont(pos, font); -#endif ++pos; } else if (token == "\\LyXTable") { par->table = new LyXTable(lex); @@ -1046,7 +1035,6 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->SetFont(pos, font); ++pos; } else if (token == "\\protected_separator") { // obsolete -#if 1 LyXLayout const & layout = textclasslist.Style(params.textclass, par->GetLayout()); @@ -1055,15 +1043,11 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->InsertChar(pos, ' '); par->SetFont(pos, font); } else { - inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); + Inset * inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); par->InsertChar(pos, LyXParagraph::META_INSET); par->InsertInset(pos, inset); par->SetFont(pos, font); } -#else - par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR); - par->SetFont(pos, font); -#endif ++pos; } else if (token == "\\bibitem") { // ale970302 if (!par->bibkey) @@ -1079,9 +1063,9 @@ bool Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, // This should be insurance for the future: (Asger) lex.printError("Unknown token `$$Token'. " "Inserting as text."); - int n = token.length(); - for (int i = 0; i < n; ++i) { - par->InsertChar(pos, token[i]); + for(string::const_iterator cit = token.begin(); + cit != token.end(); ++cit) { + par->InsertChar(pos, (*cit)); par->SetFont(pos, font); ++pos; } @@ -1403,7 +1387,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen) LyXLayout const & layout = textclasslist.Style(params.textclass, par->GetLayout()); - bool free_spc = layout.free_spacing; + //bool free_spc = layout.free_spacing; //unused /* It might be a table */ if (par->table){ @@ -1425,29 +1409,18 @@ void Buffer::writeFileAscii(string const & fname, int linelen) c = par->GetChar(i); if (c == LyXParagraph::META_INSET) { if ((inset = par->GetInset(i))) { -#if 1 #ifdef HAVE_SSTREAM std::ostringstream ost; - inset->Latex(ost, true, free_spc); + inset->Ascii(ost); h += ost.str().length(); #else ostrstream ost; - inset->Latex(ost, true, free_spc); + inset->Ascii(ost); ost << '\0'; char * tmp = ost.str(); string tstr(tmp); h += tstr.length(); delete [] tmp; -#endif -#else - ofstream fs(fname1.c_str()); - if (!fs) { - WriteFSAlert(_("Error: Cannot open temporary file:"), fname1); - return; - } - inset->Latex(fs, true, free_spc); - h += fs.tellp() - 1; - ::remove(fname1.c_str()); #endif } } else if (c == LyXParagraph::META_NEWLINE) { @@ -1530,7 +1503,7 @@ void Buffer::writeFileAscii(string const & fname, int linelen) case LyXParagraph::META_INSET: if ((inset = par->GetInset(i))) { fpos = ofs.tellp(); - inset->Latex(ofs, true, free_spc); + inset->Ascii(ofs); currlinelen += (ofs.tellp() - fpos); actpos += (ofs.tellp() - fpos) - 1; } @@ -3535,10 +3508,9 @@ void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par) switch (c) { case LyXParagraph::META_INSET: if ((inset = par->GetInset(i))) { -#if 1 #ifdef HAVE_SSTREAM stringstresm ss(ios::in | ios::out); - inset->Latex(ss, true); + inset->Ascii(ss); ss.seekp(0); ss.get(c); while (!ss) { @@ -3550,7 +3522,7 @@ void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par) } #else strstream ss; - inset->Latex(ss, true); + inset->Ascii(ss); ss.seekp(0); ss.get(c); while (!ss) { @@ -3561,27 +3533,6 @@ void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par) ss.get(c); } delete [] ss.str(); -#endif -#else - fstream fs(fname2.c_str(), ios::in|ios::out); - if (!fs) { - WriteAlert(_("LYX_ERROR:"), - _("Cannot open temporary file:"), fname2); - ofs.close(); - remove(fname1.c_str()); - return; - } - inset->Latex(fs, true); - fs.seekp(0); - fs.get(c); - while(!fs) { - if (c == '\\') - ofs << "\\\\"; - else - ofs << c; - fs >> c; - } - fs.close(); #endif } break; diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 9b9d28f0dd..d40996c3e3 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -28,6 +28,12 @@ #include +#include +#include +#include +#include +#include + #include #include #include @@ -36,11 +42,6 @@ #include #include #include -#include -#include -#include -#include -#include #include "figinset.h" #include "lyx.h" @@ -58,7 +59,6 @@ #include "support/lyxlib.h" #include "Painter.h" #include "font.h" -//#include "lyx_cb.h" #include "bufferview_funcs.h" #include "ColorHandler.h" @@ -72,6 +72,7 @@ using std::vector; using std::find; using std::flush; using std::endl; +using std::ostringstream; extern BufferView * current_view; extern FL_OBJECT * figinset_canvas; @@ -147,12 +148,27 @@ void addpidwait(int pid) } +static +string make_tmp(int pid) +{ + return system_tempdir + "/~lyxgs" + tostr(pid) + ".ps"; +} + + +static +void kill_gs(int pid, int sig) +{ + if (lyxerr.debugging()) + lyxerr << "Killing gs " << pid << endl; + lyx::kill(pid, sig); + unlink(make_tmp(pid).c_str()); +} + + extern "C" // static int GhostscriptMsg(FL_OBJECT *, Window, int, int, XEvent * ev, void *) { - char tmp[128]; - XClientMessageEvent * e = reinterpret_cast(ev); if(lyxerr.debugging()) { @@ -162,7 +178,6 @@ int GhostscriptMsg(FL_OBJECT *, Window, int, int, // just kill gs, that way it will work for sure // This loop looks like S**T so it probably is... - //for (bitmaps_type::size_type i = 0; i < bitmaps.size(); ++i) for (bitmaps_type::iterator it = bitmaps.begin(); it != bitmaps.end(); ++it) if (static_cast((*it)->bitmap) == @@ -272,31 +287,13 @@ int GhostscriptMsg(FL_OBJECT *, Window, int, int, } } noim: - if (lyxerr.debugging()) { - lyxerr << "Killing gs " - << p->gspid << endl; - } - lyx::kill(p->gspid, SIGHUP); - - sprintf(tmp, "%s/~lyxgs%d.ps", - system_tempdir.c_str(), - p->gspid); - unlink(tmp); + kill_gs(p->gspid, SIGHUP); if (forkstat == 0) { XCloseDisplay(tmpdisp); _exit(0); } } else { - if (lyxerr.debugging()) { - lyxerr << "Killing gs " - << p->gspid << endl; - } - lyx::kill(p->gspid, SIGHUP); - - sprintf(tmp, "%s/~lyxgs%d.ps", - system_tempdir.c_str(), - p->gspid); - unlink(tmp); + kill_gs(p->gspid, SIGHUP); } break; } @@ -405,15 +402,17 @@ void InitFigures() gs_color = false; if (lyxrc.use_gui) { fl_add_canvas_handler(figinset_canvas, ClientMessage, - GhostscriptMsg, current_view->owner()->getMainForm()); + GhostscriptMsg, + current_view->owner()->getMainForm()); local_gc_copy = createGC(); - Visual * vi = DefaultVisual(fl_display, DefaultScreen(fl_display)); + Visual * vi = DefaultVisual(fl_display, + DefaultScreen(fl_display)); if (lyxerr.debugging()) { printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n", - vi->visualid, vi->c_class, - vi->bits_per_rgb, vi->map_entries); + vi->visualid, vi->c_class, + vi->bits_per_rgb, vi->map_entries); } color_visual = ( (vi->c_class == StaticColor) || (vi->c_class == PseudoColor) || @@ -457,12 +456,9 @@ void freefigdata(figdata * tmpdata) if (tmpdata->gspid > 0) { int pid = tmpdata->gspid; - char buf[128]; // kill ghostscript and unlink it's files tmpdata->gspid = -1; - lyx::kill(pid, SIGKILL); - sprintf(buf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), pid); - unlink(buf); + kill_gs(pid, SIGKILL); } if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap); @@ -487,7 +483,7 @@ void runqueue() } while (gsrunning < MAXGS) { - char tbuf[384], tbuf2[80]; + //char tbuf[384]; //, tbuf2[80]; Atom * prop; int nprop, i; @@ -517,15 +513,13 @@ void runqueue() return; } if (pid == 0) { // child - char ** env, rbuf[80], gbuf[40]; + char ** env; int ne = 0; Display * tempdisp = XOpenDisplay(XDisplayName(0)); // create translation file - sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), - int(getpid())); - - ofstream ofs(tbuf); + ofstream ofs; + ofs.open(make_tmp(getpid()).c_str()); ofs << "gsave clippath pathbbox grestore\n" << "4 dict begin\n" << "/ury exch def /urx exch def /lly exch def " @@ -542,18 +536,35 @@ void runqueue() ofs.close(); // Don't remove this. // gs process - set ghostview environment first - sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id( - figinset_canvas), p->data->bitmap); - +#ifdef HAVE_SSTREAM + ostringstream t2; +#else + char tbuf2[80]; + ostrstream t2(tbuf2, sizeof(tbuf)); +#endif + t2 << "GHOSTVIEW=" << fl_get_canvas_id(figinset_canvas) + << ' ' << p->data->bitmap; +#ifndef HAVE_SSTREAM + << '\0'; +#endif // now set up ghostview property on a window - sprintf(tbuf, "0 0 0 0 %d %d 72 72 0 0 0 0", - p->data->wid, p->data->hgh); // #warning BUG seems that the only bug here // might be the hardcoded dpi.. Bummer! +#ifdef HAVE_SSTREAM + ostringstream t1; +#else + char tbuf[384]; + ostrstream t1(tbuf, sizeof(tbuf)); +#endif + t1 << "0 0 0 0 " << p->data->wid << ' ' + << p->data->hgh << " 72 72 0 0 0 0"; +#ifndef HAVE_SSTREAM + << '\0'; +#endif if (lyxerr.debugging()) { lyxerr << "Will set GHOSTVIEW property to [" - << tbuf << "]" << endl; + << t1.str() << "]" << endl; } // wait until property is deleted if executing multiple // ghostscripts @@ -585,9 +596,6 @@ void runqueue() } XFree(reinterpret_cast(prop)); // jc: if (err) break; - // release the server - //XUngrabServer(tempdisp); - //XFlush(tempdisp); // ok, property found, we must wait until // ghostscript deletes it if (lyxerr.debugging()) { @@ -606,27 +614,34 @@ void runqueue() XInternAtom(tempdisp, "GHOSTVIEW", false), XInternAtom(tempdisp, "STRING", false), 8, PropModeAppend, - reinterpret_cast(tbuf), - strlen(tbuf)); + reinterpret_cast(const_cast(t1.str().c_str())), + t1.str().size()); XUngrabServer(tempdisp); XFlush(tempdisp); - + +#ifdef HAVE_SSTREAM + ostringstream t3; +#else + char tbuf[384]; + ostrstream t3(tbuf, sizeof(tbuf)); +#endif switch (p->data->flags & 3) { - case 0: tbuf[0] = 'H'; break; // Hidden - case 1: tbuf[0] = 'M'; break; // Mono - case 2: tbuf[0] = 'G'; break; // Gray + case 0: t3 << 'H'; break; // Hidden + case 1: t3 << 'M'; break; // Mono + case 2: t3 << 'G'; break; // Gray case 3: if (color_visual) - tbuf[0] = 'C'; // Color + t3 << 'C'; // Color else - tbuf[0] = 'G'; // Gray + t3 << 'G'; // Gray break; } - - sprintf(tbuf + 1, " %ld %ld", - BlackPixelOfScreen( - DefaultScreenOfDisplay(tempdisp)), - background_pixel); + + t3 << ' ' << BlackPixelOfScreen(DefaultScreenOfDisplay(tempdisp)) + << ' ' << background_pixel; +#ifndef HAVE_SSTREAM + << '\0'; +#endif XGrabServer(tempdisp); XChangeProperty(tempdisp, @@ -635,8 +650,8 @@ void runqueue() "GHOSTVIEW_COLORS", false), XInternAtom(tempdisp, "STRING", false), 8, PropModeReplace, - reinterpret_cast(tbuf), - strlen(tbuf)); + reinterpret_cast(const_cast(t3.str().c_str())), + t3.str().size()); XUngrabServer(tempdisp); XFlush(tempdisp); @@ -646,10 +661,18 @@ void runqueue() XCloseDisplay(tempdisp); // set up environment - while (environ[ne]) ++ne; + while (environ[ne]) + ++ne; typedef char * char_p; env = new char_p[ne + 2]; +#ifdef HAVE_SSTREAM + string tmp = t2.str().c_str(); + env[0] = new char[tmp.size() + 1]; + std::copy(tmp.begin(), tmp.end(), env[0]); + env[0][tmp.size()] = '\0'; +#else env[0] = tbuf2; +#endif ::memcpy(&env[1], environ, sizeof(char*) * (ne + 1)); environ = env; @@ -657,16 +680,17 @@ void runqueue() // close(0); // close(1); do NOT close. If GS writes out // errors it would hang. (Matthias 290596) - sprintf(rbuf, "-r%gx%g", p->rx, p->ry); - sprintf(gbuf, "-g%dx%d", p->data->wid, p->data->hgh); + + string rbuf = "-r" + tostr(p->rx) + "x" + tostr(p->ry); + string gbuf = "-g" + tostr(p->data->wid) + "x" + tostr(p->data->hgh); + // now chdir into dir with .eps file, to be on the safe // side ::chdir(OnlyPath(p->data->fname).c_str()); // make temp file name - sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), - int(::getpid())); + string tmpf = make_tmp(getpid()); if (lyxerr.debugging()) { - lyxerr << "starting gs " << tbuf << " " + lyxerr << "starting gs " << tmpf << " " << p->data->fname << ", pid: " << getpid() << endl; } @@ -676,7 +700,7 @@ void runqueue() "-sDEVICE=x11", "-dNOPAUSE", "-dQUIET", "-dSAFER", - rbuf, gbuf, tbuf, + rbuf.c_str(), gbuf.c_str(), tmpf.c_str(), p->data->fname.c_str(), "showpage.ps", "quit.ps", "-", 0); // if we are still there, an error occurred. @@ -685,7 +709,7 @@ void runqueue() lyxerr.debug() << "Cmd: " << lyxrc.ps_command << " -sDEVICE=x11 " - << tbuf << ' ' + << tmpf.c_str() << ' ' << p->data->fname << endl; _exit(0); // no gs? } @@ -722,8 +746,8 @@ void addwait(int psx, int psy, int pswid, int pshgh, figdata * data) static figdata * getfigdata(int wid, int hgh, string const & fname, - int psx, int psy, int pswid, int pshgh, - int raw_wid, int raw_hgh, float angle, char flags) + int psx, int psy, int pswid, int pshgh, + int raw_wid, int raw_hgh, float angle, char flags) { /* first search for an exact match with fname and width/height */ @@ -832,11 +856,7 @@ void sigchldchecker(pid_t pid, int * status) p->broken = false; } else { // remove temporary files - char tmp[128]; - sprintf(tmp, "%s/~lyxgs%d.ps", - system_tempdir.c_str(), - p->gspid); - unlink(tmp); + unlink(make_tmp(p->gspid).c_str()); p->gspid = -1; p->broken = true; } @@ -1150,6 +1170,12 @@ int InsetFig::Latex(ostream & os, } +int InsetFig::Ascii(ostream &) const +{ + return 0; +} + + int InsetFig::Linuxdoc(ostream &) const { return 0; @@ -1271,6 +1297,31 @@ Inset::Code InsetFig::LyxCode() const } +static +string stringify(InsetFig::HWTYPE hw, float f, string suffix) +{ + string res; + switch (hw) { + case InsetFig::DEF: + break; + case InsetFig::CM:// \resizebox*{h-length}{v-length}{text} + res = tostr(f) + "cm"; + break; + case InsetFig::IN: + res = tostr(f) + "in"; + break; + case InsetFig::PER_PAGE: + res = tostr(f/100) + "\\text" + suffix; + break; + case InsetFig::PER_COL: + // Doesn't occur for htype... + res = tostr(f/100) + "\\column" + suffix; + break; + } + return res; +} + + void InsetFig::Regenerate() const { string cmdbuf; @@ -1288,69 +1339,8 @@ void InsetFig::Regenerate() const string fname2 = MakeRelPath(fname, buf1); string gcmd = "\\includegraphics{" + fname2 + '}'; - - switch (wtype) { - case DEF: - break; - case CM:{// \resizebox*{h-length}{v-length}{text} - char buf[10]; - sprintf(buf, "%g", xwid); // should find better - resizeW = buf; - resizeW += "cm"; - break; - } - case IN: { - char buf[10]; - sprintf(buf, "%g", xwid); - resizeW = buf; - resizeW += "in"; - break; - } - case PER_PAGE:{ - char buf[10]; - sprintf(buf, "%g", xwid/100); - resizeW = buf; - resizeW += "\\textwidth"; - break; - } - case PER_COL:{ - char buf[10]; - sprintf(buf, "%g", xwid/100); - resizeW = buf; - resizeW += "\\columnwidth"; - break; - } - } - - switch (htype) { - case DEF: - break; - case CM: { - char buf[10]; - sprintf(buf, "%g", xhgh); - resizeH = buf; - resizeH += "cm"; - break; - } - case IN:{ - char buf[10]; - sprintf(buf, "%g", xhgh); - resizeH = buf; - resizeH += "in"; - break; - } - case PER_PAGE: { - char buf[10]; - sprintf(buf, "%g", xhgh/100); - resizeH = buf; - resizeH += "\\textheight"; - break; - } - case PER_COL: { - // Doesn't occur; case exists to suppress compiler warnings. - break; - } - } + resizeW = stringify(wtype, xwid, "width"); + resizeH = stringify(htype, xhgh, "height"); if (!resizeW.empty() || !resizeH.empty()) { recmd = "\\resizebox*{"; @@ -1368,12 +1358,8 @@ void InsetFig::Regenerate() const if (angle != 0) { - char buf[10]; - sprintf(buf, "%g", angle); // \rotatebox{angle}{text} - rotate = "\\rotatebox{"; - rotate += buf; - rotate += "}{"; + rotate = "\\rotatebox{" + tostr(angle) + "}{"; } cmdbuf = recmd; @@ -1406,8 +1392,8 @@ void InsetFig::TempRegenerate() float txhgh = atof(fl_get_input(form->Height)); if (!tfname || !*tfname) { - cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}"; - cmd += _("empty figure path"); + cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}"; + cmd += _("empty figure path"); cmd += '}'; return; } @@ -1416,69 +1402,9 @@ void InsetFig::TempRegenerate() string fname2 = MakeRelPath(tfname, buf1); // \includegraphics*[][]{file} string gcmd = "\\includegraphics{" + fname2 + '}'; - - switch (twtype) { - case DEF: - break; - case CM: {// \resizebox*{h-length}{v-length}{text} - char buf[10]; - sprintf(buf, "%g", txwid); // should find better - resizeW = buf; - resizeW += "cm"; - break; - } - case IN: { - char buf[10]; - sprintf(buf, "%g", txwid); - resizeW = buf; - resizeW += "in"; - break; - } - case PER_PAGE: { - char buf[10]; - sprintf(buf, "%g", txwid/100); - resizeW = buf; - resizeW += "\\textwidth"; - break; - } - case PER_COL: { - char buf[10]; - sprintf(buf, "%g", txwid/100); - resizeW = buf; - resizeW += "\\columnwidth"; - break; - } - } - switch (thtype) { - case DEF: - break; - case CM: { - char buf[10]; - sprintf(buf, "%g", txhgh); - resizeH = buf; - resizeH += "cm"; - break; - } - case IN: { - char buf[10]; - sprintf(buf, "%g", txhgh); - resizeH = buf; - resizeH += "in"; - break; - } - case PER_PAGE: { - char buf[10]; - sprintf(buf, "%g", txhgh/100); - resizeH = buf; - resizeH += "\\textheight"; - break; - } - case PER_COL: { - // Doesn't occur; case exists to suppress compiler warnings. - break; - } - } + resizeW = stringify(twtype, txwid, "width"); + resizeH = stringify(thtype, txhgh, "height"); // \resizebox*{h-length}{v-length}{text} if (!resizeW.empty() || !resizeH.empty()) { @@ -1496,17 +1422,11 @@ void InsetFig::TempRegenerate() } if (tangle != 0) { - char buf[10]; - sprintf(buf, "%g", tangle); // \rotatebox{angle}{text} - rotate = "\\rotatebox{"; - rotate += buf; - rotate += "}{"; + rotate = "\\rotatebox{" + tostr(tangle) + "}{"; } - cmdbuf = recmd; - cmdbuf += rotate; - cmdbuf += gcmd; + cmdbuf = recmd + rotate + gcmd; if (!rotate.empty()) cmdbuf += '}'; if (!recmd.empty()) cmdbuf += '}'; if (psubfigure && !tsubcap.empty()) { @@ -1663,9 +1583,6 @@ void InsetFig::GetPSSizes() if (c == '%' && lastchar == '%') { ifs >> p; if (p.empty()) break; - // we should not use this, with it we cannot - // discover bounding box and end of file. - //if (strcmp(p, "EndComments") == 0) break; lyxerr.debug() << "Token: `" << p << "'" << endl; if (p == "BoundingBox:") { float fpsx, fpsy, fpswid, fpshgh; @@ -1944,8 +1861,6 @@ void EnableFigurePanel(FD_Figure * const form) void InsetFig::RestoreForm() { - char buf[32]; - EnableFigurePanel(form); twtype = wtype; @@ -1983,12 +1898,9 @@ void InsetFig::RestoreForm() fl_set_button(form->Subfigure, (subfigure != 0)); pflags = flags; psubfigure = subfigure; - sprintf(buf, "%g", xwid); - fl_set_input(form->Width, buf); - sprintf(buf, "%g", xhgh); - fl_set_input(form->Height, buf); - sprintf(buf, "%g", angle); - fl_set_input(form->Angle, buf); + fl_set_input(form->Width, tostr(xwid).c_str()); + fl_set_input(form->Height, tostr(xhgh).c_str()); + fl_set_input(form->Angle, tostr(angle).c_str()); if (!fname.empty()){ string buf1 = OnlyPath(owner->fileName()); string fname2 = MakeRelPath(fname, buf1); @@ -2080,14 +1992,13 @@ void InsetFig::BrowseFile() once = 1; if (contains(p, "#") || contains(p, "~") || contains(p, "$") - || contains(p, "%") || contains(p, " ")) - { - WriteAlert(_("Filename can't contain any " - "of these characters:"), - // xgettext:no-c-format - _("space, '#', '~', '$' or '%'.")); - error = true; - } + || contains(p, "%") || contains(p, " ")) { + WriteAlert(_("Filename can't contain any " + "of these characters:"), + // xgettext:no-c-format + _("space, '#', '~', '$' or '%'.")); + error = true; + } } while (error); if (form) fl_set_input(form->EpsFile, buf.c_str()); diff --git a/src/insets/figinset.h b/src/insets/figinset.h index ae004dc1de..178ddf4acf 100644 --- a/src/insets/figinset.h +++ b/src/insets/figinset.h @@ -39,6 +39,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_space) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 289f1614e1..9cbad721e9 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -18,7 +18,9 @@ #include "lyxfont.h" #include "BufferView.h" #include "Painter.h" +#include "support/LOstream.h" +using std::ostream; InsetCollapsable::InsetCollapsable(Buffer * bf) : InsetText(bf) @@ -143,14 +145,13 @@ void InsetCollapsable::draw(Painter & pain, LyXFont const & f, return; } - int - top_x = int(x); + int top_x = int(x); draw_collapsed(pain, f, baseline, x); x += 2; - int w = getMaxTextWidth(pain,this); - int h = ascent(pain,f) + descent(pain,f); + int w = getMaxTextWidth(pain, this); + int h = ascent(pain,f) + descent(pain, f); pain.rectangle(int(x), baseline - ascent(pain, f), w, h, framecolor); @@ -160,7 +161,7 @@ void InsetCollapsable::draw(Painter & pain, LyXFont const & f, } -void InsetCollapsable::Edit(BufferView *bv, int x, int y, unsigned int button) +void InsetCollapsable::Edit(BufferView * bv, int x, int y, unsigned int button) { if (collapsed && autocollapse) { collapsed = false; @@ -179,7 +180,8 @@ Inset::EDITABLE InsetCollapsable::Editable() const return HIGHLY_EDITABLE; } -void InsetCollapsable::InsetUnlock(BufferView *bv) + +void InsetCollapsable::InsetUnlock(BufferView * bv) { if (autocollapse) { collapsed = true; @@ -195,7 +197,7 @@ void InsetCollapsable::UpdateLocal(BufferView * bv, bool flag) } -void InsetCollapsable::InsetButtonPress(BufferView *bv,int x,int y,int button) +void InsetCollapsable::InsetButtonPress(BufferView * bv,int x,int y,int button) { if (!collapsed && (x >= button_length)) { InsetText::InsetButtonPress(bv, x, y, button); @@ -203,7 +205,8 @@ void InsetCollapsable::InsetButtonPress(BufferView *bv,int x,int y,int button) } -void InsetCollapsable::InsetButtonRelease(BufferView *bv, int x, int y, int button) +void InsetCollapsable::InsetButtonRelease(BufferView * bv, + int x, int y, int button) { if ((x >= 0) && (x < button_length) && (y >= button_top_y) && (y < button_bottom_y)) { @@ -221,26 +224,31 @@ void InsetCollapsable::InsetButtonRelease(BufferView *bv, int x, int y, int butt } } -void InsetCollapsable::InsetMotionNotify(BufferView *bv, int x, int y, int state) + +void InsetCollapsable::InsetMotionNotify(BufferView * bv, + int x, int y, int state) { if (x >= button_length) { InsetText::InsetMotionNotify(bv, x, y, state); } } -int InsetCollapsable::getMaxWidth(Painter & pain, UpdatableInset const * inset) const + +int InsetCollapsable::getMaxWidth(Painter & pain, + UpdatableInset const * inset) const { if ((this == inset) && !owner()) return pain.paperWidth(); if (this == inset) - return (static_cast(owner())->getMaxWidth(pain,inset)); + return static_cast(owner())->getMaxWidth(pain,inset); if (owner()) - return (static_cast(owner())->getMaxWidth(pain,inset)- - width_collapsed(pain, labelfont) - 2 - widthOffset); + return static_cast(owner())->getMaxWidth(pain,inset)- + width_collapsed(pain, labelfont) - 2 - widthOffset; return pain.paperWidth()-width_collapsed(pain, labelfont)-2-widthOffset; } + int InsetCollapsable::getMaxTextWidth(Painter & pain, UpdatableInset const * inset, int) const { diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 38eaf42af1..69322ae890 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -204,6 +204,12 @@ int InsetCommand::Latex(ostream & os, bool /*fragile*/, bool/*fs*/) const } +int InsetCommand::Ascii(ostream &) const +{ + return 0; +} + + int InsetCommand::Linuxdoc(ostream &) const { return 0; diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 59ee7175f8..449d0f19ed 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -51,6 +51,8 @@ public: virtual int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// virtual int Linuxdoc(std::ostream &) const; /// virtual int DocBook(std::ostream &) const; diff --git a/src/insets/inseterror.C b/src/insets/inseterror.C index cc3acec315..b1a879cfaa 100644 --- a/src/insets/inseterror.C +++ b/src/insets/inseterror.C @@ -111,6 +111,12 @@ int InsetError::Latex(ostream &, } +int InsetError::Ascii(ostream &) const +{ + return 0; +} + + int InsetError::Linuxdoc(ostream &) const { return 0; diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index 6f248e1220..519da5fe93 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -50,6 +50,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 41f7bb668d..dd591b2452 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -334,6 +334,12 @@ int InsetGraphics::Latex(ostream & os, } +int InsetGraphics::Ascii(ostream &) const +{ + return 0; +} + + int InsetGraphics::Linuxdoc(ostream &) const { return 0; diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 56ccddef93..92849ae229 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -51,6 +51,8 @@ public: */ int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index 656ffee6bf..3c58a89091 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -139,6 +139,12 @@ int InsetInfo::Latex(ostream &, } +int InsetInfo::Ascii(ostream &) const +{ + return 0; +} + + int InsetInfo::Linuxdoc(ostream &) const { return 0; diff --git a/src/insets/insetinfo.h b/src/insets/insetinfo.h index aaf064f8b9..2e4267a888 100644 --- a/src/insets/insetinfo.h +++ b/src/insets/insetinfo.h @@ -52,6 +52,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 92f871afab..0973ad239c 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -53,6 +53,12 @@ int InsetLabel::Latex(ostream & os, return 0; } +int InsetLabel::Ascii(ostream & os) const +{ + os << "<" << getContents() << ">"; + return 0; +} + int InsetLabel::Linuxdoc(ostream & os) const { diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index df4e2b5b09..62196b7d80 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -42,6 +42,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetlatex.C b/src/insets/insetlatex.C index 0761f3f030..38175672a3 100644 --- a/src/insets/insetlatex.C +++ b/src/insets/insetlatex.C @@ -106,6 +106,13 @@ int InsetLatex::Latex(string & file, signed char /*fragile*/, bool /*fs*/) } +int InsetLatex::Ascii(string & file) +{ + file += contents; + return 0; +} + + int InsetLatex::Linuxdoc(string & file) { file += contents; diff --git a/src/insets/insetlatex.h b/src/insets/insetlatex.h index bd499db900..c3b5b52a50 100644 --- a/src/insets/insetlatex.h +++ b/src/insets/insetlatex.h @@ -50,6 +50,8 @@ public: /// int Latex(string & file, signed char fragile, bool free_spc); /// + int Ascii(string & file) const; + /// int Linuxdoc(string & file); /// int DocBook(string & file); diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index cbe3c8e605..01bd28aea7 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -627,6 +627,13 @@ int InsetLatexAccent::Latex(ostream & os, } +int InsetLatexAccent::Ascii(ostream & os) const +{ + os << contents; + return 0; +} + + int InsetLatexAccent::Linuxdoc(ostream & os) const { os << contents; diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index e648a6b85f..018eb86d18 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -56,6 +56,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index ae5d82a89e..fe09f6e047 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -250,6 +250,7 @@ int InsetQuotes::Latex(ostream & os, bool /*fragile*/, bool) const // protect against !` and ?` ligatures. // Is it very bad of us to always protect against those ligatures? + // CHECK #if 0 if ((suffixIs(file, '?') || suffixIs(file, '!')) && qstr[0] == '`') @@ -264,6 +265,13 @@ int InsetQuotes::Latex(ostream & os, bool /*fragile*/, bool) const } +int InsetQuotes::Ascii(ostream & os) const +{ + os << "\""; + return 0; +} + + int InsetQuotes::Linuxdoc(ostream & os) const { os << "\""; diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index 7c89694b2a..31903afbd6 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -88,6 +88,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insetref.C b/src/insets/insetref.C index bb985a9ed8..0df28abc6d 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -84,6 +84,13 @@ int InsetRef::Latex(ostream & os, } +int InsetRef::Ascii(ostream & os) const +{ + os << "[" << getContents() << "]"; + return 0; +} + + int InsetRef::Linuxdoc(ostream & os) const { os << ""; break; case PROTECTED_SEPARATOR: os << " "; break; @@ -204,16 +203,15 @@ int InsetSpecialChar::Linuxdoc(ostream & os) const } +int InsetSpecialChar::Linuxdoc(ostream & os) const +{ + return Ascii(os); +} + + int InsetSpecialChar::DocBook(ostream & os) const { - switch (kind) { - case HYPHENATION: os << ""; break; - case END_OF_SENTENCE: os << ""; break; - case LDOTS: os << "..."; break; - case MENU_SEPARATOR: os << "->"; break; - case PROTECTED_SEPARATOR: os << " "; break; - } - return 0; + return Ascii(os); } diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index a276acd580..f8d5a20152 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -58,6 +58,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 58810293ee..faa3f38552 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -3,7 +3,7 @@ * * LyX, The Document Processor * - * Copyright (C) 2000 The LyX Team. + * Copyright 2000 The LyX Team. * *====================================================== */ @@ -33,6 +33,9 @@ const int ADD_TO_TABULAR_WIDTH = 2; using std::ostream; using std::ifstream; +using std::max; +using std::endl; + InsetTabular::InsetTabular(Buffer * buf, int rows, int columns) { @@ -53,6 +56,7 @@ InsetTabular::InsetTabular(Buffer * buf, int rows, int columns) init = true; } + InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf) { tabular = new LyXTabular(*(tab.tabular), buf); @@ -65,9 +69,9 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf) init = true; } + InsetTabular::~InsetTabular() { - if (tabular) delete tabular; } @@ -89,7 +93,6 @@ void InsetTabular::Write(ostream & os) const void InsetTabular::Read(LyXLex & lex) { - if (tabular) delete tabular; // bool old_format = (lex.GetString() == "\\LyXTabular"); @@ -155,7 +158,7 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline, } -const char * InsetTabular::EditMessage() const +char const * InsetTabular::EditMessage() const { return _("Opened Tabular Inset"); } @@ -193,6 +196,7 @@ void InsetTabular::InsetUnlock(BufferView * bv) no_selection = false; } + bool InsetTabular::LockInsetInInset(UpdatableInset *) { return true; @@ -221,6 +225,7 @@ void InsetTabular::UpdateLocal(BufferView * bv, bool flag) bv->updateInset(this, flag); } + bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset) { if (!the_locking_inset) @@ -231,7 +236,9 @@ bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset) return true; } -void InsetTabular::InsetButtonRelease(BufferView *bv, int x, int y, int button) + +void InsetTabular::InsetButtonRelease(BufferView * bv, + int x, int y, int button) { if (the_locking_inset) { the_locking_inset->InsetButtonRelease(bv, x-inset_x,y-inset_y,button); @@ -240,7 +247,8 @@ void InsetTabular::InsetButtonRelease(BufferView *bv, int x, int y, int button) no_selection = false; } -void InsetTabular::InsetButtonPress(BufferView *bv, int x, int y, int) + +void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int) { if (hasCharSelection()) { sel_pos_start = sel_pos_end = 0; @@ -252,8 +260,7 @@ void InsetTabular::InsetButtonPress(BufferView *bv, int x, int y, int) the_locking_inset->InsetUnlock(bv); } #if 0 - int - oldcell = actcell; + int oldcell = actcell; #endif setPos(bv->painter(),x,y); the_locking_inset = 0; @@ -271,13 +278,13 @@ void InsetTabular::InsetButtonPress(BufferView *bv, int x, int y, int) void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button) { if (the_locking_inset) { - the_locking_inset->InsetMotionNotify(bv, x-inset_x,y-inset_y,button); + the_locking_inset->InsetMotionNotify(bv, x - inset_x, + y - inset_y, button); return; } if (!no_selection) { - int -// oldcell = actcell, - old = sel_pos_end; + // int oldcell = actcell, + int old = sel_pos_end; setPos(bv->painter(), x, y); sel_pos_end = cursor.pos; @@ -302,7 +309,7 @@ void InsetTabular::InsetKeyPress(XKeyEvent * xke) } -UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView *bv, int action, +UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, string const & arg) { UpdatableInset::RESULT @@ -441,16 +448,24 @@ int InsetTabular::Latex(ostream & os, bool, bool) const return tabular->Latex(os); } + +int InsetTabular::Ascii(ostream &) const +{ + return 0; +} + int InsetTabular::Linuxdoc(ostream &) const { return 0; } + int InsetTabular::DocBook(ostream &) const { return 0; } + void InsetTabular::Validate(LaTeXFeatures & features) const { if (tabular->IsLongTabular()) @@ -458,35 +473,37 @@ void InsetTabular::Validate(LaTeXFeatures & features) const } -void InsetTabular::calculate_width_of_cells(Painter & pain, LyXFont const & font) const +void InsetTabular::calculate_width_of_cells(Painter & pain, + LyXFont const & font) const { - int - cell=-1, - i,j, - maxAsc, maxDesc; - InsetText - *inset; + int cell = -1; + int maxAsc, maxDesc; + InsetText * inset; - for(i=0; i < tabular->rows(); ++i) { - maxAsc = maxDesc = 0; - for(j=0; j < tabular->columns(); ++j) { - if (tabular->IsPartOfMultiColumn(i,j)) - continue; - ++cell; - inset = tabular->GetCellInset(cell); - maxAsc = max(maxAsc, inset->ascent(pain, font)); - maxDesc = max(maxDesc, inset->descent(pain, font)); - tabular->SetWidthOfCell(cell, inset->width(pain, font)); - } - tabular->SetAscentOfRow(i,maxAsc+ADD_TO_HEIGHT); - tabular->SetDescentOfRow(i,maxDesc+ADD_TO_HEIGHT); - } + for(int i = 0; i < tabular->rows(); ++i) { + maxAsc = maxDesc = 0; + for(int j= 0; j < tabular->columns(); ++j) { + if (tabular->IsPartOfMultiColumn(i,j)) + continue; + ++cell; + inset = tabular->GetCellInset(cell); + maxAsc = max(maxAsc, inset->ascent(pain, font)); + maxDesc = max(maxDesc, inset->descent(pain, font)); + tabular->SetWidthOfCell(cell, + inset->width(pain, font)); + } + tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT); + tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT); + } } void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline, int row, int cell) const { + // Juergen, have you thought about drawing the on-off lines in a + // different color (gray of some kind), especially since those + // lines will not be there on the hardcopy anyway. (Lgb) int x2 = x + tabular->WidthOfColumn(cell); bool on_off = !tabular->TopLine(cell); @@ -528,14 +545,11 @@ void InsetTabular::ToggleInsetCursor(BufferView * bv) the_locking_inset->ToggleInsetCursor(bv); return; } - int - asc,desc; - LyXFont - font; // = the_locking_inset->GetFont(par, cursor.pos); + LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos); - asc = lyxfont::maxAscent(font); - desc = lyxfont::maxDescent(font); + int asc = lyxfont::maxAscent(font); + int desc = lyxfont::maxDescent(font); if (cursor_visible) bv->hideLockedInsetCursor(); @@ -548,13 +562,10 @@ void InsetTabular::ToggleInsetCursor(BufferView * bv) void InsetTabular::ShowInsetCursor(BufferView * bv) { if (!cursor_visible) { - int - asc,desc; - LyXFont - font; // = GetFont(par, cursor.pos); + LyXFont font; // = GetFont(par, cursor.pos); - asc = lyxfont::maxAscent(font); - desc = lyxfont::maxDescent(font); + int asc = lyxfont::maxAscent(font); + int desc = lyxfont::maxDescent(font); bv->fitLockedInsetCursor(cursor.x, cursor.y, asc, desc); bv->showLockedInsetCursor(cursor.x, cursor.y, asc, desc); cursor_visible = true; @@ -571,11 +582,9 @@ void InsetTabular::HideInsetCursor(BufferView * bv) void InsetTabular::setPos(Painter &, int x, int y) const { - int - lx, ly; - cursor.y = cursor.pos = actcell = actrow = actcol = 0; - ly = tabular->DescentOfRow(actrow); + int ly = tabular->DescentOfRow(actrow); + // first search the right row while((ly < y) && (actrow < tabular->rows())) { cursor.y += tabular->DescentOfRow(actrow) + @@ -585,20 +594,22 @@ void InsetTabular::setPos(Painter &, int x, int y) const ly = cursor.y + tabular->DescentOfRow(actrow); } actcell = tabular->GetCellNumber(actcol, actrow); + // now search the right column - for(lx=tabular->GetWidthOfCell(actcell); + int lx = tabular->GetWidthOfCell(actcell); + for(; !tabular->IsLastCellInRow(actcell) && (lx < x); ++actcell,lx += tabular->GetWidthOfCell(actcell)) {} cursor.x = lx - tabular->GetWidthOfCell(actcell) + top_x + 2; } -void InsetTabular::resetPos(BufferView *bv) -{ - int - lx, cell; +void InsetTabular::resetPos(BufferView * bv) +{ actrow = cursor.y = actcol = 0; - for(cell=0; (cellIsLastRow(cell); ++cell) { + + int cell = 0; + for(; (cellIsLastRow(cell); ++cell) { if (tabular->IsLastCellInRow(cell)) { cursor.y += tabular->DescentOfRow(actrow) + tabular->AscentOfRow(actrow+1) + @@ -608,7 +619,8 @@ void InsetTabular::resetPos(BufferView *bv) } for(cell=actcell;!tabular->IsFirstCellInRow(cell);--cell) ; - for(lx=tabular->GetWidthOfCell(actcell); (cell < actcell); ++cell) { + int lx = tabular->GetWidthOfCell(actcell); + for(; (cell < actcell); ++cell) { lx += tabular->GetWidthOfCell(actcell); ++actcol; } @@ -619,11 +631,13 @@ void InsetTabular::resetPos(BufferView *bv) } } + void InsetTabular::setWidthOfCell(int, int, int) { } -UpdatableInset::RESULT InsetTabular::moveRight(BufferView *bv) + +UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv) { if (cursor.pos % 2) { // behind the inset ++actcell; @@ -637,40 +651,48 @@ UpdatableInset::RESULT InsetTabular::moveRight(BufferView *bv) return DISPATCHED_NOUPDATE; } + UpdatableInset::RESULT InsetTabular::moveLeft() { return DISPATCHED_NOUPDATE; } + UpdatableInset::RESULT InsetTabular::moveUp() { return DISPATCHED_NOUPDATE; } + UpdatableInset::RESULT InsetTabular::moveDown() { return DISPATCHED_NOUPDATE; } + bool InsetTabular::moveNextCell() { return false; } + bool InsetTabular::movePrevCell() { return false; } + bool InsetTabular::Delete() { return true; } + void InsetTabular::SetFont(LyXFont const &) { } + void InsetTabular::TabularFeatures(int, string) { #if 0 diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 3c731636bb..bf91314f64 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -110,6 +110,8 @@ public: /// int Latex(std::ostream &, bool, bool) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 246be22a54..48c1da4741 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -56,11 +56,13 @@ using std::ostream; using std::ifstream; +using std::endl; using std::min; using std::max; extern unsigned char getCurrentTextClass(Buffer *); + InsetText::InsetText(Buffer * buf) { par = new LyXParagraph(); @@ -75,6 +77,7 @@ InsetText::InsetText(InsetText const & ins, Buffer * buf) autoBreakRows = ins.autoBreakRows; } + void InsetText::init(Buffer * buf, InsetText const * ins) { the_locking_inset = 0; @@ -374,6 +377,7 @@ void InsetText::InsetUnlock(BufferView * bv) no_selection = false; } + bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset) { lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): "; @@ -404,6 +408,7 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset) return false; } + bool InsetText::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset, bool lr) { @@ -792,7 +797,7 @@ InsetText::LocalDispatch(BufferView * bv, } -int InsetText::Latex(ostream & os, bool /*fragile*/, bool) const +int InsetText::Latex(ostream & os, bool /*fragile*/, bool /*fp*/) const { TexRow texrow; int ret = par->SimpleTeXOnePar(os, texrow); @@ -922,12 +927,14 @@ LyXFont InsetText::GetFont(LyXParagraph * par, int pos) const return tmpfont; } + // the font for drawing may be different from the real font LyXFont InsetText::GetDrawFont(LyXParagraph * par, int pos) const { return GetFont(par, pos); } + int InsetText::BeginningOfMainBody(LyXParagraph * par) const { if (textclasslist.Style(buffer->params.textclass, @@ -1047,7 +1054,8 @@ void InsetText::resetPos(Painter & pain) const cursor.y = top_baseline; actrow = 0; - for(unsigned int i = 0; (i < (rows.size()-1)) && (rows[i].pos <= cursor.pos); + for(unsigned int i = 0; + (i < (rows.size()-1)) && (rows[i].pos <= cursor.pos); ++i) { cursor.y = rows[i].baseline; actrow = i; @@ -1307,7 +1315,7 @@ void InsetText::computeTextRows(Painter & pain, float x) const (par->GetChar(p + 1)==LyXParagraph::META_INSET)) inset = par->GetInset(p + 1); if (inset) { - inset->setOwner(this); + inset->setOwner(const_cast(this)); // is this safe? if (inset->display()) { if (!is_first_word_in_row && (width >= maxWidth)) { // we have to split also the row above @@ -1408,7 +1416,8 @@ void InsetText::computeBaselines(int baseline) const } } -void InsetText::UpdateLocal(BufferView *bv, bool flag) + +void InsetText::UpdateLocal(BufferView * bv, bool flag) { if (flag) { computeTextRows(bv->painter(), xpos); @@ -1419,6 +1428,7 @@ void InsetText::UpdateLocal(BufferView *bv, bool flag) resetPos(bv->painter()); } + bool InsetText::cutSelection() { if (!hasSelection()) @@ -1426,7 +1436,7 @@ bool InsetText::cutSelection() CutAndPaste cap; - LyXParagraph *endpar = par; + LyXParagraph * endpar = par; int start, end; if (selection_start > selection_end) { start = selection_end; @@ -1439,6 +1449,7 @@ bool InsetText::cutSelection() return cap.cutSelection(par, &endpar, start, end,buffer->params.textclass); } + bool InsetText::copySelection() { if (!hasSelection()) @@ -1457,6 +1468,7 @@ bool InsetText::copySelection() return cap.copySelection(par, par, start, end, buffer->params.textclass); } + bool InsetText::pasteSelection() { CutAndPaste cap; @@ -1474,6 +1486,7 @@ bool InsetText::pasteSelection() buffer->params.textclass); } + bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, int button) { @@ -1496,6 +1509,7 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y, return false; } + int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset, int x) const { diff --git a/src/insets/insettext.h b/src/insets/insettext.h index e05c4b0d10..bbc558cf5f 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -84,6 +84,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const { return 0; } + /// int Linuxdoc(std::ostream &) const { return 0; } /// int DocBook(std::ostream &) const { return 0; } diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index a8f69ee1eb..ae2c16a9fe 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -185,6 +185,16 @@ int InsetUrl::Latex(ostream & os, } +int InsetUrl::Ascii(ostream & os) const +{ + if (getOptions().empty()) + os << "[" << getContents() << "]"; + else + os << "[" << getContents() << "||" << getOptions() << "]"; + return 0; +} + + int InsetUrl::Linuxdoc(ostream & os) const { os << "<" << getCmdName() diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index b89bcb591e..81ae62d370 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -74,6 +74,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index 7466d33232..5f0a7326cf 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -91,8 +91,6 @@ public: /// SPECIALCHAR_CODE, /// - NUMBER_CODE, - /// TABULAR_CODE }; @@ -145,7 +143,8 @@ public: */ virtual int Latex(std::ostream &, bool fragile, bool free_spc) const = 0; - + /// + virtual int Ascii(std::ostream &) const = 0; /// virtual int Linuxdoc(std::ostream &) const = 0; /// diff --git a/src/layout.C b/src/layout.C index bfa8dde453..853114a7c2 100644 --- a/src/layout.C +++ b/src/layout.C @@ -134,7 +134,6 @@ LyXLayout::LyXLayout () // Reads a layout definition from file bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass) { -#if 1 // This table is sorted alphabetically [asierra 30March96] keyword_item layoutTags[] = { { "align", LT_ALIGN }, @@ -175,7 +174,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass) { "textfont", LT_TEXTFONT }, { "topsep", LT_TOPSEP } }; -#endif + bool error = false; bool finished = false; lexrc.pushTable(layoutTags, LT_INTITLE); @@ -403,7 +402,6 @@ enum AlignTags { void LyXLayout::readAlign(LyXLex & lexrc) { -#if 1 keyword_item alignTags[] = { { "block", AT_BLOCK }, { "center", AT_CENTER }, @@ -411,7 +409,7 @@ void LyXLayout::readAlign(LyXLex & lexrc) { "left", AT_LEFT }, { "right", AT_RIGHT } }; -#endif + pushpophelper pph(lexrc, alignTags, AT_LAYOUT); int le = lexrc.lex(); switch (le) { @@ -442,7 +440,6 @@ void LyXLayout::readAlign(LyXLex & lexrc) void LyXLayout::readAlignPossible(LyXLex & lexrc) { -#if 1 keyword_item alignTags[] = { { "block", AT_BLOCK }, { "center", AT_CENTER }, @@ -450,7 +447,7 @@ void LyXLayout::readAlignPossible(LyXLex & lexrc) { "left", AT_LEFT }, { "right", AT_RIGHT } }; -#endif + lexrc.pushTable(alignTags, AT_LAYOUT); alignpossible = LYX_ALIGN_NONE; int lineno = lexrc.GetLineNo(); @@ -530,7 +527,6 @@ static keyword_item labelTypeTags[] = { void LyXLayout::readLabelType(LyXLex & lexrc) { -#if 1 keyword_item labelTypeTags[] = { { "bibliography", LA_BIBLIO }, { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT }, @@ -550,7 +546,7 @@ void LyXLayout::readLabelType(LyXLex & lexrc) { "static", LA_STATIC }, { "top_environment", LA_TOP_ENVIRONMENT } }; -#endif + pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO); int le = lexrc.lex(); switch (le) { @@ -653,7 +649,6 @@ static keyword_item marginTags[] = { void LyXLayout::readMargin(LyXLex & lexrc) { -#if 1 keyword_item marginTags[] = { { "dynamic", MARGIN_DYNAMIC }, { "first_dynamic", MARGIN_FIRST_DYNAMIC }, @@ -661,7 +656,7 @@ void LyXLayout::readMargin(LyXLex & lexrc) { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX }, { "static", MARGIN_STATIC } }; -#endif + pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX); int le = lexrc.lex(); @@ -697,15 +692,14 @@ static keyword_item latexTypeTags[] = { void LyXLayout::readLatexType(LyXLex & lexrc) { -#if 1 keyword_item latexTypeTags[] = { { "command", LATEX_COMMAND }, { "environment", LATEX_ENVIRONMENT }, { "item_environment", LATEX_ITEM_ENVIRONMENT }, { "list_environment", LATEX_LIST_ENVIRONMENT }, { "paragraph", LATEX_PARAGRAPH } -}; -#endif + }; + pushpophelper pph(lexrc, latexTypeTags, LATEX_LIST_ENVIRONMENT); int le = lexrc.lex(); switch (le) { @@ -747,14 +741,13 @@ static keyword_item spacingTags[] = { void LyXLayout::readSpacing(LyXLex & lexrc) { -#if 1 keyword_item spacingTags[] = { {"double", ST_SPACING_DOUBLE }, {"onehalf", ST_SPACING_ONEHALF }, {"other", ST_OTHER }, {"single", ST_SPACING_SINGLE } }; -#endif + pushpophelper pph(lexrc, spacingTags, ST_OTHER); int le = lexrc.lex(); switch(le) { @@ -867,7 +860,6 @@ static keyword_item textClassTags[] = { // Reads a textclass structure from file. bool LyXTextClass::Read(string const & filename, bool merge) { -#if 1 keyword_item textClassTags[] = { { "classoptions", TC_CLASSOPTIONS }, { "columns", TC_COLUMNS }, @@ -887,8 +879,8 @@ bool LyXTextClass::Read(string const & filename, bool merge) { "sides", TC_SIDES }, { "style", TC_STYLE }, { "tocdepth", TC_TOCDEPTH } -}; -#endif + }; + if (!merge) lyxerr[Debug::TCLASS] << "Reading textclass " << MakeDisplayPath(filename) @@ -1074,14 +1066,13 @@ static keyword_item outputTypeTags[] = { void LyXTextClass::readOutputType(LyXLex & lexrc) { -#if 1 keyword_item outputTypeTags[] = { { "docbook", DOCBOOK }, { "latex", LATEX }, { "linuxdoc", LINUXDOC }, { "literate", LITERATE } -}; -#endif + }; + pushpophelper pph(lexrc, outputTypeTags, LITERATE); int le = lexrc.lex(); @@ -1136,7 +1127,6 @@ static keyword_item maxCounterTags[] = { void LyXTextClass::readMaxCounter(LyXLex & lexrc) { -#if 1 keyword_item maxCounterTags[] = { {"counter_chapter", MC_COUNTER_CHAPTER }, {"counter_enumi", MC_COUNTER_ENUMI }, @@ -1149,7 +1139,7 @@ void LyXTextClass::readMaxCounter(LyXLex & lexrc) {"counter_subsection", MC_COUNTER_SUBSECTION }, {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION } }; -#endif + pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV); int le = lexrc.lex(); switch(le) { @@ -1213,14 +1203,13 @@ static keyword_item classOptionsTags[] = { void LyXTextClass::readClassOptions(LyXLex & lexrc) { -#if 1 keyword_item classOptionsTags[] = { {"end", CO_END }, {"fontsize", CO_FONTSIZE }, {"other", CO_OTHER }, {"pagestyle", CO_PAGESTYLE } }; -#endif + lexrc.pushTable(classOptionsTags, CO_END); bool getout = false; while (!getout && lexrc.IsOK()) { diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 8ea28722a8..ee3c344c6b 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -50,7 +50,6 @@ using std::istringstream; #include "insets/insetinclude.h" #include "insets/insetbib.h" #include "insets/insettext.h" -//#include "insets/insetnumber.h" #include "insets/insetert.h" #include "insets/insetgraphics.h" #include "insets/insetfoot.h" @@ -995,6 +994,8 @@ string LyXFunc::Dispatch(int ac, case LFUN_FREE: Free(owner->view()); + owner->view()->setState(); + owner->getMiniBuffer()->Set(CurrentState(owner->view())); break; case LFUN_TEX: @@ -1677,19 +1678,14 @@ string LyXFunc::Dispatch(int ac, // --- text changing commands ------------------------ case LFUN_BREAKLINE: -#if 1 owner->view()->beforeChange(); owner->view()->text->InsertChar(LyXParagraph::META_NEWLINE); owner->view()->smallUpdate(1); SetUpdateTimer(0.01); moveCursorUpdate(false); -#else - owner->view()->newline(); -#endif break; case LFUN_PROTECTEDSPACE: -#if 1 { LyXLayout const & style = textclasslist.Style(owner->view()->buffer()->params.textclass, @@ -1703,15 +1699,7 @@ string LyXFunc::Dispatch(int ac, } moveCursorUpdate(false); } -#else - owner->view()->beforeChange(); - owner->view()->text-> - InsertChar(LyXParagraph::META_PROTECTED_SEPARATOR); - owner->view()->smallUpdate(1); - SetUpdateTimer(); - moveCursorUpdate(false); -#endif - break; + break; case LFUN_SETMARK: if(owner->view()->text->mark_set) { @@ -2032,15 +2020,6 @@ string LyXFunc::Dispatch(int ac, new_inset->Edit(owner->view(), 0, 0, 0); } break; -#if 0 - case LFUN_INSET_NUMBER: - { - InsetNumber * new_inset = new InsetNumber(owner->buffer()); - owner->view()->insertInset(new_inset); - new_inset->Edit(owner->view(), 0, 0, 0); - } - break; -#endif case LFUN_INSET_ERT: { InsetERT * new_inset = new InsetERT(owner->buffer()); @@ -2649,20 +2628,6 @@ string LyXFunc::Dispatch(int ac, } owner->view()->beforeChange(); - -#if 0 - if (isdigit(argument[0]) && - (lyxrc.number_inset == "true" || - (lyxrc.number_inset == "rtl" && - owner->view()->text->real_current_font.isVisibleRightToLeft() - ))) { - UpdatableInset * tmpinset = new InsetNumber(owner->buffer()); - owner->view()->open_new_inset(tmpinset); - tmpinset->LocalDispatch(owner->view(), action, - argument); - return string(); - } -#endif for (string::size_type i = 0; i < argument.length(); ++i) { diff --git a/src/lyxtext.h b/src/lyxtext.h index b9df6e38da..64ff77d9f5 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -285,7 +285,7 @@ public: /// void DeleteLineForward(); /// - int SelectWordWhenUnderCursor(); + bool SelectWordWhenUnderCursor(); enum TextCase { text_lowercase = 0, diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 7b499e5863..5737a6ab01 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -317,14 +317,18 @@ int InsetFormula::Latex(ostream & os, bool fragile, bool) const int ret = 0; //#warning Alejandro, the number of lines is not returned in this case // This problem will disapear at 0.13. - if (fragile) // this is where fragile != 0 was used (Lgb) - par->Write(os, fragile); - else - mathed_write(par, os, &ret, fragile, label.c_str()); + mathed_write(par, os, &ret, fragile, label.c_str()); return ret; } +int InsetFormula::Ascii(ostream & os) const +{ + par->Write(os, false); + return 0; +} + + int InsetFormula::Linuxdoc(ostream &) const { return 0; diff --git a/src/mathed/formula.h b/src/mathed/formula.h index 3120560209..365000021f 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -54,6 +54,8 @@ public: /// int Latex(std::ostream &, bool fragile, bool free_spc) const; /// + int Ascii(std::ostream &) const; + /// int Linuxdoc(std::ostream &) const; /// int DocBook(std::ostream &) const; diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index a382f96968..ac0a538e61 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -276,7 +276,11 @@ void MathParInset::Write(ostream & os, bool fragile) << "} "; } } -#if 1 + + // CHECK + // Just make sure that the correct number of braces are output. + // (Lgb) +#if 0 while (brace > 0) { os << '}'; --brace; @@ -330,12 +334,12 @@ void mathed_write(MathParInset * p, ostream & os, int * newlines, os << "\\( "; // changed from " \\( " (Albrecht Dress) } else { - // Thinko! + // CHECK // Is this '\n' really needed, what can go wrong //if it is not there? The reason why I want to avoid this is // because of the "backlook" into the output stream. // Lgb. -#warning Thinko! +#warning CHECK #if 0 if (!suffixIs(outf, '\n')) { // in batchmode we need to make sure diff --git a/src/paragraph.C b/src/paragraph.C index 747e7e0dcc..0d705667a2 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -3129,20 +3129,13 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow, && running_font.isRightToLeft()) { os << "\\L{"; close = true; - } else if (inset->LyxCode() == Inset::NUMBER_CODE - && running_font.isRightToLeft()) { - os << "{\\beginL "; - close = true; } int tmp = inset->Latex(os, style.isCommand(), style.free_spacing); if (close) - if (inset->LyxCode() == Inset::NUMBER_CODE) - os << "\\endL}"; - else - os << "}"; + os << "}"; if (tmp) { column = 0; @@ -3403,10 +3396,9 @@ bool LyXParagraph::RoffContTableRows(ostream & os, switch (c) { case LyXParagraph::META_INSET: if ((inset = GetInset(i))) { -#if 1 #ifdef HAVE_SSTREAM stringstream ss(ios::in | ios::out); - inset->Latex(ss, true); + inset->Ascii(ss); ss.seekp(0); ss.get(c); while (!ss) { @@ -3418,7 +3410,7 @@ bool LyXParagraph::RoffContTableRows(ostream & os, } #else strstream ss; - inset->Latex(ss, true); + inset->Ascii(ss); ss.seekp(0); ss.get(c); while (!ss) { @@ -3429,27 +3421,6 @@ bool LyXParagraph::RoffContTableRows(ostream & os, ss.get(c); } delete [] ss.str(); -#endif -#else - fstream fs(fname2.c_str(), - ios::in|ios::out); - if (!fs) { - WriteAlert(_("LYX_ERROR:"), - _("Cannot open temporary file:"), - fname2); - return false; - } - inset->Latex(fs, true); - fs.seekp(0); - fs.get(c); - while (!fs) { - if (c == '\\') - os << "\\\\"; - else - os << c; - fs.get(c); - } - fs.close(); #endif } break; diff --git a/src/text.C b/src/text.C index 1e2ee06141..f8df1fd96a 100644 --- a/src/text.C +++ b/src/text.C @@ -45,8 +45,6 @@ static const int LYX_PAPER_MARGIN = 20; // ale070405 extern int bibitemMaxWidth(Painter &, LyXFont const &); -#define FIX_DOUBLE_SPACE 1 - static int iso885968x[] = { 0xbc, // 0xa8 = fathatan 0xbd, // 0xa9 = dammatan @@ -2326,23 +2324,13 @@ void LyXText::InsertCharInTable(char c) jumped_over_space = false; if (IsLineSeparatorChar(c)) { - -#ifndef FIX_DOUBLE_SPACE - /* avoid double blanks but insert the new blank because - * of a possible font change */ - if (cursor.pos < lastpos && - cursor.par->IsLineSeparator(cursor.pos)) { - cursor.par->Erase(cursor.pos); - jumped_over_space = true; - } else -#endif - if ((cursor.pos > 0 && - cursor.par->IsLineSeparator(cursor.pos - 1)) - || (cursor.pos > 0 && cursor.par->IsNewline(cursor.pos - 1)) - || (cursor.pos == 0 && - !(cursor.par->Previous() - && cursor.par->Previous()->footnoteflag - == LyXParagraph::OPEN_FOOTNOTE))) + if ((cursor.pos > 0 && + cursor.par->IsLineSeparator(cursor.pos - 1)) + || (cursor.pos > 0 && cursor.par->IsNewline(cursor.pos - 1)) + || (cursor.pos == 0 && + !(cursor.par->Previous() + && cursor.par->Previous()->footnoteflag + == LyXParagraph::OPEN_FOOTNOTE))) return; } else if (IsNewlineChar(c)) { if (!IsEmptyTableCell()) { @@ -2467,8 +2455,7 @@ void LyXText::BackspaceInTable() if (cursor.par->IsNewline(cursor.pos)) { /* nothing :-) */ return; - } - else { + } else { cursor.par->Erase(cursor.pos); /* refresh the positions */ @@ -2477,28 +2464,6 @@ void LyXText::BackspaceInTable() tmprow = tmprow->next; tmprow->pos--; } - -#ifndef FIX_DOUBLE_SPACE - /* delete superfluous blanks */ - if (cursor.pos < cursor.par->Last() - 1 && - (cursor.par->IsLineSeparator(cursor.pos))) { - - if (cursor.pos == BeginningOfMainBody(cursor.par) - || !cursor.pos - || cursor.par->IsLineSeparator(cursor.pos - 1)) { - cursor.par->Erase(cursor.pos); - /* refresh the positions */ - tmprow = row; - while (tmprow->next && - tmprow->next->par == row->par) { - tmprow = tmprow->next; - tmprow->pos--; - } - if (cursor.pos) /* move one character left */ - cursor.pos--; - } - } -#endif } CheckParagraphInTable(cursor.par, cursor.pos); @@ -2522,18 +2487,9 @@ void LyXText::BackspaceInTable() /* just a macro to make some thing easier. */ void LyXText::RedoParagraph() const { -#if 1 - // I suspect this version will work - // also. ClearSelection(); RedoParagraphs(cursor, cursor.par->Next()); SetCursorIntern(cursor.par, cursor.pos); -#else - LyXCursor tmpcursor = cursor; - ClearSelection(); - RedoParagraphs(cursor, cursor.par->Next()); - SetCursorIntern(tmpcursor.par, tmpcursor.pos); -#endif } @@ -2587,34 +2543,6 @@ void LyXText::InsertChar(char c) bool jumped_over_space = false; if (!freeSpacing && IsLineSeparatorChar(c)) { -#ifndef FIX_DOUBLE_SPACE - if (cursor.pos < lastpos - && cursor.par->IsLineSeparator(cursor.pos)) { - /* the user inserted a space before a space. So we - * will just make a CursorRight. BUT: The font of this - * space should be set to current font. That is why - * we need to rebreak perhaps. If there is a protected - * blank at the end of a row we have to force - * a rebreak.*/ - - owner_->owner()->getMiniBuffer() - ->Set(_("You cannot type two spaces this way. " - " Please read the Tutorial.")); -#if 1 - // How can this ever happen? - if (cursor.pos == RowLast(cursor.row) - && !IsLineSeparatorChar(c)) - cursor.row->fill = -1; // force rebreak - cursor.par->Erase(cursor.pos); - jumped_over_space = true; -#else - // Seems to me that this works just as well. - CursorRight(); - charInserted(); - return; -#endif - } else -#endif if ((cursor.pos > 0 && cursor.par->IsLineSeparator(cursor.pos - 1)) || (cursor.pos > 0 @@ -3049,19 +2977,18 @@ void LyXText::SelectWord() 1: no selection is currently set, 2: the cursor is not at the borders of the word. */ -int LyXText::SelectWordWhenUnderCursor() +bool LyXText::SelectWordWhenUnderCursor() { - if ( selection ) return 0; - if ( cursor.pos < cursor.par->Last() - && !cursor.par->IsSeparator(cursor.pos) - && !cursor.par->IsKomma(cursor.pos) - && cursor.pos - && !cursor.par->IsSeparator(cursor.pos -1) - && !cursor.par->IsKomma(cursor.pos -1) ) { + if (!selection && + cursor.pos > 0 && cursor.pos < cursor.par->Last() + && !cursor.par->IsSeparator(cursor.pos) + && !cursor.par->IsKomma(cursor.pos) + && !cursor.par->IsSeparator(cursor.pos -1) + && !cursor.par->IsKomma(cursor.pos -1) ) { SelectWord(); - return 1; + return true; } - return 0; + return false; } @@ -3312,16 +3239,11 @@ void LyXText::Delete() // and that can very well delete the par or par->previous in // old_cursor. Will a solution where we compare paragraph id's //work better? -#if 1 if ((cursor.par->previous ? cursor.par->previous->id() : 0) == old_cur_par_prev_id && cursor.par->id() != old_cur_par_id) return; // delete-empty-paragraph-mechanism has done it -#else - if (cursor.par->previous == old_cursor.par->previous - && cursor.par != old_cursor.par) - return; // delete-empty-paragraph-mechanism has done it -#endif + // if you had success make a backspace if (old_cursor.par != cursor.par || old_cursor.pos != cursor.pos) { LyXCursor tmpcursor = cursor; @@ -3530,28 +3452,6 @@ void LyXText::Backspace() tmprow->pos--; } -#ifndef FIX_DOUBLE_SPACE - // delete superfluous blanks - if (cursor.pos < cursor.par->Last() - 1 && - (cursor.par->IsLineSeparator(cursor.pos))) { - - if (cursor.pos == BeginningOfMainBody(cursor.par) - || !cursor.pos - || cursor.par->IsLineSeparator(cursor.pos - 1)) { - cursor.par->Erase(cursor.pos); - // refresh the positions - tmprow = row; - while (tmprow->next && - tmprow->next->par == row->par) { - tmprow = tmprow->next; - tmprow->pos--; - } - if (cursor.pos) // move one character left - cursor.pos--; - } - } -#endif - // delete newlines at the beginning of paragraphs while (cursor.par->Last() && cursor.par->IsNewline(cursor.pos) && @@ -4305,40 +4205,6 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y) } else if (row_ptr->par->IsSeparator(pos)) { tmpx = x; x+= SingleWidth(row_ptr->par, pos); -#warning Think about this. -#if 0 - /* -------> Only draw protected spaces when - * not in free-spacing mode. */ - if (row_ptr->par->GetChar(pos) == LyXParagraph::META_PROTECTED_SEPARATOR && !layout.free_spacing) { - pain.line(int(tmpx), - offset + row_ptr->baseline - 3, - int(tmpx), - offset + row_ptr->baseline - 1, - LColor::vfillline); - - pain.line(int(tmpx), - offset + row_ptr->baseline - 1, - int(x - 2), - offset + row_ptr->baseline - 1, - LColor::vfillline); - - pain.line(int(x - 2), - offset + row_ptr->baseline - 3, - int(x - 2), - offset + row_ptr->baseline - 1, - LColor::vfillline); - - /* what about underbars? */ - font = GetFont(row_ptr->par, pos); - if (font.underbar() == LyXFont::ON - && font.latex() != LyXFont::ON) { - pain.line(int(tmpx), - offset + row_ptr->baseline + 2, - int(x - tmpx), - offset + row_ptr->baseline + 2); - } - } -#endif ++vpos; } else draw(row_ptr, vpos, offset, x); @@ -4441,47 +4307,9 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y) x += 2; ++vpos; } else if (row_ptr->par->IsSeparator(pos)) { -#if 0 - tmpx = x; -#endif x += SingleWidth(row_ptr->par, pos); if (pos >= main_body) x += fill_separator; -#warning Think about this -#if 0 - /* -------> Only draw protected spaces when - * not in free-spacing mode. */ - if (row_ptr->par->GetChar(pos) == LyXParagraph::META_PROTECTED_SEPARATOR && !layout.free_spacing) { - - pain.line(int(tmpx), - offset + row_ptr->baseline - 3, - int(tmpx), - offset + row_ptr->baseline - 1, - LColor::vfillline); - - pain.line(int(tmpx), - offset + row_ptr->baseline - 1, - int(x - 2), - offset + row_ptr->baseline - 1, - LColor::vfillline); - - pain.line(int(x - 2), - offset + row_ptr->baseline - 3, - int(x - 2), - offset + row_ptr->baseline - 1, - LColor::vfillline); - - /* what about underbars? */ - font = GetFont(row_ptr->par, pos); - if (font.underbar() == LyXFont::ON - && font.latex() != LyXFont::ON) { - pain.line(int(tmpx), - offset + row_ptr->baseline + 2, - int(x - tmpx), - offset + row_ptr->baseline + 2); - } - } -#endif ++vpos; } else draw(row_ptr, vpos, offset, x); diff --git a/src/text2.C b/src/text2.C index e15b93454a..ffbb5d2f89 100644 --- a/src/text2.C +++ b/src/text2.C @@ -40,7 +40,6 @@ #include "font.h" #include "debug.h" -#define FIX_DOUBLE_SPACE 1 //#define USE_OLD_CUT_AND_PASTE 1 using std::copy; @@ -1087,8 +1086,11 @@ void LyXText::ToggleFree(LyXFont const & font, bool toggleall) } // Try implicit word selection + // If there is a change in the language the implicit word selection + // is disabled. LyXCursor resetCursor = cursor; - int implicitSelection = SelectWordWhenUnderCursor(); + bool implicitSelection = (font.language() == ignore_language) + ? SelectWordWhenUnderCursor() : false; // Set font SetFont(font, toggleall); @@ -1995,22 +1997,6 @@ void LyXText::CutSelection(bool doclear) (Lgb) */ -#ifndef FIX_DOUBLE_SPACE - bool space_wrapped = - sel_end_cursor.par->IsLineSeparator(sel_end_cursor.pos); - if (sel_end_cursor.pos > 0 - && sel_end_cursor.par->IsLineSeparator(sel_end_cursor.pos - 1)) { - // please break before a space at the end - sel_end_cursor.pos--; - space_wrapped = true; - } - // cut behind a space if there is one - while (sel_start_cursor.par->Last() > sel_start_cursor.pos - && sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos) - && (sel_start_cursor.par != sel_end_cursor.par - || sel_start_cursor.pos < sel_end_cursor.pos)) - sel_start_cursor.pos++; -#endif // there are two cases: cut only within one paragraph or // more than one paragraph @@ -2033,55 +2019,19 @@ void LyXText::CutSelection(bool doclear) } simple_cut_buffer->InsertFromMinibuffer(simple_cut_buffer->Last()); } -#ifndef FIX_DOUBLE_SPACE - // check for double spaces - if (sel_start_cursor.pos && - sel_start_cursor.par->Last() > sel_start_cursor.pos - && sel_start_cursor.par - ->IsLineSeparator(sel_start_cursor.pos - 1) - && sel_start_cursor.par - ->IsLineSeparator(sel_start_cursor.pos)) { - sel_start_cursor.par->Erase(sel_start_cursor.pos); - } - if (space_wrapped) - simple_cut_buffer->InsertChar(i - sel_start_cursor.pos, - ' '); -#endif endpar = sel_end_cursor.par->Next(); } else { // cut more than one paragraph sel_end_cursor.par ->BreakParagraphConservative(sel_end_cursor.pos); -#ifndef FIX_DOUBLE_SPACE - // insert a space at the end if there was one - if (space_wrapped) - sel_end_cursor.par - ->InsertChar(sel_end_cursor.par->Last(), ' '); -#endif sel_end_cursor.par = sel_end_cursor.par->Next(); sel_end_cursor.pos = 0; cursor = sel_end_cursor; -#ifndef FIX_DOUBLE_SPACE - // please break behind a space, if there is one. - // The space should be copied too - if (sel_start_cursor.par - ->IsLineSeparator(sel_start_cursor.pos)) - sel_start_cursor.pos++; -#endif sel_start_cursor.par ->BreakParagraphConservative(sel_start_cursor.pos); -#ifndef FIX_DOUBLE_SPACE - if (!sel_start_cursor.pos - || sel_start_cursor.par - ->IsLineSeparator(sel_start_cursor.pos - 1) - || sel_start_cursor.par - ->IsNewline(sel_start_cursor.pos - 1)) { - sel_start_cursor.par->Next()->InsertChar(0, ' '); - } -#endif // store the endparagraph for redoing later endpar = sel_end_cursor.par->Next(); /* needed because the sel_end_ @@ -2120,17 +2070,6 @@ void LyXText::CutSelection(bool doclear) || !sel_start_cursor.par->Next()->Last()) sel_start_cursor.par->ParFromPos(sel_start_cursor.pos)->PasteParagraph(); - -#ifndef FIX_DOUBLE_SPACE - // maybe a forgotten blank - if (sel_start_cursor.pos - && sel_start_cursor.par - ->IsLineSeparator(sel_start_cursor.pos) - && sel_start_cursor.par - ->IsLineSeparator(sel_start_cursor.pos - 1)) { - sel_start_cursor.par->Erase(sel_start_cursor.pos); - } -#endif } // sometimes necessary @@ -2282,14 +2221,13 @@ void LyXText::CopySelection() // set the textclass simple_cut_buffer_textclass = buffer->params->textclass; -#ifdef FIX_DOUBLE_SPACE // copy behind a space if there is one while (sel_start_cursor.par->Last() > sel_start_cursor.pos && sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos) && (sel_start_cursor.par != sel_end_cursor.par || sel_start_cursor.pos < sel_end_cursor.pos)) sel_start_cursor.pos++; -#endif + // there are two cases: copy only within one paragraph // or more than one paragraph if (sel_start_cursor.par->ParFromPos(sel_start_cursor.pos) @@ -2383,14 +2321,12 @@ void LyXText::CopySelection() } /* table stuff -- end */ -#ifdef FIX_DOUBLE_SPACE // copy behind a space if there is one while (sel_start_cursor.par->Last() > sel_start_cursor.pos && sel_start_cursor.par->IsLineSeparator(sel_start_cursor.pos) && (sel_start_cursor.par != sel_end_cursor.par || sel_start_cursor.pos < sel_end_cursor.pos)) sel_start_cursor.pos++; -#endif CutAndPaste cap; @@ -2450,12 +2386,6 @@ void LyXText::PasteSelection() if (!simple_cut_buffer->next) { // only within a paragraph -#ifndef FIX_DOUBLE_SPACE - // please break behind a space, if there is one - while (tmpcursor.par->Last() > tmpcursor.pos - && tmpcursor.par->IsLineSeparator(tmpcursor.pos)) - tmpcursor.pos++; -#endif tmppar = simple_cut_buffer->Clone(); /* table stuff -- begin */ bool table_too_small = false; @@ -2471,7 +2401,6 @@ void LyXText::PasteSelection() else table_too_small = true; } else { -#ifdef FIX_DOUBLE_SPACE // This is an attempt to fix the // "never insert a space at the // beginning of a paragraph" problem. @@ -2484,12 +2413,6 @@ void LyXText::PasteSelection() tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos); tmpcursor.pos++; } -#else - simple_cut_buffer->CutIntoMinibuffer(0); - simple_cut_buffer->Erase(0); - tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos); - tmpcursor.pos++; -#endif } } } else { @@ -2501,7 +2424,6 @@ void LyXText::PasteSelection() // the beginning of the paragraph the space should // be removed. while (simple_cut_buffer->size()) { -#ifdef FIX_DOUBLE_SPACE // This is an attempt to fix the // "never insert a space at the // beginning of a paragraph" problem. @@ -2514,12 +2436,6 @@ void LyXText::PasteSelection() tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos); tmpcursor.pos++; } -#else - simple_cut_buffer->CutIntoMinibuffer(0); - simple_cut_buffer->Erase(0); - tmpcursor.par->InsertFromMinibuffer(tmpcursor.pos); - tmpcursor.pos++; -#endif } } delete simple_cut_buffer; @@ -2562,13 +2478,6 @@ void LyXText::PasteSelection() while (lastbuffer->Next()) lastbuffer = lastbuffer->Next(); -#ifndef FIX_DOUBLE_SPACE - // Please break behind a space, if there is one. The space - // should be copied too. - if (cursor.par->Last() > cursor.pos - && cursor.par->IsLineSeparator(cursor.pos)) - cursor.pos++; -#endif bool paste_the_end = false; // open the paragraph for inserting the simple_cut_buffer @@ -2578,15 +2487,6 @@ void LyXText::PasteSelection() paste_the_end = true; } -#ifndef FIX_DOUBLE_SPACE - // be careful with double spaces - if ((!cursor.par->Last() - || cursor.par->IsLineSeparator(cursor.pos - 1) - || cursor.par->IsNewline(cursor.pos - 1)) - && simple_cut_buffer->text.size() - && simple_cut_buffer->IsLineSeparator(0)) - simple_cut_buffer->Erase(0); -#endif // set the end for redoing later endpar = cursor.par->ParFromPos(cursor.pos)->next->Next(); @@ -2612,41 +2512,14 @@ void LyXText::PasteSelection() // maybe some pasting if (lastbuffer->Next() && paste_the_end) { if (lastbuffer->Next()->HasSameLayout(lastbuffer)) { -#ifndef FIX_DOUBLE_SPACE - // be careful with double spaces - if ((!lastbuffer->Last() - || lastbuffer->IsLineSeparator(lastbuffer->Last() - 1) - || lastbuffer->IsNewline(lastbuffer->Last() - 1)) - && lastbuffer->Next()->Last() - && lastbuffer->Next()->IsLineSeparator(0)) - lastbuffer->Next()->Erase(0); -#endif lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(); } else if (!lastbuffer->Next()->Last()) { lastbuffer->Next()->MakeSameLayout(lastbuffer); -#ifndef FIX_DOUBLE_SPACE - // be careful witth double spaces - if ((!lastbuffer->Last() - || lastbuffer->IsLineSeparator(lastbuffer->Last() - 1) - || lastbuffer->IsNewline(lastbuffer->Last() - 1)) - && lastbuffer->Next()->Last() - && lastbuffer->Next()->IsLineSeparator(0)) - lastbuffer->Next()->Erase(0); -#endif lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(); } else if (!lastbuffer->Last()) { lastbuffer->MakeSameLayout(lastbuffer->next); -#ifndef FIX_DOUBLE_SPACE - // be careful witth double spaces - if ((!lastbuffer->Last() - || lastbuffer->IsLineSeparator(lastbuffer->Last() - 1) - || lastbuffer->IsNewline(lastbuffer->Last() - 1)) - && lastbuffer->Next()->Last() - && lastbuffer->Next()->IsLineSeparator(0)) - lastbuffer->Next()->Erase(0); -#endif lastbuffer->ParFromPos(lastbuffer->Last())->PasteParagraph(); } else @@ -2856,7 +2729,6 @@ void LyXText::InsertStringA(string const & str) ++pos; } } else if (str[i] == ' ') { -#if 1 InsetSpecialChar * new_inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); if (par->InsertInsetAllowed(new_inset)) { @@ -2866,14 +2738,9 @@ void LyXText::InsertStringA(string const & str) } else { delete new_inset; } -#else - par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR); - par->SetFont(pos, current_font); -#endif ++pos; } else if (str[i] == '\t') { for (a = pos; a < (pos / 8 + 1) * 8 ; ++a) { -#if 1 InsetSpecialChar * new_inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); if (par->InsertInsetAllowed(new_inset)) { @@ -2883,10 +2750,6 @@ void LyXText::InsertStringA(string const & str) } else { delete new_inset; } -#else - par->InsertChar(a, LyXParagraph::META_PROTECTED_SEPARATOR); - par->SetFont(a, current_font); -#endif } pos = a; } else if (str[i] != 13 && @@ -2921,7 +2784,6 @@ void LyXText::InsertStringA(string const & str) break; } else { if (!par->size()) { // par is empty -#if 1 InsetSpecialChar * new_inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); if (par->InsertInsetAllowed(new_inset)) { @@ -2931,10 +2793,6 @@ void LyXText::InsertStringA(string const & str) } else { delete new_inset; } -#else - par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR); - par->SetFont(pos, current_font); -#endif ++pos; } par->BreakParagraph(pos, flag); @@ -3156,6 +3014,7 @@ void LyXText::SetCursor(LyXParagraph * par, DeleteEmptyParagraphMechanism(old_cursor); } + void LyXText::SetCursor(LyXCursor & cur, LyXParagraph * par, LyXParagraph::size_type pos) const { @@ -3588,7 +3447,6 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const bool deleted = false; -#ifdef FIX_DOUBLE_SPACE /* Ok I'll put some comments here about what is missing. I have fixed BackSpace (and thus Delete) to not delete double-spaces automagically. I have also changed Cut, @@ -3630,8 +3488,7 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const return; } } -#endif -#if 1 + // Do not delete empty paragraphs with keepempty set. if ((textclasslist.Style(buffer->params.textclass, old_cursor.par->GetLayout())).keepempty) @@ -3734,14 +3591,9 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const } // correct cursor y -#if 1 + SetCursorIntern(cursor.par, cursor.pos); -#else - SetCursor(cursor.par, cursor.pos); -#endif - /* if (cursor.y > old_cursor.y) - cursor.y -= old_cursor.row->height; */ - + if (sel_cursor.par == old_cursor.par && sel_cursor.pos == sel_cursor.pos) { // correct selection @@ -3753,16 +3605,11 @@ void LyXText::DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const if (old_cursor.par->ClearParagraph()) { RedoParagraphs(old_cursor, old_cursor.par->Next()); // correct cursor y -#if 1 SetCursorIntern(cursor.par, cursor.pos); -#else - SetCursor(cursor.par, cursor.pos); -#endif sel_cursor = cursor; } } } -#endif }