]> git.lyx.org Git - lyx.git/blobdiff - src/LyXFunc.cpp
white space -> tabs
[lyx.git] / src / LyXFunc.cpp
index ff93bd876deb171e237aef21b3cc96026182e2f9..f549847e39ace99b6ce4d1f42bc7ee95d9573961 100644 (file)
@@ -18,6 +18,7 @@
  */
 
 #include <config.h>
+#include <vector>
 
 #include "LyXFunc.h"
 
@@ -28,7 +29,7 @@
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "bufferview_funcs.h"
-#include "LCursor.h"
+#include "Cursor.h"
 #include "CutAndPaste.h"
 #include "debug.h"
 #include "DispatchResult.h"
 #include "Importer.h"
 #include "InsetIterator.h"
 #include "Intl.h"
-#include "kb_keymap.h"
+#include "KeyMap.h"
 #include "Language.h"
-#include "LColor.h"
+#include "Color.h"
 #include "Session.h"
 #include "LyX.h"
-#include "lyx_cb.h"
+#include "callback.h"
 #include "LyXAction.h"
 #include "lyxfind.h"
-#include "LyXLex.h"
+#include "Lexer.h"
 #include "LyXRC.h"
 #include "Row.h"
-#include "LyXServer.h"
-#include "LyXTextClassList.h"
+#include "Server.h"
+#include "TextClassList.h"
 #include "LyXVC.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
@@ -67,6 +68,7 @@
 #include "insets/InsetERT.h"
 #include "insets/InsetExternal.h"
 #include "insets/InsetFloat.h"
+#include "insets/InsetListings.h"
 #include "insets/InsetGraphics.h"
 #include "insets/InsetInclude.h"
 #include "insets/InsetNote.h"
 #include "insets/InsetWrap.h"
 
 #include "frontends/Application.h"
-#include "frontends/Alert.h"
+#include "frontends/alert.h"
 #include "frontends/Dialogs.h"
 #include "frontends/FileDialog.h"
 #include "frontends/FontLoader.h"
 #include "frontends/Gui.h"
-#include "frontends/LyXKeySym.h"
+#include "frontends/KeySymbol.h"
 #include "frontends/LyXView.h"
 #include "frontends/Menubar.h"
 #include "frontends/Toolbars.h"
@@ -146,7 +148,7 @@ namespace fs = boost::filesystem;
 
 namespace {
 
-bool getLocalStatus(LCursor cursor,
+bool getLocalStatus(Cursor cursor,
               FuncRequest const & cmd, FuncStatus & status)
 {
        // Try to fix cursor in case it is broken.
@@ -155,10 +157,10 @@ bool getLocalStatus(LCursor cursor,
        // This is, of course, a mess. Better create a new doc iterator and use
        // this in Inset::getStatus. This might require an additional
        // BufferView * arg, though (which should be avoided)
-       //LCursor safe = *this;
+       //Cursor safe = *this;
        bool res = false;
        for ( ; cursor.depth(); cursor.pop()) {
-               //lyxerr << "\nLCursor::getStatus: cmd: " << cmd << endl << *this << endl;
+               //lyxerr << "\nCursor::getStatus: cmd: " << cmd << endl << *this << endl;
                BOOST_ASSERT(cursor.idx() <= cursor.lastidx());
                BOOST_ASSERT(cursor.pit() <= cursor.lastpit());
                BOOST_ASSERT(cursor.pos() <= cursor.lastpos());
@@ -207,10 +209,10 @@ LyXFunc::LyXFunc()
 }
 
 
-void LyXFunc::initKeySequences(kb_keymap * kb)
+void LyXFunc::initKeySequences(KeyMap * kb)
 {
-       keyseq.reset(new kb_sequence(kb, kb));
-       cancel_meta_seq.reset(new kb_sequence(kb, kb));
+       keyseq.reset(new KeySequence(kb, kb));
+       cancel_meta_seq.reset(new KeySequence(kb, kb));
 }
 
 
@@ -271,11 +273,11 @@ void LyXFunc::gotoBookmark(unsigned int idx, bool openFile, bool switchToBuffer)
                // see http://bugzilla.lyx.org/show_bug.cgi?id=3092
                if (bm.bottom_pit != new_pit || bm.bottom_pos != new_pos || bm.top_id != new_id )
                        const_cast<BookmarksSection::Bookmark &>(bm).updatePos(new_pit, new_pos, new_id);
-       } 
+       }
 }
 
 
-void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
+void LyXFunc::processKeySym(KeySymbolPtr keysym, key_modifier::state state)
 {
        LYXERR(Debug::KEY) << "KeySym is " << keysym->getSymbolName() << endl;
 
@@ -383,7 +385,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
        FuncStatus flag;
 
-       LCursor & cur = view()->cursor();
+       Cursor & cur = view()->cursor();
 
        /* In LyX/Mac, when a dialog is open, the menus of the
           application can still be accessed without giving focus to
@@ -467,7 +469,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
 
        case LFUN_LAYOUT_TABULAR:
-               enable = cur.innerInsetOfType(InsetBase::TABULAR_CODE);
+               enable = cur.innerInsetOfType(Inset::TABULAR_CODE);
                break;
 
        case LFUN_LAYOUT:
@@ -496,29 +498,32 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                enable = false;
                if (!cur)
                        break;
-               InsetBase::Code code = cur.inset().lyxCode();
+               Inset::Code code = cur.inset().lyxCode();
                switch (code) {
-                       case InsetBase::TABULAR_CODE:
+                       case Inset::TABULAR_CODE:
                                enable = cmd.argument() == "tabular";
                                break;
-                       case InsetBase::ERT_CODE:
+                       case Inset::ERT_CODE:
                                enable = cmd.argument() == "ert";
                                break;
-                       case InsetBase::FLOAT_CODE:
+                       case Inset::FLOAT_CODE:
                                enable = cmd.argument() == "float";
                                break;
-                       case InsetBase::WRAP_CODE:
+                       case Inset::WRAP_CODE:
                                enable = cmd.argument() == "wrap";
                                break;
-                       case InsetBase::NOTE_CODE:
+                       case Inset::NOTE_CODE:
                                enable = cmd.argument() == "note";
                                break;
-                       case InsetBase::BRANCH_CODE:
+                       case Inset::BRANCH_CODE:
                                enable = cmd.argument() == "branch";
                                break;
-                       case InsetBase::BOX_CODE:
+                       case Inset::BOX_CODE:
                                enable = cmd.argument() == "box";
                                break;
+                       case Inset::LISTINGS_CODE:
+                               enable = cmd.argument() == "listings";
+                               break;
                        default:
                                break;
                }
@@ -527,7 +532,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 
        case LFUN_INSET_APPLY: {
                string const name = cmd.getArg(0);
-               InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
+               Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
                if (inset) {
                        FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
                        FuncStatus fs;
@@ -544,6 +549,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
        }
 
+       case LFUN_DIALOG_TOGGLE:
+               flag.setOnOff(lyx_view_->getDialogs().visible(cmd.getArg(0)));
+               // fall through to set "enable"
        case LFUN_DIALOG_SHOW: {
                string const name = cmd.getArg(0);
                if (!buf)
@@ -555,7 +563,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                        enable = Exporter::isExportable(*buf, "dvi")
                                && lyxrc.print_command != "none";
                else if (name == "character")
-                       enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
+                       enable = cur.inset().lyxCode() != Inset::ERT_CODE &&
+                               cur.inset().lyxCode() != Inset::LISTINGS_CODE;
                else if (name == "latexlog")
                        enable = isFileReadable(FileName(buf->getLogName().second));
                else if (name == "spellchecker")
@@ -570,8 +579,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        case LFUN_DIALOG_SHOW_NEW_INSET:
-               enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
-               if (cur.inset().lyxCode() == InsetBase::CAPTION_CODE) {
+               enable = cur.inset().lyxCode() != Inset::ERT_CODE &&
+                       cur.inset().lyxCode() != Inset::LISTINGS_CODE;
+               if (cur.inset().lyxCode() == Inset::CAPTION_CODE) {
                        FuncStatus flag;
                        if (cur.inset().getStatus(cur, cmd, flag))
                                return flag;
@@ -607,10 +617,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                enable = LyX::ref().session().bookmarks().size() > 0;
                break;
 
-       case LFUN_TOOLBAR_TOGGLE_STATE: {
-               ToolbarInfo::Flags flags = lyx_view_->getToolbarState(to_utf8(cmd.argument()));
-               if (!(flags & ToolbarInfo::AUTO))
-                       flag.setOnOff(flags & ToolbarInfo::ON);
+       case LFUN_TOOLBAR_TOGGLE: {
+               bool const current = lyx_view_->getToolbars().visible(cmd.getArg(0));
+               flag.setOnOff(current);
+               break;
+       }
+       case LFUN_WINDOW_CLOSE: {
+               enable = (theApp()->gui().viewIds().size() > 1);
                break;
        }
 
@@ -637,7 +650,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_BUFFER_UPDATE:
        case LFUN_BUFFER_VIEW:
        case LFUN_BUFFER_IMPORT:
-       case LFUN_TOC_VIEW:
        case LFUN_BUFFER_AUTO_SAVE:
        case LFUN_RECONFIGURE:
        case LFUN_HELP_OPEN:
@@ -675,7 +687,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_BUFFER_NEXT:
        case LFUN_BUFFER_PREVIOUS:
        case LFUN_WINDOW_NEW:
-       case LFUN_WINDOW_CLOSE:
        case LFUN_LYX_QUIT:
                // these are handled in our dispatch()
                break;
@@ -880,7 +891,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                menuWrite(lyx_view_->buffer());
                                lyx_view_->message(str + _(" done."));
                        } else {
-                               writeAs(lyx_view_->buffer());
+                               writeAs(lyx_view_->buffer());
                        }
                        updateFlags = Update::None;
                        break;
@@ -897,7 +908,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        docstring text = bformat(_("Any changes will be lost. Are you sure "
                                                             "you want to revert to the saved version of the document %1$s?"), file);
                        int const ret = Alert::prompt(_("Revert to saved document?"),
-                               text, 0, 1, _("&Revert"), _("&Cancel"));
+                               text, 1, 1, _("&Revert"), _("&Cancel"));
 
                        if (ret == 0)
                                reloadBuffer();
@@ -1049,6 +1060,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                                        command2);
                                } else {
                                        // case 2: print directly to a printer
+                                       if (target_name != "default")
+                                               command += lyxrc.print_to_printer + target_name + ' ';
                                        res = one.startscript(
                                                Systemcall::DontWait,
                                                command + quoteName(dviname));
@@ -1060,10 +1073,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                if (fs::exists(filename.toFilesystemEncoding())) {
                                        docstring text = bformat(
                                                _("The file %1$s already exists.\n\n"
-                                                 "Do you want to over-write that file?"),
+                                                 "Do you want to overwrite that file?"),
                                                makeDisplayPath(filename.absFilename()));
-                                       if (Alert::prompt(_("Over-write file?"),
-                                           text, 0, 1, _("&Over-write"), _("&Cancel")) != 0)
+                                       if (Alert::prompt(_("Overwrite file?"),
+                                           text, 0, 1, _("&Overwrite"), _("&Cancel")) != 0)
                                                break;
                                }
                                command += lyxrc.print_to_file
@@ -1091,14 +1104,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                theApp()->gui().closeAllViews();
                        break;
 
-               case LFUN_TOC_VIEW: {
-                       BOOST_ASSERT(lyx_view_);
-                       InsetCommandParams p("tableofcontents");
-                       string const data = InsetCommandMailer::params2string("toc", p);
-                       lyx_view_->getDialogs().show("toc", data, 0);
-                       break;
-               }
-
                case LFUN_BUFFER_AUTO_SAVE:
                        autoSave(view());
                        break;
@@ -1220,7 +1225,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                case LFUN_SERVER_NOTIFY:
                        dispatch_buffer = keyseq->print(false);
-                       theLyXServer().notifyClient(to_utf8(dispatch_buffer));
+                       theServer().notifyClient(to_utf8(dispatch_buffer));
                        break;
 
                case LFUN_SERVER_GOTO_FILE_ROW: {
@@ -1271,11 +1276,11 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                        data = "literate ";
                                        break;
                                }
-                               data += LyXLex::quoteString(logfile.second);
+                               data += Lexer::quoteString(logfile.second);
                                lyx_view_->getDialogs().show("log", data);
                        } else if (name == "vclog") {
                                string const data = "vc " +
-                                       LyXLex::quoteString(lyx_view_->buffer()->lyxvc().getLogFile());
+                                       Lexer::quoteString(lyx_view_->buffer()->lyxvc().getLogFile());
                                lyx_view_->getDialogs().show("log", data);
                        } else
                                lyx_view_->getDialogs().show(name, data);
@@ -1323,6 +1328,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        } else if (name == "float") {
                                InsetFloatParams p;
                                data = InsetFloatMailer::params2string(p);
+                       } else if (name == "listings") {
+                               InsetListingsParams p;
+                               data = InsetListingsMailer::params2string(p);
                        } else if (name == "graphics") {
                                InsetGraphicsParams p;
                                Buffer const & buffer = *lyx_view_->buffer();
@@ -1345,7 +1353,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        BOOST_ASSERT(lyx_view_);
                        string const & name = argument;
                        // Can only update a dialog connected to an existing inset
-                       InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
+                       Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
                                inset->dispatch(view()->cursor(), fr);
@@ -1361,6 +1369,15 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        Dialogs::hide(argument, 0);
                        break;
 
+               case LFUN_DIALOG_TOGGLE: {
+                       BOOST_ASSERT(lyx_view_);
+                       if (lyx_view_->getDialogs().visible(cmd.getArg(0)))
+                               dispatch(FuncRequest(LFUN_DIALOG_HIDE, argument));
+                       else
+                               dispatch(FuncRequest(LFUN_DIALOG_SHOW, argument));
+                       break;
+               }
+
                case LFUN_DIALOG_DISCONNECT_INSET:
                        BOOST_ASSERT(lyx_view_);
                        lyx_view_->getDialogs().disconnect(argument);
@@ -1393,21 +1410,34 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                }
 
                case LFUN_BUFFER_CHILD_OPEN: {
+                       // takes an optional argument, "|bool", at the end
+                       // indicating whether this file is being opened automatically
+                       // by LyX itself, in which case we will not want to switch
+                       // buffers after opening. The default is false, so in practice
+                       // it is used only when true.
                        BOOST_ASSERT(lyx_view_);
-                       FileName const filename =
+                       int const arglength = argument.length();
+                       FileName filename;
+                       bool autoOpen = false;
+                       if (argument.substr(arglength - 5, 5) == "|true") {
+                               autoOpen = true;
+                               filename = makeAbsPath(argument.substr(0, arglength - 5), 
+                                       lyx_view_->buffer()->filePath());
+                       } else if (argument.substr(arglength - 6, 6) == "|false") {
+                               filename = makeAbsPath(argument.substr(0, arglength - 6), 
+                                       lyx_view_->buffer()->filePath());
+                       } else filename = 
                                makeAbsPath(argument, lyx_view_->buffer()->filePath());
-                       setMessage(bformat(_("Opening child document %1$s..."),
-                                          makeDisplayPath(filename.absFilename())));
                        view()->saveBookmark(false);
-                       string const parentfilename = lyx_view_->buffer()->fileName();
-                       if (theBufferList().exists(filename.absFilename()))
-                               lyx_view_->setBuffer(theBufferList().getBuffer(filename.absFilename()));
-                       else
-                               lyx_view_->loadLyXFile(filename);
-                       // Set the parent name of the child document.
-                       // This makes insertion of citations and references in the child work,
-                       // when the target is in the parent or another child document.
-                       lyx_view_->buffer()->setParentName(parentfilename);
+                       if (theBufferList().exists(filename.absFilename())) {
+                               Buffer * buf = theBufferList().getBuffer(filename.absFilename());
+                               if (!autoOpen)
+                                       lyx_view_->setBuffer(buf, true);
+                               else
+                                       buf->setParentName(lyx_view_->buffer()->fileName());
+                       } else
+                               lyx_view_->loadLyXFile(filename, true, true, autoOpen);
+
                        break;
                }
 
@@ -1464,8 +1494,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                case LFUN_PREFERENCES_SAVE: {
                        lyxrc.write(makeAbsPath("preferences",
-                                               package().user_support().absFilename()),
-                                   false);
+                                               package().user_support().absFilename()),
+                                   false);
                        break;
                }
 
@@ -1489,8 +1519,8 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        }
 
                        bool const graphicsbg_changed =
-                               (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
-                                x11_name != lcolor.getX11Name(LColor::graphicsbg));
+                               (lyx_name == lcolor.getLyXName(Color::graphicsbg) &&
+                                x11_name != lcolor.getX11Name(Color::graphicsbg));
 
                        if (!lcolor.setColor(lyx_name, x11_name)) {
                                setErrorMessage(
@@ -1535,7 +1565,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_INSET_APPLY: {
                        BOOST_ASSERT(lyx_view_);
                        string const name = cmd.getArg(0);
-                       InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
+                       Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_MODIFY, argument);
                                inset->dispatch(view()->cursor(), fr);
@@ -1553,20 +1583,20 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        BOOST_ASSERT(lyx_view_);
                        string action;
                        string const name = split(argument, action, ' ');
-                       InsetBase::Code const inset_code =
-                               InsetBase::translate(name);
+                       Inset::Code const inset_code =
+                               Inset::translate(name);
 
-                       LCursor & cur = view()->cursor();
+                       Cursor & cur = view()->cursor();
                        FuncRequest fr(LFUN_INSET_TOGGLE, action);
 
-                       InsetBase & inset = lyx_view_->buffer()->inset();
+                       Inset & inset = lyx_view_->buffer()->inset();
                        InsetIterator it  = inset_iterator_begin(inset);
                        InsetIterator const end = inset_iterator_end(inset);
                        for (; it != end; ++it) {
                                if (!it->asInsetMath()
-                                   && (inset_code == InsetBase::NO_CODE
+                                   && (inset_code == Inset::NO_CODE
                                    || inset_code == it->lyxCode())) {
-                                       LCursor tmpcur = cur;
+                                       Cursor tmpcur = cur;
                                        tmpcur.pushLeft(*it);
                                        it->dispatch(tmpcur, fr);
                                }
@@ -1596,7 +1626,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        Buffer defaults(fname);
 
                        istringstream ss(argument);
-                       LyXLex lex(0,0);
+                       Lexer lex(0,0);
                        lex.setStream(ss);
                        int const unknown_tokens = defaults.readHeader(lex);
 
@@ -1609,7 +1639,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                        if (defaults.writeFile(FileName(defaults.fileName())))
                                setMessage(bformat(_("Document defaults saved in %1$s"),
-                                                  makeDisplayPath(fname)));
+                                                  makeDisplayPath(fname)));
                        else
                                setErrorMessage(from_ascii(N_("Unable to save document defaults")));
                        break;
@@ -1621,7 +1651,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                lyx_view_->buffer()->params().getEngine();
 
                        istringstream ss(argument);
-                       LyXLex lex(0,0);
+                       Lexer lex(0,0);
                        lex.setStream(ss);
                        int const unknown_tokens =
                                lyx_view_->buffer()->readHeader(lex);
@@ -1635,14 +1665,14 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        if (engine == lyx_view_->buffer()->params().getEngine())
                                break;
 
-                       LCursor & cur = view()->cursor();
+                       Cursor & cur = view()->cursor();
                        FuncRequest fr(LFUN_INSET_REFRESH);
 
-                       InsetBase & inset = lyx_view_->buffer()->inset();
+                       Inset & inset = lyx_view_->buffer()->inset();
                        InsetIterator it  = inset_iterator_begin(inset);
                        InsetIterator const end = inset_iterator_end(inset);
                        for (; it != end; ++it)
-                               if (it->lyxCode() == InsetBase::CITE_CODE)
+                               if (it->lyxCode() == Inset::CITE_CODE)
                                        it->dispatch(cur, fr);
                        break;
                }
@@ -1736,9 +1766,25 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        LyX::ref().session().bookmarks().clear();
                        break;
 
-               case LFUN_TOOLBAR_TOGGLE_STATE:
-                       lyx_view_->toggleToolbarState(argument);
+               case LFUN_TOOLBAR_TOGGLE: {
+                       BOOST_ASSERT(lyx_view_);
+                       string const name = cmd.getArg(0);
+                       bool const allowauto = cmd.getArg(1) == "allowauto";
+                       lyx_view_->toggleToolbarState(name, allowauto);
+                       ToolbarInfo::Flags const flags = 
+                               lyx_view_->getToolbarState(name);
+                       docstring state;
+                       if (flags & ToolbarInfo::ON)
+                               state = _("on");
+                       else if (flags & ToolbarInfo::OFF)
+                               state = _("off");
+                       else if (flags & ToolbarInfo::AUTO)
+                               state = _("auto");
+
+                       setMessage(bformat(_("Toolbar \"%1$s\" state set to %2$s"), 
+                                                  from_ascii(name), state));
                        break;
+               }
 
                default: {
                        BOOST_ASSERT(lyx_view_);
@@ -2022,9 +2068,9 @@ void LyXFunc::doImport(string const & argument)
                docstring const file = makeDisplayPath(lyxfile.absFilename(), 30);
 
                docstring text = bformat(_("The document %1$s already exists.\n\n"
-                                                    "Do you want to over-write that document?"), file);
-               int const ret = Alert::prompt(_("Over-write document?"),
-                       text, 0, 1, _("&Over-write"), _("&Cancel"));
+                                                    "Do you want to overwrite that document?"), file);
+               int const ret = Alert::prompt(_("Overwrite document?"),
+                       text, 0, 1, _("&Overwrite"), _("&Cancel"));
 
                if (ret == 1) {
                        lyx_view_->message(_("Canceled."));