]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
citation patch from Angus
[lyx.git] / src / lyxfunc.C
index c359d127f85d778c13fbf293c93d8ad0251cf28d..0d9c79a790cac6bfcfaf3d0a23d836edaba50668 100644 (file)
@@ -92,6 +92,7 @@ using std::istringstream;
 #include "menus.h"
 #endif
 #include "FloatList.h"
+#include "exporter.h"
 #include "FontLoader.h"
 #include "TextCache.h"
 
@@ -112,15 +113,21 @@ extern kb_keymap * toplevel_keymap;
 
 extern bool MenuWrite(Buffer *);
 extern bool MenuWriteAs(Buffer *);
+#ifdef NEW_MENUBAR
 extern int  MenuRunLaTeX(Buffer *);
+#endif
 extern int  MenuBuildProg(Buffer *);
 extern int  MenuRunChktex(Buffer *);
+#ifndef NEW_EXPORT
 extern bool CreatePostscript(Buffer *, bool);
+#endif
 extern void MenuPrint(Buffer *);
 extern void MenuSendto();
 extern void QuitLyX();
 extern void MenuFax(Buffer *);
+#ifndef NEW_EXPORT
 extern void MenuExport(Buffer *, string const &);
+#endif
 extern void show_symbols_form(LyXFunc *);
 
 extern LyXAction lyxaction;
@@ -128,8 +135,10 @@ extern LyXAction lyxaction;
 extern tex_accent_struct get_accent(kb_action action);
 
 extern void AutoSave(BufferView *);
+#ifndef NEW_EXPORT
 extern bool PreviewDVI(Buffer *);
 extern bool PreviewPostscript(Buffer *);
+#endif
 extern void MenuInsertLabel(char const *);
 extern void MenuLayoutCharacter();
 extern void MenuLayoutParagraph();
@@ -262,10 +271,6 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                lyxerr << "Key ["
                       << action << "]["
                       << buf << "]"
-#if 0
-                      << "["
-                      << num_bytes << "]"
-#endif
                       << endl;
        }
 
@@ -301,12 +306,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                        return 0;
                }
        }
-#if 0
-       else
-               if (action == LFUN_SELFINSERT) {
-                       argument = s_r[0];
-               }
-#endif
+
         bool tmp_sc = show_sc;
        show_sc = false;
        Dispatch(action, argument.c_str());
@@ -495,6 +495,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
         static bool noLaTeX = lyxrc.latex_command == "none";
         bool disable = false;
         switch (action) {
+#ifndef NEW_EXPORT
        case LFUN_PREVIEW:
                disable = noLaTeX || lyxrc.view_dvi_command == "none";
                break;
@@ -505,6 +506,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
        case LFUN_RUNDVIPS:
                disable = noLaTeX;
                break;
+#endif
        case LFUN_MENUPRINT:
                disable = noLaTeX || lyxrc.print_command == "none";
                break;
@@ -517,6 +519,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                else if (argument == "linuxdoc")
                        disable = lyxrc.linuxdoc_to_lyx_command == "none";
                break;
+#ifndef NEW_EXPORT
        case LFUN_EXPORT:
                if (argument == "latex")
                        disable = (! buf->isLatex() && ! buf->isLiterate()) ;
@@ -536,6 +539,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                else if (argument == "custom")
                        disable = (! buf->isLatex() && ! buf->isLiterate());
                break;
+#endif
        case LFUN_UNDO:
                disable = buf->undostack.empty();
                break;
@@ -569,7 +573,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
        case LFUN_TABULAR_FEATURE:
                disable = true;
                if (owner->view()->the_locking_inset) {
-                       int ret = 0;
+                       func_status ret = LyXFunc::Disabled;
                        if (owner->view()->the_locking_inset->LyxCode() == Inset::TABULAR_CODE) {
                                ret = static_cast<InsetTabular *>
                                        (owner->view()->the_locking_inset)->
@@ -580,21 +584,17 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
                                        GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
                                        getStatus(argument);
                        }
-                       switch(ret) {
-                       case 0:
-                               break;
-                       case 1:
-                               disable = false;
-                               break;
-                       case 2:
-                               disable = false;
-                               flag |= LyXFunc::ToggleOn;
-                               break;
-                       case 3:
-                               disable = false;
-                               flag |= LyXFunc::ToggleOff;
-                               break;
-                       }
+                       flag |= ret;
+                       disable = false;
+               } else {
+                   static InsetTabular inset(owner->buffer(), 1, 1);
+                   func_status ret;
+
+                   disable = true;
+                   ret = inset.getStatus(argument);
+                   if ((ret & LyXFunc::ToggleOn) ||
+                       (ret & LyXFunc::ToggleOff))
+                       flag |= LyXFunc::ToggleOff;
                }
                break;
 
@@ -612,6 +612,9 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const
        case LFUN_VC_HISTORY:
                disable = !buf->lyxvc.inUse();
                break;
+       case LFUN_REF_BACK:
+               disable = owner->view()->NoSavedPositions();
+               break;
        default:
                break;
         }
@@ -976,6 +979,15 @@ string LyXFunc::Dispatch(int ac,
                reloadBuffer();
                break;
                
+#ifdef NEW_EXPORT
+       case LFUN_UPDATE:
+               Exporter::Export(owner->buffer(), argument, true);
+               break;
+
+       case LFUN_PREVIEW:
+               Exporter::Preview(owner->buffer(), argument);
+               break;
+#else
        case LFUN_PREVIEW:
                PreviewDVI(owner->buffer());
                break;
@@ -987,6 +999,11 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_RUNLATEX:
                MenuRunLaTeX(owner->buffer());
                break;
+
+       case LFUN_RUNDVIPS:
+               CreatePostscript(owner->buffer(), false);
+               break;
+#endif
                
         case LFUN_BUILDPROG:
                 MenuBuildProg(owner->buffer());
@@ -995,11 +1012,7 @@ string LyXFunc::Dispatch(int ac,
        case LFUN_RUNCHKTEX:
                MenuRunChktex(owner->buffer());
                break;
-               
-       case LFUN_RUNDVIPS:
-               CreatePostscript(owner->buffer(), false);
-               break;
-               
+                               
        case LFUN_MENUPRINT:
                owner->getDialogs()->showPrint();
                break;
@@ -1009,7 +1022,11 @@ string LyXFunc::Dispatch(int ac,
                break;
                        
        case LFUN_EXPORT:
+#ifdef NEW_EXPORT
+               Exporter::Export(owner->buffer(), argument, false);
+#else
                MenuExport(owner->buffer(), argument);
+#endif
                break;
 
        case LFUN_IMPORT:
@@ -1062,7 +1079,7 @@ string LyXFunc::Dispatch(int ac,
                break;
        }
                
-       case LFUN_TABLE:
+       case LFUN_DIALOG_TABULAR_INSERT:
 #ifndef NEW_TABULAR
                Table();
 #else
@@ -1428,7 +1445,7 @@ string LyXFunc::Dispatch(int ac,
        break;
 
        case LFUN_LAYOUT_DOCUMENT:
-#ifdef USE_OLD_LAYOUT
+#ifdef USE_OLD_DOCUMENT_LAYOUT
                MenuLayoutDocument();
 #else
                owner->getDialogs()->showLayoutDocument();
@@ -1467,11 +1484,15 @@ string LyXFunc::Dispatch(int ac,
            break;
 
        case LFUN_LAYOUT_PAPER:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
                MenuLayoutPaper();
+#endif
                break;
                
        case LFUN_LAYOUT_QUOTES:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
                MenuLayoutQuotes();
+#endif
                break;
                
        case LFUN_LAYOUT_PREAMBLE:
@@ -1566,26 +1587,22 @@ string LyXFunc::Dispatch(int ac,
                MenuInsertLabel(argument.c_str());
                break;
                
-       case LFUN_REF_CREATE:
-       {
-               InsetCommandParams p( "ref" );
-               owner->getDialogs()->createRef( p.getAsString() );
-       }
-       break;
-               
        case LFUN_REF_INSERT:
-       {
-               InsetCommandParams p;
-               p.setFromString( argument );
+               if (argument.empty()) {
+                       InsetCommandParams p("ref");
+               owner->getDialogs()->createRef(p.getAsString());
+               } else {
+                       InsetCommandParams p;
+                       p.setFromString(argument);
+
+                       InsetRef * inset = new InsetRef(p);
+                       if (!owner->view()->insertInset(inset))
+                               delete inset;
+                       else
+                               owner->view()->updateInset(inset, true);
+               }
+               break;
 
-               InsetRef * inset = new InsetRef( p );
-               if (!owner->view()->insertInset(inset))
-                       delete inset;
-               else
-                       owner->view()->updateInset( inset, true );
-       }
-       break;
-                   
        case LFUN_REF_BACK:
        {
                owner->view()->restorePosition();
@@ -2515,6 +2532,28 @@ string LyXFunc::Dispatch(int ac,
        }
        break;
 
+       case LFUN_GOTO_PARAGRAPH:
+       {
+#ifdef HAVE_SSTREAM
+                istringstream istr(argument);
+#else
+                istrstream istr(argument.c_str());
+#endif
+
+               int id;
+               istr >> id;
+               LyXParagraph * par = owner->view()->text->GetParFromID(id);
+
+               // Set the cursor
+               owner->view()->text->SetCursor(owner->view(), par, 0);
+               owner->view()->setState();
+               owner->showState();
+
+               // Recenter screen
+               owner->view()->center();
+       }
+       break;
+
        case LFUN_APROPOS:
        case LFUN_GETTIP:
        {