]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
fix "make dist" target
[lyx.git] / src / lyxfunc.C
index 285af55c54a751c5827fc87908c82da052804612..d40c5a4a2272963d419d1df6e8f47d84152b48c7 100644 (file)
@@ -25,6 +25,7 @@
 #pragma implementation
 #endif
 
+#include "support/lyxalgo.h"
 #include "version.h"
 #include "kbmap.h"
 #include "lyxfunc.h"
@@ -112,10 +113,46 @@ extern LyXTextClass::size_type current_layout;
 
 extern void ShowLatexLog();
 
+
+#if 0
+
+///
+class MiniBufferController : public SigC::Object {
+public:
+       ///
+       MiniBufferController() {
+               minibuffer
+                       .cmdReady
+                       .connect(slot(this,
+                                     &MiniBufferController::receiveCommand));
+               minibuffer
+                       .argReady
+                       .connect(slot(this,
+                                     &MiniBufferController::receiveArg));
+       }
+       ///
+       void receiveCmd(string const & cmd) {}
+       ///
+       void receiveArg(string const & arg) {}
+       
+       
+private:
+};
+
+namespace {
+
+MiniBufferController mb_ctrl;
+
+}
+#endif
+
+
 /* === globals =========================================================== */
 
+// Initialization of static member var
 bool LyXFunc::show_sc = true;
 
+
 LyXFunc::LyXFunc(LyXView * o)
        : owner(o)
 {
@@ -125,14 +162,16 @@ LyXFunc::LyXFunc(LyXView * o)
        setupLocalKeymap();
 }
 
+
 inline
-LyXText * LyXFunc::TEXT(bool flag=true) const
+LyXText * LyXFunc::TEXT(bool flag = true) const
 {
        if (flag)
                return owner->view()->text;
        return owner->view()->getLyXText();
 }
 
+
 // I changed this func slightly. I commented out the ...FinishUndo(),
 // this means that all places that used to have a moveCursorUpdate, now
 // have a ...FinishUndo() as the preceeding statement. I have also added
@@ -158,10 +197,10 @@ void LyXFunc::moveCursorUpdate(bool flag, bool selecting)
 
 void LyXFunc::handleKeyFunc(kb_action action)
 {
-       char c = 0;
+       char c = keyseq.getiso();
 
-       if (keyseq.length == -1 && keyseq.getiso() != 0) 
-               c = keyseq.getiso();
+       if (keyseq.length != -1) c = 0;
+       
        owner->getIntl()->getTrans()
                .deadkey(c, get_accent(action).accent, TEXT(false));
        // Need to reset, in case the minibuffer calls these
@@ -175,12 +214,12 @@ void LyXFunc::handleKeyFunc(kb_action action)
 }
 
 
-int LyXFunc::processKeySym(KeySym keysym, unsigned int state) 
+void LyXFunc::processKeySym(KeySym keysym, unsigned int state) 
 {
        string argument;
        
        if (lyxerr.debugging(Debug::KEY)) {
-               char * tmp = XKeysymToString(keysym);
+               char const * tmp = XKeysymToString(keysym);
                string const stm = (tmp ? tmp : "");
                lyxerr << "KeySym is "
                       << stm
@@ -194,9 +233,14 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                lyxerr[Debug::KEY] << "Empty kbd action (probably composing)"
                                   << endl;
                //return 0;
-               return FL_PREEMPT;
+               //return FL_PREEMPT;
+               return;
        }
 
+#if 0
+       // This if clause should not be here, but should rather be changed
+       // to a lyxfunc and get XK_Escape bound to it (Lgb)
+#warning Fix this please. (Lgb)
        if (owner->view()->available()) {
                // this function should be used always [asierra060396]
                UpdatableInset * tli = owner->view()->theLockingInset();
@@ -208,21 +252,26 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                                owner->showState();
                        } else {
                                tli->UnlockInsetInInset(owner->view(),
-                                                       tli->GetLockingInset(),true);
+                                                       tli->GetLockingInset(),
+                                                       true);
                        }
                        //return 0;
-                       return FL_PREEMPT;
+                       //return FL_PREEMPT;
+                       return;
                }
        }
+#endif
        
        // Can we be sure that this will work for all X-Windows
        // 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)
-               return 0;
-
+           || keysym == XK_Mode_switch || keysym == 0x0) {
+               //return 0;
+               return;
+       }
+       
        // Do a one-deep top-level lookup for
        // cancel and meta-fake keys. RVDK_PATCH_5
        cancel_meta_seq.reset();
@@ -239,7 +288,8 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        // Mostly, meta_fake_bit = 0. RVDK_PATCH_5.
        if ((action != LFUN_CANCEL) && (action != LFUN_META_FAKE)) {
                if (lyxerr.debugging(Debug::KEY)) {
-                       lyxerr << "meta_fake_bit is [" << meta_fake_bit << "]" << endl;
+                       lyxerr << "meta_fake_bit is ["
+                              << meta_fake_bit << "]" << endl;
                }
                // remove Caps Lock and Mod2 as a modifiers
                action = keyseq.addkey(keysym,
@@ -247,7 +297,8 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                                       &(ShiftMask|ControlMask
                                         |Mod1Mask));
                if (lyxerr.debugging(Debug::KEY)) {
-                       lyxerr << "action now set to [" << action << "]" << endl;
+                       lyxerr << "action now set to ["
+                              << action << "]" << endl;
                }
        }
        // Dont remove this unless you know what you are doing.
@@ -271,30 +322,31 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        if (keyseq.length > 1 || keyseq.length < -1) {
                string buf;
                keyseq.print(buf);
-               owner->getMiniBuffer()->Set(buf);
+               owner->message(buf);
        }
 
        if (action == -1) {
-               if (keyseq.length < -1) { // unknown key sequence...
-                       string buf;
-                       keyseq.print(buf);
-                       owner->getMiniBuffer()->Set(_("Unknown sequence:"), buf);
-                       return 0;
-               }
-       
-               char const isochar = keyseq.getiso();
-               if (!(state & ControlMask) &&
-                   !(state & Mod1Mask) &&
-                   (isochar && keysym < 0xF000)) {
-                       argument += isochar;
+               // It is unknown, but what if we remove all
+               // the modifiers? (Lgb)
+               action = keyseq.addkey(keysym, 0);
+
+               // We keep the shift state, but remove the others.
+               // This is for the sake of the LFUN_SELFINSERT below.
+               state &= ShiftMask;
+               
+               if (lyxerr.debugging(Debug::KEY)) {
+                       lyxerr << "Removing modifiers...\n"
+                              << "Action now set to ["
+                              << action << "]" << endl;
                }
-               if (argument.empty()) {
-                       lyxerr.debug() << "Empty argument!" << endl;
-                       // This can`t possibly be of any use
-                       // so we`ll skip the dispatch.
-                       return 0;
+               if (action == -1) {
+                       owner->message(_("Unknown function."));
+                       //return 0;
+                       return;
                }
-       } else if (action == LFUN_SELFINSERT) {
+       }
+
+       if (action == LFUN_SELFINSERT) {
                // We must set the argument to the char looked up by
                // XKeysymToString
                XKeyEvent xke;
@@ -315,13 +367,14 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
                xke.same_screen = True;
                char ret[10];
                KeySym tmpkeysym;
-               int res = XLookupString(&xke, ret, 10, &tmpkeysym, 0);
+               int const res = XLookupString(&xke, ret, 10, &tmpkeysym, 0);
                //Assert(keysym == tmpkeysym);
                lyxerr[Debug::KEY] << "TmpKeysym ["
                                   << tmpkeysym << "]" << endl;
                
                if (res > 0)
                        argument = string(ret, res);
+
                lyxerr[Debug::KEY] << "SelfInsert arg["
                                   << argument << "]" << endl;
        }
@@ -332,15 +385,18 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state)
        Dispatch(action, argument);
        show_sc = tmp_sc;
        
-       return 0;
+       //return 0;
 } 
 
+
 LyXFunc::func_status LyXFunc::getStatus(int ac) const
 {
        return getStatus(ac, string());
 }
 
-LyXFunc::func_status LyXFunc::getStatus(int ac, string const & not_to_use_arg) const
+
+LyXFunc::func_status LyXFunc::getStatus(int ac,
+                                       string const & not_to_use_arg) const
 {
         kb_action action;
         func_status flag = LyXFunc::OK;
@@ -411,8 +467,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, string const & not_to_use_arg) c
                break;
 
        case LFUN_INSERTFOOTNOTE:
-       case LFUN_FOOTMELT:
-       case LFUN_MARGINMELT:
                // Disable insertion of floats in a tabular.
                disable = false;
                if (owner->view()->theLockingInset()) {
@@ -512,6 +566,13 @@ LyXFunc::func_status LyXFunc::getStatus(int ac, string const & not_to_use_arg) c
 }
 
 
+// temporary dispatch method
+void LyXFunc::miniDispatch(string const & s) 
+{
+       Dispatch(s);
+}
+
+
 string const LyXFunc::Dispatch(string const & s) 
 {
        // Split command string into command and argument
@@ -524,7 +585,7 @@ string const LyXFunc::Dispatch(string const & s)
 
 
 string const LyXFunc::Dispatch(int ac,
-                        string const & do_not_use_this_arg)
+                              string const & do_not_use_this_arg)
 {
        lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
                              <<"] arg[" << do_not_use_this_arg << "]" << endl;
@@ -550,7 +611,7 @@ string const LyXFunc::Dispatch(int ac,
        }
     
        selection_possible = false;
-
+       
        if (owner->view()->available())
                owner->view()->hideCursor();
 
@@ -596,7 +657,8 @@ string const LyXFunc::Dispatch(int ac,
                        if (!comname.empty()) {
                                comname = strip(comname);
                                commandshortcut = "(" + comname + ')';
-                               owner->getMiniBuffer()->Set(commandshortcut);
+                               owner->message(commandshortcut);
+
                                // Here we could even add a small pause,
                                // to annoy the user and make him learn
                                // the shortcuts.
@@ -693,9 +755,34 @@ string const LyXFunc::Dispatch(int ac,
                }
        }
 
-       Assert(action != LFUN_SELECT_FILE_SYNC);
+       lyx::Assert(action != LFUN_SELECT_FILE_SYNC);
 
        switch (action) {
+               
+       case LFUN_ESCAPE:
+       {
+               if (!owner->view()->available()) break;
+               
+               // this function should be used always [asierra060396]
+               UpdatableInset * tli =
+                       owner->view()->theLockingInset();
+               if (tli) {
+                       UpdatableInset * lock = tli->GetLockingInset();
+                       
+                       if (tli == lock) {
+                               owner->view()->unlockInset(tli);
+                               TEXT()->CursorRight(owner->view());
+                               moveCursorUpdate(true, false);
+                               owner->showState();
+                       } else {
+                               tli->UnlockInsetInInset(owner->view(),
+                                                       lock,
+                                                       true);
+                       }
+               }
+       }
+       break;
+                       
                // --- Misc -------------------------------------------
        case LFUN_WORDFINDFORWARD  : 
        case LFUN_WORDFINDBACKWARD : {
@@ -747,14 +834,21 @@ string const LyXFunc::Dispatch(int ac,
                }
                string buf;
                keyseq.print(buf, true);
-               owner->getMiniBuffer()->Set(buf, string(), string(), 1);
+               owner->message(buf);
        }
        break;
 
        // --- Misc -------------------------------------------
        case LFUN_EXEC_COMMAND:
-               owner->getMiniBuffer()->PrepareForCommand(); 
-               break;
+       {
+               std::vector<string> allCmds;
+               std::transform(lyxaction.func_begin(), lyxaction.func_end(),
+                              std::back_inserter(allCmds), lyx::firster());
+               static std::vector<string> hist;
+               owner->getMiniBuffer()->getString(MiniBuffer::spaces,
+                                                 allCmds, hist);
+       }
+       break;
                
        case LFUN_CANCEL:                   // RVDK_PATCH_5
                keyseq.reset();
@@ -802,9 +896,11 @@ string const LyXFunc::Dispatch(int ac,
                
        case LFUN_MENUWRITE:
                if (!owner->buffer()->isUnnamed()) {
-                       owner->getMiniBuffer()->Set(_("Saving document"),
-                                                   MakeDisplayPath(owner->buffer()->fileName()),
-                                                   "...");
+                       string const s1 = _("Saving document") + ' '
+                               + MakeDisplayPath(owner->buffer()->fileName()
+                                                 + "...");
+                       
+                       owner->message(s1);
                        MenuWrite(owner->view(), owner->buffer());
                } else
                        WriteAs(owner->view(), owner->buffer());
@@ -854,22 +950,27 @@ string const LyXFunc::Dispatch(int ac,
                break;
                
        case LFUN_TOCVIEW:
+#if 0
        case LFUN_LOFVIEW:
        case LFUN_LOTVIEW:
        case LFUN_LOAVIEW:
+#endif
        {
                InsetCommandParams p;
-               
-               if (action == LFUN_TOCVIEW )
-                       p.setCmdName( "tableofcontents" );
+
+#if 0
+               if (action == LFUN_TOCVIEW)
+#endif
+                       p.setCmdName("tableofcontents");
+#if 0
                else if (action == LFUN_LOAVIEW )
-                       p.setCmdName( "listofalgorithms" );
-               else if (action == LFUN_LOFVIEW )
-                       p.setCmdName( "listoffigures" );
+                       p.setCmdName("listof{algorithm}{List of Algorithms}");
+               else if (action == LFUN_LOFVIEW)
+                       p.setCmdName("listoffigures");
                else
-                       p.setCmdName( "listoftables" );
-
-               owner->getDialogs()->createTOC( p.getAsString() );
+                       p.setCmdName("listoftables");
+#endif
+               owner->getDialogs()->createTOC(p.getAsString());
                break;
        }       
 
@@ -904,12 +1005,6 @@ string const LyXFunc::Dispatch(int ac,
                }
                break;
                
-#ifndef NEW_INSETS
-       case LFUN_OPENSTUFF:
-               owner->view()->openStuff();
-               break;
-#endif
-               
        case LFUN_HYPHENATION:
                owner->view()->hyphenationPoint();
                break;
@@ -951,43 +1046,12 @@ string const LyXFunc::Dispatch(int ac,
                owner->view()->setState();
                owner->showState();
                break;
-#ifndef NEW_INSETS             
-       case LFUN_MELT:
-               Melt(owner->view());
-               break;
-#endif
+
        case LFUN_RECONFIGURE:
                Reconfigure(owner->view());
                break;
-#ifndef NEW_INSETS
-       case LFUN_FOOTMELT:
-               if (owner->view()->available()
-                   && !TEXT()->selection
-                   && TEXT()->cursor.par()->footnoteflag
-                   != LyXParagraph::NO_FOOTNOTE)
-                       { // only melt footnotes with FOOTMELT, not margins etc
-                               if (TEXT()->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE)
-                                       Melt(owner->view());
-                       }
-               else
-                       Foot(owner->view()); 
-               owner->view()->setState();
-               break;
 
-       case LFUN_MARGINMELT:
-               if (owner->view()->available()
-                   && !TEXT()->selection
-                   && TEXT()->cursor.par()->footnoteflag
-                   != LyXParagraph::NO_FOOTNOTE) {
-                       // only melt margins
-                       if (TEXT()->cursor.par()->footnotekind == LyXParagraph::MARGIN)
-                               Melt(owner->view());
-               } else
-                       Margin(owner->view()); 
-               owner->view()->setState();
-               break;
-#endif
-#ifndef NEW_INSETS
+#if 0
        case LFUN_FLOATSOPERATE:
                if (argument == "openfoot")
                        owner->view()->allFloats(1,0);
@@ -1011,22 +1075,25 @@ string const LyXFunc::Dispatch(int ac,
                owner->getDialogs()->showCredits();
                break;
 
-        case LFUN_HELP_OPEN: {
-               string arg = argument;
+        case LFUN_HELP_OPEN:
+       {
+               string const arg = argument;
                if (arg.empty()) {
                        setErrorMessage(N_("Missing argument"));
                        break;
                }
                ProhibitInput(owner->view());
-               string fname = i18nLibFileSearch("doc", arg, "lyx");
+               string const fname = i18nLibFileSearch("doc", arg, "lyx");
                if (fname.empty()) {
                        lyxerr << "LyX: unable to find documentation file `"
                               << arg << "'. Bad installation?" << endl;
                        AllowInput(owner->view());
                        break;
                }
-               owner->getMiniBuffer()->Set(_("Opening help file"),
-                                           MakeDisplayPath(fname),"...");
+               string const str = _("Opening help file") + ' '
+                       + MakeDisplayPath(fname) + "...";
+               
+               owner->message(str);
                owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
                AllowInput(owner->view());
                break;
@@ -1307,11 +1374,11 @@ string const LyXFunc::Dispatch(int ac,
        }
        break;
        
+       case LFUN_MATH_EXTERN:
        case LFUN_MATH_NUMBER:
        case LFUN_MATH_LIMITS:
        {
                setErrorMessage(N_("This is only allowed in math mode!"));
-       
        }
        break;
 
@@ -1355,35 +1422,6 @@ string const LyXFunc::Dispatch(int ac,
        }
        break;
 
-#ifndef NEW_INSETS
-       case LFUN_INSERTFOOTNOTE: 
-       {
-               LyXParagraph::footnote_kind kind;
-               if (argument == "footnote") {
-                       kind = LyXParagraph::FOOTNOTE;
-               } else if (argument == "margin") {
-                       kind = LyXParagraph::MARGIN;
-               } else if (argument == "figure") {
-                       kind = LyXParagraph::FIG;
-               } else if (argument == "table") {
-                       kind = LyXParagraph::TAB;
-               } else if (argument == "wide-fig") {
-                       kind = LyXParagraph::WIDE_FIG;
-               } else if (argument == "wide-tab") {
-                       kind = LyXParagraph::WIDE_TAB;
-               } else if (argument == "algorithm") {
-                       kind = LyXParagraph::ALGORITHM;
-               } else {
-                       setErrorMessage(N_("Unknown kind of footnote"));
-                       break;
-               }
-               TEXT()->InsertFootnoteEnvironment(owner->view(), kind);
-               owner->view()->update(TEXT(),
-                                     BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
-               owner->view()->setState();
-       }
-       break;
-#endif
        case LFUN_TOGGLECURSORFOLLOW:
                lyxrc.cursor_follows_scrollbar = !lyxrc.cursor_follows_scrollbar;
                break;
@@ -1466,10 +1504,23 @@ string const LyXFunc::Dispatch(int ac,
                break;
        }
 
+       case LFUN_MESSAGE:
+               owner->message(argument);
+               break;
+
+       case LFUN_MESSAGE_PUSH:
+               owner->messagePush(argument);
+               break;
+
+       case LFUN_MESSAGE_POP:
+               owner->messagePop();
+               break;
+
        default:
                // Then if it was none of the above
                if (!owner->view()->Dispatch(action, argument))
-                       lyxerr << "A truly unknown func!" << endl;
+                       lyxerr << "A truly unknown func ["
+                              << action << "]!" << endl;
                break;
        } // end of switch
 
@@ -1479,19 +1530,11 @@ exit_with_message:
 
        if (res.empty()) {
                if (!commandshortcut.empty()) {
-                       string const newbuf =
-                               owner->getMiniBuffer()->GetText();
-                       if (newbuf != commandshortcut) {
-                               owner->getMiniBuffer()->Set(newbuf
-                                                           + " " +
-                                                           commandshortcut);
-                       }
+                       owner->getMiniBuffer()->addSet(commandshortcut);
                }
        } else {
-               string msg(_(res));
-               msg += " ";
-               msg += commandshortcut;
-               owner->getMiniBuffer()->Set(msg);
+               string const msg(_(res) + ' ' + commandshortcut);
+               owner->message(msg);
        }
 
        return res;
@@ -1521,14 +1564,19 @@ void LyXFunc::MenuNew(bool fromTemplate)
        
        if (lyxrc.new_ask_filename) {
                FileDialog fileDlg(owner, _("Enter filename for new document"),
-                       LFUN_SELECT_FILE_SYNC,
-                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
-                       make_pair(string(_("Templates")), string(lyxrc.template_path)));
-
-               FileDialog::Result result = fileDlg.Select(initpath, _("*.lyx|LyX Documents (*.lyx)"), _("newfile"));
+                                  LFUN_SELECT_FILE_SYNC,
+                       make_pair(string(_("Documents")),
+                                 string(lyxrc.document_path)),
+                       make_pair(string(_("Templates")),
+                                 string(lyxrc.template_path)));
+
+               FileDialog::Result result =
+                       fileDlg.Select(initpath,
+                                      _("*.lyx|LyX Documents (*.lyx)"),
+                                      _("newfile"));
        
                if (result.second.empty()) {
-                       owner->getMiniBuffer()->Set(_("Canceled."));
+                       owner->message(_("Canceled."));
                        lyxerr.debug() << "New Document Cancelled." << endl;
                        return;
                }
@@ -1541,10 +1589,10 @@ void LyXFunc::MenuNew(bool fromTemplate)
 
                // Check if the document already is open
                if (bufferlist.exists(s)) {
-                       switch (AskConfirmation(_("Document is already open:"), 
-                                              MakeDisplayPath(s, 50),
-                                              _("Do you want to close that document now?\n"
-                                                "('No' will just switch to the open version)")))
+                       switch (AskConfirmation(_("Document is already open:"),
+                                               MakeDisplayPath(s, 50),
+                                               _("Do you want to close that document now?\n"
+                                                 "('No' will just switch to the open version)")))
                        {
                        case 1: // Yes: close the document
                                if (!bufferlist.close(bufferlist.getBuffer(s)))
@@ -1555,7 +1603,7 @@ void LyXFunc::MenuNew(bool fromTemplate)
                                owner->view()->buffer(bufferlist.getBuffer(s));
                                return;
                        case 3: // Cancel: Do nothing
-                               owner->getMiniBuffer()->Set(_("Canceled."));
+                               owner->message(_("Canceled."));
                                return;
                        }
                }
@@ -1567,14 +1615,14 @@ void LyXFunc::MenuNew(bool fromTemplate)
                                        MakeDisplayPath(s, 50),
                                        _("Do you want to open the document?"))) {
                                // loads document
-                               owner->getMiniBuffer()->Set(_("Opening document"), 
-                                                           MakeDisplayPath(s), "...");
+                               owner->message(_("Opening document") + ' '
+                                              + MakeDisplayPath(s) + "...");
                                XFlush(fl_get_display());
                                owner->view()->buffer(
                                        bufferlist.loadLyXFile(s));
-                               owner->getMiniBuffer()->Set(_("Document"),
-                                                           MakeDisplayPath(s),
-                                                           _("opened."));
+                               owner->message(_("Document") + ' '
+                                              + MakeDisplayPath(s) + ' '
+                                              + _("opened."));
                                return;
                        }
                }
@@ -1596,10 +1644,14 @@ void LyXFunc::MenuNew(bool fromTemplate)
        if (fromTemplate) {
                FileDialog fileDlg(owner, _("Select template file"),
                        LFUN_SELECT_FILE_SYNC,
-                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
-                       make_pair(string(_("Templates")), string(lyxrc.template_path)));
-
-               FileDialog::Result result = fileDlg.Select(initpath, _("*.lyx|LyX Documents (*.lyx)"));
+                       make_pair(string(_("Documents")),
+                                 string(lyxrc.document_path)),
+                       make_pair(string(_("Templates")),
+                                 string(lyxrc.template_path)));
+
+               FileDialog::Result result =
+                       fileDlg.Select(initpath,
+                                      _("*.lyx|LyX Documents (*.lyx)"));
        
                if (result.first == FileDialog::Later)
                        return;
@@ -1633,10 +1685,14 @@ void LyXFunc::Open(string const & fname)
        if (fname.empty()) {
                FileDialog fileDlg(owner, _("Select document to open"),
                        LFUN_FILE_OPEN,
-                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
-                       make_pair(string(_("Examples")), string(AddPath(system_lyxdir, "examples"))));
-
-               FileDialog::Result result = fileDlg.Select(initpath, "*.lyx|LyX Documents (*.lyx)");
+                       make_pair(string(_("Documents")),
+                                 string(lyxrc.document_path)),
+                       make_pair(string(_("Examples")),
+                                 string(AddPath(system_lyxdir, "examples"))));
+
+               FileDialog::Result result =
+                       fileDlg.Select(initpath,
+                                      "*.lyx|LyX Documents (*.lyx)");
        
                if (result.first == FileDialog::Later)
                        return;
@@ -1645,7 +1701,7 @@ void LyXFunc::Open(string const & fname)
  
                // check selected filename
                if (filename.empty()) {
-                       owner->getMiniBuffer()->Set(_("Canceled."));
+                       owner->message(_("Canceled."));
                        return;
                }
        } else
@@ -1658,17 +1714,17 @@ void LyXFunc::Open(string const & fname)
                filename += ".lyx";
 
        // loads document
-       owner->getMiniBuffer()->Set(_("Opening document"),
-                                   MakeDisplayPath(filename), "...");
+       owner->message(_("Opening document") + ' '
+                      + MakeDisplayPath(filename) + "...");
        Buffer * openbuf = bufferlist.loadLyXFile(filename);
        if (openbuf) {
                owner->view()->buffer(openbuf);
-               owner->getMiniBuffer()->Set(_("Document"),
-                                           MakeDisplayPath(filename),
-                                           _("opened."));
+               owner->message(_("Document") + ' '
+                              + MakeDisplayPath(filename)
+                              + ' ' + _("opened."));
        } else {
-               owner->getMiniBuffer()->Set(_("Could not open document"),
-                                           MakeDisplayPath(filename));
+               owner->message(_("Could not open document") + ' '
+                              + MakeDisplayPath(filename));
        }
 }
 
@@ -1696,13 +1752,17 @@ void LyXFunc::doImport(string const & argument)
 
                FileDialog fileDlg(owner, text, 
                        LFUN_IMPORT,
-                       make_pair(string(_("Documents")), string(lyxrc.document_path)),
-                       make_pair(string(_("Examples")), string(AddPath(system_lyxdir, "examples"))));
+                       make_pair(string(_("Documents")),
+                                 string(lyxrc.document_path)),
+                       make_pair(string(_("Examples")),
+                                 string(AddPath(system_lyxdir, "examples"))));
                        
-               string const extension = "*." + formats.Extension(format) + "| " +
-                       formats.PrettyName(format) + " (*." + formats.Extension(format) + ")";
+               string const extension = "*." + formats.Extension(format)
+                       + "| " + formats.PrettyName(format)
+                       + " (*." + formats.Extension(format) + ")";
 
-               FileDialog::Result result = fileDlg.Select(initpath, extension);
+               FileDialog::Result result = fileDlg.Select(initpath,
+                                                          extension);
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1710,8 +1770,8 @@ void LyXFunc::doImport(string const & argument)
                filename = result.second;
  
                // check selected filename
-               if (filename.empty()) 
-                       owner->getMiniBuffer()->Set(_("Canceled."));
+               if (filename.empty())
+                       owner->message(_("Canceled."));
        }
 
        // still no filename? abort
@@ -1726,9 +1786,9 @@ void LyXFunc::doImport(string const & argument)
        // Check if the document already is open
        if (bufferlist.exists(lyxfile)) {
                switch (AskConfirmation(_("Document is already open:"), 
-                                      MakeDisplayPath(lyxfile, 50),
-                                      _("Do you want to close that document now?\n"
-                                        "('No' will just switch to the open version)")))
+                                       MakeDisplayPath(lyxfile, 50),
+                                       _("Do you want to close that document now?\n"
+                                         "('No' will just switch to the open version)")))
                        {
                        case 1: // Yes: close the document
                                if (!bufferlist.close(bufferlist.getBuffer(lyxfile)))
@@ -1739,7 +1799,7 @@ void LyXFunc::doImport(string const & argument)
                                owner->view()->buffer(bufferlist.getBuffer(lyxfile));
                                return;
                        case 3: // Cancel: Do nothing
-                               owner->getMiniBuffer()->Set(_("Canceled."));
+                               owner->message(_("Canceled."));
                                return;
                        }
        }
@@ -1749,11 +1809,11 @@ void LyXFunc::doImport(string const & argument)
        if (f.exist() && !AskQuestion(_("A document by the name"), 
                                      MakeDisplayPath(lyxfile),
                                      _("already exists. Overwrite?"))) {
-               owner->getMiniBuffer()->Set(_("Canceled."));
+               owner->message(_("Canceled"));
                return;
        }
        // filename should be valid now
-
+       
        Importer::Import(owner, filename, format);
 }
 
@@ -1798,3 +1858,50 @@ void LyXFunc::setMessage(string const & m)
 {
        dispatch_buffer = m;
 }
+
+
+void LyXFunc::initMiniBuffer() 
+{
+       string text = _("Welcome to LyX!");
+       
+       // When meta-fake key is pressed, show the key sequence so far + "M-".
+       if (wasMetaKey()) {
+               keyseqStr();
+               text += "M-";
+       }
+
+       // Else, when a non-complete key sequence is pressed,
+       // show the available options.
+       else if (keyseqUncomplete()) 
+               text = keyseqOptions();
+   
+       // Else, show the buffer state.
+       else if (owner->view()->available()) {
+               Buffer * tmpbuf = owner->buffer();
+               
+               string const nicename = 
+                       MakeDisplayPath(tmpbuf->fileName());
+               // Should we do this instead? (kindo like emacs)
+               // leaves more room for other information
+               text = "LyX: ";
+               text += nicename;
+               if (tmpbuf->lyxvc.inUse()) {
+                       text += " [";
+                       text += tmpbuf->lyxvc.version();
+                       text += ' ';
+                       text += tmpbuf->lyxvc.locker();
+                       if (tmpbuf->isReadonly())
+                               text += " (RO)";
+                       text += ']';
+               } else if (tmpbuf->isReadonly())
+                       text += " [RO]";
+               if (!tmpbuf->isLyxClean())
+                       text += _(" (Changed)");
+       } else {
+               if (text != _("Welcome to LyX!")) // this is a hack
+                       text = _("* No document open *");
+       }
+       
+       owner->message(text);
+}
+