X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfunc.C;h=1ff937641a2012ac839fa9426e692bae64d9da69;hb=e06bc73c2272c18a5f52d4229449c4e0b0caf1e9;hp=600702e32e7326adb49a4834ac1985de84bdf079;hpb=16a7d8015e91922b0fb651beb7a5b24101084779;p=lyx.git diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 600702e32e..1ff937641a 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-2000 The LyX Team. + * Copyright 1995-2001 The LyX Team. * * ====================================================== */ @@ -14,22 +14,25 @@ #include #include +#include +#include #include #include -#include +//#include #ifdef __GNUG__ #pragma implementation #endif +#include "support/lyxalgo.h" #include "version.h" #include "kbmap.h" #include "lyxfunc.h" #include "bufferlist.h" #include "ColorHandler.h" #include "lyxserver.h" -#include "lyx.h" +#include "figure_form.h" #include "intl.h" #include "lyx_main.h" #include "lyx_cb.h" @@ -60,7 +63,6 @@ #include "minibuffer.h" #include "vspace.h" #include "LyXView.h" -#include "filedlg.h" #include "lyx_gui_misc.h" #include "support/filetools.h" #include "support/FileInfo.h" @@ -75,8 +77,8 @@ #include "trans_mgr.h" #include "layout.h" #include "WorkArea.h" -#include "lyxfr1.h" #include "bufferview_funcs.h" +#include "frontends/FileDialog.h" #include "frontends/Dialogs.h" #include "frontends/Toolbar.h" #include "frontends/Menubar.h" @@ -86,23 +88,21 @@ #include "importer.h" #include "FontLoader.h" #include "TextCache.h" +#include "lyxfind.h" using std::pair; +using std::make_pair; using std::endl; using std::find_if; -extern void math_insert_symbol(BufferView *, string const &); -extern bool math_insert_greek(BufferView *, char); extern BufferList bufferlist; extern LyXServer * lyxserver; extern int greek_kb_flag; extern bool selection_possible; +extern void MenuSendto(); -extern kb_keymap * toplevel_keymap; +extern boost::scoped_ptr toplevel_keymap; -#if 0 -extern void MenuFax(Buffer *); -#endif extern void show_symbols_form(LyXFunc *); extern LyXAction lyxaction; @@ -113,8 +113,43 @@ 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; @@ -128,20 +163,29 @@ LyXFunc::LyXFunc(LyXView * o) } +inline +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 // a moveCursorUpdate to some of the functions that updated the cursor, but // that did not show its new position. inline -void LyXFunc::moveCursorUpdate(LyXText * text, bool selecting) +void LyXFunc::moveCursorUpdate(bool flag, bool selecting) { - if (selecting || text->mark_set) { - text->SetSelection(owner->view()); - if (text->bv_owner) + if (selecting || TEXT(flag)->selection.mark()) { + TEXT(flag)->SetSelection(owner->view()); + if (TEXT(flag)->bv_owner) owner->view()->toggleToggle(); } - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR); + owner->view()->update(TEXT(flag), BufferView::SELECT|BufferView::FITCUR); owner->view()->showCursor(); /* ---> Everytime the cursor is moved, show the current font state. */ @@ -151,12 +195,31 @@ void LyXFunc::moveCursorUpdate(LyXText * text, bool selecting) } -int LyXFunc::processKeySym(KeySym keysym, unsigned int state) +void LyXFunc::handleKeyFunc(kb_action action) +{ + char 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 + // actions + keyseq.reset(); + keyseq.length = 0; + // copied verbatim from do_accent_char + owner->view()->update(TEXT(false), + BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); + TEXT(false)->selection.cursor = TEXT(false)->cursor; +} + + +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 @@ -170,35 +233,20 @@ 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 (owner->view()->available()) { - // this function should be used always [asierra060396] - UpdatableInset * tli = owner->view()->theLockingInset(); - if (tli && (keysym == XK_Escape)) { - if (tli == tli->GetLockingInset()) { - owner->view()->unlockInset(tli); - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(owner->view()->text, false); - owner->showState(); - } else { - tli->UnlockInsetInInset(owner->view(), - tli->GetLockingInset(),true); - } - //return 0; - return FL_PREEMPT; - } - } - // 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(); @@ -215,7 +263,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, @@ -223,7 +272,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. @@ -234,7 +284,7 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) if (lyxerr.debugging(Debug::KEY)) { string buf; keyseq.print(buf); - lyxerr << "Key [" + lyxerr << "Key [action=" << action << "][" << buf << "]" << endl; @@ -247,72 +297,72 @@ 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; + // It is unknown, but what if we remove all + // the modifiers? (Lgb) + action = keyseq.addkey(keysym, 0); + + if (lyxerr.debugging(Debug::KEY)) { + lyxerr << "Removing modifiers...\n" + << "Action now set to [" + << action << "]" << endl; } - - char const isochar = keyseq.getiso(); - if (!(state & ControlMask) && - !(state & Mod1Mask) && - (isochar && keysym < 0xF000)) { - argument += isochar; + if (action == -1) { + owner->message(_("Unknown function.")); + //return 0; + return; } - 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 == LFUN_SELFINSERT) { + // This is very X dependant. + 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: + // latin 8 byte 3 = 18 (0x12) + case 0x00001200: + // latin 9 byte 3 = 19 (0x13) + case 0x00001300: + c &= 0x000000FF; + break; + default: + c = 0; + break; } - } else if (action == LFUN_SELFINSERT) { - // We must set the argument to the char looked up by - // XKeysymToString - XKeyEvent xke; - xke.type = KeyPress; - xke.serial = 0; - xke.send_event = False; - xke.display = fl_get_display(); - xke.window = 0; - xke.root = 0; - xke.subwindow = 0; - xke.time = 0; - xke.x = 0; - xke.y = 0; - xke.x_root = 0; - xke.y_root = 0; - xke.state = state; - xke.keycode = XKeysymToKeycode(fl_get_display(), keysym); - xke.same_screen = True; - char ret[10]; - KeySym tmpkeysym; - int 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; + if (c > 0) + argument = static_cast(c); + lyxerr[Debug::KEY] << "SelfInsert arg[`" + << argument << "']" << endl; } - bool tmp_sc = show_sc; show_sc = false; 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 { kb_action action; func_status flag = LyXFunc::OK; @@ -321,8 +371,11 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const if (lyxaction.isPseudoAction(ac)) action = lyxaction.retrieveActionArg(ac, argument); - else + else { action = static_cast(ac); + if (!not_to_use_arg.empty()) + argument = not_to_use_arg; // exept here + } if (action == LFUN_UNKNOWN_ACTION) { setErrorMessage(N_("Unknown action")); @@ -359,17 +412,10 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const disable = !Exporter::IsExportable(buf, "dvi") || lyxrc.print_command == "none"; break; -#if 0 - case LFUN_FAX: - disable = !Exporter::IsExportable(buf, "ps") - || lyxrc.fax_command == "none"; - break; -#else case LFUN_EXPORT: disable = argument == "fax" && !Exporter::IsExportable(buf, argument); break; -#endif case LFUN_UNDO: disable = buf->undostack.empty(); break; @@ -387,8 +433,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const break; case LFUN_INSERTFOOTNOTE: - case LFUN_FOOTMELT: - case LFUN_MARGINMELT: // Disable insertion of floats in a tabular. disable = false; if (owner->view()->theLockingInset()) { @@ -459,7 +503,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const if (buf) { func_status box = LyXFunc::ToggleOff; LyXFont const & font = - owner->view()->getLyXText()->real_current_font; + TEXT(false)->real_current_font; switch (action) { case LFUN_EMPH: if (font.emph() == LyXFont::ON) @@ -488,6 +532,13 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const } +// 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 @@ -500,7 +551,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; @@ -530,11 +581,8 @@ string const LyXFunc::Dispatch(int ac, if (owner->view()->available()) owner->view()->hideCursor(); - // We have to do this heare because of te goto below. (Lgb) - LyXText * text = owner->view()->getLyXText(); - // We cannot use this function here - if (getStatus(ac) & Disabled) + if (getStatus(ac, do_not_use_this_arg) & Disabled) goto exit_with_message; commandshortcut.erase(); @@ -575,7 +623,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. @@ -603,11 +652,11 @@ string const LyXFunc::Dispatch(int ac, inset->GetCursorPos(owner->view(), slx, sly); owner->view()->unlockInset(inset); owner->view()->menuUndo(); - if (owner->view()->text->cursor.par()-> - IsInset(owner->view()->text->cursor.pos())) { + if (TEXT()->cursor.par()-> + IsInset(TEXT()->cursor.pos())) { inset = static_cast( - owner->view()->text->cursor.par()-> - GetInset(owner->view()->text-> + TEXT()->cursor.par()-> + GetInset(TEXT()-> cursor.pos())); } else { inset = 0; @@ -624,8 +673,8 @@ string const LyXFunc::Dispatch(int ac, owner->view()->unlockInset(inset); owner->view()->menuRedo(); inset = static_cast( - owner->view()->text->cursor.par()-> - GetInset(owner->view()->text-> + TEXT()->cursor.par()-> + GetInset(TEXT()-> cursor.pos())); if (inset) inset->Edit(owner->view(),slx,sly,0); @@ -642,27 +691,30 @@ string const LyXFunc::Dispatch(int ac, case LFUN_UNKNOWN_ACTION: case LFUN_BREAKPARAGRAPH: case LFUN_BREAKLINE: - owner->view()->text->CursorRight(owner->view()); + TEXT()->CursorRight(owner->view()); owner->view()->setState(); owner->showState(); break; case LFUN_RIGHT: - if (!owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(owner->view()->text, false); + if (!TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { + TEXT()->CursorRight(owner->view()); + moveCursorUpdate(true, false); owner->showState(); } return string(); case LFUN_LEFT: - if (owner->view()->text->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { - owner->view()->text->CursorRight(owner->view()); - moveCursorUpdate(owner->view()->text, false); + if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) { + TEXT()->CursorRight(owner->view()); + moveCursorUpdate(true, false); owner->showState(); } return string(); case LFUN_DOWN: - owner->view()->text->CursorDown(owner->view()); - moveCursorUpdate(owner->view()->text, false); + if (TEXT()->cursor.row()->next()) + TEXT()->CursorDown(owner->view()); + else + TEXT()->CursorRight(owner->view()); + moveCursorUpdate(true, false); owner->showState(); return string(); default: @@ -672,7 +724,34 @@ string const LyXFunc::Dispatch(int ac, } } + 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 : { @@ -686,26 +765,24 @@ string const LyXFunc::Dispatch(int ac, searched_string = last_search; } - LyXText * ltCur = owner->view()->text ; - if (!searched_string.empty() && ((action == LFUN_WORDFINDBACKWARD) ? - ltCur->SearchBackward(owner->view(), searched_string) : - ltCur->SearchForward(owner->view(), searched_string))) { + SearchBackward(owner->view(), searched_string) : + SearchForward(owner->view(), searched_string))) { // ??? What is that ??? - owner->view()->update(ltCur, BufferView::SELECT|BufferView::FITCUR); + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); // ??? Needed ??? // clear the selection (if there is any) owner->view()->toggleSelection(); - owner->view()->text->ClearSelection(); + TEXT()->ClearSelection(owner->view()); // Move cursor so that successive C-s 's will not stand in place. if (action == LFUN_WORDFINDFORWARD ) - owner->view()->text->CursorRightOneWord(owner->view()); - owner->view()->text->FinishUndo(); - moveCursorUpdate(owner->view()->text, false); + TEXT()->CursorRightOneWord(owner->view()); + TEXT()->FinishUndo(); + moveCursorUpdate(true, false); // ??? Needed ??? // set the new selection @@ -717,23 +794,30 @@ string const LyXFunc::Dispatch(int ac, owner->view()->showCursor(); } break; - + case LFUN_PREFIX: { - if (owner->view()->available()) { - owner->view()->update(owner->view()->text, + if (owner->view()->available() && !owner->view()->theLockingInset()) { + owner->view()->update(TEXT(), BufferView::SELECT|BufferView::FITCUR); } 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 allCmds; + std::transform(lyxaction.func_begin(), lyxaction.func_end(), + std::back_inserter(allCmds), lyx::firster()); + static std::vector hist; + owner->getMiniBuffer()->getString(MiniBuffer::spaces, + allCmds, hist); + } + break; case LFUN_CANCEL: // RVDK_PATCH_5 keyseq.reset(); @@ -766,13 +850,6 @@ string const LyXFunc::Dispatch(int ac, owner->view()->center(); break; - case LFUN_APPENDIX: - if (owner->view()->available()) { - text->toggleAppendix(owner->view()); - owner->view()->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - } - break; - // --- Menus ----------------------------------------------- case LFUN_MENUNEW: MenuNew(false); @@ -782,33 +859,24 @@ string const LyXFunc::Dispatch(int ac, MenuNew(true); break; - case LFUN_MENUOPEN: - MenuOpen(); - break; - case LFUN_CLOSEBUFFER: CloseBuffer(); break; 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()); - //owner->getMiniBuffer()-> { - // Set(_("Document saved as"), - // MakeDisplayPath(owner->buffer()->fileName())); - //} else { - //owner->getMiniBuffer()->Set(_("Save failed!")); - //} - } else { - MenuWriteAs(owner->view(), owner->buffer()); - } + } else + WriteAs(owner->view(), owner->buffer()); break; - case LFUN_MENUWRITEAS: - MenuWriteAs(owner->view(), owner->buffer()); + case LFUN_WRITEAS: + WriteAs(owner->view(), owner->buffer(), argument); break; case LFUN_MENURELOAD: @@ -835,14 +903,11 @@ string const LyXFunc::Dispatch(int ac, owner->getDialogs()->showPrint(); break; -#if 0 - case LFUN_FAX: - MenuFax(owner->buffer()); - break; -#endif - case LFUN_EXPORT: - Exporter::Export(owner->buffer(), argument, false); + if (argument == "custom") + MenuSendto(); + else + Exporter::Export(owner->buffer(), argument, false); break; case LFUN_IMPORT: @@ -854,75 +919,38 @@ 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; } - case LFUN_TOC_INSERT: - case LFUN_LOA_INSERT: - case LFUN_LOF_INSERT: - case LFUN_LOT_INSERT: - { - InsetCommandParams p; - - if (action == LFUN_TOC_INSERT ) - p.setCmdName( "tableofcontents" ); - else if (action == LFUN_LOA_INSERT ) - p.setCmdName( "listofalgorithms" ); - else if (action == LFUN_LOF_INSERT ) - p.setCmdName( "listoffigures" ); - else - p.setCmdName( "listoftables" ); - - Inset * inset = new InsetTOC( p ); - if (!owner->view()->insertInset( inset, "Standard", true ) ) - delete inset; - break; - } - case LFUN_DIALOG_TABULAR_INSERT: owner->getDialogs()->showTabularCreate(); break; - case LFUN_TABULAR_FEATURE: - case LFUN_SCROLL_INSET: - // this is not handled here as this funktion is only aktive - // if we have a locking_inset and that one is (or contains) - // a tabular-inset - break; - case LFUN_FIGURE: Figure(); break; - case LFUN_INSET_GRAPHICS: - { - Inset * new_inset = new InsetGraphics; - if (!owner->view()->insertInset(new_inset)) { - delete new_inset; - } else { - // this is need because you don't use a inset->Edit() - owner->view()->updateInset(new_inset, true); - new_inset->Edit(owner->view(), 0, 0, 0); - } - break; - } - case LFUN_AUTOSAVE: AutoSave(owner->view()); break; @@ -936,111 +964,30 @@ string const LyXFunc::Dispatch(int ac, break; case LFUN_MENUSEARCH: - { - // Ok this is one _very_ bad solution, but I think that some - // of this will be rewritten as part of GUI indep anyway. - // Lgb - static LyXFindReplace FR_; - FR_.StartSearch(owner->view()); - } - break; - - case LFUN_PASTE: - owner->view()->paste(); - owner->view()->setState(); - break; - - case LFUN_PASTESELECTION: - { - bool asPara = false; - if (argument == "paragraph") asPara = true; - owner->view()->pasteClipboard(asPara); - } - break; - - case LFUN_CUT: - owner->view()->cut(); - break; - - case LFUN_COPY: - owner->view()->copy(); - break; - - case LFUN_LAYOUT_COPY: - owner->view()->copyEnvironment(); - break; - - case LFUN_LAYOUT_PASTE: - owner->view()->pasteEnvironment(); - owner->view()->setState(); - break; - - case LFUN_GOTOERROR: - owner->view()->gotoInset(Inset::ERROR_CODE, false); + owner->getDialogs()->showSearch(); break; case LFUN_REMOVEERRORS: if (owner->view()->removeAutoInsets()) { owner->view()->redraw(); - owner->view()->fitCursor(owner->view()->text); + owner->view()->fitCursor(TEXT()); } break; - - case LFUN_GOTONOTE: - owner->view()->gotoInset(Inset::IGNORE_CODE, false); - break; - - case LFUN_REFERENCE_GOTO: - { - vector tmp; - tmp.push_back(Inset::LABEL_CODE); - tmp.push_back(Inset::REF_CODE); - owner->view()->gotoInset(tmp, true); - break; - } - -#ifndef NEW_INSETS - case LFUN_OPENSTUFF: - owner->view()->openStuff(); - break; -#endif - - case LFUN_HYPHENATION: - owner->view()->hyphenationPoint(); - break; - - case LFUN_LDOTS: - owner->view()->ldots(); - break; - - case LFUN_END_OF_SENTENCE: - owner->view()->endOfSentenceDot(); - break; - case LFUN_MENU_SEPARATOR: - owner->view()->menuSeparator(); - break; - - case LFUN_HFILL: - owner->view()->hfill(); - break; - case LFUN_DEPTH: - changeDepth(owner->view(), text, 0); + changeDepth(owner->view(), TEXT(false), 0); break; case LFUN_DEPTH_MIN: - changeDepth(owner->view(), text, -1); + changeDepth(owner->view(), TEXT(false), -1); break; case LFUN_DEPTH_PLUS: - changeDepth(owner->view(), text, 1); + changeDepth(owner->view(), TEXT(false), 1); break; case LFUN_FREE: - Free(owner->view()); - owner->view()->setState(); - owner->showState(); + owner->getDialogs()->setUserFreeFont(); break; case LFUN_TEX: @@ -1048,43 +995,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() - && !owner->view()->text->selection - && owner->view()->text->cursor.par()->footnoteflag - != LyXParagraph::NO_FOOTNOTE) - { // only melt footnotes with FOOTMELT, not margins etc - if (owner->view()->text->cursor.par()->footnotekind == LyXParagraph::FOOTNOTE) - Melt(owner->view()); - } - else - Foot(owner->view()); - owner->view()->setState(); - break; - case LFUN_MARGINMELT: - if (owner->view()->available() - && !owner->view()->text->selection - && owner->view()->text->cursor.par()->footnoteflag - != LyXParagraph::NO_FOOTNOTE) { - // only melt margins - if (owner->view()->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); @@ -1096,7 +1012,9 @@ string const LyXFunc::Dispatch(int ac, owner->view()->allFloats(0,1); break; #else +#ifdef WITH_WARNINGS #warning Find another implementation here (or another lyxfunc)! +#endif #endif case LFUN_HELP_COPYRIGHT: owner->getDialogs()->showCopyright(); @@ -1106,22 +1024,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; @@ -1190,20 +1111,6 @@ string const LyXFunc::Dispatch(int ac, owner->view()->buffer(bufferlist.getBuffer(argument)); break; - - case LFUN_FILE_INSERT: - { - MenuInsertLyXFile(argument); - } - break; - - case LFUN_FILE_INSERT_ASCII: - { - bool asPara = (argument == "paragraph"); - InsertAsciiFile(owner->view(), string(), asPara); - } - break; - case LFUN_FILE_NEW: { // servercmd: argument must be :