? arguments.patch ? build Index: src/BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.244 diff -u -p -r1.244 BufferView_pimpl.C --- src/BufferView_pimpl.C 29 May 2002 16:20:56 -0000 1.244 +++ src/BufferView_pimpl.C 29 May 2002 19:24:01 -0000 @@ -1804,17 +1804,6 @@ bool BufferView::Pimpl::Dispatch(kb_acti lyxerr[Debug::INFO] << "LFUN_LAYOUT: (arg) " << argument << endl; - // This is not the good solution to the empty argument - // problem, but it will hopefully suffice for 1.2.0. - // The correct solution would be to augument the - // function list/array with information about what - // functions needs arguments and their type. - if (argument.empty()) { - owner_->getLyXFunc()->setErrorMessage( - _("LyX function 'layout' needs an argument.")); - break; - } - // Derive layout number from given argument (string) // and current buffer's textclass (number). */ bool hasLayout = tclass.hasLayout(argument); @@ -2829,12 +2818,16 @@ bool BufferView::Pimpl::Dispatch(kb_acti string tmp; istr >> tmp; + Spacing::Space new_spacing = cur_spacing; float new_value = cur_value; +#if 0 if (tmp.empty()) { lyxerr << "Missing argument to `paragraph-spacing'" << endl; - } else if (tmp == "single") { + } else +#endif + if (tmp == "single") { new_spacing = Spacing::Single; } else if (tmp == "onehalf") { new_spacing = Spacing::Onehalf; @@ -3188,6 +3181,7 @@ bool BufferView::Pimpl::Dispatch(kb_acti } break; +#if 0 case LFUN_INDEX_INSERT: { InsetCommandParams p; @@ -3200,6 +3194,7 @@ bool BufferView::Pimpl::Dispatch(kb_acti updateInset(inset, true); } break; +#endif case LFUN_INDEX_INSERT_LAST: { @@ -3287,8 +3282,9 @@ bool BufferView::Pimpl::Dispatch(kb_acti case LFUN_SELFINSERT: { +#if 0 if (argument.empty()) break; - +#endif /* Automatically delete the currently selected * text and replace it with what is being * typed in now. Depends on lyxrc settings Index: src/LyXAction.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LyXAction.C,v retrieving revision 1.115 diff -u -p -r1.115 LyXAction.C --- src/LyXAction.C 21 Mar 2002 17:25:08 -0000 1.115 +++ src/LyXAction.C 29 May 2002 19:24:01 -0000 @@ -102,16 +102,18 @@ void LyXAction::init() { LFUN_VECTOR, "accent-vector", "", Noop }, { LFUN_APPENDIX, "appendix", N_("Insert appendix"), Noop }, { LFUN_APROPOS, "apropos", N_("Describe command"), - NoBuffer|ReadOnly }, + NoBuffer | ReadOnly | Argument }, { LFUN_LEFTSEL, "backward-select", N_("Select previous char"), ReadOnly }, - { LFUN_BIBDB_ADD, "bibtex-database-add", "", Noop }, - { LFUN_BIBDB_DEL, "bibtex-database-del", "", Noop }, + { LFUN_BIBDB_ADD, "bibtex-database-add", "", Argument }, + { LFUN_BIBDB_DEL, "bibtex-database-del", "", Argument }, { LFUN_INSERT_BIBTEX, "bibtex-insert", N_("Insert bibtex"), - Noop }, - { LFUN_BIBTEX_STYLE, "bibtex-style", "", Noop }, - { LFUN_BOOKMARK_GOTO, "bookmark-goto", "", ReadOnly }, - { LFUN_BOOKMARK_SAVE, "bookmark-save", "", ReadOnly }, + Argument }, + { LFUN_BIBTEX_STYLE, "bibtex-style", "", Argument }, + { LFUN_BOOKMARK_GOTO, "bookmark-goto", "", + ReadOnly | Argument }, + { LFUN_BOOKMARK_SAVE, "bookmark-save", "", + ReadOnly | Argument}, { LFUN_BREAKLINE, "break-line", "", Noop }, { LFUN_BREAKPARAGRAPH, "break-paragraph", "", Noop }, { LFUN_BREAKPARAGRAPHKEEPLAYOUT, "break-paragraph-keep-layout", @@ -124,17 +126,19 @@ void LyXAction::init() N_("Go to beginning of document"), ReadOnly }, { LFUN_BEGINNINGBUFSEL, "buffer-begin-select", N_("Select to beginning of document"), ReadOnly }, - { LFUN_CHILD_INSERT, "buffer-child-insert", "", Noop }, - { LFUN_CHILDOPEN, "buffer-child-open", "", ReadOnly }, + { LFUN_CHILD_INSERT, "buffer-child-insert", "", Argument }, + { LFUN_CHILDOPEN, "buffer-child-open", "", + ReadOnly | Argument }, { LFUN_RUNCHKTEX, "buffer-chktex", N_("Check TeX"), ReadOnly }, { LFUN_CLOSEBUFFER, "buffer-close", N_("Close"), ReadOnly }, { LFUN_ENDBUF, "buffer-end", N_("Go to end of document"), ReadOnly }, { LFUN_ENDBUFSEL, "buffer-end-select", N_("Select to end of document"), ReadOnly }, - { LFUN_EXPORT, "buffer-export", N_("Export to"), ReadOnly }, + { LFUN_EXPORT, "buffer-export", N_("Export to"), + ReadOnly | Argument }, { LFUN_IMPORT, "buffer-import", - N_("Import document"), NoBuffer }, + N_("Import document"), NoBuffer | Argument }, { LFUN_BUFFER_PRINT, "buffer-print-xtl", N_("Print"), ReadOnly }, { LFUN_PRINTER_PARAMS_GET, "printer-params-get", @@ -146,14 +150,16 @@ void LyXAction::init() { LFUN_MENURELOAD, "buffer-reload", N_("Revert to saved"), ReadOnly }, { LFUN_SWITCHBUFFER, "buffer-switch", - N_("Switch to an open document"), ReadOnly }, + N_("Switch to an open document"), ReadOnly | Argument }, { LFUN_READ_ONLY_TOGGLE, "buffer-toggle-read-only", N_("Toggle read-only"), ReadOnly }, - { LFUN_UPDATE, "buffer-update", N_("Update"), ReadOnly }, - { LFUN_PREVIEW, "buffer-view", N_("View") , ReadOnly }, + { LFUN_UPDATE, "buffer-update", N_("Update"), + ReadOnly | Argument}, + { LFUN_PREVIEW, "buffer-view", N_("View"), + ReadOnly | Argument }, { LFUN_MENUWRITE, "buffer-write", N_("Save"), ReadOnly }, { LFUN_WRITEAS, "buffer-write-as", N_("Save As"), - ReadOnly }, + ReadOnly | Argument }, { LFUN_CANCEL, "cancel", N_("Cancel"), NoBuffer }, { LFUN_INSET_CAPTION, "caption-insert", "", Noop }, { LFUN_LEFT, "char-backward", N_("Go one char back"), @@ -162,11 +168,11 @@ void LyXAction::init() ReadOnly }, { LFUN_CITATION_CREATE, "citation-insert", N_("Insert citation"), Noop }, - { LFUN_CITATION_INSERT, "", "internal only", Noop }, + { LFUN_CITATION_INSERT, "", "internal only", Argument }, { LFUN_EXEC_COMMAND, "command-execute", "", NoBuffer }, { LFUN_PREFIX, "command-prefix", N_("Execute command"), NoBuffer }, - { LFUN_SEQUENCE, "command-sequence", "", Noop }, + { LFUN_SEQUENCE, "command-sequence", "", Argument }, { LFUN_COPY, "copy", N_("Copy"), ReadOnly }, { LFUN_CUT, "cut", N_("Cut"), Noop }, { LFUN_DATE_INSERT, "date-insert", "", Noop }, @@ -196,16 +202,20 @@ void LyXAction::init() N_("Insert a new external inset"), Noop }, { LFUN_INSET_GRAPHICS, "graphics-insert", N_("Insert Graphics"), Noop }, - { LFUN_FILE_INSERT, "file-insert", "", Noop }, - { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", _("Insert ASCII files as lines"), Noop }, - { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", _("Insert ASCII file as a paragraph"), Noop }, - { LFUN_FILE_NEW, "file-new", "", NoBuffer }, - { LFUN_FILE_OPEN, "file-open", _("Open a file"), NoBuffer }, + { LFUN_FILE_INSERT, "file-insert", "", Argument }, + { LFUN_FILE_INSERT_ASCII, "file-insert-ascii", + N_("Insert ASCII files as lines"), Argument }, + { LFUN_FILE_INSERT_ASCII_PARA, "file-insert-ascii-para", + N_("Insert ASCII file as a paragraph"), Argument }, + { LFUN_FILE_NEW, "file-new", "", NoBuffer | Argument }, + { LFUN_FILE_OPEN, "file-open", N_("Open a file"), + NoBuffer | Argument }, { LFUN_MENUSEARCH, "find-replace", N_("Find & Replace"), ReadOnly }, - { LFUN_INSET_FLOAT, "float-insert", "Insert a Float", Noop }, + { LFUN_INSET_FLOAT, "float-insert", N_("Insert a Float"), + Argument }, { LFUN_INSET_WIDE_FLOAT, "float-wide-insert", - "Insert a wide Float", Noop }, + N_("Insert a wide Float"), Argument }, { LFUN_BOLD, "font-bold", N_("Toggle bold"), Noop }, { LFUN_CODE, "font-code", N_("Toggle code style"), Noop }, { LFUN_DEFAULT, "font-default", N_("Default font style"), @@ -219,7 +229,7 @@ void LyXAction::init() { LFUN_SANS, "font-sans", N_("Toggle sans font style"), Noop }, { LFUN_FRAK, "font-frak", N_("Toggle fraktur font style"), Noop }, { LFUN_ITAL, "font-ital", N_("Toggle italic font style"), Noop }, - { LFUN_FONT_SIZE, "font-size", N_("Set font size"), Noop }, + { LFUN_FONT_SIZE, "font-size", N_("Set font size"), Argument }, { LFUN_FONT_STATE, "font-state", N_("Show font state"), ReadOnly }, { LFUN_UNDERLINE, "font-underline", @@ -231,7 +241,7 @@ void LyXAction::init() { LFUN_HFILL, "hfill-insert", N_("Insert horizontal fill"), Noop }, { LFUN_HELP_OPEN, "help-open", N_("Open a Help file"), - NoBuffer|Argument}, + NoBuffer | Argument }, { LFUN_HTMLURL, "html-insert", "", Noop }, { LFUN_HYPHENATION, "hyphenation-point-insert", N_("Insert hyphenation point"), Noop }, @@ -252,11 +262,11 @@ void LyXAction::init() { LFUN_KMAP_TOGGLE, "keymap-toggle", N_("Toggle keymap"), ReadOnly }, { LFUN_INSERT_LABEL, "label-insert", N_("Insert Label"), - Noop }, - { LFUN_LANGUAGE, "language", N_("Change language"), Noop }, + Argument }, + { LFUN_LANGUAGE, "language", N_("Change language"), Argument }, { LFUN_LATEX_LOG, "latex-view-log", N_("View LaTeX log"), ReadOnly }, - { LFUN_LAYOUT, "layout", "", Noop }, + { LFUN_LAYOUT, "layout", "", Argument }, { LFUN_LAYOUT_CHARACTER, "layout-character", "", Noop }, { LFUN_LAYOUT_COPY, "layout-copy", N_("Copy paragraph environment type"), Noop }, @@ -284,21 +294,22 @@ void LyXAction::init() { LFUN_MARK_OFF, "mark-off", "", ReadOnly }, { LFUN_MARK_ON, "mark-on", "", ReadOnly }, { LFUN_SETMARK, "mark-toggle", "", ReadOnly }, - { LFUN_MATH_DELIM, "math-delim", "", Noop }, - { LFUN_MATH_DISPLAY, "math-display", "", Noop }, - { LFUN_GREEK, "math-greek", N_("Math Greek"), Noop }, + { LFUN_MATH_DELIM, "math-delim", "", Argument }, + { LFUN_MATH_DISPLAY, "math-display", "", Argument }, + { LFUN_GREEK, "math-greek", N_("Math Greek"), Argument }, { LFUN_GREEK_TOGGLE, "math-greek-toggle", "", Noop }, { LFUN_INSERT_MATH, "math-insert", - N_("Insert math symbol"), Noop }, + N_("Insert math symbol"), Argument }, { LFUN_SUBSCRIPT, "math-subscript", "", Noop }, { LFUN_SUPERSCRIPT, "math-superscript", "", Noop }, { LFUN_MATH_LIMITS, "math-limits", "", Noop }, - { LFUN_MATH_MACRO, "math-macro", "", Noop }, + { LFUN_MATH_MACRO, "math-macro", "", Argument }, { LFUN_MATH_MUTATE, "math-mutate", "", Noop }, { LFUN_MATH_SPACE, "math-space", "", Noop }, - { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", "", Noop }, + { LFUN_MATH_IMPORT_SELECTION, "math-import-selection", "", + Argument }, { LFUN_INSERT_MATRIX, "math-matrix", "", Noop }, - { LFUN_MATH_MODE, "math-mode", N_("Math mode"), Noop }, + { LFUN_MATH_MODE, "math-mode", N_("Math mode"), Argument }, { LFUN_MATH_NONUMBER, "math-nonumber", "", Noop }, { LFUN_MATH_NUMBER, "math-number", "", Noop }, { LFUN_MATH_EXTERN, "math-extern", "", Noop }, @@ -310,7 +321,8 @@ void LyXAction::init() { LFUN_MATH_COLUMN_DELETE, "math-column-delete", "", Noop }, { LFUN_MATH_PANEL, "math-panel", "", Noop }, { LFUN_MATH_SIZE, "math-size", "", Noop }, - { LFUN_MENU_OPEN_BY_NAME, "menu-open", "", NoBuffer }, + { LFUN_MENU_OPEN_BY_NAME, "menu-open", "", + NoBuffer | Argument }, { LFUN_MENU_SEPARATOR, "menu-separator-insert", "", Noop }, { LFUN_META_FAKE, "meta-prefix", "", NoBuffer }, { LFUN_INSET_MINIPAGE, "minipage-insert", "", Noop }, @@ -323,13 +335,13 @@ void LyXAction::init() { LFUN_DOWN_PARAGRAPHSEL, "paragraph-down-select", N_("Select next paragraph"), ReadOnly }, { LFUN_GOTO_PARAGRAPH, "paragraph-goto", - N_("Go to paragraph"), ReadOnly }, - { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Noop }, + N_("Go to paragraph"), ReadOnly | Argument }, + { LFUN_PARAGRAPH_SPACING, "paragraph-spacing", "", Argument }, { LFUN_UP_PARAGRAPH, "paragraph-up", N_("Go one paragraph up"), ReadOnly }, { LFUN_UP_PARAGRAPHSEL, "paragraph-up-select", N_("Select previous paragraph"), ReadOnly }, - { LFUN_PARENTINSERT, "parent-insert", "", Noop }, + { LFUN_PARENTINSERT, "parent-insert", "", Argument }, { LFUN_PASTE, "paste", N_("Paste") , Noop }, { LFUN_DIALOG_PREFERENCES, "dialog-preferences", N_("Edit Preferences"), NoBuffer }, @@ -355,16 +367,17 @@ void LyXAction::init() { LFUN_PRIORSEL, "screen-up-select", "", ReadOnly }, { LFUN_SCROLL_INSET, "inset-scroll", N_("Scroll inset"), ReadOnly }, - { LFUN_SELFINSERT, "self-insert", "", Noop }, + { LFUN_SELFINSERT, "self-insert", "", Argument }, { LFUN_CHARATCURSOR, "server-char-after", "", ReadOnly }, { LFUN_GETFONT, "server-get-font", "", ReadOnly }, { LFUN_GETLAYOUT, "server-get-layout", "", ReadOnly }, { LFUN_GETNAME, "server-get-name", "", ReadOnly }, - { LFUN_GETTIP, "server-get-tip", "", ReadOnly }, + { LFUN_GETTIP, "server-get-tip", "", ReadOnly | Argument }, { LFUN_GETXY, "server-get-xy", "", ReadOnly }, - { LFUN_GOTOFILEROW, "server-goto-file-row", "", Noop }, + { LFUN_GOTOFILEROW, "server-goto-file-row", "", + Noop | Argument}, { LFUN_NOTIFY, "server-notify", "", ReadOnly }, - { LFUN_SETXY, "server-set-xy", "", ReadOnly }, + { LFUN_SETXY, "server-set-xy", "", ReadOnly | Argument }, { LFUN_SET_COLOR, "set-color", "", ReadOnly|NoBuffer }, { LFUN_SPELLCHECK, "spellchecker", "", Noop }, { LFUN_SHIFT_TAB, "tab-backward", "", Noop }, @@ -387,13 +400,14 @@ void LyXAction::init() { LFUN_TOGGLECURSORFOLLOW, "toggle-cursor-follows-scrollbar", N_("Toggle cursor does/doesn't follow the scrollbar"), ReadOnly }, - { LFUN_ADD_TO_TOOLBAR, "toolbar-add-to", "", NoBuffer }, - { LFUN_PUSH_TOOLBAR, "toolbar-push", "", NoBuffer }, + { LFUN_ADD_TO_TOOLBAR, "toolbar-add-to", "", + NoBuffer | Argument }, + { LFUN_PUSH_TOOLBAR, "toolbar-push", "", NoBuffer | Argument }, { LFUN_UNDO, "undo", N_("Undo"), Noop }, { LFUN_UP, "up", "", ReadOnly }, { LFUN_UPSEL, "up-select", "", ReadOnly }, { LFUN_URL, "url-insert", "", Noop }, - { LFUN_INSERT_URL, "", "internal only", Noop }, + { LFUN_INSERT_URL, "", "internal only", Argument }, { LFUN_VC_CHECKIN, "vc-check-in", "", ReadOnly }, { LFUN_VC_CHECKOUT, "vc-check-out", "", ReadOnly }, { LFUN_VC_HISTORY, "vc-history", "", ReadOnly }, @@ -414,15 +428,16 @@ void LyXAction::init() { LFUN_LOWCASE_WORD, "word-lowcase", "", Noop }, { LFUN_UPCASE_WORD, "word-upcase", "", Noop }, { LFUN_MESSAGE, "message", - N_("Show message in minibuffer"), NoBuffer }, + N_("Show message in minibuffer"), NoBuffer | Argument }, { LFUN_MESSAGE_PUSH, "message-push", N_("Push old message and show this one in minibuffer"), - NoBuffer }, + NoBuffer | Argument }, { LFUN_MESSAGE_POP, "message-pop", N_("Pop old message and show it in the minibuffer"), NoBuffer }, { LFUN_TRANSPOSE_CHARS, "chars-transpose", "", Noop }, - { LFUN_FLOAT_LIST, "float-list", "Insert a float list", Noop }, + { LFUN_FLOAT_LIST, "float-list", N_("Insert a float list"), + Argument }, { LFUN_ESCAPE, "escape", "", Noop }, { LFUN_HELP_ABOUTLYX, "help-aboutlyx", N_("Display information about LyX"), NoBuffer }, @@ -431,7 +446,8 @@ void LyXAction::init() { LFUN_FORKS_SHOW, "show-forks", N_("Show the processes forked by LyX"), NoBuffer }, { LFUN_FORKS_KILL, "kill-forks", - N_("Kill the forked process with this PID"), NoBuffer }, + N_("Kill the forked process with this PID"), + NoBuffer | Argument }, { LFUN_TOOLTIPS_TOGGLE, "toggle-tooltips", "", NoBuffer }, { LFUN_NOACTION, "", "", Noop } }; Index: src/lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.318 diff -u -p -r1.318 lyxfunc.C --- src/lyxfunc.C 29 May 2002 16:20:57 -0000 1.318 +++ src/lyxfunc.C 29 May 2002 19:24:01 -0000 @@ -384,6 +384,7 @@ FuncStatus LyXFunc::getStatus(kb_action } } + UpdatableInset * tli = owner->view()->theLockingInset(); // I would really like to avoid having this switch and rather try to @@ -880,6 +881,23 @@ string const LyXFunc::dispatch(kb_action goto exit_with_message; } + // Check whether we need an argument + if (lyxaction.funcHasFlag(action, LyXAction::Argument)) { + // Yes we need an argumet, do we have one? + if (argument.empty()) { + // No. + ostringstream msg; + msg << _("LyX function") + << " '" + << lyxaction.getActionName(action) + << "' " + << _("needs an argument."); + + setErrorMessage(msg.str().c_str()); + goto exit_with_message; + } + } + if (owner->view()->available() && owner->view()->theLockingInset()) { UpdatableInset::RESULT result; if ((action > 1) || ((action == LFUN_UNKNOWN_ACTION) && @@ -1260,10 +1278,14 @@ string const LyXFunc::dispatch(kb_action case LFUN_HELP_OPEN: { string const arg = argument; + +#if 0 if (arg.empty()) { setErrorMessage(N_("Missing argument")); break; } +#endif + owner->prohibitInput(); string const fname = i18nLibFileSearch("doc", arg, "lyx"); if (fname.empty()) { @@ -1491,12 +1513,16 @@ string const LyXFunc::dispatch(kb_action string tmp(argument); //lyxerr <<string("Argument: ") + argument); //lyxerr <<string("Tmp : ") + tmp); +#if 0 if (tmp.empty()) { setErrorMessage(N_("Usage: toolbar-add-to <LyX command>")); } else { +#endif owner->getToolbar()->add(argument, false); owner->getToolbar()->set(); +#if 0 } +#endif } break;
-- Lgb