]> git.lyx.org Git - lyx.git/blobdiff - src/bufferview_funcs.C
Various fixes to Tabular, InsetTabular and InsetText. Fixed left border for
[lyx.git] / src / bufferview_funcs.C
index a68acf56c069943f5c72bf1d9266e7d32e3f7689..c028e0af285244ff86c873cbcbb9cb5696930ec0 100644 (file)
 #include "lyxfont.h"
 #include "lyx_gui_misc.h"
 #include "lyxtext.h"
-#include "minibuffer.h"
 #include "buffer.h"
 #include "support/lstrings.h"
 #include "lyx_cb.h"
-#include "layout_forms.h"
-
-extern FD_form_character * fd_form_character;
-
-#ifndef NEW_INSETS
-void Foot(BufferView * bv)
-{
-       if (!bv->available()) 
-               return;
-       
-       bv->owner()->getMiniBuffer()
-               ->Set(_("Inserting Footnote..."));
-       bv->hideCursor();
-       bv->update(BufferView::SELECT|BufferView::FITCUR);
-       bv->text->InsertFootnoteEnvironment(bv, LyXParagraph::FOOTNOTE);
-       bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-}
-#endif
+#include "language.h"
+#include "gettext.h"
 
 
 void Emph(BufferView * bv)
@@ -69,19 +52,6 @@ void Noun(BufferView * bv)
 }
 
 
-#ifndef NEW_INSETS
-void Margin(BufferView * bv)
-{
-       if (bv->available()) {
-               bv->owner()->getMiniBuffer()->Set(_("Inserting margin note..."));
-               bv->hideCursor();
-               bv->update(BufferView::SELECT|BufferView::FITCUR);
-               bv->text->InsertFootnoteEnvironment(bv, LyXParagraph::MARGIN);
-               bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-       }
-}
-#endif
-
 void Number(BufferView * bv)
 {
        LyXFont font(LyXFont::ALL_IGNORE);
@@ -101,21 +71,6 @@ void Lang(BufferView * bv, string const & l)
 }
 
 
-#ifndef NEW_INSETS
-void Melt(BufferView * bv)
-{
-       if (!bv->available()) return;
-       
-       bv->owner()->getMiniBuffer()->Set(_("Melt"));
-       bv->hideCursor();
-       bv->beforeChange();
-       bv->update(BufferView::SELECT|BufferView::FITCUR);
-       bv->text->MeltFootnoteEnvironment(bv);
-       bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-}
-#endif
-
-
 void Tex(BufferView * bv)
 {
        LyXFont font(LyXFont::ALL_IGNORE);
@@ -127,26 +82,22 @@ void Tex(BufferView * bv)
 // Change environment depth.
 // if decInc >= 0, increment depth
 // if decInc <  0, decrement depth
-void changeDepth(BufferView * bv, int decInc)
+void changeDepth(BufferView * bv, LyXText * text, int decInc)
 {
-       if (!bv->available()) return;
+       if (!bv->available() || !text)
+           return;
        
        bv->hideCursor();
-       bv->update(BufferView::SELECT|BufferView::FITCUR);
+       bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
        if (decInc >= 0)
-               bv->text->IncDepth(bv);
+               text->IncDepth(bv);
        else
-               bv->text->DecDepth(bv);
-       bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-       bv->owner()->getMiniBuffer()
-               ->Set(_("Changed environment depth"
-                       " (in possible range, maybe not)"));
-}
-
-
-void Free(BufferView * bv)
-{
-       ToggleAndShow(bv, UserFreeFont(bv->buffer()->params));
+               text->DecDepth(bv);
+       if (text->inset_owner)
+           bv->updateInset((Inset *)text->inset_owner, true);
+       bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+       bv->owner()->message(_("Changed environment depth "
+                              "(in possible range, maybe not)"));
 }
 
 
@@ -174,11 +125,6 @@ void ProhibitInput(BufferView * bv)
        XDefineCursor(fl_get_display(), bv->owner()->getForm()->window, 
                      cursor);
 
-       if (fd_form_character->form_character->visible)
-               XDefineCursor(fl_get_display(),
-                             fd_form_character->form_character->window,
-                             cursor);
-
        XFlush(fl_get_display());
        fl_deactivate_all_forms();
 }
@@ -190,10 +136,6 @@ void AllowInput(BufferView * bv)
    
        XUndefineCursor(fl_get_display(), bv->owner()->getForm()->window);
 
-       if (fd_form_character->form_character->visible)
-               XUndefineCursor(fl_get_display(),
-                               fd_form_character->form_character->window);
-
        XFlush(fl_get_display());
        fl_activate_all_forms();
 }
@@ -268,9 +210,9 @@ string const CurrentState(BufferView * bv)
                        state += string(_(", Depth: ")) + tostr(depth);
                // The paragraph spacing, but only if different from
                // buffer spacing.
-               if (!text->cursor.par()->spacing.isDefault()) {
+               if (!text->cursor.par()->params.spacing().isDefault()) {
                        Spacing::Space cur_space =
-                               text->cursor.par()->spacing.getSpace();
+                               text->cursor.par()->params.spacing().getSpace();
                        state += _(", Spacing: ");
                        switch (cur_space) {
                        case Spacing::Single:
@@ -284,7 +226,7 @@ string const CurrentState(BufferView * bv)
                                break;
                        case Spacing::Other:
                                state += _("Other (");
-                               state += tostr(text->cursor.par()->spacing.getValue());
+                               state += tostr(text->cursor.par()->params.spacing().getValue());
                                state += ")";
                                break;
                        case Spacing::Default:
@@ -300,21 +242,24 @@ string const CurrentState(BufferView * bv)
 /* -------> Does the actual toggle job of the XxxCB() calls above.
  * Also shows the current font state.
  */
-void ToggleAndShow(BufferView * bv, LyXFont const & font)
+void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
 {
        if (bv->available()) { 
-               bv->hideCursor();
-               bv->update(BufferView::SELECT|BufferView::FITCUR);
-               if (bv->theLockingInset())
+               if (bv->theLockingInset()) {
                        bv->theLockingInset()->SetFont(bv, font, toggleall);
-               else
-                       bv->text->ToggleFree(bv, font, toggleall);
-               bv->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+                       return;
+               }
+               LyXText * text = bv->getLyXText();
+
+               bv->hideCursor();
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+               text->ToggleFree(bv, font, toggleall);
+               bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
 
                if (font.language() != ignore_language ||
                    font.latex() != LyXFont::IGNORE ||
-                   font.number() != LyXFont::IGNORE) {
-                       LyXText * text = bv->getLyXText();
+                   font.number() != LyXFont::IGNORE)
+               {
                        LyXCursor & cursor = text->cursor;
                        text->ComputeBidiTables(bv->buffer(), cursor.row());
                        if (cursor.boundary() !=