+2000-04-23 Dekel Tsur <dekel@math.tau.ac.il>
+
+ * 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 <larsbj@lyx.org>
+
+ * 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 <jug@sad.it>
* src/insets/insettext.C (cutSelection):
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
}
}
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
}
}
* 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;
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)
#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"
}
-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);
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.
} 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
} 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") {
} 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());
} 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());
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");
font.setLanguage(params.language_info);
else
lex.printError("Unknown direction `$$Token'");
+#endif
} else if (token == "\\emph") {
lex.next();
font.setEmph(font.setLyXMisc(lex.GetString()));
//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);
} 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") {
}
}
} 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);
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();
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);
}
++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);
par->SetFont(pos, font);
++pos;
} else if (token == "\\protected_separator") { // obsolete
-#if 1
LyXLayout const & layout =
textclasslist.Style(params.textclass,
par->GetLayout());
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)
// 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;
}
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){
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) {
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;
}
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) {
}
#else
strstream ss;
- inset->Latex(ss, true);
+ inset->Ascii(ss);
ss.seekp(0);
ss.get(c);
while (!ss) {
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;
#include <config.h>
+#include <fstream>
+#include <queue>
+#include <list>
+#include <algorithm>
+#include <vector>
+
#include <unistd.h>
#include <csignal>
#include <sys/wait.h>
#include <cstdlib>
#include <cctype>
#include <cmath>
-#include <fstream>
-#include <queue>
-#include <list>
-#include <algorithm>
-#include <vector>
#include "figinset.h"
#include "lyx.h"
#include "support/lyxlib.h"
#include "Painter.h"
#include "font.h"
-//#include "lyx_cb.h"
#include "bufferview_funcs.h"
#include "ColorHandler.h"
using std::find;
using std::flush;
using std::endl;
+using std::ostringstream;
extern BufferView * current_view;
extern FL_OBJECT * figinset_canvas;
}
+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<XClientMessageEvent*>(ev);
if(lyxerr.debugging()) {
// 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<long>((*it)->bitmap) ==
}
}
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;
}
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) ||
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);
}
while (gsrunning < MAXGS) {
- char tbuf[384], tbuf2[80];
+ //char tbuf[384]; //, tbuf2[80];
Atom * prop;
int nprop, i;
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 "
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
}
XFree(reinterpret_cast<char *>(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()) {
XInternAtom(tempdisp, "GHOSTVIEW", false),
XInternAtom(tempdisp, "STRING", false),
8, PropModeAppend,
- reinterpret_cast<unsigned char*>(tbuf),
- strlen(tbuf));
+ reinterpret_cast<unsigned char*>(const_cast<char*>(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,
"GHOSTVIEW_COLORS", false),
XInternAtom(tempdisp, "STRING", false),
8, PropModeReplace,
- reinterpret_cast<unsigned char*>(tbuf),
- strlen(tbuf));
+ reinterpret_cast<unsigned char*>(const_cast<char*>(t3.str().c_str())),
+ t3.str().size());
XUngrabServer(tempdisp);
XFlush(tempdisp);
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;
// 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;
}
"-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.
lyxerr.debug() << "Cmd: "
<< lyxrc.ps_command
<< " -sDEVICE=x11 "
- << tbuf << ' '
+ << tmpf.c_str() << ' '
<< p->data->fname << endl;
_exit(0); // no gs?
}
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 */
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;
}
}
+int InsetFig::Ascii(ostream &) const
+{
+ return 0;
+}
+
+
int InsetFig::Linuxdoc(ostream &) const
{
return 0;
}
+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;
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*{";
if (angle != 0) {
- char buf[10];
- sprintf(buf, "%g", angle);
// \rotatebox{angle}{text}
- rotate = "\\rotatebox{";
- rotate += buf;
- rotate += "}{";
+ rotate = "\\rotatebox{" + tostr(angle) + "}{";
}
cmdbuf = recmd;
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;
}
string fname2 = MakeRelPath(tfname, buf1);
// \includegraphics*[<llx,lly>][<urx,ury>]{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()) {
}
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()) {
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;
void InsetFig::RestoreForm()
{
- char buf[32];
-
EnableFigurePanel(form);
twtype = wtype;
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);
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());
///
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;
#include "lyxfont.h"
#include "BufferView.h"
#include "Painter.h"
+#include "support/LOstream.h"
+using std::ostream;
InsetCollapsable::InsetCollapsable(Buffer * bf)
: InsetText(bf)
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);
}
-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;
return HIGHLY_EDITABLE;
}
-void InsetCollapsable::InsetUnlock(BufferView *bv)
+
+void InsetCollapsable::InsetUnlock(BufferView * bv)
{
if (autocollapse) {
collapsed = true;
}
-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);
}
-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)) {
}
}
-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<UpdatableInset*>(owner())->getMaxWidth(pain,inset));
+ return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset);
if (owner())
- return (static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset)-
- width_collapsed(pain, labelfont) - 2 - widthOffset);
+ return static_cast<UpdatableInset*>(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
{
}
+int InsetCommand::Ascii(ostream &) const
+{
+ return 0;
+}
+
+
int InsetCommand::Linuxdoc(ostream &) const
{
return 0;
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;
}
+int InsetError::Ascii(ostream &) const
+{
+ return 0;
+}
+
+
int InsetError::Linuxdoc(ostream &) const
{
return 0;
///
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;
}
+int InsetGraphics::Ascii(ostream &) const
+{
+ return 0;
+}
+
+
int InsetGraphics::Linuxdoc(ostream &) const
{
return 0;
*/
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;
}
+int InsetInfo::Ascii(ostream &) const
+{
+ return 0;
+}
+
+
int InsetInfo::Linuxdoc(ostream &) const
{
return 0;
///
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;
return 0;
}
+int InsetLabel::Ascii(ostream & os) const
+{
+ os << "<" << getContents() << ">";
+ return 0;
+}
+
int InsetLabel::Linuxdoc(ostream & os) const
{
///
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;
}
+int InsetLatex::Ascii(string & file)
+{
+ file += contents;
+ return 0;
+}
+
+
int InsetLatex::Linuxdoc(string & file)
{
file += contents;
///
int Latex(string & file, signed char fragile, bool free_spc);
///
+ int Ascii(string & file) const;
+ ///
int Linuxdoc(string & file);
///
int DocBook(string & file);
}
+int InsetLatexAccent::Ascii(ostream & os) const
+{
+ os << contents;
+ return 0;
+}
+
+
int InsetLatexAccent::Linuxdoc(ostream & os) const
{
os << contents;
///
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;
// 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] == '`')
}
+int InsetQuotes::Ascii(ostream & os) const
+{
+ os << "\"";
+ return 0;
+}
+
+
int InsetQuotes::Linuxdoc(ostream & os) const
{
os << "\"";
///
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;
}
+int InsetRef::Ascii(ostream & os) const
+{
+ os << "[" << getContents() << "]";
+ return 0;
+}
+
+
int InsetRef::Linuxdoc(ostream & os) const
{
os << "<ref id=\"" << getContents()
///
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;
return 0;
}
-
-int InsetSpecialChar::Linuxdoc(ostream & os) const
+int InsetSpecialChar::Ascii(ostream & os) const
{
switch (kind) {
- case HYPHENATION: os << ""; break;
- case END_OF_SENTENCE: os << ""; break;
+ case HYPHENATION: break;
+ case END_OF_SENTENCE: os << "."; break;
case LDOTS: os << "..."; break;
case MENU_SEPARATOR: os << "->"; break;
case PROTECTED_SEPARATOR: os << " "; break;
}
+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);
}
///
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;
*
* LyX, The Document Processor
*
- * Copyright (C) 2000 The LyX Team.
+ * Copyright 2000 The LyX Team.
*
*======================================================
*/
using std::ostream;
using std::ifstream;
+using std::max;
+using std::endl;
+
InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
{
init = true;
}
+
InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
{
tabular = new LyXTabular(*(tab.tabular), buf);
init = true;
}
+
InsetTabular::~InsetTabular()
{
- if (tabular)
delete tabular;
}
void InsetTabular::Read(LyXLex & lex)
{
- if (tabular)
delete tabular;
// bool old_format = (lex.GetString() == "\\LyXTabular");
}
-const char * InsetTabular::EditMessage() const
+char const * InsetTabular::EditMessage() const
{
return _("Opened Tabular Inset");
}
no_selection = false;
}
+
bool InsetTabular::LockInsetInInset(UpdatableInset *)
{
return true;
bv->updateInset(this, flag);
}
+
bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
{
if (!the_locking_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);
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;
the_locking_inset->InsetUnlock(bv);
}
#if 0
- int
- oldcell = actcell;
+ int oldcell = actcell;
#endif
setPos(bv->painter(),x,y);
the_locking_inset = 0;
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;
}
-UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView *bv, int action,
+UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
string const & arg)
{
UpdatableInset::RESULT
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())
}
-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);
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();
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;
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) +
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; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
+
+ int cell = 0;
+ for(; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
if (tabular->IsLastCellInRow(cell)) {
cursor.y += tabular->DescentOfRow(actrow) +
tabular->AscentOfRow(actrow+1) +
}
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;
}
}
}
+
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;
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
///
int Latex(std::ostream &, bool, bool) const;
///
+ int Ascii(std::ostream &) const;
+ ///
int Linuxdoc(std::ostream &) const;
///
int DocBook(std::ostream &) const;
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();
autoBreakRows = ins.autoBreakRows;
}
+
void InsetText::init(Buffer * buf, InsetText const * ins)
{
the_locking_inset = 0;
no_selection = false;
}
+
bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
{
lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): ";
return false;
}
+
bool InsetText::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
bool lr)
{
}
-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);
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,
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;
(par->GetChar(p + 1)==LyXParagraph::META_INSET))
inset = par->GetInset(p + 1);
if (inset) {
- inset->setOwner(this);
+ inset->setOwner(const_cast<InsetText*>(this)); // is this safe?
if (inset->display()) {
if (!is_first_word_in_row && (width >= maxWidth)) {
// we have to split also the row above
}
}
-void InsetText::UpdateLocal(BufferView *bv, bool flag)
+
+void InsetText::UpdateLocal(BufferView * bv, bool flag)
{
if (flag) {
computeTextRows(bv->painter(), xpos);
resetPos(bv->painter());
}
+
bool InsetText::cutSelection()
{
if (!hasSelection())
CutAndPaste cap;
- LyXParagraph *endpar = par;
+ LyXParagraph * endpar = par;
int start, end;
if (selection_start > selection_end) {
start = selection_end;
return cap.cutSelection(par, &endpar, start, end,buffer->params.textclass);
}
+
bool InsetText::copySelection()
{
if (!hasSelection())
return cap.copySelection(par, par, start, end, buffer->params.textclass);
}
+
bool InsetText::pasteSelection()
{
CutAndPaste cap;
buffer->params.textclass);
}
+
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
int button)
{
return false;
}
+
int InsetText::getMaxTextWidth(Painter & pain, UpdatableInset const * inset,
int x) const
{
///
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; }
}
+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()
///
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;
///
SPECIALCHAR_CODE,
///
- NUMBER_CODE,
- ///
TABULAR_CODE
};
*/
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;
///
// 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 },
{ "textfont", LT_TEXTFONT },
{ "topsep", LT_TOPSEP }
};
-#endif
+
bool error = false;
bool finished = false;
lexrc.pushTable(layoutTags, LT_INTITLE);
void LyXLayout::readAlign(LyXLex & lexrc)
{
-#if 1
keyword_item alignTags[] = {
{ "block", AT_BLOCK },
{ "center", AT_CENTER },
{ "left", AT_LEFT },
{ "right", AT_RIGHT }
};
-#endif
+
pushpophelper pph(lexrc, alignTags, AT_LAYOUT);
int le = lexrc.lex();
switch (le) {
void LyXLayout::readAlignPossible(LyXLex & lexrc)
{
-#if 1
keyword_item alignTags[] = {
{ "block", AT_BLOCK },
{ "center", AT_CENTER },
{ "left", AT_LEFT },
{ "right", AT_RIGHT }
};
-#endif
+
lexrc.pushTable(alignTags, AT_LAYOUT);
alignpossible = LYX_ALIGN_NONE;
int lineno = lexrc.GetLineNo();
void LyXLayout::readLabelType(LyXLex & lexrc)
{
-#if 1
keyword_item labelTypeTags[] = {
{ "bibliography", LA_BIBLIO },
{ "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
{ "static", LA_STATIC },
{ "top_environment", LA_TOP_ENVIRONMENT }
};
-#endif
+
pushpophelper pph(lexrc, labelTypeTags, LA_BIBLIO);
int le = lexrc.lex();
switch (le) {
void LyXLayout::readMargin(LyXLex & lexrc)
{
-#if 1
keyword_item marginTags[] = {
{ "dynamic", MARGIN_DYNAMIC },
{ "first_dynamic", MARGIN_FIRST_DYNAMIC },
{ "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
{ "static", MARGIN_STATIC }
};
-#endif
+
pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX);
int le = lexrc.lex();
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) {
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) {
// 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 },
{ "sides", TC_SIDES },
{ "style", TC_STYLE },
{ "tocdepth", TC_TOCDEPTH }
-};
-#endif
+ };
+
if (!merge)
lyxerr[Debug::TCLASS] << "Reading textclass "
<< MakeDisplayPath(filename)
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();
void LyXTextClass::readMaxCounter(LyXLex & lexrc)
{
-#if 1
keyword_item maxCounterTags[] = {
{"counter_chapter", MC_COUNTER_CHAPTER },
{"counter_enumi", MC_COUNTER_ENUMI },
{"counter_subsection", MC_COUNTER_SUBSECTION },
{"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
};
-#endif
+
pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV);
int le = lexrc.lex();
switch(le) {
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()) {
#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"
case LFUN_FREE:
Free(owner->view());
+ owner->view()->setState();
+ owner->getMiniBuffer()->Set(CurrentState(owner->view()));
break;
case LFUN_TEX:
// --- 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,
}
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) {
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());
}
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) {
///
void DeleteLineForward();
///
- int SelectWordWhenUnderCursor();
+ bool SelectWordWhenUnderCursor();
enum TextCase {
text_lowercase = 0,
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;
///
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;
<< "} ";
}
}
-#if 1
+
+ // CHECK
+ // Just make sure that the correct number of braces are output.
+ // (Lgb)
+#if 0
while (brace > 0) {
os << '}';
--brace;
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
&& 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;
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) {
}
#else
strstream ss;
- inset->Latex(ss, true);
+ inset->Ascii(ss);
ss.seekp(0);
ss.get(c);
while (!ss) {
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;
// ale070405
extern int bibitemMaxWidth(Painter &, LyXFont const &);
-#define FIX_DOUBLE_SPACE 1
-
static int iso885968x[] = {
0xbc, // 0xa8 = fathatan
0xbd, // 0xa9 = dammatan
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()) {
if (cursor.par->IsNewline(cursor.pos)) {
/* nothing :-) */
return;
- }
- else {
+ } else {
cursor.par->Erase(cursor.pos);
/* refresh the positions */
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);
/* 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
}
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
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;
}
// 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;
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) &&
} 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);
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);
#include "font.h"
#include "debug.h"
-#define FIX_DOUBLE_SPACE 1
//#define USE_OLD_CUT_AND_PASTE 1
using std::copy;
}
// 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);
(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
}
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_
||
!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
// 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)
}
/* 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;
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;
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.
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 {
// 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.
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;
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
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();
// 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
++pos;
}
} else if (str[i] == ' ') {
-#if 1
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
} 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)) {
} 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 &&
break;
} else {
if (!par->size()) { // par is empty
-#if 1
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
} else {
delete new_inset;
}
-#else
- par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR);
- par->SetFont(pos, current_font);
-#endif
++pos;
}
par->BreakParagraph(pos, flag);
DeleteEmptyParagraphMechanism(old_cursor);
}
+
void LyXText::SetCursor(LyXCursor & cur, LyXParagraph * par,
LyXParagraph::size_type pos) 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,
return;
}
}
-#endif
-#if 1
+
// Do not delete empty paragraphs with keepempty set.
if ((textclasslist.Style(buffer->params.textclass,
old_cursor.par->GetLayout())).keepempty)
}
// 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
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
}