From: Lars Gullik Bjønnes Date: Wed, 27 Jun 2001 14:10:35 +0000 (+0000) Subject: LyX Drinkers United: patch 2 X-Git-Tag: 1.6.10~21167 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=76ef051b1cb1fb51c3ffd8ccc9105be4471e74d4;p=features.git LyX Drinkers United: patch 2 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2144 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/lib/CREDITS b/lib/CREDITS index aaa214e2f4..64c0e42d28 100644 --- a/lib/CREDITS +++ b/lib/CREDITS @@ -31,7 +31,8 @@ @iE-mail: larsbj@lyx.org improvements to user interface (menus and keyhandling) including configurable toolbar, - and a few other minor things. Also current + and a few other (not so) minor things, like + rewriting most of the LyX kernel. Also current source maintainer. @bChristian Buescher user-definable keys, lyxserver and more @@ -43,7 +44,7 @@ Improvements to the czech keymaps @bAlbert Chin @iE-mail: china@thewrittenword.com - Bug fixes. + Bug fixes @bClaudio Coco @iE-mail: lacocio@iol.it Italian translation @@ -72,7 +73,7 @@ @iE-mail: goebel@noris.net Improvements to Koma-Script classes @bClaus Hentschel -@iE-mail claus.hentschel@mbau.fh-hannover.de +@iE-mail: claus.hentschel@mbau.fh-hannover.de Win32 port of LyX 1.1.x @bBernard Michael Hurley @iE-mail: bernardh@westherts.ac.uk @@ -124,12 +125,12 @@ @iE-mail: a.leeming@ic.ac.uk GUI-I-fication of insets and more @bEdwin Leuven -@iE-mail leuven@fee.uva.nl +@iE-mail: leuven@fee.uva.nl Qt2 frontend GUI-I-fication of several popups (in particular the one you are using now :) @bJohn Levon -@iE-mail moz@compsoc.man.ac.uk +@iE-mail: moz@compsoc.man.ac.uk KDE port GUI-I-fication of several popups @bJosé Matos @@ -139,7 +140,7 @@ @iE-mail: a.t.meinen@chello.nl Dutch translation coordinator @bDaniel Naber -@iE-mail dnaber@mini.gt.owl.de +@iE-mail: dnaber@mini.gt.owl.de Improvements to find&replace popup @bDirk Niggemann @iE-mail: dabn100@cam.ac.uk @@ -159,6 +160,7 @@ Better support for serbian and serbocroatian @bKornelia Pietsch @iE-mail: pietsch@mathematik.tu-chemnitz.de + heavy mathed testing provided siamltex document class @bAndré Poenitz @iE-mail: poenitz@HTWM.De @@ -166,7 +168,7 @@ file io with streams --export and --import command line options @bAlkis Polyzotis - Keymap work. + Keymap work @bBernhard Psaier Designer of the LyX-Banner @bThomas Pundt @@ -174,6 +176,7 @@ initial configure script @bAllan Rae @iE-mail: rae@elec.uq.edu.au + GUI-I architect, LyX PR head, LDN, bug reports/fixes, Itemize Bullet Selection, xforms-0.81 + gcc-2.6.3 compatibility @bGarst R. Reese @@ -185,11 +188,11 @@ Support for Koma-Script family of classes @bMichael Ressler @iE-mail: mike.ressler@alum.mit.edu - various documentation contributions, AASTeX support + documentation maintainer, AASTeX support @bHubert Schreier spellchecker (ispell frontend) beautiful document-manager based on the simple - table of contents (temporary removed) + table of contents (removed) @bIvan Schreter @iE-mail: schreter@kdk.sk international support and kbmaps for slovak, czech, @@ -206,19 +209,20 @@ small fixes (some work, others didn't) @bPeter Sütterlin @iE-mail: pit@uni-sw.gwdg.de - aapaper support, bug reports + aapaper support, german documentation translation, + bug reports @bKayvan Aghaiepour Sylvan @iE-mail: kayvan@sylvan.com noweb2lyx and reLyX integration of noweb files. - Added Import->Noweb and key bindings to menus. + added Import->Noweb and key bindings to menus. @bReuben Thomas @iE-mail: rrt@dcs.gla.ac.uk - encts document class - lots of useful bug reports + encts document class + lots of useful bug reports @bDekel Tsur @iE-mail: dekel@math.tau.ac.il - Hebrew support. - Many bug fixes. + Hebrew support, general file converter, + many many bug fixes. @bMatthias Ulrichs @iE-mail: urlichs@smurf.noris.de bug reports and small fixes @@ -233,7 +237,8 @@ svjour/svjog, egs and llncs document classes @bJuergen Vigna @iE-mail: jug@sad.it - Fax- and Ascii-Export support + complete rewrite of the tabular, text inset + fax- and Ascii-Export support iletter and dinbrief support @bJohn P. Weiss @iE-mail: weissjp@colorado.edu @@ -243,15 +248,15 @@ Tutorial chapter 1 @bEdmar Wienskoski Jr. @iE-mail: edmar-w-jr@technologist.com - Literate programming support - Various bug fixes + literate programming support + various bug fixes @bSerge Winitzki @iE-mail: winitzki@erebus.phys.cwru.edu - Updates to the Scientific Word bindings + updates to the Scientific Word bindings @bStephan Witt @iE-mail: stephan.witt@beusen.de - Support for page selection for printing - Support for number of copies + support for page selection for printing + support for number of copies @bHenner Zeller @iE-mail: zeller@think.de rotation of wysiwyg figures diff --git a/lib/ChangeLog b/lib/ChangeLog index 65b65ea2e7..8439d63356 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,14 @@ +2001-06-26 The LyX Project + + * CREDITS: update a bit + + * ui/default.ui: make math align entries non-optional, move + math-mutate stuff to Edit>Math. + +2001-06-26 The LyX Project + + * ui/default.ui: add align options to edit_math menu. + 2001-06-23 The LyX Project * templates/dinbrief.lyx: remove obsolete \cursor tag diff --git a/lib/ui/default.ui b/lib/ui/default.ui index 5ca433c7fa..2f894a007a 100644 --- a/lib/ui/default.ui +++ b/lib/ui/default.ui @@ -146,6 +146,23 @@ Menuset End Menu "edit_math" + Item "Toggle numbering|n" "math-number" + Item "Toggle numbering of line|u" "math-nonumber" + Item "Toggle limits|l" "math-limits" + Separator + Item "Inline formula|I" "math-mutate inline" + Item "Displayed formula|D" "math-mutate display" + Item "Eqnarray environment|q" "math-mutate eqnarray" + Item "Align environment|A" "math-mutate align" + Separator + Item "Align Left|f" "math-halign left" + Item "Align Center|C" "math-halign center" + Item "Align Right|R" "math-halign right" + Separator + Item "V.Align Top|T" "math-valign top" + Item "V.Align Center|e" "math-valign center" + Item "V.Align Bottom|B" "math-valign bottom" + Separator # Item "Make eqnarray|e" "break-line e" # Item "Make multline|m" "break-line m" # Item "Make align 1 column|1" "break-line 1" @@ -154,9 +171,6 @@ Menuset # Item "Make alignat 2 columns|2" "break-line B" # Item "Make alignat 3 columns|3" "break-line C" # Separator - Item "Toggle numbering|n" "math-number" - Item "Toggle numbering of line|u" "math-nonumber" - Item "Toggle limits|l" "math-limits" End # @@ -165,10 +179,6 @@ Menuset Menu "insert" Item "Math Formula|h" "math-mode simple" Item "Display Formula|D" "math-mode display" - Item "Change to Inline Math Formula|q" "math-mutate simple" - Item "Change to Displayed Math Formula|q" "math-mutate equation" - Item "Change to Eqnarray Environment|q" "math-mutate eqnarray" - Item "Change to Align Environment|g" "math-mutate align" Separator Submenu "Special Character|S" "insert_special" Item "Citation Reference...|C" "citation-insert" diff --git a/po/POTFILES.in b/po/POTFILES.in index 53c323e68c..300a18a53d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -198,6 +198,7 @@ src/lyxrc.C src/LyXSendto.C src/lyxvc.C src/LyXView.C +src/mathed/formulabase.C src/mathed/formula.C src/mathed/formulamacro.C src/MenuBackend.C diff --git a/src/BufferView2.C b/src/BufferView2.C index 09232ceb84..0269bf9c36 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -84,10 +84,11 @@ bool BufferView::insertLyXFile(string const & filen) bool res = true; if (c == '#') { - lyxerr.debug() << "Will insert file with header" << endl; + lyxerr[Debug::INFO] << "Will insert file with header" << endl; res = buffer()->readFile(lex, text->cursor.par()); } else { - lyxerr.debug() << "Will insert file without header" << endl; + lyxerr[Debug::INFO] << "Will insert file without header" + << endl; res = buffer()->readLyXformat2(lex, text->cursor.par()); } diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index d0f753a5da..600eef68c3 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -16,6 +16,7 @@ #include "lyxrow.h" #include "LyXView.h" #include "commandtags.h" +#include "lyxfunc.h" #include "font.h" #include "bufferview_funcs.h" #include "TextCache.h" @@ -1183,8 +1184,12 @@ void BufferView::Pimpl::setState() return; LyXText * text = bv_->getLyXText(); - if (text->real_current_font.isRightToLeft() && - text->real_current_font.latex() != LyXFont::ON) { + if (text->real_current_font.isRightToLeft() +#ifndef NO_LATEX + && + text->real_current_font.latex() != LyXFont::ON +#endif + ) { if (owner_->getIntl()->keymap == Intl::PRIMARY) owner_->getIntl()->KeyMapSec(); } else { @@ -1393,15 +1398,12 @@ void BufferView::Pimpl::MenuInsertLyXFile(string const & filen) } } - // get absolute path of file and make sure the filename ends - // with .lyx - filename = MakeAbsPath(filename); - if (!IsLyXFilename(filename)) - filename += ".lyx"; + // get absolute path of file and add ".lyx" to the filename if + // necessary + filename = FileSearch(string(), filename, "lyx"); string const disp_fn(MakeDisplayPath(filename)); - // Inserts document ostringstream s1; s1 << _("Inserting document") << ' ' << disp_fn << " ..."; @@ -1550,13 +1552,15 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_FREE: owner_->getDialogs()->setUserFreeFont(); break; - + +#ifndef NO_LATEX case LFUN_TEX: Tex(bv_); setState(); owner_->showState(); break; - +#endif + case LFUN_FILE_INSERT: { MenuInsertLyXFile(argument); @@ -1573,8 +1577,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_LAYOUT: { - lyxerr.debug() << "LFUN_LAYOUT: (arg) " - << argument << endl; + lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) " + << argument << endl; // Derive layout number from given argument (string) // and current buffer's textclass (number). */ @@ -1680,7 +1684,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) update(lt, BufferView::SELECT | BufferView::FITCUR); - lt->changeWordCase(bv_, LyXText::text_uppercase); + lt->changeCase(bv_, LyXText::text_uppercase); if (lt->inset_owner) updateInset(lt->inset_owner, true); update(lt, @@ -1695,7 +1699,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) LyXText * lt = bv_->getLyXText(); update(lt, BufferView::SELECT|BufferView::FITCUR); - lt->changeWordCase(bv_, LyXText::text_lowercase); + lt->changeCase(bv_, LyXText::text_lowercase); if (lt->inset_owner) updateInset(lt->inset_owner, true); update(lt, @@ -1710,8 +1714,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) LyXText * lt = bv_->getLyXText(); update(lt, BufferView::SELECT|BufferView::FITCUR); - lt->changeWordCase(bv_, - LyXText::text_capitalization); + lt->changeCase(bv_, LyXText::text_capitalization); if (lt->inset_owner) updateInset(lt->inset_owner, true); update(lt, @@ -2593,7 +2596,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) cur_value = par->params().spacing().getValue(); } - istringstream istr(argument.c_str()); + istringstream istr(argument); string tmp; istr >> tmp; @@ -2831,10 +2834,12 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_SETXY: { -#warning Should check sscanf for errors (Lgb) - int x; - int y; - ::sscanf(argument.c_str(), " %d %d", &x, &y); + int x = 0; + int y = 0; + if (::sscanf(argument.c_str(), " %d %d", &x, &y) != 2) { + lyxerr << "SETXY: Could not parse coordinates in '" + << argument << std::endl; + } bv_->getLyXText()->setCursorFromCoordinates(bv_, x, y); } break; @@ -2858,10 +2863,12 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument) case LFUN_GETLATEX: { +#ifndef NO_LATEX LyXFont & font = bv_->getLyXText()->current_font; if (font.latex() == LyXFont::ON) owner_->getLyXFunc()->setMessage("L"); else +#endif owner_->getLyXFunc()->setMessage("0"); } break; @@ -3392,8 +3399,9 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout) string(), 0); update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - +#ifndef NO_LATEX bv_->text->current_font.setLatex(LyXFont::OFF); +#endif } bv_->text->insertInset(bv_, inset); diff --git a/src/ChangeLog b/src/ChangeLog index fb9d1afea6..a1d1778f5a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,76 @@ +2001-06-27 Juergen Vigna + + * text.C (cursorLeftOneWord): changed to return the cursor and added + overlay with BufferView * parameter which calls this one. + (getWord): added + (selectWord): use new getWord function. + (changeCase): renamed from changeWordCase as and extended to work + also on selections. + + * lyxtext.h: added enum word_location + + * BufferView_pimpl.C (Dispatch): change function changeWordCase to + changeCase as this operates now also on selections. + +2001-06-26 The LyX Project + + * lyxfunc.C (getStatus): support LFUN_MATH_MUTATE + + * many files: send debug output to Debug::INFO instead of + Debug::ANY. + + * converter.C (View): + (Convert): + (Move): send debug output to Debug::FILES instead of console. + +2001-06-26 The LyX Project + + * lyxfunc.C (getStatus): use func_status + + * func_status.h: new header, describing the results of + LyXFunc::getStatus; + + * lyxfunc.C (getStatus): add support for LFUN_MATH_VALIGN and + LFUN_MATH_HALIGN. + +2001-06-25 The LyX Project + + * buffer.C (sgmlOpenTag): + (sgmlCloseTag): + (SimpleDocBookOnePar): disable the depth spaces, for the moment. + +2001-06-26 Lars Gullik Bjønnes + + * text2.C: remove some dead code + + * tabular.C (GetCellInset): store the last cell checked (gotten) + + * tabular.h: add the helper for the speedup + + * lyxtext.h: remove some dead code + +2001-06-26 The LyX Project + + * paragraph.C: Change export to LaTeX of alignment to + \begin{center} and family for better roundtrip work with reLyX. + + * Tune the math drawing a bit. + +2001-06-25 The LyX Project + + * LColor.C (LColor): New color for math background. New color + for buttons. + +2001-06-25 The LyX Project + + * lyxfunc.C (MenuNew): remove extra check for .lyx file + + * lyxfunc.C (Open): + * bufferlist.C (newFile): do not restrict to files ending with + .lyx + + * BufferView_pimpl.C (MenuInsertLyXFile): + 2001-06-24 The LyX Project * lyxlex_pimpl.C (compare_tags): use compare_ascii_no_case instead diff --git a/src/FontLoader.C b/src/FontLoader.C index 0f7e2d7782..e01669d124 100644 --- a/src/FontLoader.C +++ b/src/FontLoader.C @@ -271,7 +271,9 @@ XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family, f.setEmph(LyXFont::INHERIT); f.setUnderbar(LyXFont::INHERIT); f.setNoun(LyXFont::INHERIT); +#ifndef NO_LATEX f.setLatex(LyXFont::INHERIT); +#endif f.setColor(LColor::inherit); lyxerr << "Font '" << f.stateText(0) << "' matched by\n" << font << endl; diff --git a/src/LColor.C b/src/LColor.C index f3ed338277..e0c952f7be 100644 --- a/src/LColor.C +++ b/src/LColor.C @@ -68,18 +68,19 @@ LColor::LColor() { depthbar, N_("depth bar"), "depthbar", "IndianRed", "depthbar" }, { language, N_("language"), "language", "Blue", "language" }, { command, N_("command inset"), "command", "black", "command" }, - { commandbg, N_("command inset background"), "commandbg", "grey80", "commandbg" }, + { commandbg, N_("command inset background"), "commandbg", "azure", "commandbg" }, { commandframe, N_("command inset frame"), "commandframe", "black", "commandframe" }, { special, N_("special character"), "special", "RoyalBlue", "special" }, { math, N_("math"), "math", "DarkBlue", "math" }, { mathbg, N_("math background"), "mathbg", "AntiqueWhite", "mathbg" }, + { mathmacrobg, N_("Math macro background"), "mathmacrobg", "AntiqueWhite", "mathmacrobg" }, { mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" }, { mathcursor, N_("math cursor"), "mathcursor", "black", "mathcursor" }, { mathline, N_("math line"), "mathline", "Blue", "mathline" }, { captionframe, N_("caption frame"), "captionframe", "DarkRed", "captionframe" }, { collapsable, N_("collapsable inset text"), "collapsable", "DarkRed", "collapsable" }, { collapsableframe, N_("collapsable inset frame"), "collapsableframe", "IndianRed", "collapsableframe" }, - { insetbg, N_("inset background"), "insetbg", "grey60", "insetbg" }, + { insetbg, N_("inset background"), "insetbg", "grey80", "insetbg" }, { insetframe, N_("inset frame"), "insetframe", "IndianRed", "insetframe" }, { error, N_("LaTeX error"), "error", "Red", "error" }, { eolmarker, N_("end-of-line marker"), "eolmarker", "Brown", "eolmarker" }, @@ -92,11 +93,11 @@ LColor::LColor() "LightSteelBlue", "tabularonoffline" }, { bottomarea, N_("bottom area"), "bottomarea", "grey40", "bottomarea" }, { pagebreak, N_("page break"), "pagebreak", "RoyalBlue", "pagebreak" }, - { top, N_("top of button"), "top", "grey80", "top" }, - { bottom, N_("bottom of button"), "bottom", "grey40", "bottom" }, - { left, N_("left of button"), "left", "grey80", "left" }, - { right, N_("right of button"), "right", "grey40", "right" }, - { buttonbg, N_("button background"), "buttonbg", "grey60", "buttonbg" }, + { top, N_("top of button"), "top", "grey90", "top" }, + { bottom, N_("bottom of button"), "bottom", "grey60", "bottom" }, + { left, N_("left of button"), "left", "grey90", "left" }, + { right, N_("right of button"), "right", "grey60", "right" }, + { buttonbg, N_("button background"), "buttonbg", "grey80", "buttonbg" }, { inherit, N_("inherit"), "inherit", "black", "inherit" }, { ignore, N_("ignore"), "ignore", "black", "ignore" }, { ignore, 0, 0, 0, 0 } diff --git a/src/LColor.h b/src/LColor.h index 6d832857c4..b6651839b6 100644 --- a/src/LColor.h +++ b/src/LColor.h @@ -106,6 +106,8 @@ public: math, /// Math inset background color mathbg, + /// Macro math inset background color + mathmacrobg, /// Math inset frame color mathframe, /// Math cursor color diff --git a/src/LyXAction.C b/src/LyXAction.C index 7c90498ccf..44dc887bbd 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -369,7 +369,9 @@ void LyXAction::init() N_("Tabular Features"), Noop }, { LFUN_INSET_TABULAR, "tabular-insert", N_("Insert a new Tabular Inset"), Noop }, +#ifndef NO_LATEX { LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop }, +#endif { LFUN_INSET_TEXT, "text-insert", N_("Insert a new Text Inset"), Noop }, { LFUN_INSET_THEOREM, "theorem-insert", "", Noop }, diff --git a/src/Makefile.am b/src/Makefile.am index 4cc29ddc21..cefe8d1433 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -114,6 +114,7 @@ lyx_SOURCES = \ figureForm.h \ font.C \ font.h \ + func_status.h \ gettext.C \ gettext.h \ importer.C \ diff --git a/src/Painter.C b/src/Painter.C index 93a8b73483..7b4f1160fa 100644 --- a/src/Painter.C +++ b/src/Painter.C @@ -55,7 +55,7 @@ PainterBase & Painter::point(int x, int y, LColor::color c) if (!Lgb_bug_find_hack) lyxerr << "point not called from " "workarea::workhandler\n"; - lyxerr.debug() << "Painter drawable: " + lyxerr[Debug::INFO] << "Painter drawable: " << owner.getPixmap() << endl; } @@ -74,7 +74,7 @@ PainterBase & Painter::line(int x1, int y1, int x2, int y2, if (!Lgb_bug_find_hack) lyxerr << "line not called from " "workarea::workhandler\n"; - lyxerr.debug() << "Painter drawable: " + lyxerr[Debug::INFO] << "Painter drawable: " << owner.getPixmap() << endl; } @@ -94,7 +94,7 @@ PainterBase & Painter::lines(int const * xp, int const * yp, int np, if (!Lgb_bug_find_hack) lyxerr << "lines not called from " "workarea::workhandler\n"; - lyxerr.debug() << "Painter drawable: " + lyxerr[Debug::INFO] << "Painter drawable: " << owner.getPixmap() << endl; } @@ -332,7 +332,11 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls, } } } - if (f.underbar() == LyXFont::ON && f.latex() != LyXFont::ON) + if (f.underbar() == LyXFont::ON +#ifndef NO_LATEX + && f.latex() != LyXFont::ON +#endif + ) underline(f, x, y, lyxfont::width(s, ls, f)); return *this; } @@ -371,7 +375,11 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls, } } } - if (f.underbar() == LyXFont::ON && f.latex() != LyXFont::ON) + if (f.underbar() == LyXFont::ON +#ifndef NO_LATEX + && f.latex() != LyXFont::ON +#endif + ) underline(f, x, y, lyxfont::width(s, ls, f)); return *this; } diff --git a/src/TextCache.C b/src/TextCache.C index 28f956499b..f7133d6030 100644 --- a/src/TextCache.C +++ b/src/TextCache.C @@ -99,13 +99,13 @@ void TextCache::show(ostream & os, TextCache::value_type const & vt) void TextCache::add(Buffer * buf, int workwidth, LyXText * text) { - lyxerr.debug() << "TextCache::add " << text; + lyxerr[Debug::INFO] << "TextCache::add " << text; if (bufferlist.isLoaded(buf)) { cache[buf] = make_pair(workwidth, text); - lyxerr.debug() << " added" << endl; + lyxerr[Debug::INFO] << " added" << endl; } else { delete text; - lyxerr.debug() << " deleted" << endl; + lyxerr[Debug::INFO] << " deleted" << endl; } } diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index b8d0c413a2..afca95d881 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -64,7 +64,9 @@ void ToolbarDefaults::init() add(LFUN_DEPTH); add(SEPARATOR); +#ifndef NO_LATEX add(LFUN_TEX); +#endif add(LFUN_MATH_MODE); add(SEPARATOR); diff --git a/src/buffer.C b/src/buffer.C index f95fa7893c..5cb9a3ca88 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -363,6 +363,9 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, ) { bool the_end_read = false; +#ifdef NO_LATEX + static string inset_ert_contents; +#endif #ifndef NO_PEXTRA_REALLY // This is super temporary but is needed to get the compability // mode for minipages work correctly together with new tabulars. @@ -386,6 +389,15 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, par->insertInset(pos, inset, font); ++pos; } else if (token == "\\layout") { +#ifdef NO_LATEX + // Do the insetert. + if (!inset_ert_contents.empty()) { + Inset * inset = new InsetERT(inset_ert_contents); + par->insertInset(pos, inset, font); + ++pos; + inset_ert_contents.erase(); + } +#endif lex.EatLine(); string const layoutname = lex.GetString(); pair pp @@ -848,6 +860,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, } else if (token == "\\size") { lex.next(); font.setLyXSize(lex.GetString()); +#ifndef NO_LATEX +#ifdef WITH_WARNINGS +#warning compatability hack needed +#endif } else if (token == "\\latex") { lex.next(); string const tok = lex.GetString(); @@ -861,6 +877,21 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par, else lex.printError("Unknown LaTeX font flag " "`$$Token'"); +#else + } else if (token == "\\latex") { + lex.next(); + string const tok = lex.GetString(); + if (tok == "no_latex") { + ; // nothing + } else if (tok == "latex") { + ; // nothing + } else if (tok == "default") { + ; // nothing + } else { + lex.printError("Unknown LaTeX font flag " + "`$$Token'"); + } +#endif } else if (token == "\\lang") { lex.next(); string const tok = lex.GetString(); @@ -1577,8 +1608,10 @@ string const Buffer::asciiParagraph(Paragraph const * par, } else { lyxerr << "Should this ever happen?" << endl; } - + +#ifndef NO_LATEX LyXFont const font1 = LyXFont(LyXFont::ALL_INHERIT, params.language); +#endif for (Paragraph::size_type i = 0; i < par->size(); ++i) { if (!i && !noparbreak) { if (linelen > 0) @@ -1617,6 +1650,7 @@ string const Buffer::asciiParagraph(Paragraph const * par, currlinelen += (ltype_depth-depth)*2; } } +#ifndef NO_LATEX LyXFont const font2 = par->getFontSettings(params, i); if (font1.latex() != font2.latex()) { if (font2.latex() == LyXFont::OFF) @@ -1626,6 +1660,7 @@ string const Buffer::asciiParagraph(Paragraph const * par, } else { islatex = 0; } +#endif char c = par->getUChar(params, i); if (islatex) @@ -1691,7 +1726,7 @@ string const Buffer::asciiParagraph(Paragraph const * par, } else if (c != '\0') buffer << c; else if (c == '\0') - lyxerr.debug() << "writeAsciiFile: NULL char in structure." << endl; + lyxerr[Debug::INFO] << "writeAsciiFile: NULL char in structure." << endl; ++currlinelen; break; } @@ -1761,7 +1796,7 @@ void Buffer::makeLaTeXFile(string const & fname, texrow.newline(); texrow.newline(); } - lyxerr.debug() << "lyx header finished" << endl; + lyxerr[Debug::INFO] << "lyx header finished" << endl; // There are a few differences between nice LaTeX and usual files: // usual is \batchmode and has a // special input@path to allow the including of figures @@ -2177,7 +2212,7 @@ void Buffer::makeLaTeXFile(string const & fname, ofs << "\\begin{document}\n"; texrow.newline(); } // only_body - lyxerr.debug() << "preamble finished, now the body." << endl; + lyxerr[Debug::INFO] << "preamble finished, now the body." << endl; if (!lyxrc.language_auto_begin) { ofs << subst(lyxrc.language_command_begin, "$$lang", @@ -2223,7 +2258,7 @@ void Buffer::makeLaTeXFile(string const & fname, lyxerr << "File was not closed properly." << endl; } - lyxerr.debug() << "Finished making latex file." << endl; + lyxerr[Debug::INFO] << "Finished making latex file." << endl; } @@ -2305,7 +2340,8 @@ void Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type depth, string const & latexname) const { if (!latexname.empty() && latexname != "!-- --") - os << string(depth, ' ') << "<" << latexname << ">\n"; + os << "" << "<" << latexname << ">"; + //os << string(depth, ' ') << "<" << latexname << ">\n"; } @@ -2313,7 +2349,8 @@ void Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type depth, string const & latexname) const { if (!latexname.empty() && latexname != "!-- --") - os << string(depth, ' ') << "\n"; + os << "" << "\n"; + //os << string(depth, ' ') << "\n"; } @@ -2727,7 +2764,11 @@ void Buffer::SimpleLinuxDocOnePar(ostream & os, continue; } - if (font.latex() == LyXFont::ON || style.latexparam() == "CDATA") { + if ( +#ifndef NO_LATEX + font.latex() == LyXFont::ON || +#endif + style.latexparam() == "CDATA") { // "TeX"-Mode on == > SGML-Mode on. if (c != '\0') os << c; @@ -3093,8 +3134,8 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, LyXFont font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font; int char_line_count = depth; - if (!style.free_spacing) - os << string(depth,' '); + //if (!style.free_spacing) + // os << string(depth,' '); // parsing main loop for (Paragraph::size_type i = 0; @@ -3140,11 +3181,13 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, else os << tmp_out; } +#ifndef NO_LATEX } else if (font.latex() == LyXFont::ON) { // "TeX"-Mode on ==> SGML-Mode on. if (c != '\0') os << c; ++char_line_count; +#endif } else { string sgml_string; if (par->linuxDocConvertChar(c, sgml_string) @@ -3175,7 +3218,7 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, // not closed... os << ""; } - os << '\n'; + if(style.free_spacing) os << '\n'; } @@ -3327,7 +3370,7 @@ string const Buffer::getIncludeonlyList(char delim) } } } - lyxerr.debug() << "Includeonly(" << lst << ')' << endl; + lyxerr[Debug::INFO] << "Includeonly(" << lst << ')' << endl; return lst; } diff --git a/src/bufferlist.C b/src/bufferlist.C index 36ba4b357d..a7ce2a9270 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -443,7 +443,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed) if (tname.empty()) { tname = LibFileSearch("templates", "defaults.lyx"); } - if (!tname.empty() && IsLyXFilename(tname)) { + if (!tname.empty()) { bool templateok = false; LyXLex lex(0, 0); lex.setFile(tname); diff --git a/src/bufferview_funcs.C b/src/bufferview_funcs.C index 117f28bad5..f9b9689a5d 100644 --- a/src/bufferview_funcs.C +++ b/src/bufferview_funcs.C @@ -71,12 +71,14 @@ void Lang(BufferView * bv, string const & l) } +#ifndef NO_LATEX void Tex(BufferView * bv) { LyXFont font(LyXFont::ALL_IGNORE); font.setLatex (LyXFont::TOGGLE); ToggleAndShow(bv, font); } +#endif // Change environment depth. @@ -266,7 +268,9 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall) bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); if (font.language() != ignore_language || +#ifndef NO_LATEX font.latex() != LyXFont::IGNORE || +#endif font.number() != LyXFont::IGNORE) { LyXCursor & cursor = text->cursor; diff --git a/src/commandtags.h b/src/commandtags.h index d3fc152ae8..4725e88a36 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -12,6 +12,11 @@ #include +#if 1 +// For NO_LATEX +#include "lyxfont.h" +#endif + /** These are all the lyxfunctions (as enums). Please add new functions at the end of the enum, right before LFUN_LASTACTION. @@ -49,7 +54,9 @@ enum kb_action { LFUN_HFILL, LFUN_DEPTH, LFUN_FREE, // 30 +#ifndef NO_LATEX LFUN_TEX, +#endif #if 0 LFUN_FOOTMELT, // schedule for deletion LFUN_MARGINMELT, // schedule for deletion @@ -293,7 +300,3 @@ enum kb_action { std::ostream & operator<<(std::ostream &, kb_action); #endif - - - - diff --git a/src/converter.C b/src/converter.C index 423274cd1c..c9248c5150 100644 --- a/src/converter.C +++ b/src/converter.C @@ -189,7 +189,7 @@ bool Formats::View(Buffer const * buffer, string const & filename, command += " " + QuoteName(OnlyFilename((filename))); - lyxerr << "Executing command: " << command << endl; + lyxerr[Debug::FILES] << "Executing command: " << command << endl; ShowMessage(buffer, _("Executing command:"), command); Path p(OnlyPath(filename)); @@ -574,7 +574,7 @@ bool Converters::Convert(Buffer const * buffer, Converter const & conv = converterlist[*cit]; bool dummy = conv.To->dummy() && conv.to != "program"; if (!dummy) - lyxerr << "Converting from " + lyxerr[Debug::FILES] << "Converting from " << conv.from << " to " << conv.to << endl; infile = outfile; outfile = conv.result_dir.empty() @@ -587,14 +587,15 @@ bool Converters::Convert(Buffer const * buffer, if (conv.latex) { run_latex = true; string command = subst(conv.command, token_from, ""); - lyxerr << "Running " << command << endl; + lyxerr[Debug::FILES] << "Running " << command << endl; if (!runLaTeX(buffer, command)) return false; } else { if (conv.need_aux && !run_latex && !latex_command.empty()) { - lyxerr << "Running " << latex_command - << " to update aux file"<< endl; + lyxerr[Debug::FILES] + << "Running " << latex_command + << " to update aux file"<< endl; runLaTeX(buffer, latex_command); } @@ -618,7 +619,7 @@ bool Converters::Convert(Buffer const * buffer, command = add_options(command, dvipdfm_options(buffer)); - lyxerr << "Calling " << command << endl; + lyxerr[Debug::FILES] << "Calling " << command << endl; if (buffer) ShowMessage(buffer, _("Executing command:"), command); @@ -700,7 +701,8 @@ bool Converters::Move(string const & from, string const & to, bool copy) string from2 = path + *it; string to2 = to_base + (*it).substr(base.length()); to2 = ChangeExtension(to2, to_extension); - lyxerr << "moving " << from2 << " to " << to2 << endl; + lyxerr[Debug::FILES] << "moving " << from2 + << " to " << to2 << endl; bool moved = (copy) ? lyx::copy(from2, to2) : lyx::rename(from2, to2); diff --git a/src/frontends/controllers/ControlBibitem.C b/src/frontends/controllers/ControlBibitem.C index 845dbaa2b2..0433149d13 100644 --- a/src/frontends/controllers/ControlBibitem.C +++ b/src/frontends/controllers/ControlBibitem.C @@ -35,6 +35,7 @@ ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d) d_.showBibitem.connect(slot(this, &ControlBibitem::showInset)); } + void ControlBibitem::applyParamsToInset() { // FIXME: diff --git a/src/frontends/controllers/ControlCharacter.C b/src/frontends/controllers/ControlCharacter.C index 7725a1a4fa..5b459abbce 100644 --- a/src/frontends/controllers/ControlCharacter.C +++ b/src/frontends/controllers/ControlCharacter.C @@ -30,6 +30,7 @@ using Liason::setMinibuffer; using SigC::slot; using std::vector; + ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d) : ControlDialog(lv, d), font_(0), toggleall_(false) @@ -82,11 +83,13 @@ LyXFont::FONT_FAMILY ControlCharacter::getFamily() const return LyXFont::IGNORE_FAMILY; } + void ControlCharacter::setFamily(LyXFont::FONT_FAMILY val) { font_->setFamily(val); } + LyXFont::FONT_SERIES ControlCharacter::getSeries() const { if (font_.get()) @@ -94,11 +97,13 @@ LyXFont::FONT_SERIES ControlCharacter::getSeries() const return LyXFont::IGNORE_SERIES; } + void ControlCharacter::setSeries(LyXFont::FONT_SERIES val) { font_->setSeries(val); } + LyXFont::FONT_SHAPE ControlCharacter::getShape() const { if (font_.get()) @@ -106,11 +111,13 @@ LyXFont::FONT_SHAPE ControlCharacter::getShape() const return LyXFont::IGNORE_SHAPE; } + void ControlCharacter::setShape(LyXFont::FONT_SHAPE val) { font_->setShape(val); } + LyXFont::FONT_SIZE ControlCharacter::getSize() const { if (font_.get()) @@ -118,11 +125,13 @@ LyXFont::FONT_SIZE ControlCharacter::getSize() const return LyXFont::IGNORE_SIZE; } + void ControlCharacter::setSize(LyXFont::FONT_SIZE val) { font_->setSize(val); } + character::FONT_STATE ControlCharacter::getBar() const { if (font_.get()) { @@ -134,13 +143,15 @@ character::FONT_STATE ControlCharacter::getBar() const else if (font_->noun() != LyXFont::IGNORE) return character::NOUN_TOGGLE; - +#ifndef NO_LATEX else if (font_->latex() != LyXFont::IGNORE) return character::LATEX_TOGGLE; +#endif } return character::IGNORE; } + void ControlCharacter::setBar(character::FONT_STATE val) { switch (val) { @@ -148,7 +159,9 @@ void ControlCharacter::setBar(character::FONT_STATE val) font_->setEmph(LyXFont::IGNORE); font_->setUnderbar(LyXFont::IGNORE); font_->setNoun(LyXFont::IGNORE); +#ifndef NO_LATEX font_->setLatex(LyXFont::IGNORE); +#endif break; case character::EMPH_TOGGLE: @@ -163,19 +176,24 @@ void ControlCharacter::setBar(character::FONT_STATE val) font_->setNoun(LyXFont::TOGGLE); break; +#ifndef NO_LATEX case character::LATEX_TOGGLE: font_->setLatex(LyXFont::TOGGLE); break; - +#endif + case character::INHERIT: font_->setEmph(LyXFont::INHERIT); font_->setUnderbar(LyXFont::INHERIT); font_->setNoun(LyXFont::INHERIT); +#ifndef NO_LATEX font_->setLatex(LyXFont::INHERIT); +#endif break; } } + LColor::color ControlCharacter::getColor() const { LColor::color col = LColor::ignore; @@ -203,6 +221,7 @@ LColor::color ControlCharacter::getColor() const return col; } + void ControlCharacter::setColor(LColor::color val) { switch (val) { @@ -251,6 +270,7 @@ bool ControlCharacter::getToggleAll() const return toggleall_; } + void ControlCharacter::setToggleAll(bool t) { toggleall_ = t; diff --git a/src/frontends/qt2/FormParagraph.C b/src/frontends/qt2/FormParagraph.C index 41d8d1bb64..dc62aedf54 100644 --- a/src/frontends/qt2/FormParagraph.C +++ b/src/frontends/qt2/FormParagraph.C @@ -145,7 +145,7 @@ void FormParagraph::apply() lyxerr[Debug::GUI] << "Setting above space \"" << LyXGlueLength(spaceabove.length().asString()).asString() << "\"" << endl; lyxerr[Debug::GUI] << "Setting below space \"" << LyXGlueLength(spacebelow.length().asString()).asString() << "\"" << endl; - lv_->view()->text->SetParagraph(lv_->view(), + lv_->view()->text->setParagraph(lv_->view(), dialog_->getLineAbove(), dialog_->getLineBelow(), dialog_->getPagebreakAbove(), dialog_->getPagebreakBelow(), spaceabove, spacebelow, dialog_->getAlign(), diff --git a/src/frontends/qt2/FormSplashImpl.C b/src/frontends/qt2/FormSplashImpl.C index 2380b4fa6f..5ebe8ebf67 100644 --- a/src/frontends/qt2/FormSplashImpl.C +++ b/src/frontends/qt2/FormSplashImpl.C @@ -43,7 +43,7 @@ FormSplashBase::~FormSplashBase() } -void FormSplashBase::mousePressEvent( QMouseEvent * e) +void FormSplashBase::mousePressEvent( QMouseEvent * ) { hide(); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 61f895737d..51bcb28ba6 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,17 @@ +2001-06-26 The LyX Project + + * combox.C (remove): send debug output to Debug::GUI. + +2001-06-26 The LyX Project + + * Menubar_pimpl.C (create_submenu): + * Toolbar_pimpl.C (update): update to use func_status + +2001-06-25 The LyX Project + + * FormPreferences.C (Path::feedback): remove bogus description of + lyxpipe. + 2001-06-16 Angus Leeming * xformsBC.h: clean-up of included files. diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index 4e183e98a2..3a0a1b5290 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -2088,7 +2088,6 @@ FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH); else if (ob == dialog_->input_serverpipe) { str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE); - str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out."; } return str; diff --git a/src/frontends/xforms/Menubar_pimpl.C b/src/frontends/xforms/Menubar_pimpl.C index cb2fa4fd3d..f15d7c7984 100644 --- a/src/frontends/xforms/Menubar_pimpl.C +++ b/src/frontends/xforms/Menubar_pimpl.C @@ -407,7 +407,8 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, if (i->kind() == MenuItem::Separator) *last = "%l"; else if (!i->optional() || - !(view->getLyXFunc()->getStatus(i->action()) & LyXFunc::Disabled)) + !(view->getLyXFunc()->getStatus(i->action()) + & func_status::Disabled)) last = it; it = extra_labels.begin(); @@ -417,11 +418,12 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, switch (item.kind()) { case MenuItem::Command: { - LyXFunc::func_status flag = + func_status::value_type flag = view->getLyXFunc()->getStatus(item.action()); // handle optional entries. - if (item.optional() && (flag & LyXFunc::Disabled)) { + if (item.optional() + && (flag & func_status::Disabled)) { lyxerr[Debug::GUI] << "Skipping optional item " << item.label() << endl; @@ -447,11 +449,12 @@ int Menubar::Pimpl::create_submenu(Window win, LyXView * view, // Modify the entry using the function status string pupmode; - if (flag & (LyXFunc::Disabled | LyXFunc::Unknown)) + if (flag & (func_status::Disabled + | func_status::Unknown)) pupmode += "%i"; - if (flag & LyXFunc::ToggleOn) + if (flag & func_status::ToggleOn) pupmode += "%B"; - if (flag & LyXFunc::ToggleOff) + if (flag & func_status::ToggleOff) pupmode += "%b"; label += pupmode; diff --git a/src/frontends/xforms/Toolbar_pimpl.C b/src/frontends/xforms/Toolbar_pimpl.C index 9a051dd33a..b80357e11e 100644 --- a/src/frontends/xforms/Toolbar_pimpl.C +++ b/src/frontends/xforms/Toolbar_pimpl.C @@ -23,6 +23,7 @@ #include "debug.h" #include "LyXView.h" #include "lyxfunc.h" +#include "func_status.h" #include "BufferView.h" #include "buffer.h" #include "LyXAction.h" @@ -190,7 +191,7 @@ void Toolbar::Pimpl::update() for (; p != end; ++p) { if (p->icon) { int status = owner->getLyXFunc()->getStatus(p->action); - if (status & LyXFunc::ToggleOn) { + if (status & func_status::ToggleOn) { // I'd like to use a different color // here, but then the problem is to // know how to use transparency with @@ -203,7 +204,7 @@ void Toolbar::Pimpl::update() fl_set_object_boxtype(p->icon, FL_UP_BOX); } - if (status & LyXFunc::Disabled) { + if (status & func_status::Disabled) { // Is there a way here to specify a // mask in order to show that the // button is disabled? (JMarc) diff --git a/src/frontends/xforms/bmtable.h b/src/frontends/xforms/bmtable.h index 3ae4adb07a..a55c423f09 100644 --- a/src/frontends/xforms/bmtable.h +++ b/src/frontends/xforms/bmtable.h @@ -1,4 +1,3 @@ -// -*- C++ -*- /* * File: bmtable.h * Purpose: Declaration of the XForms object bmtable. diff --git a/src/frontends/xforms/combox.C b/src/frontends/xforms/combox.C index a815321193..eac8d17352 100644 --- a/src/frontends/xforms/combox.C +++ b/src/frontends/xforms/combox.C @@ -81,20 +81,20 @@ void Combox::clear() void Combox::remove() { - lyxerr.debug() << "Button: " << button << endl; + lyxerr[Debug::GUI] << "Button: " << button << endl; if (button) { fl_delete_object(button); fl_free_object(button); } - lyxerr.debug() << "Label: " << label << endl; + lyxerr[Debug::GUI] << "Label: " << label << endl; if (label && label != button) { fl_delete_object(label); fl_free_object(label); } - lyxerr.debug() << "Form: " << form << endl; - lyxerr.debug() << "Browser: " << browser << endl; + lyxerr[Debug::GUI] << "Form: " << form << endl; + lyxerr[Debug::GUI] << "Browser: " << browser << endl; if (form && browser) { fl_delete_object(browser); fl_free_object(browser); diff --git a/src/func_status.h b/src/func_status.h new file mode 100644 index 0000000000..66e84122cc --- /dev/null +++ b/src/func_status.h @@ -0,0 +1,29 @@ +// -*- C++ -*- +#ifndef FUNC_STATUS_H +#define FUNC_STATUS_H + +/// The status of a function. +namespace func_status { + +enum value_type { + /// No problem + OK = 0, + /// + Unknown = 1, + /// Command cannot be executed + Disabled = 2, + /// + ToggleOn = 4, + /// + ToggleOff = 8 + }; +} + +/// +inline +void operator|=(func_status::value_type & fs, func_status::value_type f) +{ + fs = static_cast(fs | f); +} + +#endif diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index cdf5931066..595e40e97a 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,33 @@ +2001-06-26 The LyX Project + + * figinset.C: + * inset.C: + * insetgraphics.C: send debug output to Debug::INFO instead of + Debug::ANY. + +2001-06-26 The LyX Project + + * insettabular.h: + * insettabular.C (getStatus): update to use func_status + +2001-06-26 ben + + * insetref.C (DocBook): added support for cross-references without + a name. + +2001-06-26 The LyX Project + + * insetref.C: + * insetref.h: + * insetlabel.C: + * insetlabel.h: removed escape method and moved it to + support/lstrings.h. + +2001-06-26 Lars Gullik Bjønnes + + * insettabular.C (getMaxWidth): do the speedup in a different way, + remove dead code + 2001-06-24 The LyX Project * insettabular.C (getMaxWidth): We cache a mapping from @@ -21,7 +51,7 @@ 2001-06-14 Juergen Vigna - * insettext.C (draw): removed warinings. + * insettext.C (draw): removed warnings. 2001-06-13 Juergen Vigna diff --git a/src/insets/figinset.C b/src/insets/figinset.C index 5b9614c559..fa11c2a78d 100644 --- a/src/insets/figinset.C +++ b/src/insets/figinset.C @@ -233,7 +233,7 @@ int GhostscriptMsg(XEvent * ev, void *) // now fork rendering process forkstat = fork(); if (forkstat == -1) { - lyxerr.debug() + lyxerr[Debug::INFO] << "Cannot fork, using slow " "method for pixmap translation." << endl; tmpdisp = fl_get_display(); @@ -438,7 +438,7 @@ void DoneFigures() bitmaps.clear(); figures.clear(); - lyxerr.debug() << "Unregistering figures..." << endl; + lyxerr[Debug::INFO] << "Unregistering figures..." << endl; } @@ -676,7 +676,7 @@ void runqueue() // if we are still there, an error occurred. lyxerr << "Error executing ghostscript. " << "Code: " << err << endl; - lyxerr.debug() << "Cmd: " + lyxerr[Debug::INFO] << "Cmd: " << lyxrc.ps_command << " -sDEVICE=x11 " << tmpf << ' ' @@ -799,18 +799,18 @@ void makeupdatelist(figdata * p) // this func is only "called" in spellchecker.C void sigchldchecker(pid_t pid, int * status) { - lyxerr.debug() << "Got pid = " << pid << endl; + lyxerr[Debug::INFO] << "Got pid = " << pid << endl; bool pid_handled = false; for (bitmaps_type::iterator it = bitmaps.begin(); it != bitmaps.end(); ++it) { if ((*it)->reading && pid == (*it)->gspid) { - lyxerr.debug() << "Found pid in bitmaps" << endl; + lyxerr[Debug::INFO] << "Found pid in bitmaps" << endl; // now read the file and remove it from disk figdata * p = (*it); p->reading = false; if ((*it)->gsdone) *status = 0; if (*status == 0) { - lyxerr.debug() << "GS [" << pid + lyxerr[Debug::INFO] << "GS [" << pid << "] exit OK." << endl; } else { lyxerr << "GS [" << pid << "] error " @@ -836,18 +836,18 @@ void sigchldchecker(pid_t pid, int * status) } } if (!pid_handled) { - lyxerr.debug() << "Checking pid in pidwait" << endl; + lyxerr[Debug::INFO] << "Checking pid in pidwait" << endl; list::iterator it = find(pidwaitlist.begin(), pidwaitlist.end(), pid); if (it != pidwaitlist.end()) { - lyxerr.debug() << "Found pid in pidwait\n" + lyxerr[Debug::INFO] << "Found pid in pidwait\n" << "Caught child pid of recompute " "routine" << pid << endl; pidwaitlist.erase(it); } } if (pid == -1) { - lyxerr.debug() << "waitpid error" << endl; + lyxerr[Debug::INFO] << "waitpid error" << endl; switch (errno) { case ECHILD: lyxerr << "The process or process group specified by " @@ -871,7 +871,7 @@ void sigchldchecker(pid_t pid, int * status) } else if (pid == 0) { lyxerr << "waitpid nohang" << endl;; } else { - lyxerr.debug() << "normal exit from childhandler" << endl; + lyxerr[Debug::INFO] << "normal exit from childhandler" << endl; } } @@ -1078,7 +1078,7 @@ void InsetFig::Read(Buffer const *, LyXLex & lex) lex.next(); string const token = lex.GetString(); - lyxerr.debug() << "Token: " << token << endl; + lyxerr[Debug::INFO] << "Token: " << token << endl; if (token.empty()) continue; @@ -1126,7 +1126,7 @@ void InsetFig::Read(Buffer const *, LyXLex & lex) case PER_PAGE: wtype = PER_PAGE; break; case PER_COL: wtype = PER_COL; break; default: - lyxerr.debug() << "Unknown type!" << endl; + lyxerr[Debug::INFO] << "Unknown type!" << endl; break; } twtype = wtype; @@ -1142,7 +1142,7 @@ void InsetFig::Read(Buffer const *, LyXLex & lex) case IN: htype = IN; break; case PER_PAGE: htype = PER_PAGE; break; default: - lyxerr.debug() << "Unknown type!" << endl; + lyxerr[Debug::INFO] << "Unknown type!" << endl; break; } thtype = htype; @@ -1214,7 +1214,7 @@ string const InsetFig::EditMessage() const void InsetFig::Edit(BufferView * bv, int, int, unsigned int) { - lyxerr.debug() << "Editing InsetFig." << endl; + lyxerr[Debug::INFO] << "Editing InsetFig." << endl; Regenerate(); // We should have RO-versions of the form instead. @@ -1587,14 +1587,14 @@ void InsetFig::GetPSSizes() for (;;) { char c = 0; ifs.get(c); if (ifs.eof()) { - lyxerr.debug() << "End of (E)PS file reached and" + lyxerr[Debug::INFO] << "End of (E)PS file reached and" " no BoundingBox!" << endl; break; } if (c == '%' && lastchar == '%') { ifs >> p; if (p.empty()) break; - lyxerr.debug() << "Token: `" << p << "'" << endl; + lyxerr[Debug::INFO] << "Token: `" << p << "'" << endl; if (p == "BoundingBox:") { float fpsx, fpsy, fpswid, fpshgh; if (ifs >> fpsx >> fpsy >> fpswid >> fpshgh) { @@ -1664,7 +1664,7 @@ void InsetFig::CallbackFig(long arg) fl_activate_object(form->Width); break; default: - lyxerr.debug() << "Unknown type!" << endl; + lyxerr[Debug::INFO] << "Unknown type!" << endl; break; } regen = true; @@ -1695,7 +1695,7 @@ void InsetFig::CallbackFig(long arg) fl_activate_object(form->Height); break; default: - lyxerr.debug() << "Unknown type!" << endl; + lyxerr[Debug::INFO] << "Unknown type!" << endl; break; } regen = true; diff --git a/src/insets/inset.C b/src/insets/inset.C index e86a169fed..5fe9644487 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -85,34 +85,34 @@ LyXText * Inset::getLyXText(BufferView const * bv, bool const) const void UpdatableInset::InsetButtonPress(BufferView *, int x, int y, int button) { - lyxerr.debug() << "Inset Button Press x=" << x + lyxerr[Debug::INFO] << "Inset Button Press x=" << x << ", y=" << y << ", button=" << button << endl; } void UpdatableInset::InsetButtonRelease(BufferView *, int x, int y, int button) { - lyxerr.debug() << "Inset Button Release x=" << x + lyxerr[Debug::INFO] << "Inset Button Release x=" << x << ", y=" << y << ", button=" << button << endl; } void UpdatableInset::InsetKeyPress(XKeyEvent *) { - lyxerr.debug() << "Inset Keypress" << endl; + lyxerr[Debug::INFO] << "Inset Keypress" << endl; } void UpdatableInset::InsetMotionNotify(BufferView *, int x, int y, int state) { - lyxerr.debug() << "Inset Motion Notify x=" << x + lyxerr[Debug::INFO] << "Inset Motion Notify x=" << x << ", y=" << y << ", state=" << state << endl; } void UpdatableInset::InsetUnlock(BufferView *) { - lyxerr.debug() << "Inset Unlock" << endl; + lyxerr[Debug::INFO] << "Inset Unlock" << endl; } diff --git a/src/insets/insetert.C b/src/insets/insetert.C index a1e0e4c46e..8160e7416b 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -25,9 +25,11 @@ using std::ostream; InsetERT::InsetERT() : InsetCollapsable() { - setLabel(_("ERT")); + setLabel(_("666")); +#ifndef NO_LATEX LyXFont font(LyXFont::ALL_SANE); font.setLatex (LyXFont::ON); +#endif labelfont = LyXFont(LyXFont::ALL_SANE); labelfont.decSize(); labelfont.decSize(); @@ -60,6 +62,12 @@ string const InsetERT::EditMessage() const } +bool InsetERT::InsertInset(BufferView *, Inset *) +{ + return false; +} + + void InsetERT::SetFont(BufferView *, LyXFont const &, bool, bool selectall) { // if selectall is activated then the fontchange was an outside general @@ -74,6 +82,38 @@ void InsetERT::SetFont(BufferView *, LyXFont const &, bool, bool selectall) void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button) { InsetCollapsable::Edit(bv, x, y, button); +#ifndef NO_LATEX LyXFont font(LyXFont::ALL_SANE); font.setLatex (LyXFont::ON); +#endif +} + + +int InsetERT::Latex(Buffer const *, std::ostream & os, bool /*fragile*/, + bool /*free_spc*/) const +{ + Paragraph::size_type siz = inset.par->size(); + for (Paragraph::size_type i = 0; i != siz; ++i) { + os << inset.par->getChar(i); + } + return 1; +} + + +int InsetERT::Ascii(Buffer const *, + std::ostream &, int /*linelen*/) const +{ + return 0; +} + + +int InsetERT::Linuxdoc(Buffer const *, std::ostream &) const +{ + return 0; +} + + +int InsetERT::DocBook(Buffer const *, std::ostream &) const +{ + return 0; } diff --git a/src/insets/insetert.h b/src/insets/insetert.h index f57208d4c8..d653b69316 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -30,18 +30,28 @@ public: /// InsetERT(); /// - void Write(Buffer const * buf, std::ostream & os) const; + virtual void Write(Buffer const * buf, std::ostream & os) const; /// - Inset * Clone(Buffer const &) const; + virtual Inset * Clone(Buffer const &) const; /// - string const EditMessage() const; + virtual string const EditMessage() const; /// - bool InsertInset(BufferView *, Inset *) { return false; } + virtual bool InsertInset(BufferView *, Inset *); /// - void SetFont(BufferView *, LyXFont const &, bool toggleall = false, - bool selectall = false); + virtual void SetFont(BufferView *, LyXFont const &, + bool toggleall = false, bool selectall = false); /// - void Edit(BufferView *, int, int, unsigned int); + virtual void Edit(BufferView *, int, int, unsigned int); + /// + virtual int Latex(Buffer const *, std::ostream &, bool fragile, + bool free_spc) const; + /// + virtual int Ascii(Buffer const *, + std::ostream &, int linelen = 0) const; + /// + virtual int Linuxdoc(Buffer const *, std::ostream &) const; + /// + virtual int DocBook(Buffer const *, std::ostream &) const; }; #endif diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index a99ce6cb79..fb7defde2b 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -328,7 +328,8 @@ void InsetGraphics::Read(Buffer const * buf, LyXLex & lex) lex.next(); string const token = lex.GetString(); - lyxerr.debug() << "Token: '" << token << '\'' << std::endl; + lyxerr[Debug::INFO] << "Token: '" << token << '\'' + << std::endl; if (token.empty()) { continue; @@ -597,14 +598,14 @@ void InsetGraphics::updateInset() const } -bool InsetGraphics::setParams(InsetGraphicsParams const & params) +bool InsetGraphics::setParams(InsetGraphicsParams const & p) { // If nothing is changed, just return and say so. - if (this->params == params) + if (params == p) return false; // Copy the new parameters. - this->params = params; + params = p; // Update the inset with the new parameters. updateInset(); @@ -622,7 +623,9 @@ InsetGraphicsParams InsetGraphics::getParams() const Inset * InsetGraphics::Clone(Buffer const &) const { +#ifdef WITH_WARNINGS #warning use the copy constructor instead. (Lgb) +#endif InsetGraphics * newInset = new InsetGraphics; newInset->cacheHandle = cacheHandle; diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index 1aedaa180c..148b677b23 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -39,7 +39,11 @@ InsetInfo::InsetInfo() : form(0), labelfont(LyXFont::ALL_SANE) { labelfont.decSize().decSize() - .setColor(LColor::note).setLatex(LyXFont::OFF); + .setColor(LColor::note) +#ifndef NO_LATEX + .setLatex(LyXFont::OFF) +#endif + ; } @@ -47,7 +51,11 @@ InsetInfo::InsetInfo(string const & str) : contents(str), form(0), labelfont(LyXFont::ALL_SANE) { labelfont.decSize().decSize() - .setColor(LColor::note).setLatex(LyXFont::OFF); + .setColor(LColor::note) +#ifndef NO_LATEX + .setLatex(LyXFont::OFF) +#endif + ; } diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 5be50470db..ff3fa02cb5 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -22,6 +22,7 @@ #include "buffer.h" #include "gettext.h" #include "BufferView.h" +#include "support/lstrings.h" using std::ostream; using std::vector; @@ -94,23 +95,3 @@ int InsetLabel::DocBook(Buffer const *, ostream & os) const os << ""; return 0; } - - -// This function escapes 8-bit characters and other problematic characters -// It's exactly the same code as in insetref.C. -string const InsetLabel::escape(string const & lab) const { - char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - string enc; - for (string::size_type i= 0; i < lab.length(); ++i) { - unsigned char c = lab[i]; - if (c >= 128 || c == '=' || c == '%') { - enc += '='; - enc += hexdigit[c >> 4]; - enc += hexdigit[c & 15]; - } else { - enc += c; - } - } - return enc; -} diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index b52ce2f8ce..888f1dd3bc 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -43,9 +43,6 @@ public: int Linuxdoc(Buffer const *, std::ostream &) const; /// int DocBook(Buffer const *, std::ostream &) const; -private: - /// This function escapes 8-bit characters - string const escape(string const &) const; }; #endif diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 0b50057837..80053ffe73 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -195,8 +195,10 @@ int InsetQuotes::width(BufferView *, LyXFont const & font) const LyXFont const InsetQuotes::ConvertFont(LyXFont const & f) const { LyXFont font(f); +#ifndef NO_LATEX // quotes-insets cannot be latex of any kind font.setLatex(LyXFont::OFF); +#endif return font; } diff --git a/src/insets/insetref.C b/src/insets/insetref.C index d0331fb6cf..681aa2183b 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -14,6 +14,7 @@ #include "frontends/Dialogs.h" #include "lyxfunc.h" #include "BufferView.h" +#include "support/lstrings.h" using std::ostream; @@ -81,30 +82,14 @@ int InsetRef::Linuxdoc(Buffer const *, ostream & os) const int InsetRef::DocBook(Buffer const *, ostream & os) const { - os << "" << getOptions() << ""; - return 0; -} - - -// This function escapes 8-bit characters and other problematic characters -// It's exactly the same code as in insetlabel.C. -string const InsetRef::escape(string const & lab) const -{ - char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - string enc; - for (string::size_type i = 0; i < lab.length(); ++i) { - unsigned char c= lab[i]; - if (c >= 128 || c == '=' || c == '%') { - enc += '='; - enc += hexdigit[c>>4]; - enc += hexdigit[c & 15]; - } else { - enc += c; - } + if (getOptions().empty()) { + os << ""; + } else { + os << "" << getOptions() << ""; } - return enc; + + return 0; } diff --git a/src/insets/insetref.h b/src/insets/insetref.h index 102371acdb..19c8c031d7 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -65,8 +65,6 @@ public: /// void Validate(LaTeXFeatures & features) const; private: - /// This function escapes 8-bit characters - string const escape(string const &) const; /// bool isLatex; }; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 437971d5ab..0278bb7e60 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -15,7 +15,7 @@ #include #include - +//#include #ifdef __GNUG__ #pragma implementation #endif @@ -24,6 +24,7 @@ #include "buffer.h" #include "commandtags.h" +#include "lyxfunc.h" #include "debug.h" #include "LaTeXFeatures.h" #include "Painter.h" @@ -46,7 +47,6 @@ using std::endl; using std::swap; using std::max; - namespace { const int ADD_TO_HEIGHT = 2; @@ -292,6 +292,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, first_visible_cell = cell; if (hasSelection()) DrawCellSelection(pain, nx, baseline, i, j, cell); + tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, cleared); DrawCellLines(pain, nx, baseline, i, cell); @@ -308,6 +309,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, if (the_locking_inset && tabular->GetCellInset(actcell) != the_locking_inset) { +#warning Jürgen, why is this? Inset * inset = tabular->GetCellInset(cell); for (i = 0; inset != the_locking_inset && i < tabular->rows(); @@ -353,7 +355,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, float dx = nx + tabular->GetBeginningOfTextInCell(cell); float cx = dx; //cx = dx = nx + tabular->GetBeginningOfTextInCell(cell); - tabular->GetCellInset(cell)->draw(bv,font,baseline, dx, false); + tabular->GetCellInset(cell)->draw(bv, font, baseline, dx, false); #if 0 if (bv->text->status == LyXText::CHANGED_IN_DRAW) return; @@ -382,8 +384,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, x -= ADD_TO_TABULAR_WIDTH; x += width(bv, font); if (bv->text->status == LyXText::CHANGED_IN_DRAW) { - int i=0; - for(Inset * inset=owner();inset;++i) + int i = 0; + for(Inset * inset=owner(); inset; ++i) inset = inset->owner(); if (calculate_dimensions_of_cells(bv, font, false)) need_update = INIT; @@ -582,7 +584,9 @@ bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset, if (the_locking_inset == inset) { the_locking_inset->InsetUnlock(bv); the_locking_inset = 0; +#ifdef WITH_WARNINGS #warning fix scrolling when cellinset has requested a scroll (Jug)!!! +#endif #if 0 if (scroll(false)) scroll(bv, 0.0F); @@ -783,7 +787,7 @@ InsetTabular::LocalDispatch(BufferView * bv, bool hs = hasSelection(); - result=DISPATCHED; + result = DISPATCHED; // this one have priority over the locked InsetText! switch (action) { case LFUN_SHIFT_TAB: @@ -1141,10 +1145,13 @@ bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv, changed = tabular->SetDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT) || changed; return changed; } +#if 0 + cur_cell = -1; +#endif for (int i = 0; i < tabular->rows(); ++i) { maxAsc = 0; maxDesc = 0; - for (int j= 0; j < tabular->columns(); ++j) { + for (int j = 0; j < tabular->columns(); ++j) { if (tabular->IsPartOfMultiColumn(i,j)) continue; ++cell; @@ -1904,34 +1911,36 @@ int InsetTabular::GetMaxWidthOfCell(BufferView * bv, int cell) const int InsetTabular::getMaxWidth(BufferView * bv, UpdatableInset const * inset) const { - typedef std::map Cache; - static Cache cache; - - int cell = -1; - Cache::const_iterator ci = cache.find(inset); - if (ci != cache.end()) { - cell = (*ci).second; - if (tabular->GetCellInset(cell) != inset) { - cell = -1; - } + int cell = tabular->cur_cell; + if (tabular->GetCellInset(cell) != inset) { + cell = actcell; + if (tabular->GetCellInset(cell) != inset) { + lyxerr << "Actcell not equal to actual cell!" << std::endl; + //raise(SIGSTOP); + cell = -1; + } } int const n = tabular->GetNumberOfCells(); + if (cell == -1) { cell = 0; for (; cell < n; ++cell) { if (tabular->GetCellInset(cell) == inset) break; } - cache[inset] = cell; } - - if (cell >= n) - return -1; + + if (cell >= n) { + return -1; + } + int w = GetMaxWidthOfCell(bv, cell); - if (w > 0) + if (w > 0) { // because the inset then subtracts it's top_x and owner->x() w += (inset->x() - top_x); + } + return w; } @@ -1945,8 +1954,8 @@ void InsetTabular::deleteLyXText(BufferView * bv, bool recursive) const void InsetTabular::resizeLyXText(BufferView * bv, bool force) const { if (force) { - for(int i=0; i < tabular->rows(); ++i) { - for(int j=0; j < tabular->columns(); ++j) { + for(int i = 0; i < tabular->rows(); ++i) { + for(int j = 0; j < tabular->columns(); ++j) { tabular->GetCellInset(i, j)->resizeLyXText(bv, true); } } @@ -1994,10 +2003,10 @@ void InsetTabular::OpenLayoutDialog(BufferView * bv) const // 2 ... toggled on // 3 ... toggled off // -LyXFunc::func_status InsetTabular::getStatus(string const & what) const +func_status::value_type InsetTabular::getStatus(string const & what) const { int action = LyXTabular::LAST_ACTION; - LyXFunc::func_status status = LyXFunc::OK; + func_status::value_type status = func_status::OK; int i = 0; for (; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) { @@ -2010,7 +2019,7 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const } } if (action == LyXTabular::LAST_ACTION) - return LyXFunc::Unknown; + return func_status::Unknown; string const argument = frontStrip(what.substr(tabularFeatures[i].feature.length())); @@ -2030,7 +2039,7 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const case LyXTabular::SET_MPWIDTH: case LyXTabular::SET_SPECIAL_COLUMN: case LyXTabular::SET_SPECIAL_MULTI: - status |= LyXFunc::Disabled; + status |= func_status::Disabled; return status; case LyXTabular::APPEND_ROW: @@ -2039,169 +2048,169 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const case LyXTabular::DELETE_COLUMN: case LyXTabular::SET_ALL_LINES: case LyXTabular::UNSET_ALL_LINES: - status |= LyXFunc::OK; + status |= func_status::OK; return status; case LyXTabular::MULTICOLUMN: if (tabular->IsMultiColumn(actcell)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_TOGGLE_LINE_TOP: flag = false; case LyXTabular::TOGGLE_LINE_TOP: if (tabular->TopLine(actcell, flag)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_TOGGLE_LINE_BOTTOM: flag = false; case LyXTabular::TOGGLE_LINE_BOTTOM: if (tabular->BottomLine(actcell, flag)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_TOGGLE_LINE_LEFT: flag = false; case LyXTabular::TOGGLE_LINE_LEFT: if (tabular->LeftLine(actcell, flag)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_TOGGLE_LINE_RIGHT: flag = false; case LyXTabular::TOGGLE_LINE_RIGHT: if (tabular->RightLine(actcell, flag)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_ALIGN_LEFT: flag = false; case LyXTabular::ALIGN_LEFT: if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_ALIGN_RIGHT: flag = false; case LyXTabular::ALIGN_RIGHT: if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_ALIGN_CENTER: flag = false; case LyXTabular::ALIGN_CENTER: if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_VALIGN_TOP: flag = false; case LyXTabular::VALIGN_TOP: if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_VALIGN_BOTTOM: flag = false; case LyXTabular::VALIGN_BOTTOM: if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::M_VALIGN_CENTER: flag = false; case LyXTabular::VALIGN_CENTER: if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_LONGTABULAR: if (tabular->IsLongTabular()) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::UNSET_LONGTABULAR: if (!tabular->IsLongTabular()) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_ROTATE_TABULAR: if (tabular->GetRotateTabular()) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::UNSET_ROTATE_TABULAR: if (!tabular->GetRotateTabular()) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_ROTATE_CELL: if (tabular->GetRotateCell(actcell)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::UNSET_ROTATE_CELL: if (!tabular->GetRotateCell(actcell)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_USEBOX: if (strToInt(argument) == tabular->GetUsebox(actcell)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_LTFIRSTHEAD: if (tabular->GetRowOfLTHead(actcell, dummy)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_LTHEAD: if (tabular->GetRowOfLTHead(actcell, dummy)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_LTFOOT: if (tabular->GetRowOfLTFoot(actcell, dummy)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_LTLASTFOOT: if (tabular->GetRowOfLTFoot(actcell, dummy)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; case LyXTabular::SET_LTNEWPAGE: if (tabular->GetLTNewPage(actcell)) - status |= LyXFunc::ToggleOn; + status |= func_status::ToggleOn; else - status |= LyXFunc::ToggleOff; + status |= func_status::ToggleOff; break; default: - status = LyXFunc::Disabled; + status = func_status::Disabled; break; } return status; @@ -2218,12 +2227,6 @@ bool InsetTabular::copySelection(BufferView * bv) { if (!hasSelection()) return false; - //delete paste_tabular; - - //int sel_col_start; - //int sel_col_end; - //int sel_row_start; - //int sel_row_end; int sel_col_start = tabular->column_of_cell(sel_cell_start); int sel_col_end = tabular->column_of_cell(sel_cell_end); @@ -2238,16 +2241,12 @@ bool InsetTabular::copySelection(BufferView * bv) int sel_row_start = tabular->row_of_cell(sel_cell_start); int sel_row_end = tabular->row_of_cell(sel_cell_end); if (sel_row_start > sel_row_end) { - //int tmp tmp = sel_row_start; - //sel_row_start = sel_row_end; - //sel_row_end = tmp; swap(sel_row_start, sel_row_end); } int const rows = sel_row_end - sel_row_start + 1; delete paste_tabular; paste_tabular = new LyXTabular(this, *tabular); // rows, columns); - //int i; for (int i = 0; i < sel_row_start; ++i) paste_tabular->DeleteRow(0); while(paste_tabular->rows() > rows) diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 2de5b4b949..211a191ec3 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -56,7 +56,7 @@ #include "tabular.h" #include "LString.h" #include "lyxcursor.h" -#include "lyxfunc.h" +#include "func_status.h" class LyXLex; class Painter; @@ -178,7 +178,7 @@ public: /// bool ShowInsetDialog(BufferView *) const; /// - LyXFunc::func_status getStatus(string const & argument) const; + func_status::value_type getStatus(string const & argument) const; /// std::vector const getLabelList() const; /// diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 7516a4a6b1..2382a35461 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -171,11 +171,12 @@ public: /// void SetFrameColor(BufferView *, LColor::color); /// - LyXText * getLyXText(BufferView const *, bool const recursive=false) const; + LyXText * getLyXText(BufferView const *, + bool const recursive = false) const; /// - void deleteLyXText(BufferView *, bool recursive=true) const; + void deleteLyXText(BufferView *, bool recursive = true) const; /// - void resizeLyXText(BufferView *, bool force=false) const; + void resizeLyXText(BufferView *, bool force = false) const; /// bool ShowInsetDialog(BufferView *) const; /// @@ -184,9 +185,11 @@ public: bool nodraw() const; /// int scroll(bool recursive=true) const; + /// void scroll(BufferView *bv, float sx) const { UpdatableInset::scroll(bv, sx); } + /// void scroll(BufferView *bv, int offset) const { UpdatableInset::scroll(bv, offset); } diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 8bb730868f..dc73658688 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -277,7 +277,7 @@ int MenuRunChktex(Buffer * buffer) void QuitLyX() { - lyxerr.debug() << "Running QuitLyX." << endl; + lyxerr[Debug::INFO] << "Running QuitLyX." << endl; if (lyxrc.use_gui) { if (!bufferlist.QwriteAll()) @@ -294,7 +294,7 @@ void QuitLyX() bufferlist.closeAll(); // do any other cleanup procedures now - lyxerr.debug() << "Deleting tmp dir " << system_tempdir << endl; + lyxerr[Debug::INFO] << "Deleting tmp dir " << system_tempdir << endl; DestroyLyXTmpDir(system_tempdir); @@ -390,9 +390,9 @@ Buffer * NewLyxFile(string const & filename) tmpname = split(tmpname, ':'); } #endif - lyxerr.debug() << "Arg is " << filename - << "\nName is " << name - << "\nTemplate is " << tmpname << endl; + lyxerr[Debug::INFO] << "Arg is " << filename + << "\nName is " << name + << "\nTemplate is " << tmpname << endl; // find a free buffer Buffer * tmpbuf = bufferlist.newFile(name, tmpname); diff --git a/src/lyxfont.C b/src/lyxfont.C index c481050584..7dae2cab0d 100644 --- a/src/lyxfont.C +++ b/src/lyxfont.C @@ -107,7 +107,9 @@ LyXFont::FontBits LyXFont::sane = { SIZE_NORMAL, LColor::none, OFF, +#ifndef NO_LATEX OFF, +#endif OFF, OFF, OFF }; @@ -120,7 +122,9 @@ LyXFont::FontBits LyXFont::inherit = { INHERIT_SIZE, LColor::inherit, INHERIT, +#ifndef NO_LATEX INHERIT, +#endif INHERIT, INHERIT, OFF }; @@ -133,7 +137,9 @@ LyXFont::FontBits LyXFont::ignore = { IGNORE_SIZE, LColor::ignore, IGNORE, +#ifndef NO_LATEX IGNORE, +#endif IGNORE, IGNORE, IGNORE }; @@ -149,7 +155,9 @@ bool LyXFont::FontBits::operator==(LyXFont::FontBits const & fb1) const fb1.emph == emph && fb1.underbar == underbar && fb1.noun == noun && +#ifndef NO_LATEX fb1.latex == latex && +#endif fb1.number == number; } @@ -196,10 +204,12 @@ LyXFont::FONT_MISC_STATE LyXFont::underbar() const } +#ifndef NO_LATEX LyXFont::FONT_MISC_STATE LyXFont::latex() const { return bits.latex; } +#endif LColor::color LyXFont::color() const @@ -228,7 +238,11 @@ bool LyXFont::isRightToLeft() const bool LyXFont::isVisibleRightToLeft() const { - return (lang->RightToLeft() && latex() != ON && number() != ON); + return (lang->RightToLeft() && +#ifndef NO_LATEX + latex() != ON && +#endif + number() != ON); } @@ -281,11 +295,13 @@ LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n) } +#ifndef NO_LATEX LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l) { bits.latex = l; return *this; } +#endif LyXFont & LyXFont::setColor(LColor::color c) @@ -437,8 +453,10 @@ void LyXFont::update(LyXFont const & newfont, setEmph(setMisc(newfont.emph(), emph())); setUnderbar(setMisc(newfont.underbar(), underbar())); setNoun(setMisc(newfont.noun(), noun())); +#ifndef NO_LATEX setLatex(setMisc(newfont.latex(), latex())); - +#endif + setNumber(setMisc(newfont.number(), number())); if (newfont.language() == language() && toggleall) if (language() == document_language) @@ -472,8 +490,10 @@ void LyXFont::reduce(LyXFont const & tmplt) setUnderbar(INHERIT); if (noun() == tmplt.noun()) setNoun(INHERIT); +#ifndef NO_LATEX if (latex() == tmplt.latex()) setLatex(INHERIT); +#endif if (color() == tmplt.color()) setColor(LColor::inherit); } @@ -508,9 +528,11 @@ LyXFont & LyXFont::realize(LyXFont const & tmplt) if (bits.noun == INHERIT) { bits.noun = tmplt.bits.noun; } +#ifndef NO_LATEX if (bits.latex == INHERIT) { bits.latex = tmplt.bits.latex; } +#endif if (bits.color == LColor::inherit) { bits.color = tmplt.bits.color; } @@ -524,7 +546,10 @@ bool LyXFont::resolved() const return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES && shape() != INHERIT_SHAPE && size() != INHERIT_SIZE && emph() != INHERIT && underbar() != INHERIT && - noun() != INHERIT && latex() != INHERIT && + noun() != INHERIT && +#ifndef NO_LATEX + latex() != INHERIT && +#endif color() != LColor::inherit); } @@ -551,8 +576,10 @@ string const LyXFont::stateText(BufferParams * params) const << _(GUIMiscNames[underbar()]) << ", "; if (noun() != INHERIT) ost << _("Noun ") << _(GUIMiscNames[noun()]) << ", "; +#ifndef NO_LATEX if (latex() != INHERIT) ost << _("Latex ") << _(GUIMiscNames[latex()]) << ", "; +#endif if (bits == inherit) ost << _("Default") << ", "; if (!params || (language() != params->language)) @@ -689,6 +716,7 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex) lex.next(); string const ttok = lex.GetString(); setLyXSize(ttok); +#ifndef NO_LATEX } else if (tok == "latex") { lex.next(); string const ttok = lowercase(lex.GetString()); @@ -700,6 +728,7 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex) } else { lex.printError("Illegal LaTeX type`$$Token'"); } +#endif } else if (tok == "misc") { lex.next(); string const ttok = lowercase(lex.GetString()); @@ -773,6 +802,7 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const if (orgfont.noun() != noun()) { os << "\\noun " << LyXMiscNames[noun()] << " \n"; } +#ifndef NO_LATEX if (orgfont.latex() != latex()) { // This is only for backwards compatibility switch (latex()) { @@ -789,6 +819,7 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const break; } } +#endif if (orgfont.color() != color()) { // To make us file compatible with older // lyx versions we emit "default" instead @@ -977,8 +1008,10 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base, LColor::color LyXFont::realColor() const { +#ifndef NO_LATEX if (latex() == ON) return LColor::latex; +#endif if (color() == LColor::none) return LColor::foreground; return color(); @@ -1005,7 +1038,9 @@ LyXFont::FONT_SHAPE LyXFont::realShape() const bool LyXFont::equalExceptLatex(LyXFont const & f) const { LyXFont f1 = *this; +#ifndef NO_LATEX f1.setLatex(f.latex()); +#endif return f1 == f; } diff --git a/src/lyxfont.h b/src/lyxfont.h index 6a716b88c1..11543c87f3 100644 --- a/src/lyxfont.h +++ b/src/lyxfont.h @@ -26,6 +26,8 @@ class LyXLex; class BufferParams; +//#define NO_LATEX 1 + /// class LyXFont { public: @@ -186,9 +188,10 @@ public: /// FONT_MISC_STATE noun() const; +#ifndef NO_LATEX /// FONT_MISC_STATE latex() const; - +#endif /// FONT_MISC_STATE number() const; @@ -218,8 +221,10 @@ public: LyXFont & setUnderbar(LyXFont::FONT_MISC_STATE u); /// LyXFont & setNoun(LyXFont::FONT_MISC_STATE n); +#ifndef NO_LATEX /// LyXFont & setLatex(LyXFont::FONT_MISC_STATE l); +#endif /// LyXFont & setNumber(LyXFont::FONT_MISC_STATE n); /// @@ -330,8 +335,10 @@ private: FONT_MISC_STATE underbar; /// FONT_MISC_STATE noun; +#ifndef NO_LATEX /// FONT_MISC_STATE latex; +#endif /// FONT_MISC_STATE number; }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 245c063478..33ae956f30 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -59,7 +59,9 @@ #include "insets/insettheorem.h" #include "insets/insetcaption.h" #include "mathed/formulamacro.h" -#include "spellchecker.h" // RVDK_PATCH_5 +#include "mathed/math_cursor.h" +#include "mathed/math_inset.h" +#include "spellchecker.h" #include "minibuffer.h" #include "vspace.h" #include "LyXView.h" @@ -350,17 +352,17 @@ void LyXFunc::processKeySym(KeySym keysym, unsigned int state) } -LyXFunc::func_status LyXFunc::getStatus(int ac) const +func_status::value_type LyXFunc::getStatus(int ac) const { return getStatus(ac, string()); } -LyXFunc::func_status LyXFunc::getStatus(int ac, - string const & not_to_use_arg) const +func_status::value_type LyXFunc::getStatus(int ac, + string const & not_to_use_arg) const { kb_action action; - func_status flag = LyXFunc::OK; + func_status::value_type flag = func_status::OK; string argument; Buffer * buf = owner->buffer(); @@ -374,7 +376,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, if (action == LFUN_UNKNOWN_ACTION) { setErrorMessage(N_("Unknown action")); - return LyXFunc::Unknown; + return func_status::Unknown; } // Check whether we need a buffer @@ -388,13 +390,13 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, LyXAction::ReadOnly)) { // no setErrorMessage(N_("Document is read-only")); - flag |= LyXFunc::Disabled; + flag |= func_status::Disabled; } } else { // no setErrorMessage(N_("Command not allowed with" "out any document open")); - flag |= LyXFunc::Disabled; + flag |= func_status::Disabled; return flag; } } @@ -447,7 +449,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, case LFUN_TABULAR_FEATURE: disable = true; if (owner->view()->theLockingInset()) { - func_status ret = LyXFunc::Disabled; + func_status::value_type ret = func_status::Disabled; if (owner->view()->theLockingInset()->LyxCode() == Inset::TABULAR_CODE) { ret = static_cast (owner->view()->theLockingInset())-> @@ -455,20 +457,20 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, } else if (owner->view()->theLockingInset()->GetFirstLockingInsetOfType(Inset::TABULAR_CODE)) { ret = static_cast (owner->view()->theLockingInset()-> - GetFirstLockingInsetOfType(Inset::TABULAR_CODE))-> + GetFirstLockingInsetOfType(Inset::TABULAR_CODE))-> getStatus(argument); } flag |= ret; disable = false; } else { - static InsetTabular inset(*owner->buffer(), 1, 1); - func_status ret; - - disable = true; - ret = inset.getStatus(argument); - if ((ret & LyXFunc::ToggleOn) || - (ret & LyXFunc::ToggleOff)) - flag |= LyXFunc::ToggleOff; + static InsetTabular inset(*owner->buffer(), 1, 1); + func_status::value_type ret; + + disable = true; + ret = inset.getStatus(argument); + if ((ret & func_status::ToggleOn) || + (ret & func_status::ToggleOff)) + flag |= func_status::ToggleOff; } break; @@ -489,39 +491,117 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, case LFUN_BOOKMARK_GOTO: disable = !owner->view()-> isSavedPosition(strToUnsignedInt(argument)); + case LFUN_MATH_VALIGN: { + Inset * tli = owner->view()->theLockingInset(); + if (tli && (tli->LyxCode() == Inset::MATH_CODE + || tli->LyxCode() == Inset::MATHMACRO_CODE)) { + char align = mathcursor->valign(); + if (align == '\0') { + disable = true; + break; + } + if (argument.empty()) { + flag = func_status::OK; + break; + } + if (!contains("tcb", argument[0])) { + disable = true; + break; + } + if (argument[0] == align) + flag |= func_status::ToggleOn; + else + flag |= func_status::ToggleOff; + } else + disable = true; + break; + } + case LFUN_MATH_HALIGN: { + Inset * tli = owner->view()->theLockingInset(); + if (tli && (tli->LyxCode() == Inset::MATH_CODE + || tli->LyxCode() == Inset::MATHMACRO_CODE)) { + char align = mathcursor->halign(); + if (align == '\0') { + disable = true; + break; + } + if (argument.empty()) { + flag = func_status::OK; + break; + } + if (!contains("lcr", argument[0])) { + disable = true; + break; + } + if (argument[0] == align) + flag |= func_status::ToggleOn; + else + flag |= func_status::ToggleOff; + } else + disable = true; + break; + } + case LFUN_MATH_MUTATE: { + Inset * tli = owner->view()->theLockingInset(); + if (tli && (tli->LyxCode() == Inset::MATH_CODE)) { + MathInsetTypes type = mathcursor->par()->GetType(); + func_status::value_type box = func_status::ToggleOff; + if (argument == "inline") { + if (type == LM_OT_SIMPLE) + box = func_status::ToggleOn; + } else if (argument == "display") { + if (type == LM_OT_EQUATION) + box = func_status::ToggleOn; + } else if (argument == "eqnarray") { + if (type == LM_OT_EQNARRAY) + box = func_status::ToggleOn; + } else if (argument == "align") { + if (type == LM_OT_ALIGN) + box = func_status::ToggleOn; + } else { + box = func_status::OK; + disable = true; + } + flag |= box; + } else + disable = true; + break; + } default: break; } if (disable) - flag |= LyXFunc::Disabled; + flag |= func_status::Disabled; if (buf) { - func_status box = LyXFunc::ToggleOff; + func_status::value_type box = func_status::ToggleOff; LyXFont const & font = TEXT(false)->real_current_font; switch (action) { case LFUN_EMPH: if (font.emph() == LyXFont::ON) - box = LyXFunc::ToggleOn; + box = func_status::ToggleOn; break; case LFUN_NOUN: if (font.noun() == LyXFont::ON) - box = LyXFunc::ToggleOn; + box = func_status::ToggleOn; break; case LFUN_BOLD: if (font.series() == LyXFont::BOLD_SERIES) - box = LyXFunc::ToggleOn; + box = func_status::ToggleOn; break; +#ifndef NO_LATEX case LFUN_TEX: if (font.latex() == LyXFont::ON) - box = LyXFunc::ToggleOn; + box = func_status::ToggleOn; break; +#endif case LFUN_READ_ONLY_TOGGLE: if (buf->isReadonly()) - box = LyXFunc::ToggleOn; + box = func_status::ToggleOn; break; default: - box = LyXFunc::OK; + box = func_status::OK; break; } flag |= box; @@ -583,58 +663,9 @@ string const LyXFunc::Dispatch(int ac, owner->view()->hideCursor(); // We cannot use this function here - if (getStatus(ac, do_not_use_this_arg) & Disabled) + if (getStatus(ac, do_not_use_this_arg) & func_status::Disabled) goto exit_with_message; - commandshortcut.erase(); - - if (lyxrc.display_shortcuts && show_sc) { - if (action != LFUN_SELFINSERT) { - // Put name of command and list of shortcuts - // for it in minibuffer - string comname = lyxaction.getActionName(action); - - int pseudoaction = action; - bool argsadded = false; - - if (!argument.empty()) { - // If we have the command with argument, - // this is better - pseudoaction = - lyxaction.searchActionArg(action, - argument); - - if (pseudoaction == -1) { - pseudoaction = action; - } else { - comname += " " + argument; - argsadded = true; - } - } - - string const shortcuts = - toplevel_keymap->findbinding(pseudoaction); - - if (!shortcuts.empty()) { - comname += ": " + shortcuts; - } else if (!argsadded) { - comname += " " + argument; - } - - if (!comname.empty()) { - comname = strip(comname); - commandshortcut = "(" + comname + ')'; - owner->message(commandshortcut); - - // Here we could even add a small pause, - // to annoy the user and make him learn - // the shortcuts. - // No! That will just annoy, not teach - // anything. The user will read the messages - // if they are interested. (Asger) - } - } - } if (owner->view()->available() && owner->view()->theLockingInset()) { UpdatableInset::RESULT result; @@ -644,7 +675,7 @@ string const LyXFunc::Dispatch(int ac, if ((action==LFUN_UNKNOWN_ACTION) && argument.empty()){ argument = keyseq.getiso(); } - // Undo/Redo pre 0.13 is a bit tricky for insets. + // Undo/Redo is a bit tricky for insets. if (action == LFUN_UNDO) { int slx; int sly; @@ -989,13 +1020,15 @@ string const LyXFunc::Dispatch(int ac, case LFUN_FREE: owner->getDialogs()->setUserFreeFont(); break; - + +#ifndef NO_LATEX case LFUN_TEX: Tex(owner->view()); owner->view()->setState(); owner->showState(); break; - +#endif + case LFUN_RECONFIGURE: Reconfigure(owner->view()); break; @@ -1130,9 +1163,9 @@ string const LyXFunc::Dispatch(int ac, case LFUN_LAYOUTNO: { - lyxerr.debug() << "LFUN_LAYOUTNO: (arg) " << argument << endl; + lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (arg) " << argument << endl; int sel = strToInt(argument); - lyxerr.debug() << "LFUN_LAYOUTNO: (sel) "<< sel << endl; + lyxerr[Debug::INFO] << "LFUN_LAYOUTNO: (sel) "<< sel << endl; // Should this give a setMessage instead? if (sel == 0) @@ -1201,7 +1234,7 @@ string const LyXFunc::Dispatch(int ac, case LFUN_GETNAME: setMessage(owner->buffer()->fileName()); - lyxerr.debug() << "FNAME[" + lyxerr[Debug::INFO] << "FNAME[" << owner->buffer()->fileName() << "] " << endl; break; @@ -1476,6 +1509,55 @@ string const LyXFunc::Dispatch(int ac, exit_with_message: + commandshortcut.erase(); + + if (lyxrc.display_shortcuts && show_sc) { + if (action != LFUN_SELFINSERT) { + // Put name of command and list of shortcuts + // for it in minibuffer + string comname = lyxaction.getActionName(action); + + int pseudoaction = action; + bool argsadded = false; + + if (!argument.empty()) { + // If we have the command with argument, + // this is better + pseudoaction = + lyxaction.searchActionArg(action, + argument); + + if (pseudoaction == -1) { + pseudoaction = action; + } else { + comname += " " + argument; + argsadded = true; + } + } + + string const shortcuts = + toplevel_keymap->findbinding(pseudoaction); + + if (!shortcuts.empty()) { + comname += ": " + shortcuts; + } else if (!argsadded) { + comname += " " + argument; + } + + if (!comname.empty()) { + comname = strip(comname); + commandshortcut = "(" + comname + ')'; + + // Here we could even add a small pause, + // to annoy the user and make him learn + // the shortcuts. + // No! That will just annoy, not teach + // anything. The user will read the messages + // if they are interested. (Asger) + } + } + } + string const res = getMessage(); if (res.empty()) { @@ -1527,7 +1609,7 @@ void LyXFunc::MenuNew(bool fromTemplate) if (result.second.empty()) { owner->message(_("Canceled.")); - lyxerr.debug() << "New Document Cancelled." << endl; + lyxerr[Debug::INFO] << "New Document Cancelled." << endl; return; } @@ -1558,31 +1640,28 @@ void LyXFunc::MenuNew(bool fromTemplate) } } // Check whether the file already exists - if (IsLyXFilename(s)) { - FileInfo fi(s); - if (fi.readable() && - AskQuestion(_("File already exists:"), - MakeDisplayPath(s, 50), - _("Do you want to open the document?"))) { + FileInfo fi(s); + if (fi.readable() && + AskQuestion(_("File already exists:"), + MakeDisplayPath(s, 50), + _("Do you want to open the document?"))) { // loads document - string const disp_fn(MakeDisplayPath(s)); - - ostringstream str; - str << _("Opening document") << ' ' - << disp_fn << "..."; - - owner->message(str.str().c_str()); - //XFlush(fl_get_display()); - owner->view()->buffer( - bufferlist.loadLyXFile(s)); - ostringstream str2; - str2 << _("Document") << ' ' - << disp_fn << ' ' << _("opened."); - - owner->message(str2.str().c_str()); - - return; - } + string const disp_fn(MakeDisplayPath(s)); + + ostringstream str; + str << _("Opening document") << ' ' + << disp_fn << "..."; + + owner->message(str.str().c_str()); + //XFlush(fl_get_display()); + owner->view()->buffer(bufferlist.loadLyXFile(s)); + ostringstream str2; + str2 << _("Document") << ' ' + << disp_fn << ' ' << _("opened."); + + owner->message(str2.str().c_str()); + + return; } } else { s = AddName(lyxrc.document_path, @@ -1622,7 +1701,7 @@ void LyXFunc::MenuNew(bool fromTemplate) } // find a free buffer - lyxerr.debug() << "Find a free buffer." << endl; + lyxerr[Debug::INFO] << "Find a free buffer." << endl; owner->view()->buffer(bufferlist.newFile(s, templname)); } @@ -1665,11 +1744,9 @@ void LyXFunc::Open(string const & fname) } else filename = fname; - // get absolute path of file and make sure the filename ends - // with .lyx - filename = MakeAbsPath(filename); - if (!IsLyXFilename(filename)) - filename += ".lyx"; + // get absolute path of file and add ".lyx" to the filename if + // necessary + filename = FileSearch(string(), filename, "lyx"); // loads document string const disp_fn(MakeDisplayPath(filename)); @@ -1698,8 +1775,8 @@ void LyXFunc::doImport(string const & argument) { string format; string filename = split(argument, format, ' '); - lyxerr.debug() << "LyXFunc::doImport: " << format - << " file: " << filename << endl; + lyxerr[Debug::INFO] << "LyXFunc::doImport: " << format + << " file: " << filename << endl; if (filename.empty()) { // need user interaction string initpath = lyxrc.document_path; diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 68ee86ff53..f1312dadd6 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -10,6 +10,7 @@ #include FORMS_H_LOCATION #include "commandtags.h" +#include "func_status.h" #include "kbsequence.h" #include "insets/inset.h" #include "LString.h" @@ -25,19 +26,6 @@ class LyXView; */ class LyXFunc : public SigC::Object { public: - /// The status of a function. - enum func_status { - /// No problem - OK = 0, - /// - Unknown = 1, - /// Command cannot be executed - Disabled = 2, - /// - ToggleOn = 4, - /// - ToggleOff = 8 - }; /// explicit LyXFunc(LyXView *); @@ -59,9 +47,10 @@ public: /// we need one internall which is called from inside LyXAction and /// can contain the string argument. - func_status getStatus(int ac) const; + func_status::value_type getStatus(int ac) const; /// - func_status getStatus(int ac, string const & not_to_use_arg) const; + func_status::value_type getStatus(int ac, + string const & not_to_use_arg) const; /// The last key was meta bool wasMetaKey() const; @@ -185,11 +174,4 @@ void LyXFunc::setHintMessage(bool hm) show_sc = hm; } -/// -inline -void operator|=(LyXFunc::func_status & fs, LyXFunc::func_status f) -{ - fs = static_cast(fs | f); -} - #endif diff --git a/src/lyxtext.h b/src/lyxtext.h index a7d11dbefa..5d55c9ddff 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -46,6 +46,15 @@ public: /// CHANGED_IN_DRAW }; + /// + enum word_location { + /// the word around the cursor + WHOLE_WORD, + /// the word begining from the cursor position + PARTIAL_WORD, + /// the next word (not yet used) + NEXT_WORD + }; /// Constructor LyXText(BufferView *); @@ -212,20 +221,6 @@ public: */ mutable LyXCursor cursor; -#if 0 - /* the selection cursor */ - /// - mutable bool selection; - /// - mutable bool mark_set; - - /// - mutable LyXCursor sel_cursor; - /// - mutable LyXCursor sel_start_cursor; - /// - mutable LyXCursor sel_end_cursor; -#else /** The structrue that keeps track of the selections set. */ struct Selection { bool set() const { @@ -249,7 +244,7 @@ public: }; mutable Selection selection; -#endif + /// needed for the toggling LyXCursor last_sel_cursor; /// @@ -264,6 +259,8 @@ public: /// string const selectionAsString(Buffer const *) const; + /// select the word we need depending on word_location + void getWord(LyXCursor & from, LyXCursor & to, word_location) const; /// just selects the word the cursor is in void selectWord(BufferView *); @@ -316,6 +313,8 @@ public: /// void cursorLeftOneWord(BufferView *) const; /// + void cursorLeftOneWord(LyXCursor &) const; + /// void cursorRightOneWord(BufferView *) const; /// void cursorUpParagraph(BufferView *) const; @@ -353,7 +352,7 @@ public: text_uppercase = 2 }; /// Change the case of the word at cursor position. - void changeWordCase(BufferView *, TextCase action); + void changeCase(BufferView *, TextCase action); /// void transposeChars(BufferView const &); diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index a4e88d22d8..5e5591bd91 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,18 @@ +2001-06-25 The LyX Project + + * math_scriptinset.C: Fix for entering with cursor up/down. + + * math_fracinset.C: We can enter fractions with cursor up and + down. + + * math_cursor.C (Right): Fixes for cursor movement. + + * formula.C (draw): New background color for math. + + * math_cursor.C: Fixes for toggling labels on/off in math. + Fixes for infinity and other symbols that didn't appear in + LaTeX. + 2001-06-24 The LyX Project * math_inset.C: Cursor movement is better in square roots, among diff --git a/src/mathed/array.C b/src/mathed/array.C index acbecb1230..4ceaa578b0 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -100,7 +100,7 @@ MathInset * MathArray::GetInset(int pos) const return p; } -char MathArray::GetChar(int pos) const +byte MathArray::GetChar(int pos) const { return pos < size() ? bf_[pos + 1] : '\0'; } @@ -122,7 +122,7 @@ void MathArray::replace(int pos, MathInset * p) memcpy(&bf_[pos + 1], &p, sizeof(p)); } -void MathArray::insert(int pos, char b, MathTextCodes t) +void MathArray::insert(int pos, byte b, MathTextCodes t) { bf_.insert(bf_.begin() + pos, 3, t); bf_[pos + 1] = b; @@ -144,7 +144,7 @@ void MathArray::push_back(MathInset * p) insert(size(), p); } -void MathArray::push_back(char b, MathTextCodes c) +void MathArray::push_back(byte b, MathTextCodes c) { insert(size(), b, c); } @@ -183,7 +183,7 @@ int MathArray::size() const void MathArray::erase(int pos) { - if (pos < bf_.size()) + if (pos < static_cast(bf_.size())) erase(pos, pos + item_size(pos)); } @@ -221,7 +221,16 @@ MathScriptInset * MathArray::prevScriptInset(int pos) const prev(pos); MathInset * inset = GetInset(pos); - if (inset && inset->GetType() == LM_OT_SCRIPT) + if (inset && inset->isScriptInset()) + return static_cast(inset); + + return 0; +} + +MathScriptInset * MathArray::nextScriptInset(int pos) const +{ + MathInset * inset = GetInset(pos); + if (inset && inset->isScriptInset()) return static_cast(inset); return 0; @@ -261,7 +270,6 @@ void MathArray::Write(ostream & os, bool fragile) const return; int brace = 0; - latexkeys const * l; for (int pos = 0; pos < size(); next(pos)) { if (isInset(pos)) { @@ -270,15 +278,22 @@ void MathArray::Write(ostream & os, bool fragile) const } else { - char fcode = GetCode(pos); - char c = GetChar(pos); + MathTextCodes fcode = GetCode(pos); + byte c = GetChar(pos); if (MathIsSymbol(fcode)) { - l = lm_get_key_by_id(c, fcode == LM_TC_BSYM ? LM_TK_BIGSYM : LM_TK_SYM); - if (l) - os << '\\' << l->name << ' '; + latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM); + + if (l == 0) { + l = lm_get_key_by_id(c, LM_TK_BIGSYM); + } + + if (l) { + os << '\\' << l->name << ' '; + } else { + lyxerr << "Could not find the LaTeX name for " << c << " and fcode " << fcode << "!" << std::endl; + } } else { - if (fcode >= LM_TC_RM && fcode <= LM_TC_TEXTRM) os << '\\' << math_font_name[fcode - LM_TC_RM] << '{'; @@ -295,7 +310,7 @@ void MathArray::Write(ostream & os, bool fragile) const if (c == '}' && fcode == LM_TC_TEX && brace < 0) lyxerr <<"Math warning: Unexpected closing brace.\n"; else - os << char(c); + os << c; } if (fcode >= LM_TC_RM && fcode <= LM_TC_TEXTRM) diff --git a/src/mathed/array.h b/src/mathed/array.h index 135bf136e3..cd0c071efd 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -64,7 +64,7 @@ public: /// void insert(int pos, MathInset * inset); /// - void insert(int pos, char, MathTextCodes); + void insert(int pos, byte, MathTextCodes); /// void insert(int pos, MathArray const &); @@ -85,7 +85,7 @@ public: /// void push_back(MathInset * inset); /// - void push_back(char, MathTextCodes); + void push_back(byte, MathTextCodes); /// void push_back(MathArray const &); /// @@ -104,7 +104,9 @@ public: /// MathScriptInset * prevScriptInset(int pos) const; /// - char GetChar(int pos) const; + MathScriptInset * nextScriptInset(int pos) const; + /// + byte GetChar(int pos) const; /// MathTextCodes GetCode(int pos) const; /// diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 50a847e251..ea5f5f76d5 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -117,16 +117,20 @@ void InsetFormula::Read(Buffer const *, LyXLex & lex) void InsetFormula::draw(BufferView * bv, LyXFont const &, - int y, float & x, bool) const + int y, float & xx, bool) const { + int x = int(xx) - 1; + y -= 2; MathInset::workwidth = bv->workWidth(); Painter & pain = bv->painter(); + int w = par()->width(); + int h = par()->height(); + int a = par()->ascent(); + pain.fillRectangle(int(x), y - a, w, h, LColor::mathbg); + if (mathcursor) { par()->Metrics(LM_ST_TEXT); - int w = par()->width() + 2; - int a = par()->ascent() + 1; - int h = par()->height() + 1; if (mathcursor->formula() == this) { if (mathcursor->Selection()) { @@ -136,12 +140,12 @@ void InsetFormula::draw(BufferView * bv, LyXFont const &, mathcursor->SelGetArea(xp, yp, n); pain.fillPolygon(xp, yp, n, LColor::selection); } - pain.rectangle(int(x - 1), y - a, w, h, LColor::green); + pain.rectangle(int(x), y - a, w, h, LColor::mathframe); } } par()->draw(pain, int(x), y); - x += par()->width(); + xx += par()->width(); setCursorVisible(false); } @@ -193,7 +197,7 @@ InsetFormula::LocalDispatch(BufferView * bv, kb_action action, //lyxerr << "toggling line number\n"; if (display()) { bv->lockedInsetStoreUndo(Undo::INSERT); - int row = par()->nrows() - 1; + int row = mathcursor->row(); bool old = par()->numbered(row); bv->owner()->message(old ? _("No number") : _("Number")); par()->numbered(row, !old); @@ -206,7 +210,7 @@ InsetFormula::LocalDispatch(BufferView * bv, kb_action action, { bv->lockedInsetStoreUndo(Undo::INSERT); - int row = par()->nrows() - 1; + int row = mathcursor->row(); string old_label = par()->label(row); string new_label = arg; @@ -313,7 +317,7 @@ void InsetFormula::Validate(LaTeXFeatures & features) const int InsetFormula::ascent(BufferView *, LyXFont const &) const { - return par()->ascent(); + return par()->ascent() + 4; } diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index c66eb52510..1941b0a614 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -282,8 +282,6 @@ void InsetFormulaBase::InsetUnlock(BufferView * bv) } - - void InsetFormulaBase::GetCursorPos(BufferView *, int & x, int & y) const { mathcursor->GetPos(x, y); @@ -352,7 +350,6 @@ void InsetFormulaBase::ToggleInsetSelection(BufferView * bv) } - vector const InsetFormulaBase::getLabelList() const { return std::vector(); @@ -532,7 +529,6 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, } if (!mathcursor->Left()) break; - // fall through... case LFUN_DELETE: @@ -622,12 +618,17 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, case LFUN_CODE: mathcursor->toggleLastCode(LM_TC_TT); break; case LFUN_DEFAULT: mathcursor->setLastCode(LM_TC_VAR); break; +#ifndef NO_LATEX +#ifdef WITH_WARNINGS +#warning This needs a fix. + // Can we use the ERT inset here? (Lgb) +#endif case LFUN_TEX: // varcode = LM_TC_TEX; mathcursor->setLastCode(LM_TC_TEX); bv->owner()->message(_("TeX mode")); break; - +#endif case LFUN_MATH_LIMITS: bv->lockedInsetStoreUndo(Undo::INSERT); if (mathcursor->toggleLimits()) @@ -638,7 +639,7 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, if (!arg.empty()) { bv->lockedInsetStoreUndo(Undo::INSERT); latexkeys const * l = in_word_set(arg); - mathcursor->SetSize(MathStyles(l ? l->id : -1)); + mathcursor->SetSize(MathStyles(l ? l->id : static_cast(-1))); UpdateLocal(bv); } break; @@ -651,7 +652,6 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, } break; - case LFUN_INSERT_MATRIX: if (mathcursor) { bv->lockedInsetStoreUndo(Undo::INSERT); @@ -815,18 +815,8 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, result = UNDISPATCHED; break; - - //------- dummy actions -#ifdef WITH_WARNINGS -#warning Is this needed here? Shouldnt the main dispatch handle this? (Lgb) -#endif - //case LFUN_EXEC_COMMAND: - //bv->owner()->getMiniBuffer()->PrepareForCommand(); - //break; - default: - if ((action == -1 || action == LFUN_SELFINSERT) - && !arg.empty()) { + if ((action == -1 || action == LFUN_SELFINSERT) && !arg.empty()) { unsigned char c = arg[0]; bv->lockedInsetStoreUndo(Undo::INSERT); @@ -896,11 +886,20 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, mathcursor->clearLastCode(); mathcursor->insert(c, LM_TC_MIN); } else if (('0' <= c && c <= '9') || strchr(";:!|[]().,?", c)) { - mathcursor->insert(c, LM_TC_CONST); + MathTextCodes code = mathcursor->getLastCode(); + if (code != LM_TC_TEXTRM) + code = LM_TC_CONST; + mathcursor->insert(c, code); } else if (strchr("+/-*<>=", c)) { - mathcursor->insert(c, LM_TC_BOP); + MathTextCodes code = mathcursor->getLastCode(); + if (code != LM_TC_TEXTRM) + code = LM_TC_BOP; + mathcursor->insert(c, code); } else if (strchr(latex_special_chars, c) && c!= '_') { - mathcursor->insert(c, LM_TC_SPECIAL); + MathTextCodes code = mathcursor->getLastCode(); + if (code != LM_TC_TEXTRM) + code = LM_TC_SPECIAL; + mathcursor->insert(c, code); } else if (c == '_' || c == '^') { char s[2]; s[0] = c; @@ -925,9 +924,9 @@ InsetFormulaBase::LocalDispatch(BufferView * bv, kb_action action, sp->SetSpace(isp); space_on = true; } else { - lyxerr << "look here!\n"; - //if (!mathcursor->cursor.pop() && !mathcursor->cursor.OK()) - result = FINISHED; + if (!mathcursor->pop()) + result = FINISHED; + mathcursor->plainRight(); } } else if (c == '\'' || c == '@') { mathcursor->insert (c, LM_TC_VAR); @@ -999,8 +998,7 @@ bool math_insert_greek(BufferView * bv, char c) new_inset->LocalDispatch(bv, LFUN_SELFINSERT, tmp); if (greek_kb_flag_save < 2) { bv->unlockInset(new_inset); // bv->theLockingInset()); -#warning someone broke this in bolzano - //bv->text->cursorRight(bv, true); + bv->text->cursorRight(bv, true); } } else if (bv->theLockingInset()->LyxCode() == Inset::MATH_CODE || @@ -1024,7 +1022,9 @@ LyXFont const InsetFormulaBase::ConvertFont(LyXFont const & f) const { // We have already discussed what was here LyXFont font(f); +#ifndef NO_LATEX font.setLatex(LyXFont::OFF); +#endif return font; } diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 2dd4a2af68..1317be9d95 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -143,7 +143,7 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f, pain.fillRectangle(int(x), y , w, h, LColor::mathbg); pain.rectangle(int(x), y, w, h, LColor::mathframe); - + if (mathcursor && mathcursor->formula() == this && mathcursor->Selection()) { int xp[10]; int yp[10]; diff --git a/src/mathed/math_bigopinset.C b/src/mathed/math_bigopinset.C index c82123e10f..9758426b94 100644 --- a/src/mathed/math_bigopinset.C +++ b/src/mathed/math_bigopinset.C @@ -9,8 +9,10 @@ using std::ostream; MathBigopInset::MathBigopInset(string const & name, int id) - : MathInset(name, LM_OT_BIGOP), lims_(-1), sym_(id) -{} + : MathScriptInset(true, false), lims_(-1), sym_(id) +{ + SetName(name); +} MathInset * MathBigopInset::Clone() const @@ -22,40 +24,34 @@ MathInset * MathBigopInset::Clone() const void MathBigopInset::Write(ostream & os, bool fragile) const { - bool const limp = GetLimits(); - + //bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY; os << '\\' << name(); - - bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY; - - if (limp && !f) + if (limits() == 1) os << "\\limits "; + else if (limits() == -1) + os << "\\nolimits "; else - if (!limp && f) - os << "\\nolimits "; - else - os << ' '; + os << ' '; + MathScriptInset::Write(os, fragile); } void MathBigopInset::WriteNormal(ostream & os) const { - bool const limp = GetLimits(); - bool f = sym_ != LM_int && sym_ != LM_oint; - os << "[bigop " << name(); - - if (limp && !f) - os << " limits"; + if (limits() == 1) + os << "\\limits "; + else if (limits() == -1) + os << "\\nolimits "; else - if (!limp && f) - os << " nolimits"; - + os << ' '; + MathScriptInset::WriteNormal(os); os << "] "; } void MathBigopInset::Metrics(MathStyles st) { + MathScriptInset::Metrics(st); size(st); string s; short t; @@ -68,9 +64,22 @@ void MathBigopInset::Metrics(MathStyles st) s = name(); t = LM_TC_TEXTRM; } - mathed_string_dim(t, size(), s, ascent_, descent_, width_); + + int asc, des, wid; + mathed_string_dim(t, size(), s, asc, des, wid); if (sym_ == LM_oint) - width_ += 2; + wid += 2; + + if (hasLimits()) { + ascent_ = asc + xcell(0).height() + 2; + descent_ = des + xcell(1).height() + 2; + width_ = max(width_, wid); + } else { + ascent_ = max(ascent_, asc); + descent_ = max(descent_, des); + width_ += wid; + } + } @@ -78,6 +87,7 @@ void MathBigopInset::draw(Painter & pain, int x, int y) { xo(x); yo(y); + string s; short t; @@ -93,22 +103,44 @@ void MathBigopInset::draw(Painter & pain, int x, int y) LColor::mathline); ++x; } - pain.text(x, y, s, mathed_get_font(t, size())); + + int asc, des, wid; + mathed_string_dim(t, size(), s, asc, des, wid); + + if (hasLimits()) { + int w = width(); + pain.text(x + (w - wid)/2, y, s, mathed_get_font(t, size())); + xcell(0).draw + (pain, x + (w - xcell(0).width())/2, y - asc - xcell(0).descent() - 1); + xcell(1).draw + (pain, x + (w - xcell(1).width())/2, y + des + xcell(1).ascent() + 1); + } else { + pain.text(x, y, s, mathed_get_font(t, size())); + MathScriptInset::draw(pain, x + wid, y); + } } -bool MathBigopInset::GetLimits() const -{ - // Default case - if (lims_ < 0) - return sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY; - - // Custom - return lims_ > 0; +int MathBigopInset::limits() const +{ + return lims_; } -void MathBigopInset::SetLimits(bool ls) +void MathBigopInset::limits(int limit) { - lims_ = ls ? 1 : 0; + lims_ = limit; +} + +bool MathBigopInset::hasLimits() const +{ + return limits() == 1 || (limits() == 0 && size() == LM_ST_DISPLAY); +} + + +bool MathBigopInset::idxDelete(int idx) +{ + // ignore the return value, we do not want the inset to be deleted + MathScriptInset::idxDelete(idx); + return false; } diff --git a/src/mathed/math_bigopinset.h b/src/mathed/math_bigopinset.h index 20fc5ec750..a518250f04 100644 --- a/src/mathed/math_bigopinset.h +++ b/src/mathed/math_bigopinset.h @@ -5,7 +5,7 @@ #include "math_scriptinset.h" /// big operators -class MathBigopInset : public MathInset { +class MathBigopInset : public MathScriptInset { public: /// MathBigopInset(string const &, int); @@ -20,11 +20,15 @@ public: /// void Metrics(MathStyles st); /// - bool GetLimits() const; + int limits() const; /// - void SetLimits(bool); -private: + bool hasLimits() const; + /// + void limits(int); /// + bool idxDelete(int idx); +private: + /// 1: \limits, -1: \nolimits, 0: use default int lims_; /// int sym_; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index c0849df500..9086e861e4 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -33,6 +33,7 @@ #include "LColor.h" #include "Painter.h" #include "math_matrixinset.h" +#include "math_grid.h" #include "math_spaceinset.h" #include "math_funcinset.h" #include "math_bigopinset.h" @@ -94,15 +95,16 @@ void MathCursor::push(MathInset * par, bool first) } -void MathCursor::pop() +bool MathCursor::pop() { if (path_.empty()) - return; + return false; par_ = path_.back().par_; idx_ = path_.back().idx_; cursor_ = path_.back().cursor_; dump("Popped:"); path_.pop_back(); + return true; } @@ -167,8 +169,7 @@ bool MathCursor::Left(bool sel) if (selection) { result = array().prev(cursor_); - if (!result && !path_.empty()) { - pop(); + if (!result && pop()) { anchor_ = cursor_; result = array().next(anchor_); } @@ -186,8 +187,7 @@ bool MathCursor::Left(bool sel) if (!result) { if (par_->idxLeft(idx_, cursor_)) { result = true; - } else if (!path_.empty()) { - pop(); + } else if (pop()) { result = true; } } @@ -198,6 +198,12 @@ bool MathCursor::Left(bool sel) } +bool MathCursor::plainRight() +{ + return array().next(cursor_); +} + + bool MathCursor::Right(bool sel) { dump("Right 1"); @@ -213,10 +219,9 @@ bool MathCursor::Right(bool sel) if (selection) { result = array().next(cursor_); - if (!result && !path_.empty()) { - pop(); + if (!result && pop()) { anchor_ = cursor_; - result = array().prev(anchor_); + result = array().next(cursor_); } } else { MathInset * p = nextActiveInset(); @@ -228,8 +233,7 @@ bool MathCursor::Right(bool sel) if (!result) { if (par_->idxRight(idx_, cursor_)) { result = true; - } else if (!path_.empty()) { - pop(); + } else if (pop()) { result = true; array().next(cursor_); } @@ -405,6 +409,13 @@ void MathCursor::Delete() if (cursor_ < array().size()) array().erase(cursor_); + // delete empty cells parts if necessary + if (cursor_ == 0 && array().size() == 0) { + bool removeit = par_->idxDelete(idx_); + if (pop() && removeit) + Delete(); + } + #ifdef WITH_WARNINGS #warning pullArg disabled #endif @@ -438,10 +449,38 @@ bool MathCursor::Up(bool sel) SelHandle(sel); SelClear(); + // check whether we could move into an inset on the right or on the left + MathInset * p = nextInset(); + if (p) { + int idx, cursor; + if (p->idxFirstUp(idx, cursor)) { + push(p, true); + par_ = p; + idx_ = idx; + cursor_ = cursor; + dump("Up 3"); + return true; + } + } + + p = prevInset(); + if (p) { + int idx, cursor; + if (p->idxLastUp(idx, cursor)) { + array().prev(cursor_); + push(p, false); + par_ = p; + idx_ = idx; + cursor_ = cursor; + dump("Up 4"); + return true; + } + } + + int x = xarray().pos2x(cursor_); bool result = par_->idxUp(idx_, cursor_); - if (!result && !path_.empty()) { - pop(); + if (!result && pop()) { result = par_->idxUp(idx_, cursor_); } cursor_ = xarray().x2pos(x); @@ -458,10 +497,35 @@ bool MathCursor::Down(bool sel) SelHandle(sel); SelClear(); + // check whether we could move into an inset on the right or on the left + MathInset * p = nextInset(); + if (p) { + int idx, cursor; + if (p->idxFirstDown(idx, cursor)) { + push(p, true); + idx_ = idx; + cursor_ = cursor; + dump("Down 3"); + return true; + } + } + + p = prevInset(); + if (p) { + int idx, cursor; + if (p->idxLastDown(idx, cursor)) { + array().prev(cursor_); + push(p, false); + idx_ = idx; + cursor_ = cursor; + dump("Down 4"); + return true; + } + } + int x = xarray().pos2x(cursor_); bool result = par_->idxDown(idx_, cursor_); - if (!result && !path_.empty()) { - pop(); + if (!result && pop()) { result = par_->idxDown(idx_, cursor_); } cursor_ = xarray().x2pos(x); @@ -476,9 +540,9 @@ bool MathCursor::toggleLimits() if (!prevIsInset()) return false; MathInset * p = prevInset(); - bool old = p->GetLimits(); - p->SetLimits(!old); - return old != p->GetLimits(); + int old = p->limits(); + p->limits(old == -1 ? 1 : -1); + return old != p->limits(); } @@ -494,26 +558,30 @@ void MathCursor::Interpret(string const & s) lyxerr << "Interpret: '" << s << "'\n"; if (s[0] == '^') { - MathScriptInset * p = prevScriptInset(); + MathScriptInset * p = nearbyScriptInset(); if (!p) { p = new MathScriptInset; insert(p); + array().prev(cursor_); } + push(p, true); if (!p->up()) p->up(true); - push(p, true); + idx_ = 0; return; } if (s[0] == '_') { - MathScriptInset * p = prevScriptInset(); + MathScriptInset * p = nearbyScriptInset(); if (!p) { p = new MathScriptInset; insert(p); + array().prev(cursor_); } + push(p, true); if (!p->down()) p->down(true); - push(p, true); + idx_ = 1; return; } @@ -526,7 +594,7 @@ void MathCursor::Interpret(string const & s) MathInset * p = 0; latexkeys const * l = in_word_set(s); - if (!l) { + if (l == 0) { if (s == "root") p = new MathRootInset; else if (MathMacroTable::hasTemplate(s)) @@ -540,13 +608,16 @@ void MathCursor::Interpret(string const & s) break; case LM_TK_SYM: - if (l->id < 255) - insert(static_cast(l->id), MathIsBOPS(l->id) ? - LM_TC_BOPS : LM_TC_SYMB); - else - p = new MathFuncInset(l->name); - break; - + if (l->id < 255) { + insert(static_cast(l->id), + MathIsBOPS(l->id) ? + LM_TC_BOPS : LM_TC_SYMB); + + } else { + p = new MathFuncInset(l->name); + } + break; + case LM_TK_STACK: p = new MathFracInset(LM_OT_STACKREL); break; @@ -1018,7 +1089,7 @@ MathInset * MathCursor::prevActiveInset() const if (cursor_ <= 0 || !array().isInset(cursor_ - 1)) return 0; MathInset * inset = prevInset(); - return inset->nargs() ? inset : 0; + return inset->isActive() ? inset : 0; } @@ -1034,14 +1105,17 @@ MathInset * MathCursor::nextActiveInset() const if (!array().isInset(cursor_)) return 0; MathInset * inset = nextInset(); - return inset->nargs() ? inset : 0; + return inset->isActive() ? inset : 0; } -MathScriptInset * MathCursor::prevScriptInset() const +MathScriptInset * MathCursor::nearbyScriptInset() const { normalize(); - return array().prevScriptInset(cursor_); + MathScriptInset * p = array().prevScriptInset(cursor_); + if (p) + return p; + return array().nextScriptInset(cursor_); } @@ -1078,7 +1152,7 @@ bool MathCursor::nextIsInset() const bool MathCursor::nextIsActive() const { - return nextIsInset() && nextInset()->nargs(); + return nextIsInset() && nextInset()->isActive(); } @@ -1090,7 +1164,7 @@ bool MathCursor::prevIsInset() const bool MathCursor::prevIsActive() const { - return prevIsInset() && prevInset()->nargs(); + return prevIsInset() && prevInset()->isActive(); } @@ -1122,3 +1196,19 @@ void MathCursor::idxRight() { par_->idxRight(idx_, cursor_); } + +char MathCursor::valign() const +{ + int idx; + MathGridInset * p = + static_cast(enclosing(LM_OT_MATRIX, idx)); + return p ? p->valign() : 0; +} + +char MathCursor::halign() const +{ + int idx; + MathGridInset * p = + static_cast(enclosing(LM_OT_MATRIX, idx)); + return p ? p->halign(idx % p->ncols()) : 0; +} diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 9284319070..af340065bb 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -56,6 +56,8 @@ public: /// Put the cursor in the last position void last(); /// + bool plainRight(); + /// void Delete(); /// void DelLine(); @@ -131,7 +133,15 @@ public: MathTextCodes prevCode() const; /// void selArray(MathArray &) const; - + /// + char valign() const; + /// + char halign() const; + /// + int col() const; + /// + int row() const; + //protected: /// bool macro_mode; @@ -167,9 +177,14 @@ public: /// MathStyles style() const; - /// + /// Make sure cursor position is valid void normalize() const; + /// Enter a new MathInset from the front or the back + void push(MathInset * par, bool first); + /// Leave current MathInset + bool pop(); + private: /// Description of a position struct MathIter { @@ -181,10 +196,6 @@ private: /// MathPath std::vector path_; - /// - void push(MathInset * par, bool first); - /// - void pop(); /// int last() const; /// @@ -222,11 +233,7 @@ private: /// MathInset * prevActiveInset() const; /// - MathScriptInset * prevScriptInset() const; - /// - int col() const; - /// - int row() const; + MathScriptInset * nearbyScriptInset() const; /// MathFuncInset * imacro; diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index a3b33c1ad4..09429072fb 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -11,7 +11,7 @@ #include "support/LOstream.h" -MathFracInset::MathFracInset(short ot) +MathFracInset::MathFracInset(MathInsetTypes ot) : MathInset("frac", ot, 2) { if (objtype == LM_OT_STACKREL) @@ -96,3 +96,31 @@ bool MathFracInset::idxDown(int & idx, int &) const return true; } +bool MathFracInset::idxFirstUp(int & idx, int & pos) const +{ + idx = 0; + pos = 0; + return true; +} + +bool MathFracInset::idxFirstDown(int & idx, int & pos) const +{ + idx = 1; + pos = 0; + return true; +} + +bool MathFracInset::idxLastUp(int & idx, int & pos) const +{ + idx = 0; + pos = cell(idx).size(); + return true; +} + +bool MathFracInset::idxLastDown(int & idx, int & pos) const +{ + idx = 1; + pos = cell(idx).size(); + return true; +} + diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 27d9ed61a5..072d265bca 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -14,7 +14,7 @@ class MathFracInset : public MathInset { public: /// - explicit MathFracInset(short ot = LM_OT_FRAC); + explicit MathFracInset(MathInsetTypes ot = LM_OT_FRAC); /// virtual MathInset * Clone() const; /// @@ -33,6 +33,14 @@ public: virtual bool idxLeft(int &, int &) const; /// virtual bool idxRight(int &, int &) const; + /// + virtual bool idxFirstUp(int & idx, int & pos) const; + /// + virtual bool idxFirstDown(int & idx, int & pos) const; + /// + virtual bool idxLastUp(int & idx, int & pos) const; + /// + virtual bool idxLastDown(int & idx, int & pos) const; }; #endif diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index c87bbee157..2f56e9fefb 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -17,7 +17,7 @@ using std::ostream; extern LyXFont WhichFont(short type, int size); -MathFuncInset::MathFuncInset(string const & nm, short ot) +MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot) : MathInset(nm, ot) { lims_ = (GetType() == LM_OT_FUNCLIM); @@ -34,7 +34,9 @@ void MathFuncInset::draw(Painter & pain, int x, int y) { if (!name_.empty() && name_[0] > ' ') { LyXFont font = WhichFont(LM_TC_TEXTRM, size()); +#ifndef NO_LATEX font.setLatex(LyXFont::ON); +#endif x += (lyxfont::width('I', font) + 3) / 4; pain.text(x, y, name_, font); } @@ -56,7 +58,9 @@ void MathFuncInset::WriteNormal(std::ostream & os) const void MathFuncInset::Metrics(MathStyles st) { LyXFont font = WhichFont(LM_TC_TEXTRM, size()); +#ifndef NO_LATEX font.setLatex(LyXFont::ON); +#endif size_ = st; if (name_.empty()) { width_ = lyxfont::width('M', font); diff --git a/src/mathed/math_funcinset.h b/src/mathed/math_funcinset.h index afb875f0b9..7bfea999a5 100644 --- a/src/mathed/math_funcinset.h +++ b/src/mathed/math_funcinset.h @@ -15,9 +15,9 @@ class MathFuncInset : public MathInset { public: /// - explicit MathFuncInset(string const & nm, short ot = LM_OT_FUNC); + explicit MathFuncInset(string const & nm, MathInsetTypes ot = LM_OT_FUNC); /// - MathInset * Clone() const; + MathInset * Clone() const; /// void draw(Painter &, int, int); /// diff --git a/src/mathed/math_grid.C b/src/mathed/math_grid.C index 0ec2c9a4bc..467f77ba14 100644 --- a/src/mathed/math_grid.C +++ b/src/mathed/math_grid.C @@ -36,7 +36,7 @@ MathGridInset::ColInfo::ColInfo() {} -MathGridInset::MathGridInset(int m, int n, string const & nm, short ot) +MathGridInset::MathGridInset(int m, int n, string const & nm, MathInsetTypes ot) : MathInset(nm, ot, m * n), rowinfo_(n), colinfo_(m), v_align_('c') { if (m <= 0) @@ -66,12 +66,21 @@ void MathGridInset::halign(char h, int col) colinfo_[col].h_align_ = h; } +char MathGridInset::halign(int col) const +{ + return colinfo_[col].h_align_; +} + void MathGridInset::valign(char c) { - lyxerr << "setting valign to " << c << "\n"; v_align_ = c; } +char MathGridInset::valign() const +{ + return v_align_; +} + void MathGridInset::Metrics(MathStyles st) { // let the cells adjust themselves @@ -101,7 +110,6 @@ void MathGridInset::Metrics(MathStyles st) } // adjust vertical offset - lyxerr << "v_align: " << v_align_ << "\n"; int h = 0; switch (v_align_) { case 't': @@ -139,11 +147,6 @@ void MathGridInset::Metrics(MathStyles st) width_ = colinfo_.back().offset_ + colinfo_.back().width_; ascent_ = - rowinfo_.front().offset_ + rowinfo_.front().ascent_; descent_ = rowinfo_.back().offset_ + rowinfo_.back().descent_; - - // some extra space around - width_ += 2 * MATH_BORDER; - ascent_ += MATH_BORDER; - descent_ += MATH_BORDER; /* // Increase ws_[i] for 'R' columns (except the first one) @@ -232,7 +235,6 @@ void MathGridInset::Write(std::ostream & os, bool fragile) const void MathGridInset::addRow(int row) { - lyxerr << "adding row " << row << endl; rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo()); cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray()); } diff --git a/src/mathed/math_grid.h b/src/mathed/math_grid.h index 67f835225e..f6ed4dee11 100644 --- a/src/mathed/math_grid.h +++ b/src/mathed/math_grid.h @@ -52,7 +52,7 @@ class MathGridInset : public MathInset { public: /// - MathGridInset(int m, int n, string const & nm, short ot); + MathGridInset(int m, int n, string const & nm, MathInsetTypes ot); /// MathInset * Clone() const = 0; /// @@ -66,8 +66,12 @@ public: /// void halign(char c, int col); /// + char halign(int col) const; + /// void valign(char c); /// + char valign() const; + /// void resize(short int type, int cols); /// const RowInfo & rowinfo(int row) const; diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index fef84e41f7..4386e96f0f 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -5,6 +5,7 @@ #include "math_defs.h" #include "math_parser.h" #include "support/lstrings.h" +#include namespace { @@ -12,7 +13,7 @@ latexkeys const wordlist[] = { {"setminus", LM_TK_SYM, LM_setminus}, {"ldots", LM_TK_DOTS, LM_ldots}, - //{"limits", LM_TK_LIMIT, 1 }, + {"limits", LM_TK_LIMIT, 1 }, {"stackrel", LM_TK_STACK, 0}, {"ll", LM_TK_SYM, LM_ll}, {"label", LM_TK_LABEL, 0}, @@ -82,7 +83,7 @@ latexkeys const wordlist[] = {"widehat", LM_TK_WIDE, LM_widehat}, {"sin", LM_TK_FUNC, 0}, {"asymp", LM_TK_SYM, LM_asymp}, - //{"nolimits", LM_TK_LIMIT, 0 }, + {"nolimits", LM_TK_LIMIT, 0 }, {"perp", LM_TK_MACRO, LM_perp}, {"wedge", LM_TK_SYM, LM_wedge}, {"ln", LM_TK_FUNC, 0}, @@ -282,14 +283,13 @@ latexkeys const wordlist[] = }; - struct symbolindex { - int id; + unsigned int id; short token; - symbolindex(int i, short t) : id(i), token(t) + symbolindex(unsigned int i, short t) : id(i), token(t) {} - + bool operator<(symbolindex const & s) const { return (id < s.id) || (id == s.id && token < s.token); @@ -307,7 +307,19 @@ struct init { init() { int const n = sizeof(wordlist)/sizeof(wordlist[0]); for (latexkeys const * it = wordlist; it != wordlist + n; ++it) { + if (LatexkeyByName.find(it->name) != LatexkeyByName.end()) { + std::cerr << "math_hash.C: Bug: Duplicate entry: " + << it->name << std::endl; + } LatexkeyByName[it->name] = it - wordlist; + if (it->id != 0 && + LatexkeyById.find(symbolindex(it->id, it->token)) != + LatexkeyById.end()) { + std::cerr << "math_hash.C: Bug: Duplicate entry: " + << it->name << " Id: " + << it->id << " token: " << it->token + << std::endl; + } LatexkeyById[symbolindex(it->id, it->token)] = it - wordlist; } } @@ -327,7 +339,7 @@ latexkeys const * in_word_set(string const & str) } -latexkeys const * lm_get_key_by_id(int id, short tc) +latexkeys const * lm_get_key_by_id(unsigned int id, short tc) { std::map::const_iterator pos = LatexkeyById.find(symbolindex(id, tc)); diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index b9903f2f4d..b44d53ad1a 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -30,7 +30,7 @@ int MathInset::workwidth; -MathInset::MathInset(string const & name, short ot, int nargs) +MathInset::MathInset(string const & name, MathInsetTypes ot, int nargs) : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0), size_(LM_ST_TEXT), cells_(nargs), xo_(0), yo_(0) {} @@ -60,13 +60,20 @@ int MathInset::height() const } -bool MathInset::GetLimits() const +int MathInset::limits() const { return false; } -void MathInset::SetLimits(bool) {} +void MathInset::limits(int) +{ +} + +bool MathInset::hasLimits() const +{ + return false; +} string const & MathInset::name() const @@ -75,13 +82,13 @@ string const & MathInset::name() const } -short MathInset::GetType() const +MathInsetTypes MathInset::GetType() const { return objtype; } -void MathInset::SetType(short t) +void MathInset::SetType(MathInsetTypes t) { objtype = t; } @@ -246,7 +253,7 @@ bool MathInset::idxLast(int & i, int & pos) const } -bool MathInset::idxHome(int & i, int & pos) const +bool MathInset::idxHome(int & /* idx */, int & pos) const { if (pos == 0) return false; @@ -265,6 +272,35 @@ bool MathInset::idxEnd(int & idx, int & pos) const } +bool MathInset::idxFirstUp(int &, int &) const +{ + return false; +} + + +bool MathInset::idxFirstDown(int &, int &) const +{ + return false; +} + +bool MathInset::idxDelete(int) +{ + return false; +} + + +bool MathInset::idxLastUp(int &, int &) const +{ + return false; +} + + +bool MathInset::idxLastDown(int &, int &) const +{ + return false; +} + + void MathInset::GetXY(int & x, int & y) const { x = xo(); diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 03f770a1c8..2baa756e8e 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -44,7 +44,7 @@ public: */ /// explicit - MathInset (string const & nm = string(), short ot = LM_OT_SIMPLE, int na = 0); + MathInset (string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE, int na = 0); /// The virtual base destructor virtual ~MathInset() {} @@ -59,7 +59,7 @@ public: /// Appends itself with macro arguments substituted virtual void substitute(MathArray & array, MathMacro const & macro) const; /// Compute the size of the object - virtual void Metrics(MathStyles st) = 0; + virtual void Metrics(MathStyles st) = 0; /// virtual int ascent() const; /// @@ -69,16 +69,18 @@ public: /// virtual int height() const; /// - virtual bool GetLimits() const; + virtual bool hasLimits() const; /// - virtual void SetLimits(bool); + virtual int limits() const; + /// + virtual void limits(int); /// string const & name() const; /// - short GetType() const; + MathInsetTypes GetType() const; //Man: Avoid to use these functions if it's not strictly necessary /// - virtual void SetType(short t); + virtual void SetType(MathInsetTypes t); /// virtual void SetName(string const & n); /// @@ -92,16 +94,30 @@ public: virtual bool idxLeft(int & idx, int & pos) const; /// The right key virtual bool idxRight(int & idx, int & pos) const; - /// Where should we go when we enter the inset from the left? + + /// Target pos when we enter the inset from the left by pressing "Right" virtual bool idxFirst(int & idx, int & pos) const; - /// Where should we go when we enter the inset from the right? + /// Target pos when we enter the inset from the left by pressing "Up" + virtual bool idxFirstUp(int & idx, int & pos) const; + /// Target pos when we enter the inset from the left by pressing "Down" + virtual bool idxFirstDown(int & idx, int & pos) const; + + /// Target pos when we enter the inset from the right by pressing "Left" virtual bool idxLast(int & idx, int & pos) const; + /// Target pos when we enter the inset from the right by pressing "Up" + virtual bool idxLastUp(int & idx, int & pos) const; + /// Target pos when we enter the inset from the right by pressing "Down" + virtual bool idxLastDown(int & idx, int & pos) const; /// Where should we go if we press home? virtual bool idxHome(int & idx, int & pos) const; /// Where should we go if we press end? virtual bool idxEnd(int & idx, int & pos) const; + /// Delete a cell and move cursor + // a return value true indicates that the whole inset should be deleted + virtual bool idxDelete(int idx); + /// int nargs() const; @@ -150,6 +166,10 @@ public: void GetXY(int & x, int & y) const; /// bool covers(int x, int y) const; + /// Identifies ScriptInsets + virtual bool isScriptInset() const { return false; } + /// + virtual bool isActive() const { return nargs() > 0; } /// @@ -166,7 +186,7 @@ protected: /// string name_; /// - short objtype; + MathInsetTypes objtype; /// int width_; /// diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 00c853a4a0..95d8572404 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -117,6 +117,12 @@ void MathMacroTable::builtinMacros() insertTemplate(t); } + { + MathMacroTemplate * t = new MathMacroTemplate("to", 0); + t->push_back(LM_rightarrow, LM_TC_SYMB); + insertTemplate(t); + } + { MathMacroTemplate * t = new MathMacroTemplate("perp", 0); t->push_back(LM_bot, LM_TC_BOP); diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index 0ec2f7faa3..96a4c0db74 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -104,47 +104,9 @@ void MathMatrixInset::Metrics(MathStyles st) if (l) width_ += 30 + l; } - -/* - { - cxrow->setBaseline((cxrow == row_.begin()) ? - cxrow->ascent() : - cxrow->ascent() + cprow->descent() - + MATH_ROWSEP + cprow->getBaseline()); - h += cxrow->ascent() + cxrow->descent() + MATH_ROWSEP; - cprow = cxrow; - } - - int const hl = descent(); - h -= MATH_ROWSEP; - - // Compute vertical align - switch (v_align_) { - case 't': - ascent = row_.begin()->getBaseline(); - break; - case 'b': - ascent = h - hl; - break; - default: - ascent = row_.begin().is_last() ? h / 2 : h - hl; - break; - } - descent = h - ascent + 2; - - // Increase ws_[i] for 'R' columns (except the first one) - for (int i = 1; i < nc_; ++i) - if (h_align_[i] == 'R') - ws_[i] += 10 * df_width; - // Increase ws_[i] for 'C' column - if (h_align_[0] == 'C') - if (ws_[0] < 7 * workwidth / 8) - ws_[0] = 7 * workwidth / 8; - -*/ - } + void MathMatrixInset::draw(Painter & pain, int x, int y) { xo(x); @@ -154,7 +116,9 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) if (numberedType()) { LyXFont wfont = WhichFont(LM_TC_BF, size()); +#ifndef NO_LATEX wfont.setLatex(LyXFont::OFF); +#endif int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20; for (int row = 0; row < nrows(); ++row) pain.text(xx, y + rowinfo_[row].offset_, nicelabel(row), wfont); diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 1ae93cb369..e5640e6036 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -403,7 +403,7 @@ void handle_frac(MathArray & dat, MathInsetTypes t) MathScriptInset * lastScriptInset(MathArray & array) { MathInset * p = array.back_inset(); - if (!p || p->GetType() != LM_OT_SCRIPT) { + if (!p || !p->isScriptInset()) { p = new MathScriptInset; array.push_back(p); } @@ -417,12 +417,12 @@ MathScriptInset * lastScriptInset(MathArray & array) static bool curr_num; static string curr_label; -void mathed_parse_lines(MathInset * inset, int col) +void mathed_parse_lines(MathInset * inset, int col, bool numbered, bool outmost) { MathGridInset * p = static_cast(inset); - while (1) { + for (int row = 0; true; ++row) { // reset global variables - curr_num = true; + curr_num = numbered; curr_label = string(); // reading a row @@ -431,6 +431,12 @@ void mathed_parse_lines(MathInset * inset, int col) mathed_parse(p->cell(idx), FLAG_AMPERSAND); mathed_parse(p->cell(idx), FLAG_NEWLINE | FLAG_END); + if (outmost) { + MathMatrixInset * m = static_cast(p); + m->numbered(row, curr_num); + m->label(row, curr_label); + } + // Hack! // no newline if (yylval.i != -1) @@ -474,17 +480,27 @@ MathInset * mathed_parse() switch (typ) { case LM_OT_SIMPLE: { + curr_num = latex_mathenv[i].numbered; + curr_label = string(); mathed_parse(p->cell(0), 0); + MathMatrixInset * m = static_cast(p); + m->numbered(0, curr_num); + m->label(0, curr_label); break; } case LM_OT_EQUATION: { + curr_num = latex_mathenv[i].numbered; + curr_label = string(); mathed_parse(p->cell(0), FLAG_END); + MathMatrixInset * m = static_cast(p); + m->numbered(0, curr_num); + m->label(0, curr_label); break; } case LM_OT_EQNARRAY: { - mathed_parse_lines(p, 3); + mathed_parse_lines(p, 3, latex_mathenv[i].numbered, true); break; } @@ -492,7 +508,7 @@ MathInset * mathed_parse() LexGetArg('{'); //int c = atoi(yytext.c_str()); lyxerr << "LM_OT_ALIGNAT: not implemented\n"; - mathed_parse_lines(p, 2); + mathed_parse_lines(p, 2, latex_mathenv[i].numbered, true); lyxerr << "LM_OT_ALIGNAT: par: " << *p << "\n"; break; } @@ -503,10 +519,6 @@ MathInset * mathed_parse() p->SetName(latex_mathenv[i].basename); -/* - curr_num = latex_mathenv[i].numbered; - p->numbered(p->nrows()-1, curr_num); -*/ break; } @@ -649,7 +661,7 @@ void mathed_parse(MathArray & array, unsigned flags) { MathScriptInset * p = lastScriptInset(array); if (p) - p->SetLimits(bool(yylval.l->id)); + p->limits(yylval.l->id ? 1 : -1); break; } @@ -843,7 +855,7 @@ void mathed_parse(MathArray & array, unsigned flags) mm->valign(valign[0]); mm->halign(halign); - mathed_parse_lines(mm, halign.size()); + mathed_parse_lines(mm, halign.size(), latex_mathenv[i].numbered, false); do_insert(array, mm); //lyxerr << "read matrix " << *mm << "\n"; break; diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index edca7279ab..3320fa7cfb 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -108,7 +108,7 @@ struct latexkeys { /// short token; /// - int id; + unsigned int id; }; @@ -116,7 +116,7 @@ struct latexkeys { latexkeys const * in_word_set(string const & str); /// -latexkeys const * lm_get_key_by_id(int id, short tc); +latexkeys const * lm_get_key_by_id(unsigned int id, short tc); MathInset * mathed_parse(std::istream &); diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 046b8ab55f..7be748d1e2 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -32,8 +32,10 @@ void MathScriptInset::Metrics(MathStyles st) MathInset::Metrics(st); size_ = st; width_ = max(xcell(0).width(), xcell(1).width()) + 2; - ascent_ = xcell(0).height() + 9; - descent_ = xcell(1).height(); + if (up()) + ascent_ = max(ascent_, xcell(0).height() + 9); + if (down()) + descent_ = max(descent_, xcell(1).height()); } @@ -140,3 +142,52 @@ bool MathScriptInset::idxLast(int & idx, int & pos) const pos = cell(idx).size(); return true; } + + +bool MathScriptInset::idxFirstUp(int & idx, int & pos) const +{ + if (!up()) + return false; + idx = 0; + pos = 0; + return true; +} + +bool MathScriptInset::idxFirstDown(int & idx, int & pos) const +{ + if (!down()) + return false; + idx = 1; + pos = 0; + return true; +} + +bool MathScriptInset::idxLastUp(int & idx, int & pos) const +{ + if (!up()) + return false; + idx = 0; + pos = cell(idx).size(); + return true; +} + +bool MathScriptInset::idxLastDown(int & idx, int & pos) const +{ + if (!down()) + return false; + idx = 1; + pos = cell(idx).size(); + return true; +} + + +bool MathScriptInset::idxDelete(int idx) +{ + if (idx == 0) { + up(false); + return !down(); + } else { + down(false); + return !up(); + } +} diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 7f155a9fc7..d9713b5cfa 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -39,8 +39,16 @@ public: /// bool idxFirst(int & idx, int & pos) const; /// + bool idxFirstUp(int & idx, int & pos) const; + /// + bool idxFirstDown(int & idx, int & pos) const; + /// bool idxLast(int & idx, int & pos) const; /// + bool idxLastUp(int & idx, int & pos) const; + /// + bool idxLastDown(int & idx, int & pos) const; + /// bool up() const; /// bool down() const; @@ -48,6 +56,12 @@ public: void up(bool); /// void down(bool); + /// + bool isActive() const { return false; } + /// Identifies ScriptInsets + bool isScriptInset() const { return true; } + /// + bool idxDelete(int idx); private: /// bool up_; diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 6ddc32d9d4..375b4b1ed2 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -11,7 +11,7 @@ #include "support/LOstream.h" -MathSpaceInset::MathSpaceInset(int sp, short ot) +MathSpaceInset::MathSpaceInset(int sp, MathInsetTypes ot) : MathInset("", ot), space_(sp) {} diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index 4d20d2707d..fdb10df4d3 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -13,7 +13,7 @@ class MathSpaceInset : public MathInset { public: /// - MathSpaceInset(int sp, short ot = LM_OT_SPACE); + MathSpaceInset(int sp, MathInsetTypes ot = LM_OT_SPACE); /// MathInset * Clone() const; /// diff --git a/src/mathed/support.C b/src/mathed/support.C index e7a60dbe94..dfef26cfba 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -364,9 +364,11 @@ int mathed_string_width(short type, int size, string const & s) LyXFont mathed_get_font(short type, int size) { LyXFont f = WhichFont(type, size); +#ifndef NO_LATEX if (type == LM_TC_TEX) { f.setLatex(LyXFont::ON); } +#endif return f; } diff --git a/src/paragraph.C b/src/paragraph.C index e1572fc8d2..c1ca96b893 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -1436,24 +1436,21 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, else main_body = beginningOfMainBody(); + int column = 0; + if (main_body > 0) { os << '['; + ++column; basefont = getFont(bparams, -2); // Get label font } else { basefont = getFont(bparams, -1); // Get layout font } - int column = 0; - if (main_body >= 0 && !pimpl_->size()) { if (style.isCommand()) { os << '{'; ++column; - } else if (params().align() != LYX_ALIGN_LAYOUT) { - os << '{'; - ++column; - return_value = true; } } @@ -1483,12 +1480,6 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, if (style.isCommand()) { os << '{'; ++column; - } else if (params().align() != LYX_ALIGN_LAYOUT && next_) { - // We do not need \par here (Dekel) - // os << "{\\par"; - os << "{"; - ++column; - return_value = true; } if (params().noindent()) { @@ -1502,32 +1493,26 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, case LYX_ALIGN_SPECIAL: break; case LYX_ALIGN_LEFT: - if (moving_arg) - os << "\\protect"; if (getParLanguage(bparams)->babel() != "hebrew") { - os << "\\raggedright "; - column+= 13; + os << "\\begin{flushleft}"; + column+= 17; } else { - os << "\\raggedleft "; - column+= 12; + os << "\\begin{flushright}"; + column+= 18; } break; case LYX_ALIGN_RIGHT: - if (moving_arg) - os << "\\protect"; if (getParLanguage(bparams)->babel() != "hebrew") { - os << "\\raggedleft "; - column+= 12; + os << "\\begin{flushright}"; + column+= 18; } else { - os << "\\raggedright "; - column+= 13; + os << "\\begin{flushleft}"; + column+= 17; } break; case LYX_ALIGN_CENTER: - if (moving_arg) - os << "\\protect"; - os << "\\centering "; - column+= 11; + os << "\\begin{center}"; + column+= 14; break; } } @@ -1578,7 +1563,10 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, // newlines are handled differently here than // the default in SimpleTeXSpecialChars(). if (!style.newline_allowed - || font.latex() == LyXFont::ON) { +#ifndef NO_LATEX + || font.latex() == LyXFont::ON +#endif + ) { os << '\n'; } else { if (open_font) { @@ -1626,6 +1614,36 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, return_value = false; } + switch (params().align()) { + case LYX_ALIGN_NONE: + case LYX_ALIGN_BLOCK: + case LYX_ALIGN_LAYOUT: + case LYX_ALIGN_SPECIAL: + break; + case LYX_ALIGN_LEFT: + if (getParLanguage(bparams)->babel() != "hebrew") { + os << "\\end{flushleft}"; + column+= 15; + } else { + os << "\\end{flushright}"; + column+= 16; + } + break; + case LYX_ALIGN_RIGHT: + if (getParLanguage(bparams)->babel() != "hebrew") { + os << "\\end{flushright}"; + column+= 16; + } else { + os << "\\end{flushleft}"; + column+= 15; + } + break; + case LYX_ALIGN_CENTER: + os << "\\end{center}"; + column+= 12; + break; + } + lyxerr[Debug::LATEX] << "SimpleTeXOnePar...done " << this << endl; return return_value; } @@ -2065,3 +2083,4 @@ ParagraphParameters const & Paragraph::params() const { return pimpl_->params; } + diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 8e3a9eee81..2d9891074c 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -207,10 +207,12 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow, && i && owner_->getChar(i - 1) != ' ' && (i < owner_->size() - 1) +#ifndef NO_LATEX // In LaTeX mode, we don't want to // break lines since some commands // do not like this && ! (font.latex() == LyXFont::ON) +#endif // same in FreeSpacing mode && !style.free_spacing // In typewriter mode, we want to avoid @@ -230,13 +232,18 @@ void Paragraph::Pimpl::simpleTeXBlanks(ostream & os, TexRow & texrow, texrow.newline(); texrow.start(owner_, i + 1); column = 0; - } else if (font.latex() == LyXFont::OFF) { + } else +#ifndef NO_LATEX + if (font.latex() == LyXFont::OFF) { +#endif if (style.free_spacing) { os << '~'; } else { os << ' '; } +#ifndef NO_LATEX } +#endif } @@ -307,6 +314,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, default: // And now for the special cases within each mode +#ifndef NO_LATEX // Are we in LaTeX mode? if (font.latex() == LyXFont::ON) { // at present we only have one option @@ -325,6 +333,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, break; } } else { +#endif // Plain mode (i.e. not LaTeX) switch (c) { case '\\': @@ -498,7 +507,9 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, } break; } +#ifndef NO_LATEX } +#endif } } diff --git a/src/support/ChangeLog b/src/support/ChangeLog index f476378185..a4701a298a 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,21 @@ +2001-06-26 The LyX Project + + * filetools.C (DeleteAllFilesInDir): send debug output to + Debug::FILES instewad of Debug::ANY. + + * DebugStream.h: remove gcc 2.8.x hack. + +2001-06-26 The LyX Project + + * lstrings.h: + * lstrings.C (escape): move method to escape non ascii characters + from insets label and ref to here. + +2001-06-25 The LyX Project + + * filetools.C (IsLyXFilename): + (IsSGMLFilename): do case insensitive name matching + 2001-06-24 The LyX Project * lstrings.C (compare_ascii_no_case): version of compare_no_case diff --git a/src/support/DebugStream.h b/src/support/DebugStream.h index fd361cd514..d27eda5e1b 100644 --- a/src/support/DebugStream.h +++ b/src/support/DebugStream.h @@ -18,9 +18,6 @@ #include "LOstream.h" -// I don't really like this, but too please doc++...(Lgb) -using std::ostream; - #ifdef TEST_DEBUGSTREAM #include struct Debug { @@ -78,11 +75,8 @@ struct Debug { debug[Debug::type(Debug::INFO | Debug::CRIT)] << "...info/crit...\n"; */ -class DebugStream : public ostream +class DebugStream : public std::ostream { -// This workaround is needed only for gcc 2.8.1 (and possibly egcs -// 1.0.x), which generates a compiler error when subclassing from -// std::. (JMarc) public: /// Constructor, sets the debug level to t. explicit DebugStream(Debug::type t = Debug::NONE); diff --git a/src/support/filetools.C b/src/support/filetools.C index 9ced099097..f082e2ad9c 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -68,13 +68,13 @@ extern string system_tempdir; bool IsLyXFilename(string const & filename) { - return suffixIs(filename, ".lyx"); + return suffixIs(lowercase(filename), ".lyx"); } bool IsSGMLFilename(string const & filename) { - return suffixIs(filename, ".sgml"); + return suffixIs(lowercase(filename), ".sgml"); } @@ -408,7 +408,8 @@ int DeleteAllFilesInDir (string const & path) continue; string const unlinkpath = AddName (path, temp); - lyxerr.debug() << "Deleting file: " << unlinkpath << endl; + lyxerr[Debug::FILES] << "Deleting file: " << unlinkpath + << endl; bool deleted = true; if (FileInfo(unlinkpath).isDir()) diff --git a/src/support/lstrings.C b/src/support/lstrings.C index 6a6ad42004..f0e6fe2b95 100644 --- a/src/support/lstrings.C +++ b/src/support/lstrings.C @@ -55,13 +55,16 @@ int compare_no_case(string const & s, string const & s2) return 1; } -static -int ascii_tolower(int c) { - if (c >= 'A' && c <= 'Z') - return c - 'A' + 'a'; - return c; + +namespace { + int ascii_tolower(int c) { + if (c >= 'A' && c <= 'Z') + return c - 'A' + 'a'; + return c; + } } + int compare_ascii_no_case(string const & s, string const & s2) { string::const_iterator p = s.begin(); @@ -619,3 +622,24 @@ string const rsplit(string const & a, string & piece, char delim) } return tmp; } + + +// This function escapes 8-bit characters and other problematic +// characters that cause problems in latex labels. +string const escape(string const & lab) +{ + char hexdigit[16] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + string enc; + for (string::size_type i = 0; i < lab.length(); ++i) { + unsigned char c= lab[i]; + if (c >= 128 || c == '=' || c == '%') { + enc += '='; + enc += hexdigit[c>>4]; + enc += hexdigit[c & 15]; + } else { + enc += c; + } + } + return enc; +} diff --git a/src/support/lstrings.h b/src/support/lstrings.h index a3a20b1db8..e79d1f158c 100644 --- a/src/support/lstrings.h +++ b/src/support/lstrings.h @@ -237,4 +237,7 @@ string const split(string const & a, char delim); /// Same as split but uses the last delim. string const rsplit(string const & a, string & piece, char delim); +/// Escapes non ASCII chars +string const escape(string const & lab); + #endif diff --git a/src/support/syscall.C b/src/support/syscall.C index b43fcc6995..60afc42935 100644 --- a/src/support/syscall.C +++ b/src/support/syscall.C @@ -209,8 +209,11 @@ int Systemcalls::startscript(Starttype how, string const & what, retval = 0; if (how == SystemDontWait) { - (os::shell() == os::UNIX) ? command += " &" - : command = "start /min/n " + command; + if (os::shell() == os::UNIX) { + command += " &"; + } else { + command = "start /min/n " + command; + } } return startscript(); diff --git a/src/tabular.C b/src/tabular.C index 6c7ef5c22f..e7e5b03461 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -93,6 +93,7 @@ LyXTabular::columnstruct::columnstruct() LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg) { owner_ = inset; + cur_cell = -1; Init(rows_arg, columns_arg); } @@ -100,6 +101,7 @@ LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg) LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt) { owner_ = inset; + cur_cell = -1; Init(lt.rows_, lt.columns_, <); #if 0 #ifdef WITH_WARNINGS @@ -113,6 +115,7 @@ LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt) LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex) { owner_ = inset; + cur_cell = -1; Read(buf, lex); } @@ -129,7 +132,7 @@ LyXTabular & LyXTabular::operator=(LyXTabular const & lt) // So then it is ok to throw an exception, or for now // call abort() lyx::Assert(rows_ == lt.rows_ && columns_ == lt.columns_); - + cur_cell = -1; cell_info = lt.cell_info; row_info = lt.row_info; column_info = lt.column_info; @@ -2520,6 +2523,7 @@ int LyXTabular::Ascii(Buffer const * buf, ostream & os) const InsetText * LyXTabular::GetCellInset(int cell) const { + cur_cell = cell; return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset; } diff --git a/src/tabular.h b/src/tabular.h index c53fbbf999..558f3e777c 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -371,6 +371,8 @@ public: void Validate(LaTeXFeatures &) const; /// std::vector const getLabelList() const; + /// + mutable int cur_cell; private: /// struct cellstruct { diff --git a/src/texrow.C b/src/texrow.C index eaca7cdf3a..61f0a7b0ac 100644 --- a/src/texrow.C +++ b/src/texrow.C @@ -112,14 +112,14 @@ void TexRow::increasePos(int id, int pos) const if (id == (*kit).id() && pos < (*kit).pos()) { (*kit).pos((*kit).pos() + 1); - lyxerr.debug() + lyxerr[Debug::INFO] << "TeXRow::increasePos: ideally this " "should never happen..." << endl; } // When verified to work this clause should be deleted. if (id == (*kit).id() && pos == (*kit).pos()) { - lyxerr.debug() + lyxerr[Debug::INFO] << "TexRow::increasePos: this should happen " "maximum one time for each run of " "increasePos!" << endl; diff --git a/src/text.C b/src/text.C index 3b9a19e085..55c8669e27 100644 --- a/src/text.C +++ b/src/text.C @@ -922,12 +922,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const last_separator = i - 1; x = width; // this means break } else { -#if 0 - last_separator = i; - x += width; -#else x += singleWidth(bview, par, i, c); -#endif } } else { if (IsLineSeparatorChar(c)) @@ -1494,6 +1489,9 @@ void LyXText::appendParagraph(BufferView * bview, Row * row) const not_ready = false; // Set the dimensions of the row +#ifdef WITH_WARNINGS +#warning Something is rotten here! (Jug) +#endif tmprow->fill(fill(bview, tmprow, workWidth(bview))); setHeightOfRow(bview, tmprow); @@ -2129,72 +2127,88 @@ void LyXText::cursorTab(BufferView * bview) const void LyXText::cursorLeftOneWord(BufferView * bview) const { - // treat HFills, floats and Insets as words LyXCursor tmpcursor = cursor; - while (tmpcursor.pos() - && (tmpcursor.par()->isSeparator(tmpcursor.pos() - 1) - || tmpcursor.par()->isKomma(tmpcursor.pos() - 1)) - && !(tmpcursor.par()->isHfill(tmpcursor.pos() - 1) - || tmpcursor.par()->isInset(tmpcursor.pos() - 1))) - tmpcursor.pos(tmpcursor.pos() - 1); - - if (tmpcursor.pos() - && (tmpcursor.par()->isInset(tmpcursor.pos() - 1) - || tmpcursor.par()->isHfill(tmpcursor.pos() - 1))) { - tmpcursor.pos(tmpcursor.pos() - 1); - } else if (!tmpcursor.pos()) { - if (tmpcursor.par()->previous()){ - tmpcursor.par(tmpcursor.par()->previous()); - tmpcursor.pos(tmpcursor.par()->size()); - } - } else { // Here, tmpcursor != 0 - while (tmpcursor.pos() > 0 && - tmpcursor.par()->isWord(tmpcursor.pos()-1) ) - tmpcursor.pos(tmpcursor.pos() - 1); - } + cursorLeftOneWord(tmpcursor); setCursor(bview, tmpcursor.par(), tmpcursor.pos()); } +void LyXText::cursorLeftOneWord(LyXCursor & cur) const +{ + // treat HFills, floats and Insets as words + cur = cursor; + while (cur.pos() + && (cur.par()->isSeparator(cur.pos() - 1) + || cur.par()->isKomma(cur.pos() - 1)) + && !(cur.par()->isHfill(cur.pos() - 1) + || cur.par()->isInset(cur.pos() - 1))) + cur.pos(cur.pos() - 1); + + if (cur.pos() + && (cur.par()->isInset(cur.pos() - 1) + || cur.par()->isHfill(cur.pos() - 1))) { + cur.pos(cur.pos() - 1); + } else if (!cur.pos()) { + if (cur.par()->previous()){ + cur.par(cur.par()->previous()); + cur.pos(cur.par()->size()); + } + } else { // Here, cur != 0 + while (cur.pos() > 0 && + cur.par()->isWord(cur.pos()-1) ) + cur.pos(cur.pos() - 1); + } +} + /* -------> Select current word. This depends on behaviour of CursorLeftOneWord(), so it is patched as well. */ -void LyXText::selectWord(BufferView * bview) +void LyXText::getWord(LyXCursor & from, LyXCursor & to, word_location loc) const { - // Move cursor to the beginning, when not already there. - if (cursor.pos() - && !cursor.par()->isSeparator(cursor.pos() - 1) - && !cursor.par()->isKomma(cursor.pos() - 1)) - cursorLeftOneWord(bview); + // first put the cursor where we wana start to select the word + from = cursor; + switch(loc) { + case WHOLE_WORD: + // Move cursor to the beginning, when not already there. + if (from.pos() && !from.par()->isSeparator(from.pos() - 1) + && !from.par()->isKomma(from.pos() - 1)) + cursorLeftOneWord(from); + break; + case NEXT_WORD: + lyxerr << "LyXText::getWord: NEXT_WORD not implemented yet\n"; + break; + case PARTIAL_WORD: + break; + } + to = from; + while (to.pos() < to.par()->size() + && !to.par()->isSeparator(to.pos()) + && !to.par()->isKomma(to.pos()) + && !to.par()->isHfill(to.pos()) ) + { + to.pos(to.pos() + 1); + } +} - // set the sel cursor -#if 0 - sel_cursor = cursor; -#else + +void LyXText::selectWord(BufferView * bview) +{ + LyXCursor from; + LyXCursor to; + getWord(from, to, WHOLE_WORD); + if (cursor != from) + setCursor(bview, from.par(), from.pos()); selection.cursor = cursor; -#endif - - while (cursor.pos() < cursor.par()->size() - && !cursor.par()->isSeparator(cursor.pos()) - && !cursor.par()->isKomma(cursor.pos()) ) - cursor.pos(cursor.pos() + 1); - setCursor(bview, cursor.par(), cursor.pos() ); - - // finally set the selection + setCursor(bview, to.par(), to.pos() ); setSelection(bview); } - /* -------> Select the word currently under the cursor when: 1: no selection is currently set, 2: the cursor is not at the borders of the word. */ bool LyXText::selectWordWhenUnderCursor(BufferView * bview) { -#if 0 - if (!selection && -#else - if (!selection.set() && -#endif + if (!selection.set() && cursor.pos() > 0 && cursor.pos() < cursor.par()->size() && !cursor.par()->isSeparator(cursor.pos()) && !cursor.par()->isKomma(cursor.pos()) @@ -2226,8 +2240,11 @@ string const LyXText::selectNextWord(BufferView * bview, // Now, skip until we have real text (will jump paragraphs) while ((cursor.par()->size() > cursor.pos() && (!cursor.par()->isLetter(cursor.pos()) +#ifndef NO_LATEX || cursor.par()->getFont(bview->buffer()->params, cursor.pos()) - .latex() == LyXFont::ON)) + .latex() == LyXFont::ON +#endif + )) || (cursor.par()->size() == cursor.pos() && cursor.par()->next())){ if (cursor.pos() == cursor.par()->size()) { @@ -2244,11 +2261,7 @@ string const LyXText::selectNextWord(BufferView * bview, } // Start the selection from here -#if 0 - sel_cursor = cursor; -#else selection.cursor = cursor; -#endif std::ostringstream latex; @@ -2265,15 +2278,6 @@ string const LyXText::selectNextWord(BufferView * bview, // Finally, we copy the word to a string and return it string str; -#if 0 - if (sel_cursor.pos() < cursor.pos()) { - Paragraph::size_type i; - for (i = sel_cursor.pos(); i < cursor.pos(); ++i) { - if (cursor.par()->getChar(i) != Paragraph::META_INSET) - str += cursor.par()->getChar(i); - } - } -#else if (selection.cursor.pos() < cursor.pos()) { Paragraph::size_type i; for (i = selection.cursor.pos(); i < cursor.pos(); ++i) { @@ -2281,7 +2285,6 @@ string const LyXText::selectNextWord(BufferView * bview, str += cursor.par()->getChar(i); } } -#endif return str; } @@ -2289,19 +2292,11 @@ string const LyXText::selectNextWord(BufferView * bview, // This one is also only for the spellchecker void LyXText::selectSelectedWord(BufferView * bview) { -#if 0 - // move cursor to the beginning - setCursor(bview, sel_cursor.par(), sel_cursor.pos()); - - // set the sel cursor - sel_cursor = cursor; -#else // move cursor to the beginning setCursor(bview, selection.cursor.par(), selection.cursor.pos()); // set the sel cursor selection.cursor = cursor; -#endif std::ostringstream latex; // now find the end of the word @@ -2329,18 +2324,10 @@ void LyXText::deleteWordForward(BufferView * bview) else { LyXCursor tmpcursor = cursor; tmpcursor.row(0); // ?? -#if 0 - selection = true; // to avoid deletion -#else selection.set(true); // to avoid deletion -#endif cursorRightOneWord(bview); setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); -#if 0 - sel_cursor = cursor; -#else selection.cursor = cursor; -#endif cursor = tmpcursor; setSelection(bview); @@ -2358,18 +2345,10 @@ void LyXText::deleteWordBackward(BufferView * bview) else { LyXCursor tmpcursor = cursor; tmpcursor.row(0); // ?? -#if 0 - selection = true; // to avoid deletion -#else selection.set(true); // to avoid deletion -#endif cursorLeftOneWord(bview); setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); -#if 0 - sel_cursor = cursor; -#else selection.cursor = cursor; -#endif cursor = tmpcursor; setSelection(bview); cutSelection(bview); @@ -2388,26 +2367,14 @@ void LyXText::deleteLineForward(BufferView * bview) // We can't store the row over a regular setCursor // so we set it to 0 and reset it afterwards. tmpcursor.row(0); // ?? -#if 0 - selection = true; // to avoid deletion -#else selection.set(true); // to avoid deletion -#endif cursorEnd(bview); setCursor(bview, tmpcursor, tmpcursor.par(), tmpcursor.pos()); -#if 0 - sel_cursor = cursor; -#else selection.cursor = cursor; -#endif cursor = tmpcursor; setSelection(bview); // What is this test for ??? (JMarc) -#if 0 - if (!selection) { -#else - if (!selection.set()) { -#endif + if (!selection.set()) { deleteWordForward(bview); } else { cutSelection(bview); @@ -2423,20 +2390,25 @@ void LyXText::deleteLineForward(BufferView * bview) // Paragraph, but it will have to change for 1.1 anyway. At least // it does not access outside of the allocated array as the older // version did. (JMarc) -void LyXText::changeWordCase(BufferView * bview, LyXText::TextCase action) +void LyXText::changeCase(BufferView * bview, LyXText::TextCase action) { - Paragraph * tmppar = cursor.par(); + LyXCursor from; + LyXCursor to; - setUndo(bview->buffer(),Undo::FINISH, - tmppar->previous(), tmppar->next()); + if (selection.set()) { + from = selection.cursor; + to = cursor; + } else { + getWord(from, to, PARTIAL_WORD); + setCursor(bview, to.par(), to.pos()+1); + } - Paragraph::size_type tmppos = cursor.pos(); + setUndo(bview->buffer(), Undo::FINISH, + from.par()->previous(), to.par()->next()); - while (tmppos < tmppar->size()) { - unsigned char c = tmppar->getChar(tmppos); - if (IsKommaChar(c) || IsLineSeparatorChar(c)) - break; - if (c != Paragraph::META_INSET) { + while(from != to) { + unsigned char c = from.par()->getChar(from.pos()); + if (!IsInsetChar(c) && !IsHfillChar(c)) { switch (action) { case text_lowercase: c = tolower(c); @@ -2450,13 +2422,19 @@ void LyXText::changeWordCase(BufferView * bview, LyXText::TextCase action) break; } } - - //tmppar->text[tmppos] = c; - tmppar->setChar(tmppos, c); - ++tmppos; + from.par()->setChar(from.pos(), c); + checkParagraph(bview, from.par(), from.pos()); + from.pos(from.pos() + 1); + if (from.pos() >= from.par()->size()) { + from.par(from.par()->next()); + from.pos(0); + } + } + if (to.row() != from.row()) { + refresh_y = from.y() - from.row()->baseline(); + refresh_row = from.row(); + status = LyXText::NEED_MORE_REFRESH; } - checkParagraph(bview, tmppar, tmppos); - cursorRightOneWord(bview); } @@ -3520,7 +3498,7 @@ int LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, float last_tmpx = tmpx; if (main_body > 0 && - (main_body-1 > last || + (main_body - 1 > last || !row->par()->isLineSeparator(main_body - 1))) main_body = 0; @@ -3551,7 +3529,7 @@ int LyXText::getColumnNearX(BufferView * bview, Row * row, int & x, ++vc; } - if (1 || (tmpx + last_tmpx) / 2 > x) { + if ((tmpx + last_tmpx) / 2 > x) { tmpx = last_tmpx; left_side = true; } diff --git a/src/text2.C b/src/text2.C index c0ae0663ed..4a451e4089 100644 --- a/src/text2.C +++ b/src/text2.C @@ -80,17 +80,10 @@ void LyXText::init() status = LyXText::UNCHANGED; // set cursor at the very top position -#if 0 - selection = true; /* these setting is necessary - because of the delete-empty- - paragraph mechanism in - SetCursor */ -#else selection.set(true); /* these setting is necessary because of the delete-empty- paragraph mechanism in SetCursor */ -#endif if (bv_owner) { Paragraph * par = ownerParagraph(); current_font = getFont(bv_owner->buffer(), par, 0); @@ -102,15 +95,9 @@ void LyXText::init() } else current_font = LyXFont(LyXFont::ALL_SANE); -#if 0 - sel_cursor = cursor; - selection = false; - mark_set = false; -#else selection.cursor = cursor; selection.set(false); selection.mark(false); -#endif // no rebreak necessary need_break_row = 0; @@ -151,11 +138,7 @@ void LyXText::init(BufferView * bview) par = par->next(); } setCursorIntern(bview, firstrow->par(), 0); -#if 0 - sel_cursor = cursor; -#else selection.cursor = cursor; -#endif #if 0 printf("TP = %x\n",inset_owner->owner()); // Dump all rowinformation: @@ -545,32 +528,6 @@ Paragraph * LyXText::setLayout(BufferView * bview, // set layout over selection and make a total rebreak of those paragraphs void LyXText::setLayout(BufferView * bview, LyXTextClass::size_type layout) { -#if 0 - LyXCursor tmpcursor = cursor; /* store the current cursor */ - - // if there is no selection just set the layout - // of the current paragraph */ - if (!selection) { - sel_start_cursor = cursor; // dummy selection - sel_end_cursor = cursor; - } - Paragraph * - endpar = SetLayout(bview, cursor, sel_start_cursor, - sel_end_cursor, layout); - RedoParagraphs(bview, sel_start_cursor, endpar); - - // we have to reset the selection, because the - // geometry could have changed - SetCursor(bview, sel_start_cursor.par(), - sel_start_cursor.pos(), false); - sel_cursor = cursor; - SetCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos(), - false); - UpdateCounters(bview, cursor.row()); - ClearSelection(bview); - SetSelection(bview); - SetCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); -#else LyXCursor tmpcursor = cursor; /* store the current cursor */ // if there is no selection just set the layout @@ -594,94 +551,9 @@ void LyXText::setLayout(BufferView * bview, LyXTextClass::size_type layout) clearSelection(bview); setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true); -#endif } -#if 0 -// increment depth over selection and -// make a total rebreak of those paragraphs -void LyXText::IncDepth(BufferView * bview) -{ - // If there is no selection, just use the current paragraph - if (!selection) { - sel_start_cursor = cursor; // dummy selection - sel_end_cursor = cursor; - } - - // We end at the next paragraph with depth 0 - Paragraph * endpar = sel_end_cursor.par()->next(); - - Paragraph * undoendpar = endpar; - - if (endpar && endpar->getDepth()) { - while (endpar && endpar->getDepth()) { - endpar = endpar->next(); - undoendpar = endpar; - } - } - else if (endpar) { - endpar = endpar->next(); // because of parindents etc. - } - - SetUndo(bview->buffer(), Undo::EDIT, - sel_start_cursor.par()->previous(), - undoendpar); - - LyXCursor tmpcursor = cursor; // store the current cursor - - // ok we have a selection. This is always between sel_start_cursor - // and sel_end cursor - cursor = sel_start_cursor; - - bool anything_changed = false; - - while (true) { - // NOTE: you can't change the depth of a bibliography entry - if ( - textclasslist.Style(bview->buffer()->params.textclass, - cursor.par()->GetLayout() - ).labeltype != LABEL_BIBLIO) { - Paragraph * prev = cursor.par()->previous(); - - if (prev - && (prev->GetDepth() - cursor.par()->GetDepth() > 0 - || (prev->GetDepth() == cursor.par()->GetDepth() - && textclasslist.Style(bview->buffer()->params.textclass, - prev->GetLayout()).isEnvironment()))) { - cursor.par()->params.depth(cursor.par()->params.depth() + 1); - anything_changed = true; - } - } - if (cursor.par() == sel_end_cursor.par()) - break; - cursor.par(cursor.par()->next()); - } - - // if nothing changed set all depth to 0 - if (!anything_changed) { - cursor = sel_start_cursor; - while (cursor.par() != sel_end_cursor.par()) { - cursor.par()->params.depth(0); - cursor.par(cursor.par()->next()); - } - cursor.par()->params.depth(0); - } - - redoParagraphs(bview, sel_start_cursor, endpar); - - // we have to reset the selection, because the - // geometry could have changed - setCursor(bview, sel_start_cursor.par(), - sel_start_cursor.pos()); - sel_cursor = cursor; - setCursor(bview, sel_end_cursor.par(), sel_end_cursor.pos()); - updateCounters(bview, cursor.row()); - clearSelection(bview); - setSelection(bview); - setCursor(bview, tmpcursor.par(), tmpcursor.pos()); -} -#else // increment depth over selection and // make a total rebreak of those paragraphs void LyXText::incDepth(BufferView * bview) @@ -763,7 +635,6 @@ void LyXText::incDepth(BufferView * bview) setSelection(bview); setCursor(bview, tmpcursor.par(), tmpcursor.pos()); } -#endif // decrement depth over selection and diff --git a/src/trans_mgr.C b/src/trans_mgr.C index 63715a0146..923d84cf95 100644 --- a/src/trans_mgr.C +++ b/src/trans_mgr.C @@ -288,9 +288,11 @@ void TransManager::insertVerbatim(string const & str, LyXText * text) string::size_type const l = str.length(); for (string::size_type i = 0; i < l; ++i) { - if (str[i] == '\"' + if (str[i] == '\"' +#ifndef NO_LATEX && text->getFont(current_view->buffer(),text->cursor.par(), text->cursor.pos()).latex() == LyXFont::OFF +#endif && text->getFont(current_view->buffer(),text->cursor.par(), text->cursor.pos()).language()->lang() != "hebrew") current_view->insertCorrectQuote();