]> git.lyx.org Git - features.git/commitdiff
*duck*
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 18 Jun 2002 15:44:30 +0000 (15:44 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 18 Jun 2002 15:44:30 +0000 (15:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4417 a592a061-630c-0410-9148-cb99ea01b6c8

186 files changed:
src/BufferView.C
src/BufferView.h
src/BufferView2.C
src/BufferView_pimpl.C
src/BufferView_pimpl.h
src/ChangeLog
src/LyXAction.C
src/buffer.C
src/buffer.h
src/commandtags.h
src/frontends/ChangeLog
src/frontends/Dialogs.C
src/frontends/Dialogs.h
src/frontends/LyXKeySym.C [new file with mode: 0644]
src/frontends/LyXKeySym.h [new file with mode: 0644]
src/frontends/LyXKeySymFactory.h [new file with mode: 0644]
src/frontends/LyXScreenFactory.h [new file with mode: 0644]
src/frontends/LyXView.C
src/frontends/LyXView.h
src/frontends/Makefile.am
src/frontends/Toolbar.C
src/frontends/Toolbar.h
src/frontends/WorkArea.C [new file with mode: 0644]
src/frontends/WorkArea.h
src/frontends/WorkAreaFactory.h [new file with mode: 0644]
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlAboutlyx.C
src/frontends/controllers/ControlBibitem.C
src/frontends/controllers/ControlBibtex.C
src/frontends/controllers/ControlCharacter.C
src/frontends/controllers/ControlCharacter.h
src/frontends/controllers/ControlCitation.C
src/frontends/controllers/ControlDialog.tmpl
src/frontends/controllers/ControlERT.C
src/frontends/controllers/ControlError.C
src/frontends/controllers/ControlExternal.C
src/frontends/controllers/ControlFloat.C
src/frontends/controllers/ControlForks.C
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlInclude.C
src/frontends/controllers/ControlIndex.C
src/frontends/controllers/ControlInset.tmpl
src/frontends/controllers/ControlLog.C
src/frontends/controllers/ControlMinipage.C
src/frontends/controllers/ControlParagraph.C
src/frontends/controllers/ControlParagraph.h
src/frontends/controllers/ControlPreamble.C
src/frontends/controllers/ControlPreamble.h
src/frontends/controllers/ControlPrint.C
src/frontends/controllers/ControlPrint.h
src/frontends/controllers/ControlRef.C
src/frontends/controllers/ControlSearch.C
src/frontends/controllers/ControlSendto.C
src/frontends/controllers/ControlSendto.h
src/frontends/controllers/ControlShowFile.C
src/frontends/controllers/ControlSpellchecker.C
src/frontends/controllers/ControlTabularCreate.C
src/frontends/controllers/ControlTexinfo.C
src/frontends/controllers/ControlThesaurus.C
src/frontends/controllers/ControlToc.C
src/frontends/controllers/ControlUrl.C
src/frontends/controllers/ControlVCLog.C
src/frontends/controllers/GUI.h
src/frontends/guiapi.h [new file with mode: 0644]
src/frontends/screen.C
src/frontends/screen.h
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormAboutlyx.h
src/frontends/xforms/FormBaseDeprecated.h
src/frontends/xforms/FormDocument.C
src/frontends/xforms/FormMathsPanel.C
src/frontends/xforms/FormMathsPanel.h
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/FormPreferences.h
src/frontends/xforms/FormRef.C
src/frontends/xforms/FormShowFile.C
src/frontends/xforms/FormTabular.C
src/frontends/xforms/FormTabular.h
src/frontends/xforms/LyXKeySymFactory.C [new file with mode: 0644]
src/frontends/xforms/LyXScreenFactory.C [new file with mode: 0644]
src/frontends/xforms/Makefile.am
src/frontends/xforms/WorkAreaFactory.C [new file with mode: 0644]
src/frontends/xforms/XLyXKeySym.C [new file with mode: 0644]
src/frontends/xforms/XLyXKeySym.h [new file with mode: 0644]
src/frontends/xforms/XPainter.C
src/frontends/xforms/XPainter.h
src/frontends/xforms/XWorkArea.C
src/frontends/xforms/XWorkArea.h
src/frontends/xforms/forms/.cvsignore
src/frontends/xforms/forms/form_maths_delim.fd
src/frontends/xforms/guiapi.C [new file with mode: 0644]
src/frontends/xforms/xscreen.C [new file with mode: 0644]
src/frontends/xforms/xscreen.h [new file with mode: 0644]
src/insets/ChangeLog
src/insets/inset.h
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetcommand.C
src/insets/insetcommand.h
src/insets/inseterror.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetexternal.C
src/insets/insetexternal.h
src/insets/insetfloat.C
src/insets/insetfloat.h
src/insets/insetfloatlist.h
src/insets/insetfoot.C
src/insets/insetfoot.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinclude.C
src/insets/insetinclude.h
src/insets/insetindex.C
src/insets/insetindex.h
src/insets/insetlabel.C
src/insets/insetlabel.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetnote.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetref.C
src/insets/insetref.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/insettoc.C
src/insets/insettoc.h
src/insets/inseturl.C
src/insets/inseturl.h
src/intl.h
src/kbmap.C
src/kbmap.h
src/kbsequence.C
src/kbsequence.h
src/lyx_cb.C
src/lyxfind.C
src/lyxfind.h
src/lyxfunc.C
src/lyxfunc.h
src/lyxtext.h
src/mathed/ChangeLog
src/mathed/Makefile.am
src/mathed/formula.C
src/mathed/formula.h
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/formulamacro.C
src/mathed/formulamacro.h
src/mathed/math_autocorrect.C
src/mathed/math_charinset.C
src/mathed/math_charinset.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_data.C
src/mathed/math_data.h
src/mathed/math_extern.C
src/mathed/math_extern.h
src/mathed/math_factory.C
src/mathed/math_fontinset.C
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_notinset.C
src/mathed/math_numberinset.C [new file with mode: 0644]
src/mathed/math_numberinset.h [new file with mode: 0644]
src/mathed/math_parser.C
src/mathed/math_scriptinset.C
src/mathed/math_stringinset.C
src/mathed/math_stringinset.h
src/mathed/math_support.C
src/mathed/math_support.h
src/mathed/math_symbolinset.C
src/tabular.C
src/tabular.h

index 6e169eb689415697184740fe1db272d1044852f5..78b4b09d25f47b1af4a5862813ff9961e4c74cec 100644 (file)
@@ -41,7 +41,7 @@ Buffer * BufferView::buffer() const
 }
 
 
-LScreen & BufferView::screen() const
+LyXScreen & BufferView::screen() const
 {
        return pimpl_->screen();
 }
index f994f582cd400c178bfb52301108c1218bbee4e6..ef3072a889cc84ecc6e8b130be2e39036b366fb0 100644 (file)
@@ -25,7 +25,7 @@ class LyXView;
 class LyXText;
 class TeXErrors;
 class Buffer;
-class LScreen;
+class LyXScreen;
 class Language;
 class Painter;
 class UpdatableInset;
@@ -54,7 +54,7 @@ public:
        ///
        Painter & painter() const;
        ///
-       LScreen & screen() const;
+       LyXScreen & screen() const;
        ///
        void buffer(Buffer * b);
        ///
index 8022c299b62a55254936b9dff74cd361e7083579..7638b0435eb4b0ab0aa74b11671c86242c66e20a 100644 (file)
@@ -564,7 +564,7 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
                     locking_inset))
                        text->setCursor(this, cursor,
                                        cursor.par(), cursor.pos() - 1);
-               LScreen::Cursor_Shape shape = LScreen::BAR_SHAPE;
+               LyXScreen::Cursor_Shape shape = LyXScreen::BAR_SHAPE;
                LyXText * txt = getLyXText();
                if (locking_inset->isTextInset() &&
                    locking_inset->lyxCode() != Inset::ERT_CODE &&
@@ -573,8 +573,8 @@ void BufferView::showLockedInsetCursor(int x, int y, int asc, int desc)
                     || txt->real_current_font.isVisibleRightToLeft()
                     != buffer()->params.language->RightToLeft()))
                        shape = (txt->real_current_font.isVisibleRightToLeft())
-                               ? LScreen::REVERSED_L_SHAPE
-                               : LScreen::L_SHAPE;
+                               ? LyXScreen::REVERSED_L_SHAPE
+                               : LyXScreen::L_SHAPE;
                y += cursor.iy() + theLockingInset()->insetInInsetY();
                screen().showManualCursor(text, x, y, asc, desc,
                                                  shape);
@@ -594,7 +594,7 @@ bool BufferView::fitLockedInsetCursor(int x, int y, int asc, int desc)
 {
        if (theLockingInset() && available()) {
                y += text->cursor.iy() + theLockingInset()->insetInInsetY();
-               if (screen().fitManualCursor(text, this, x, y, asc, desc)) {
+               if (screen().fitManualCursor(this, text, x, y, asc, desc)) {
                        updateScrollbar();
                        return true;
                }
index 83696e9b15a1078fb8a03404934b6d4fee2057ac..e3804be66d5627ce01a0e20f3de3189e9d587d66 100644 (file)
@@ -15,6 +15,8 @@
 #include "BufferView_pimpl.h"
 #include "frontends/WorkArea.h"
 #include "frontends/screen.h"
+#include "frontends/LyXScreenFactory.h"
+#include "frontends/WorkAreaFactory.h"
 #include "frontends/Dialogs.h"
 #include "frontends/Alert.h"
 #include "frontends/FileDialog.h"
@@ -117,25 +119,6 @@ namespace {
 
 const unsigned int saved_positions_num = 20;
 
-inline
-void waitForX()
-{
-       XSync(fl_get_display(), 0);
-}
-
-
-void SetXtermCursor(Window win)
-{
-       static Cursor cursor;
-       static bool cursor_undefined = true;
-       if (cursor_undefined) {
-               cursor = XCreateFontCursor(fl_get_display(), XC_xterm);
-               XFlush(fl_get_display());
-               cursor_undefined = false;
-       }
-       XDefineCursor(fl_get_display(), win, cursor);
-       XFlush(fl_get_display());
-}
 
 } // anon namespace
 
@@ -145,8 +128,8 @@ BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
        : bv_(b), owner_(o), buffer_(0), cursor_timeout(400),
          using_xterm_cursor(false)
 {
-       workarea_.reset(new WorkArea(xpos, ypos, width, height));
-       screen_.reset(new LScreen(workarea()));
+       workarea_.reset(WorkAreaFactory::create(xpos, ypos, width, height));
+       screen_.reset(LyXScreenFactory::create(workarea()));
  
        // Setup the signals
        workarea().scrollDocView.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
@@ -182,7 +165,7 @@ WorkArea & BufferView::Pimpl::workarea() const
 }
 
  
-LScreen & BufferView::Pimpl::screen() const
+LyXScreen & BufferView::Pimpl::screen() const
 {
        return *screen_.get();
 }
@@ -408,7 +391,7 @@ int BufferView::Pimpl::resizeCurrentBuffer()
 void BufferView::Pimpl::updateScreen()
 {
        // Regenerate the screen.
-       screen().reset();
+       screen().redraw(bv_->text, bv_);
 }
 
 
@@ -435,7 +418,6 @@ void BufferView::Pimpl::scrollDocView(int value)
        screen().draw(bv_->text, bv_, value);
 
        if (!lyxrc.cursor_follows_scrollbar) {
-               waitForX();
                return;
        }
 
@@ -449,8 +431,6 @@ void BufferView::Pimpl::scrollDocView(int value)
                vbt->setCursorFromCoordinates(bv_, 0, first);
        else if (vbt->cursor.y() > last)
                vbt->setCursorFromCoordinates(bv_, 0, last);
-
-       waitForX();
 }
 
 
@@ -470,7 +450,8 @@ int BufferView::Pimpl::scroll(long time)
 }
 
 
-void BufferView::Pimpl::workAreaKeyPress(KeySym key, key_modifier::state state)
+void BufferView::Pimpl::workAreaKeyPress(LyXKeySymPtr key,
+                                        key_modifier::state state)
 {
        bv_->owner()->getLyXFunc()->processKeySym(key, state);
 }
@@ -2545,7 +2526,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                LyXText * lt = bv_->getLyXText();
 
                if (!lt->selection.set()) {
-                       if (owner_->getIntl()->getTrans().backspace()) {
+                       if (owner_->getIntl()->getTransManager().backspace()) {
                                lt->backspace(bv_);
                                lt->selection.cursor = lt->cursor;
                                update(lt,
@@ -2930,7 +2911,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                        owner_->getLyXFunc()->handleKeyFunc(action);
                } else {
                        owner_->getLyXFunc()->handleKeyFunc(action);
-                       owner_->getIntl()->getTrans()
+                       owner_->getIntl()->getTransManager()
                                .TranslateAndInsert(argument[0], bv_->getLyXText());
                        update(bv_->getLyXText(),
                               BufferView::SELECT
@@ -2939,6 +2920,10 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                }
                break;
 
+       case LFUN_MATH:
+               mathDispatch(bv_, argument);
+               break;
+
        case LFUN_MATH_MACRO:
                mathDispatchMathMacro(bv_, argument);
                break;
@@ -3174,7 +3159,8 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
                string::const_iterator cit = argument.begin();
                string::const_iterator end = argument.end();
                for (; cit != end; ++cit) {
-                       owner_->getIntl()->getTrans().TranslateAndInsert(*cit, lt);
+                       owner_->getIntl()->getTransManager().
+                               TranslateAndInsert(*cit, lt);
                }
 
                bv_->update(lt,
index b0a45d146183e3622bd5582ca3256659e27eca55..4ae67509b3bfc55aaf1eb2ea85fc53974c24df96 100644 (file)
@@ -15,6 +15,7 @@
 #include "frontends/Timeout.h"
 #include "frontends/key_state.h"
 #include "frontends/mouse_state.h"
+#include "frontends/LyXKeySym.h"
 #include "box.h"
 #include "insets/insetspecialchar.h"
 #include "support/types.h"
 
 class LyXView;
 class WorkArea;
-class LScreen;
-
-// FIXME: remove
-#include <X11/Xlib.h>
+class LyXScreen;
  
 ///
 struct BufferView::Pimpl : public boost::signals::trackable {
@@ -43,7 +41,7 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        /// return the work area for this bview
        WorkArea & workarea() const;
        /// return the screen for this bview
-       LScreen & screen() const;
+       LyXScreen & screen() const;
        ///
        void buffer(Buffer *);
        ///
@@ -79,7 +77,8 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        /// wheel mouse scroll
        int scroll(long time);
        ///
-       void workAreaKeyPress(KeySym key, key_modifier::state state);
+       void workAreaKeyPress(LyXKeySymPtr key,
+                             key_modifier::state state);
        ///
        void workAreaMotionNotify(int x, int y, mouse_button::state state);
        ///
@@ -172,7 +171,7 @@ private:
        ///
        Buffer * buffer_;
        ///
-       boost::scoped_ptr<LScreen> screen_;
+       boost::scoped_ptr<LyXScreen> screen_;
        ///
        boost::scoped_ptr<WorkArea> workarea_;
        ///
index bc3b5151757e18f446610fd0fba0810412d11e38..772d27f183049804adaf20ea38f65819719f5fb2 100644 (file)
@@ -1,3 +1,39 @@
+2002-06-16    <alstrup@diku.dk>
+
+       * BufferView_pimpl.C (Pimpl): Use WorkAreaFactory.
+       Got rid of FORMS_H_LOCATION include. Now we are
+       GUII.
+
+2002-06-15  LyX Development team  <lyx@rilke>
+
+       * buffer.[Ch] (sgmlOpenTag):
+       (sgmlCloseTag): Added support for avoiding pernicious mixed
+       content. Return number of lines written.
+
+       (makeLinuxDocFile):
+       (makeDocBookFile): Fixed calls to sgml*Tag.
+       Simple white space clean.
+
+       (simpleDocBookOnePar): Simple white space clean.
+
+       * tabular.[Ch] (docBook): Renamed to docbook and got another
+       argument to related with the pernicious mixed content.
+
+       (docbookRow): Fixed calls for docbook inset method.
+
+2002-06-15  Lyx Development team  <larsbj@birdstep.com>
+
+       * lyxfunc.[Ch]: Use LyXKeySym instead of KeySym, 
+       so it's X11 independent.
+
+       * kb*.[Ch]: ditto.
+
+       * BufferView_pimpl.[Ch] (workAreaKeyPress): ditto.
+
+2002-06-15  Lyx Development team  <lyx@electronia>
+
+       * intl.h: Renamed getTrans to getTransManager.
+
 2002-06-14  Angus Leeming  <leeming@lyx.org>
 
        * Makefile.am: nuke forgotten stl_string_fwd.h.
index ae804fb502bc2077ca9cb5a0080867fe28b66291..ca434957ff874e2abfff17603bf0727c7e3044a1 100644 (file)
@@ -280,6 +280,7 @@ void LyXAction::init()
                { LFUN_MARK_OFF, "mark-off", "", ReadOnly },
                { LFUN_MARK_ON, "mark-on", "", ReadOnly },
                { LFUN_SETMARK, "mark-toggle", "", ReadOnly },
+               { LFUN_MATH, "math", "", Noop },
                { LFUN_MATH_DELIM, "math-delim", "", Noop },
                { LFUN_MATH_DISPLAY, "math-display", "", Noop },
                { LFUN_GREEK, "math-greek", N_("Math Greek"), Noop },
index 95912feaeab49a280436490b8ae52e43d46ff85a..ef5cf085388181c8591a7349cb85c86120a25b4c 100644 (file)
@@ -1713,7 +1713,7 @@ bool Buffer::readFile(LyXLex & lex, Paragraph * par)
                                } else if (file_format < 220) {
                                        Alert::alert(_("ERROR!"),
                                                     _("Old LyX file format found. "
-                                                      "User LyX 1.2.x to read this!"));
+                                                      "Use LyX 1.2.x to read this!"));
                                        return false;
                                }
                        }
@@ -2749,21 +2749,35 @@ bool Buffer::isSGML() const
 }
 
 
-void Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type,
+int Buffer::sgmlOpenTag(ostream & os, Paragraph::depth_type depth, bool mixcont,
                         string const & latexname) const
 {
-       if (!latexname.empty() && latexname != "!-- --")
-               //os << "<!-- " << depth << " -->" << "<" << latexname << ">";
-               os << "<" << latexname << ">";
+       if (!latexname.empty() && latexname != "!-- --") {
+               if (!mixcont)
+                       os << string(" ",depth);
+               os << "<" << latexname << ">";
+       }
+
+       if (!mixcont)
+               os << endl;
+
+       return mixcont?0:1;
 }
 
 
-void Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type,
+int Buffer::sgmlCloseTag(ostream & os, Paragraph::depth_type depth, bool mixcont,
                          string const & latexname) const
 {
-       if (!latexname.empty() && latexname != "!-- --")
-               //os << "<!-- " << depth << " -->" << "</" << latexname << ">\n";
+       if (!latexname.empty() && latexname != "!-- --") {
+               if (!mixcont)
+                       os << endl << string(" ",depth);
                os << "</" << latexname << ">";
+       }
+
+       if (!mixcont)
+               os << endl;
+
+       return mixcont?0:1;
 }
 
 
@@ -2803,12 +2817,12 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                ofs << ">\n\n";
 
                if (params.options.empty())
-                       sgmlOpenTag(ofs, 0, top_element);
+                       sgmlOpenTag(ofs, 0, false, top_element);
                else {
                        string top = top_element;
                        top += " ";
                        top += params.options;
-                       sgmlOpenTag(ofs, 0, top);
+                       sgmlOpenTag(ofs, 0, false, top);
                }
        }
 
@@ -2830,7 +2844,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                        Inset::Code lyx_code = inset->lyxCode();
                        if (lyx_code == Inset::TOC_CODE) {
                                string const temp = "toc";
-                               sgmlOpenTag(ofs, depth, temp);
+                               sgmlOpenTag(ofs, depth, false, temp);
 
                                par = par->next();
                                continue;
@@ -2839,7 +2853,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
 
                // environment tag closing
                for (; depth > par->params().depth(); --depth) {
-                       sgmlCloseTag(ofs, depth, environment_stack[depth]);
+                       sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
                        environment_stack[depth].erase();
                }
 
@@ -2848,14 +2862,14 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                case LATEX_PARAGRAPH:
                        if (depth == par->params().depth()
                           && !environment_stack[depth].empty()) {
-                               sgmlCloseTag(ofs, depth, environment_stack[depth]);
+                               sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
                                environment_stack[depth].erase();
                                if (depth)
                                        --depth;
                                else
                                        ofs << "</p>";
                        }
-                       sgmlOpenTag(ofs, depth, style.latexname());
+                       sgmlOpenTag(ofs, depth, false, style.latexname());
                        break;
 
                case LATEX_COMMAND:
@@ -2865,21 +2879,19 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                                            " LatexType Command.\n"));
 
                        if (!environment_stack[depth].empty()) {
-                               sgmlCloseTag(ofs, depth,
-                                            environment_stack[depth]);
+                               sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
                                ofs << "</p>";
                        }
 
                        environment_stack[depth].erase();
-                       sgmlOpenTag(ofs, depth, style.latexname());
+                       sgmlOpenTag(ofs, depth, false, style.latexname());
                        break;
 
                case LATEX_ENVIRONMENT:
                case LATEX_ITEM_ENVIRONMENT:
                        if (depth == par->params().depth()
                            && environment_stack[depth] != style.latexname()) {
-                               sgmlCloseTag(ofs, depth,
-                                            environment_stack[depth]);
+                               sgmlCloseTag(ofs, depth, false, environment_stack[depth]);
                                environment_stack[depth].erase();
                        }
                        if (depth < par->params().depth()) {
@@ -2888,9 +2900,9 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                        }
                        if (environment_stack[depth] != style.latexname()) {
                                if (depth == 0) {
-                                       sgmlOpenTag(ofs, depth, "p");
+                                       sgmlOpenTag(ofs, depth, false, "p");
                                }
-                               sgmlOpenTag(ofs, depth, style.latexname());
+                               sgmlOpenTag(ofs, depth, false, style.latexname());
 
                                if (environment_stack.size() == depth + 1)
                                        environment_stack.push_back("!-- --");
@@ -2907,10 +2919,10 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                        else
                                item_name = "item";
 
-                       sgmlOpenTag(ofs, depth + 1, item_name);
+                       sgmlOpenTag(ofs, depth + 1, false, item_name);
                        break;
                default:
-                       sgmlOpenTag(ofs, depth, style.latexname());
+                       sgmlOpenTag(ofs, depth, false, style.latexname());
                        break;
                }
 
@@ -2929,18 +2941,18 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
                                ofs << "]]>";
                        break;
                default:
-                       sgmlCloseTag(ofs, depth, style.latexname());
+                       sgmlCloseTag(ofs, depth, false, style.latexname());
                        break;
                }
        }
 
        // Close open tags
        for (int i=depth; i >= 0; --i)
-               sgmlCloseTag(ofs, depth, environment_stack[i]);
+               sgmlCloseTag(ofs, depth, false, environment_stack[i]);
 
        if (!body_only) {
                ofs << "\n\n";
-               sgmlCloseTag(ofs, 0, top_element);
+               sgmlCloseTag(ofs, 0, false, top_element);
        }
 
        ofs.close();
@@ -3266,7 +3278,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                top += " ";
                top += params.options;
        }
-       sgmlOpenTag(ofs, 0, top);
+       sgmlOpenTag(ofs, 0, false, top);
 
        ofs << "<!-- DocBook file was created by " << lyx_docversion
            << "\n  See http://www.lyx.org/ for more information -->\n";
@@ -3296,14 +3308,11 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                for (; depth > par->params().depth(); --depth) {
                        if (environment_inner[depth] != "!-- --") {
                                item_name = "listitem";
-                               sgmlCloseTag(ofs, command_depth + depth,
-                                            item_name);
+                               sgmlCloseTag(ofs, command_depth + depth, false, item_name);
                                if (environment_inner[depth] == "varlistentry")
-                                       sgmlCloseTag(ofs, depth+command_depth,
-                                                    environment_inner[depth]);
+                                       sgmlCloseTag(ofs, depth+command_depth, false, environment_inner[depth]);
                        }
-                       sgmlCloseTag(ofs, depth + command_depth,
-                                    environment_stack[depth]);
+                       sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]);
                        environment_stack[depth].erase();
                        environment_inner[depth].erase();
                }
@@ -3313,16 +3322,12 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                   && !environment_stack[depth].empty()) {
                        if (environment_inner[depth] != "!-- --") {
                                item_name= "listitem";
-                               sgmlCloseTag(ofs, command_depth+depth,
-                                            item_name);
+                               sgmlCloseTag(ofs, command_depth+depth, false, item_name);
                                if (environment_inner[depth] == "varlistentry")
-                                       sgmlCloseTag(ofs,
-                                                    depth + command_depth,
-                                                    environment_inner[depth]);
+                                       sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]);
                        }
 
-                       sgmlCloseTag(ofs, depth + command_depth,
-                                    environment_stack[depth]);
+                       sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]);
 
                        environment_stack[depth].erase();
                        environment_inner[depth].erase();
@@ -3331,8 +3336,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                // Write opening SGML tags.
                switch (style.latextype) {
                case LATEX_PARAGRAPH:
-                       sgmlOpenTag(ofs, depth + command_depth,
-                                   style.latexname());
+                       sgmlOpenTag(ofs, depth + command_depth, false, style.latexname());
                        break;
 
                case LATEX_COMMAND:
@@ -3352,14 +3356,14 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                                if (cmd_depth < command_base) {
                                        for (Paragraph::depth_type j = command_depth;
                                             j >= command_base; --j) {
-                                               sgmlCloseTag(ofs, j, command_stack[j]);
+                                               sgmlCloseTag(ofs, j, false, command_stack[j]);
                                                ofs << endl;
                                        }
                                        command_depth = command_base = cmd_depth;
                                } else if (cmd_depth <= command_depth) {
                                        for (int j = command_depth;
                                             j >= int(cmd_depth); --j) {
-                                               sgmlCloseTag(ofs, j, command_stack[j]);
+                                               sgmlCloseTag(ofs, j, false, command_stack[j]);
                                                ofs << endl;
                                        }
                                        command_depth = cmd_depth;
@@ -3388,12 +3392,10 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                                }
                        }
 
-                       sgmlOpenTag(ofs, depth + command_depth, command_name);
-                       if (c_params.empty())
-                               item_name = "title";
-                       else
-                               item_name = c_params;
-                       sgmlOpenTag(ofs, depth + 1 + command_depth, item_name);
+                       sgmlOpenTag(ofs, depth + command_depth, false, command_name);
+
+                       item_name = c_params.empty()?"title":c_params;
+                       sgmlOpenTag(ofs, depth + 1 + command_depth, false, item_name);
                        break;
 
                case LATEX_ENVIRONMENT:
@@ -3410,18 +3412,13 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                                }
                                environment_stack[depth] = style.latexname();
                                environment_inner[depth] = "!-- --";
-                               sgmlOpenTag(ofs, depth + command_depth,
-                                           environment_stack[depth]);
+                               sgmlOpenTag(ofs, depth + command_depth, false, environment_stack[depth]);
                        } else {
                                if (environment_inner[depth] != "!-- --") {
                                        item_name= "listitem";
-                                       sgmlCloseTag(ofs,
-                                                    command_depth + depth,
-                                                    item_name);
+                                       sgmlCloseTag(ofs, command_depth + depth, false, item_name);
                                        if (environment_inner[depth] == "varlistentry")
-                                               sgmlCloseTag(ofs,
-                                                            depth + command_depth,
-                                                            environment_inner[depth]);
+                                               sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]);
                                }
                        }
 
@@ -3430,35 +3427,21 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                                        if (style.latexparam() == "CDATA")
                                                ofs << "<![CDATA[";
                                        else
-                                               sgmlOpenTag(ofs, depth + command_depth,
-                                                           style.latexparam());
+                                               sgmlOpenTag(ofs, depth + command_depth, false, style.latexparam());
                                }
                                break;
                        }
 
                        desc_on = (style.labeltype == LABEL_MANUAL);
 
-                       if (desc_on)
-                               environment_inner[depth]= "varlistentry";
-                       else
-                               environment_inner[depth]= "listitem";
-
-                       sgmlOpenTag(ofs, depth + 1 + command_depth,
-                                   environment_inner[depth]);
+                       environment_inner[depth] = desc_on?"varlistentry": "listitem";
+                       sgmlOpenTag(ofs, depth + 1 + command_depth, false, environment_inner[depth]);
 
-                       if (desc_on) {
-                               item_name= "term";
-                               sgmlOpenTag(ofs, depth + 1 + command_depth,
-                                           item_name);
-                       } else {
-                               item_name= "para";
-                               sgmlOpenTag(ofs, depth + 1 + command_depth,
-                                           item_name);
-                       }
+                       item_name = desc_on? "term": "para";
+                       sgmlOpenTag(ofs, depth + 1 + command_depth, false, item_name);
                        break;
                default:
-                       sgmlOpenTag(ofs, depth + command_depth,
-                                   style.latexname());
+                       sgmlOpenTag(ofs, depth + command_depth, false, style.latexname());
                        break;
                }
 
@@ -3469,31 +3452,27 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                // write closing SGML tags
                switch (style.latextype) {
                case LATEX_COMMAND:
-                       if (c_params.empty())
-                               end_tag = "title";
-                       else
-                               end_tag = c_params;
-                       sgmlCloseTag(ofs, depth + command_depth, end_tag);
+                       end_tag = c_params.empty()?"title":c_params;
+                       sgmlCloseTag(ofs, depth + command_depth, false, end_tag);
                        break;
                case LATEX_ENVIRONMENT:
                        if (!style.latexparam().empty()) {
                                if (style.latexparam() == "CDATA")
                                        ofs << "]]>";
                                else
-                                       sgmlCloseTag(ofs, depth + command_depth,
-                                                    style.latexparam());
+                                       sgmlCloseTag(ofs, depth + command_depth, false, style.latexparam());
                        }
                        break;
                case LATEX_ITEM_ENVIRONMENT:
                        if (desc_on == 1) break;
                        end_tag= "para";
-                       sgmlCloseTag(ofs, depth + 1 + command_depth, end_tag);
+                       sgmlCloseTag(ofs, depth + 1 + command_depth, false, end_tag);
                        break;
                case LATEX_PARAGRAPH:
-                       sgmlCloseTag(ofs, depth + command_depth, style.latexname());
+                       sgmlCloseTag(ofs, depth + command_depth, false, style.latexname());
                        break;
                default:
-                       sgmlCloseTag(ofs, depth + command_depth, style.latexname());
+                       sgmlCloseTag(ofs, depth + command_depth, false, style.latexname());
                        break;
                }
        }
@@ -3503,26 +3482,23 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
                if (!environment_stack[depth].empty()) {
                        if (environment_inner[depth] != "!-- --") {
                                item_name = "listitem";
-                               sgmlCloseTag(ofs, command_depth + depth,
-                                            item_name);
+                               sgmlCloseTag(ofs, command_depth + depth, false, item_name);
                               if (environment_inner[depth] == "varlistentry")
-                                      sgmlCloseTag(ofs, depth + command_depth,
-                                                   environment_inner[depth]);
+                                      sgmlCloseTag(ofs, depth + command_depth, false, environment_inner[depth]);
                        }
 
-                       sgmlCloseTag(ofs, depth + command_depth,
-                                    environment_stack[depth]);
+                       sgmlCloseTag(ofs, depth + command_depth, false, environment_stack[depth]);
                }
        }
 
        for (int j = command_depth; j >= 0 ; --j)
                if (!command_stack[j].empty()) {
-                       sgmlCloseTag(ofs, j, command_stack[j]);
+                       sgmlCloseTag(ofs, j, false, command_stack[j]);
                        ofs << endl;
                }
 
        ofs << "\n\n";
-       sgmlCloseTag(ofs, 0, top_element);
+       sgmlCloseTag(ofs, 0, false, top_element);
 
        ofs.close();
        // How to check for successful close
@@ -3538,8 +3514,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
 {
        bool emph_flag = false;
 
-       LyXLayout const & style =
-               textclasslist[params.textclass][par->layout()];
+       LyXLayout const & style = textclasslist[params.textclass][par->layout()];
 
        LyXFont font_old = style.labeltype == LABEL_MANUAL ? style.labelfont : style.font;
 
@@ -3577,7 +3552,7 @@ void Buffer::simpleDocBookOnePar(ostream & os,
                        if ( i || desc_on != 3) {
                                if(style.latexparam() == "CDATA")
                                        os << "]]>";
-                               inset->docbook(this, os);
+                               inset->docbook(this, os, false);
                                if(style.latexparam() == "CDATA")
                                        os << "<![CDATA[";
                        }
index ee644a0bd73f08560cde215545f0737d2d734d27..d46db48035cf00ac64b241f75f931f6f2907a4b2 100644 (file)
@@ -180,10 +180,10 @@ public:
        void makeDocBookFile(string const & filename,
                             bool nice, bool only_body = false);
        /// Open SGML/XML tag.
-       void sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth,
+       int sgmlOpenTag(std::ostream & os, Paragraph::depth_type depth, bool mixcont,
                string const & latexname) const;
        /// Closes SGML/XML tag.
-       void sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth,
+       int sgmlCloseTag(std::ostream & os, Paragraph::depth_type depth, bool mixcont,
                string const & latexname) const;
        ///
        void sgmlError(Paragraph * par, int pos, string const & message) const;
index af4dadb0203b2a32257f6a16e28794820c9b58e2..249e6bd1052d4f9301e1c471dd93dda35cb672fa 100644 (file)
@@ -131,6 +131,7 @@ enum kb_action {
        LFUN_INSERT_MATH,
        LFUN_INSERT_MATRIX,
        LFUN_GREEK,  // 110
+       LFUN_MATH,                      // Andre' 2002-06-14
        LFUN_MATH_LIMITS,
        LFUN_GREEK_TOGGLE,
        LFUN_MATH_DELIM,                // Alejandro 180696
index 0e58b620b0e721a963ca1d56a1e79ee33d919014..16b423d190edfe8977e316e11f4a2c46771f540d 100644 (file)
@@ -1,11 +1,47 @@
+2002-06-16  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * add a nother layer of inderection for calling gui specific
+       methods.
+       * guiapi.h: new file
+
+2002-06-16    <alstrup@diku.dk>
+
+       * WorkArea.C: New file for GUII.
+
+       * WorkAreaFactory.h: New file for GUII.
+
+       * WorkArea.h: GUII stuff.
+
+2002-06-15  Lyx Development team  <larsbj@birdstep.com>
+
+       * LyXKeySymFactory.h: Added GUII factory for LyXKeySyms.
+
+       * LyXKeySym.[Ch]: Made the LyXKeySym class GUII.
+
+       * LyXKeySym.[Ch]: new LyXKeySym class for representing a
+       keypress. For now, X11 dependent.
+
+       * Makefile.am: Added LyXKeySym.
+
+2002-06-14  Lyx Development team  <lyx@electronia>
+
+       * LyXScreenFactory.h: New factory for creating the screen
+       object in the super GUII way.
+
+       * screen.h: Made LyXScreen an abstract base class for the
+       screen object.
+
+       * LyXView.h: Moved last_textclass_ member to Toolbar.C where it
+       belongs.
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * Painter.h:
        * Painter.C: s/PainterBase/Painter, remove dead code
+
 2002-06-12  Angus Leeming  <leeming@lyx.org>
 
-       * lyx_gui.h: remove trailing semi-colon after the brace closing 
+       * lyx_gui.h: remove trailing semi-colon after the brace closing
        the namespace.
 
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
        * LyXView.h: cleanup
 
        * LyXView.C: move init() here from xforms/
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * screen.h:
        * screen.C: change topCursorVisible() prototype
+
 2002-06-12  Angus Leeming  <leeming@lyx.org>
 
-       * font_metrics.h: remove trailing semi-colon after the brace closing 
+       * font_metrics.h: remove trailing semi-colon after the brace closing
        the namespace.
 
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
        * GUIRunTime.h: remove in favour of ...
 
        * Makefile.am:
-       * lyx_gui.h: ... namespace for GUI start up 
-       * LyXView.h: remove init(),show(),setPosition() 
+       * lyx_gui.h: ... namespace for GUI start up
+
+       * LyXView.h: remove init(),show(),setPosition()
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * Menubar.C:
        * Timeout.h:
        * Toolbar.C:
        * LyXView.h:
-       * LyXView.C: some cleanup, prefer scoped_ptr 
+       * LyXView.C: some cleanup, prefer scoped_ptr
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * screen.C:
        * Painter.C: use workHeight()
 
        * WorkArea.h: remove confusing duplicate unused code
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * screen.h:
        * screen.C: rename, add reset()
+
 2002-06-11  John Levon  <moz@compsoc.man.ac.uk>
 
        * font_metrics.h: move X-specific stuff out of namespace
+
 2002-06-07  Angus Leeming  <leeming@lyx.org>
 
        Fixes needed to compile with Compaq cxx 6.5.
 2002-05-31  John Levon  <moz@compsoc.man.ac.uk>
 
        * Alert.h: better variable name
+
 2002-05-29  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * switch from SigC signals to boost::signals
index 85d7611b11de7ba1ac61b02cd727256eb5d16e6d..01a67137ea1dfd2efd3ed13f92cd55509a26043b 100644 (file)
 #endif
 
 #include "Dialogs.h"
+
 #include "support/LAssert.h"
 
+#include "guiapi.h"
+
 // Signal enabling all visible dialogs to be redrawn if so desired.
 // E.g., when the GUI colours have been remapped.
 boost::signal0<void> Dialogs::redrawGUI;
 
+extern LyXView * dialogs_lyxview;
+
 
 // toggle tooltips on/off in all dialogs.
 boost::signal0<void> Dialogs::toggleTooltips;
 
-void Dialogs::add(DialogBase * ptr)
+void Dialogs::showAboutlyx()
+{
+       gui_ShowAboutlyx(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showBibitem(InsetCommand * ic)
+{
+       gui_ShowBibitem(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showBibtex(InsetCommand * ic)
+{
+       gui_ShowBibtex(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showCharacter()
+{
+       gui_ShowCharacter(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::setUserFreeFont()
+{
+       gui_SetUserFreeFont(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showCitation(InsetCommand * ic)
+{
+       gui_ShowCitation(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createCitation(string const & s)
+{
+       gui_CreateCitation(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showDocument()
+{
+       gui_ShowDocument(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showError(InsetError * ie)
+{
+       gui_ShowError(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showERT(InsetERT * ie)
+{
+       gui_ShowERT(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::updateERT(InsetERT * ie)
+{
+       gui_UpdateERT(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showExternal(InsetExternal * ie)
+{
+       gui_ShowExternal(ie, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showFile(string const & f)
+{
+       gui_ShowFile(f, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showFloat(InsetFloat * ifl)
+{
+       gui_ShowFloat(ifl, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showForks()
+{
+       gui_ShowForks(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showGraphics(InsetGraphics * ig)
+{
+       gui_ShowGraphics(ig, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showInclude(InsetInclude * ii)
+{
+       gui_ShowInclude(ii, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showIndex(InsetCommand * ic)
+{
+       gui_ShowIndex(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createIndex(string const & s)
+{
+       gui_CreateIndex(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showInfo(InsetInfo * /*ii*/)
+{
+#if 0
+       gui_ShowInfo(ii, *dialogs_lyxview, *this);
+#endif
+}
+
+
+void Dialogs::showLogFile()
+{
+       gui_ShowLogFile(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showMathPanel()
+{
+       gui_ShowMathPanel(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showMinipage(InsetMinipage * im)
+{
+       gui_ShowMinipage(im, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::updateMinipage(InsetMinipage * im)
+{
+       gui_UpdateMinipage(im, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showParagraph()
+{
+       gui_ShowParagraph(*dialogs_lyxview, *this);
+}
+
+void Dialogs::updateParagraph()
+{
+#if 0
+       gui_UpdateParagraph(*dialogs_lyxview, *this);
+#endif
+}
+
+
+void Dialogs::showPreamble()
+{
+       gui_ShowPreamble(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showPreferences()
+{
+       gui_ShowPreferences(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showPrint()
+{
+       gui_ShowPrint(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showRef(InsetCommand * ic)
 {
-       lyx::Assert(ptr);
-       dialogs_.push_back(db_ptr(ptr));
+       gui_ShowRef(ic, *dialogs_lyxview, *this);
 }
+
+
+void Dialogs::createRef(string const & s)
+{
+       gui_CreateRef(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSearch()
+{
+       gui_ShowSearch(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSendto()
+{
+       gui_ShowSendto(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSpellchecker()
+{
+       gui_ShowSpellchecker(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showSpellcheckerPreferences()
+{
+       gui_ShowSpellcheckerPreferences(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTabular(InsetTabular * it)
+{
+       gui_ShowTabular(it, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::updateTabular(InsetTabular * it)
+{
+       gui_UpdateTabular(it, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTabularCreate()
+{
+       gui_ShowTabularCreate(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showThesaurus(string const & s)
+{
+       gui_ShowThesaurus(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTexinfo()
+{
+       gui_ShowTexinfo(*dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showTOC(InsetCommand * ic)
+{
+       gui_ShowTOC(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createTOC(string const & s)
+{
+       gui_CreateTOC(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showUrl(InsetCommand * ic)
+{
+       gui_ShowUrl(ic, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::createUrl(string const & s)
+{
+       gui_CreateUrl(s, *dialogs_lyxview, *this);
+}
+
+
+void Dialogs::showVCLogFile()
+{
+       gui_ShowVCLogFile(*dialogs_lyxview, *this);
+}
+
+
+//void Dialogs::add(DialogBase * ptr)
+//{
+//     lyx::Assert(ptr);
+//     dialogs_.push_back(db_ptr(ptr));
+//}
index d9eb211d5fd824d9b549055985247084047ad7d0..fd32e5ea90c2616c5d08eb1d19c5eed1eefc051e 100644 (file)
@@ -24,8 +24,6 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/signals/signal0.hpp>
 #include <boost/signals/signal1.hpp>
-#include <boost/function.hpp>
-
 #include <vector>
 
 #ifdef __GNUG__
@@ -95,101 +93,101 @@ public:
           Put into some sort of alphabetical order */
        //@{
        ///
-       boost::function<void> showAboutlyx;
+       void showAboutlyx();
        /// show the key and label of a bibliography entry
-       boost::function<void, InsetCommand *> showBibitem;
+       void showBibitem(InsetCommand * ic);
        /// show the bibtex dialog
-       boost::function<void, InsetCommand *> showBibtex;
+       void showBibtex(InsetCommand * ic);
        ///
-       boost::function<void> showCharacter;
+       void showCharacter();
        /// connected to the character dialog also
-       boost::function<void> setUserFreeFont;
+       void setUserFreeFont();
        ///
-       boost::function<void, InsetCommand *> showCitation;
+       void showCitation(InsetCommand *);
        ///
-       boost::function<void, string const &> createCitation;
+       void createCitation(string const &);
        ///
-       boost::function<void> showDocument;
+       void showDocument();
        ///
-       boost::function<void, InsetError *> showError;
+       void showError(InsetError *);
        /// show the external inset dialog
-       boost::function<void, InsetExternal *> showExternal;
+       void showExternal(InsetExternal *);
        /// show the contents of a file.
-       boost::function<void, string const &> showFile;
+       void showFile(string const &);
        /// show all forked child processes
-       boost::function<void> showForks;
+       void showForks();
        ///
-       boost::function<void, InsetGraphics *> showGraphics;
+       void showGraphics(InsetGraphics *);
        /// show the details of a LyX file include inset
-       boost::function<void, InsetInclude *> showInclude;
+       void showInclude(InsetInclude *);
        ///
-       boost::function<void, InsetCommand *> showIndex;
+       void showIndex(InsetCommand *);
        ///
-       boost::function<void, string const &> createIndex;
+       void createIndex(string const &);
        ///
-       boost::function<void, InsetInfo *> showInfo;
+       void showInfo(InsetInfo *);
        /// show the LaTeX log or build file
-       boost::function<void> showLogFile;
+       void showLogFile();
        /// display the top-level maths panel
-       boost::function<void> showMathPanel;
+       void showMathPanel();
        ///
-       boost::function<void, InsetMinipage *> showMinipage;
+       void showMinipage(InsetMinipage *);
        ///
-       boost::function<void, InsetMinipage *> updateMinipage;
+       void updateMinipage(InsetMinipage *);
        ///
-       boost::function<void, InsetERT *> showERT;
+       void showERT(InsetERT *);
        ///
-       boost::function<void, InsetERT *> updateERT;
+       void updateERT(InsetERT *);
        ///
-       boost::function<void, InsetFloat *> showFloat;
+       void showFloat(InsetFloat *);
        ///
-       boost::function<void> showParagraph;
+       void showParagraph();
        ///
-       boost::signal0<void> updateParagraph;
+       void updateParagraph();
        ///
-       boost::function<void> showPreamble;
+       void showPreamble();
        ///
-       boost::function<void> showPreferences;
+       void showPreferences();
        ///
-       boost::function<void> showPrint;
+       void showPrint();
        ///
-       boost::function<void, InsetCommand *> showRef;
+       void showRef(InsetCommand *);
        ///
-       boost::function<void, string const &> createRef;
+       void createRef(string const &);
        ///
-       boost::function<void> showSearch;
+       void showSearch();
        ///
-       boost::function<void> showSendto;
+       void showSendto();
        /// bring up the spellchecker
-       boost::function<void> showSpellchecker;
+       void showSpellchecker();
        /// bring up the spellchecker tab in preferences
-       boost::function<void> showSpellcheckerPreferences;
+       void showSpellcheckerPreferences();
        ///
-       boost::function<void, InsetTabular *> showTabular;
+       void showTabular(InsetTabular *);
        ///
-       boost::function<void, InsetTabular *> updateTabular;
+       void updateTabular(InsetTabular *);
        ///
-       boost::function<void> showTabularCreate;
+       void showTabularCreate();
        /// show the TexInfo
-       boost::function<void> showTexinfo;
+       void showTexinfo();
        /// show the thesaurus dialog
-       boost::function<void, string const &> showThesaurus;
+       void showThesaurus(string const &);
        ///
-       boost::function<void, InsetCommand *> showTOC;
+       void showTOC(InsetCommand *);
        ///
-       boost::function<void, string const &> createTOC;
+       void createTOC(string const &);
        ///
-       boost::function<void, InsetCommand *> showUrl;
+       void showUrl(InsetCommand *);
        ///
-       boost::function<void, string const &> createUrl;
+       void createUrl(string const &);
        /// show the version control log
-       boost::function<void> showVCLogFile;
+       void showVCLogFile();
        //@}
 private:
        /// Add a dialog to the vector of dialogs.
-       void add(DialogBase *);
+       //void add(DialogBase *);
        /// the dialogs being managed
-       std::vector<db_ptr> dialogs_;
+       //std::vector<db_ptr> dialogs_;
 };
 
 #endif
diff --git a/src/frontends/LyXKeySym.C b/src/frontends/LyXKeySym.C
new file mode 100644 (file)
index 0000000..4e24684
--- /dev/null
@@ -0,0 +1,15 @@
+/**
+ * \file LyXKeySym.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "LyXKeySym.h"
diff --git a/src/frontends/LyXKeySym.h b/src/frontends/LyXKeySym.h
new file mode 100644 (file)
index 0000000..c003e5a
--- /dev/null
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+/**
+ * \file LyXKeySym.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#ifndef LYXKEYSYM_H
+#define LYXKEYSYM_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include <boost/shared_ptr.hpp>
+
+/**
+ * This is a base class for representing a keypress.
+ * Each frontend has to implement this to provide
+ * the functionality that LyX needs in regards to
+ * key presses.
+ */
+class LyXKeySym {
+public:
+       LyXKeySym() {}
+
+       virtual ~LyXKeySym() {}
+
+       /// Initialize with the name of a key. F. ex. "space" or "a"
+       virtual void init(string const & symbolname) = 0;
+
+       /// Is this a valid key?
+       virtual bool isOK() const = 0;
+
+       /// Is this a modifier key only?
+       virtual bool isModifier() const = 0;
+
+       /// What is the symbolic name of this key? F.ex. "Return" or "c"
+       virtual string getSymbolName() const = 0;
+
+       /**
+        * Return the value of the keysym into the local ISO encoding.
+        * This converts the LyXKeySym to a 8-bit encoded character.
+        * This relies on user to use the right encoding.
+        */
+       virtual char getISOEncoded() const = 0;
+
+       /**
+        * We need to be able to equality compare these for the
+        * sake of the keymap business.
+        */
+       virtual bool operator==(LyXKeySym const & k) const = 0;
+};
+
+typedef boost::shared_ptr<LyXKeySym> LyXKeySymPtr;
+
+#endif
diff --git a/src/frontends/LyXKeySymFactory.h b/src/frontends/LyXKeySymFactory.h
new file mode 100644 (file)
index 0000000..5bff157
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * \file LyXKeySymFactory.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger & Juergen
+ */
+
+#ifndef LYXKEYSYMFACTORY_H
+#define LYXKEYSYMFACTORY_H
+
+class LyXKeySym;
+
+namespace LyXKeySymFactory {
+       /**
+        * Make a LyXKeySym. Used because we want to 
+        * generate a toolkit-specific instance.
+        */
+       LyXKeySym * create();
+}
+
+#endif // LYXKEYSYM_FACTORY_H
diff --git a/src/frontends/LyXScreenFactory.h b/src/frontends/LyXScreenFactory.h
new file mode 100644 (file)
index 0000000..880f2cd
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * \file LyXScreenFactory.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef LYXSCREENFACTORY_H
+#define LYXSCREENFACTORY_H
+class WorkArea;
+class LyXScreen;
+
+namespace LyXScreenFactory {
+       /**
+        * Make a screen renderer. Used because we want to 
+        * generate a toolkit-specific instance.
+        */
+       LyXScreen * create(WorkArea & owner);
+}
+
+#endif // LYXSCREEN_FACTORY_H
index d8c4ee1539caf2adc2ae77c6d6e51f02c1f14e25..7daffc511a99f172bf533ac4613cceb50f66aa91 100644 (file)
@@ -66,8 +66,6 @@ LyXView::~LyXView()
 
 void LyXView::init()
 {
-       // Set the textclass choice
-       invalidateLayoutChoice();
        updateLayoutChoice();
        updateMenubar();
        
@@ -182,12 +180,6 @@ void LyXView::resetAutosaveTimer()
 }
 
 
-void LyXView::invalidateLayoutChoice()
-{
-       last_textclass_ = -1;
-}
-
-
 void LyXView::updateLayoutChoice()
 {
        // don't show any layouts without a buffer
@@ -197,12 +189,8 @@ void LyXView::updateLayoutChoice()
        }
 
        // update the layout display
-       if (last_textclass_ != int(buffer()->params.textclass)) {
-               toolbar_->updateLayoutList(true);
-               last_textclass_ = int(buffer()->params.textclass);
-               current_layout = textclasslist[last_textclass_].defaultLayoutName();
-       } else {
-               toolbar_->updateLayoutList(false);
+       if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
+               current_layout = textclasslist[buffer()->params.textclass].defaultLayoutName();
        }
 
        string const & layout =
index bf8388a3a4d4be908c9ad566ac7baddb44b0288a..fcf4187011b4b41d075610309ab2bff8cc2d9814 100644 (file)
@@ -55,7 +55,11 @@ public:
 
        virtual ~LyXView();
 
-       /// FIXME: what is the requirement for this be to separate from the ctor ?
+       /** 
+        * This is called after the concrete view has been created.
+        * We have to have the toolbar and the other stuff created
+        * before we can populate it with this call.
+        */
        void init();
 
        /// start modal operation
@@ -111,7 +115,7 @@ public:
        void messagePop();
        /// show state (font etc.) in minibuffer
        void showState();
-       
+
        /// updates the title of the window
        void updateWindowTitle();
 
@@ -138,9 +142,6 @@ protected:
        /// called on timeout
        void autoSave();
 
-       /// FIXME: GUII - toolbar property
-       void invalidateLayoutChoice();
-
 private:
        /**
         * setWindowTitle - set title of window
@@ -153,15 +154,6 @@ private:
        boost::scoped_ptr<LyXFunc> lyxfunc_;
        /// dialogs for this view
        boost::scoped_ptr<Dialogs> dialogs_;
-
-       /**
-        * The last textclass layout list in the layout choice selector
-        * This should probably be moved to the toolbar, but for now it's
-        * here. (Asger)
-        *
-        * FIXME: GUII
-        */
-       int last_textclass_;
 };
 
 #endif // LYXVIEW_H
index b586297be19d26b1563badb0eb993c93a99e1d63..0dc1e8e0190fbfbe531abe0481aa1d479ec0535b 100644 (file)
@@ -23,6 +23,12 @@ libfrontends_la_SOURCES = \
        FileDialog.h \
        Liason.C \
        Liason.h \
+       LyXKeySym.C \
+       LyXKeySym.h \
+       LyXKeySymFactory.h \
+       LyXScreenFactory.h \
+       LyXView.C \
+       LyXView.h \
        Menubar.C \
        Menubar.h \
        Painter.C \
@@ -31,11 +37,12 @@ libfrontends_la_SOURCES = \
        Timeout.h \
        Toolbar.C \
        Toolbar.h \
-       LyXView.C \
-       LyXView.h \
+       WorkArea.C \
        WorkArea.h \
+       WorkAreaFactory.h \
        font_loader.h \
        font_metrics.h \
+       guiapi.h \
        key_state.h \
        lyx_gui.h \
        mouse_state.h \
index f564c534df7233d91533fb98bdb38f8f88c5fa52..bfe845a63873522b064553f6de23f6a54d5cddd1 100644 (file)
@@ -23,6 +23,7 @@ extern LyXAction lyxaction;
 
 
 Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
+       : last_textclass_(-1)
 {
        pimpl_ = new Pimpl(o, x, y);
 
@@ -75,9 +76,17 @@ void Toolbar::setLayout(string const & layout)
 }
 
 
-void Toolbar::updateLayoutList(bool force)
+bool Toolbar::updateLayoutList(int textclass)
 {
-       pimpl_->updateLayoutList(force);
+       // update the layout display
+       if (last_textclass_ != textclass) {
+               pimpl_->updateLayoutList(true);
+               last_textclass_ = textclass;
+               return true;
+       } else {
+               pimpl_->updateLayoutList(false);
+               return false;
+       }
 }
 
 
index 3ef7dcb85afcd863bba1a35e917767a57d001617..3558f73121ed500e851f5064e3e18a4b720bab42 100644 (file)
@@ -55,8 +55,11 @@ public:
 
        /// update the layout combox
        void setLayout(string const & layout);
-       /// Populate the layout combox; re-do everything if force is true.
-       void updateLayoutList(bool force);
+       /** 
+        * Populate the layout combox - returns whether we did a full 
+        * update or not
+        */
+       bool updateLayoutList(int textclass);
        /// Drop down the layout list
        void openLayoutList();
        /// Erase the layout list
@@ -69,5 +72,10 @@ private:
        friend struct Toolbar::Pimpl;
        ///
        Pimpl * pimpl_;
+
+       /**
+        * The last textclass layout list in the layout choice selector
+        */
+       int last_textclass_;
 };
 #endif
diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C
new file mode 100644 (file)
index 0000000..70ae7be
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * \file WorkArea.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "WorkArea.h"
+
+
+
+
+
+
+
+  
index a3751bf52ebdc1ff0837da60b0f50b3bac72dd85..091318b0d6a45a3b6a79c3e871e1a3b753df6060 100644 (file)
@@ -1,2 +1,98 @@
-// temporary
-#include "frontends/xforms/XWorkArea.h"
+// -*- C++ -*-
+/**
+ * \file WorkArea.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef WORKAREA_H
+#define WORKAREA_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "frontends/Painter.h"
+#include "frontends/mouse_state.h"
+#include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
+
+#include <boost/signals/signal0.hpp>
+#include <boost/signals/signal1.hpp>
+#include <boost/signals/signal2.hpp>
+#include <boost/signals/signal3.hpp>
+
+#include <utility>
+
+///
+class WorkArea {
+public:
+       ///
+       WorkArea() {}
+       ///
+       virtual ~WorkArea() {}
+       ///
+       virtual Painter & getPainter() = 0;
+       ///
+       virtual int workWidth() const = 0;
+       ///
+       virtual int workHeight() const = 0;
+       ///
+       virtual unsigned int width() const = 0;
+  
+       ///
+       virtual int xpos() const = 0;
+       ///
+       virtual int ypos() const = 0;
+       ///
+       virtual void resize(int xpos, int ypos, int width, int height) = 0;
+       ///
+       virtual void redraw() const = 0;
+       ///
+       virtual void setFocus() const = 0;
+       ///
+       virtual bool hasFocus() const = 0;
+       ///
+       virtual bool visible() const = 0;
+       ///
+       virtual void greyOut() const = 0;
+        ///
+        virtual void setScrollbarParams(int height, int pos, int line_height) = 0;
+       /// a selection exists
+       virtual void haveSelection(bool) const = 0;
+       ///
+       virtual string const getClipboard() const = 0;
+       ///
+       virtual void putClipboard(string const &) const = 0;
+       // Signals
+       ///
+       boost::signal0<void> workAreaExpose;
+       ///
+       boost::signal1<void, int> scrollDocView;
+       ///
+       boost::signal2<void, LyXKeySymPtr, key_modifier::state> workAreaKeyPress;
+       ///
+       boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
+       ///
+       boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
+       ///
+       boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
+       ///
+       boost::signal0<void> workAreaFocus;
+       ///
+       boost::signal0<void> workAreaUnfocus;
+       ///
+       boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
+       ///
+       boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
+       /// emitted when an X client has requested our selection
+       boost::signal0<void> selectionRequested;
+       /// emitted when another X client has stolen our selection
+       boost::signal0<void> selectionLost;
+};
+#endif // WORKAREA_H
diff --git a/src/frontends/WorkAreaFactory.h b/src/frontends/WorkAreaFactory.h
new file mode 100644 (file)
index 0000000..ce276bf
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * \file WorkAreaFactory.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef WORKAREAFACTORY_H
+#define WORKAREAFACTORY_H
+class WorkArea;
+namespace WorkAreaFactory {
+       /**
+        * Make a work area. Used because we want to generate
+        * a toolkit-specific instance.
+        */
+       WorkArea * create(int x, int y, int w, int h);
+}
+
+#endif // WORKAREA_FACTORY_H
index 0f31d13f402e80bcea9e00012158f2e028d605dd..9e3a53cd15b849667604e2b0d61f1f96be046841 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-16  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * changes to simplify function setup, removal of a lot of includes.
+
 2002-06-12  Angus Leeming  <leeming@lyx.org>
 
        * ControlParagraph.[Ch]: forward declare ParagraphParameters.
        * ControlInset.tmpl: add missing header file, ButtonControllerBase.h.
 
 2002-06-11  Edwin Leuven  <leuven@fee.uva.nl>
-       * ControlParagraph.[Ch]: new paragraph controller
-       * GUI.h: add new controller
-       * Makefile.am: ditto
-       
+
+       * ControlParagraph.[Ch]: new paragraph controller
+       * GUI.h: add new controller
+       * Makefile.am: ditto
+
 2002-06-10  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * GUI.h: do not include ButtonController.tmpl
index ddde313cfccac1754325ee18b8e39e9ad053e66d..f7815b97cc0fcfcbc6f23c15350a837f9d79a9fe 100644 (file)
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlAboutlyx.h"
-#include "Dialogs.h"
 #include "frontends/LyXView.h"
 #include "Lsstream.h"
 #include "BufferView.h"
 #include "support/filetools.h" // FileSearch
 #include "version.h"
 
-#include <boost/bind.hpp>
-
 // needed for the browser
 extern string system_lyxdir;
 extern string user_lyxdir;
 
+
 ControlAboutlyx::ControlAboutlyx(LyXView & lv, Dialogs & d)
        : ControlDialogBI(lv, d)
-{
-       d_.showAboutlyx = boost::bind(&ControlAboutlyx::show, this);
-}
+{}
 
 
 stringstream & ControlAboutlyx::getCredits(stringstream & ss) const
@@ -65,21 +59,25 @@ stringstream & ControlAboutlyx::getCredits(stringstream & ss) const
        return ss;
 }
 
+
 string const ControlAboutlyx::getCopyright() const
 {
        return _("LyX is Copyright (C) 1995 by Matthias Ettrich,\n1995-2001 LyX Team");
 }
 
+
 string const ControlAboutlyx::getLicense() const
 {
        return _("This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.");
 }
 
+
 string const ControlAboutlyx::getDisclaimer() const
 {
        return _("LyX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\nSee the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.");
 }
 
+
 string const ControlAboutlyx::getVersion() const
 {
        stringstream ss;
index 04be99188c75de29aaa38bf11d353036d46a5a7d..288bfff455d94eaf1e9a78acf68a478997f6ad1b 100644 (file)
 #endif
 
 #include "ControlBibitem.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
 #include "BufferView.h"
 
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
-
-#include <algorithm>
 
 ControlBibitem::ControlBibitem(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d)
-{
-       d_.showBibitem = boost::bind(&ControlBibitem::showInset, this, _1);
-}
+{}
 
 
 void ControlBibitem::applyParamsToInset()
index 22927cae4e3a5e251df3c38be6b82dd1ba6d8d3a..43e7557cb372ab350440e2a529d879cf97ace00d 100644 (file)
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlBibtex.h"
-#include "Dialogs.h"
-#include "buffer.h"
 #include "BufferView.h"
 #include "lyxrc.h"
 #include "helper_funcs.h"
 
 #include "frontends/LyXView.h"
 
-#include <boost/bind.hpp>
-
-#include <algorithm>
-
 using std::pair;
-using std::make_pair;
+
 
 ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d)
-{
-       d_.showBibtex = boost::bind(&ControlBibtex::showInset, this, _1);
-}
+{}
+
 
 void ControlBibtex::applyParamsToInset()
 {
index f0e2e78901d8a821efe209140897c354f09136c9..a12534fe85591aa656db87231b5469ef2bb5bce1 100644 (file)
@@ -16,7 +16,6 @@
 #include "ViewBase.h"
 #include "ButtonControllerBase.h"
 #include "buffer.h"
-#include "Dialogs.h"
 #include "Liason.h"
 #include "bufferview_funcs.h" // ToggleAndShow
 #include "gettext.h"
 
 #include "frontends/LyXView.h"
 
-#include <boost/bind.hpp>
-
-#include <vector>
-
 using Liason::setMinibuffer;
-using std::vector;
 
 
 ControlCharacter::ControlCharacter(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d),
          font_(0), toggleall_(false)
-{
-       d_.showCharacter = boost::bind(&ControlCharacter::show, this);
-       d_.setUserFreeFont = boost::bind(&ControlCharacter::apply, this);
-}
+{}
 
 
 void ControlCharacter::setParams()
index b8d3938849f7ac7213a2ad09e32c1cc93f52ec41..108025de0a4ea9782b1f460f3ecf16bdea80d24b 100644 (file)
@@ -61,9 +61,9 @@ public:
        ///
        bool getToggleAll() const;
 
-private:
        /// Get changed parameters and Dispatch them to the kernel.
        virtual void apply();
+private:
        /// set the params before show or update.
        virtual void setParams();
 
index 5af344ed4a23fcdfcd745832fee7646249e861a5..d1069ef90e7ffce3595242eba88524f63474e043 100644 (file)
 #endif
 
 #include "ControlCitation.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "buffer.h"
-#include "Dialogs.h"
 
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
-
-#include <algorithm>
-
-using std::pair;
 using std::vector;
+using std::pair;
 
 vector<biblio::CiteStyle> ControlCitation::citeStyles_;
 
+
 ControlCitation::ControlCitation(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d, LFUN_CITATION_INSERT)
-{
-       // These are permanent connections so we won't bother
-       // storing a copy because we won't be disconnecting.
-       d_.showCitation = boost::bind(&ControlCitation::showInset, this, _1);
-       d_.createCitation = boost::bind(&ControlCitation::createInset, this, _1);
-}
+{}
 
 
 void ControlCitation::clearDaughterParams()
index adfa9e424f7d2f1321f813a3ad67818ac66299be..ff4151d581496da6c9440bd3600974d9db4a0769 100644 (file)
@@ -72,4 +72,3 @@ void ControlDialog<Base>::hide()
        disconnect();
        view().hide();
 }
-
index 55a4ac22206899c4274c4f4e4277540eb8507461..1125440686d8d6b8e3e046a4ab3ab51050d3df7a 100644 (file)
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlERT.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "buffer.h"
-#include "BufferView.h"
-
-#include <boost/bind.hpp>
-
-using std::vector;
 
 // sorry this is just a temporary hack we should include vspace.h! (Jug)
 extern const char * stringFromUnit(int);
 
+
 ControlERT::ControlERT(LyXView & lv, Dialogs & d)
        : ControlInset<InsetERT, ERTParams>(lv, d)
-{
-       d_.showERT = boost::bind(&ControlERT::showInset, this, _1);
-
-       // We could have an extra method updateInset that calls
-       // view().update() rather than view().show(), but I don't see why
-       // it is really needed.
-       d_.updateERT = boost::bind(&ControlERT::showInset, this, _1);
-}
+{}
 
 
 void ControlERT::applyParamsToInset()
@@ -65,6 +49,7 @@ ERTParams::ERTParams()
        : status(InsetERT::Collapsed)
 {}
 
+
 ERTParams::ERTParams(InsetERT const & inset)
        : status(inset.status())
 {}
index 412c6e66919c658ff02403a2fc6d7a045fcdd0de..fd3918bc848e492c111b1153ab2208505313a3e6 100644 (file)
 #endif
 
 #include "ControlError.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
 #include "insets/inseterror.h"
 
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
 
 ControlError::ControlError(LyXView & lv, Dialogs & d)
        : ControlInset<InsetError, string>(lv, d)
-{
-       d_.showError = boost::bind(&ControlError::showInset, this, _1);
-}
+{}
 
 
 string const ControlError::getParams(InsetError const & inset)
index 8436ef787e234ad5a52049721438e80f2794b5eb..7a5d3c36f9d75cfc785bf1c10a042757211200e6 100644 (file)
 #pragma implementation
 #endif
 
-#include "BufferView.h"
-#include "ButtonControllerBase.h"
 #include "ControlExternal.h"
-#include "Dialogs.h"
-#include "Liason.h"
-#include "frontends/LyXView.h"
-#include "ViewBase.h"
-#include "buffer.h"
-#include "frontends/Alert.h"
+#include "BufferView.h"
 #include "gettext.h"
 #include "helper_funcs.h"
 #include "lyxrc.h"
 #include "support/filetools.h"
-#include "support/lstrings.h"
-
-#include <boost/scoped_ptr.hpp>
-#include <boost/bind.hpp>
 
-#include <utility>
 #include <vector>
 
-using std::make_pair;
 using std::vector;
 
 ControlExternal::ControlExternal(LyXView & lv, Dialogs & d)
        : ControlInset<InsetExternal, InsetExternal::Params>(lv, d)
-{
-       d_.showExternal = boost::bind(&ControlExternal::showInset, this, _1);
-}
+{}
 
 
 InsetExternal::Params const ControlExternal::getParams(string const &)
index 2e8891a3c9adc74f7c4d47c9b703d2d4d0f88ad9..a04eb8dd48bef49ad53ca2f53a988cccbb448ab0 100644 (file)
 #endif
 
 #include "ControlFloat.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
-#include "BufferView.h"
-
-#include "insets/insetfloat.h"
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
-
-using std::vector;
 
 
 ControlFloat::ControlFloat(LyXView & lv, Dialogs & d)
        : ControlInset<InsetFloat, FloatParams>(lv, d)
-{
-       d_.showFloat = boost::bind(&ControlFloat::showInset, this, _1);
-
-       // We could have an extra method updateInset that calls
-       // view().update() rather than view().show(), but I don't see why
-       // it is really needed.
-       //d_.updateFloat.connect(slot(this, &ControlFloat::showInset));
-}
+{}
 
 
 void ControlFloat::applyParamsToInset()
index 962790f165327864fe58760232ea490b2ac03885..80f65f43f759a0adfba66f16865964b13210f9c5 100644 (file)
 #endif
 
 #include "ControlForks.h"
-#include "ButtonControllerBase.h"
 #include "ViewBase.h"
 
 #include "BufferView.h"
 #include "frontends/LyXView.h"
 #include "lyxfunc.h"
 
-#include "frontends/Dialogs.h"
-
 #include "support/forkedcontr.h"
 #include "support/lstrings.h"
 
@@ -32,9 +29,7 @@ using std::vector;
 
 ControlForks::ControlForks(LyXView & lv, Dialogs & d)
        : ControlDialogBI(lv, d)
-{
-       d_.showForks = boost::bind(&ControlForks::show, this);
-}
+{}
 
 
 vector<pid_t> const ControlForks::getPIDs() const
index c43807c0cdeb452e18944085ad044e3f0fc42186..cb799c2f27517bd66880c1d8e51d37c91ef4b7d2 100644 (file)
@@ -18,8 +18,6 @@
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlGraphics.h"
 
 #include "helper_funcs.h"
 #include "support/filetools.h"
 #include "support/FileInfo.h"
 
-#include <boost/bind.hpp>
-
-#include <fstream>
-
 using std::pair;
 using std::make_pair;
-using std::ifstream;
 using std::vector;
 
 namespace {
@@ -103,9 +96,7 @@ string const xforms_pattern()
 
 ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
        : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
-{
-       d_.showGraphics = boost::bind(&ControlGraphics::showInset, this, _1);
-}
+{}
 
 
 InsetGraphicsParams const ControlGraphics::getParams(string const &)
@@ -209,6 +200,7 @@ size_t const rorigin_size = sizeof(rorigin_lyx_strs) / sizeof(char *);
 
 } // namespace anon
 
+
 vector<RotationOriginPair> getRotationOriginData()
 {
        static vector<RotationOriginPair> data;
@@ -217,8 +209,8 @@ vector<RotationOriginPair> getRotationOriginData()
 
        data.resize(rorigin_size);
        for (lyx::size_type i = 0; i < rorigin_size; ++i) {
-               data[i] = std::make_pair(_(rorigin_gui_strs[i]),
-                                        rorigin_lyx_strs[i]);
+               data[i] = make_pair(_(rorigin_gui_strs[i]),
+                                   rorigin_lyx_strs[i]);
        }
 
        return data;
index 5c01ad3839c96d8bcf702e0baa27368bcb7f2464..bc2f6989205651b510b110f84f6abb9055014a1c 100644 (file)
@@ -9,19 +9,14 @@
  */
 
 #include <config.h>
-#include <utility>
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
 #include "ControlInclude.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "buffer.h"
 #include "Alert.h"
 #include "BufferView.h"
-#include "Dialogs.h"
 #include "lyxfunc.h"
 #include "gettext.h"
 #include "helper_funcs.h"
 
 #include "support/filetools.h"
 
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
+#include <utility>
 
 using std::pair;
-using std::make_pair;
+
 
 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
        : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
-{
-       d_.showInclude = boost::bind(&ControlInclude::showInset, this, _1);
-}
+{}
 
 
 void ControlInclude::applyParamsToInset()
index 6ed48c5b362881597f9c730fdc6fc82143978cfc..a74bea85fda111e55a7ada5e2fc39deec84f9b5c 100644 (file)
 #endif
 
 #include "ControlIndex.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "buffer.h"
-#include "Dialogs.h"
 
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
 
 ControlIndex::ControlIndex(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d, LFUN_INDEX_INSERT)
-{
-       d_.showIndex = boost::bind(&ControlIndex::showInset, this, _1);
-       d_.createIndex = boost::bind(&ControlIndex::createInset, this, _1);
-}
+{}
index 7b36a70529a09f9479f425cf172bf1894d1566b8..fe88747c366ad931b4f019034ecc1abbe42d8010 100644 (file)
 #include "buffer.h"
 #include "debug.h"
 #include "frontends/LyXView.h"
+#include "insets/insetfloat.h"
+#include "insets/insetgraphics.h"
 #include "support/LAssert.h"
+
 #include <boost/bind.hpp>
 
 template <class Inset, class Params>
index 2bc28734324baf78610cadad6b56ee3bc244fb36..bcaa49bb678e9c9d26b406be8f8191205ecc0db8 100644 (file)
 #endif
 
 #include "ControlLog.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "lyxrc.h"
 #include "BufferView.h"
 
 #include "frontends/LyXView.h"
 
-#include <boost/bind.hpp>
 
 ControlLog::ControlLog(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d)
-{
-       d_.showLogFile = boost::bind(&ControlLog::show, this);
-}
+{}
 
 
 void ControlLog::setParams()
index 017abd6e4dfe482dcf160e89301b8212e0330daa..2ebc759a4c34e2400ca98d1fac77d8a33a15c317 100644 (file)
 #endif
 
 #include "ControlMinipage.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "buffer.h"
 #include "BufferView.h"
-#include "helper_funcs.h"
-
-#include <boost/bind.hpp>
-
-using std::vector;
 
 
 ControlMinipage::ControlMinipage(LyXView & lv, Dialogs & d)
        : ControlInset<InsetMinipage, MinipageParams>(lv, d)
-{
-       d_.showMinipage = boost::bind(&ControlMinipage::showInset, this, _1);
-
-       // We could have an extra method updateInset that calls
-       // view().update() rather than view().show(), but I don't see why
-       // it is really needed.
-       d_.updateMinipage = boost::bind(&ControlMinipage::showInset, this, _1);
-}
+{}
 
 
 void ControlMinipage::applyParamsToInset()
index e554cb1e5a2acb95ee0f81dd89d5ab4fd74eafea..0438e044b090e8fd9004b4b5408d24c6860c1866 100644 (file)
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlParagraph.h"
+#include "ViewBase.h"
 #include "ParagraphParameters.h"
-#include "Dialogs.h"
 #include "Liason.h"
 #include "LyXView.h"
 #include "BufferView.h"
 #include "lyxtextclasslist.h"
 #include "support/LAssert.h"
 
-#include <boost/bind.hpp>
-
 using Liason::setMinibuffer;
 
 
 ControlParagraph::ControlParagraph(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d), pp_(0), ininset_(false)
-{
-       d_.showParagraph = boost::bind(&ControlParagraph::show, this);
-}
+{}
 
 
 ControlParagraph::~ControlParagraph()
@@ -83,13 +77,13 @@ void ControlParagraph::apply()
                           pp_->noindent());
 
        // Actually apply these settings
-       lv_.view()->update(text, 
+       lv_.view()->update(text,
                           BufferView::SELECT |
                           BufferView::FITCUR |
                           BufferView::CHANGE);
-       
+
        lv_.buffer()->markDirty();
-       
+
        setMinibuffer(&lv_, _("Paragraph layout set"));
 }
 
@@ -101,13 +95,13 @@ void ControlParagraph::setParams()
 
        /// get paragraph
        Paragraph const * par_ = lv_.view()->getLyXText()->cursor.par();
-       
+
        /// Set the paragraph parameters
-        *pp_ = par_->params();
-       
+       *pp_ = par_->params();
+
        /// this needs to be done separately
        pp_->labelWidthString(par_->getLabelWidthString());
-       
+
        /// alignment
        LyXTextClass const & tclass =
                textclasslist[lv_.view()->buffer()->params.textclass];
@@ -118,5 +112,5 @@ void ControlParagraph::setParams()
        alignpos_ = tclass[par_->layout()].alignpossible;
 
        /// is paragraph in inset
-        ininset_ = par_->inInset();
+       ininset_ = par_->inInset();
 }
index b089a07ec91115b27fc9da6758bf9cb471766ef8..343e0dd28a13b366b9e3657f164a25e82464b6bc 100644 (file)
@@ -54,4 +54,3 @@ private:
 };
 
 #endif // CONTROLPARAGRAPH_H
-
index 4f3485c84ba192ff41a4659f942f32978c5078ba..7f30834f55a9aee1e6ff1c242dcfc9fe929caa2e 100644 (file)
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlPreamble.h"
+#include "ViewBase.h"
 #include "frontends/LyXView.h"
-#include "Dialogs.h"
 #include "buffer.h"
-#include "lyxrc.h"
 #include "Liason.h"
 #include "gettext.h"
 #include "BufferView.h"
 #include "support/LAssert.h"
 
-#include <boost/bind.hpp>
 
 ControlPreamble::ControlPreamble(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d),
          params_(0)
-{
-       d_.showPreamble = boost::bind(&ControlPreamble::show, this);
-}
+{}
 
 
 void ControlPreamble::apply()
@@ -56,15 +50,13 @@ string & ControlPreamble::params() const
 
 void ControlPreamble::setParams()
 {
-       if (params_) delete params_;
+       delete params_;
        params_ = new string(lv_.buffer()->params.preamble);
 }
 
 
 void ControlPreamble::clearParams()
 {
-       if (params_) {
-               delete params_;
-               params_ = 0;
-       }
+       delete params_;
+       params_ = 0;
 }
index 3042abce12cb02d4240fbd156af503d43f5422bf..893bd11a521290a33a10cf04ca83b25073e00281 100644 (file)
@@ -16,6 +16,8 @@
 
 #include "ControlDialog_impl.h"
 
+#include "LString.h"
+
 /** A controller for Preamble dialogs.
  */
 class ControlPreamble : public ControlDialogBD {
index 6c0609734c31308249ecf81bdfdbf6c9b972976e..8e5ba18f4f8a63899a957a24e445255fe959e668 100644 (file)
  */
 
 #include <config.h>
-#include <utility>
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
+#include "ControlPrint.h"
 #include "ViewBase.h"
 #include "ButtonControllerBase.h"
-#include "ControlPrint.h"
 #include "buffer.h"
-#include "Dialogs.h"
 #include "frontends/LyXView.h"
 #include "PrinterParams.h"
 #include "Liason.h"
 #include "BufferView.h"
 #include "support/LAssert.h"
 
-#include <boost/bind.hpp>
-
 using Liason::printBuffer;
 using Liason::getPrinterParams;
-using std::make_pair;
+
 
 ControlPrint::ControlPrint(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d),
          params_(0)
-{
-       d_.showPrint = boost::bind(&ControlPrint::show, this);
-}
+{}
 
 
 void ControlPrint::apply()
index d88362ceb69d7956ddeaea0be6862ad7d58be098..211787f389fe6a940505b6d2e71cda8ef1d00a93 100644 (file)
@@ -21,6 +21,8 @@
 
 #include "ControlDialog_impl.h"
 
+#include "LString.h"
+
 class PrinterParams;
 
 /** A controller for Print dialogs.
index 568fc2c6ba02c7b93346f31c9961f21870b6a51a..98e6cbc7953ddfb269582ca42c1b7333be68dfcc 100644 (file)
 #endif
 
 #include "ControlRef.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
 #include "lyxfunc.h"
 #include "bufferlist.h"
-#include "debug.h"
-
-#include "frontends/LyXView.h"
 
 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
 
-#include <boost/bind.hpp>
-
-#include <algorithm>
-
 using std::vector;
-using std::find;
 
 extern BufferList bufferlist;
 
+
 ControlRef::ControlRef(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d, LFUN_REF_INSERT)
-{
-       d_.showRef = boost::bind(&ControlRef::showInset, this, _1);
-       d_.createRef = boost::bind(&ControlRef::createInset, this, _1);
-}
+{}
 
 
 vector<string> const ControlRef::getLabelList(string const & name) const
index 224930cea91ef2ac5e3795a3804815376f6dc37c..867ef54425a9f521b0c1276b7bd96bcffa9aa1ee 100644 (file)
 #endif
 
 #include "ControlSearch.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
 #include "Liason.h"
 #include "buffer.h"
 #include "lyxfind.h"
-#include "debug.h"
 #include "gettext.h"
 #include "BufferView.h"
 
 
 #include "support/lstrings.h"
 
-#include <boost/bind.hpp>
-
 using Liason::setMinibuffer;
 
+
 ControlSearch::ControlSearch(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d)
-{
-       d_.showSearch = boost::bind(&ControlSearch::show, this);
-
-       // perhaps in the future we'd like a
-       // "search again" button/keybinding
-       // d_.searchAgain.connect(SigC::slot(this, &ControlSearch::FindNext));
-}
+{}
 
 
 void ControlSearch::find(string const & search,
                         bool casesensitive, bool matchword, bool forward) const
 {
-       bool const found = LyXFind(lv_.view(), search,
-                                  forward, false, casesensitive, matchword);
+       bool const found = lyxfind::LyXFind(lv_.view(), search,
+                                           forward, casesensitive,
+                                           matchword);
 
        if (!found)
                setMinibuffer(&lv_, _("String not found!"));
@@ -65,9 +55,10 @@ void ControlSearch::replace(string const & search, string const & replace,
        // move on to the next instance once the present instance has been
        // changed
        bool const once = !all;
-       int const replace_count = LyXReplace(lv_.view(),
-                                            search, replace, true, casesensitive,
-                                            matchword, all, once);
+       int const replace_count =
+               lyxfind::LyXReplace(lv_.view(),
+                                   search, replace, true, casesensitive,
+                                   matchword, all, once);
 
        if (replace_count == 0) {
                setMinibuffer(&lv_, _("String not found!"));
index 8aaa29b8050b0bc0380d34a80290ff6f6f2dcfb0..7eb8376e22b202b0089806bf6ddc7b33df5535da 100644 (file)
 #pragma implementation
 #endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlSendto.h"
-#include "Dialogs.h"
+#include "ViewBase.h"
 #include "frontends/LyXView.h"
 #include "BufferView.h"
 #include "buffer.h"
 #include "support/lstrings.h"
 #include "support/systemcall.h"
 
-#include <boost/bind.hpp>
-
-#include <fstream>
-
 using std::vector;
 
+
 ControlSendto::ControlSendto(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d),
          format_(0),
          command_(lyxrc.custom_export_command)
-{
-       d_.showSendto = boost::bind(&ControlSendto::show, this);
-}
+{}
 
 
 vector<Format const *> const ControlSendto::allFormats() const
index e4189a9b12892f3d80acbadf909ce7222e15e16a..25a4ee08de4a03f8e71f8ee3eeaf2299bab59c4a 100644 (file)
@@ -15,6 +15,8 @@
 #endif
 
 #include "ControlDialog_impl.h"
+#include "LString.h"
+
 #include <vector>
 
 class Format;
index 9d5e0b5ce66f4b4cb537b3632f84846c43e7a328..a412ff48318e0f64c5a771faa81b67b3a8a7aac1 100644 (file)
 #endif
 
 #include "ControlShowFile.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "frontends/LyXView.h"
-#include "BufferView.h"
-#include "gettext.h"
 
 #include "support/filetools.h" // FileSearch
 
-#include <boost/bind.hpp>
-
-#include <fstream>
 
 ControlShowFile::ControlShowFile(LyXView & lv, Dialogs & d)
        : ControlDialogBI(lv, d)
-{
-       d_.showFile = boost::bind(&ControlShowFile::showFile, this, _1);
-}
+{}
 
 
 void ControlShowFile::showFile(string const & file)
index 1d7ebce2abfeec89c15577c8ace61098b7957817..329bb68c862f05549d2d37cf45e071d927010840 100644 (file)
@@ -26,7 +26,6 @@
 #include "language.h"
 
 #include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "Dialogs.h"
 #include "Liason.h"
 
 # include "sp_pspell.h"
 #endif
 
-#include "debug.h"
-
-#include <boost/bind.hpp>
-
 #include <sys/types.h> // needed by <sys/select.h> at least on freebsd
 
 #ifdef HAVE_SYS_SELECT_H
@@ -60,9 +55,7 @@ ControlSpellchecker::ControlSpellchecker(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d),
          rtl_(false), newval_(0.0), oldval_(0), newvalue_(0), count_(0),
          stop_(false), result_(SpellBase::ISP_OK), speller_(0)
-{
-       d_.showSpellchecker = boost::bind(&ControlSpellchecker::show, this);
-}
+{}
 
 
 void ControlSpellchecker::setParams()
index 9eb5254229039b4dd07fb6d53e3fc4d2bb409de6..9db249361b54bab7e376344117ca333af21274d4 100644 (file)
 #include "ViewBase.h"
 #include "ButtonControllerBase.h"
 #include "BufferView.h"
-#include "Dialogs.h"
 #include "lyxfunc.h"
 
 #include "frontends/LyXView.h"
 
 #include "support/lstrings.h"
 
-#include <boost/bind.hpp>
 
 ControlTabularCreate::ControlTabularCreate(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d)
-{
-       d_.showTabularCreate = boost::bind(&ControlTabularCreate::show, this);
-}
+{}
 
 
 ControlTabularCreate::rowsCols & ControlTabularCreate::params()
index ad4981069bb77f31bfe497da6adb76eeddd9530c..7637bbdccf5058f9672eb3109f15cca96e54f72d 100644 (file)
@@ -18,8 +18,6 @@
 #endif
 
 #include "ControlTexinfo.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "Dialogs.h"
 #include "BufferView.h"
 #include "gettext.h"
 #include "support/path.h"
 #include "support/lstrings.h"
 
-#include <boost/bind.hpp>
-
 extern string user_lyxdir; // home of *Files.lst
 
 
 ControlTexinfo::ControlTexinfo(LyXView & lv, Dialogs & d)
        : ControlDialogBI(lv, d)
-{
-       d_.showTexinfo = boost::bind(&ControlTexinfo::show, this);
-}
+{}
 
 
 // build filelists of all availabe bst/cls/sty-files. done through
index 29e11c01b65aedf34f4b8dd1bfd4c3baea5122cd..19e042e6124802bb5233cdb6083fce1a312a5cc0 100644 (file)
 #endif
 
 #include "ControlThesaurus.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
 #include "Liason.h"
 #include "lyxfind.h"
 #include "buffer.h"
-#include "debug.h"
 #include "gettext.h"
 #include "BufferView.h"
 
 #include "frontends/LyXView.h"
 
-#include <boost/bind.hpp>
-
 using Liason::setMinibuffer;
 
+
 ControlThesaurus::ControlThesaurus(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d)
-{
-       d_.showThesaurus = boost::bind(&ControlThesaurus::showEntry, this, _1);
-}
+{}
 
 
 void ControlThesaurus::showEntry(string const & entry)
@@ -49,8 +42,9 @@ void ControlThesaurus::replace(string const & newstr)
         * on a particular charpos in a paragraph that is broken on
         * deletion/change !
         */
-       int const replace_count = LyXReplace(lv_.view(), oldstr_, newstr,
-                                       true, true, true, false, true);
+       int const replace_count =
+               lyxfind::LyXReplace(lv_.view(), oldstr_, newstr,
+                                   true, true, true, false, true);
 
        oldstr_ = newstr;
 
index 5c731c0566f7bc5a58ab1c7590e61d76e679167a..50cf2a5cb30c2aaa8fb1ad67ca9292580eb3bbc6 100644 (file)
 #endif
 
 #include "ControlToc.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "buffer.h"
 #include "Dialogs.h"
 #include "lyxfunc.h"
 #include "gettext.h"
 #include "BufferView.h"
 
-#include "frontends/LyXView.h"
-
 #include "support/lstrings.h" // tostr
 
-#include <boost/bind.hpp>
-
 using std::vector;
 
+
 ControlToc::ControlToc(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d, LFUN_TOC_INSERT)
-{
-       d_.showTOC = boost::bind(&ControlToc::showInset, this, _1);
-       d_.createTOC = boost::bind(&ControlToc::createInset, this, _1);
-}
+{}
 
 
 void ControlToc::Goto(int const & id) const
index 03e2ce7d4836ecd587f75f1492ca37e6519175c7..97438d8606f7e9b116a769b7a9a8cd10cf523d08 100644 (file)
 #endif
 
 #include "ControlUrl.h"
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
-#include "Dialogs.h"
-#include "buffer.h"
 
-#include "frontends/LyXView.h"
-
-#include <boost/bind.hpp>
 
 ControlUrl::ControlUrl(LyXView & lv, Dialogs & d)
        : ControlCommand(lv, d, LFUN_INSERT_URL)
-{
-       d_.showUrl = boost::bind(&ControlUrl::showInset, this, _1);
-       d_.createUrl = boost::bind(&ControlUrl::createInset, this, _1);
-}
+{}
index 5670d19d940cc6875e8025121e3a8ca4de9fa3ab..2b5f13a2542e7ee85b2eafa2e5db28cdb97a8db4 100644 (file)
 
 #include "ControlVCLog.h"
 #include "Lsstream.h"
-#include "ViewBase.h"
 #include "ButtonControllerBase.h"
 #include "buffer.h"
 #include "BufferView.h"
-#include "Dialogs.h"
 #include "lyxrc.h"
 #include "gettext.h"
 
 
 #include "support/lyxlib.h"
 
-#include <boost/bind.hpp>
-
 #include <fstream>
 
 using std::endl;
 
+
 ControlVCLog::ControlVCLog(LyXView & lv, Dialogs & d)
        : ControlDialogBD(lv, d)
-{
-       d_.showVCLogFile = boost::bind(&ControlVCLog::show, this);
-}
+{}
+
 
 string const ControlVCLog::getBufferFileName() const
 {
index c22090ce28372acb7652990d68daf93bc63d11e2..49f62ea290673a673ef653d3a1191585d4150879 100644 (file)
 #define GUI_H
 
 #include "ButtonController.h"
-#include "ButtonPolicies.h"
-#include "ControlAboutlyx.h"
-#include "ControlBibitem.h"
-#include "ControlBibtex.h"
-#include "ControlCharacter.h"
-#include "ControlCitation.h"
-#include "ControlError.h"
-#include "ControlERT.h"
-#include "ControlExternal.h"
-#include "ControlFloat.h"
-#include "ControlForks.h"
-#include "ControlGraphics.h"
-#include "insets/insetgraphicsParams.h"
-#include "ControlInclude.h"
-#include "ControlIndex.h"
-#include "ControlLog.h"
-#include "ControlMinipage.h"
-#include "ControlParagraph.h"
-#include "ControlPreamble.h"
-#include "ControlPrint.h"
-#include "ControlRef.h"
-#include "ControlSearch.h"
-#include "ControlSendto.h"
-#include "ControlShowFile.h"
-#include "ControlSpellchecker.h"
-#include "ControlTabularCreate.h"
-#include "ControlTexinfo.h"
-#include "ControlThesaurus.h"
-#include "ControlToc.h"
-#include "ControlUrl.h"
-#include "ControlVCLog.h"
-
+#include "ViewBase.h"
 
 /** This class instantiates and makes available the GUI-specific
     ButtonController and View.
@@ -57,6 +26,45 @@ public:
        ///
        virtual ViewBase & view() { return view_; }
 
+       friend void gui_ShowAboutlyx(LyXView &, Dialogs &);
+       friend void gui_ShowBibitem(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_ShowBibtex(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_ShowCharacter(LyXView &, Dialogs &);
+       friend void gui_SetUserFreeFont(LyXView &, Dialogs &);
+       friend void gui_ShowCitation(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_CreateCitation(string const &, LyXView &, Dialogs &);
+       friend void gui_ShowDocument(LyXView &, Dialogs &);
+       friend void gui_ShowError(InsetError *, LyXView &, Dialogs &);
+       friend void gui_ShowERT(InsetERT *, LyXView &, Dialogs &);
+       friend void gui_UpdateERT(InsetERT *, LyXView &, Dialogs &);
+       friend void gui_ShowExternal(InsetExternal *, LyXView &, Dialogs &);
+       friend void gui_ShowFloat(InsetFloat *, LyXView &, Dialogs &);
+       friend void gui_ShowForks(LyXView &, Dialogs &);
+       friend void gui_ShowGraphics(InsetGraphics *, LyXView &, Dialogs &);
+       friend void gui_ShowInclude(InsetInclude *, LyXView &, Dialogs &);
+       friend void gui_ShowIndex(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_CreateIndex(string const &, LyXView &, Dialogs &);
+       friend void gui_ShowLogFile(LyXView &, Dialogs &);
+       friend void gui_ShowMathPanel(LyXView &, Dialogs &);
+       friend void gui_ShowMinipage(InsetMinipage *, LyXView &, Dialogs &);
+       friend void gui_UpdateMinipage(InsetMinipage *, LyXView &, Dialogs &);
+       friend void gui_ShowParagraph(LyXView &, Dialogs &);
+       friend void gui_ShowPreamble(LyXView &, Dialogs &);
+       friend void gui_ShowPreferences(LyXView &, Dialogs &);
+       friend void gui_ShowPrint(LyXView &, Dialogs &);
+       friend void gui_ShowRef(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_CreateRef(string const &, LyXView &, Dialogs &);
+       friend void gui_ShowSearch(LyXView &, Dialogs &);
+       friend void gui_ShowSendto(LyXView &, Dialogs &);
+       friend void gui_ShowSpellchecker(LyXView &, Dialogs &);
+       friend void gui_ShowTabularCreate(LyXView &, Dialogs &);
+       friend void gui_ShowTexinfo(LyXView &, Dialogs &);
+       friend void gui_ShowTOC(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_CreateTOC(string const &, LyXView &, Dialogs &);
+       friend void gui_ShowUrl(InsetCommand *, LyXView &, Dialogs &);
+       friend void gui_CreateUrl(string const &, LyXView &, Dialogs &);
+       friend void gui_ShowVCLogFile(LyXView &, Dialogs &);
+
 private:
        ///
        ButtonController<Policy, GUIbc> bc_;
@@ -64,357 +72,4 @@ private:
        GUIview view_;
 };
 
-#if 0
-/** Specialization for About LyX dialog
- */
-template <class GUIview, class GUIbc>
-class GUIAboutlyx :
-       public GUI<ControlAboutlyx, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIAboutlyx(LyXView & lv, Dialogs & d)
-               : GUI<ControlAboutlyx, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Bibitem dialog
- */
-template <class GUIview, class GUIbc>
-class GUIBibitem :
-       public GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIBibitem(LyXView & lv, Dialogs & d)
-               : GUI<ControlBibitem, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Bibtex dialog
- */
-template <class GUIview, class GUIbc>
-class GUIBibtex :
-       public GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIBibtex(LyXView & lv, Dialogs & d)
-               : GUI<ControlBibtex, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Character dialog
- */
-template <class GUIview, class GUIbc>
-class GUICharacter : public GUI<ControlCharacter, GUIview,
-                               OkApplyCancelReadOnlyPolicy, GUIbc>
-{
-public:
-       ///
-       GUICharacter(LyXView & lv, Dialogs & d)
-               : GUI<ControlCharacter, GUIview,
-                     OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Citation dialog
- */
-template <class GUIview, class GUIbc>
-class GUICitation : public GUI<ControlCitation, GUIview,
-                              NoRepeatedApplyReadOnlyPolicy, GUIbc>
-{
-public:
-       ///
-       GUICitation(LyXView & lv, Dialogs & d)
-               : GUI<ControlCitation, GUIview,
-                     NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Error dialog
- */
-template <class GUIview, class GUIbc>
-class GUIError :
-       public GUI<ControlError, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIError(LyXView & lv, Dialogs & d)
-               : GUI<ControlError, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for ERT dialog
- */
-template <class GUIview, class GUIbc>
-class GUIERT :
-       public GUI<ControlERT, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIERT(LyXView & lv, Dialogs & d)
-               : GUI<ControlERT, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for External dialog
- */
-template <class GUIview, class GUIbc>
-class GUIExternal :
-       public GUI<ControlExternal, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIExternal(LyXView & lv, Dialogs & d)
-               : GUI<ControlExternal, GUIview, OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Forks dialog
- */
-template <class GUIview, class GUIbc>
-class GUIForks :
-       public GUI<ControlForks, GUIview, OkApplyCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIForks(LyXView & lv, Dialogs & d)
-               : GUI<ControlForks, GUIview, OkApplyCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Graphics dialog
- */
-template <class GUIview, class GUIbc>
-class GUIGraphics :
-       public GUI<ControlGraphics, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIGraphics(LyXView & lv, Dialogs & d)
-               : GUI<ControlGraphics, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Include dialog
- */
-template <class GUIview, class GUIbc>
-class GUIInclude :
-       public GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIInclude(LyXView & lv, Dialogs & d)
-               : GUI<ControlInclude, GUIview, OkCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Index dialog
- */
-template <class GUIview, class GUIbc>
-class GUIIndex :
-       public GUI<ControlIndex, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIIndex(LyXView & lv, Dialogs & d)
-               : GUI<ControlIndex, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Log dialog
- */
-template <class GUIview, class GUIbc>
-class GUILog :
-       public GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUILog(LyXView & lv, Dialogs & d)
-               : GUI<ControlLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Minipage dialog
- */
-template <class GUIview, class GUIbc>
-class GUIMinipage :
-       public GUI<ControlMinipage, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIMinipage(LyXView & lv, Dialogs & d)
-               : GUI<ControlMinipage, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Float dialog
- */
-template <class GUIview, class GUIbc>
-class GUIFloat :
-       public GUI<ControlFloat, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIFloat(LyXView & lv, Dialogs & d)
-               : GUI<ControlFloat, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Paragraph dialog
- */
-template <class GUIview, class GUIbc>
-class GUIParagraph : public GUI<ControlParagraph, GUIview,
-                               OkApplyCancelReadOnlyPolicy, GUIbc>
-{
-public:
-       ///
-       GUIParagraph(LyXView & lv, Dialogs & d)
-               : GUI<ControlParagraph, GUIview,
-                     OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Preamble dialog
- */
-template <class GUIview, class GUIbc>
-class GUIPreamble :
-       public GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIPreamble(LyXView & lv, Dialogs & d)
-               : GUI<ControlPreamble, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Print dialog
- */
-template <class GUIview, class GUIbc>
-class GUIPrint :
-       public GUI<ControlPrint, GUIview, OkApplyCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIPrint(LyXView & lv, Dialogs & d)
-               : GUI<ControlPrint, GUIview, OkApplyCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Ref dialog
- */
-template <class GUIview, class GUIbc>
-class GUIRef :
-       public GUI<ControlRef, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIRef(LyXView & lv, Dialogs & d)
-               : GUI<ControlRef, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Search dialog
- */
-template <class GUIview, class GUIbc>
-class GUISearch :
-       public GUI<ControlSearch, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUISearch(LyXView & lv, Dialogs & d)
-               : GUI<ControlSearch, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Sendto dialog
- */
-template <class GUIview, class GUIbc>
-class GUISendto :
-       public GUI<ControlSendto, GUIview, OkApplyCancelPolicy, GUIbc> {
-public:
-       ///
-       GUISendto(LyXView & lv, Dialogs & d)
-               : GUI<ControlSendto, GUIview, OkApplyCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for ShowFile dialog
- */
-template <class GUIview, class GUIbc>
-class GUIShowFile :
-       public GUI<ControlShowFile, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIShowFile(LyXView & lv, Dialogs & d)
-               : GUI<ControlShowFile, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Spellchecker dialog
- */
-template <class GUIview, class GUIbc>
-class GUISpellchecker :
-       public GUI<ControlSpellchecker, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUISpellchecker(LyXView & lv, Dialogs & d)
-               : GUI<ControlSpellchecker, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Toc dialog
- */
-template <class GUIview, class GUIbc>
-class GUIToc :
-       public GUI<ControlToc, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIToc(LyXView & lv, Dialogs & d)
-               : GUI<ControlToc, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for TabularCreate dialog
- */
-template <class GUIview, class GUIbc>
-class GUITabularCreate :
-       public GUI<ControlTabularCreate, GUIview,
-                  OkApplyCancelReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUITabularCreate(LyXView & lv, Dialogs & d)
-               : GUI<ControlTabularCreate, GUIview,
-                     OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Texinfo dialog
- */
-template <class GUIview, class GUIbc>
-class GUITexinfo :
-       public GUI<ControlTexinfo, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUITexinfo(LyXView & lv, Dialogs & d)
-               : GUI<ControlTexinfo, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-/** Specialization for Thesaurus dialog
- */
-template <class GUIview, class GUIbc>
-class GUIThesaurus :
-       public GUI<ControlThesaurus, GUIview,
-                  OkApplyCancelReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIThesaurus(LyXView & lv, Dialogs & d)
-               : GUI<ControlThesaurus, GUIview,
-                     OkApplyCancelReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for Url dialog
- */
-template <class GUIview, class GUIbc>
-class GUIUrl :
-       public GUI<ControlUrl, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc> {
-public:
-       ///
-       GUIUrl(LyXView & lv, Dialogs & d)
-           : GUI<ControlUrl, GUIview, NoRepeatedApplyReadOnlyPolicy, GUIbc>(lv, d) {}
-};
-
-
-/** Specialization for VCLog dialog
- */
-template <class GUIview, class GUIbc>
-class GUIVCLog :
-       public GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc> {
-public:
-       ///
-       GUIVCLog(LyXView & lv, Dialogs & d)
-           : GUI<ControlVCLog, GUIview, OkCancelPolicy, GUIbc>(lv, d) {}
-};
-
-#endif
-
 #endif // GUI_H
diff --git a/src/frontends/guiapi.h b/src/frontends/guiapi.h
new file mode 100644 (file)
index 0000000..e7abe92
--- /dev/null
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+
+#include "LString.h"
+
+class LyXView;
+class Dialogs;
+class InsetCommand;
+class InsetError;
+class InsetERT;
+class InsetExternal;
+class InsetFloat;
+class InsetGraphics;
+class InsetInclude;
+class InsetInfo;
+class InsetMinipage;
+class InsetTabular;
+
+extern "C" {
+
+       void gui_ShowAboutlyx(LyXView &, Dialogs &);
+       void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d);
+       void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d);
+       void gui_ShowCharacter(LyXView & lv, Dialogs & d);
+       void gui_SetUserFreeFont(LyXView & lv, Dialogs & d);
+       void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d);
+       void gui_CreateCitation(string const &, LyXView & lv, Dialogs & d);
+       void gui_ShowDocument(LyXView & lv, Dialogs & d);
+       void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d);
+       void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d);
+       void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d);
+       void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d);
+       void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d);
+       void gui_ShowFloat(InsetFloat *, LyXView & lv, Dialogs &);
+       void gui_ShowForks(LyXView & lv, Dialogs & d);
+       void gui_ShowGraphics(InsetGraphics *, LyXView & lv, Dialogs & d);
+       void gui_ShowInclude(InsetInclude *, LyXView & lv, Dialogs & d);
+       void gui_ShowIndex(InsetCommand *, LyXView & lv, Dialogs & d);
+       void gui_CreateIndex(string const &, LyXView & lv, Dialogs & d);
+       void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d);
+       void gui_ShowLogFile(LyXView & lv, Dialogs & d);
+       void gui_ShowMathPanel(LyXView & lv, Dialogs & d);
+       void gui_ShowMinipage(InsetMinipage *, LyXView & lv, Dialogs & d);
+       void gui_UpdateMinipage(InsetMinipage *, LyXView & lv, Dialogs & d);
+       void gui_ShowParagraph(LyXView & lv, Dialogs & d);
+       void gui_UpdateParagraph(LyXView & lv, Dialogs & d);
+       void gui_ShowPreamble(LyXView & lv, Dialogs & d);
+       void gui_ShowPreferences(LyXView & lv, Dialogs & d);
+       void gui_ShowPrint(LyXView & lv, Dialogs & d);
+       void gui_ShowRef(InsetCommand *, LyXView &, Dialogs &);
+       void gui_CreateRef(string const &, LyXView &, Dialogs &);
+       void gui_ShowSearch(LyXView & lv, Dialogs & d);
+       void gui_ShowSendto(LyXView & lv, Dialogs & d);
+       void gui_ShowSpellchecker(LyXView & lv, Dialogs & d);
+       void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d);
+       void gui_ShowTabular(InsetTabular *, LyXView &, Dialogs &);
+       void gui_UpdateTabular(InsetTabular *, LyXView &, Dialogs &);
+       void gui_ShowTabularCreate(LyXView & lv, Dialogs & d);
+       void gui_ShowTexinfo(LyXView & lv, Dialogs & d);
+       void gui_ShowThesaurus(string const &, LyXView &, Dialogs &);
+       void gui_ShowTOC(InsetCommand *, LyXView &, Dialogs &);
+       void gui_CreateTOC(string const &, LyXView &, Dialogs &);
+       void gui_ShowUrl(InsetCommand *, LyXView &, Dialogs &);
+       void gui_CreateUrl(string const &, LyXView &, Dialogs &);
+       void gui_ShowVCLogFile(LyXView & lv, Dialogs & d);
+
+} // extern "C"
index 79dd6542d522a623e8ffe9179e8d673e1b530a8e..8c72d540183fcc70b12222c2f153d87765b712e5 100644 (file)
-/* This file is part of
-* ======================================================
-*
-*           LyX, The Document Processor
-*
-*          Copyright 1995 Matthias Ettrich
-*           Copyright 1995-1998 The LyX Team
-*
-* ====================================================== */
-
-#include <config.h>
+/**
+ * \file screen.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include <algorithm>
+#include <config.h>
 
 #include "screen.h"
 #include "lyxtext.h"
 #include "lyxrow.h"
-#include "frontends/Painter.h"
-#include "frontends/WorkArea.h"
-#include "buffer.h"
 #include "BufferView.h"
+#include "buffer.h"
+#include "WorkArea.h"
+#include "Painter.h"
 #include "font_metrics.h"
-#include "insets/insettext.h"
-#include "frontends/xforms/ColorHandler.h"
 #include "language.h"
+#include "debug.h"
 
-using std::max;
 using std::min;
-
-namespace {
-
-GC createGC()
-{
-       XGCValues val;
-       val.foreground = BlackPixel(fl_get_display(),
-                                   DefaultScreen(fl_get_display()));
-
-       val.function = GXcopy;
-       val.graphics_exposures = false;
-       val.line_style = LineSolid;
-       val.line_width = 0;
-       return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0),
-                        GCForeground | GCFunction | GCGraphicsExposures
-                        | GCLineWidth | GCLineStyle , &val);
-}
-
-} // namespace anon
-
-
-// Constructor
-LScreen::LScreen(WorkArea & o)
-       : owner(o), force_clear(true)
+using std::max;
+using std::endl;
+LyXScreen::LyXScreen()
+       : force_clear_(true), cursor_visible_(false)
 {
-       // the cursor isnt yet visible
-       cursor_visible = false;
-       cursor_pixmap = 0;
-       cursor_pixmap_x = 0;
-       cursor_pixmap_y = 0;
-       cursor_pixmap_w = 0;
-       cursor_pixmap_h = 0;
-
-       // We need this GC
-       gc_copy = createGC();
 }
 
 
-LScreen::~LScreen()
+LyXScreen::~LyXScreen()
 {
-       XFreeGC(fl_get_display(), gc_copy);
 }
 
+// FIXME: GUII these cursor methods need to decide
+// whether the workarea is focused or not
 
-void LScreen::reset()
+void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
 {
-       XFreeGC(fl_get_display(), gc_copy);
-       // the cursor isnt yet visible
-       cursor_visible = false;
-       cursor_pixmap = 0;
-       cursor_pixmap_x = 0;
-       cursor_pixmap_y = 0;
-       cursor_pixmap_w = 0;
-       cursor_pixmap_h = 0;
-
-       // We need this GC
-       gc_copy = createGC();
-}
+       if (cursor_visible_)
+               return;
  
+       workarea().getPainter().start();
  
-void LScreen::setCursorColor()
-{
-       if (!lyxColorHandler.get()) return;
-
-       GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
-
-       XGCValues val;
-       XGetGCValues(fl_get_display(),
-                    gc, GCForeground, &val);
-       XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
-}
-
-
-void LScreen::redraw(LyXText * text, BufferView * bv)
-{
-       drawFromTo(text, bv, 0, owner.workHeight(), 0, 0, text == bv->text);
-       expose(0, 0, owner.workWidth(), owner.workHeight());
-       if (cursor_visible) {
-               cursor_visible = false;
-               bv->showCursor();
-       }
-}
-
-
-void LScreen::expose(int x, int y, int exp_width, int exp_height)
-{
-       XCopyArea(fl_get_display(),
-                 owner.getPixmap(),
-                 owner.getWin(),
-                 gc_copy,
-                 x, y,
-                 exp_width, exp_height,
-                 x + owner.xpos(),
-                 y + owner.ypos());
-}
-
-
-void LScreen::drawFromTo(LyXText * text, BufferView * bv,
-                          int y1, int y2, int y_offset, int x_offset,
-                          bool internal)
-{
-       int y_text = text->first_y + y1;
-
-       // get the first needed row
-       Row * row = text->getRowNearY(y_text);
-       // y_text is now the real beginning of the row
-
-       int y = y_text - text->first_y;
-       // y1 is now the real beginning of row on the screen
-
-       while (row != 0 && y < y2) {
-               LyXText::text_status st = text->status();
-               text->getVisibleRow(bv, y + y_offset,
-                                   x_offset, row, y + text->first_y);
-               internal = internal && (st != LyXText::CHANGED_IN_DRAW);
-               while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
-                       text->fullRebreak(bv);
-                       st = LyXText::NEED_MORE_REFRESH;
-                       text->setCursor(bv, text->cursor.par(),
-                                       text->cursor.pos());
-                       text->status(bv, st);
-                       // we should be sure our row-pointer is still valid, so it's
-                       // better to recompute it.
-                       y_text = y + text->first_y;
-                       row = text->getRowNearY(y_text);
-                       y = y_text - text->first_y;
-                       text->getVisibleRow(bv, y + y_offset,
-                                           x_offset, row, y + text->first_y);
-               }
-               y += row->height();
-               row = row->next();
-       }
-       force_clear = false;
-
-       // maybe we have to clear the screen at the bottom
-       if ((y < y2) && text->bv_owner) {
-               owner.getPainter().fillRectangle(0, y,
-                                                owner.workWidth(),
-                                                y2 - y,
-                                              LColor::bottomarea);
-       }
-}
-
-
-void LScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
-                          int y_text, int y_offset, int x_offset)
-{
-       int const y = y_text - text->first_y + y_offset;
-
-       if (((y + row->height()) > 0) &&
-           ((y - row->height()) <= static_cast<int>(owner.workHeight()))) {
-               // ok there is something visible
-               text->getVisibleRow(bv, y, x_offset, row, y + text->first_y);
-       }
-       force_clear = false;
-}
-
-
-/* draws the screen, starting with textposition y. uses as much already
- * printed pixels as possible */
-void LScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
-{
-       if (cursor_visible) hideCursor();
-
-       int const old_first = text->first_y;
-       bool internal = (text == bv->text);
-       text->first_y = y;
-
-       // is any optimiziation possible?
-       if ((y - old_first) < owner.workHeight()
-           && (old_first - y) < owner.workHeight())
-       {
-               if (text->first_y < old_first) {
-                       drawFromTo(text, bv, 0,
-                                  old_first - text->first_y, 0, 0, internal);
-                       XCopyArea (fl_get_display(),
-                                  owner.getWin(),
-                                  owner.getWin(),
-                                  gc_copy,
-                                  owner.xpos(),
-                                  owner.ypos(),
-                                  owner.workWidth(),
-                                  owner.workHeight() - old_first + text->first_y,
-                                  owner.xpos(),
-                                  owner.ypos() + old_first - text->first_y
-                               );
-                       // expose the area drawn
-                       expose(0, 0,
-                              owner.workWidth(),
-                              old_first - text->first_y);
-               } else  {
-                       drawFromTo(text, bv,
-                                  owner.workHeight() + old_first - text->first_y,
-                                  owner.workHeight(), 0, 0, internal);
-                       XCopyArea (fl_get_display(),
-                                  owner.getWin(),
-                                  owner.getWin(),
-                                  gc_copy,
-                                  owner.xpos(),
-                                  owner.ypos() + text->first_y - old_first,
-                                  owner.workWidth(),
-                                  owner.workHeight() + old_first - text->first_y,
-                                  owner.xpos(),
-                                  owner.ypos());
-                       // expose the area drawn
-                       expose(0, owner.workHeight() + old_first - text->first_y,
-                              owner.workWidth(), text->first_y - old_first);
-               }
-       } else {
-               // make a dumb new-draw
-               drawFromTo(text, bv, 0, owner.workHeight(), 0, 0, internal);
-               expose(0, 0, owner.workWidth(), owner.workHeight());
-       }
-}
-
-
-void LScreen::showCursor(LyXText const * text, BufferView const * bv)
-{
-       if (!cursor_visible) {
-               Cursor_Shape shape = BAR_SHAPE;
-               if (text->real_current_font.language() !=
-                   bv->buffer()->params.language
-                   || text->real_current_font.isVisibleRightToLeft()
-                   != bv->buffer()->params.language->RightToLeft())
-                       shape = (text->real_current_font.isVisibleRightToLeft())
-                               ? REVERSED_L_SHAPE : L_SHAPE;
-               showManualCursor(text, text->cursor.x(), text->cursor.y(),
-                                font_metrics::maxAscent(text->real_current_font),
-                                font_metrics::maxDescent(text->real_current_font),
-                                shape);
+       Cursor_Shape shape = BAR_SHAPE;
+       BufferParams const & bp(bv->buffer()->params);
+       LyXFont const & realfont(text->real_current_font);
+
+       if (realfont.language() != bp.language
+               || realfont.isVisibleRightToLeft() 
+               != bp.language->RightToLeft()) {
+               shape = (realfont.isVisibleRightToLeft())
+                       ? REVERSED_L_SHAPE : L_SHAPE;
        }
+       showManualCursor(text, text->cursor.x(), text->cursor.y(),
+               font_metrics::maxAscent(realfont),
+               font_metrics::maxDescent(realfont),
+               shape);
+       workarea().getPainter().end();
 }
 
 
-/* returns true if first has changed, otherwise false */
-bool LScreen::fitManualCursor(LyXText * text, BufferView * bv,
-                               int /*x*/, int y, int asc, int desc)
+bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
+       int /*x*/, int y, int asc, int desc)
 {
+       int const vheight = workarea().workHeight();
        int newtop = text->first_y;
-
-       if (y + desc - text->first_y >= static_cast<int>(owner.workHeight()))
-               newtop = y - 3 * owner.workHeight() / 4;  // the scroll region must be so big!!
+       if (y + desc - text->first_y >= vheight)
+               newtop = y - 3 * vheight / 4;  // the scroll region must be so big!!
        else if (y - asc < text->first_y
                && text->first_y > 0) {
-               newtop = y - owner.workHeight() / 4;
+               newtop = y - vheight / 4;
        }
 
        newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
-
        if (newtop != text->first_y) {
                draw(text, bv, newtop);
                text->first_y = newtop;
@@ -288,124 +91,26 @@ bool LScreen::fitManualCursor(LyXText * text, BufferView * bv,
 }
 
 
-void LScreen::showManualCursor(LyXText const * text, int x, int y,
-                                int asc, int desc, Cursor_Shape shape)
+void LyXScreen::cursorToggle(BufferView * bv) const
 {
-       // Update the cursor color.
-       setCursorColor();
-
-       int const y1 = max(y - text->first_y - asc, 0);
-       int const y_tmp = min(y - text->first_y + desc,
-                             static_cast<int>(owner.workHeight()));
-
-       // Secure against very strange situations
-       int const y2 = max(y_tmp, y1);
-
-       if (cursor_pixmap) {
-               XFreePixmap(fl_get_display(), cursor_pixmap);
-               cursor_pixmap = 0;
-       }
-
-       if (y2 > 0 && y1 < int(owner.workHeight())) {
-               cursor_pixmap_h = y2 - y1 + 1;
-               cursor_pixmap_y = y1;
-
-               switch (shape) {
-               case BAR_SHAPE:
-                       cursor_pixmap_w = 1;
-                       cursor_pixmap_x = x;
-                       break;
-               case L_SHAPE:
-                       cursor_pixmap_w = cursor_pixmap_h/3;
-                       cursor_pixmap_x = x;
-                       break;
-               case REVERSED_L_SHAPE:
-                       cursor_pixmap_w = cursor_pixmap_h/3;
-                       cursor_pixmap_x = x - cursor_pixmap_w + 1;
-                       break;
-               }
-
-               cursor_pixmap =
-                       XCreatePixmap (fl_get_display(),
-                                      fl_root,
-                                      cursor_pixmap_w,
-                                      cursor_pixmap_h,
-                                      fl_get_visual_depth());
-               XCopyArea (fl_get_display(),
-                          owner.getWin(),
-                          cursor_pixmap,
-                          gc_copy,
-                          owner.xpos() + cursor_pixmap_x,
-                          owner.ypos() + cursor_pixmap_y,
-                          cursor_pixmap_w,
-                          cursor_pixmap_h,
-                          0, 0);
-               XDrawLine(fl_get_display(),
-                         owner.getWin(),
-                         gc_copy,
-                         x + owner.xpos(),
-                         y1 + owner.ypos(),
-                         x + owner.xpos(),
-                         y2 + owner.ypos());
-               switch (shape) {
-               case BAR_SHAPE:
-                       break;
-               case L_SHAPE:
-               case REVERSED_L_SHAPE:
-                       int const rectangle_h = (cursor_pixmap_h + 10) / 20;
-                       XFillRectangle(fl_get_display(),
-                                      owner.getWin(),
-                                      gc_copy,
-                                      cursor_pixmap_x + owner.xpos(),
-                                      y2 - rectangle_h + 1 + owner.ypos(),
-                                      cursor_pixmap_w - 1, rectangle_h);
-                       break;
-               }
-
-       }
-       cursor_visible = true;
-}
-
-
-void LScreen::hideCursor()
-{
-       if (!cursor_visible) return;
-
-       if (cursor_pixmap) {
-               XCopyArea (fl_get_display(),
-                          cursor_pixmap,
-                          owner.getWin(),
-                          gc_copy,
-                          0, 0,
-                          cursor_pixmap_w, cursor_pixmap_h,
-                          cursor_pixmap_x + owner.xpos(),
-                          cursor_pixmap_y + owner.ypos());
-       }
-       cursor_visible = false;
-}
-
-
-void LScreen::cursorToggle(BufferView * bv) const
-{
-       if (cursor_visible)
+       if (cursor_visible_)
                bv->hideCursor();
        else
                bv->showCursor();
 }
 
 
-/* returns a new top so that the cursor is visible */
-unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
+unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
 {
-       int const vheight = owner.workHeight();
-       int newtop = top_y; 
+       int const vheight = workarea().workHeight();
+       int newtop = top_y;
 
        Row * row = cursor.row();
 
        // Is this a hack? Yes, probably... (Lgb)
        if (!row)
                return max(newtop, 0);
-
+       
        if (cursor.y() - row->baseline() + row->height()
            - top_y >= vheight) {
                if (row->height() < vheight
@@ -418,8 +123,8 @@ unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
                        newtop = cursor.y()
                                - vheight / 2;   /* the scroll region must be so big!! */
                }
-
-       } else if (static_cast<int>(cursor.y() - row->baseline()) <
+               
+       } else if (static_cast<int>((cursor.y()) - row->baseline()) <
                   top_y && top_y > 0) {
                if (row->height() < vheight
                    && row->height() > vheight / 4) {
@@ -437,9 +142,7 @@ unsigned int LScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
 }
 
 
-/* scrolls the screen so that the cursor is visible, if necessary.
-* returns true if a change was made, otherwise false */
-bool LScreen::fitCursor(LyXText * text, BufferView * bv)
+bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
 {
        // Is a change necessary?
        int const newtop = topCursorVisible(text->cursor, text->first_y);
@@ -449,28 +152,33 @@ bool LScreen::fitCursor(LyXText * text, BufferView * bv)
        return result;
 }
 
-
-void LScreen::update(LyXText * text, BufferView * bv,
-                      int y_offset, int x_offset)
+  
+void LyXScreen::update(LyXText * text, BufferView * bv,
+       int yo, int xo)
 {
+       int const vwidth = workarea().workWidth();
+       int const vheight = workarea().workHeight();
+
+       workarea().getPainter().start();
        switch (text->status()) {
        case LyXText::NEED_MORE_REFRESH:
        {
                int const y = max(int(text->refresh_y - text->first_y), 0);
-               drawFromTo(text, bv, y, owner.workHeight(), y_offset, x_offset);
+               drawFromTo(text, bv, y, vheight, yo, xo);
                text->refresh_y = 0;
                // otherwise this is called ONLY from BufferView_pimpl(update)
                // or we should see to set this flag accordingly
                if (text != bv->text)
                        text->status(bv, LyXText::UNCHANGED);
-               expose(0, y, owner.workWidth(), owner.workHeight() - y);
+               expose(0, y, vwidth, vheight - y);
        }
        break;
        case LyXText::NEED_VERY_LITTLE_REFRESH:
        {
                // ok I will update the current cursor row
                drawOneRow(text, bv, text->refresh_row, text->refresh_y,
-                          y_offset, x_offset);
+                          yo, xo);
                // this because if we had a major update the refresh_row could
                // have been set to 0!
                if (text->refresh_row) {
@@ -478,8 +186,8 @@ void LScreen::update(LyXText * text, BufferView * bv,
                        // or we should see to set this flag accordingly
                        if (text != bv->text)
                                text->status(bv, LyXText::UNCHANGED);
-                       expose(0, text->refresh_y - text->first_y + y_offset,
-                                  owner.workWidth(), text->refresh_row->height());
+                       expose(0, text->refresh_y - text->first_y + yo,
+                                  vwidth, text->refresh_row->height());
                }
        }
        break;
@@ -488,12 +196,14 @@ void LScreen::update(LyXText * text, BufferView * bv,
                // Nothing needs done
                break;
        }
+       workarea().getPainter().end();
 }
 
 
-void LScreen::toggleSelection(LyXText * text, BufferView * bv,
+void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
                                bool kill_selection,
-                               int y_offset, int x_offset)
+                               int yo, int xo)
 {
        // only if there is a selection
        if (!text->selection.set()) return;
@@ -503,45 +213,140 @@ void LScreen::toggleSelection(LyXText * text, BufferView * bv,
                                     - text->selection.end.row()->baseline()
                                     + text->selection.end.row()->height()),
                    text->first_y),
-               static_cast<int>(text->first_y + owner.workHeight()));
+               static_cast<int>(text->first_y + workarea().workHeight()));
        int const top = min(
                max(static_cast<int>(text->selection.start.y() -
                                     text->selection.start.row()->baseline()),
                    text->first_y),
-               static_cast<int>(text->first_y + owner.workHeight()));
+               static_cast<int>(text->first_y + workarea().workHeight()));
 
        if (kill_selection)
                text->selection.set(false);
+       workarea().getPainter().start();
        drawFromTo(text, bv, top - text->first_y, bottom - text->first_y,
-                  y_offset, x_offset);
+                  yo, xo);
        expose(0, top - text->first_y,
-              owner.workWidth(),
-              bottom - text->first_y - (top - text->first_y));
+              workarea().workWidth(),
+              bottom - text->first_y - (top - text->first_y));
+       workarea().getPainter().end();
 }
-
-
-void LScreen::toggleToggle(LyXText * text, BufferView * bv,
-                            int y_offset, int x_offset)
+  
+void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
+                            int yo, int xo)
 {
        if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
            && text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
                return;
-
+       
        int const top_tmp = text->toggle_cursor.y()
                - text->toggle_cursor.row()->baseline();
        int const bottom_tmp = text->toggle_end_cursor.y()
                - text->toggle_end_cursor.row()->baseline()
                + text->toggle_end_cursor.row()->height();
-
-       int const offset = y_offset < 0 ? y_offset : 0;
+       
+       int const offset = yo < 0 ? yo : 0;
        int const bottom = min(max(bottom_tmp, text->first_y),
-                    static_cast<int>(text->first_y + owner.workHeight()))-offset;
+               static_cast<int>(text->first_y + workarea().workHeight())) - offset;
        int const top = min(max(top_tmp, text->first_y),
-                 static_cast<int>(text->first_y + owner.workHeight()))-offset;
+               static_cast<int>(text->first_y + workarea().workHeight())) - offset;
+
+       workarea().getPainter().start();
 
        drawFromTo(text, bv, top - text->first_y,
-                  bottom - text->first_y, y_offset,
-                  x_offset);
-       expose(0, top - text->first_y, owner.workWidth(),
+                  bottom - text->first_y, yo,
+                  xo);
+       expose(0, top - text->first_y, workarea().workWidth(),
               bottom - text->first_y - (top - text->first_y));
+       workarea().getPainter().end();
+}
+
+
+void LyXScreen::redraw(LyXText * text, BufferView * bv)
+{
+       workarea().getPainter().start();
+
+       if (!text) {
+               greyOut();
+               expose(0, 0, workarea().workWidth(), workarea().workHeight());
+               workarea().getPainter().end();
+               return;
+       }
+
+       drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text);
+       expose(0, 0, workarea().workWidth(), workarea().workHeight());
+       workarea().getPainter().end();
+       if (cursor_visible_) {
+               cursor_visible_ = false;
+               bv->showCursor();
+       }
+}
+
+
+void LyXScreen::greyOut()
+{
+       workarea().getPainter().fillRectangle(0, 0,
+               workarea().workWidth(),
+               workarea().workHeight(),
+               LColor::bottomarea);
+}
+
+
+void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
+       int y1, int y2, int yo, int xo,
+       bool internal)
+{
+       int y_text = text->first_y + y1;
+  
+       // get the first needed row
+       Row * row = text->getRowNearY(y_text);
+       // y_text is now the real beginning of the row
+  
+       int y = y_text - text->first_y;
+       // y1 is now the real beginning of row on the screen
+       
+       while (row != 0 && y < y2) {
+               LyXText::text_status st = text->status();
+               text->getVisibleRow(bv, y + yo,
+                                   xo, row, y + text->first_y);
+               internal = internal && (st != LyXText::CHANGED_IN_DRAW);
+               while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
+                       text->fullRebreak(bv);
+                       st = LyXText::NEED_MORE_REFRESH;
+                       text->setCursor(bv, text->cursor.par(), text->cursor.pos());
+                       text->status(bv, st);
+                       text->getVisibleRow(bv, y + yo,
+                                           xo, row, y + text->first_y);
+               }
+               y += row->height();
+               row = row->next();
+       }
+       force_clear_ = false;
+
+       // maybe we have to clear the screen at the bottom
+       if ((y < y2) && text->bv_owner) {
+               workarea().getPainter().fillRectangle(0, y,
+                       workarea().workWidth(), y2 - y,
+                       LColor::bottomarea);
+       }
+}
+
+
+void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
+       int y_text, int yo, int xo)
+{
+       int const y = y_text - text->first_y + yo;
+
+       if (((y + row->height()) > 0) &&
+           ((y - row->height()) <= static_cast<int>(workarea().workHeight()))) {
+               text->getVisibleRow(bv, y, xo, row, y + text->first_y);
+       }
+       force_clear_ = false;
 }
index 378d9d991e7936b352caf4e64f40c4ab4fcc2906..47f092d8e563bc673466d4acd03cb3e7f4eec1b1 100644 (file)
@@ -6,29 +6,25 @@
  *
  * \author unknown
  * \author John Levon <moz@compsoc.man.ac.uk>
- */ 
+ */
 
-#ifndef LYXSCREEN_H
-#define LYXSCREEN_H
+#ifndef SCREEN_H
+#define SCREEN_H
 
 #ifdef __GNUG__
 #pragma interface
 #endif
-
-#include <X11/Xlib.h>
-
 class LyXText;
 class LyXCursor;
 class WorkArea;
-class Buffer;
 class BufferView;
-
 struct Row;
 
 /**
- * LScreen - document rendering management
+ * LyXScreen - document rendering management
  *
- * This class is used to manage the on-screen rendering inside the
+ * This class is used to manage the on-screen rendering inside the 
  * work area; it is responsible for deciding which LyXText rows
  * need re-drawing.
  *
@@ -37,36 +33,66 @@ struct Row;
  *
  * The blinking cursor is also handled here.
  */
-class LScreen {
+class LyXScreen {
 public:
-       ///
+       /// types of cursor in work area
        enum Cursor_Shape {
-               ///
+               /// normal I-beam
                BAR_SHAPE,
-               ///
+               /// L-shape for locked insets of a different language
                L_SHAPE,
-               ///
+               /// reverse L-shape for RTL text
                REVERSED_L_SHAPE
        };
 
-       ///
-       LScreen(WorkArea &);
+       LyXScreen();
 
-       ///
-       ~LScreen();
-
-       void reset();
+       virtual ~LyXScreen();
+        
+       /**
+        * draw the screen from a given position
+        * @param y the text position to draw from
+        *
+        * Uses as much of the already printed pixmap as possible 
+        */
+       virtual void draw(LyXText *, BufferView *, unsigned int y) = 0;
+       /**
+        * showManualCursor - display the cursor on the work area
+        * @param text the lyx text containing the cursor
+        * @param x the x position of the cursor
+        * @param y the y position of the row's baseline
+        * @param asc ascent of the row
+        * @param desc descent of the row
+        * @param shape the current shape
+        */
+       virtual void showManualCursor(LyXText const *, int x, int y,
+                             int asc, int desc,
+                             Cursor_Shape shape) = 0;
+       
+       /// unpaint the cursor painted by showManualCursor()
+       virtual void hideCursor() = 0;
+       /**
+        * fit the cursor onto the visible work area, scrolling if necessary
+        * @param bv the buffer view
+        * @param vheight the height of the visible region
+        * @param base_y the top of the lyxtext to look at
+        * @param x the new x position
+        * @param y the new y position
+        * @param a ascent of the cursor's row
+        * @param d descent of the cursor's row
+        * @return true if the work area needs scrolling as a result
+        */
+       bool fitManualCursor(BufferView * bv, LyXText * text,
+               int x, int y, int a, int d);
+       /// redraw the screen, without using existing pixmap
+       virtual void redraw(LyXText *, BufferView *);
+   
+       /// draw the cursor if it's not already shown
+       virtual void showCursor(LyXText const *, BufferView const *);
  
-       /// Sets the cursor color to LColor::cursor.
-       void setCursorColor();
-
-       /** Draws the screen form textposition y. Uses as much of
-           the already printed pixmap as possible */
-       void draw(LyXText *, BufferView *, unsigned int y);
-
-       /// Redraws the screen, without using existing pixmap
-       void redraw(LyXText *, BufferView *);
-
        /**
         * topCursorVisible - get a new "top" to make the cursor visible
         * @param c the cursor
@@ -75,70 +101,71 @@ public:
         * This helper function calculates a new y co-ordinate for
         * the top of the containing region such that the cursor contained
         * within the LyXText is "nicely" visible.
-        */ 
-       unsigned int topCursorVisible(LyXCursor const & c, int top_y);
+        */
+       virtual unsigned int topCursorVisible(LyXCursor const & c, int top_y);
  
-       /// Redraws the screen such that the cursor is visible
-       bool fitCursor(LyXText *, BufferView *);
-       ///
-       void showCursor(LyXText const *, BufferView const *);
-       ///
-       void hideCursor();
-       ///
-       void cursorToggle(BufferView *) const;
-       ///
-       void showManualCursor(LyXText const *, int x, int y,
-                             int asc, int desc,
-                             Cursor_Shape shape);
-       /// returns 1 if first has changed, otherwise 0
-       bool fitManualCursor(LyXText *, BufferView *, int, int, int, int);
-       ///
-       void toggleSelection(LyXText *, BufferView *, bool = true,
+       /**
+        * fitCursor - fit the cursor onto the work area
+        * @param text the text containing the cursor
+        * @param bv the bufferview
+        * @return true if a change was necessary
+        *
+        * Scrolls the screen so that the cursor is visible,
+        */
+       virtual bool fitCursor(LyXText *, BufferView *);
+       /// show the cursor if it's not, and vice versa
+       virtual void cursorToggle(BufferView *) const;
+
+       /**
+        * update - update part of the screen rendering
+        * @param text the containing text region
+        * @param bv the bufferview
+        * @param xo the x offset into the text
+        * @param yo the x offset into the text
+        * 
+        * Updates part of the screen. If text->status is
+        * LyXText::NEED_MORE_REFRESH, we update from the
+        * point of change and to the end of the screen.
+        * If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
+        * we only update the current row. 
+        */
+       virtual void update(LyXText * text, BufferView * bv, int yo = 0, int xo = 0);
+       /// FIXME
+       virtual void toggleSelection(LyXText *, BufferView *, bool = true,
                             int y_offset = 0, int x_offset = 0);
-       ///
-       void toggleToggle(LyXText *, BufferView *,
+       /// FIXME - at least change the name !!
+       virtual void toggleToggle(LyXText *, BufferView *,
                          int y_offset = 0, int x_offset = 0);
+       
+       /// FIXME
+       virtual bool forceClear() const { return force_clear_; }
 
-       /** Updates part of the screen. If text->status is
-           LyXText::NEED_MORE_REFRESH, we update from the
-           point of change and to the end of the screen.
-           If text->status is LyXText::NEED_VERY_LITTLE_REFRESH,
-           we only update the current row. */
-       void update(LyXText *, BufferView *, int y_offset=0, int x_offset=0);
-       ///
-       bool forceClear() const { return force_clear; }
-
-       ///
-       bool cursor_visible;
-private:
-       /// Copies specified area of pixmap to screen
-       void expose(int x, int y, int exp_width, int exp_height);
+protected:
+       /// copies specified area of pixmap to screen
+       virtual void expose(int x, int y, int exp_width, int exp_height) = 0;
 
+       /// get the work area
+       virtual WorkArea & workarea() const = 0;
        /// y1 and y2 are coordinates of the screen
-       void drawFromTo(LyXText *, BufferView *, int y1, int y2,
-                       int y_offset = 0, int x_offset = 0, bool internal=false);
+       virtual void drawFromTo(LyXText *, BufferView *, int y1, int y2,
+                       int y_offset = 0, int x_offset = 0, bool internal = false);
 
        /// y is a coordinate of the text
-       void drawOneRow(LyXText *, BufferView *, Row * row,
+       virtual void drawOneRow(LyXText *, BufferView *, Row * row,
                        int y_text, int y_offset = 0, int x_offset = 0);
-
-       ///
-       WorkArea & owner;
-
-       ///
-       Pixmap cursor_pixmap;
-       ///
-       int cursor_pixmap_x;
-       ///
-       int cursor_pixmap_y;
-       ///
-       int cursor_pixmap_w;
-       ///
-       int cursor_pixmap_h;
-       ///
-       GC gc_copy;
-       ///
-       bool force_clear;
+       /// grey out (no buffer)
+       void greyOut();
+       /// FIXME ?
+       bool force_clear_;
+       /// is the blinking cursor currently drawn
+       bool cursor_visible_;
 };
 
-#endif
+#endif // SCREEN_H
index 1f2440ee1eff2fe0ac881902718aabe2659dded7..a13b2c0c23b25854ab13db5697376a83ddac1b4b 100644 (file)
@@ -1,10 +1,37 @@
-2002-06-13  Juergen Spitzmueller <j.spitzmueller@gmx.de>
+2002-06-16  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
-       * FormRef.C: Add Tooltips
+       * changes to let the function setup happen in frontends
+       * guiapi.C: new file
 
-2002-06-18  Angus Leeming  <leeming@lyx.org>
+2002-06-16    <alstrup@diku.dk>
 
-       * forms/.cvsignore: ignore any generated files/dirs.
+       * xscreen.C (draw): After drawing, we wait for X with XSync..
+
+       * XWorkArea.[Ch]: Xforms implementation of GUII WorkArea.
+
+       * XPainter.[Ch]: Use XWorkArea instead of WorkArea.
+
+       * xscreen.[Ch]: Use XWorkArea instead of WorkArea.
+
+       * WorkAreaFactory.C: New file for GUII WorkArea.
+
+       * LyXScreenFactory.C: WorkArea GUIIized.
+
+2002-06-15  Lyx Development team  <larsbj@birdstep.com>
+
+       * LyXKeySymFactory.C: Added XForms implementation.
+
+       * XLyXKeySym.[Ch]: Added XForms implementation of the LyXKeySym
+       stuff.
+
+       * XWorkArea.[Ch]: Use LyXKeySym in signal interface for keypress.
+
+2002-06-14  Lyx Development team  <lyx@electronia>
+
+       * LyXScreenFactory.C: Implementation for XForms.
+
+       * xscreen.[Ch]: Added implementation of LyXScreen for XForms,
+       called XScreen (surprise!).
 
 2002-06-14  Angus Leeming  <leeming@lyx.org>
 
        * xforms_helpers.[Ch]: removed scex, idex functions.
 
        * Most other files: minor changes associated with the above.
-       
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * XWorkArea.h:
        * XWorkArea.C: move scrolling logic into here
+
        * ColorHandler.h:
        * ColorHandler.C:
        * XPainter.h:
        * XPainter.C: remove unused stuff, s/PainterBase/Painter/,
        s/Painter/XPainter/
+
 2002-06-12  Angus Leeming  <leeming@lyx.org>
 
        * lyx_gui.C (parse_init): exit isn't in namespace lyx_gui!
 
 2002-05-24  Martin Vermeer  <martin.vermeer@hut.fi>
 
-       * FormMathsDelim.C: fix delimiter pre-display rendering 
+       * FormMathsDelim.C: fix delimiter pre-display rendering
          mess-up bug (354)
 
 2002-06-12  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
        * XFormsView.h:
        * XFormsView.C: move init() back to LyXView
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * GUIRunTime.C: remove in favour of ...
 
        * XFormsView.h:
        * XFormsView.C: change show() prototype
+
        * XPainter.C:
        * xfont_loader.C: don't use GUIRunTime any more
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
-       * ColorHandler.C: 
+       * ColorHandler.C:
        * FontInfo.h:
        * FormBase.C:
        * FormBaseDeprecated.C:
        * MathsSymbols.C:
        * Menubar_pimpl.C: minor cleanups
+
 2002-06-12  John Levon  <moz@compsoc.man.ac.uk>
 
        * xformsGImage.C:
        * FontInfo.h:
        * FontInfo.C: some cleanup
-       * XWorkArea.C: 
+
+       * XWorkArea.C:
        * XFormsView.h:
        * XFormsView.C: some minor cleanup, use of
          scoped_ptr
 
        * XWorkArea.h:
        * XWorkArea.C: use workHeight(), remove enter/leaveView
+
 2002-06-11  John Levon  <moz@compsoc.man.ac.uk>
 
        * XWorkArea.h:
        * XWorkArea.C: remove belowMouse() and active()
+
 2002-06-11  John Levon  <moz@compsoc.man.ac.uk>
 
        * xfont_metrics.h:
        * XPainter.C: X-specific metrics stuff moved into xforms/ only
 
 2002-06-11  Edwin Leuven  <leuven@fee.uva.nl>
-       * FormParagraph.[Ch]: moved to mvc
-       * form_paragraph.[Ch]: idem
-       * forms/form_paragraph.fd: idem
-       * Dialogs.C: idem
+
+       * FormParagraph.[Ch]: moved to mvc
+       * form_paragraph.[Ch]: idem
+       * forms/form_paragraph.fd: idem
+       * Dialogs.C: idem
 
 2002-06-06  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
        * xformsGImage.h: use FLIMAGE_H_LOCATION to include flimage.h.
 
 2002-06-10  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
        * FormMathsPanel.C: do not include ButtonController.tmpl
        * FormPreferences.C: ditto
        * xformsBC.C: ditto
 2002-06-04  John Levon  <moz@compsoc.man.ac.uk>
 
        * xformsGImage.h: an xforms build fix
+
 2002-06-02  Michael A. Koziarski  <michael@koziarski.com>
+
        * Tooltips.C: fix some sigc++ -> boost errors.
+
 2002-06-02  John Levon  <moz@compsoc.man.ac.uk>
 
        * GUIRunTime.C:
 
 2002-05-10  Herbert Voss  <voss@perce.de>
 
-       * FormInclude.C (input, update): disable load-button when 
+       * FormInclude.C (input, update): disable load-button when
        "use verbatim" is enabled
 
 2002-05-30  Lars Gullik Bjønnes  <larsbj@birdstep.com>
index fbb4ce3839a6a7fa0550d08a8bfcbfa8d825379f..f4c3bf74d2b402eb177fd7ecc3b295ebc40e02f6 100644 (file)
 #endif
 
 #include "Dialogs.h"
+#include "Tooltips.h"
 
-#include "GUI.h"
-#include "xformsBC.h"
-
-#include "combox.h"       // needed for clean destruction of boost::scoped_ptr
-#include "forms/form_aboutlyx.h"
-#include "forms/form_bibitem.h"
-#include "forms/form_bibtex.h"
-#include "forms/form_browser.h"
-#include "forms/form_character.h"
-#include "forms/form_citation.h"
-#include "forms/form_error.h"
-#include "forms/form_ert.h"
-#include "forms/form_external.h"
-#include "forms/form_float.h"
-#include "forms/form_forks.h"
-#include "forms/form_graphics.h"
-#include "forms/form_include.h"
-#include "forms/form_index.h"
-#include "forms/form_minipage.h"
-#include "forms/form_paragraph.h"
-#include "forms/form_preamble.h"
-#include "forms/form_print.h"
-#include "forms/form_ref.h"
-#include "forms/form_search.h"
-#include "forms/form_sendto.h"
-#include "forms/form_spellchecker.h"
-#include "forms/form_tabular_create.h"
-#include "forms/form_texinfo.h"
-#include "forms/form_thesaurus.h"
-#include "forms/form_toc.h"
-#include "forms/form_url.h"
-
-#include "FormAboutlyx.h"
-#include "FormBibitem.h"
-#include "FormBibtex.h"
-#include "FormCharacter.h"
-#include "FormCitation.h"
-#include "FormError.h"
-#include "FormERT.h"
-#include "FormExternal.h"
-#include "FormFloat.h"
-#include "FormForks.h"
-#include "FormGraphics.h"
-#include "FormInclude.h"
-#include "FormIndex.h"
-#include "FormLog.h"
-#include "FormMinipage.h"
-#include "FormParagraph.h"
-#include "FormPreamble.h"
-#include "FormPrint.h"
-#include "FormRef.h"
-#include "FormSearch.h"
-#include "FormSendto.h"
-#include "FormShowFile.h"
-#include "FormSpellchecker.h"
-#include "FormTabularCreate.h"
-#include "FormTexinfo.h"
-#include "FormThesaurus.h"
-#include "FormToc.h"
-#include "FormUrl.h"
-#include "FormVCLog.h"
+LyXView * dialogs_lyxview;
 
-#include "FormDocument.h"
-#include "FormMathsPanel.h"
-#include "FormPreferences.h"
-#include "FormTabular.h"
-
-#include "Tooltips.h"
 
 /// Are the tooltips on or off?
 bool Dialogs::tooltipsEnabled()
@@ -93,72 +28,9 @@ bool Dialogs::tooltipsEnabled()
 
 Dialogs::Dialogs(LyXView * lv)
 {
-       add(new GUI<ControlAboutlyx, FormAboutlyx,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlBibitem, FormBibitem,
-                   OkCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlBibtex, FormBibtex,
-                   OkCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlCharacter, FormCharacter,
-                   OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlCitation, FormCitation,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlError, FormError,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlERT, FormERT,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlExternal, FormExternal,
-                   OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlForks, FormForks,
-                   OkApplyCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlGraphics, FormGraphics,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlInclude, FormInclude,
-                   OkCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlIndex, FormIndex,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlLog, FormLog,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlMinipage, FormMinipage,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlFloat, FormFloat,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlParagraph, FormParagraph,
-                   OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlPreamble, FormPreamble,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlPrint, FormPrint,
-                   OkApplyCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlRef, FormRef,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlSearch, FormSearch,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlSendto, FormSendto,
-                   OkApplyCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlShowFile, FormShowFile,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlSpellchecker, FormSpellchecker,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlTabularCreate, FormTabularCreate,
-                   OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
-#ifdef HAVE_LIBAIKSAURUS
-       add(new GUI<ControlThesaurus, FormThesaurus,
-                   OkApplyCancelReadOnlyPolicy, xformsBC>(*lv, *this));
+#if 1
+       dialogs_lyxview = lv;
 #endif
-       add(new GUI<ControlTexinfo, FormTexinfo,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlToc, FormToc,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlUrl, FormUrl,
-                   NoRepeatedApplyReadOnlyPolicy, xformsBC>(*lv, *this));
-       add(new GUI<ControlVCLog, FormVCLog,
-                   OkCancelPolicy, xformsBC>(*lv, *this));
-
-       add(new FormDocument(lv, this));
-       add(new FormMathsPanel(lv, this));
-       add(new FormPreferences(lv, this));
-       add(new FormTabular(lv, this));
-
        // reduce the number of connections needed in
        // dialogs by a simple connection here.
        hideAll.connect(hideBufferDependent);
index 6156600a4a1d8b0135ebe25e02ac3309c0c3abc4..fa083189936dfc43c8343e4f99374ccb24362201 100644 (file)
@@ -50,4 +50,5 @@ private:
        boost::scoped_ptr<FD_aboutlyx_license> license_;
 };
 
+
 #endif // FORMABOUTLYX_H
index ddcae8f4441aa32b7f95eedaa2b26c292845e5f3..188f980863dd6ac6328f4ef52660f8df2c336f06 100644 (file)
@@ -57,6 +57,8 @@ public:
 
        Tooltips & tooltips();
 
+       friend void gui_ShowDocument(LyXView &, Dialogs &);
+
 protected: // methods
 
        /// Pointer to the actual instantiation of the ButtonController.
index 83f6a252485cd41214a0b701d19f0306b19e3a4a..ee2f78f9810f66451d06c5ea228fd1ddc2c8a157 100644 (file)
@@ -62,10 +62,12 @@ FormDocument::FormDocument(LyXView * lv, Dialogs * d)
          ActCell(0), Confirmed(0),
          current_bullet_panel(0), current_bullet_depth(0), fbullet(0)
 {
+#if 0
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
        d->showDocument = boost::bind(&FormDocument::show, this);
+#endif
 }
 
 
index 735284146b48291576107c04b3378c2d94e17e29..251ace8f1d2a999dc6a9731af684cc34d486bb75 100644 (file)
@@ -152,7 +152,9 @@ FormMathsPanel::FormMathsPanel(LyXView * lv, Dialogs * d)
        ams_ops_.reset(new FormMathsBitmap(lv, d, *this, _("AMS Operators"), latex));
 
        //showUnderMouse(false);
+#if 0
        d->showMathPanel = boost::bind(&FormMathsPanel::show, this);
+#endif
 }
 
 
index 1c5a65ef7fd6b82ad3bfe469b91d435cbc72aba1..db1af2827f432ff173582c40475b2df736a14298 100644 (file)
@@ -37,6 +37,7 @@ struct FD_maths_panel;
  */
 class FormMathsPanel : public FormBaseBD {
 public:
+       friend void gui_ShowMathPanel(LyXView &, Dialogs &);
        ///
        FormMathsPanel(LyXView *, Dialogs *);
        ///
@@ -96,7 +97,7 @@ class FormMathsSub : public FormBaseBD {
 public:
        ///
        FormMathsSub(LyXView *, Dialogs *, FormMathsPanel const &,
-                    string const &, bool allowResize=true);
+                    string const &, bool allowResize = true);
 
 protected:
        /// Pointer to the actual instantiation of the ButtonController.
index 0a5fa59d02d8b063f67df8712db0c48254013d85..9ebb1914800e3351670268e56f3ded6b494b0a12 100644 (file)
@@ -70,8 +70,8 @@ Converters local_converters;
 } // namespace anon
 
 
-FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
-       : FormBaseBI(lv, d, _("Preferences"), false),
+FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
+       : FormBaseBI(&lv, &d, _("Preferences"), false),
          colors_(*this), converters_(*this), inputs_misc_(*this),
          formats_(*this), interface_(*this), language_(*this),
          lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
@@ -80,8 +80,12 @@ FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
+#if 0
        d->showPreferences = boost::bind(&FormPreferences::show, this);
+#endif
+#if 0
        d->showSpellcheckerPreferences = boost::bind(&FormPreferences::showSpellPref, this);
+#endif
 }
 
 
index 81da0ba80dc7f2fa39569a719dcab1ec30904ece..6b83e0765730221c6080f3d96e7088f65d714c74 100644 (file)
@@ -50,8 +50,10 @@ struct FD_preferences_spelloptions;
  */
 class FormPreferences : public FormBaseBI {
 public:
+       friend void gui_ShowPreferences(LyXView &, Dialogs &);
+       friend void gui_ShowSpellcheckerPreferences(LyXView &, Dialogs &);
        ///
-       FormPreferences(LyXView *, Dialogs *);
+       FormPreferences(LyXView &, Dialogs &);
 
 private:
        /// Pointer to the actual instantiation of the ButtonController.
index 4b06416c2864c313eaf36f50ab0feaed07f18b50..f66890ae91adce2cef58b05d71b2aeeb00bfb0d2 100644 (file)
@@ -17,7 +17,6 @@
 #include "ControlRef.h"
 #include "FormRef.h"
 #include "forms/form_ref.h"
-#include "Tooltips.h"
 #include "xforms_helpers.h"
 #include "insets/insetref.h"
 #include "helper_funcs.h" // getStringFromVector
@@ -63,25 +62,6 @@ void FormRef::build()
        bc().addReadOnly(dialog_->button_update);
        bc().addReadOnly(dialog_->input_name);
        bc().addReadOnly(dialog_->input_ref);
-       
-       //set up the tooltip mechanism
-       string str = _("Show the labels of another opened document. Useful if you are working with multipart documents, where you might want to refer to another doc.");
-       tooltips().init(dialog_->choice_buffer, str);
-
-       str = _("Choose a label to refer to.");
-       tooltips().init(dialog_->browser_refs, str);
-
-       str = _("Type in a label name. We recommend that you use the browser instead.");
-       tooltips().init(dialog_->input_ref, str);
-
-       str = _("Choose the reference style.");
-       tooltips().init(dialog_->choice_type, str);
-
-       str = _("Sort labels in alphabetical order.");
-       tooltips().init(dialog_->check_sort, str);
-
-       str = _("Refresh the list of labels.");
-       tooltips().init(dialog_->button_update, str);
 }
 
 
index 9067ebb401ae05b888a860835d88bee44877da8f..ca454c93695bffda1229234692ce46a0223c0cea 100644 (file)
@@ -19,6 +19,7 @@
 #include "gettext.h"
 #include FORMS_H_LOCATION
 
+
 FormShowFile::FormShowFile(ControlShowFile & c)
        : FormCB<ControlShowFile, FormBrowser>(c, string())
 {}
index ad802a295b99d5bd62f0a3339092b1a652936cef..60150d2cc3ba8eb62cba48bf6744da040aafb58e 100644 (file)
@@ -39,15 +39,17 @@ using std::bind2nd;
 using std::remove_if;
 
 
-FormTabular::FormTabular(LyXView * lv, Dialogs * d)
-       : FormInset(lv, d, _("Tabular Layout")),
+FormTabular::FormTabular(LyXView & lv, Dialogs & d)
+       : FormInset(&lv, &d, _("Tabular Layout")),
          inset_(0), actCell_(-1), closing_(false)
 {
+#if 0
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
        d->showTabular = boost::bind(&FormTabular::showInset, this, _1);
        d->updateTabular = boost::bind(&FormTabular::updateInset, this, _1);
+#endif
 }
 
 
index fd26fe8e2b7e034cc9e29a3a60c7ec3a0f56029b..c05e426bea191ce8704e417e20429e5fca4d6250 100644 (file)
@@ -31,8 +31,11 @@ struct FD_tabular_longtable;
  */
 class FormTabular : public FormInset {
 public:
+       friend void gui_ShowTabular(InsetTabular *, LyXView &, Dialogs &);
+       friend void gui_UpdateTabular(InsetTabular *, LyXView &, Dialogs &);
+
        /// #FormTabular x(LyXFunc ..., Dialogs ...);#
-       FormTabular(LyXView *, Dialogs *);
+       FormTabular(LyXView &, Dialogs &);
 
 private:
        /// Pointer to the actual instantiation of the ButtonController.
diff --git a/src/frontends/xforms/LyXKeySymFactory.C b/src/frontends/xforms/LyXKeySymFactory.C
new file mode 100644 (file)
index 0000000..798fc55
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * \file LyXKeySymFactory.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger & Juergen
+ */
+
+#include <config.h>
+#include "frontends/LyXKeySymFactory.h"
+
+#include "XLyXKeySym.h"
+
+namespace LyXKeySymFactory {
+
+LyXKeySym * create()
+{
+       return new XLyXKeySym();
+} 
+}
diff --git a/src/frontends/xforms/LyXScreenFactory.C b/src/frontends/xforms/LyXScreenFactory.C
new file mode 100644 (file)
index 0000000..1ce2b1c
--- /dev/null
@@ -0,0 +1,23 @@
+/**
+ * \file LyXScreenFactory.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+#include "frontends/LyXScreenFactory.h"
+
+#include "XWorkArea.h"
+#include "xscreen.h"
+namespace LyXScreenFactory {
+
+LyXScreen * create(WorkArea & owner)
+{
+       return new XScreen(static_cast<XWorkArea &>(owner));
+} 
+}
index ed2b953913b8bc76bd3f7d532c59ad737fd28428..f280f20d8b3bc8bd9e868d59905ecc18c31d89d3 100644 (file)
@@ -40,6 +40,8 @@ libxforms_la_SOURCES = \
        xforms_resize.h \
        $(XFORMSGIMAGE) xformsBC.C \
        xformsBC.h \
+       xscreen.C \
+       xscreen.h \
        Alert_pimpl.C \
        Color.C \
        Color.h \
@@ -141,6 +143,9 @@ libxforms_la_SOURCES = \
        FormUrl.h \
        FormVCLog.C \
        FormVCLog.h \
+       guiapi.C \
+       LyXKeySymFactory.C \
+       LyXScreenFactory.C \
        MathsSymbols.C \
        MathsSymbols.h \
        Menubar_pimpl.C \
@@ -153,8 +158,11 @@ libxforms_la_SOURCES = \
        Toolbar_pimpl.h \
        Tooltips.C \
        Tooltips.h \
+       WorkAreaFactory.C \
        XFormsView.C \
        XFormsView.h \
+       XLyXKeySym.C \
+       XLyXKeySym.h \
        XPainter.C \
        XPainter.h \
        XWorkArea.h \
diff --git a/src/frontends/xforms/WorkAreaFactory.C b/src/frontends/xforms/WorkAreaFactory.C
new file mode 100644 (file)
index 0000000..59bd400
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * \file WorkAreaFactory.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+#include "frontends/WorkAreaFactory.h"
+#include "XWorkArea.h"
+namespace WorkAreaFactory {
+WorkArea * create(int x, int y, int w, int h)
+{
+       return new XWorkArea(x, y, w, h);
+}
+}
diff --git a/src/frontends/xforms/XLyXKeySym.C b/src/frontends/xforms/XLyXKeySym.C
new file mode 100644 (file)
index 0000000..0398507
--- /dev/null
@@ -0,0 +1,106 @@
+/**
+ * \file XLyXKeySym.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "XLyXKeySym.h"
+
+#include "debug.h"
+
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+
+using std::endl;
+
+XLyXKeySym::XLyXKeySym()
+       : LyXKeySym(), keysym(NoSymbol)
+{
+}
+
+void XLyXKeySym::initFromKeySym(KeySym ks)
+{
+       keysym = ks;
+}
+
+void XLyXKeySym::init(string const & symbolname)
+{
+       keysym = XStringToKeysym(symbolname.c_str());
+       if (keysym == NoSymbol) {
+               lyxerr[Debug::KBMAP]
+                       << "XLyXKeySym.C: No such keysym: "
+                       << symbolname << endl;
+       }
+}
+
+bool XLyXKeySym::isOK() const
+{
+       return keysym != NoSymbol;
+}
+
+bool XLyXKeySym::isModifier() const
+{
+       // Can we be sure that this will work for all X Window
+       // implementations? (Lgb)
+       // Perhaps all of them should be explictly mentioned?
+       return ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
+           || keysym == XK_Mode_switch || keysym == 0x0);
+}
+
+string
+XLyXKeySym::getSymbolName() const
+{
+       char * name = XKeysymToString(keysym);
+       return name ? name : string();
+}
+
+char
+XLyXKeySym::getISOEncoded() const
+{
+       if (keysym == NoSymbol) {
+               return 0;
+       }
+
+       unsigned int c = keysym;
+
+       switch (c & 0x0000FF00) {
+               // latin 1 byte 3 = 0
+       case 0x00000000: break;
+               // latin 2 byte 3 = 1
+       case 0x00000100:
+               // latin 3 byte 3 = 2
+       case 0x00000200:
+               // latin 4 byte 3 = 3
+       case 0x00000300:
+               // cyrillic KOI8 & Co
+       case 0x00000600:
+               // greek
+       case 0x00000700:
+               // latin 8 byte 3 = 18 (0x12)
+       case 0x00001200:
+               // latin 9 byte 3 = 19 (0x13)
+       case 0x00001300:
+               c &= 0x000000FF;
+               break;
+       default:
+               c = 0;
+       }
+       return c;
+}
+
+bool XLyXKeySym::operator==(LyXKeySym const & k) const
+{
+       // This is dangerous! Ideally, we should use dynamic_cast instead,
+       // but on the other hand, we are sure that we will always get
+       // the right type, because we decide at compile time which
+       // frontend we use. (Asger)
+       return keysym == static_cast<XLyXKeySym const &>(k).keysym;
+}
diff --git a/src/frontends/xforms/XLyXKeySym.h b/src/frontends/xforms/XLyXKeySym.h
new file mode 100644 (file)
index 0000000..b056411
--- /dev/null
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+/**
+ * \file XLyXKeySym.h
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author Asger and Juergen
+ */
+
+#ifndef XLYXKEYSYM_H
+#define XLYXKEYSYM_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "LString.h"
+#include <X11/Xlib.h>
+#include "frontends/LyXKeySym.h"
+
+/**
+ * This is a base class for representing a keypress.
+ * Each frontend has to implement this to provide
+ * the functionality that LyX needs in regards to
+ * key presses.
+ */
+class XLyXKeySym : public LyXKeySym {
+public:
+       XLyXKeySym();
+
+       /// X11 specific initialization with an X11 KeySym
+       void initFromKeySym(KeySym);
+
+       virtual void init(string const & symbolname);
+
+       virtual ~XLyXKeySym() {}
+
+       /// Is this a valid key?
+       virtual bool isOK() const;
+
+       /// Is this a modifier key only?
+       virtual bool isModifier() const;
+       
+       virtual string getSymbolName() const;
+
+       /**
+        * Return the value of the keysym into the local ISO encoding.
+        * This converts the LyXKeySym to a 8-bit encoded character.
+        * This relies on user to use the right encoding.
+        */
+       virtual char getISOEncoded() const;
+
+       virtual bool operator==(LyXKeySym const & k) const;
+
+private:
+       unsigned int keysym;
+};
+
+#endif
+
index 3c96f662568a337cfb1a27441a874d7e4494ec92..68837a7d712b6572a239628b00b2929e9a9c3eac 100644 (file)
@@ -36,7 +36,7 @@ using std::endl;
 using std::max;
 
  
-XPainter::XPainter(WorkArea & xwa)
+XPainter::XPainter(XWorkArea & xwa)
        : Painter(), owner_(xwa)
 {
 }
index 1813cf1e60eeb6743d5f8badd684680bcdab33d4..ddb5c3684bfff88f3e749c95030cf8ab69821e79 100644 (file)
 
 
 class LyXFont;
-class WorkArea;
+class XWorkArea;
 
 /**
  * XPainter - a painter implementation for Xlib
  */
 class XPainter : public Painter {
 public:
-       XPainter(WorkArea &);
+       XPainter(XWorkArea &);
        
        /// return the width of the work area in pixels
        virtual int paperWidth() const;
@@ -120,7 +120,7 @@ public:
  
 private:
        /// our owner who we paint upon
-       WorkArea & owner_;
+       XWorkArea & owner_;
 };
 
 #endif // XPAINTER_H
index 4498937b847daba84802b08182e6d1c680f84368..6348e476e14f26518de8c81bec6a62ec24b58b37 100644 (file)
@@ -18,6 +18,7 @@
 #include "LyXView.h"
 #include "lyxrc.h" // lyxrc.show_banner
 #include "version.h" // lyx_version
+#include "XLyXKeySym.h"
 
 #if FL_VERSION < 1 && (FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5))
 #include "lyxlookup.h"
@@ -123,33 +124,33 @@ key_modifier::state x_key_state(unsigned int state)
 
 
 extern "C" {
-       // Just a bunch of C wrappers around static members of WorkArea
+       // Just a bunch of C wrappers around static members of XWorkArea
        static
-       void C_WorkArea_scroll_cb(FL_OBJECT * ob, long)
+       void C_XWorkArea_scroll_cb(FL_OBJECT * ob, long)
        {
-               WorkArea * area = static_cast<WorkArea*>(ob->u_vdata);
+               XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
                area->scroll_cb();
        }
 
 
        static
-       int C_WorkArea_work_area_handler(FL_OBJECT * ob, int event,
+       int C_XWorkArea_work_area_handler(FL_OBJECT * ob, int event,
                                         FL_Coord, FL_Coord,
                                         int key, void * xev)
        {
-               return WorkArea::work_area_handler(ob, event,
+               return XWorkArea::work_area_handler(ob, event,
                                                   0, 0, key, xev);
        }
 
        static
-       int C_WorkAreaEventCB(FL_FORM * form, void * xev) {
-               WorkArea * wa = static_cast<WorkArea*>(form->u_vdata);
+       int C_XWorkAreaEventCB(FL_FORM * form, void * xev) {
+               XWorkArea * wa = static_cast<XWorkArea*>(form->u_vdata);
                return wa->event_cb(static_cast<XEvent*>(xev));
        }
 }
 
 
-WorkArea::WorkArea(int x, int y, int w, int h)
+XWorkArea::XWorkArea(int x, int y, int w, int h)
        : splash_(0), splash_text_(0), workareapixmap(0), painter_(*this)
 {
        fl_freeze_all_forms();
@@ -207,7 +208,7 @@ WorkArea::WorkArea(int x, int y, int w, int h)
        fl_set_object_resize(obj, FL_RESIZE_ALL);
        fl_set_object_gravity(obj, NorthEastGravity, SouthEastGravity);
        obj->u_vdata = this;
-       fl_set_object_callback(obj, C_WorkArea_scroll_cb, 0);
+       fl_set_object_callback(obj, C_XWorkArea_scroll_cb, 0);
        fl_set_scrollbar_bounds(scrollbar, 0.0, 0.0);
        fl_set_scrollbar_value(scrollbar, 0.0);
        fl_set_scrollbar_size(scrollbar, scrollbar->h);
@@ -232,9 +233,9 @@ WorkArea::WorkArea(int x, int y, int w, int h)
                                      x + bw, y + bw,
                                      w - 15 - 2 * bw, // scrollbarwidth
                                      h - 2 * bw, "",
-                                     C_WorkArea_work_area_handler);
+                                     C_XWorkArea_work_area_handler);
        obj->wantkey = FL_KEY_ALL;
-       obj->u_vdata = this; /* This is how we pass the WorkArea
+       obj->u_vdata = this; /* This is how we pass the XWorkArea
                                to the work_area_handler. */
        fl_set_object_boxtype(obj,FL_DOWN_BOX);
        fl_set_object_resize(obj, FL_RESIZE_ALL);
@@ -242,20 +243,20 @@ WorkArea::WorkArea(int x, int y, int w, int h)
 
        /// X selection hook - xforms gets it wrong
        fl_current_form->u_vdata = this;
-       fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_WorkAreaEventCB);
+       fl_register_raw_callback(fl_current_form, FL_ALL_EVENT, C_XWorkAreaEventCB);
 
        fl_unfreeze_all_forms();
 }
 
 
-WorkArea::~WorkArea()
+XWorkArea::~XWorkArea()
 {
        if (workareapixmap)
                XFreePixmap(fl_get_display(), workareapixmap);
 }
 
 
-void WorkArea::resize(int xpos, int ypos, int width, int height)
+void XWorkArea::resize(int xpos, int ypos, int width, int height)
 {
        fl_freeze_all_forms();
 
@@ -297,7 +298,7 @@ void destroy_object(FL_OBJECT * obj)
 } // namespace anon
 
 
-void WorkArea::createPixmap(int width, int height)
+void XWorkArea::createPixmap(int width, int height)
 {
        // Three calls to createPixmap are needed to draw the initial view
        // of LyX. Any more and the splash is destroyed.
@@ -335,7 +336,7 @@ void WorkArea::createPixmap(int width, int height)
 }
 
 
-void WorkArea::greyOut() const
+void XWorkArea::greyOut() const
 {
        if (!splash_) {
                fl_winset(FL_ObjWin(work_area));
@@ -345,13 +346,13 @@ void WorkArea::greyOut() const
 }
 
 
-void WorkArea::setFocus() const
+void XWorkArea::setFocus() const
 {
        fl_set_focus_object(work_area->form, work_area);
 }
 
 
-void WorkArea::setScrollbarParams(int height, int pos, int line_height)
+void XWorkArea::setScrollbarParams(int height, int pos, int line_height)
 {
        // we need to cache this for scroll_cb
        doc_height_ = height;
@@ -391,7 +392,7 @@ void WorkArea::setScrollbarParams(int height, int pos, int line_height)
 
 
 // callback for scrollbar slider
-void WorkArea::scroll_cb()
+void XWorkArea::scroll_cb()
 {
        double const val = fl_get_scrollbar_value(scrollbar);
        lyxerr[Debug::GUI] << "scroll: val: " << val << endl;
@@ -402,7 +403,7 @@ void WorkArea::scroll_cb()
 }
 
 
-int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
+int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
                                FL_Coord, FL_Coord ,
                                int key, void * xev)
 {
@@ -411,7 +412,7 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
        static long scrollbar_value_old = -1;
 
        XEvent * ev = static_cast<XEvent*>(xev);
-       WorkArea * area = static_cast<WorkArea*>(ob->u_vdata);
+       XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
 
        if (!area) return 1;
 
@@ -477,15 +478,16 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
 //             lyxerr << "We have " << num_keys << " keys in the returned buffer" << endl;
 //             lyxerr << "Our dummy string is " << dummy << endl;
 #endif
+               
                if (lyxerr.debugging(Debug::KEY)) {
                        char const * tmp = XKeysymToString(key);
                        char const * tmp2 = XKeysymToString(keysym);
                        string const stm = (tmp ? tmp : "");
                        string const stm2 = (tmp2 ? tmp2 : "");
 
-                       lyxerr[Debug::KEY] << "WorkArea: Key is `" << stm << "' ["
+                       lyxerr[Debug::KEY] << "XWorkArea: Key is `" << stm << "' ["
                               << key << "]" << endl;
-                       lyxerr[Debug::KEY] << "WorkArea: Keysym is `" << stm2 << "' ["
+                       lyxerr[Debug::KEY] << "XWorkArea: Keysym is `" << stm2 << "' ["
                               << keysym << "]" << endl;
                }
 
@@ -562,7 +564,11 @@ int WorkArea::work_area_handler(FL_OBJECT * ob, int event,
                last_key_pressed = xke->keycode;
                last_state_pressed = ret_state;
 
-               area->workAreaKeyPress(ret_key, x_key_state(ret_state));
+               XLyXKeySym * xlk = new XLyXKeySym;
+               xlk->initFromKeySym(ret_key);
+               
+               area->workAreaKeyPress(LyXKeySymPtr(xlk),
+                                      x_key_state(ret_state));
        }
        break;
 
@@ -637,7 +643,7 @@ extern "C" {
 } // namespace anon
 
 
-int WorkArea::event_cb(XEvent * xev)
+int XWorkArea::event_cb(XEvent * xev)
 {
        int ret = 0;
        switch (xev->type) {
@@ -654,7 +660,7 @@ int WorkArea::event_cb(XEvent * xev)
 }
 
 
-void WorkArea::haveSelection(bool yes) const
+void XWorkArea::haveSelection(bool yes) const
 {
        if (!yes) {
                XSetSelectionOwner(fl_get_display(), XA_PRIMARY, None, CurrentTime);
@@ -665,7 +671,7 @@ void WorkArea::haveSelection(bool yes) const
 }
 
 
-string const WorkArea::getClipboard() const
+string const XWorkArea::getClipboard() const
 {
        clipboard_read = false;
 
@@ -686,7 +692,7 @@ string const WorkArea::getClipboard() const
 }
 
 
-void WorkArea::putClipboard(string const & s) const
+void XWorkArea::putClipboard(string const & s) const
 {
        static string hold;
        hold = s;
index 5caf8076d8475eda517d767ffe227861adc1faeb..55de2f14fd41651d17a74b0f405131bf59707d5c 100644 (file)
 #pragma interface
 #endif
 
+#include "frontends/WorkArea.h"
 #include "XPainter.h"
-#include "frontends/mouse_state.h"
-#include "frontends/key_state.h"
-
-#include <boost/signals/signal0.hpp>
-#include <boost/signals/signal1.hpp>
-#include <boost/signals/signal2.hpp>
-#include <boost/signals/signal3.hpp>
 
 #include FORMS_H_LOCATION
-#include <utility>
 
 ///
-class WorkArea {
+class XWorkArea : public WorkArea {
 public:
        ///
-       WorkArea(int xpos, int ypos, int width, int height);
+       XWorkArea(int xpos, int ypos, int width, int height);
        ///
-       ~WorkArea();
+       ~XWorkArea();
        ///
-       Painter & getPainter() { return painter_; }
+       virtual Painter & getPainter() { return painter_; }
        ///
-       int workWidth() const { return work_area->w; }
+       virtual int workWidth() const { return work_area->w; }
        ///
-       int workHeight() const { return work_area->h; }
+       virtual int workHeight() const { return work_area->h; }
        ///
-       unsigned int width() const { return work_area->w + scrollbar->w; }
-       //unsigned int width() const { return backgroundbox->w + 15; }
+       virtual unsigned int width() const { return work_area->w + scrollbar->w; }
        ///
-       int xpos() const { return work_area->x; }
-       //int xpos() const { return backgroundbox->x; }
+       virtual int xpos() const { return work_area->x; }
        ///
-       int ypos() const { return work_area->y; }
-       //int ypos() const { return backgroundbox->y; }
+       virtual int ypos() const { return work_area->y; }
        ///
-       void resize(int xpos, int ypos, int width, int height);
+       virtual void resize(int xpos, int ypos, int width, int height);
        ///
-       void redraw() const {
+       virtual void redraw() const {
                fl_redraw_object(work_area);
                fl_redraw_object(scrollbar);
        }
        ///
-       void setFocus() const;
+       virtual void setFocus() const;
        ///
        Window getWin() const { return work_area->form->window; }
        ///
-       bool hasFocus() const { return work_area->focus; }
+       virtual bool hasFocus() const { return work_area->focus; }
        ///
-       bool visible() const { return work_area->form->visible; }
+       virtual bool visible() const { return work_area->form->visible; }
        ///
-       void greyOut() const;
+       virtual void greyOut() const;
         ///
-        void setScrollbarParams(int height, int pos, int line_height);
+       virtual void setScrollbarParams(int height, int pos, int line_height);
        ///
        Pixmap getPixmap() const { return workareapixmap; }
        /// xforms callback
@@ -78,36 +68,11 @@ public:
        /// xforms callback from scrollbar
        void scroll_cb();
        /// a selection exists
-       void haveSelection(bool) const;
-       ///
-       string const getClipboard() const;
-       ///
-       void putClipboard(string const &) const;
-       // Signals
-       ///
-       boost::signal0<void> workAreaExpose;
-       ///
-       boost::signal1<void, int> scrollDocView;
-       ///
-       boost::signal2<void, KeySym, key_modifier::state> workAreaKeyPress;
-       ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaButtonPress;
-       ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaButtonRelease;
-       ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaMotionNotify;
-       ///
-       boost::signal0<void> workAreaFocus;
-       ///
-       boost::signal0<void> workAreaUnfocus;
+       virtual void haveSelection(bool) const;
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaDoubleClick;
+       virtual string const getClipboard() const;
        ///
-       boost::signal3<void, int, int, mouse_button::state> workAreaTripleClick;
-       /// emitted when an X client has requested our selection
-       boost::signal0<void> selectionRequested;
-       /// emitted when another X client has stolen our selection
-       boost::signal0<void> selectionLost;
+       virtual void putClipboard(string const &) const;
 
        /// handles SelectionRequest X Event, to fill the clipboard
        int event_cb(XEvent * xev);
index 8f7466392f451dc153b784b534dc0bf1248ad95e..3181709fd4e5373119364cc4a594cd867246ac71 100644 (file)
@@ -4,6 +4,3 @@ Makefile
 *.h
 *.C
 *.tmp
-*.lo
-.deps
-.libs
index 12eddccd988515ca7e1912cd763e4ab42d350df1..d543119de7679a0cf9bf6afc58a9052d89cf04d0 100644 (file)
@@ -10,13 +10,13 @@ SnapGrid: 2
 =============== FORM ===============
 Name: form_maths_delim
 Width: 250
-Height: 307
+Height: 221
 Number of Objects: 11
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 250 307
+box: 0 0 250 221
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -34,7 +34,7 @@ argument:
 --------------------
 class: FL_BUTTON
 type: PUSH_BUTTON
-box: 42 112 170 140
+box: 28 108 192 64
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -52,7 +52,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 168 268 70 30
+box: 168 182 70 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -88,7 +88,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 90 268 70 30
+box: 90 182 70 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -106,7 +106,7 @@ argument: 0
 --------------------
 class: FL_BUTTON
 type: RETURN_BUTTON
-box: 12 268 70 30
+box: 14 182 70 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -135,7 +135,7 @@ label:
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
-name:
+name: 
 callback: 
 argument: 
 
diff --git a/src/frontends/xforms/guiapi.C b/src/frontends/xforms/guiapi.C
new file mode 100644 (file)
index 0000000..af5ef38
--- /dev/null
@@ -0,0 +1,534 @@
+#include <config.h>
+
+#include "guiapi.h"
+
+#include "FormAboutlyx.h"
+#include "forms/form_aboutlyx.h"
+
+#include "FormBibitem.h"
+#include "forms/form_bibitem.h"
+
+#include "FormBibtex.h"
+#include "forms/form_bibtex.h"
+
+#include "FormBrowser.h"
+#include "forms/form_browser.h"
+
+#include "FormCharacter.h"
+#include "forms/form_character.h"
+
+#include "FormCitation.h"
+#include "forms/form_citation.h"
+
+#include "FormDocument.h"
+#include "forms/form_document.h"
+
+#include "FormError.h"
+#include "forms/form_error.h"
+
+#include "FormERT.h"
+#include "forms/form_ert.h"
+
+#include "FormExternal.h"
+#include "forms/form_external.h"
+
+#include "FormFloat.h"
+#include "forms/form_float.h"
+
+#include "FormForks.h"
+#include "forms/form_forks.h"
+
+#include "FormGraphics.h"
+#include "forms/form_graphics.h"
+
+#include "FormInclude.h"
+#include "forms/form_include.h"
+
+#include "FormIndex.h"
+#include "forms/form_index.h"
+
+#include "FormLog.h"
+
+#include "FormMathsPanel.h"
+#include "FormMathsBitmap.h"
+#include "FormMathsDeco.h"
+#include "FormMathsDelim.h"
+#include "FormMathsMatrix.h"
+#include "FormMathsSpace.h"
+#include "FormMathsStyle.h"
+
+#include "forms/form_maths_deco.h"
+#include "forms/form_maths_delim.h"
+#include "forms/form_maths_matrix.h"
+#include "forms/form_maths_panel.h"
+#include "forms/form_maths_space.h"
+#include "forms/form_maths_style.h"
+
+#include "FormMinipage.h"
+#include "forms/form_minipage.h"
+
+#include "FormParagraph.h"
+#include "forms/form_paragraph.h"
+
+#include "FormPreamble.h"
+#include "forms/form_preamble.h"
+
+#include "FormPreferences.h"
+#include "forms/form_preferences.h"
+
+#include "FormPrint.h"
+#include "forms/form_print.h"
+
+#include "FormRef.h"
+#include "forms/form_ref.h"
+
+#include "FormSearch.h"
+#include "forms/form_search.h"
+
+#include "FormSendto.h"
+#include "forms/form_sendto.h"
+
+#include "FormShowFile.h"
+
+#include "FormSpellchecker.h"
+#include "forms/form_spellchecker.h"
+
+#include "FormTabular.h"
+#include "forms/form_tabular.h"
+
+#include "FormTabularCreate.h"
+#include "forms/form_tabular_create.h"
+
+#include "FormTexinfo.h"
+#include "forms/form_texinfo.h"
+
+#include "FormToc.h"
+#include "forms/form_toc.h"
+
+#include "FormUrl.h"
+#include "forms/form_url.h"
+
+#include "FormVCLog.h"
+
+#include "xformsBC.h"
+#include "combox.h"
+
+#include "controllers/GUI.h"
+#include "insets/inseterror.h"
+
+#include "LyXView.h"
+
+#include "ControlAboutlyx.h"
+#include "ControlBibitem.h"
+#include "ControlBibtex.h"
+#include "ControlCharacter.h"
+#include "ControlCitation.h"
+#include "ControlError.h"
+#include "ControlERT.h"
+#include "ControlExternal.h"
+#include "ControlFloat.h"
+#include "ControlForks.h"
+#include "ControlGraphics.h"
+#include "insets/insetgraphicsParams.h"
+#include "ControlInclude.h"
+#include "ControlIndex.h"
+#include "ControlLog.h"
+#include "ControlMinipage.h"
+#include "ControlParagraph.h"
+#include "ControlPreamble.h"
+#include "ControlPrint.h"
+#include "ControlRef.h"
+#include "ControlSearch.h"
+#include "ControlSendto.h"
+#include "ControlShowFile.h"
+#include "ControlSpellchecker.h"
+#include "ControlTabularCreate.h"
+#include "ControlTexinfo.h"
+#include "ControlThesaurus.h"
+#include "ControlToc.h"
+#include "ControlUrl.h"
+#include "ControlVCLog.h"
+
+
+namespace { // anon
+
+// I belive that this one is buggy (Lgb)
+// But not if used correctly. (Lgb)
+template <class T>
+class GUISingleton {
+public:
+       static
+       T & get(LyXView & lv, Dialogs & d) {
+               static T t(lv, d);
+               return t;
+       }
+};
+
+
+GUISingleton<GUI<ControlCharacter, FormCharacter,
+                OkApplyCancelReadOnlyPolicy, xformsBC> >
+controlCharacterSingleton;
+
+GUISingleton<GUI<ControlCitation, FormCitation,
+                NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlCitationSingleton;
+
+
+GUISingleton<GUI<ControlERT, FormERT,
+                NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlERTSingleton;
+
+GUISingleton<GUI<ControlIndex, FormIndex,
+                NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlIndexSingleton;
+
+GUISingleton<GUI<ControlMinipage, FormMinipage,
+                NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlMinipageSingleton;
+
+GUISingleton<FormPreferences> formPreferencesSingleton;
+
+GUISingleton<GUI<ControlRef, FormRef,
+                NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlRefSingleton;
+
+GUISingleton<FormTabular> formTabularSingleton;
+
+GUISingleton<GUI<ControlToc, FormToc,
+                OkCancelPolicy, xformsBC> >
+controlTocSingleton;
+
+GUISingleton<GUI<ControlUrl, FormUrl,
+                NoRepeatedApplyReadOnlyPolicy, xformsBC> >
+controlUrlSingleton;
+
+} // anon
+
+
+extern "C" {
+
+       void gui_ShowAboutlyx(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlAboutlyx, FormAboutlyx,
+                       OkCancelPolicy, xformsBC> cal(lv, d);
+               cal.show();
+       }
+
+
+       void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlBibitem, FormBibitem,
+                       OkCancelReadOnlyPolicy, xformsBC> cbi(lv, d);
+               cbi.showInset(ic);
+       }
+
+
+       void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlBibtex, FormBibtex,
+                       OkCancelReadOnlyPolicy, xformsBC> cbt(lv, d);
+               cbt.showInset(ic);
+       }
+
+
+       void gui_ShowCharacter(LyXView & lv, Dialogs & d)
+       {
+               controlCharacterSingleton.get(lv, d).show();
+       }
+
+
+       void gui_SetUserFreeFont(LyXView & lv, Dialogs & d)
+       {
+               controlCharacterSingleton.get(lv, d).apply();
+       }
+
+
+       void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               controlCitationSingleton.get(lv, d).showInset(ic);
+       }
+
+
+       void gui_CreateCitation(string const & s, LyXView & lv, Dialogs & d)
+       {
+               controlCitationSingleton.get(lv, d).createInset(s);
+       }
+
+
+       void gui_ShowDocument(LyXView & lv, Dialogs & d)
+       {
+               static FormDocument fd(&lv, &d);
+               fd.show();
+       }
+
+
+       void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlError, FormError,
+                       OkCancelPolicy, xformsBC> ce(lv, d);
+               ce.showInset(ie);
+       }
+
+
+       void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d)
+       {
+               controlERTSingleton.get(lv, d).showInset(ie);
+       }
+
+
+       void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d)
+       {
+               controlERTSingleton.get(lv, d).showInset(ie);
+       }
+
+
+       void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlExternal, FormExternal,
+                       OkApplyCancelReadOnlyPolicy, xformsBC> ce(lv, d);
+               ce.showInset(ie);
+       }
+
+
+       void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlShowFile, FormShowFile,
+                       OkCancelPolicy, xformsBC> csf(lv, d);
+               csf.showFile(f);
+       }
+
+
+       void gui_ShowFloat(InsetFloat * ifl, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlFloat, FormFloat,
+                       NoRepeatedApplyReadOnlyPolicy, xformsBC> cf(lv, d);
+               cf.showInset(ifl);
+       }
+
+
+       void gui_ShowForks(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlForks, FormForks,
+                       OkApplyCancelPolicy, xformsBC> cf(lv, d);
+               cf.show();
+       }
+
+
+       void gui_ShowGraphics(InsetGraphics * ig, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlGraphics, FormGraphics,
+                       NoRepeatedApplyReadOnlyPolicy, xformsBC> cg(lv, d);
+               cg.showInset(ig);
+       }
+
+
+       void gui_ShowInclude(InsetInclude * ii, LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlInclude, FormInclude,
+                       OkCancelReadOnlyPolicy, xformsBC> ci(lv, d);
+               ci.showInset(ii);
+       }
+
+
+       void gui_ShowIndex(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               controlIndexSingleton.get(lv, d).showInset(ic);
+       }
+
+
+       void gui_CreateIndex(string const & s, LyXView & lv, Dialogs & d)
+       {
+               controlIndexSingleton.get(lv, d).createInset(s);
+       }
+
+
+#if 0
+       void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d)
+       {
+       }
+#endif
+
+
+       void gui_ShowLogFile(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlLog, FormLog,
+                       OkCancelPolicy, xformsBC> cl(lv, d);
+               cl.show();
+       }
+
+
+       void gui_ShowMathPanel(LyXView & lv, Dialogs & d)
+       {
+               static FormMathsPanel fmp(&lv, &d);
+               fmp.show();
+       }
+
+
+       void gui_ShowMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
+       {
+               controlMinipageSingleton.get(lv, d).showInset(im);
+       }
+
+
+       void gui_UpdateMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
+       {
+               controlMinipageSingleton.get(lv, d).showInset(im);
+       }
+
+
+       void gui_ShowParagraph(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlParagraph, FormParagraph,
+                       OkApplyCancelReadOnlyPolicy, xformsBC> cp(lv, d);
+               cp.show();
+       }
+
+
+#if 0
+       void gui_UpdateParagraph(LyXView & lv, Dialogs & d)
+       {
+#warning FIXME!
+               // This should be the same object as in gui_ShowParagraph
+               static GUI<ControlParagraph, FormParagraph,
+                       OkApplyCancelReadOnlyPolicy, xformsBC> cp(lv, d);
+#if 0
+               cp.
+#endif
+       }
+#endif
+
+
+       void gui_ShowPreamble(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlPreamble, FormPreamble,
+                       NoRepeatedApplyReadOnlyPolicy, xformsBC> cp(lv, d);
+               cp.show();
+       }
+
+
+       void gui_ShowPreferences(LyXView & lv, Dialogs & d)
+       {
+               formPreferencesSingleton.get(lv, d).show();
+       }
+
+
+       void gui_ShowPrint(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlPrint, FormPrint,
+                       OkApplyCancelPolicy, xformsBC> cp(lv, d);
+               cp.show();
+       }
+
+
+       void gui_ShowRef(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               controlRefSingleton.get(lv, d).showInset(ic);
+       }
+
+
+       void gui_CreateRef(string const & s, LyXView & lv, Dialogs & d)
+       {
+               controlRefSingleton.get(lv, d).createInset(s);
+       }
+
+
+       void gui_ShowSearch(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlSearch, FormSearch,
+                       NoRepeatedApplyReadOnlyPolicy, xformsBC> cs(lv, d);
+               cs.show();
+       }
+
+
+       void gui_ShowSendto(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlSendto, FormSendto,
+                       OkApplyCancelPolicy, xformsBC> cs(lv, d);
+               cs.show();
+       }
+
+
+       void gui_ShowSpellchecker(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlSpellchecker, FormSpellchecker,
+                       NoRepeatedApplyReadOnlyPolicy, xformsBC> cp(lv, d);
+               cp.show();
+       }
+
+
+       void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d)
+       {
+               formPreferencesSingleton.get(lv, d).showSpellPref();
+       }
+
+
+       void gui_ShowTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
+       {
+               formTabularSingleton.get(lv, d).showInset(it);
+       }
+
+
+       void gui_UpdateTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
+       {
+               formTabularSingleton.get(lv, d).updateInset(it);
+       }
+
+
+       void gui_ShowTabularCreate(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlTabularCreate, FormTabularCreate,
+                       OkApplyCancelReadOnlyPolicy, xformsBC> ctc(lv, d);
+               ctc.show();
+       }
+
+
+       void gui_ShowTexinfo(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlTexinfo, FormTexinfo,
+                       OkCancelPolicy, xformsBC> ct(lv, d);
+               ct.show();
+       }
+
+
+       void gui_ShowThesaurus(string const & /*s*/, LyXView & , Dialogs &)
+       {
+#ifdef HAVE_LIBAIKSAURUS
+               static GUI<ControlThesaurus, FormThesaurus,
+                       OkApplyCancelReadOnlyPolicy, xformsBC> ct(lv, d);
+               ct.showEntry(s);
+#endif
+       }
+
+
+       void gui_ShowTOC(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               controlTocSingleton.get(lv, d).showInset(ic);
+       }
+
+
+       void gui_CreateTOC(string const & s, LyXView & lv, Dialogs & d)
+       {
+               controlTocSingleton.get(lv, d).createInset(s);
+       }
+
+
+       void gui_ShowUrl(InsetCommand * ic, LyXView & lv, Dialogs & d)
+       {
+               controlUrlSingleton.get(lv, d).showInset(ic);
+       }
+
+
+       void gui_CreateUrl(string const & s, LyXView & lv, Dialogs & d)
+       {
+               controlUrlSingleton.get(lv, d).createInset(s);
+       }
+
+
+       void gui_ShowVCLogFile(LyXView & lv, Dialogs & d)
+       {
+               static GUI<ControlVCLog, FormVCLog,
+                       OkCancelPolicy, xformsBC> cv(lv, d);
+               cv.show();
+       }
+
+} // extern "C"
diff --git a/src/frontends/xforms/xscreen.C b/src/frontends/xforms/xscreen.C
new file mode 100644 (file)
index 0000000..715b0f3
--- /dev/null
@@ -0,0 +1,260 @@
+/**
+ * \file xscreen.C
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <algorithm>
+#include <X11/Xlib.h>
+
+#include "frontends/screen.h"
+#include "frontends/font_metrics.h"
+#include "XWorkArea.h"
+#include "xscreen.h"
+#include "lyxtext.h"
+#include "lyxrow.h"
+#include "Painter.h"
+#include "WorkArea.h"
+#include "buffer.h"
+#include "BufferView.h"
+#include "insets/insettext.h"
+#include "ColorHandler.h"
+#include "language.h"
+
+using std::max;
+using std::min;
+
+namespace {
+
+GC createGC()
+{
+       XGCValues val;
+       val.foreground = BlackPixel(fl_get_display(), 
+                                   DefaultScreen(fl_get_display()));
+       
+       val.function = GXcopy;
+       val.graphics_exposures = false;
+       val.line_style = LineSolid;
+       val.line_width = 0;
+       return XCreateGC(fl_get_display(), RootWindow(fl_get_display(), 0), 
+                        GCForeground | GCFunction | GCGraphicsExposures
+                        | GCLineWidth | GCLineStyle , &val);
+}
+
+} // namespace anon
+
+
+// Constructor
+XScreen::XScreen(XWorkArea & o)
+       : LyXScreen(), owner_(o)
+{
+       // the cursor isnt yet visible
+       cursor_pixmap = 0;
+       cursor_pixmap_x = 0;
+       cursor_pixmap_y = 0;
+       cursor_pixmap_w = 0;
+       cursor_pixmap_h = 0;
+
+       // We need this GC
+       gc_copy = createGC();
+}
+
+
+XScreen::~XScreen()
+{
+       XFreeGC(fl_get_display(), gc_copy);
+}
+
+void XScreen::setCursorColor() 
+{
+       if (!lyxColorHandler.get()) return;
+
+       GC gc = lyxColorHandler->getGCForeground(LColor::cursor);
+       
+       XGCValues val;
+       XGetGCValues(fl_get_display(),
+                    gc, GCForeground, &val);
+       XChangeGC(fl_get_display(), gc_copy, GCForeground, &val);
+}
+
+
+void XScreen::showManualCursor(LyXText const * text, int x, int y,
+                                int asc, int desc, Cursor_Shape shape)
+{
+       // Update the cursor color.
+       setCursorColor();
+       
+       int const y1 = max(y - text->first_y - asc, 0);
+       int const y_tmp = min(y - text->first_y + desc,
+                             static_cast<int>(owner_.workHeight()));
+
+       // Secure against very strange situations
+       int const y2 = max(y_tmp, y1);
+       
+       if (cursor_pixmap) {
+               XFreePixmap(fl_get_display(), cursor_pixmap);
+               cursor_pixmap = 0;
+       }
+
+       if (y2 > 0 && y1 < int(owner_.workHeight())) {
+               cursor_pixmap_h = y2 - y1 + 1;
+               cursor_pixmap_y = y1;
+
+               switch (shape) {
+               case BAR_SHAPE:
+                       cursor_pixmap_w = 1;
+                       cursor_pixmap_x = x;
+                       break;
+               case L_SHAPE:
+                       cursor_pixmap_w = cursor_pixmap_h/3;
+                       cursor_pixmap_x = x;
+                       break;
+               case REVERSED_L_SHAPE:
+                       cursor_pixmap_w = cursor_pixmap_h/3;
+                       cursor_pixmap_x = x - cursor_pixmap_w + 1;
+                       break;
+               }
+
+               cursor_pixmap = 
+                       XCreatePixmap (fl_get_display(),
+                                      fl_root,
+                                      cursor_pixmap_w,
+                                      cursor_pixmap_h,
+                                      fl_get_visual_depth());
+               XCopyArea (fl_get_display(),
+                          owner_.getWin(),
+                          cursor_pixmap,
+                          gc_copy,
+                          owner_.xpos() + cursor_pixmap_x,
+                          owner_.ypos() + cursor_pixmap_y,
+                          cursor_pixmap_w,
+                          cursor_pixmap_h,
+                          0, 0);
+               XDrawLine(fl_get_display(),
+                         owner_.getWin(),
+                         gc_copy,
+                         x + owner_.xpos(),
+                         y1 + owner_.ypos(),
+                         x + owner_.xpos(),
+                         y2 + owner_.ypos());
+               switch (shape) {
+               case BAR_SHAPE:
+                       break;
+               case L_SHAPE:
+               case REVERSED_L_SHAPE:
+                       int const rectangle_h = (cursor_pixmap_h + 10) / 20;
+                       XFillRectangle(fl_get_display(),
+                                      owner_.getWin(),
+                                      gc_copy,
+                                      cursor_pixmap_x + owner_.xpos(),
+                                      y2 - rectangle_h + 1 + owner_.ypos(),
+                                      cursor_pixmap_w - 1, rectangle_h);
+                       break;
+               }
+
+       }
+       cursor_visible_ = true;
+}
+
+
+void XScreen::hideCursor()
+{
+       if (!cursor_visible_) return;
+
+       if (cursor_pixmap) {
+               XCopyArea (fl_get_display(), 
+                          cursor_pixmap,
+                          owner_.getWin(),
+                          gc_copy,
+                          0, 0, 
+                          cursor_pixmap_w, cursor_pixmap_h,
+                          cursor_pixmap_x + owner_.xpos(),
+                          cursor_pixmap_y + owner_.ypos());
+       }
+       cursor_visible_ = false;
+}
+
+void XScreen::expose(int x, int y, int exp_width, int exp_height)
+{
+       // FIXME: here we should definitely NOT do this.
+       // we need to generate an expose event for the workarea
+       // and then copy from the pixmap to the screen. This
+       // is the Sane Way (tm) 
+       XCopyArea(fl_get_display(),
+                 owner_.getPixmap(),
+                 owner_.getWin(),
+                 gc_copy,
+                 x, y,
+                 exp_width, exp_height,
+                 x + owner_.xpos(),
+                 y + owner_.ypos());
+}
+
+
+void XScreen::draw(LyXText * text, BufferView * bv, unsigned int y)
+{
+       if (cursor_visible_) hideCursor();
+
+       int const old_first = text->first_y;
+       bool internal = (text == bv->text);
+       text->first_y = y;
+
+       // is any optimization possible?
+       if ((y - old_first) < owner_.workHeight()
+           && (old_first - y) < owner_.workHeight())
+       {
+               if (text->first_y < old_first) {
+                       drawFromTo(text, bv, 0,
+                                  old_first - text->first_y, 0, 0, internal);
+                       XCopyArea (fl_get_display(),
+                                  owner_.getWin(),
+                                  owner_.getWin(),
+                                  gc_copy,
+                                  owner_.xpos(),
+                                  owner_.ypos(),
+                                  owner_.workWidth(),
+                                  owner_.workHeight() - old_first + text->first_y,
+                                  owner_.xpos(),
+                                  owner_.ypos() + old_first - text->first_y
+                               );
+                       // expose the area drawn
+                       expose(0, 0,
+                              owner_.workWidth(),
+                              old_first - text->first_y);
+               } else  {
+                       drawFromTo(text, bv,
+                                  owner_.workHeight() + old_first - text->first_y,
+                                  owner_.workHeight(), 0, 0, internal);
+                       XCopyArea (fl_get_display(),
+                                  owner_.getWin(),
+                                  owner_.getWin(),
+                                  gc_copy,
+                                  owner_.xpos(),
+                                  owner_.ypos() + text->first_y - old_first,
+                                  owner_.workWidth(),
+                                  owner_.workHeight() + old_first - text->first_y,
+                                  owner_.xpos(),
+                                  owner_.ypos());
+                       // expose the area drawn
+                       expose(0, owner_.workHeight() + old_first - text->first_y,
+                              owner_.workWidth(), text->first_y - old_first);
+               }
+       } else {
+               // make a dumb new-draw 
+               drawFromTo(text, bv, 0, owner_.workHeight(), 0, 0, internal);
+               expose(0, 0, owner_.workWidth(), owner_.workHeight());
+       }
+
+       XSync(fl_get_display(), 0);
+}
diff --git a/src/frontends/xforms/xscreen.h b/src/frontends/xforms/xscreen.h
new file mode 100644 (file)
index 0000000..2fad257
--- /dev/null
@@ -0,0 +1,75 @@
+// -*- C++ -*-
+/**
+ * \file xscreen.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author unknown
+ * \author John Levon <moz@compsoc.man.ac.uk>
+ */
+
+#ifndef XSCREEN_H
+#define XSCREEN_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <X11/Xlib.h>
+
+#include "screen.h"
+
+#include "XWorkArea.h"
+/** The class XScreen is used for the main Textbody.
+    Concretely, the screen is held in a pixmap.  This pixmap is kept up to
+    date and used to optimize drawing on the screen.
+    This class also handles the drawing of the cursor and partly the selection.
+ */
+class XScreen : public LyXScreen {
+public:
+       ///
+       XScreen(XWorkArea &);
+
+       ///
+       virtual ~XScreen();
+
+       /// Sets the cursor color to LColor::cursor.
+       virtual void setCursorColor();
+       ///
+       virtual void hideCursor();
+       ///
+       virtual void showManualCursor(LyXText const *, int x, int y,
+                             int asc, int desc,
+                             Cursor_Shape shape);
+       
+       /** Draws the screen form textposition y. Uses as much of
+           the already printed pixmap as possible */
+       virtual void draw(LyXText *, BufferView *, unsigned int y);
+
+protected:
+       /// get the work area
+       virtual WorkArea & workarea() const { return owner_; }
+       /// Copies specified area of pixmap to screen
+       virtual void expose(int x, int y, int exp_width, int exp_height); 
+private:
+       /// our owning widget
+       XWorkArea & owner_;
+       ///
+       Pixmap cursor_pixmap;
+       ///
+       int cursor_pixmap_x;
+       ///
+       int cursor_pixmap_y;
+       ///
+       int cursor_pixmap_w;
+       ///
+       int cursor_pixmap_h;
+       ///
+       GC gc_copy;
+};
+
+#endif
index b10409dfebb7756e3d587c931588db205ea9abaa..6a1e3004e5a7e99a9277ee6d6afa3fc0af9638b4 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-15  LyX Development team <lyx@rilke>
+
+       * inset*.[Ch] (docbook): Added new argument to take the pernicious
+       mixed content. Small white spaces clean.
+
 2002-06-14  Angus Leeming  <leeming@lyx.org>
 
        * inseetexternal.C: remove the using std::difftime declaration.
index 3a54462dcfb8a7a22089b3628956f73534a60972..d0f14006f018d7449c70377229d3760f3842a1cf 100644 (file)
@@ -194,7 +194,7 @@ public:
        ///
        virtual int linuxdoc(Buffer const *, std::ostream &) const = 0;
        ///
-       virtual int docbook(Buffer const *, std::ostream &) const = 0;
+       virtual int docbook(Buffer const *, std::ostream &, bool) const = 0;
        /// Updates needed features for this inset.
        virtual void validate(LaTeXFeatures & features) const;
        ///
index f0417a212e650ed2e65f190cc3a577db8b199e4e..494d69bd017af9d3c6d8a27746f0f5e249634c01 100644 (file)
@@ -120,11 +120,11 @@ int InsetCaption::ascii(Buffer const * /*buf*/,
 }
 
 
-int InsetCaption::docbook(Buffer const * buf, ostream & os) const
+int InsetCaption::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
        int ret;
        os << "<title>";
-       ret = InsetText::docbook(buf, os);
+       ret = InsetText::docbook(buf, os, mixcont);
        os << "</title>\n";
        return ret;
 }
index 35da0d33cd6728cb0b833edb2bd11d3a5283a203..b9705f062367356cf4f42f93163a838495c512c1 100644 (file)
@@ -54,7 +54,7 @@ public:
        int ascii(Buffer const * buf, std::ostream & os, int linelen) const;
        ///
        virtual
-       int docbook(Buffer const * buf, std::ostream & os) const;
+       int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const;
 protected:
 private:
 };
index 00b3e869ec6c3ce989ecb5b63d41ecf05bcfa110..b66e5e5e447cbffa910847631dcf8c089b0ac753 100644 (file)
@@ -392,9 +392,9 @@ int InsetCollapsable::linuxdoc(Buffer const * buf, ostream & os) const
 }
 
 
-int InsetCollapsable::docbook(Buffer const * buf, ostream & os) const
+int InsetCollapsable::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
-       return inset.docbook(buf, os);
+       return inset.docbook(buf, os, mixcont);
 }
 
 #if 0
@@ -649,7 +649,8 @@ bool InsetCollapsable::searchForward(BufferView * bv, string const & str,
        bool found = inset.searchForward(bv, str, cs, mw);
        if (first_after_edit && !found)
                close(bv);
-       first_after_edit = false;
+       else if (!found)
+               first_after_edit = false;
        return found;
 }
 
@@ -660,7 +661,8 @@ bool InsetCollapsable::searchBackward(BufferView * bv, string const & str,
        bool found = inset.searchBackward(bv, str, cs, mw);
        if (first_after_edit && !found)
                close(bv);
-       first_after_edit = false;
+       else if (!found)
+               first_after_edit = false;
        return found;
 }
 
index d3dc3945ef5ca0ac356855ac53c3d1690d1c5748..a86e00df5b281127499692e215e7de3f03ce8d97 100644 (file)
@@ -105,7 +105,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
index 6fe86786abfe314bcace60e5c8a1b4fe4d4ab05e..dd1b3afac8696743da276bf6fb50420f020e6416 100644 (file)
@@ -213,7 +213,7 @@ int InsetCommand::linuxdoc(Buffer const *, ostream &) const
 }
 
 
-int InsetCommand::docbook(Buffer const *, ostream &) const
+int InsetCommand::docbook(Buffer const *, ostream &, bool) const
 {
        return 0;
 }
index d010017f5d99bbe164bea83d36f0d1e5680f8289..466bef87f605591796e8352c2c5cd062543d7767 100644 (file)
@@ -97,7 +97,7 @@ public:
        ///
        virtual int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       virtual int docbook(Buffer const *, std::ostream &) const;
+       virtual int docbook(Buffer const *, std::ostream &, bool) const;
        ///
        Inset::Code lyxCode() const { return Inset::NO_CODE; }
 
index f30b90a250301c87bc74d2800f0f4b58f64d4af2..b7a817214134aca4942904d3a52319ca5e731bc6 100644 (file)
@@ -52,7 +52,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
        ///
-       int docbook(Buffer const *, std::ostream &) const { return 0; }
+       int docbook(Buffer const *, std::ostream &, bool) const { return 0; }
        ///
        bool autoDelete() const { return true; }
        /// what appears in the minibuffer when opening
index 7bd95628797842b7c38e907b7bcc53ff5701e92e..cb009011b89582558000436d3904c65eaa01bfb0 100644 (file)
@@ -414,7 +414,7 @@ int InsetERT::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetERT::docbook(Buffer const *, ostream & os) const
+int InsetERT::docbook(Buffer const *, ostream & os, bool) const
 {
        Paragraph * par = inset.paragraph();
        int lines = 0;
index 8aaf1310cc97543076bf75d65a7b404f75207d68..4675049f8ec3a513926642c4b1198c326f92d03d 100644 (file)
@@ -90,7 +90,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures &) const {}
        ///
index fdfe4a287bfb8e45fad9e0d28f883a6b87fefcb9..cc66ca3b20e6b351f32912aa2357c7676e110389 100644 (file)
@@ -171,7 +171,7 @@ int InsetExternal::linuxdoc(Buffer const * buf, ostream & os) const
 }
 
 
-int InsetExternal::docbook(Buffer const * buf, ostream & os) const
+int InsetExternal::docbook(Buffer const * buf, ostream & os, bool) const
 {
        return write("DocBook", buf, os);
 }
index c0a605b804307cf1b09f32fd7b0dd791aa9c183d..cc3376cc53dd756a30fdfc9f726e3e5bcdf1c1eb 100644 (file)
@@ -68,7 +68,7 @@ public:
        /// write LinuxDoc output to the ostream
        virtual int linuxdoc(Buffer const *, std::ostream &) const;
        /// write DocBook output to the ostream
-       virtual int docbook(Buffer const *, std::ostream &) const;
+       virtual int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 
        /// Updates needed features for this inset.
        virtual void validate(LaTeXFeatures & features) const;
index cc733c4226cc621de6caceb94f4fec0dee0a9138..7882fe3348a1e8a4dd5cc65aed127652c0671377 100644 (file)
@@ -259,10 +259,10 @@ int InsetFloat::latex(Buffer const * buf,
 }
 
 
-int InsetFloat::docbook(Buffer const * buf, ostream & os) const
+int InsetFloat::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
        os << "<" << floatType_ << ">";
-       int const i = inset.docbook(buf, os);
+       int const i = inset.docbook(buf, os, mixcont);
        os << "</" << floatType_ << ">";
 
        return i;
index af3f724d5098fb8b4b73ca5eef019c45b446d658..81ab93538cc9222b74054a60f325ed46e6b8e84e 100644 (file)
@@ -46,7 +46,7 @@ public:
        ///
        int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        string const editMessage() const;
        ///
index 19b03e8dbefff46f674f66453670a66460a497c9..fe10608006506976c5950e602b26f75ce52fa0d9 100644 (file)
@@ -51,7 +51,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
        ///
-       int docbook(Buffer const *, std::ostream &) const { return 0; }
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const { return 0; }
        ///
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
index 28ee366ce0b394fb147ab7af28296eb67ba51b5a..91f45fb071fccab38cf20cbf31c293517c323911 100644 (file)
@@ -79,10 +79,10 @@ int InsetFoot::latex(Buffer const * buf,
 }
 
 
-int InsetFoot::docbook(Buffer const * buf, ostream & os) const
+int InsetFoot::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
        os << "<footnote>";
-       int const i = inset.docbook(buf, os);
+       int const i = inset.docbook(buf, os, mixcont);
        os << "</footnote>";
 
        return i;
index e20155a7773227d0c3b6821cede0e1500397a780..a5198f1f5e6eb1451455f10904427006a255d9b5 100644 (file)
@@ -37,7 +37,7 @@ public:
        ///
        int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        string const editMessage() const;
 };
index 2f58bbe252eba6e9657925137daf0a7394607f3c..601d76173619c27d56ceda38de1a8920b0cb5800 100644 (file)
@@ -810,7 +810,7 @@ int InsetGraphics::linuxdoc(Buffer const *, ostream &) const
 // For explanation on inserting graphics into DocBook checkout:
 // http://linuxdoc.org/LDP/LDP-Author-Guide/inserting-pictures.html
 // See also the docbook guide at http://www.docbook.org/
-int InsetGraphics::docbook(Buffer const *, ostream & os) const
+int InsetGraphics::docbook(Buffer const *, ostream & os, bool mixcont) const
 {
        // In DocBook v5.0, the graphic tag will be eliminated from DocBook, will
        // need to switch to MediaObject. However, for now this is sufficient and
index d3e04cf76b2f44f69d28b153efc6af2d72f37631..7aa5967d37220aac40c167ea10ed71527049629f 100644 (file)
@@ -70,7 +70,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 
        /** Tell LyX what the latex features you need i.e. what latex packages
            you need to be included.
index 008d510e0dfecae68a69ba175d5574cd83f17ef3..844d6d3cada3389d6f2f691fc92374ed49862c9e 100644 (file)
@@ -342,7 +342,7 @@ int InsetInclude::linuxdoc(Buffer const * buffer, ostream & os) const
 }
 
 
-int InsetInclude::docbook(Buffer const * buffer, ostream & os) const
+int InsetInclude::docbook(Buffer const * buffer, ostream & os, bool mixcont) const
 {
        string incfile(params_.cparams.getContents());
 
index 9aed79b72bf9b6013829448e171689f36743be29..106765ed4ec23f0e4dc26f3f35e237fcf19c233a 100644 (file)
@@ -99,7 +99,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures &) const;
 
index 1e5e2c6de32d8f2183ed240ba90bb989dc00eb19..3f66ba35099361f26ca409a3f562f186ed3762bd 100644 (file)
@@ -37,7 +37,7 @@ void InsetIndex::edit(BufferView * bv, bool)
 }
 
 
-int InsetIndex::docbook(Buffer const *, ostream & os) const
+int InsetIndex::docbook(Buffer const *, ostream & os, bool) const
 {
        os << "<indexterm><primary>" << getContents()
           << "</primary></indexterm>";
index 32b0e2a905028e0e1b658ec2853ce52e473de826..dfd8304a6809ffa28b756eff96e8348107c5e5ed 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        Inset::Code lyxCode() const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 };
 
 
index f3126eaa38ba92c3ac12b0431ef356cacff5573e..9c0167f39fd85a4c1638d756a37c4003b1ca8962 100644 (file)
@@ -95,7 +95,7 @@ int InsetLabel::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetLabel::docbook(Buffer const *, ostream & os) const
+int InsetLabel::docbook(Buffer const *, ostream & os, bool) const
 {
        os << "<anchor id=\"" << getContents() << "\">";
        return 0;
index 823bf73071cd106be0a825a547bc011797d05c3f..16b1e094ec6dc83de6742ae526a0af1e30a6bc01 100644 (file)
@@ -46,7 +46,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 };
 
 #endif
index 31834610a7615a041a6dd3c76e32d1f6813f6825..572538bdac8d30c143237c0dcfaac1ba71449704 100644 (file)
@@ -655,7 +655,7 @@ int InsetLatexAccent::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetLatexAccent::docbook(Buffer const *, ostream & os) const
+int InsetLatexAccent::docbook(Buffer const *, ostream & os, bool) const
 {
        os << contents;
        return 0;
index a314e6500b018137910a596b3b42d38bf1cde9db..8e80c56e591debcf1376057e118525192909157a 100644 (file)
@@ -61,7 +61,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        bool deletable() const;
        ///
index 2c20a8e8996623a45000348f011b7e48a7ea7459..ca75cade0151be97542fb5bec84f241f77df09cc 100644 (file)
@@ -44,7 +44,7 @@ public:
        int linuxdoc(Buffer const *, std::ostream &) const
                { return 0; }
        ///
-       int docbook(Buffer const *, std::ostream &) const
+       int docbook(Buffer const *, std::ostream &, bool) const
                { return 0; }
        ///
        int ascii(Buffer const *, std::ostream &, int) const
index 051b12a7916de846449b031f194102097f6c27ef..ce24a655d713c01b1c42fe32a2cbdc5f7ff0413a 100644 (file)
@@ -325,7 +325,7 @@ int InsetQuotes::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetQuotes::docbook(Buffer const *, ostream & os) const
+int InsetQuotes::docbook(Buffer const *, ostream & os, bool) const
 {
        if (times_ == DoubleQ) {
                if (side_ == LeftQ)
index 7fe44c073000146344ba0fa3e946847b9b62bbbc..44a5565add152a2291296aa444b1948c51da319a 100644 (file)
@@ -96,7 +96,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures &) const;
        ///
index 0f39f93b8456df8eec6b0184e75daf64412148b2..826de684007fb6188dc8d5db6a4d9c699792da31 100644 (file)
@@ -85,7 +85,7 @@ int InsetRef::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetRef::docbook(Buffer const *, ostream & os) const
+int InsetRef::docbook(Buffer const *, ostream & os, bool) const
 {
        if (getOptions().empty()) {
                os << "<xref linkend=\"" << getContents() << "\">";
index 45c09a22701a6a3e4e0253dea1f2b1aa363e2070..cbf6a6f5f1be26d15b3e54aae55e997d6c6939ff 100644 (file)
@@ -63,7 +63,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures & features) const;
 private:
index 1d727042f9638005978a1d5b06119dee40841af8..0feb09eee1ec28d861dbe5402473986fb82e969f 100644 (file)
@@ -287,7 +287,7 @@ int InsetSpecialChar::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetSpecialChar::docbook(Buffer const *, ostream & os) const
+int InsetSpecialChar::docbook(Buffer const *, ostream & os, bool) const
 {
        switch (kind_) {
        case HYPHENATION:
index 1f0547d44455a4d46adeeb1f508932acd2423b06..d8d00452b0186c8774165efd55dbd8fcc7ecac03 100644 (file)
@@ -67,7 +67,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        virtual Inset * clone(Buffer const &, bool same_id = false) const;
        ///
index 194b18401af0f938909d0a865cad3994eaac9853..39138732feb10d92303748b8b8d9a322f7596993 100644 (file)
@@ -146,7 +146,7 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
        clearSelection();
        need_update = INIT;
        in_update = false;
-       in_reset_pos = false;
+       in_reset_pos = 0;
        inset_x = 0;
        inset_y = 0;
 }
@@ -166,7 +166,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf,
        clearSelection();
        need_update = INIT;
        in_update = false;
-       in_reset_pos = false;
+       in_reset_pos = 0;
        inset_x = 0;
        inset_y = 0;
 }
@@ -603,6 +603,7 @@ void InsetTabular::insetUnlock(BufferView * bv)
                the_locking_inset = 0;
        }
        hideInsetCursor(bv);
+       actcell = 0;
        oldcell = -1;
        locked = false;
        if (scroll(false) || hasSelection()) {
@@ -626,15 +627,10 @@ void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
                what = FULL;
        if (need_update < what) // only set this if it has greater update
                need_update = what;
-#if 0 // maybe this should not be done!
-       if ((what == INIT) && hasSelection()) {
-               clearSelection();
-       }
-#endif
        // Dirty Cast! (Lgb)
        if (need_update != NONE) {
                bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
-               if (locked) // && (what != NONE))
+               if (locked)
                        resetPos(bv);
        }
 }
@@ -1317,7 +1313,7 @@ int InsetTabular::linuxdoc(Buffer const * buf, ostream & os) const
 }
 
 
-int InsetTabular::docbook(Buffer const * buf, ostream & os) const
+int InsetTabular::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
        int ret = 0;
        Inset * master;
@@ -1329,12 +1325,16 @@ int InsetTabular::docbook(Buffer const * buf, ostream & os) const
            master = master->owner());
 
        if (!master) {
-               os << "<informaltable>\n";
+               os << "<informaltable>";
+               if (mixcont)
+                       os << endl;
                ret++;
        }
-       ret+= tabular->docBook(buf,os);
+       ret+= tabular->docbook(buf, os, mixcont);
        if (!master) {
-               os << "</informaltable>\n";
+               os << "</informaltable>";
+               if (mixcont)
+                       os << endl;
                ret++;
        }
        return ret;
@@ -1526,7 +1526,7 @@ void InsetTabular::resetPos(BufferView * bv) const
 #warning This should be fixed in the right manner (20011128 Jug)
 #endif
        // fast hack to fix infinite repaintings!
-       if (in_reset_pos)
+       if (in_reset_pos > 10)
                return;
 
        int cell = 0;
@@ -1547,7 +1547,7 @@ void InsetTabular::resetPos(BufferView * bv) const
                return;
        }
        // we need this only from here on!!!
-       in_reset_pos = true;
+       ++in_reset_pos;
        static int const offset = ADD_TO_TABULAR_WIDTH + 2;
        int new_x = getCellXPos(actcell);
        int old_x = cursor_.x();
@@ -1598,7 +1598,7 @@ void InsetTabular::resetPos(BufferView * bv) const
                bv->owner()->getDialogs()->updateTabular(inset);
                oldcell = actcell;
        }
-       in_reset_pos = false;
+       in_reset_pos = 0;
 }
 
 
@@ -2738,56 +2738,45 @@ void InsetTabular::toggleSelection(BufferView * bv, bool kill_selection)
 bool InsetTabular::searchForward(BufferView * bv, string const & str,
                                 bool cs, bool mw)
 {
-       nodraw(true);
        if (the_locking_inset) {
                if (the_locking_inset->searchForward(bv, str, cs, mw)) {
-                       nodraw(false);
                        updateLocal(bv, CELL, false);
                        return true;
                }
-               if (tabular->IsLastCell(actcell)) {
-                       nodraw(false);
-                       bv->unlockInset(const_cast<InsetTabular *>(this));
-                       return false;
+       }
+       do {
+               InsetText * inset = tabular->GetCellInset(actcell);
+               if (inset->searchForward(bv, str, cs, mw)) {
+                       updateLocal(bv, FULL, false);
+                       return true;
                }
                ++actcell;
-       }
-       // otherwise we have to lock the next inset and search there
-       UpdatableInset * inset =
-               static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
-       inset->edit(bv);
-       bool const ret = searchForward(bv, str, cs, mw);
-       nodraw(false);
-       updateLocal(bv, CELL, false);
-       return ret;
+       } while (!tabular->IsLastCell(actcell));
+       return false;
 }
 
 
 bool InsetTabular::searchBackward(BufferView * bv, string const & str,
                               bool cs, bool mw)
 {
-       nodraw(true);
        if (the_locking_inset) {
                if (the_locking_inset->searchBackward(bv, str, cs, mw)) {
-                       nodraw(false);
                        updateLocal(bv, CELL, false);
                        return true;
                }
-               if (!actcell) { // we are already in the first cell
-                       nodraw(false);
-                       bv->unlockInset(const_cast<InsetTabular *>(this));
-                       return false;
-               }
+       }
+       if (!locked)
+               actcell = tabular->GetNumberOfCells();
+
+       while (actcell) {
                --actcell;
+               InsetText * inset = tabular->GetCellInset(actcell);
+               if (inset->searchBackward(bv, str, cs, mw)) {
+                       updateLocal(bv, CELL, false);
+                       return true;
+               }
        }
-       // otherwise we have to lock the next inset and search there
-       UpdatableInset * inset =
-               static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
-       inset->edit(bv, false);
-       bool const ret = searchBackward(bv, str, cs, mw);
-       nodraw(false);
-       updateLocal(bv, CELL, false);
-       return ret;
+       return false;
 }
 
 
index 2d23930560f8e122192f0e917d10c1936610d13c..5014ab164116af8282f24b6f619f838d14dacccc 100644 (file)
@@ -147,7 +147,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
@@ -352,6 +352,6 @@ private:
        ///
        bool in_update;
        ///
-       mutable bool in_reset_pos;
+       mutable int in_reset_pos;
 };
 #endif
index 636f981dae1bc49dd3d24701b6f9415314f97c4b..a3ed108ea85f3509b83267e0e8cd3adcc9810948 100644 (file)
@@ -1212,19 +1212,26 @@ InsetText::localDispatch(BufferView * bv,
                                }
                                break;
                        case FINISHED_DOWN:
-                               if ((result = moveDown(bv)) >= FINISHED) {
+                       {
+                               LyXText *lt = getLyXText(bv);
+                               if (lt->cursor.irow()->next()) {
+                                       lt->setCursorFromCoordinates(
+                                               bv, lt->cursor.ix() + inset_x,
+                                               lt->cursor.iy() -
+                                               lt->cursor.irow()->baseline() +
+                                               lt->cursor.irow()->height() + 1);
+                                       lt->cursor.x_fix(lt->cursor.x());
                                        updateLocal(bv, CURSOR, false);
+                               } else {
                                        bv->unlockInset(this);
                                }
+                       }
                                break;
                        default:
                                result = DISPATCHED;
                                break;
                        }
                        the_locking_inset = 0;
-#ifdef WITH_WARNINGS
-#warning I changed this to always return Dispatched maybe it is wrong (20011001 Jug)
-#endif
                        updateLocal(bv, CURSOR, false);
                        return result;
                }
@@ -1261,7 +1268,8 @@ InsetText::localDispatch(BufferView * bv,
                        }
                        lt->clearSelection();
                        for (string::size_type i = 0; i < arg.length(); ++i) {
-                               bv->owner()->getIntl()->getTrans().TranslateAndInsert(arg[i], lt);
+                               bv->owner()->getIntl()->getTransManager().
+                                       TranslateAndInsert(arg[i], lt);
                        }
                }
                lt->selection.cursor = lt->cursor;
@@ -1568,7 +1576,7 @@ int InsetText::ascii(Buffer const * buf, ostream & os, int linelen) const
 }
 
 
-int InsetText::docbook(Buffer const * buf, ostream & os) const
+int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
        Paragraph * p = par;
        unsigned int lines = 0;
@@ -1592,14 +1600,11 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                for (; depth > p->params().depth(); --depth) {
                        if (environment_inner[depth] != "!-- --") {
                                item_name = "listitem";
-                               buf->sgmlCloseTag(os, command_depth + depth,
-                                            item_name);
+                               lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
                                if (environment_inner[depth] == "varlistentry")
-                                       buf->sgmlCloseTag(os, depth+command_depth,
-                                                    environment_inner[depth]);
+                                       lines += buf->sgmlCloseTag(os, depth+command_depth, mixcont, environment_inner[depth]);
                        }
-                       buf->sgmlCloseTag(os, depth + command_depth,
-                                    environment_stack[depth]);
+                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
                        environment_stack[depth].erase();
                        environment_inner[depth].erase();
                }
@@ -1609,16 +1614,12 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                   && !environment_stack[depth].empty()) {
                        if (environment_inner[depth] != "!-- --") {
                                item_name= "listitem";
-                               buf->sgmlCloseTag(os, command_depth+depth,
-                                                 item_name);
+                               lines += buf->sgmlCloseTag(os, command_depth+depth, mixcont, item_name);
                                if (environment_inner[depth] == "varlistentry")
-                                       buf->sgmlCloseTag(os,
-                                                         depth + command_depth,
-                                                         environment_inner[depth]);
+                                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
                        }
 
-                       buf->sgmlCloseTag(os, depth + command_depth,
-                                         environment_stack[depth]);
+                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
 
                        environment_stack[depth].erase();
                        environment_inner[depth].erase();
@@ -1627,13 +1628,11 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                // Write opening SGML tags.
                switch (style.latextype) {
                case LATEX_PARAGRAPH:
-                       buf->sgmlOpenTag(os, depth + command_depth,
-                                        style.latexname());
+                       lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style.latexname());
                        break;
 
                case LATEX_COMMAND:
-                       buf->sgmlError(p, 0,
-                                      _("Error : LatexType Command not allowed here.\n"));
+                       buf->sgmlError(p, 0,  _("Error : LatexType Command not allowed here.\n"));
                        return -1;
                        break;
 
@@ -1651,18 +1650,13 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                                }
                                environment_stack[depth] = style.latexname();
                                environment_inner[depth] = "!-- --";
-                               buf->sgmlOpenTag(os, depth + command_depth,
-                                                environment_stack[depth]);
+                               lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, environment_stack[depth]);
                        } else {
                                if (environment_inner[depth] != "!-- --") {
                                        item_name= "listitem";
-                                       buf->sgmlCloseTag(os,
-                                                         command_depth + depth,
-                                                         item_name);
+                                       lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
                                        if (environment_inner[depth] == "varlistentry")
-                                               buf->sgmlCloseTag(os,
-                                                                 depth + command_depth,
-                                                                 environment_inner[depth]);
+                                               lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
                                }
                        }
 
@@ -1671,40 +1665,26 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                                        if (style.latexparam() == "CDATA")
                                                os << "<![CDATA[";
                                        else
-                                               buf->sgmlOpenTag(os, depth + command_depth,
-                                                                style.latexparam());
+                                         lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style.latexparam());
                                }
                                break;
                        }
 
                        desc_on = (style.labeltype == LABEL_MANUAL);
 
-                       if (desc_on)
-                               environment_inner[depth]= "varlistentry";
-                       else
-                               environment_inner[depth]= "listitem";
+                       environment_inner[depth] = desc_on?"varlistentry":"listitem";
+                       lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, environment_inner[depth]);
 
-                       buf->sgmlOpenTag(os, depth + 1 + command_depth,
-                                        environment_inner[depth]);
+                       item_name = desc_on?"term":"para";
+                       lines += buf->sgmlOpenTag(os, depth + 1 + command_depth, mixcont, item_name);
 
-                       if (desc_on) {
-                               item_name= "term";
-                               buf->sgmlOpenTag(os, depth + 1 + command_depth,
-                                                item_name);
-                       } else {
-                               item_name= "para";
-                               buf->sgmlOpenTag(os, depth + 1 + command_depth,
-                                                item_name);
-                       }
                        break;
                default:
-                       buf->sgmlOpenTag(os, depth + command_depth,
-                                        style.latexname());
+                       lines += buf->sgmlOpenTag(os, depth + command_depth, mixcont, style.latexname());
                        break;
                }
 
-               buf->simpleDocBookOnePar(os, p, desc_on,
-                                        depth + 1 + command_depth);
+               buf->simpleDocBookOnePar(os, p, desc_on, depth + 1 + command_depth);
                p = p->next();
 
                string end_tag;
@@ -1715,20 +1695,19 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                                if (style.latexparam() == "CDATA")
                                        os << "]]>";
                                else
-                                       buf->sgmlCloseTag(os, depth + command_depth,
-                                                         style.latexparam());
+                                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style.latexparam());
                        }
                        break;
                case LATEX_ITEM_ENVIRONMENT:
                        if (desc_on == 1) break;
                        end_tag= "para";
-                       buf->sgmlCloseTag(os, depth + 1 + command_depth, end_tag);
+                       lines += buf->sgmlCloseTag(os, depth + 1 + command_depth, mixcont, end_tag);
                        break;
                case LATEX_PARAGRAPH:
-                       buf->sgmlCloseTag(os, depth + command_depth, style.latexname());
+                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style.latexname());
                        break;
                default:
-                       buf->sgmlCloseTag(os, depth + command_depth, style.latexname());
+                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, style.latexname());
                        break;
                }
        }
@@ -1738,15 +1717,12 @@ int InsetText::docbook(Buffer const * buf, ostream & os) const
                if (!environment_stack[depth].empty()) {
                        if (environment_inner[depth] != "!-- --") {
                                item_name = "listitem";
-                               buf->sgmlCloseTag(os, command_depth + depth,
-                                                 item_name);
+                               lines += buf->sgmlCloseTag(os, command_depth + depth, mixcont, item_name);
                               if (environment_inner[depth] == "varlistentry")
-                                      buf->sgmlCloseTag(os, depth + command_depth,
-                                                        environment_inner[depth]);
+                                      lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_inner[depth]);
                        }
 
-                       buf->sgmlCloseTag(os, depth + command_depth,
-                                         environment_stack[depth]);
+                       lines += buf->sgmlCloseTag(os, depth + command_depth, mixcont, environment_stack[depth]);
                }
        }
 
@@ -2682,53 +2658,66 @@ void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
 bool InsetText::searchForward(BufferView * bv, string const & str,
                              bool cs, bool mw)
 {
+       bool clear = false;
+       if (!lt) {
+               lt = getLyXText(bv);
+               clear = true;
+       }
        if (the_locking_inset) {
                if (the_locking_inset->searchForward(bv, str, cs, mw))
                        return true;
-               bool clear = false;
-               if (!lt) {
-                       lt = getLyXText(bv);
-                       clear = true;
-               }
-               Paragraph * lpar = lt->cursor.par();
-               pos_type pos = lt->cursor.pos();
-               if (pos < lpar->size() - 1)
-                       ++pos;
-               else {
-                       pos = 0;
-                       lpar = lpar->next();
-               }
-               if (!lpar) {
-                       if (clear)
-                               lt = 0;
-                       // we have to unlock ourself in this function by default!
-                       bv->unlockInset(const_cast<InsetText *>(this));
-                       return false;
-               }
-               lt->setCursor(bv, lpar, pos);
-               if (clear)
-                       lt = 0;
-       }
-       if (LyXFind(bv, str, true, true, cs , mw)) {
-               return true;
+               lt->cursorRight(bv, true);
+       }
+       lyxfind::SearchResult result =
+               lyxfind::LyXFind(bv, lt, str, true, cs, mw);
+
+       if (result == lyxfind::SR_FOUND) {
+               LyXCursor cur = lt->cursor;
+               bv->unlockInset(bv->theLockingInset());
+               if (bv->lockInset(this))
+                       locked = true;
+               lt->cursor = cur;
+               lt->setSelectionOverString(bv, str);
+               updateLocal(bv, SELECTION, false);
        }
-       // we have to unlock ourself in this function by default!
-       bv->unlockInset(const_cast<InsetText *>(this));
-       return false;
+       if (clear)
+               lt = 0;
+       return (result != lyxfind::SR_NOT_FOUND);
 }
 
 bool InsetText::searchBackward(BufferView * bv, string const & str,
                               bool cs, bool mw)
 {
-       if (the_locking_inset)
+       if (the_locking_inset) {
                if (the_locking_inset->searchBackward(bv, str, cs, mw))
                        return true;
-       if (LyXFind(bv, str, false, true, cs, mw)) {
-               return true;
        }
-       // we have to unlock ourself in this function by default!
-       bv->unlockInset(const_cast<InsetText *>(this));
-       return false;
+       bool clear = false;
+       if (!lt) {
+               lt = getLyXText(bv);
+               clear = true;
+       }
+       if (!locked) {
+               Paragraph * p = par;
+               while (p->next())
+                       p = p->next();
+               lt->setCursor(bv, p, p->size());
+       }
+       lyxfind::SearchResult result =
+               lyxfind::LyXFind(bv, lt, str, false, cs, mw);
+
+       if (result == lyxfind::SR_FOUND) {
+               LyXCursor cur = lt->cursor;
+               bv->unlockInset(bv->theLockingInset());
+               if (bv->lockInset(this))
+                       locked = true;
+               lt->cursor = cur;
+               lt->setSelectionOverString(bv, str);
+               updateLocal(bv, SELECTION, false);
+       }
+       if (clear)
+               lt = 0;
+       return (result != lyxfind::SR_NOT_FOUND);
 }
 
 
index 9655cec4b72251487e91194a987465da4c58c4e6..fefd364ff8676132dd0b99daeb8f9fb12f9a0fd1 100644 (file)
@@ -139,7 +139,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const { return 0; }
        ///
-       int docbook(Buffer const *, std::ostream &) const ;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const ;
        ///
        void validate(LaTeXFeatures & features) const;
        ///
index b2385abd8b316a02bf44da18e8c2b3e47f6b9392..77153639fe5b39b0eef27d1a6a3f9f6582dc8373 100644 (file)
@@ -80,7 +80,7 @@ int InsetTOC::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetTOC::docbook(Buffer const *, ostream & os) const
+int InsetTOC::docbook(Buffer const *, ostream & os, bool) const
 {
        if (getCmdName() == "tableofcontents")
                os << "<toc></toc>";
index 26d75935a3554c55d95c7be6a5b5f2dc8cd76557..6b8d542c5a097f83826b8b802f787a120c751c23 100644 (file)
@@ -46,7 +46,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 };
 
 #endif
index 4a61ad859380745ed08188f93af02a4550fb7fd8..f214d7c904c8ca0874659397dbd98d5cd0498bbd 100644 (file)
@@ -82,7 +82,7 @@ int InsetUrl::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetUrl::docbook(Buffer const *, ostream & os) const
+int InsetUrl::docbook(Buffer const *, ostream & os, bool) const
 {
        os << "<ulink url=\"" << subst(getContents(),"&","&amp;")
           << "\">" << getOptions() << "</ulink>";
index f99d63244e9ff3bae295531e29efe30432fe51f4..e6f433102518682aad0bc2e414ef539e4ee8cdca 100644 (file)
@@ -52,7 +52,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 };
 
 #endif
index e2dfad5922881dbc3496b0f80dceea326722e095..0e27b76d9908a0178bd68619cb78bb5f5540daeb 100644 (file)
@@ -50,7 +50,7 @@ public:
        void InitKeyMapper(bool on);
 
        // Get the Translation Manager
-       TransManager & getTrans();
+       TransManager & getTransManager();
 
        /// using primary or secondary keymap ?
        Keymap keymap;
@@ -68,7 +68,7 @@ private:
 
 
 inline
-TransManager & Intl::getTrans()
+TransManager & Intl::getTransManager()
 {
        return trans;
 }
index 8849e36ed0072be1e8e8af0ffc84b9d9b80605e8..ee1e298527dd76f395aa26d4fd6ad19589f2789f 100644 (file)
 #include "kbsequence.h"
 #include "debug.h"
 
-#include <X11/Xlib.h>
-
 using std::endl;
 
-// The only modifiers that we handle. We want to throw away things
-// like NumLock.
-enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-
-
-string const kb_keymap::printKeysym(unsigned int key, key_modifier::state mod)
+string const kb_keymap::printKeysym(LyXKeySymPtr key,
+                                   key_modifier::state mod)
 {
        string buf;
 
-       char const * const s = XKeysymToString(key);
+       string const s = key->getSymbolName();
 
        if (mod & key_modifier::shift) buf += "S-";
        if (mod & key_modifier::ctrl) buf += "C-";
        if (mod & key_modifier::alt) buf += "M-";
-       if (s) buf += s;
+       buf += s;
        return buf;
 }
 
-
-char kb_keymap::getiso(unsigned int c)
-{
-       switch (c & 0x0000FF00) {
-               // latin 1 byte 3 = 0
-       case 0x00000000: break;
-               // latin 2 byte 3 = 1
-       case 0x00000100:
-               // latin 3 byte 3 = 2
-       case 0x00000200:
-               // latin 4 byte 3 = 3
-       case 0x00000300:
-               // cyrillic KOI8 & Co
-       case 0x00000600:
-               // greek
-       case 0x00000700:
-               // latin 8 byte 3 = 18 (0x12)
-       case 0x00001200:
-               // latin 9 byte 3 = 19 (0x13)
-       case 0x00001300:
-               c &= 0x000000FF;
-               break;
-       default:
-               c = 0;
-       }
-       return c;
-}
-
 string const kb_keymap::printKey(kb_key const & key) const
 {
        return printKeysym(key.code, key.mod.first);
@@ -97,7 +63,7 @@ string::size_type kb_keymap::bind(string const & seq, int action)
 }
 
 
-int kb_keymap::lookup(unsigned int key,
+int kb_keymap::lookup(LyXKeySymPtr key,
                      key_modifier::state mod, kb_sequence * seq) const
 {
        if (table.empty()) {
@@ -112,7 +78,7 @@ int kb_keymap::lookup(unsigned int key,
                key_modifier::state check =
                        static_cast<key_modifier::state>(mod & ~mask);
  
-               if (cit->code == key && cit->mod.first == check) {
+               if (*(cit->code) == *(key) && cit->mod.first == check) {
                        // match found
                        if (cit->table.get()) {
                                // this is a prefix key - set new map
@@ -148,15 +114,17 @@ string const kb_keymap::print() const
 
 void kb_keymap::defkey(kb_sequence * seq, int action, unsigned int r)
 {
-       unsigned int const code = seq->sequence[r];
-       if (code == NoSymbol) return;
+       LyXKeySymPtr code = seq->sequence[r];
+       if ( ! code->isOK() ) return;
 
        key_modifier::state const mod1 = seq->modifiers[r].first;
        key_modifier::state const mod2 = seq->modifiers[r].second;
 
        // check if key is already there
        for (Table::iterator it = table.begin(); it != table.end(); ++it) {
-               if (code == it->code && mod1 == it->mod.first && mod2 == it->mod.second) {
+               if (*(code) == *(it->code)
+                   && mod1 == it->mod.first
+                   && mod2 == it->mod.second) {
                        // overwrite binding
                        if (r + 1 == seq->length()) {
                                lyxerr[Debug::KBMAP]
index 390d63c2057cddc496eca093247479c54a15e987..482ab6c10db3d21f2e081363c2f193bff9e8da19 100644 (file)
@@ -17,8 +17,7 @@
 
 #include "LString.h"
 #include "frontends/key_state.h"
-
-#include <boost/shared_ptr.hpp>
+#include "frontends/LyXKeySym.h"
 
 #include <list>
 
@@ -31,6 +30,7 @@ public:
         * Bind a key sequence to an action.
         * @return 0 on success, or position in string seq where error
         * occurs.
+        * See kb_sequence::parse for the syntax of the seq string
         */
        string::size_type bind(string const & seq, int action);
 
@@ -44,7 +44,7 @@ public:
         * @param seq the current key sequence so far
         * @return the action / LFUN_PREFIX / LFUN_UNKNOWN_ACTION
         */
-       int lookup(unsigned int key,
+       int lookup(LyXKeySymPtr key,
                   key_modifier::state mod, kb_sequence * seq) const;
 
        /// Given an action, find all keybindings.
@@ -53,13 +53,11 @@ public:
 
        /**
         * Returns a string of the given keysym, with modifiers.
-        * @param key the key
+        * @param key the key as a keysym
         * @param mod the modifiers
         */
-       static string const printKeysym(unsigned int key, key_modifier::state mod);
-
-       /// return the ISO value of a keysym
-       static char getiso(unsigned int i);
+       static string const printKeysym(LyXKeySymPtr key,
+                                       key_modifier::state mod);
 
        typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
 
@@ -67,7 +65,7 @@ private:
        ///
        struct kb_key {
                /// Keysym
-               unsigned int code;
+               LyXKeySymPtr code;
 
                /// Modifier masks
                modifier_pair mod;
@@ -79,7 +77,6 @@ private:
                int action;
        };
 
-
        /**
         * Define an action for a key sequence.
         * @param r internal recursion level
index b3865a1a65ef6904c4f31ca729afa91673132ebd..cdffe37a661114b71ae220b4708e53910607627e 100644 (file)
 #endif
 
 #include "frontends/mouse_state.h"
+#include "frontends/LyXKeySymFactory.h"
 #include "kbsequence.h"
 #include "kbmap.h"
 #include "commandtags.h"
 #include "debug.h"
 
-#include <X11/Xlib.h>
-
 using std::make_pair;
 using std::vector;
 using std::endl;
@@ -29,25 +28,20 @@ using std::hex;
 using std::dec;
 
 
-// The only modifiers that we handle. We want to throw away things
-// like NumLock.
-enum { ModsMask = ShiftMask | ControlMask | Mod1Mask };
-
 
-int kb_sequence::addkey(unsigned int key, key_modifier::state mod, key_modifier::state nmod)
+int kb_sequence::addkey(LyXKeySymPtr key,
+                       key_modifier::state mod, key_modifier::state nmod)
 {
        // adding a key to a deleted sequence
        // starts a new sequence
        if (deleted_) {
                deleted_ = false;
-               length_ = 0;
                sequence.clear();
                modifiers.clear();
        }
 
        modifiers.push_back(make_pair(mod, nmod));
        sequence.push_back(key);
-       ++length_;
 
        if (curmap) {
                return curmap->lookup(key, mod, this);
@@ -112,13 +106,13 @@ string::size_type kb_sequence::parse(string const & s)
                        for (; j < s.length() && s[j] != ' '; ++j)
                                tbuf += s[j];    // (!!!check bounds :-)
 
-                       KeySym key = XStringToKeysym(tbuf.c_str());
-                       if (key == NoSymbol) {
-                               lyxerr[Debug::KBMAP]
-                                       << "kbmap.C: No such keysym: "
-                                       << tbuf << endl;
+                       LyXKeySymPtr key(LyXKeySymFactory::create());
+                       key->init(tbuf);
+                       
+                       if ( ! key->isOK() ) {
                                return j;
                        }
+
                        i = j;
 
                        addkey(key, mod, nmod);
@@ -127,7 +121,7 @@ string::size_type kb_sequence::parse(string const & s)
        }
 
        // empty sequence?
-       if (!length_)
+       if (sequence.size() == 0)
                return 0;
 
        // everything is fine
@@ -142,11 +136,13 @@ string const kb_sequence::print() const
        //if (deleted_)
        //      return buf;
 
-       for (vector<unsigned int>::size_type i = 0; i < length_; ++i) {
+       KeySequence::size_type i, length = sequence.size();
+       
+       for (i = 0; i < length; ++i) {
                buf += kb_keymap::printKeysym(sequence[i], modifiers[i].first);
 
                // append a blank
-               if (i + 1 < length_) {
+               if (i + 1 < length) {
                        buf += ' ';
                }
        }
@@ -175,23 +171,17 @@ void kb_sequence::mark_deleted()
 }
 
 
-unsigned int kb_sequence::getsym() const
+LyXKeySymPtr kb_sequence::getsym() const
 {
-       if (length_ == 0) return NoSymbol;
-       return sequence[length_ - 1];
+       if (sequence.size() == 0)
+               return LyXKeySymPtr(LyXKeySymFactory::create());
+       return sequence.back();
 }
 
 
-char kb_sequence::getiso() const
+char kb_sequence::getLastKeyEncoded() const
 {
-       unsigned int const c = getsym();
-
-       lyxerr[Debug::KBMAP] << "Raw keysym: "
-                            << hex << c << dec << endl;
-       lyxerr[Debug::KBMAP] << "byte 3: "
-                            << hex << (c & 0xff00) << dec
-                            << endl;
-       return kb_keymap::getiso(c);
+       return getsym()->getISOEncoded();
 }
 
 
@@ -203,6 +193,6 @@ void kb_sequence::reset()
 
 void kb_sequence::clear()
 {
-       length_ = 0;
+       sequence.clear();
        reset();
 }
index 46cda83795b31b1da3f2a5998998d147781b2ef4..918d29fac20cd7aa78f83651d115220599f683d3 100644 (file)
@@ -15,8 +15,8 @@
 #include <config.h>
 
 #include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
 #include "LString.h"
-
 #include <vector>
 
 class kb_keymap;
@@ -24,32 +24,35 @@ class kb_keymap;
 /// Holds a key sequence and the current and standard keymaps
 class kb_sequence {
 public:
+       typedef std::vector<LyXKeySymPtr> KeySequence;
+       
        friend class kb_keymap;
 
        ///
        kb_sequence(kb_keymap * std, kb_keymap * cur)
-               : stdmap(std), curmap(cur), length_(0), deleted_(false) {}
-
-
+               : stdmap(std), curmap(cur), deleted_(false) {}
 
        /**
         * Add a key to the key sequence and look it up in the curmap
         * if the latter is defined.
-        * @param text the text from the key event
+        * @param keysym the key to add
         * @param mod modifier mask
         * @param nmod which modifiers to mask out for equality test
         * @return the action matching this key sequence or LFUN_UNKNOWN_ACTION
         */
-       int addkey(unsigned int text, key_modifier::state mod,
-               key_modifier::state nmod = key_modifier::none);
+       int addkey(LyXKeySymPtr keysym, key_modifier::state mod,
+                  key_modifier::state nmod = key_modifier::none);
 
        /**
         * Add a sequence of keys from a string to the sequence
         * @return string::npos if OK, else error position in string
         *
         * Keys in the string must be separated with whitespace;
-        * Use the keysym names used by XStringToKeysym
+        * Use the keysym names used by XStringToKeysym, f.ex.
+        * "Space", "a", "Return", ...
         * Prefixes are S-, C-, M- for shift, control, meta
+        * Prefixes can also be ignored by using the Tilde "~"
+        * f.ex.: "~S-Space".
         */
        string::size_type parse(string const & s);
 
@@ -68,8 +71,12 @@ public:
        /// Mark the sequence as deleted.
        void mark_deleted();
 
-       /// Return the ISO value of the last keysym in sequence, or 0
-       char getiso() const;
+       /**
+        * Return the value of the last keysym in the sequence
+        * in the local ISO encoding. If it does not encode
+        * in this encoding, return 0.
+        */
+       char getLastKeyEncoded() const;
 
        /// Reset sequence to become "deleted"
        void reset();
@@ -82,8 +89,8 @@ public:
        }
 
        /// length of sequence
-       std::vector<unsigned int>::size_type length() const {
-               return length_;
+       KeySequence::size_type length() const {
+               return sequence.size();
        }
 
        /// Keymap to use if a new sequence is starting
@@ -94,21 +101,20 @@ public:
 
 private:
        /// get the keysym of last in sequence
-       unsigned int getsym() const;
+       LyXKeySymPtr getsym() const;
 
        /**
-        * Array holding the current key sequence.
+        * Array holding the current key sequence as KeySyms.
         * If sequence[length-1] < 0xff it can be used as ISO8859 char
         */
-       std::vector<unsigned int> sequence;
+       KeySequence sequence;
+
+       typedef std::pair<key_modifier::state, key_modifier::state>
+               modifier_pair;
 
-       typedef std::pair<key_modifier::state, key_modifier::state> modifier_pair;
        /// modifiers for keys in the sequence
        std::vector<modifier_pair> modifiers;
 
-       /// Current length of key sequence
-       std::vector<unsigned int>::size_type length_;
-
        /// is keysequence deleted ?
        bool deleted_;
 };
index 51bb428061c36f9912d00669c9fb2bf654c2979b..2e2983271755cd526622eecf15ef8fff85a8df90 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "frontends/Alert.h"
 #include "frontends/FileDialog.h"
-#include <X11/Xlib.h>
 
 #include "support/FileInfo.h"
 #include "support/filetools.h"
index 72784eff1aa02e59f4b74c33c7881296c18cfd7b..039d34985d035b3b5681906f84b4cb6380a7db59 100644 (file)
 
 using lyx::pos_type;
 
-
-///
-// locally used enum
-///
-enum SearchResult {
-       //
-       SR_NOT_FOUND = 0,
-       //
-       SR_FOUND,
-       //
-       SR_FOUND_NOUPDATE
-};
-
+namespace lyxfind {
 
 /// returns true if the specified string is at the specified  position
 bool IsStringInText(Paragraph * par, pos_type pos,
@@ -43,7 +31,6 @@ SearchResult SearchForward(BufferView *, LyXText * text, string const & str,
 SearchResult SearchBackward(BufferView *, LyXText * text, string const & str,
                            bool const & = true, bool const & = false);
 
-
 int LyXReplace(BufferView * bv,
               string const & searchstr, string const & replacestr,
               bool forward, bool casesens, bool matchwrd, bool replaceall,
@@ -62,17 +49,14 @@ int LyXReplace(BufferView * bv,
                return 0;
        }
 
-       LyXText * text = bv->getLyXText();
-
        // now we can start searching for the first
        // start at top if replaceall
+       LyXText * text = bv->getLyXText();
        bool fw = forward;
        if (replaceall) {
                text->clearSelection();
-               if (text->inset_owner) {
-                       bv->unlockInset(bv->theLockingInset());
-                       text = bv->text;
-               }
+               bv->unlockInset(bv->theLockingInset());
+               text = bv->text;
                text->cursorTop(bv);
                // override search direction because we search top to bottom
                fw = true;
@@ -90,7 +74,7 @@ int LyXReplace(BufferView * bv,
                str2 = lowercase(text->selectionAsString(bv->buffer(), false));
        }
        if (str1 != str2) {
-               if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||
+               if (!LyXFind(bv, searchstr, fw, casesens, matchwrd) ||
                        !replaceall)
                {
                        return 0;
@@ -100,15 +84,16 @@ int LyXReplace(BufferView * bv,
        bool found = false;
        int replace_count = 0;
        do {
+               text = bv->getLyXText();
                bv->hideCursor();
-               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR);
                bv->toggleSelection(false);
-               bv->getLyXText()->replaceSelectionWithString(bv, replacestr);
-               bv->getLyXText()->setSelectionOverString(bv, replacestr);
-               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+               text->replaceSelectionWithString(bv, replacestr);
+               text->setSelectionOverString(bv, replacestr);
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
                ++replace_count;
                if (!once)
-                       found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
+                       found = LyXFind(bv, searchstr, fw, casesens, matchwrd);
        } while (!once && replaceall && found);
 
        if (bv->focus())
@@ -119,75 +104,83 @@ int LyXReplace(BufferView * bv,
 
 bool LyXFind(BufferView * bv,
             string const & searchstr, bool forward,
-            bool frominset, bool casesens, bool matchwrd)
+            bool casesens, bool matchwrd)
 {
        if (!bv->available() || searchstr.empty())
                return false;
 
-       LyXText * text = bv->getLyXText();
-
        bv->hideCursor();
-       bv->update(text, BufferView::SELECT|BufferView::FITCUR);
-
-       if (text->selection.set())
-               text->cursor = forward ?
-                       text->selection.end : text->selection.start;
+       bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
 
-       SearchResult result = SR_NOT_FOUND;
-
-       if (!frominset && bv->theLockingInset()) {
+       if (bv->theLockingInset()) {
                bool found = forward ?
                        bv->theLockingInset()->searchForward(bv, searchstr, casesens, matchwrd) :
                        bv->theLockingInset()->searchBackward(bv, searchstr, casesens, matchwrd);
+               // We found the stuff inside the inset so we don't have to
+               // do anything as the inset did all the update for us!
                if (found)
-                       result = SR_FOUND_NOUPDATE;
-               else {
-                       text = bv->getLyXText();
-                       Paragraph * par = text->cursor.par();
-                       pos_type pos = text->cursor.pos();
-                       if (forward) {
-                               if (pos < par->size() - 1)
-                                       ++pos;
-                               else {
-                                       pos = 0;
-                                       par = par->next();
-                               }
-                               if (par)
-                                       text->setCursor(bv, par, pos);
-                       }
-                       if (par) {
-                               result = forward ?
-                                       SearchForward(bv, text, searchstr, casesens, matchwrd) :
-                                       SearchBackward(bv, text, searchstr, casesens, matchwrd);
-                       }
+                       return true;
+               // We now are in the main text but if we did a forward
+               // search we have to put the cursor behind the inset.
+               if (forward) {
+                       bv->text->cursorRight(bv, true);
                }
-       } else {
-               result = forward ?
-                       SearchForward(bv, text, searchstr, casesens, matchwrd) :
-                       SearchBackward(bv, text, searchstr, casesens, matchwrd);
        }
+       // If we arrive here we are in the main text again so we
+       // just start searching from the root LyXText at the position
+       // we are!
+       LyXText * text = bv->text;
+
+       if (text->selection.set())
+               text->cursor = forward ?
+                       text->selection.end : text->selection.start;
+
+       bv->toggleSelection();
+       text->clearSelection();
+       
+       SearchResult result = forward ?
+               SearchForward(bv, text, searchstr, casesens, matchwrd) :
+               SearchBackward(bv, text, searchstr, casesens, matchwrd);
 
        bool found = true;
+       // If we found the cursor inside an inset we will get back
+       // SR_FOUND_NOUPDATE and we don't have to do anything as the
+       // inset did it already.
        if (result == SR_FOUND) {
-               // the actual text pointer could have changed!
-               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
-               bv->toggleSelection();
-               bv->getLyXText()->clearSelection();
-               bv->getLyXText()->setSelectionOverString(bv, searchstr);
+               bv->unlockInset(bv->theLockingInset());
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+               text->setSelectionOverString(bv, searchstr);
                bv->toggleSelection(false);
-               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR);
        } else if (result == SR_NOT_FOUND) {
-               bv->toggleSelection();
-               bv->getLyXText()->clearSelection();
-               bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+               bv->unlockInset(bv->theLockingInset());
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR);
                found = false;
        }
-       if (bv->focus())
+       if (result != SR_FOUND_NOUPDATE && bv->focus())
                bv->showCursor();
 
        return found;
 }
 
+SearchResult LyXFind(BufferView * bv, LyXText * text,
+                    string const & searchstr, bool forward,
+                    bool casesens, bool matchwrd)
+{
+       if (text->selection.set())
+               text->cursor = forward ?
+                       text->selection.end : text->selection.start;
+
+       bv->toggleSelection();
+       text->clearSelection();
+
+       SearchResult result = forward ?
+               SearchForward(bv, text, searchstr, casesens, matchwrd) :
+               SearchBackward(bv, text, searchstr, casesens, matchwrd);
+
+       return result;
+}
+
 
 // returns true if the specified string is at the specified position
 bool IsStringInText(Paragraph * par, pos_type pos,
@@ -235,12 +228,13 @@ SearchResult SearchForward(BufferView * bv, LyXText * text, string const & str,
                        (inset = (UpdatableInset *)par->getInset(pos)) &&
                        (inset->isTextInset()))
                {
+#if 0
                        // lock the inset!
                        text->setCursor(bv, par, pos);
                        inset->edit(bv);
+#endif
                        if (inset->searchForward(bv, str, cs, mw))
                                return SR_FOUND_NOUPDATE;
-                       text = bv->getLyXText();
                }
 
                ++pos;
@@ -292,12 +286,13 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
                        (inset = (UpdatableInset *)par->getInset(pos)) &&
                        (inset->isTextInset()))
                {
+#if 0
                        // lock the inset!
                        text->setCursor(bv, par, pos);
                        inset->edit(bv, false);
+#endif
                        if (inset->searchBackward(bv, str, cs, mw))
                                return SR_FOUND_NOUPDATE;
-                       text = bv->getLyXText();
                }
        } while (par && !IsStringInText(par, pos, str, cs, mw));
 
@@ -310,3 +305,5 @@ SearchResult SearchBackward(BufferView * bv, LyXText * text,
                return SR_NOT_FOUND;
        }
 }
+
+} // end lyxfind namespace
index 2e74dc3361a9667c866d389fcac4dba7511e31d4..4a211e1be401867d18877e60996c4f83fe085700 100644 (file)
 
 class BufferView;
 
-int LyXReplace(BufferView * bv, string const &, string const &,
+namespace lyxfind {
+
+enum SearchResult {
+       //
+       SR_NOT_FOUND = 0,
+       //
+       SR_FOUND,
+       //
+       SR_FOUND_NOUPDATE
+};
+
+
+int LyXReplace(BufferView * bv,
+              string const &, string const &,
               bool, bool = true, bool = false,
               bool = false, bool = false);
 
+/**
+ * This function is called as a general interface to find some
+ * text from the actual cursor position in whatever direction
+ * we want to go. This does also update the screen.
+ */
 bool LyXFind(BufferView *,
             string const & searchstr, bool forward,
-            bool frominset = false, bool casesens = true,
-            bool matchwrd = false);
+            bool casesens = true, bool matchwrd = false);
+
+/**
+ * This function does search from the cursor position inside the
+ * passed LyXText parameter and regards this LyXText as the root
+ * LyXText. It will NOT update any screen stuff. It will however
+ * set the cursor to the new position inside LyXText, before
+ * returning to the calling function.
+ */
+
+SearchResult LyXFind(BufferView *, LyXText * text,
+                    string const & searchstr, bool forward,
+                    bool casesens = true, bool matchwrd = false);
 
+} // end namespace LyXFind
 #endif
index 26a1b6aae34ee20166b5e8bd1e6852d7bdbe276f..b78db827316518b0c30f474a52bf30e9f6f37fc7 100644 (file)
@@ -204,13 +204,13 @@ void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
 
 void LyXFunc::handleKeyFunc(kb_action action)
 {
-       char c = keyseq.getiso();
+       char c = keyseq.getLastKeyEncoded();
 
        if (keyseq.length() > 1) {
                c = 0;
        }
 
-       owner->getIntl()->getTrans()
+       owner->getIntl()->getTransManager()
                .deadkey(c, get_accent(action).accent, TEXT(false));
        // Need to clear, in case the minibuffer calls these
        // actions
@@ -222,32 +222,25 @@ void LyXFunc::handleKeyFunc(kb_action action)
 }
 
 
-void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state)
+void LyXFunc::processKeySym(LyXKeySymPtr keysym,
+                           key_modifier::state state)
 {
        string argument;
 
        if (lyxerr.debugging(Debug::KEY)) {
-               char const * tmp = XKeysymToString(keysym);
-               string const stm = (tmp ? tmp : "");
                lyxerr << "KeySym is "
-                      << stm
-                      << "["
-                      << keysym
+                      << keysym->getSymbolName()
                       << endl;
        }
        // Do nothing if we have nothing (JMarc)
-       if (keysym == NoSymbol) {
+       if ( ! keysym->isOK() ) {
                lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
                                   << endl;
                return;
        }
 
-       // Can we be sure that this will work for all X Window
-       // implementations? (Lgb)
-       // This code snippet makes lyx ignore some keys. Perhaps
-       // all of them should be explictly mentioned?
-       if ((keysym >= XK_Shift_L && keysym <= XK_Hyper_R)
-           || keysym == XK_Mode_switch || keysym == 0x0) {
+       // This code snippet makes lyx ignore modifier keys.
+       if (keysym->isModifier()) {
                return;
        }
 
@@ -318,13 +311,11 @@ void LyXFunc::processKeySym(KeySym keysym, key_modifier::state state)
 
        if (action == LFUN_SELFINSERT) {
                // This is very X dependent.
-               unsigned int c = keysym;
+               char c = keysym->getISOEncoded();
                string argument;
 
-               c = kb_keymap::getiso(c);
-
-               if (c > 0)
-                       argument = static_cast<char>(c);
+               if (c != 0)
+                       argument = c;
 
                dispatch(LFUN_SELFINSERT, argument);
                lyxerr[Debug::KEY] << "SelfInsert arg[`"
@@ -896,7 +887,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
 #endif
                        if ((action == LFUN_UNKNOWN_ACTION)
                            && argument.empty()) {
-                               argument = keyseq.getiso();
+                               argument = keyseq.getLastKeyEncoded();
                        }
                        // Undo/Redo is a bit tricky for insets.
                        if (action == LFUN_UNDO) {
@@ -1044,7 +1035,7 @@ string const LyXFunc::dispatch(kb_action action, string argument)
                }
                bool fw = (action == LFUN_WORDFINDBACKWARD);
                if (!searched_string.empty()) {
-                       LyXFind(owner->view(), searched_string, fw);
+                       lyxfind::LyXFind(owner->view(), searched_string, fw);
                }
 //             owner->view()->showCursor();
        }
index 387f85e9619afff362bc6aa172233c90e782e28a..9f72d2c406e12ce607312015f81a2e9b5f581c58 100644 (file)
 
 #include "frontends/mouse_state.h"
 #include "frontends/key_state.h"
+#include "frontends/LyXKeySym.h"
 
 #include <boost/signals/trackable.hpp>
 
-#include <X11/Xlib.h>
-
 class LyXView;
 class LyXText;
 
@@ -57,7 +56,7 @@ public:
        void initMiniBuffer();
 
        ///
-       void processKeySym(KeySym key, key_modifier::state state);
+       void processKeySym(LyXKeySymPtr key, key_modifier::state state);
 
        /// we need one internal which is called from inside LyXAction and
        /// can contain the string argument.
@@ -81,7 +80,7 @@ public:
        string const getMessage() const { return dispatch_buffer; }
        /// Buffer to store result messages
        string const getStatusMessage() const { return status_buffer; }
-       /// Handle a accented char keysequenze
+       /// Handle a accented char key sequence
        void handleKeyFunc(kb_action action);
 
 private:
index 47746fd1275771d92e23d5698dc57c993510d349..bd27342e775724bba3d0e179e674273cd85fee13 100644 (file)
@@ -83,7 +83,7 @@ public:
        mutable LyXFont current_font;
        /// the current font
        mutable LyXFont real_current_font;
-       /// first visible pixel-row is set from LScreen!!!
+       /// first visible pixel-row is set from LyXScreen!!!
        // unsigned is wrong here for text-insets!
        int first_y;
        ///
index b147f371420ee61ac81488b9dcb04b079e970672..d807a7c2ddf6df5dedf1f4ddd6b8bb9592b064ec 100644 (file)
@@ -1,3 +1,22 @@
+2002-06-16  André Pönitz <poenitz@gmx.net>
+
+       * math_factory.C:
+       * math_support.C: fix font fall-back
+
+       * math_specialcharinset.[Ch]:
+       * math_funcliminset.[Ch]: remove, it's now done by MathSymbolInset
+
+       * math_funcinset.[Ch]: remove, it's not used
+
+2002-06-16  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * math_extern.C: add using std::endl
+
+2002-06-15  LyX Development team <lyx@rilke>
+
+       * formula.[Ch]:
+       * macroformula.[Ch] (docbook): Added argument to care about the
+       pernicious mixed content.
 
 2002-05-30  André Pönitz <poenitz@gmx.net>
 
index 29ceacc6c7d930a1b5e379ae39da82a297ecd86e..e5ce335e4f6c3d260ea36063d48e32129f8cd741 100644 (file)
@@ -64,8 +64,6 @@ libmathed_la_SOURCES = \
        math_fracinset.h \
        math_fracbase.C \
        math_fracbase.h \
-       math_funcliminset.C \
-       math_funcliminset.h \
        math_gridinset.C \
        math_gridinset.h \
        math_hullinset.C \
@@ -92,12 +90,14 @@ libmathed_la_SOURCES = \
        math_mathmlstream.h \
        math_matrixinset.C \
        math_matrixinset.h \
-       math_metricsinfo.h \
        math_metricsinfo.C \
+       math_metricsinfo.h \
        math_nestinset.C \
        math_nestinset.h \
        math_notinset.C \
        math_notinset.h \
+       math_numberinset.C \
+       math_numberinset.h \
        math_parser.C \
        math_parser.h \
        math_pos.C \
@@ -111,8 +111,6 @@ libmathed_la_SOURCES = \
        math_sizeinset.h \
        math_spaceinset.C \
        math_spaceinset.h \
-       math_specialcharinset.C \
-       math_specialcharinset.h \
        math_splitinset.C \
        math_splitinset.h \
        math_sqrtinset.C \
index c56e48fa4efe4bc5a7b0ee9f3bee69d09e607a9e..c87271376fefe9f91eb9509367739708f8faa317 100644 (file)
@@ -33,7 +33,6 @@
 #include "frontends/Alert.h"
 #include "support/LOstream.h"
 #include "support/LAssert.h"
-#include "support/systemcall.h"
 #include "support/filetools.h" // LibFileSearch
 #include "frontends/LyXView.h"
 #include "frontends/Painter.h"
@@ -53,197 +52,6 @@ using std::vector;
 using std::getline;
 
 
-namespace {
-
-       string captureOutput(string const & cmd, string const & data)
-       {
-               string outfile = lyx::tempName(string(), "mathextern");
-               string full =  "echo '" + data + "' | (" + cmd + ") > " + outfile;
-               lyxerr << "calling: " << full << "\n";
-               Systemcall dummy;
-               dummy.startscript(Systemcall::Wait, full);
-               string out = GetFileContents(outfile);
-               lyx::unlink(outfile);
-               lyxerr << "result: '" << out << "'\n";
-               return out;
-       }
-
-
-       MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
-       {
-               string header = "readlib(latex):\n";
-
-               // remove the \\it for variable names
-               //"#`latex/csname_font` := `\\it `:"
-               header +=
-                       "`latex/csname_font` := ``:\n";
-
-               // export matrices in (...) instead of [...]
-               header +=
-                       "`latex/latex/matrix` := "
-                               "subs(`[`=`(`, `]`=`)`,"
-                                       "eval(`latex/latex/matrix`)):\n";
-
-               // replace \\cdots with proper '*'
-               header +=
-                       "`latex/latex/*` := "
-                               "subs(`\\,`=`\\cdot `,"
-                                       "eval(`latex/latex/*`)):\n";
-
-               // remove spurious \\noalign{\\medskip} in matrix output
-               header +=
-                       "`latex/latex/matrix`:= "
-                               "subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
-                                       "eval(`latex/latex/matrix`)):\n";
-
-               //"#`latex/latex/symbol` "
-               //      " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
-
-               string trailer = "quit;";
-               ostringstream os;
-               MapleStream ms(os);
-               ms << ar;
-               string expr = os.str().c_str();
-               lyxerr << "ar: '" << ar << "'\n";
-
-               for (int i = 0; i < 100; ++i) { // at most 100 attempts
-                       // try to fix missing '*' the hard way by using mint
-                       //
-                       // ... > echo "1A;" | mint -i 1 -S -s -q
-                       // on line     1: 1A;
-                       //                 ^ syntax error -
-                       //                   Probably missing an operator such as * p
-                       //
-                       lyxerr << "checking expr: '" << expr << "'\n";
-                       string out = captureOutput("mint -i 1 -S -s -q -q", expr + ";");
-                       if (out.empty())
-                               break; // expression syntax is ok
-                       istringstream is(out.c_str());
-                       string line;
-                       getline(is, line);
-                       if (line.find("on line") != 0)
-                               break; // error message not identified
-                       getline(is, line);
-                       string::size_type pos = line.find('^');
-                       if (pos == string::npos || pos < 15)
-                               break; // caret position not found
-                       pos -= 15; // skip the "on line ..." part
-                       if (expr[pos] == '*' || (pos > 0 && expr[pos - 1] == '*'))
-                               break; // two '*' in a row are definitely bad
-                       expr.insert(pos,  "*");
-               }
-
-               string full = "latex(" +  extra + '(' + expr + "));";
-               string out = captureOutput("maple -q", header + full + trailer);
-
-               // change \_ into _
-
-               //
-               MathArray res;
-               mathed_parse_cell(res, out);
-               return res;
-       }
-
-
-       MathArray pipeThroughOctave(string const &, MathArray const & ar)
-       {
-               ostringstream os;
-               OctaveStream vs(os);
-               vs << ar;
-               string expr = os.str().c_str();
-               string out;
-
-               for (int i = 0; i < 100; ++i) { // at most 100 attempts
-                       //
-                       // try to fix missing '*' the hard way
-                       // parse error:
-                       // >>> ([[1 2 3 ];[2 3 1 ];[3 1 2 ]])([[1 2 3 ];[2 3 1 ];[3 1 2 ]])
-                       //                                   ^
-                       //
-                       lyxerr << "checking expr: '" << expr << "'\n";
-                       out = captureOutput("octave -q 2>&1", expr);
-                       lyxerr << "checking out: '" << out << "'\n";
-
-                       // leave loop if expression syntax is probably ok
-                       if (out.find("parse error:") == string::npos)
-                               break;
-
-                       // search line with single caret
-                       istringstream is(out.c_str());
-                       string line;
-                       while (is) {
-                               getline(is, line);
-                               lyxerr << "skipping line: '" << line << "'\n";
-                               if (line.find(">>> ") != string::npos)
-                                       break;
-                       }
-
-                       // found line with error, next line is the one with caret
-                       getline(is, line);
-                       string::size_type pos = line.find('^');
-                       lyxerr << "caret line: '" << line << "'\n";
-                       lyxerr << "found caret at pos: '" << pos << "'\n";
-                       if (pos == string::npos || pos < 4)
-                               break; // caret position not found
-                       pos -= 4; // skip the ">>> " part
-                       if (expr[pos] == '*')
-                               break; // two '*' in a row are definitely bad
-                       expr.insert(pos,  "*");
-               }
-
-               if (out.size() < 6)
-                       return MathArray();
-
-               // remove 'ans = '
-               out = out.substr(6);
-
-               // parse output as matrix or single number
-               MathAtom at(new MathArrayInset("array", out));
-               MathArrayInset const * mat = at.nucleus()->asArrayInset();
-               MathArray res;
-               if (mat->ncols() == 1 && mat->nrows() == 1)
-                       res.push_back(mat->cell(0));
-               else {
-                       res.push_back(MathAtom(new MathDelimInset("(", ")")));
-                       res.back()->cell(0).push_back(at);
-               }
-               return res;
-       }
-
-
-       MathArray pipeThroughExtern(string const & lang, string const & extra,
-               MathArray const & ar)
-       {
-               if (lang == "octave")
-                       return pipeThroughOctave(extra, ar);
-
-               if (lang == "maple")
-                       return pipeThroughMaple(extra, ar);
-
-               // create normalized expression
-               ostringstream os;
-               NormalStream ns(os);
-               os << "[" << extra << ' ';
-               ns << ar;
-               os << "]";
-               string data = os.str().c_str();
-
-               // search external script
-               string file = LibFileSearch("mathed", "extern_" + lang);
-               if (file.empty()) {
-                       lyxerr << "converter to '" << lang << "' not found\n";
-                       return MathArray();
-               }
-
-               // run external sript
-               string out = captureOutput(file, data);
-               MathArray res;
-               mathed_parse_cell(res, out);
-               return res;
-       }
-
-}
-
 
 InsetFormula::InsetFormula()
        : par_(MathAtom(new MathHullInset))
@@ -315,18 +123,23 @@ int InsetFormula::ascii(Buffer const *, ostream & os, int) const
 
 int InsetFormula::linuxdoc(Buffer const * buf, ostream & os) const
 {
-       return docbook(buf, os);
+       return docbook(buf, os, false);
 }
 
 
-int InsetFormula::docbook(Buffer const * buf, ostream & os) const
+int InsetFormula::docbook(Buffer const * buf, ostream & os, bool) const
 {
        MathMLStream ms(os);
-       ms << MTag("equation") << MTag("alt");
+       ms << MTag("equation");
+       ms <<   MTag("alt");
+       ms <<    "<[CDATA[";
        int res = ascii(buf, ms.os(), 0);
-       ms << ETag("alt") << MTag("math");
-       ms << par_.nucleus();
-       ms << ETag("math") << ETag("equation");
+       ms <<    "]]>";
+       ms <<   ETag("alt");
+       ms <<   MTag("math");
+       ms <<    par_.nucleus();
+       ms <<   ETag("math");
+       ms << ETag("equation");
        return ms.line() + res;
 }
 
@@ -490,7 +303,8 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
                case LFUN_MATH_EXTERN:
                {
                        bv->lockedInsetStoreUndo(Undo::EDIT);
-                       handleExtern(arg);
+                       if (mathcursor)
+                               mathcursor->handleExtern(arg);
                        // re-compute inset dimension
                        metrics(bv);
                        updateLocal(bv, true);
@@ -502,7 +316,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
                        int x = 0;
                        int y = 0;
                        mathcursor->getPos(x, y);
-                       if (hull()->getType() == LM_OT_SIMPLE)
+                       if (getType() == LM_OT_SIMPLE)
                                hull()->mutate(LM_OT_EQUATION);
                        else
                                hull()->mutate(LM_OT_SIMPLE);
@@ -528,40 +342,9 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
 }
 
 
-void InsetFormula::handleExtern(const string & arg)
-{
-       // where are we?
-       if (!mathcursor)
-               return;
-
-       string lang;
-       string extra;
-       istringstream iss(arg.c_str());
-       iss >> lang >> extra;
-       if (extra.empty())
-               extra = "noextra";
-
-       bool selected = mathcursor->selection();
-
-       MathArray ar;
-       if (selected) {
-               mathcursor->selGet(ar);
-               //lyxerr << "use selection: " << ar << "\n";
-       } else {
-               mathcursor->last();
-               mathcursor->stripFromLastEqualSign();
-               ar = mathcursor->cursor().cell();
-               mathcursor->insert('=');
-               //lyxerr << "use whole cell: " << ar << "\n";
-       }
-
-       mathcursor->insert(pipeThroughExtern(lang, extra, ar));
-}
-
-
 bool InsetFormula::display() const
 {
-       return hull()->getType() != LM_OT_SIMPLE;
+       return getType() != LM_OT_SIMPLE;
 }
 
 
index cefe8a8ed8467c3e1c0131e94b9faaeeaed87232..1d32ce06b8baed0e1aab7270fba7d57659b22975 100644 (file)
@@ -56,7 +56,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 
        ///
        Inset * clone(Buffer const &, bool same_id = false) const;
index af2a4e33e4cd66e5e1489f8bce0a811cac0616d2..b05790d9cafc354e4369705a03616a628fb0ba8a 100644 (file)
@@ -110,7 +110,7 @@ void InsetFormulaBase::mutateToText()
        string::const_iterator cit = str.begin();
        string::const_iterator end = str.end();
        for (; cit != end; ++cit)
-               view_->owner()->getIntl()->getTrans().TranslateAndInsert(*cit, lt);
+               view_->owner()->getIntl()->getTransManager().TranslateAndInsert(*cit, lt);
 
        // remove ourselves
        //view_->owner()->getLyXFunc()->dispatch(LFUN_ESCAPE);
@@ -205,8 +205,9 @@ void InsetFormulaBase::insetUnlock(BufferView * bv)
 }
 
 
-void InsetFormulaBase::getCursorPos(BufferView *, int & x, int & y) const
+void InsetFormulaBase::getCursorPos(BufferView * bv, int & x, int & y) const
 {
+       metrics(bv);
        mathcursor->getPos(x, y);
        //x -= xo_;
        y -= yo_;
@@ -265,6 +266,20 @@ void InsetFormulaBase::hideInsetCursor(BufferView * bv)
 }
 
 
+void InsetFormulaBase::fitInsetCursor(BufferView * bv) const
+{
+       if (!mathcursor)
+               return;
+       
+       int const asc = font_metrics::maxAscent(font_);
+       int const desc = font_metrics::maxDescent(font_);
+       int x, y;
+
+       getCursorPos(bv, x, y);
+       bv->fitLockedInsetCursor(x, y, asc, desc);
+}
+
+
 void InsetFormulaBase::toggleInsetSelection(BufferView * bv)
 {
        if (mathcursor)
@@ -281,6 +296,8 @@ vector<string> const InsetFormulaBase::getLabelList() const
 void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
 {
        metrics(bv);
+       if (mathcursor)
+               bv->fitCursor();
        bv->updateInset(this, dirty);
 }
 
@@ -850,24 +867,24 @@ bool InsetFormulaBase::searchForward(BufferView * bv, string const & str,
 
        for (MathIterator it = current; it != iend(par().nucleus()); ++it) {
                if (it.cell().matchpart(ar, it.position().pos_)) {
+                       bv->unlockInset(bv->theLockingInset());
+                       if (!bv->lockInset(this)) {
+                               lyxerr << "Cannot lock inset" << endl;
+                               return false;
+                       }
+                       delete mathcursor;
+                       mathcursor = new MathCursor(this, true);
+                       metrics(bv);
                        mathcursor->setSelection(it.cursor(), ar.size());
                        current = it;
                        it.jump(ar.size());
-                       // I guess some of the following can go
-                       bv->toggleSelection(true);
-                       hideInsetCursor(bv);
-                       updateLocal(bv, true);
-                       showInsetCursor(bv);
-                       metrics(bv);
+                       updateLocal(bv, false);
                        return true;
                }
        }
 
        //lyxerr << "not found!\n";
        lastformula = 0;
-       // we have to unlock ourself in this function by default!
-       // don't ask me why...
-       bv->unlockInset(this);
        return false;
 }
 
@@ -1007,3 +1024,7 @@ void mathDispatchGreek(BufferView * bv, string const & arg)
 
 void mathDispatch(BufferView *, kb_action, string const &)
 {}
+
+
+void mathDispatch(BufferView *, string const &)
+{}
index a91eed0b38d80c09e101176f92d2e6920096ca2d..fd6c2db66405a98087d40899c645df5ee940d037 100644 (file)
@@ -76,6 +76,8 @@ public:
        ///
        virtual void hideInsetCursor(BufferView *);
        ///
+       virtual void fitInsetCursor(BufferView *) const;
+       ///
        virtual void getCursorPos(BufferView *, int &, int &) const;
        ///
        virtual void toggleInsetSelection(BufferView * bv);
@@ -165,5 +167,7 @@ void mathDispatchGreek(BufferView *, string const &);
 void mathDispatchMathImportSelection(BufferView *, string const &);
 //
 void mathDispatch(BufferView *, kb_action, string const &);
+//
+void mathDispatch(BufferView *, string const &);
 
 #endif
index 7e0493644dcfdb4ca6b87e20dd1495cab7a28788..16f8c3c58b0448fc457991ed66dd19c1cc7231ee 100644 (file)
@@ -99,7 +99,7 @@ int InsetFormulaMacro::linuxdoc(Buffer const * buf, ostream & os) const
 }
 
 
-int InsetFormulaMacro::docbook(Buffer const * buf, ostream & os) const
+int InsetFormulaMacro::docbook(Buffer const * buf, ostream & os, bool) const
 {
        return ascii(buf, os, 0);
 }
index c9d61785d0470ba71642144713b5301f91e44462..05ab42ed21a6ecadeb8b4cbed0baa089f72a0c3b 100644 (file)
@@ -57,7 +57,7 @@ public:
        ///
        int linuxdoc(Buffer const *, std::ostream & os) const;
        ///
-       int docbook(Buffer const *, std::ostream &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
 
        ///
        Inset * clone(Buffer const &, bool same_id = false) const;
index 63315bc651ad61d35bba36244e2150a42298a6e1..1ae1f149af36f107a053d26732cc7b400e1c24b7 100644 (file)
@@ -46,10 +46,12 @@ bool Correction::read(istream & is)
        is >> s1 >> s2 >> s3;
        if (!is)
                return false;
+       if (s2.size() != 1)
+               return false;
        MathArray ar1, ar3;
        mathed_parse_cell(ar1, s1);
        mathed_parse_cell(ar3, s3);
-       if (ar1.size() != 1  ||  s2.size() != 1  ||  ar3.size() !=1)
+       if (ar1.size() != 1 || ar3.size() != 1)
                return false;
        from1_ = ar1.front();
        from2_ = s2[0];
index 8e74c6bc655d6e8ab0cf4dd2d55d0c8a3888de9b..a212db15e7e356c3e8851de0fe1ecd7a73cf2b68 100644 (file)
@@ -122,6 +122,12 @@ void MathCharInset::normalize(NormalStream & os) const
 }
 
 
+void MathCharInset::octavize(OctaveStream & os) const
+{
+       os << char_;
+}
+
+
 bool MathCharInset::isRelOp() const
 {
        return char_ == '=' || char_ == '<' || char_ == '>';
index da50061c494c1f3d37501151c5020b02aac839cb..cc24898b2fdda6c845231d543c013a99047de605 100644 (file)
@@ -29,7 +29,9 @@ public:
        ///
        void write(WriteStream & os) const;
        ///
-       void normalize(NormalStream &) const;
+       void normalize(NormalStream & ns) const;
+       ///
+       void octavize(OctaveStream & os) const;
        /// identifies Charinsets
        MathCharInset const * asCharInset() const { return this; }
        ///
index 09dcfe91a1c6b7b7b74be8a1e59757289dd5c845..0f95d7d18200583066e603af4a69a9f60e80f44b 100644 (file)
@@ -36,6 +36,7 @@
 #include "math_casesinset.h"
 #include "math_charinset.h"
 #include "math_deliminset.h"
+#include "math_extern.h"
 #include "math_factory.h"
 #include "math_hullinset.h"
 #include "math_iterator.h"
@@ -46,7 +47,6 @@
 #include "math_replace.h"
 #include "math_scriptinset.h"
 #include "math_spaceinset.h"
-#include "math_specialcharinset.h"
 #include "math_support.h"
 #include "math_unknowninset.h"
 
@@ -64,131 +64,15 @@ using std::ostringstream;
 using std::isalpha;
 
 
-namespace {
-
-struct Selection
-{
-       typedef MathInset::col_type col_type;
-       typedef MathInset::row_type row_type;
-       typedef MathInset::idx_type idx_type;
-
-       Selection()
-               : data_(1, 1)
-       {}
-
-       void region(MathCursorPos const & i1, MathCursorPos const & i2,
-               row_type & r1, row_type & r2, col_type & c1, col_type & c2)
-       {
-               MathInset * p = i1.par_;
-               c1 = p->col(i1.idx_);
-               c2 = p->col(i2.idx_);
-               if (c1 > c2)
-                       swap(c1, c2);
-               r1 = p->row(i1.idx_);
-               r2 = p->row(i2.idx_);
-               if (r1 > r2)
-                       swap(r1, r2);
-       }
-
-       void grab(MathCursor const & cursor)
-       {
-               MathCursorPos i1;
-               MathCursorPos i2;
-               cursor.getSelection(i1, i2);
-               // shouldn'tt we assert on i1.par_ == i2.par_?
-               if (i1.idx_ == i2.idx_) {
-                       data_ = MathGridInset(1, 1);
-                       data_.cell(0) = MathArray(i1.cell(), i1.pos_, i2.pos_);
-               } else {
-                       row_type r1, r2;
-                       col_type c1, c2;
-                       region(i1, i2, r1, r2, c1, c2);
-                       data_ = MathGridInset(c2 - c1 + 1, r2 - r1 + 1);
-                       for (row_type row = 0; row < data_.nrows(); ++row)
-                               for (col_type col = 0; col < data_.ncols(); ++col) {
-                                       idx_type i = i1.par_->index(row + r1, col + c1);
-                                       data_.cell(data_.index(row, col)) = i1.par_->cell(i);
-                               }
-               }
-       }
-
-       void erase(MathCursor & cursor)
-       {
-               MathCursorPos i1;
-               MathCursorPos i2;
-               cursor.getSelection(i1, i2);
-               if (i1.idx_ == i2.idx_)
-                       i1.cell().erase(i1.pos_, i2.pos_);
-               else {
-                       MathInset * p = i1.par_;
-                       row_type r1, r2;
-                       col_type c1, c2;
-                       region(i1, i2, r1, r2, c1, c2);
-                       for (row_type row = r1; row <= r2; ++row)
-                               for (col_type col = c1; col <= c2; ++col)
-                                       p->cell(p->index(row, col)).erase();
-               }
-               cursor.cursor() = i1;
-       }
-
-       void paste(MathCursor & cursor) const
-       {
-               if (data_.nargs() == 1) {
-                       // single cell/part of cell
-                       cursor.paste(data_.cell(0));
-               } else {
-                       // mulitple cells
-                       idx_type idx; // index of upper left cell
-                       MathGridInset * p = cursor.enclosingGrid(idx);
-                       col_type const numcols = min(data_.ncols(), p->ncols() - p->col(idx));
-                       row_type const numrows = min(data_.nrows(), p->nrows() - p->row(idx));
-                       for (row_type row = 0; row < numrows; ++row) {
-                               for (col_type col = 0; col < numcols; ++col) {
-                                       idx_type i = p->index(row + p->row(idx), col + p->col(idx));
-                                       p->cell(i).push_back(data_.cell(data_.index(row, col)));
-                               }
-                               // append the left over horizontal cells to the last column
-                               idx_type i = p->index(row + p->row(idx), p->ncols() - 1);
-                               for (col_type col = numcols; col < data_.ncols(); ++col)
-                                       p->cell(i).push_back(data_.cell(data_.index(row, col)));
-                       }
-                       // append the left over vertical cells to the last _cell_
-                       idx_type i = p->nargs() - 1;
-                       for (row_type row = numrows; row < data_.nrows(); ++row)
-                               for (col_type col = 0; col < data_.ncols(); ++col)
-                                       p->cell(i).push_back(data_.cell(data_.index(row, col)));
-               }
-       }
-
-       // glues selection to one cell
-       MathArray glue() const
-       {
-               MathArray ar;
-               for (unsigned i = 0; i < data_.nargs(); ++i)
-                       ar.push_back(data_.cell(i));
-               return ar;
-       }
-
-       void clear()
-       {
-               data_ = MathGridInset(1, 1);
-       }
-
-       MathGridInset data_;
-};
-
-
-Selection theSelection;
-
-
-
-}
+// matheds own cut buffer
+MathGridInset theCutBuffer = MathGridInset(1, 1);
 
 
 MathCursor::MathCursor(InsetFormulaBase * formula, bool front)
        :       formula_(formula), autocorrect_(false), selection_(false)
 {
        front ? first() : last();
+       Anchor_ = Cursor_;
 }
 
 
@@ -218,7 +102,7 @@ void MathCursor::pushRight(MathAtom & t)
 bool MathCursor::popLeft()
 {
        //cerr << "Leaving atom to the left\n";
-       if (Cursor_.size() <= 1)
+       if (depth() <= 1)
                return false;
        Cursor_.pop_back();
        return true;
@@ -228,7 +112,7 @@ bool MathCursor::popLeft()
 bool MathCursor::popRight()
 {
        //cerr << "Leaving atom "; par()->write(cerr, false); cerr << " right\n";
-       if (Cursor_.size() <= 1)
+       if (depth() <= 1)
                return false;
        Cursor_.pop_back();
        posRight();
@@ -241,8 +125,8 @@ bool MathCursor::popRight()
        void MathCursor::dump(char const * what) const
        {
                lyxerr << "MC: " << what << "\n";
-               lyxerr << " Cursor: " << Cursor_.size() << "\n";
-               for (unsigned i = 0; i < Cursor_.size(); ++i)
+               lyxerr << " Cursor: " << depth() << "\n";
+               for (unsigned i = 0; i < depth(); ++i)
                        lyxerr << "    i: " << i << " " << Cursor_[i] << "\n";
                lyxerr << " Anchor: " << Anchor_.size() << "\n";
                for (unsigned i = 0; i < Anchor_.size(); ++i)
@@ -256,7 +140,7 @@ bool MathCursor::popRight()
 
 bool MathCursor::isInside(MathInset const * p) const
 {
-       for (unsigned i = 0; i < Cursor_.size(); ++i)
+       for (unsigned i = 0; i < depth(); ++i)
                if (Cursor_[i].par_ == p)
                        return true;
        return false;
@@ -276,9 +160,9 @@ bool MathCursor::openable(MathAtom const & t, bool sel) const
 
        if (sel) {
                // we can't move into anything new during selection
-               if (Cursor_.size() == Anchor_.size())
+               if (depth() == Anchor_.size())
                        return false;
-               if (t.nucleus() != Anchor_[Cursor_.size()].par_)
+               if (t.nucleus() != Anchor_[depth()].par_)
                        return false;
        }
        return true;
@@ -454,28 +338,21 @@ void MathCursor::insert(char c)
 void MathCursor::insert(MathAtom const & t)
 {
        macroModeClose();
-
-       if (selection_) {
-               if (t->nargs())
-                       selCut();
-               else
-                       selClearOrDel();
-       }
-
+       selClearOrDel();
        plainInsert(t);
 }
 
 
 void MathCursor::niceInsert(MathAtom const & t)
 {
-       selCut();
-       insert(t); // inserting invalidates the pointer!
-       MathAtom & p = prevAtom();
+       macroModeClose();
+       MathGridInset safe = grabAndEraseSelection();
+       plainInsert(t);
        // enter the new inset and move the contents of the selection if possible
-       if (p->isActive()) {
-               push(p);
-               par()->idxLast(idx(), pos());
-               selPaste();
+       if (t->isActive()) {
+               posLeft();
+               pushLeft(nextAtom());
+               paste(safe);
        }
 }
 
@@ -484,7 +361,7 @@ void MathCursor::insert(MathArray const & ar)
 {
        macroModeClose();
        if (selection_)
-               selCut();
+               eraseSelection();
 
        array().insert(pos(), ar);
        pos() += ar.size();
@@ -500,6 +377,35 @@ void MathCursor::paste(MathArray const & ar)
 }
 
 
+void MathCursor::paste(MathGridInset const & data)
+{
+       if (data.nargs() == 1) {
+               // single cell/part of cell
+               paste(data.cell(0));
+       } else {
+               // mulitple cells
+               idx_type idx; // index of upper left cell
+               MathGridInset * p = enclosingGrid(idx);
+               col_type const numcols = min(data.ncols(), p->ncols() - p->col(idx));
+               row_type const numrows = min(data.nrows(), p->nrows() - p->row(idx));
+               for (row_type row = 0; row < numrows; ++row) {
+                       for (col_type col = 0; col < numcols; ++col) {
+                               idx_type i = p->index(row + p->row(idx), col + p->col(idx));
+                               p->cell(i).push_back(data.cell(data.index(row, col)));
+                       }
+                       // append the left over horizontal cells to the last column
+                       idx_type i = p->index(row + p->row(idx), p->ncols() - 1);
+                       for (MathInset::col_type col = numcols; col < data.ncols(); ++col)
+                               p->cell(i).push_back(data.cell(data.index(row, col)));
+               }
+               // append the left over vertical cells to the last _cell_
+               idx_type i = p->nargs() - 1;
+               for (row_type row = numrows; row < data.nrows(); ++row)
+                       for (col_type col = 0; col < data.ncols(); ++col)
+                               p->cell(i).push_back(data.cell(data.index(row, col)));
+       }
+}
+
 void MathCursor::backspace()
 {
        autocorrect_ = false;
@@ -641,7 +547,13 @@ void MathCursor::macroModeClose()
 
 string MathCursor::macroName() const
 {
-       return inMacroMode() ? inMacroMode()->name() : "";
+       return inMacroMode() ? inMacroMode()->name() : string();
+}
+
+
+void MathCursor::selClear()
+{
+       selection_ = false;
 }
 
 
@@ -649,8 +561,10 @@ void MathCursor::selCopy()
 {
        dump("selCopy");
        if (selection_) {
-               theSelection.grab(*this);
-               //selClear();
+               theCutBuffer = grabSelection();
+               selection_ = false;
+       } else {
+               theCutBuffer = MathGridInset(1, 1);
        }
 }
 
@@ -658,13 +572,7 @@ void MathCursor::selCopy()
 void MathCursor::selCut()
 {
        dump("selCut");
-       if (selection_) {
-               theSelection.grab(*this);
-               theSelection.erase(*this);
-               selClear();
-       } else {
-               theSelection.clear();
-       }
+       theCutBuffer = grabAndEraseSelection();
 }
 
 
@@ -672,10 +580,8 @@ void MathCursor::selDel()
 {
        dump("selDel");
        if (selection_) {
-               theSelection.erase(*this);
-               if (pos() > size())
-                       pos() = size();
-               selClear();
+               eraseSelection();
+               selection_ = false;
        }
 }
 
@@ -684,9 +590,9 @@ void MathCursor::selPaste()
 {
        dump("selPaste");
        selClearOrDel();
-       theSelection.paste(*this);
-       //theSelection.grab(*this);
-       selClear();
+       paste(theCutBuffer);
+       //grabSelection();
+       selection_ = false;
 }
 
 
@@ -694,8 +600,8 @@ void MathCursor::selHandle(bool sel)
 {
        if (sel == selection_)
                return;
-       //theSelection.clear();
-       Anchor_    = Cursor_;
+       //clear();
+       Anchor_ = Cursor_;
        selection_ = sel;
 }
 
@@ -703,38 +609,27 @@ void MathCursor::selHandle(bool sel)
 void MathCursor::selStart()
 {
        dump("selStart 1");
-       //theSelection.clear();
+       //clear();
        Anchor_ = Cursor_;
        selection_ = true;
        dump("selStart 2");
 }
 
 
-void MathCursor::selClear()
-{
-       dump("selClear 1");
-       selection_ = false;
-       dump("selClear 2");
-}
-
-
 void MathCursor::selClearOrDel()
 {
        if (lyxrc.auto_region_delete)
                selDel();
        else
-               selClear();
+               selection_ = false;
 }
 
 
 void MathCursor::selGet(MathArray & ar)
 {
        dump("selGet");
-       if (!selection_)
-               return;
-
-       theSelection.grab(*this);
-       ar = theSelection.glue();
+       if (selection_)
+               ar = grabSelection().glue();
 }
 
 
@@ -790,10 +685,7 @@ void MathCursor::handleDelim(string const & l, string const & r)
 
 void MathCursor::handleNest(MathInset * p)
 {
-       if (selection_) {
-               selCut();
-               p->cell(0) = theSelection.glue();
-       }
+       p->cell(0) = grabAndEraseSelection().glue();
        insert(MathAtom(p)); // this invalidates p!
        pushRight(prevAtom());
 }
@@ -871,12 +763,24 @@ bool MathCursor::selection() const
 
 MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
 {
-       for (MathInset::difference_type i = Cursor_.size() - 1; i >= 0; --i) {
+       for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
                MathGridInset * p = Cursor_[i].par_->asGridInset();
                if (p) {
                        idx = Cursor_[i].idx_;
                        return p;
-                       lyxerr << "found grid and idx: " << idx << "\n";
+               }
+       }
+       return 0;
+}
+
+
+MathHullInset * MathCursor::enclosingHull(MathCursor::idx_type & idx) const
+{
+       for (MathInset::difference_type i = depth() - 1; i >= 0; --i) {
+               MathHullInset * p = Cursor_[i].par_->asHullInset();
+               if (p) {
+                       idx = Cursor_[i].idx_;
+                       return p;
                }
        }
        return 0;
@@ -885,7 +789,14 @@ MathGridInset * MathCursor::enclosingGrid(MathCursor::idx_type & idx) const
 
 void MathCursor::popToEnclosingGrid()
 {
-       while (Cursor_.size() && !Cursor_.back().par_->asGridInset())
+       while (depth() && !Cursor_.back().par_->asGridInset())
+               Cursor_.pop_back();
+}
+
+
+void MathCursor::popToEnclosingHull()
+{
+       while (depth() && !Cursor_.back().par_->asHullInset())
                Cursor_.pop_back();
 }
 
@@ -962,7 +873,7 @@ void MathCursor::normalize()
        // remove empty scripts if possible
        if (1) {
                for (pos_type i = 0; i < size(); ++i) {
-                       MathScriptInset * p = array().at(i)->asScriptInset();
+                       MathScriptInset * p = array()[i]->asScriptInset();
                        if (p) {
                                p->removeEmptyScripts();
                                //if (p->empty())
@@ -984,13 +895,17 @@ MathCursor::size_type MathCursor::size() const
 
 MathCursor::col_type MathCursor::hullCol() const
 {
-       return Cursor_[0].par_->asGridInset()->col(Cursor_[0].idx_);
+       idx_type idx = 0;
+       MathHullInset * p = enclosingHull(idx);
+       return p->col(idx);
 }
 
 
 MathCursor::row_type MathCursor::hullRow() const
 {
-       return Cursor_[0].par_->asGridInset()->row(Cursor_[0].idx_);
+       idx_type idx = 0;
+       MathHullInset * p = enclosingHull(idx);
+       return p->row(idx);
 }
 
 
@@ -1009,28 +924,28 @@ bool MathCursor::hasNextAtom() const
 MathAtom const & MathCursor::prevAtom() const
 {
        lyx::Assert(pos() > 0);
-       return array().at(pos() - 1);
+       return array()[pos() - 1];
 }
 
 
 MathAtom & MathCursor::prevAtom()
 {
        lyx::Assert(pos() > 0);
-       return array().at(pos() - 1);
+       return array()[pos() - 1];
 }
 
 
 MathAtom const & MathCursor::nextAtom() const
 {
        lyx::Assert(pos() < size());
-       return array().at(pos());
+       return array()[pos()];
 }
 
 
 MathAtom & MathCursor::nextAtom()
 {
        lyx::Assert(pos() < size());
-       return array().at(pos());
+       return array()[pos()];
 }
 
 
@@ -1043,8 +958,8 @@ MathArray & MathCursor::array() const
                return dummy;
        }
 
-       if (Cursor_.size() == 0) {
-               lyxerr << "############  Cursor_.size() == 0 not valid\n";
+       if (depth() == 0) {
+               lyxerr << "############  depth() == 0 not valid\n";
                return dummy;
        }
 
@@ -1056,8 +971,8 @@ MathXArray & MathCursor::xarray() const
 {
        static MathXArray dummy;
 
-       if (Cursor_.size() == 0) {
-               lyxerr << "############  Cursor_.size() == 0 not valid\n";
+       if (depth() == 0) {
+               lyxerr << "############  depth() == 0 not valid\n";
                return dummy;
        }
 
@@ -1096,14 +1011,15 @@ void MathCursor::breakLine()
        while (popRight())
                ;
 
-       MathHullInset * p = formula()->par()->asHullInset();
+       idx_type dummy;
+       MathHullInset * p = enclosingHull(dummy);
        if (!p)
                return;
 
        if (p->getType() == LM_OT_SIMPLE || p->getType() == LM_OT_EQUATION) {
                p->mutate(LM_OT_EQNARRAY);
-               idx() = 0;
-               pos() = size();
+               idx() = 1;
+               pos() = 0;
        } else {
                p->addRow(hullRow());
 
@@ -1158,14 +1074,14 @@ void MathCursor::getSelection(MathCursorPos & i1, MathCursorPos & i2) const
 
 MathCursorPos & MathCursor::cursor()
 {
-       lyx::Assert(Cursor_.size());
+       lyx::Assert(depth());
        return Cursor_.back();
 }
 
 
 MathCursorPos const & MathCursor::cursor() const
 {
-       lyx::Assert(Cursor_.size());
+       lyx::Assert(depth());
        return Cursor_.back();
 }
 
@@ -1301,6 +1217,22 @@ bool MathCursor::bruteFind
 }
 
 
+bool MathCursor::idxLineFirst()
+{
+       idx() -= idx() % par()->ncols();
+       pos() = 0;
+       return true;
+}
+
+
+bool MathCursor::idxLineLast()
+{
+       idx() -= idx() % par()->ncols();
+       idx() += par()->ncols() - 1;
+       pos() = size();
+       return true;
+}
+
 bool MathCursor::idxLeft()
 {
        return par()->idxLeft(idx(), pos());
@@ -1320,7 +1252,7 @@ bool MathCursor::interpret(string const & s)
                return true;
 
        //lyxerr << "char: '" << s[0] << "'  int: " << int(s[0]) << endl;
-       //owner_->getIntl()->getTrans().TranslateAndInsert(s[0], lt);
+       //owner_->getIntl()->getTransManager().TranslateAndInsert(s[0], lt);
        //lyxerr << "trans: '" << s[0] << "'  int: " << int(s[0]) << endl;
 
        if (s.size() >= 5 && s.substr(0, 5) == "cases") {
@@ -1396,7 +1328,7 @@ bool MathCursor::script(bool up)
        }
 
        macroModeClose();
-       selCut();
+       MathGridInset safe = grabAndEraseSelection();
        if (hasPrevAtom() && prevAtom()->asScriptInset()) {
                prevAtom()->asScriptInset()->ensure(up);
                pushRight(prevAtom());
@@ -1414,7 +1346,7 @@ bool MathCursor::script(bool up)
                idx() = up;
                pos() = 0;
        }
-       selPaste();
+       paste(safe);
        dump("1");
        return true;
 }
@@ -1438,7 +1370,7 @@ bool MathCursor::interpret(char c)
                if (p && 1 <= n && n <= p->numargs())
                        insert(MathAtom(new MathMacroArgument(c - '0')));
                else {
-                       insert(MathAtom(new MathSpecialCharInset('#')));
+                       insert(createMathInset("#"));
                        interpret(c); // try again
                }
                return true;
@@ -1485,7 +1417,7 @@ bool MathCursor::interpret(char c)
 
        // just clear selection on pressing the space par
        if (selection_ && c == ' ') {
-               selClear();
+               selection_ = false;
                return true;
        }
 
@@ -1539,8 +1471,13 @@ bool MathCursor::interpret(char c)
                return true;
        }
 
-       if (c == '$' || c == '%') {
-               insert(MathAtom(new MathSpecialCharInset(c)));
+       if (c == '$') {
+               insert(createMathInset("$"));
+               return true;
+       }
+
+       if (c == '%') {
+               insert(createMathInset("%"));
                return true;
        }
 
@@ -1574,40 +1511,6 @@ bool MathCursor::interpret(char c)
 }
 
 
-
-MathCursorPos MathCursor::normalAnchor() const
-{
-       if (Anchor_.size() < Cursor_.size()) {
-               Anchor_ = Cursor_;
-               lyxerr << "unusual Anchor size\n";
-               dump("1");
-       }
-       //lyx::Assert(Anchor_.size() >= Cursor_.size());
-       // use Anchor on the same level as Cursor
-       MathCursorPos normal = Anchor_[Cursor_.size() - 1];
-       if (Cursor_.size() < Anchor_.size() && !(normal < cursor())) {
-               // anchor is behind cursor -> move anchor behind the inset
-               ++normal.pos_;
-       }
-       return normal;
-}
-
-
-void MathCursor::stripFromLastEqualSign()
-{
-       // find position of last '=' in the array
-       MathArray & ar = cursor().cell();
-       MathArray::const_iterator et = ar.end();
-       for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
-               if ((*it)->getChar() == '=')
-                       et = it;
-
-       // delete everything behind this position
-       ar.erase(et - ar.begin(), ar.size());
-       pos() = ar.size();
-}
-
-
 void MathCursor::setSelection(cursor_type const & where, size_type n)
 {
        selection_ = true;
@@ -1628,7 +1531,7 @@ string MathCursor::info() const
 {
        ostringstream os;
        os << "Math editor mode ";
-       for (int i = 0, n = Cursor_.size(); i < n; ++i) {
+       for (int i = 0, n = depth(); i < n; ++i) {
                Cursor_[i].par_->infoize(os);
                os << "  ";
        }
@@ -1637,3 +1540,179 @@ string MathCursor::info() const
        os << "                ";
        return os.str().c_str(); // .c_str() needed for lyxstring
 }
+
+
+unsigned MathCursor::depth() const
+{
+       return Cursor_.size();
+}
+
+
+
+
+namespace {
+
+void region(MathCursorPos const & i1, MathCursorPos const & i2,
+       MathInset::row_type & r1, MathInset::row_type & r2,
+       MathInset::col_type & c1, MathInset::col_type & c2)
+{
+       MathInset * p = i1.par_;
+       c1 = p->col(i1.idx_);
+       c2 = p->col(i2.idx_);
+       if (c1 > c2)
+               swap(c1, c2);
+       r1 = p->row(i1.idx_);
+       r2 = p->row(i2.idx_);
+       if (r1 > r2)
+               swap(r1, r2);
+}
+
+}
+
+
+MathGridInset MathCursor::grabSelection() const
+{
+       if (!selection_)
+               return MathGridInset();
+       MathCursorPos i1;
+       MathCursorPos i2;
+       getSelection(i1, i2);
+       // shouldn't we assert on i1.par_ == i2.par_?
+       if (i1.idx_ == i2.idx_) {
+               MathGridInset data(1, 1);
+               data.cell(0) = MathArray(i1.cell(), i1.pos_, i2.pos_);
+               return data;
+       }
+       row_type r1, r2;
+       col_type c1, c2;
+       region(i1, i2, r1, r2, c1, c2);
+       MathGridInset data(c2 - c1 + 1, r2 - r1 + 1);
+       for (row_type row = 0; row < data.nrows(); ++row)
+               for (col_type col = 0; col < data.ncols(); ++col) {
+                       idx_type i = i1.par_->index(row + r1, col + c1);
+                       data.cell(data.index(row, col)) = i1.par_->cell(i);
+               }
+       return data;
+}
+
+
+void MathCursor::eraseSelection()
+{
+       MathCursorPos i1;
+       MathCursorPos i2;
+       getSelection(i1, i2);
+       if (i1.idx_ == i2.idx_)
+               i1.cell().erase(i1.pos_, i2.pos_);
+       else {
+               MathInset * p = i1.par_;
+               row_type r1, r2;
+               col_type c1, c2;
+               region(i1, i2, r1, r2, c1, c2);
+               for (row_type row = r1; row <= r2; ++row)
+                       for (col_type col = c1; col <= c2; ++col)
+                               p->cell(p->index(row, col)).erase();
+       }
+       cursor() = i1;
+}
+
+
+MathGridInset MathCursor::grabAndEraseSelection()
+{
+       if (!selection_)
+               return MathGridInset();
+       MathGridInset res = grabSelection();
+       eraseSelection();
+       selection_ = false;
+       return res;
+}
+
+
+MathCursorPos MathCursor::normalAnchor() const
+{
+       if (Anchor_.size() < depth()) {
+               Anchor_ = Cursor_;
+               lyxerr << "unusual Anchor size\n";
+       }
+       //lyx::Assert(Anchor_.size() >= cursor.depth());
+       // use Anchor on the same level as Cursor
+       MathCursorPos normal = Anchor_[depth() - 1];
+       if (depth() < Anchor_.size() && !(normal < cursor())) {
+               // anchor is behind cursor -> move anchor behind the inset
+               ++normal.pos_;
+       }
+       return normal;
+}
+
+
+
+void MathCursor::handleExtern(const string & arg)
+{
+       string lang;
+       string extra;
+       istringstream iss(arg.c_str());
+       iss >> lang >> extra;
+       if (extra.empty())
+               extra = "noextra";
+       
+
+       if (selection()) {
+               MathArray ar;
+               selGet(ar);
+               lyxerr << "use selection: " << ar << "\n";
+               insert(pipeThroughExtern(lang, extra, ar));
+               return;
+       }
+
+       MathArray eq;
+       eq.push_back(MathAtom(new MathCharInset('=')));
+
+       popToEnclosingHull();
+
+       idx_type idx = 0;
+       MathHullInset * hull = enclosingHull(idx);
+       lyx::Assert(hull);
+       idxLineFirst();
+
+       if (hull->getType() == LM_OT_SIMPLE) {
+               MathArray::size_type pos = cursor().cell().find_last(eq);
+               MathArray ar;
+               if (pos == size()) {
+                       ar = array();
+                       lyxerr << "use whole cell: " << ar << "\n";
+               } else {
+                       ar = MathArray(array(), pos + 1, size());
+                       lyxerr << "use partial cell form pos: " << pos << "\n";
+               }
+               end();
+               insert(eq);
+               insert(pipeThroughExtern(lang, extra, ar));
+               return;
+       }
+       
+       if (hull->getType() == LM_OT_EQUATION) {
+               lyxerr << "use equation inset\n";
+               hull->mutate(LM_OT_EQNARRAY);
+               MathArray & ar = cursor().cell();
+               lyxerr << "use cell: " << ar << "\n";
+               idxRight();
+               cursor().cell() = eq;
+               idxRight();
+               cursor().cell() = pipeThroughExtern(lang, extra, ar);
+               idxLineLast();
+               return;
+       } 
+       
+       {
+               lyxerr << "use eqnarray\n";
+               idxLineLast();
+               MathArray ar = cursor().cell();
+               lyxerr << "use cell: " << ar << "\n";
+               breakLine();
+               idxRight();
+               cursor().cell() = eq;
+               idxRight();
+               cursor().cell() = pipeThroughExtern(lang, extra, ar);
+               idxLineLast();
+       }
+
+}
index 1d8e95950b88b83ef77bf30f50b10ba09ba18827..f6bad5629b27696c6a74b025197a2e33550e2d44 100644 (file)
@@ -66,6 +66,8 @@ public:
        ///
        void paste(MathArray const &);
        ///
+       void paste(MathGridInset const & data);
+       ///
        void erase();
        ///
        void backspace();
@@ -105,9 +107,13 @@ public:
        /// current inset
        MathInset * par() const;
        /// return the next enclosing grid inset and the cursor's index in it
-       MathGridInset * enclosingGrid(idx_type &) const;
-       /// return the next enclosing grid inset and the cursor's index in it
+       MathGridInset * enclosingGrid(idx_type & idx) const;
+       /// return the next enclosing hull inset and the cursor's index in it
+       MathHullInset * enclosingHull(idx_type & idx) const;
+       /// go up to enclosing grid
        void popToEnclosingGrid();
+       /// go up to the hull inset
+       void popToEnclosingHull();
        ///
        InsetFormulaBase * formula();
        /// current offset in the current cell
@@ -229,6 +235,8 @@ public:
        MathCursorPos & cursor();
        /// reference to the last item of the path, i.e. "The Cursor"
        MathCursorPos const & cursor() const;
+       /// how deep are we nested?
+       unsigned depth() const;
 
        /// describe the situation
        string info() const;
@@ -236,8 +244,6 @@ public:
        void seldump(char const * str) const;
        /// dump selection information for debugging
        void dump(char const * str) const;
-       ///
-       void stripFromLastEqualSign();
        /// moves on
        void setSelection(cursor_type const & where, size_type n);
        ///
@@ -248,24 +254,38 @@ public:
        /// hack for reveal codes
        void markInsert();
        void markErase();
+       void handleExtern(string const & arg);
 
        ///
        friend class Selection;
 
+
 private:
-       /// moves cursor position one cell to the left
-       bool posLeft();
-       /// moves cursor position one cell to the right
-       bool posRight();
        /// moves cursor index one cell to the left
        bool idxLeft();
        /// moves cursor index one cell to the right
        bool idxRight();
+       /// moves cursor to beginning first cell of current line
+       bool idxLineFirst();
+       /// moves cursor to end of last cell of current line
+       bool idxLineLast();
+       /// moves cursor position one cell to the left
+       bool posLeft();
+       /// moves cursor position one cell to the right
+       bool posRight();
        /// moves position somehow up or down
        bool goUpDown(bool up);
        /// moves position into box
        bool bruteFind(int xo, int yo, int xlow, int xhigh, int ylow, int yhigh);
 
+
+       /// grab grid marked by anchor and current cursor 
+       MathGridInset grabSelection() const;
+       /// erase the selected part and re-sets the cursor
+       void eraseSelection();
+       /// guess what
+       MathGridInset grabAndEraseSelection();
+
        ///
        string macroName() const;
        ///
@@ -277,9 +297,9 @@ private:
        /// write access to cursor cell index
        idx_type & idx();
 
-       /// path of positions the cursor had to go if it were leving each inset
+       /// path of positions the cursor had to go if it were leaving each inset
        cursor_type Cursor_;
-       /// path of positions the anchor had to go if it were leving each inset
+       /// path of positions the anchor had to go if it were leaving each inset
        mutable cursor_type Anchor_;
        /// pointer to enclsing LyX inset
        InsetFormulaBase * formula_;
index 7ef98e0589ddb92a862920e69aea94428a522d62..4aa7431b64a03124842bc50ae377ea16865e5c83 100644 (file)
@@ -230,16 +230,10 @@ bool MathArray::matchpart(MathArray const & ar, pos_type pos) const
 void MathArray::replace(ReplaceData & rep)
 {
        for (size_type i = 0; i < size(); ++i) {
-               iterator it = begin() + i;
-               const_iterator rt = rep.from.begin();
-               const_iterator et = rep.from.end();
-               for (const_iterator jt = it; jt != end() && rt != et; ++jt, ++rt)
-                       if (!jt->nucleus()->match(rt->nucleus()))
-                               break;
-               if (rt == et) {
+               if (find1(rep.from, i)) {
                        // match found
                        lyxerr << "match found!\n";
-                       erase(it, it + rep.from.size());
+                       erase(i, i + rep.from.size());
                        insert(i, rep.to);
                }
        }
@@ -249,22 +243,40 @@ void MathArray::replace(ReplaceData & rep)
 }
 
 
-bool MathArray::contains(MathArray const & ar) const
+bool MathArray::find1(MathArray const & ar, size_type pos) const
 {
-       for (size_type i = 0; i + ar.size() <= size(); ++i) {
-               const_iterator it = begin() + i;
-               const_iterator rt = ar.begin();
-               const_iterator et = ar.end();
-               for (const_iterator jt = it; rt != et; ++jt, ++rt)
-                       if (!jt->nucleus()->match(rt->nucleus()))
-                               break;
-               if (rt == et)
-                       return true;
-       }
+       //lyxerr << "finding '" << ar << "' in '" << *this << "'\n";
+       for (size_type i = 0, n = ar.size(); i < n; ++i)
+               if (!at(pos + i)->match(ar[i].nucleus()))
+                       return false;
+       return true;
+}
+
+
+MathArray::size_type MathArray::find(MathArray const & ar) const
+{
+       for (int i = 0, last = size() - ar.size(); i < last; ++i)
+               if (find1(ar, i))
+                       return i;
+       return size();
+}
+
+
+MathArray::size_type MathArray::find_last(MathArray const & ar) const
+{
+       for (int i = size() - ar.size(); i >= 0; --i) 
+               if (find1(ar, i))
+                       return i;
+       return size();
+}
 
+
+bool MathArray::contains(MathArray const & ar) const
+{
+       if (find(ar) != size())
+               return true;
        for (const_iterator it = begin(); it != end(); ++it)
                if (it->nucleus()->contains(ar))
                        return true;
-
        return false;
 }
index 2b94c69dd074633e663f07d34f24079435acddc1..66994e7ccc27d6692a4e85e0767659b21e860cdf 100644 (file)
@@ -61,7 +61,7 @@ public:
        ///
        MathArray();
        ///
-       MathArray(MathArray const &, size_type from, size_type to);
+       MathArray(MathArray const & ar, size_type from, size_type to);
        ///
        MathArray(iterator from, iterator to);
 
@@ -74,26 +74,26 @@ public:
        ///
        void swap(MathArray &);
 
-       ///
-       void insert(size_type pos, MathAtom const &);
-       ///
-       void insert(size_type pos, MathArray const &);
+       /// inserts single atom at position pos
+       void insert(size_type pos, MathAtom const & at);
+       /// inserts multiple atoms at position pos
+       void insert(size_type pos, MathArray const & ar);
 
-       ///
+       /// erase range from pos1 to pos2
        void erase(iterator pos1, iterator pos2);
-       ///
+       /// erase single atom
        void erase(iterator pos);
-       ///
+       /// erase range from pos1 to pos2
        void erase(size_type pos1, size_type pos2);
-       ///
+       /// erase single atom
        void erase(size_type pos);
-       ///
+       /// erase everythng
        void erase();
 
        ///
-       void push_back(MathAtom const &);
+       void push_back(MathAtom const & at);
        ///
-       void push_back(MathArray const &);
+       void push_back(MathArray const & ar);
        ///
        void pop_back();
        ///
@@ -109,22 +109,25 @@ public:
        ///
        void dump2() const;
        ///
-       void substitute(MathMacro const &);
-       /// looks for exact match
-       bool match(MathArray const &) const;
-       /// looks for inclusion match starting at pos
-       bool matchpart(MathArray const &, pos_type pos) const;
-       /// looks for containment
-       bool contains(MathArray const &) const;
+       void substitute(MathMacro const & macro);
        ///
        void replace(ReplaceData &);
 
+       /// looks for exact match
+       bool match(MathArray const & ar) const;
+       /// looks for inclusion match starting at pos
+       bool matchpart(MathArray const & ar, pos_type pos) const;
+       /// looks for containment, return == size mean not found
+       size_type find(MathArray const & ar) const;
+       /// looks for containment, return == size mean not found
+       size_type find_last(MathArray const & ar) const;
        ///
-       MathAtom & at(size_type pos);
-       ///
-       MathAtom const & at(size_type pos) const;
-       ///
-       void validate(LaTeXFeatures &) const;
+       bool contains(MathArray const & ar) const;
+
+       /// write acccess to single atom
+       MathAtom & operator[](size_type pos) { return at(pos); }
+       /// read access o single atom
+       MathAtom const & operator[](size_type pos) const { return at(pos); }
        ///
        const_iterator begin() const;
        ///
@@ -134,7 +137,17 @@ public:
        ///
        iterator end();
 
+       ///
+       void validate(LaTeXFeatures &) const;
+
 private:
+       /// is this an exact match at this position?
+       bool find1(MathArray const & ar, size_type pos) const;
+       /// write acccess to single atom
+       MathAtom & at(size_type pos);
+       /// read access o single atom
+       MathAtom const & at(size_type pos) const;
+
        /// Buffer
        buffer_type bf_;
 };
index 502c640e2d2d236725422e4b5f67f7bedd49e667..be0a463790c852b2a2e601982e5f13fb0a090134 100644 (file)
@@ -2,9 +2,10 @@
 // information" from the unstructered layout-oriented stuff in an
 // MathArray.
 
-#include <algorithm>
+#include <config.h>
 
 #include "math_amsarrayinset.h"
+#include "math_arrayinset.h"
 #include "math_charinset.h"
 #include "math_deliminset.h"
 #include "math_diffinset.h"
 #include "math_fracinset.h"
 #include "math_matrixinset.h"
 #include "math_mathmlstream.h"
+#include "math_numberinset.h"
 #include "math_scriptinset.h"
 #include "math_stringinset.h"
 #include "math_symbolinset.h"
 #include "math_unknowninset.h"
+#include "math_parser.h"
 #include "Lsstream.h"
 #include "debug.h"
+#include "support/lyxlib.h"
+#include "support/systemcall.h"
+#include "support/filetools.h"
 
+#include <algorithm>
 
 using std::ostream;
 using std::istringstream;
 using std::find_if;
+using std::endl;
 
 
 ostream & operator<<(ostream & os, MathArray const & ar)
@@ -120,12 +128,13 @@ MathScriptInset const * asScript(MathArray::const_iterator it)
 
 // returns sequence of char with same code starting at it up to end
 // it might be less, though...
-MathArray::const_iterator charSequence(MathArray::const_iterator it,
-       MathArray::const_iterator end, string & s)
+string charSequence
+       (MathArray::const_iterator it, MathArray::const_iterator end)
 {
+       string s;
        for (; it != end && (*it)->asCharInset(); ++it)
                s += (*it)->getChar();
-       return it;
+       return s;
 }
 
 
@@ -133,18 +142,11 @@ void extractStrings(MathArray & ar)
 {
        //lyxerr << "\nStrings from: " << ar << "\n";
        for (MathArray::size_type i = 0; i < ar.size(); ++i) {
-               MathArray::iterator it = ar.begin() + i;
-               if (!(*it)->asCharInset())
+               if (!ar[i]->asCharInset())
                        continue;
-
-               // create proper string inset
-               MathStringInset * p = new MathStringInset;
-               MathArray::const_iterator
-                       jt = charSequence(it, ar.end(), p->str_);
-
-               // clean up
-               (*it).reset(p);
-               ar.erase(i + 1, jt - ar.begin());
+               string s = charSequence(ar.begin() + i, ar.end());
+               ar[i].reset(new MathStringInset(s));
+               ar.erase(i + 1, i + s.size());
        }
        //lyxerr << "\nStrings to: " << ar << "\n";
 }
@@ -201,20 +203,16 @@ bool extractString(MathInset * p, string & str)
 // convert this inset somehow to a number
 bool extractNumber(MathArray const & ar, int & i)
 {
-       string s;
-       charSequence(ar.begin(), ar.end(), s);
-       istringstream is(s.c_str());
+       istringstream is(charSequence(ar.begin(), ar.end()).c_str());
        is >> i;
        return is;
 }
 
 
-bool extractNumber(MathArray const & ar, double & i)
+bool extractNumber(MathArray const & ar, double & d)
 {
-       string s;
-       charSequence(ar.begin(), ar.end(), s);
-       istringstream is(s.c_str());
-       is >> i;
+       istringstream is(charSequence(ar.begin(), ar.end()).c_str());
+       is >> d;
        return is;
 }
 
@@ -345,6 +343,49 @@ void extractExps(MathArray & ar)
 }
 
 
+//
+// search numbers
+//
+
+bool isDigitOrSimilar(char c)
+{
+       return ('0' <= c && c <= '9') || c == '.';
+}
+
+
+// returns sequence of digits
+string digitSequence
+       (MathArray::const_iterator it, MathArray::const_iterator end)
+{
+       string s;
+       for (; it != end && (*it)->asCharInset(); ++it) {
+               if (!isDigitOrSimilar((*it)->getChar()))
+                       break;
+               s += (*it)->getChar();
+       }
+       return s;
+}
+
+
+void extractNumbers(MathArray & ar)
+{
+       //lyxerr << "\nNumbers from: " << ar << "\n";
+       for (MathArray::size_type i = 0; i < ar.size(); ++i) {
+               if (!ar[i]->asCharInset())
+                       continue;
+               if (!isDigitOrSimilar(ar[i]->asCharInset()->getChar()))
+                       continue;
+
+               string s = digitSequence(ar.begin() + i, ar.end());
+
+               ar[i].reset(new MathNumberInset(s));
+               ar.erase(i + 1, i + s.size());
+       }
+       //lyxerr << "\nNumbers to: " << ar << "\n";
+}
+
+
+
 //
 // search deliminiters
 //
@@ -660,7 +701,7 @@ void extractDiff(MathArray & ar)
                MathArray::iterator jt = it + 1;
                //int n = 1;
                MathArray & numer = f->cell(0);
-               if (numer.size() > 1 && numer.at(1)->asScriptInset()) {
+               if (numer.size() > 1 && numer[1]->asScriptInset()) {
                        // this is something like  d^n f(x) / d... or  d^n / d...
                        // FIXME
                        //n = 1;
@@ -716,6 +757,7 @@ void extractDiff(MathArray & ar)
 void extractStructure(MathArray & ar)
 {
        splitScripts(ar);
+       extractNumbers(ar);
        extractMatrices(ar);
        extractDelims(ar);
        extractFunctions(ar);
@@ -813,3 +855,200 @@ void mathmlize(MathArray const & dat, MathMLStream & os)
                os << ETag("mrow");
        }
 }
+
+
+
+
+namespace {
+
+       string captureOutput(string const & cmd, string const & data)
+       {
+               string outfile = lyx::tempName(string(), "mathextern");
+               string full =  "echo '" + data + "' | (" + cmd + ") > " + outfile;
+               lyxerr << "calling: " << full << endl;
+               Systemcall dummy;
+               dummy.startscript(Systemcall::Wait, full);
+               string out = GetFileContents(outfile);
+               lyx::unlink(outfile);
+               lyxerr << "result: '" << out << "'" << endl;
+               return out;
+       }
+
+
+       MathArray pipeThroughMaple(string const & extra, MathArray const & ar)
+       {
+               string header = "readlib(latex):\n";
+
+               // remove the \\it for variable names
+               //"#`latex/csname_font` := `\\it `:"
+               header +=
+                       "`latex/csname_font` := ``:\n";
+
+               // export matrices in (...) instead of [...]
+               header +=
+                       "`latex/latex/matrix` := "
+                               "subs(`[`=`(`, `]`=`)`,"
+                                       "eval(`latex/latex/matrix`)):\n";
+
+               // replace \\cdots with proper '*'
+               header +=
+                       "`latex/latex/*` := "
+                               "subs(`\\,`=`\\cdot `,"
+                                       "eval(`latex/latex/*`)):\n";
+
+               // remove spurious \\noalign{\\medskip} in matrix output
+               header +=
+                       "`latex/latex/matrix`:= "
+                               "subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
+                                       "eval(`latex/latex/matrix`)):\n";
+
+               //"#`latex/latex/symbol` "
+               //      " := subs((\\'_\\' = \\'`\\_`\\',eval(`latex/latex/symbol`)): ";
+
+               string trailer = "quit;";
+               ostringstream os;
+               MapleStream ms(os);
+               ms << ar;
+               string expr = os.str().c_str();
+               lyxerr << "ar: '" << ar << "'\n";
+
+               for (int i = 0; i < 100; ++i) { // at most 100 attempts
+                       // try to fix missing '*' the hard way by using mint
+                       //
+                       // ... > echo "1A;" | mint -i 1 -S -s -q
+                       // on line     1: 1A;
+                       //                 ^ syntax error -
+                       //                   Probably missing an operator such as * p
+                       //
+                       lyxerr << "checking expr: '" << expr << "'\n";
+                       string out = captureOutput("mint -i 1 -S -s -q -q", expr + ";");
+                       if (out.empty())
+                               break; // expression syntax is ok
+                       istringstream is(out.c_str());
+                       string line;
+                       getline(is, line);
+                       if (line.find("on line") != 0)
+                               break; // error message not identified
+                       getline(is, line);
+                       string::size_type pos = line.find('^');
+                       if (pos == string::npos || pos < 15)
+                               break; // caret position not found
+                       pos -= 15; // skip the "on line ..." part
+                       if (expr[pos] == '*' || (pos > 0 && expr[pos - 1] == '*'))
+                               break; // two '*' in a row are definitely bad
+                       expr.insert(pos,  "*");
+               }
+
+               string full = "latex(" +  extra + '(' + expr + "));";
+               string out = captureOutput("maple -q", header + full + trailer);
+
+               // change \_ into _
+
+               //
+               MathArray res;
+               mathed_parse_cell(res, out);
+               return res;
+       }
+
+
+       MathArray pipeThroughOctave(string const &, MathArray const & ar)
+       {
+               ostringstream os;
+               OctaveStream vs(os);
+               vs << ar;
+               string expr = os.str().c_str();
+               string out;
+
+               lyxerr << "pipe: ar: '" << ar << "'\n";
+               lyxerr << "pipe: expr: '" << expr << "'\n";
+
+               for (int i = 0; i < 100; ++i) { // at most 100 attempts
+                       //
+                       // try to fix missing '*' the hard way
+                       // parse error:
+                       // >>> ([[1 2 3 ];[2 3 1 ];[3 1 2 ]])([[1 2 3 ];[2 3 1 ];[3 1 2 ]])
+                       //                                   ^
+                       //
+                       lyxerr << "checking expr: '" << expr << "'\n";
+                       out = captureOutput("octave -q 2>&1", expr);
+                       lyxerr << "checking out: '" << out << "'\n";
+
+                       // leave loop if expression syntax is probably ok
+                       if (out.find("parse error:") == string::npos)
+                               break;
+
+                       // search line with single caret
+                       istringstream is(out.c_str());
+                       string line;
+                       while (is) {
+                               getline(is, line);
+                               lyxerr << "skipping line: '" << line << "'\n";
+                               if (line.find(">>> ") != string::npos)
+                                       break;
+                       }
+
+                       // found line with error, next line is the one with caret
+                       getline(is, line);
+                       string::size_type pos = line.find('^');
+                       lyxerr << "caret line: '" << line << "'\n";
+                       lyxerr << "found caret at pos: '" << pos << "'\n";
+                       if (pos == string::npos || pos < 4)
+                               break; // caret position not found
+                       pos -= 4; // skip the ">>> " part
+                       if (expr[pos] == '*')
+                               break; // two '*' in a row are definitely bad
+                       expr.insert(pos,  "*");
+               }
+
+               if (out.size() < 6)
+                       return MathArray();
+
+               // remove 'ans = '
+               out = out.substr(6);
+
+               // parse output as matrix or single number
+               MathAtom at(new MathArrayInset("array", out));
+               MathArrayInset const * mat = at.nucleus()->asArrayInset();
+               MathArray res;
+               if (mat->ncols() == 1 && mat->nrows() == 1)
+                       res.push_back(mat->cell(0));
+               else {
+                       res.push_back(MathAtom(new MathDelimInset("(", ")")));
+                       res.back()->cell(0).push_back(at);
+               }
+               return res;
+       }
+
+}
+
+
+MathArray pipeThroughExtern(string const & lang, string const & extra,
+       MathArray const & ar)
+{
+       if (lang == "octave")
+               return pipeThroughOctave(extra, ar);
+
+       if (lang == "maple")
+               return pipeThroughMaple(extra, ar);
+
+       // create normalized expression
+       ostringstream os;
+       NormalStream ns(os);
+       os << "[" << extra << ' ';
+       ns << ar;
+       os << "]";
+       string data = os.str().c_str();
+
+       // search external script
+       string file = LibFileSearch("mathed", "extern_" + lang);
+       if (file.empty()) {
+               lyxerr << "converter to '" << lang << "' not found\n";
+               return MathArray();
+       }
+
+       // run external sript
+       string out = captureOutput(file, data);
+       MathArray res;
+       mathed_parse_cell(res, out);
+       return res;
+}
index 6e7270e8efcedfcfe988ccd5671fb040baea7623..37478273759aab9b816aa559e9319220433c5c3f 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef MATH_EXTERN_H
 #define MATH_EXTERN_H
 
+#include "LString.h"
+
 class NormalStream;
 class MapleStream;
 class MathMLStream;
@@ -17,4 +19,7 @@ void octavize(MathArray const &, OctaveStream &);
 bool extractNumber(MathArray const & ar, int & i);
 bool extractNumber(MathArray const & ar, double & i);
 
+MathArray pipeThroughExtern(string const & lang, string const & extra,
+       MathArray const & ar);
+
 #endif
index ba9b6457f86c98ee1123d4e43ef28576ab2bf4a1..954c3f7652b2e8ee5110e5a07d2286acab0dc360 100644 (file)
@@ -9,7 +9,6 @@
 #include "math_decorationinset.h"
 #include "math_dotsinset.h"
 #include "math_fontinset.h"
-#include "math_funcliminset.h"
 #include "math_fracinset.h"
 #include "math_kerninset.h"
 #include "math_lefteqninset.h"
@@ -21,7 +20,6 @@
 #include "math_sizeinset.h"
 #include "math_spaceinset.h"
 #include "math_splitinset.h"
-#include "math_specialcharinset.h"
 #include "math_sqrtinset.h"
 #include "math_stackrelinset.h"
 #include "math_substackinset.h"
 #include "math_xymatrixinset.h"
 #include "math_xyarrowinset.h"
 
-
 #include "math_metricsinfo.h"
 #include "debug.h"
 #include "math_support.h"
 #include "Lsstream.h"
 #include "support/filetools.h" // LibFileSearch
+#include "frontends/font_loader.h"
 
 #include <map>
 #include <fstream>
@@ -52,9 +50,9 @@ WordList theWordList;
 
 struct key_type {
        ///
-       char const * name;
+       string name;
        ///
-       char const * inset;
+       string inset;
        ///
        int id;
 };
@@ -63,44 +61,24 @@ struct key_type {
 key_type wordlist_array[] =
 {
        {"!",  "space", 0},
-       {"#",  "special", 0},
-       {"$",  "special", 0},
-       {"%",  "special", 0},
-       {"&",  "special", 0},
        {"(",  "begin", LM_OT_SIMPLE},
        {")",  "end", LM_OT_SIMPLE},
        {",",  "space", 1},
-       {".",  "special", 0},
        {":",  "space", 2},
        {";",  "space", 3},
-       {"Pr",  "funclim", 0},
        {"[",  "begin", LM_OT_EQUATION},
        {"]",  "end", LM_OT_EQUATION},
-       {"_",  "special", '_'},
        {"acute",  "decoration", 0},
-       {"arccos",  "func", 0},
-       {"arcsin",  "func", 0},
-       {"arctan",  "func", 0},
-       {"arg",  "func", 0},
        {"bar",  "decoration", 0},
        {"begin",  "begin", 0},
        {"bf",  "oldfont", 0},
-       {"bmod",  "func", 0},
        {"breve",  "decoration", 0},
        {"cal",  "oldfont", 0},
        {"cdots",  "dots", 0},
        {"check",  "decoration", 0},
-       {"cos",  "func", 0},
-       {"cosh",  "func", 0},
-       {"cot",  "func", 0},
-       {"coth",  "func", 0},
-       {"csc",  "func", 0},
        {"ddot",  "decoration", 0},
        {"dddot",  "decoration", 0},
        {"ddots",  "dots", 0},
-       {"deg",  "func", 0},
-       {"det",  "funclim", 0},
-       {"dim",  "func", 0},
        {"displaystyle",  "style", LM_ST_DISPLAY},
        {"dot",  "decoration", 0},
        {"dotsb",  "dots", 0},
@@ -109,25 +87,14 @@ key_type wordlist_array[] =
        {"dotsm",  "dots", 0},
        {"dotso",  "dots", 0},
        {"end",  "end", 0},
-       {"exp",  "func", 0},
        {"frak",  "font", 0},
-       {"gcd",  "funclim", 0},
        {"grave",  "decoration", 0},
        {"hat",  "decoration", 0},
-       {"hom",  "func", 0},
-       {"inf",  "funclim", 0},
        {"it",  "oldfont", 0},
-       {"ker",  "func", 0},
        {"label",  "label", 0},
        {"ldots",  "dots", 0},
        {"left",  "left", 0},
-       {"lg",  "func", 0},
-       {"lim",  "funclim", 0},
-       {"liminf",  "funclim", 0},
        {"limits",  "limit", 1 },
-       {"limsup",  "funclim", 0},
-       {"ln",  "func", 0},
-       {"log",  "func", 0},
        {"lyxbox",  "box", 0},
        {"lyxnegspace",  "space", 6},
        {"mathbb",  "font", 0},
@@ -140,9 +107,7 @@ key_type wordlist_array[] =
        {"mathrm",  "font", 0},
        {"mathsf",  "font", 0},
        {"mathtt",  "font", 0},
-       {"max",  "funclim", 0},
        {"mbox",  "box", 0},
-       {"min",  "funclim", 0},
        {"newcommand",  "newcommand", 0 },
        {"nolimits",  "limit", -1},
        {"nonumber",  "nonum", 0},
@@ -158,12 +123,6 @@ key_type wordlist_array[] =
        {"rm",  "oldfont", 0},
        {"scriptscriptstyle",  "style", LM_ST_SCRIPTSCRIPT},
        {"scriptstyle",  "style", LM_ST_SCRIPT},
-       {"sec",  "func", 0},
-       {"sin",  "func", 0},
-       {"sinh",  "func", 0},
-       {"sup",  "funclim", 0},
-       {"tan",  "func", 0},
-       {"tanh",  "func", 0},
        {"textbf",  "font", 1},
        {"textit",  "font", 1},
        {"textmd",  "font", 1},
@@ -183,12 +142,29 @@ key_type wordlist_array[] =
        {"vdots",  "dots", 0},
        {"vec",  "decoration", 0},
        {"widehat",  "decoration", 0},
-       {"widetilde",  "decoration", 0},
-       {"{",  "special", '{'},
-       {"}",  "special", '}'}
+       {"widetilde",  "decoration", 0}
 };
 
 
+bool math_font_available(string & name)
+{
+       LyXFont f;
+       augmentFont(f, name);
+
+       // Do we have the font proper?
+       if (fontloader.available(f))
+               return true;
+
+       // can we fake it?
+       if (name == "eufrak") {
+               name = "lyxfakefrak";
+               return true;
+       }
+
+       lyxerr << "font " << name << " not available and I can't fake it\n";
+       return false;
+}
+
 
 void readSymbols(string const & filename)
 {
@@ -210,14 +186,24 @@ void readSymbols(string const & filename)
                        continue;
 
                // tmp.inset _is_ the fontname here.
-               if (math_font_available(tmp.inset)) {
+               // create fallbacks if necessary
+               if (tmp.extra == "func" || tmp.extra == "funclim" || tmp.extra=="special") {
+                       lyxerr[Debug::MATHED] << "symbol abuse for " << tmp.name << "\n";
+                       tmp.draw = tmp.name;
+               } else if (math_font_available(tmp.inset)) {
+                       lyxerr[Debug::MATHED] << "symbol available for " << tmp.name << "\n";
                        tmp.draw += char(charid);
-               } else {
+               } else if (fallbackid) {
                        if (tmp.inset == "cmex")
-                               tmp.inset  = "lyxsymb";
+                               tmp.inset  = "lyxsymbol";
                        else
-                               tmp.inset  = "lyxboldsymb";
+                               tmp.inset  = "lyxboldsymbol";
+                       lyxerr[Debug::MATHED] << "symbol fallback for " << tmp.name << "\n";
                        tmp.draw += char(fallbackid); 
+               } else {
+                       lyxerr[Debug::MATHED] << "faking " << tmp.name << "\n";
+                       tmp.draw = tmp.name;
+                       tmp.inset = "lyxredtext";
                }
 
                if (theWordList.find(tmp.name) != theWordList.end())
@@ -319,19 +305,7 @@ MathAtom createMathInset(string const & s)
        latexkeys const * l = in_word_set(s);
        if (l) {
                string const & inset = l->inset;
-               lyxerr[Debug::MATHED] << " fount inset: '" << inset << "'\n";
-               if (inset == "funclim")
-                       return MathAtom(new MathFuncLimInset(s));
-               if (inset == "special")
-                       return MathAtom(new MathSpecialCharInset(s[0]));
-               if (inset == "lyxsym" ||
-                               inset == "cmr" ||
-                               inset == "cmsy" ||
-                               inset == "cmm" ||
-                               inset == "cmex" ||
-                               inset == "msa" ||
-                               inset == "msb")
-                       return MathAtom(new MathSymbolInset(l));
+               lyxerr[Debug::MATHED] << " found inset: '" << inset << "'\n";
                if (inset == "underset")
                        return MathAtom(new MathUndersetInset);
                if (inset == "decoration")
@@ -348,10 +322,7 @@ MathAtom createMathInset(string const & s)
                        return MathAtom(new MathFontInset(l->name));
                if (inset == "oldfont")
                        return MathAtom(new MathFontInset(l->name));
-               if (inset == "func")
-                       return MathAtom(new MathUnknownInset(l->name, true, true));
-               
-               return MathAtom(new MathUnknownInset(l->name));
+               return MathAtom(new MathSymbolInset(l));
        }
 
        if (MathMacroTable::has(s))
index b1eb6ba1f7043e23cb6a64375273922c82276194..2d225665411e198a17ab7ed279a9e9361680b2e9 100644 (file)
@@ -33,25 +33,26 @@ void MathFontInset::metrics(MathMetricsInfo & mi) const
 {
        MathFontSetChanger dummy(mi.base, name_.c_str());
        xcell(0).metrics(mi);
-       width_   = xcell(0).width() + 6;
        ascent_  = xcell(0).ascent();
-       descent_ = xcell(0).descent() + 3;
+       descent_ = xcell(0).descent() + 2;
+       width_   = xcell(0).width()   + 2;
 }
 
 
 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        //lyxerr << "MathFontInset::draw\n";
-       MathNestInset::draw(pi, x, y);
+       //MathNestInset::draw(pi, x, y);
        MathFontSetChanger dummy(pi.base, name_.c_str());
-       xcell(0).draw(pi, x + 3, y);
-       int b = x + 1;
-       int t = x + width() - 1;
-       int d = y + descent();
-       pi.pain.line(b, d - 3, b, d, LColor::mathframe); 
-       pi.pain.line(t, d - 3, t, d, LColor::mathframe); 
-       pi.pain.line(b, d, b + 3, d, LColor::mathframe); 
-       pi.pain.line(t - 2, d, t, d, LColor::mathframe); 
+       xcell(0).draw(pi, x + 1, y);
+       if (editing()) {
+               int t = x + width() - 1;
+               int d = y + descent();
+               pi.pain.line(x, d - 3, x, d, LColor::mathframe); 
+               pi.pain.line(t, d - 3, t, d, LColor::mathframe); 
+               pi.pain.line(x, d, x + 3, d, LColor::mathframe); 
+               pi.pain.line(t - 2, d, t, d, LColor::mathframe); 
+       }
 }
 
 
index dbcdece874b700cef4cc3977afe384b42cb4d5d8..65b4868e87f818d3b7a3d785bf05b9924e6683e9 100644 (file)
@@ -28,6 +28,15 @@ string verboseHLine(int n)
 
 }
 
+//////////////////////////////////////////////////////////////
+
+
+MathGridInset::CellInfo::CellInfo()
+       : dummy_(false)
+{}
+
+
+
 
 //////////////////////////////////////////////////////////////
 
@@ -60,7 +69,10 @@ MathGridInset::ColInfo::ColInfo()
 
 
 MathGridInset::MathGridInset(char v, string const & h)
-       : MathNestInset(guessColumns(h)), rowinfo_(2), colinfo_(guessColumns(h) + 1)
+       : MathNestInset(guessColumns(h)),
+         rowinfo_(2),
+         colinfo_(guessColumns(h) + 1),
+         cellinfo_(1 * guessColumns(h))
 {
        setDefaults();
        valign(v);
@@ -68,15 +80,34 @@ MathGridInset::MathGridInset(char v, string const & h)
 }
 
 
+MathGridInset::MathGridInset()
+       : MathNestInset(1),
+         rowinfo_(1 + 1),
+               colinfo_(1 + 1),
+               cellinfo_(1),
+               v_align_('c')
+{
+       setDefaults();
+}
+
+
 MathGridInset::MathGridInset(col_type m, row_type n)
-       : MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_('c')
+       : MathNestInset(m * n),
+         rowinfo_(n + 1),
+               colinfo_(m + 1),
+               cellinfo_(m * n),
+               v_align_('c')
 {
        setDefaults();
 }
 
 
 MathGridInset::MathGridInset(col_type m, row_type n, char v, string const & h)
-       : MathNestInset(m * n), rowinfo_(n + 1), colinfo_(m + 1), v_align_(v)
+       : MathNestInset(m * n),
+         rowinfo_(n + 1),
+         colinfo_(m + 1),
+               cellinfo_(m * n),
+               v_align_(v)
 {
        setDefaults();
        valign(v);
@@ -355,23 +386,23 @@ void MathGridInset::metrics(MathMetricsInfo & mi) const
 }
 
 
-void MathGridInset::draw(MathPainterInfo & pain, int x, int y) const
+void MathGridInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        for (idx_type idx = 0; idx < nargs(); ++idx)
-               xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx));
+               xcell(idx).draw(pi, x + cellXOffset(idx), y + cellYOffset(idx));
 
        for (row_type row = 0; row <= nrows(); ++row)
                for (int i = 0; i < rowinfo_[row].lines_; ++i) {
                        int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
                                - i * hlinesep() - hlinesep()/2 - rowsep()/2;
-                       pain.pain.line(x + 1, yy, x + width_ - 1, yy);
+                       pi.pain.line(x + 1, yy, x + width_ - 1, yy);
                }
 
        for (col_type col = 0; col <= ncols(); ++col)
                for (int i = 0; i < colinfo_[col].lines_; ++i) {
                        int xx = x + colinfo_[col].offset_
                                - i * vlinesep() - vlinesep()/2 - colsep()/2;
-                       pain.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
+                       pi.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
                }
 }
 
@@ -507,7 +538,10 @@ string MathGridInset::eocString(col_type col) const
 void MathGridInset::addRow(row_type row)
 {
        rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
-       cells_.insert(cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
+       cells_.insert
+               (cells_.begin() + (row + 1) * ncols(), ncols(), MathXArray());
+       cellinfo_.insert
+               (cellinfo_.begin() + (row + 1) * ncols(), ncols(), CellInfo());
 }
 
 
@@ -515,8 +549,10 @@ void MathGridInset::appendRow()
 {
        rowinfo_.push_back(RowInfo());
        //cells_.insert(cells_.end(), ncols(), MathXArray());
-       for (col_type col = 0; col < ncols(); ++col)
+       for (col_type col = 0; col < ncols(); ++col) {
                cells_.push_back(cells_type::value_type());
+               cellinfo_.push_back(CellInfo());
+       }
 }
 
 
@@ -528,6 +564,9 @@ void MathGridInset::delRow(row_type row)
        cells_type::iterator it = cells_.begin() + row * ncols();
        cells_.erase(it, it + ncols());
 
+       vector<CellInfo>::iterator jt = cellinfo_.begin() + row * ncols();
+       cellinfo_.erase(jt, jt + ncols());
+
        rowinfo_.erase(rowinfo_.begin() + row);
 }
 
@@ -537,12 +576,17 @@ void MathGridInset::addCol(col_type newcol)
        const col_type nc = ncols();
        const row_type nr = nrows();
        cells_type new_cells((nc + 1) * nr);
+       vector<CellInfo> new_cellinfo((nc + 1) * nr);
 
        for (row_type row = 0; row < nr; ++row)
-               for (col_type col = 0; col < nc; ++col)
+               for (col_type col = 0; col < nc; ++col) {
                        new_cells[row * (nc + 1) + col + (col > newcol)]
                                = cells_[row * nc + col];
+                       new_cellinfo[row * (nc + 1) + col + (col > newcol)]
+                               = cellinfo_[row * nc + col];
+               }
        swap(cells_, new_cells);
+       swap(cellinfo_, new_cellinfo);
 
        ColInfo inf;
        inf.skip_  = defaultColSpace(newcol);
@@ -557,10 +601,14 @@ void MathGridInset::delCol(col_type col)
                return;
 
        cells_type tmpcells;
+       vector<CellInfo> tmpcellinfo;
        for (col_type i = 0; i < nargs(); ++i)
-               if (i % ncols() != col)
+               if (i % ncols() != col) {
                        tmpcells.push_back(cells_[i]);
+                       tmpcellinfo.push_back(cellinfo_[i]);
+               }
        swap(cells_, tmpcells);
+       swap(cellinfo_, tmpcellinfo);
 
        colinfo_.erase(colinfo_.begin() + col);
 }
@@ -813,8 +861,11 @@ void MathGridInset::write(WriteStream & os) const
                os << eolString(row);
        }
        string const s = verboseHLine(rowinfo_[nrows()].lines_);
-       if (!s.empty() && s != " ")
+       if (!s.empty() && s != " ") {
+               if (os.fragile())
+                       os << "\\protect";
                os << "\\\\" << s;
+       }
 }
 
 
@@ -846,3 +897,4 @@ int MathGridInset::border() const
 {
        return 1;
 }
+
index 45c824ec3959d85f3a2fa9d52230632ba997fd87..170748844be353cfbe9878869ade599d14488328 100644 (file)
 
 class MathGridInset : public MathNestInset {
 
+       /// additional per-cell information
+       struct CellInfo {
+               ///
+               CellInfo();
+               /// a dummy cell before a multicolumn cell
+               int dummy_;
+               /// special multi colums alignment
+               string align_;
+       };
+
        /// additional per-row information
        struct RowInfo {
                ///
@@ -61,6 +71,8 @@ class MathGridInset : public MathNestInset {
        };
 
 public:
+       /// sets nrows and ncols to 1
+       MathGridInset();
        /// constructor from columns description, creates one row
        MathGridInset(char valign, string const & halign);
        /// Note: columns first!
@@ -99,6 +111,10 @@ public:
        const RowInfo & rowinfo(row_type row) const;
        /// returns topmost row if passed (-1)
        RowInfo & rowinfo(row_type row);
+       ///
+       const CellInfo & cellinfo(idx_type idx) const { return cellinfo_[idx]; }
+       /// 
+       CellInfo & cellinfo(idx_type idx) { return cellinfo_[idx]; }
        /// identifies GridInset
        virtual MathGridInset * asGridInset() { return this; }
 
@@ -197,6 +213,8 @@ protected:
        std::vector<RowInfo> rowinfo_;
        /// column info
        std::vector<ColInfo> colinfo_;
+       /// cell info
+       std::vector<CellInfo> cellinfo_;
        ///
        char v_align_; // add approp. type
 };
index 88850070c69e52783d053fb29951fab2178691e8..ac79102345e6eac485d14d02284dc1809bd805d4 100644 (file)
@@ -125,6 +125,22 @@ MathInset * MathHullInset::clone() const
 }
 
 
+bool MathHullInset::idxFirst(idx_type & idx, pos_type & pos) const
+{
+       idx = 0;
+       pos = 0;
+       return true;
+}
+
+
+bool MathHullInset::idxLast(idx_type & idx, pos_type & pos) const
+{
+       idx = nargs() - 1;
+       pos = cell(idx).size();
+       return true;
+}
+
+
 char MathHullInset::defaultColAlign(col_type col)
 {
        switch (getType()) {
index 8202b807bc46a2b06a0be35298ba750716e83ffe..c9d90deb1cb6919d88ce39806a9fedcb372fa505 100644 (file)
@@ -75,6 +75,10 @@ public:
        int defaultColSpace(col_type col);
        ///
        char defaultColAlign(col_type col);
+       ///
+       bool idxFirst(idx_type &, pos_type &) const;
+       ///
+       bool idxLast(idx_type &, pos_type &) const;
 
        ///
        MathInsetTypes getType() const;
index 379820f7f1661b4f582780a13f892a6c2f00a777..30396bad669026250e78c76510856d7eec479675 100644 (file)
@@ -54,7 +54,6 @@ class MathBoxInset;
 class MathCharInset;
 class MathDelimInset;
 class MathFontInset;
-class MathFuncInset;
 class MathGridInset;
 class MathFracInset;
 class MathHullInset;
@@ -194,7 +193,6 @@ public:
        virtual MathDelimInset         * asDelimInset()         { return 0; }
        virtual MathDelimInset const   * asDelimInset() const   { return 0; }
        virtual MathFontInset const    * asFontInset() const    { return 0; }
-       virtual MathFuncInset          * asFuncInset()          { return 0; }
        virtual MathFracInset          * asFracInset()          { return 0; }
        virtual MathGridInset          * asGridInset()          { return 0; }
        virtual MathHullInset          * asHullInset()          { return 0; }
index 3983db44c710f11ae1cf94f0447a279cb8a7102e..b2d9655a433bf43b2c030ff03ae85b2567a1cadf 100644 (file)
@@ -145,11 +145,14 @@ void MathNestInset::dump() const
 }
 
 
-void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const
+//void MathNestInset::draw(MathPainterInfo & pi, int x, int y) const
+void MathNestInset::draw(MathPainterInfo &, int, int) const
 {
+#if 0
        if (lock_)
                pi.pain.fillRectangle(x, y - ascent(), width(), height(),
                                        LColor::mathlockbg);
+#endif
 }
 
 
@@ -209,3 +212,12 @@ bool MathNestInset::isActive() const
 {
        return nargs() > 0;
 }
+
+
+MathArray MathNestInset::glue() const
+{
+       MathArray ar;
+       for (unsigned i = 0; i < nargs(); ++i)
+               ar.push_back(cell(i));
+       return ar;
+}
index 52e2c227b36c1d4530ab7aa5f10690b5667fc59a..5d49d39d2acf9236b985b36e14ba962e35c64f03 100644 (file)
@@ -76,6 +76,8 @@ public:
        void replace(ReplaceData &);
        /// do we contain a given pattern?
        bool contains(MathArray const &);
+       /// glue everything to a single cell
+       MathArray glue() const;
 
        /// debug helper
        void dump() const;
index b341a1c6e1de21d4d74a1feaeda86e0a070e9e88..1ad2594ce7b5375609a2c55a9b68d60694a19169 100644 (file)
@@ -29,13 +29,13 @@ void MathNotInset::normalize(NormalStream & os) const
 void MathNotInset::metrics(MathMetricsInfo & mi) const
 {
        font_ = mi.base.font;
-       if (math_font_available("cmsy")) {
-               augmentFont(font_, "cmsy");
-               char_ = 54;
-       } else {
+//     if (math_font_available("cmsy")) {
+//             augmentFont(font_, "cmsy");
+//             char_ = 54;
+//     } else {
                augmentFont(font_, "mathnormal");
                char_ = '/';
-       }
+//     }
        mathed_char_dim(font_, char_, ascent_, descent_, width_);
        width_ = 0;
 }
diff --git a/src/mathed/math_numberinset.C b/src/mathed/math_numberinset.C
new file mode 100644 (file)
index 0000000..fe22f8d
--- /dev/null
@@ -0,0 +1,65 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_numberinset.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
+#include "debug.h"
+
+
+MathNumberInset::MathNumberInset(string const & s)
+       : str_(s)
+{}
+
+
+MathInset * MathNumberInset::clone() const
+{
+       return new MathNumberInset(*this);
+}
+
+
+void MathNumberInset::metrics(MathMetricsInfo & mi) const
+{
+       mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
+}
+
+
+void MathNumberInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
+       drawStr(pi, pi.base.font, x, y, str_);
+}
+
+
+void MathNumberInset::normalize(NormalStream & os) const
+{
+       os << "[number " << str_ << "]";
+}
+
+
+void MathNumberInset::maplize(MapleStream & os) const
+{
+       os << str_;
+}
+
+
+void MathNumberInset::octavize(OctaveStream & os) const
+{
+       os << str_;
+}
+
+
+void MathNumberInset::mathmlize(MathMLStream & os) const
+{
+       os << "<mi> " << str_ << " </mi>";
+}
+
+
+void MathNumberInset::write(WriteStream & os) const
+{
+       os << str_;
+}
diff --git a/src/mathed/math_numberinset.h b/src/mathed/math_numberinset.h
new file mode 100644 (file)
index 0000000..6c2a5c7
--- /dev/null
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+#ifndef MATH_NUMBERINSET_H
+#define MATH_NUMBERINSET_H
+
+#include "math_diminset.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Some inset that "is" a number
+ *  maily for math-extern
+ *  \author André Pönitz
+ */
+
+class MathNumberInset : public MathDimInset {
+public:
+       ///
+       explicit MathNumberInset(string const & s);
+       ///
+       MathInset * clone() const;
+       ///
+       void metrics(MathMetricsInfo & st) const;
+       ///
+       void draw(MathPainterInfo &, int x, int y) const;
+       ///
+       string str() const { return str_; }
+       ///
+       MathNumberInset * asNumberInset() { return this; }
+
+       ///
+       void normalize(NormalStream &) const;
+       ///
+       void octavize(OctaveStream &) const;
+       ///
+       void maplize(MapleStream &) const;
+       ///
+       void mathmlize(MathMLStream &) const;
+       ///
+       void write(WriteStream & os) const;
+
+private:
+       /// the number as string
+       string str_;
+};
+#endif
index 804263fedc88a84c13607e2c678bc44e3e3d0e27..bce39fe1e86837be3453a5a76f9787170c858128 100644 (file)
@@ -4,9 +4,9 @@
 
 /*
 
-If someone desperately needs partial "structures" (such as a few cells of
-an array inset or similar) (s)he could uses the following hack as starting
-point to write some macros:
+If someone desperately needs partial "structures" (such as a few
+cells of an array inset or similar) (s)he could uses the
+following hack as starting point to write some macros:
 
   \newif\ifcomment
   \commentfalse
@@ -43,6 +43,7 @@ point to write some macros:
 #include "math_boxinset.h"
 #include "math_charinset.h"
 #include "math_deliminset.h"
+#include "math_extern.h"
 #include "math_factory.h"
 #include "math_kerninset.h"
 #include "math_macro.h"
@@ -53,7 +54,6 @@ point to write some macros:
 #include "math_sizeinset.h"
 #include "math_sqrtinset.h"
 #include "math_scriptinset.h"
-#include "math_specialcharinset.h"
 #include "math_sqrtinset.h"
 #include "math_support.h"
 #include "math_xyarrowinset.h"
@@ -76,6 +76,7 @@ using std::fill;
 using std::vector;
 using std::atoi;
 
+
 //#define FILEDEBUG
 
 
@@ -124,18 +125,16 @@ inline CatCode catcode(unsigned char c)
 
 
 enum {
-       FLAG_BRACE_LAST = 1 << 1,  //  last closing brace ends the parsing process
+       FLAG_BRACE_LAST = 1 << 1,  //  last closing brace ends the parsing
        FLAG_RIGHT      = 1 << 2,  //  next \\right ends the parsing process
        FLAG_END        = 1 << 3,  //  next \\end ends the parsing process
-       FLAG_BRACK_END  = 1 << 4,  //  next closing bracket ends the parsing process
-       FLAG_TEXTMODE        = 1 << 5,  //  we are in a box
+       FLAG_BRACK_END  = 1 << 4,  //  next closing bracket ends the parsing
+       FLAG_TEXTMODE   = 1 << 5,  //  we are in a box
        FLAG_ITEM       = 1 << 6,  //  read a (possibly braced token)
-       FLAG_BLOCK      = 1 << 7,  //  next block ends the parsing process
-       FLAG_BLOCK2     = 1 << 8,  //  next block2 ends the parsing process
-       FLAG_LEAVE      = 1 << 9,  //  leave the loop at the end
-       FLAG_SIMPLE     = 1 << 10, //  next $ leaves the loop
-       FLAG_EQUATION   = 1 << 11, //  next \] leaves the loop
-       FLAG_SIMPLE2    = 1 << 12  //  next \) leaves the loop
+       FLAG_LEAVE      = 1 << 7,  //  leave the loop at the end
+       FLAG_SIMPLE     = 1 << 8,  //  next $ leaves the loop
+       FLAG_EQUATION   = 1 << 9,  //  next \] leaves the loop
+       FLAG_SIMPLE2    = 1 << 10  //  next \) leaves the loop
 };
 
 
@@ -719,7 +718,6 @@ void Parser::parse_into2(MathAtom & at, unsigned flags, bool numbered)
 
 void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
 {
-       bool panic  = false;
        int  limits = 0;
        MathGridInset::row_type cellrow = 0;
        MathGridInset::col_type cellcol = 0;
@@ -756,21 +754,6 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        flags |= FLAG_LEAVE;
                }
 
-               if (flags & FLAG_BLOCK) {
-                       if (t.cat() == catAlign || t.isCR() || t.cs() == "end") {
-                               putback();
-                               return;
-                       }
-               }
-
-               if (flags & FLAG_BLOCK2) {
-                       if (t.cat() == catAlign || t.isCR() || t.cs() == "end"
-                                       || t.cat() == catEnd) {
-                               putback();
-                               return;
-                       }
-               }
-
                //
                // cat codes
                //
@@ -873,8 +856,17 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        // ignore \\protect, will be re-added during output
                        ;
 
-               else if (t.cs() == "end")
-                       break;
+               else if (t.cs() == "end") {
+                       if (flags & FLAG_END) {
+                               // eat environment name
+                               //string const name =
+                               getArg('{', '}');
+                               // FIXME: check that we ended the correct environment
+                               return;
+                       }
+                       lyxerr << "found 'end' unexpectedly, cell: '" << cell << "'\n";
+                       dump();
+               }
 
                else if (t.cs() == ")")
                        break;
@@ -893,6 +885,39 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        cell = &grid.cell(grid.index(cellrow, cellcol));
                }
 
+#if 1
+               else if (t.cs() == "multicolumn") {
+                       // extract column count and insert dummy cells
+                       MathArray count;
+                       parse_into(count, FLAG_ITEM);
+                       int cols = 1;
+                       if (!extractNumber(count, cols)) {
+                               lyxerr << " can't extract number of cells from " << count << "\n";
+                       }
+                       // resize the table if necessary
+                       for (int i = 0; i < cols; ++i) {
+                               ++cellcol;
+                               if (cellcol == grid.ncols()) { 
+                                       lyxerr << "adding column " << cellcol << "\n";
+                                       grid.addCol(cellcol - 1);
+                               }
+                               cell = &grid.cell(grid.index(cellrow, cellcol));
+                               // mark this as dummy
+                               grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = true;
+                       }
+                       // the last cell is the real thng, not a dummy
+                       grid.cellinfo(grid.index(cellrow, cellcol)).dummy_ = false;
+
+                       // read special alignment
+                       MathArray align;
+                       parse_into(align, FLAG_ITEM);
+                       //grid.cellinfo(grid.index(cellrow, cellcol)).align_ = extractString(align);
+
+                       // parse the remaining contents into the "real" cell
+                       parse_into(*cell, FLAG_ITEM);
+               }
+#endif
+
                else if (t.cs() == "limits")
                        limits = 1;
 
@@ -1086,15 +1111,6 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags, bool numbered)
                        break;
                }
        }
-
-       if (panic) {
-               lyxerr << " Math Panic, expect problems!\n";
-               //   Search for the end command.
-               Token t;
-               do {
-                       t = getToken();
-               } while (good() && t.cs() != "end");
-       }
 }
 
 
index e58b4cbabcfa5bb89fc58ee1f0134f3469e3f799..47cb5deec8c082cc2354b0c1e0af0c05873b3d83 100644 (file)
@@ -185,10 +185,10 @@ void MathScriptInset::metrics(MathMetricsInfo & mi) const
 
 void MathScriptInset::metrics(MathInset const * nuc, MathMetricsInfo & mi) const
 {
-       MathScriptChanger dummy(mi.base);
-       MathNestInset::metrics(mi);
        if (nuc)
                nuc->metrics(mi);
+       MathNestInset::metrics(mi);
+       MathScriptChanger dummy(mi.base);
        ascent_  = ascent2(nuc);
        descent_ = descent2(nuc);
        width_   = width2(nuc);
@@ -198,11 +198,26 @@ void MathScriptInset::metrics(MathInset const * nuc, MathMetricsInfo & mi) const
 void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        //lyxerr << "unexpected call to MathScriptInset::draw()\n";
-       MathScriptChanger dummy(pi.base);
        draw(0, pi, x, y);
 }
 
 
+void MathScriptInset::draw(MathInset const * nuc, MathPainterInfo & pi,
+       int x, int y) const
+{
+       if (nuc)
+               nuc->draw(pi, x + dxx(nuc), y);
+       else if (editing())
+               drawStr(pi, font_, x + dxx(nuc), y, ".");
+
+       MathScriptChanger dummy(pi.base);
+       if (hasUp())
+               up().draw(pi, x + dx1(nuc), y - dy1(nuc));
+       if (hasDown())
+               down().draw(pi, x + dx0(nuc), y + dy0(nuc));
+}
+
+
 void MathScriptInset::metricsT(TextMetricsInfo const & mi) const
 {
        metricsT(0, mi);
@@ -224,22 +239,6 @@ void MathScriptInset::metricsT(MathInset const * nuc,
 }
 
 
-void MathScriptInset::draw(MathInset const * nuc, MathPainterInfo & pi,
-       int x, int y) const
-{
-       MathScriptChanger dummy(pi.base);
-       if (nuc)
-               nuc->draw(pi, x + dxx(nuc), y);
-       else if (editing())
-               drawStr(pi, font_, x + dxx(nuc), y, ".");
-
-       if (hasUp())
-               up().draw(pi, x + dx1(nuc), y - dy1(nuc));
-       if (hasDown())
-               down().draw(pi, x + dx0(nuc), y + dy0(nuc));
-}
-
-
 void MathScriptInset::drawT(TextPainter & pain, int x, int y) const
 {
        //lyxerr << "unexpected call to MathScriptInset::draw()\n";
index bb381f340c96d5d8c6379c0b3e6f0e53adb8c283..220ee4013a82e4de2b379e2383028c3e4d7dafd2 100644 (file)
 #include "debug.h"
 
 
-MathStringInset::MathStringInset()
-       : str_()
-{}
-
 MathStringInset::MathStringInset(string const & s)
        : str_(s)
 {}
index 54021486bbf3c63009ab6c9eea32e94e4d809302..e627bea1d95396a2814ec56b6a8483cb1c665db9 100644 (file)
@@ -8,14 +8,13 @@
 #pragma interface
 #endif
 
-/** Some cllection of chars with similar properties
-    \author André Pönitz
+/** Some collection of chars with similar properties
+ *  maily for math-extern
+ *  \author André Pönitz
  */
 
 class MathStringInset : public MathDimInset {
 public:
-       ///
-       MathStringInset();
        ///
        explicit MathStringInset(string const & s);
        ///
@@ -40,7 +39,7 @@ public:
        ///
        void write(WriteStream & os) const;
 
-public:
+private:
        /// the string
        string str_;
 };
index 89fd9e2913edeb4a530949167360f815e8c3981c..3cd524e0593e0100c3f702ce1cc9f8b6b60037cd 100644 (file)
@@ -4,13 +4,13 @@
 
 #include "math_support.h"
 #include "lyxfont.h"
-#include "frontends/font_loader.h"
-#include "frontends/font_metrics.h"
 #include "math_cursor.h"
 #include "math_defs.h"
 #include "math_inset.h"
 #include "math_parser.h"
 #include "frontends/Painter.h"
+#include "frontends/font_metrics.h"
+#include "frontends/font_loader.h"
 #include "debug.h"
 #include "commandtags.h"
 
@@ -57,7 +57,7 @@ namespace {
 
 /*
  * Internal struct of a drawing: code n x1 y1 ... xn yn, where code is:
- * 0 = end, 1 = line, 2 = polyline, 3 = square line, 4= square polyline
+ * 0 = end, 1 = line, 2 = polyline, 3 = square line, 4 = square polyline
  */
 
 
@@ -570,6 +570,7 @@ fontinfo fontinfos[] = {
        {"eufrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
        {"mathbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::math},
        {"mathcal",LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
+       {"mathfrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
        {"mathnormal", def_family,def_series, LyXFont::UP_SHAPE, LColor::math},
        {"mathrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::math},
        {"mathsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::math},
@@ -588,7 +589,21 @@ fontinfo fontinfos[] = {
 
        {"lyxtex", def_family, def_series, def_shape, LColor::latex},
        {"lyxsymbol", LyXFont::SYMBOL_FAMILY, def_series, def_shape, LColor::math},
-       {"lyxitsymbol", LyXFont::SYMBOL_FAMILY, def_series, LyXFont::ITALIC_SHAPE, LColor::math},
+       {"lyxboldsymbol",
+               LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES, def_shape, LColor::math},
+       {"lyxitsymbol", LyXFont::SYMBOL_FAMILY,
+               def_series, LyXFont::ITALIC_SHAPE, LColor::math},
+       {"lyxredtext", LyXFont::ROMAN_FAMILY,
+               LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::red},
+       {"lyxblacktext", LyXFont::ROMAN_FAMILY,
+               LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::black},
+
+       {"lyxfakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
+               LyXFont::UP_SHAPE, LColor::math},
+       {"lyxfakecal", LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
+               LyXFont::ITALIC_SHAPE, LColor::math},
+       {"lyxfakefrak", LyXFont::ROMAN_FAMILY, LyXFont::BOLD_SERIES,
+               LyXFont::ITALIC_SHAPE, LColor::math}
 };
 
 
@@ -605,58 +620,47 @@ fontinfo * searchFont(string const & name)
 }
 
 
+LyXFont getFont(string const & name)
+{
+       LyXFont font;
+       augmentFont(font, name);
+       return font;
+}
+
+
+void fakeFont(string const & orig, string const & fake)
+{
+       fontinfo * forig = searchFont(orig);
+       fontinfo * ffake = searchFont(fake);
+       if (forig && ffake) {
+               forig->family_ = ffake->family_;
+               forig->series_ = ffake->series_;
+               forig->shape_  = ffake->shape_;
+               forig->color_  = ffake->color_;
+       } else {
+               lyxerr << "Can't fake font '" << orig << "' with '" << fake << "'\n";
+       }
+}
+
 void augmentFont(LyXFont & font, string const & name)
 {
        static bool initialized = false;
-       
        if (!initialized) {
                initialized = true;
 
-               LyXFont f1;
-               augmentFont(f1, "msb");
-               if (!fontloader.available(f1)) {
-                       lyxerr << "faking msb\n";
-                       fontinfo * info = searchFont("msb");
-                       info->family_ = LyXFont::TYPEWRITER_FAMILY;
-                       info->series_ = LyXFont::BOLD_SERIES;
-               }
-
-               LyXFont f2;
-               augmentFont(f2, "msex");
-               if (!fontloader.available(f2)) {
-                       lyxerr << "faking msex\n";
-                       fontinfo * info = searchFont("msex");
-                       info->family_ = LyXFont::SANS_FAMILY;
-                       info->series_ = LyXFont::BOLD_SERIES;
-                       info->shape_  = LyXFont::ITALIC_SHAPE;
-               }
-
-               //{"fakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
-               //      LyXFont::UP_SHAPE, LColor::math},
-               //{"fakecal", LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
-               //      LyXFont::ITALIC_SHAPE, LColor::math},
-               //{"fakefrak", LyXFont::SANS_FAMILY, LyXFont::BOLD_SERIES,
-               //      LyXFont::ITALIC_SHAPE, LColor::math}
-
+               // fake fonts if necessary
+               if (!fontloader.available(getFont("mathfrak")))
+                       fakeFont("mathfrak", "lyxfakefrak");
+               if (!fontloader.available(getFont("mathcal")))
+                       fakeFont("mathcal", "lyxfakecal");
        }
-
-
        fontinfo * info = searchFont(name);
        if (info->family_ != def_family)
                font.setFamily(info->family_);
-
        if (info->series_ != def_series)
                font.setSeries(info->series_);
-
        if (info->shape_ != def_shape)
                font.setShape(info->shape_);
-
        if (info->color_ != LColor::none)
                font.setColor(info->color_);
 }
-
-
-bool math_font_available(string const & /*name*/)
-{
-       return true;
-}
index b2e104e730844b06948ffffb8418052a9f0435cd..0ea86a78db0b5b7b7080123457101972e4677842 100644 (file)
@@ -39,8 +39,6 @@ void drawChar(MathPainterInfo & pain,
 
 void math_font_max_dim(LyXFont const &, int & asc, int & desc);
 
-bool math_font_available(string const & name);
-
 string convertDelimToLatexName(string const & name);
 
 void augmentFont(LyXFont & f, string const & cmd);
index 7ff59dc436441fd08946c1a462e2b781a18d26dc..57d8d7b2bc86fdac93ec165251616258a7d2c2fa 100644 (file)
@@ -48,6 +48,7 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
        //      << "'\n";
        MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
        mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
+       // correct height for broken cmex font
        if (sym_->inset == "cmex") {
                h_ = 4 * descent_ / 5;
                ascent_  += h_;
@@ -55,7 +56,11 @@ void MathSymbolInset::metrics(MathMetricsInfo & mi) const
        }
        if (isRelOp())
                width_ += 6;
-       scriptable_ = (mi.base.style == LM_ST_DISPLAY && sym_->inset == "cmex");
+
+       scriptable_ = false;
+       if (mi.base.style == LM_ST_DISPLAY)
+               if (sym_->inset == "cmex" || sym_->extra == "funclim")
+                       scriptable_ = true;
 }
 
 
@@ -86,7 +91,10 @@ bool MathSymbolInset::isScriptable() const
 
 bool MathSymbolInset::takesLimits() const
 {
-       return sym_->inset == "cmex" || sym_->inset == "lyxboldsymb";
+       return
+               sym_->inset == "cmex" ||
+               sym_->inset == "lyxboldsymb" ||
+               sym_->extra == "funclim";
 }
 
 
index f8631459c2e8e841bdccb5b5c24c72fd01d4f2c1..d3653e8662f7cae1823375006742cbd95786867e 100644 (file)
@@ -2362,7 +2362,7 @@ int LyXTabular::docbookRow(Buffer const * buf, ostream & os, int row) const
                }
 
                os << ">";
-               ret += GetCellInset(cell)->docbook(buf, os);
+               ret += GetCellInset(cell)->docbook(buf, os, true);
                os << "</entry>\n";
                ++cell;
        }
@@ -2371,7 +2371,7 @@ int LyXTabular::docbookRow(Buffer const * buf, ostream & os, int row) const
 }
 
 
-int LyXTabular::docBook(Buffer const * buf, ostream & os) const
+int LyXTabular::docbook(Buffer const * buf, ostream & os, bool mixcont) const
 {
        int ret = 0;
 
index b3432cfcfeb416d14d1723bb34cebd3b72e51f6d..75f9feacf0b7c5e5d7ff00fbad5df07bd983923d 100644 (file)
@@ -297,7 +297,7 @@ public:
        ///
        int latex(Buffer const *, std::ostream &, bool, bool) const;
        ///
-       int docBook(Buffer const * buf, std::ostream & os) const;
+       int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const;
        ///
        int ascii(Buffer const *, std::ostream &, int const depth,
                  bool onlydata, unsigned char delim) const;