From 90ef01a0ed13693d2d62cf2248fe5d0969e829da Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 18 Nov 1999 14:12:19 +0000 Subject: [PATCH] The command-sequence patch from Andre'; also remove the comment in first line of .lyx files. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@325 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 4 ++++ src/LyXAction.C | 1 + src/buffer.C | 34 ++++++++++++++++++++++++---------- src/commandtags.h | 1 + src/lyxfunc.C | 20 +++++++++++++++++--- src/lyxfunc.h | 3 +-- src/lyxserver.C | 2 +- src/minibuffer.C | 16 +--------------- 8 files changed, 50 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfea2b2759..5e375fc4c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 1999-11-18 Jean-Marc Lasgouttes + * src/buffer.C (writeFile): Do not add a comment on top of .lyx + file saying who created them and when this heppened; this is + useless and annoys tools like cvs. + * lib/layouts/g-brief-{en,de}.layout, lib/templates/g-brief-{en,de}.lyx: new versions of the textclass from Thomas Hartkens . diff --git a/src/LyXAction.C b/src/LyXAction.C index 55b26fde65..acb0edea97 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -112,6 +112,7 @@ kb_func_table const lyx_func_table[] = { { "citation-insert", LFUN_INSERT_CITATION }, { "command-execute", LFUN_EXEC_COMMAND }, { "command-prefix", LFUN_PREFIX }, + { "command-sequence", LFUN_SEQUENCE }, { "copy", LFUN_COPY }, { "cut", LFUN_CUT }, { "delete-backward", LFUN_BACKSPACE }, diff --git a/src/buffer.C b/src/buffer.C index a252465a3d..2cb09c254d 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1201,11 +1201,14 @@ bool Buffer::writeFile(string const & filename, bool flag) string userName(getUserName()) ; // write out a comment in the top of the file +// We do not print this anymore, since it annoys cvs and is useless +// anyway. It could even be seen as including private +// information without telling the user :) -- JMarc +// fprintf(file, +// "#This file was created by <%s> %s", +// userName.c_str(),(char*)date()); fprintf(file, - "#This file was created by <%s> %s", - userName.c_str(),(char*)date()); - fprintf(file, - "#LyX 1.0 (C) 1995-1999 Matthias Ettrich" + "#LyX 1.1 (C) 1995-1999 Matthias Ettrich" " and the LyX Team\n"); // at the very beginning the used lyx format @@ -1946,27 +1949,38 @@ void Buffer::makeLaTeXFile(string const & filename, // Itemize bullet settings need to be last in case the user // defines their own bullets that use a package included // in the user-defined preamble -- ARRae + // Actually it has to be done much later than that + // since some packages like frenchb make modifications + // at \begin{document} time -- JMarc + string bullets_def; for (int i = 0; i < 4; ++i) { if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) { - preamble += "\\renewcommand\\labelitemi"; + if (bullets_def.empty()) + bullets_def="\\AtBeginDocument{\n"; + bullets_def += " \\renewcommand{\\labelitemi"; switch (i) { - // `i' is one less than the item to modify + // `i' is one less than the item to modify case 0: break; case 1: - preamble += 'i'; + bullets_def += 'i'; break; case 2: - preamble += "ii"; + bullets_def += "ii"; break; case 3: - preamble += 'v'; + bullets_def += 'v'; break; } - preamble += "[0]{" + params.user_defined_bullets[i].getText() + "}\n"; + bullets_def += "}{" + + params.user_defined_bullets[i].getText() + + "}\n"; } } + if (!bullets_def.empty()) + preamble += bullets_def + "}\n\n"; + for (int j = countChar(preamble, '\n'); j-- ;) { texrow.newline(); } diff --git a/src/commandtags.h b/src/commandtags.h index 9348ca137f..cba72f8dc0 100644 --- a/src/commandtags.h +++ b/src/commandtags.h @@ -240,6 +240,7 @@ enum kb_action { LFUN_APPENDIX, // ettrich 980505 LFUN_IMPORT, // Asger 980724 LFUN_MENU_SEPARATOR, // Asger 990220 + LFUN_SEQUENCE, // Andre' 991111 LFUN_LASTACTION /* this marks the end of the table */ }; diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 4a9debb279..a5b8cfa3e6 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -311,10 +311,13 @@ int LyXFunc::processKeyEvent(XEvent *ev) } -string LyXFunc::Dispatch(string const &cmd, string const &arg) +string LyXFunc::Dispatch(string const& s) { - return Dispatch(lyxaction.LookupFunc(cmd.c_str()), - arg.c_str()); + // Split command string into command and argument + string cmd, line = frontStrip(s); + string arg = strip(frontStrip(split(line, cmd, ' '))); + + return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str()); } @@ -2364,6 +2367,17 @@ string LyXFunc::Dispatch(int ac, } break; + case LFUN_SEQUENCE: + { + // argument contains ';'-terminated commands + while (argument.find(';') != string::npos) { + string first; + argument = split(argument, first, ';'); + Dispatch(first); + } + } + break; + case LFUN_UNKNOWN_ACTION: { if (owner->buffer()->isReadonly()) { diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 5228fda027..c5fd86a6c1 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -31,9 +31,8 @@ public: string Dispatch(int action, char const* arg = 0); /// The same but uses the name of a lyx command. - string Dispatch(string const &cmd, string const &arg = string()); + string Dispatch(string const &cmd); - /// A keyboard event is processed to execute a lyx action. int processKeyEvent(XEvent *ev); diff --git a/src/lyxserver.C b/src/lyxserver.C index d6c217529d..6e00f3d657 100644 --- a/src/lyxserver.C +++ b/src/lyxserver.C @@ -525,7 +525,7 @@ void LyXServer::callback(LyXServer * serv, string const & msg) string rval, buf; if (action>= 0) { - rval = serv->func->Dispatch(action, arg.c_str()); + rval = serv->func->Dispatch(cmd); } else { rval = "Unknown command"; } diff --git a/src/minibuffer.C b/src/minibuffer.C index eea98c940c..a674f6d37d 100644 --- a/src/minibuffer.C +++ b/src/minibuffer.C @@ -54,22 +54,8 @@ void MiniBuffer::ExecutingCB(FL_OBJECT * ob, long) obj->Set(_("Executing:"), obj->cur_cmd); obj->addHistory(obj->cur_cmd); - // Split command into function and argument - string arg = obj->cur_cmd; - string function; - if (contains(arg, " ")) { - arg = split(arg, function, ' '); - function = strip(function); - } else { - function = arg; - arg.clear(); - } - lyxerr.debug() << "Function: " << function - << "\nArg : " << arg << endl; - // Dispatch only returns requested data for a few commands (ale) - string res = obj->owner->getLyXFunc()->Dispatch(function.c_str(), - arg.c_str()); + string res = obj->owner->getLyXFunc()->Dispatch(obj->cur_cmd); lyxerr.debug() << "Minibuffer Res: " << res << endl; obj->shows_no_match = false; -- 2.39.2