X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfunc.C;h=5c6eece450d21a820e797518a324d35a5c30c503;hb=0031da054f072922ed081bc8a877ffd8eb280210;hp=b5fed2e3a4c1f9070710fbb8bf304102fb6b2a07;hpb=61a3cac30d5bc1987c84c0b3200a8c5839d92fe3;p=features.git diff --git a/src/lyxfunc.C b/src/lyxfunc.C index b5fed2e3a4..5c6eece450 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -10,12 +10,7 @@ #include -#ifdef HAVE_SSTREAM -#include -using std::istringstream; -#else -#include -#endif +#include "Lsstream.h" #include #include @@ -86,12 +81,9 @@ using std::istringstream; #include "bufferview_funcs.h" #include "frontends/Dialogs.h" #include "frontends/Toolbar.h" -#ifdef NEW_MENUBAR #include "frontends/Menubar.h" -#else -#include "menus.h" -#endif #include "FloatList.h" +#include "exporter.h" #include "FontLoader.h" #include "TextCache.h" @@ -101,7 +93,7 @@ using std::endl; extern bool cursor_follows_scrollbar; extern void InsertAsciiFile(BufferView *, string const &, bool); -extern void math_insert_symbol(char const *); +extern void math_insert_symbol(string const &); extern bool math_insert_greek(char); extern BufferList bufferlist; extern LyXServer * lyxserver; @@ -115,12 +107,16 @@ extern bool MenuWriteAs(Buffer *); extern int MenuRunLaTeX(Buffer *); extern int MenuBuildProg(Buffer *); extern int MenuRunChktex(Buffer *); +#ifndef NEW_EXPORT extern bool CreatePostscript(Buffer *, bool); +#endif extern void MenuPrint(Buffer *); extern void MenuSendto(); extern void QuitLyX(); extern void MenuFax(Buffer *); +#ifndef NEW_EXPORT extern void MenuExport(Buffer *, string const &); +#endif extern void show_symbols_form(LyXFunc *); extern LyXAction lyxaction; @@ -128,9 +124,11 @@ extern LyXAction lyxaction; extern tex_accent_struct get_accent(kb_action action); extern void AutoSave(BufferView *); +#ifndef NEW_EXPORT extern bool PreviewDVI(Buffer *); extern bool PreviewPostscript(Buffer *); -extern void MenuInsertLabel(char const *); +#endif +extern void MenuInsertLabel(string const &); extern void MenuLayoutCharacter(); extern void MenuLayoutParagraph(); extern void MenuLayoutDocument(); @@ -262,10 +260,6 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) lyxerr << "Key [" << action << "][" << buf << "]" -#if 0 - << "[" - << num_bytes << "]" -#endif << endl; } @@ -301,15 +295,10 @@ int LyXFunc::processKeySym(KeySym keysym, unsigned int state) return 0; } } -#if 0 - else - if (action == LFUN_SELFINSERT) { - argument = s_r[0]; - } -#endif + bool tmp_sc = show_sc; show_sc = false; - Dispatch(action, argument.c_str()); + Dispatch(action, argument); show_sc = tmp_sc; return 0; @@ -443,7 +432,7 @@ int LyXFunc::processKeyEvent(XEvent * ev) bool tmp_sc = show_sc; show_sc = false; - Dispatch(action, argument.c_str()); + Dispatch(action, argument); show_sc = tmp_sc; return 0; @@ -495,6 +484,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const static bool noLaTeX = lyxrc.latex_command == "none"; bool disable = false; switch (action) { +#ifndef NEW_EXPORT case LFUN_PREVIEW: disable = noLaTeX || lyxrc.view_dvi_command == "none"; break; @@ -505,6 +495,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const case LFUN_RUNDVIPS: disable = noLaTeX; break; +#endif case LFUN_MENUPRINT: disable = noLaTeX || lyxrc.print_command == "none"; break; @@ -517,6 +508,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const else if (argument == "linuxdoc") disable = lyxrc.linuxdoc_to_lyx_command == "none"; break; +#ifndef NEW_EXPORT case LFUN_EXPORT: if (argument == "latex") disable = (! buf->isLatex() && ! buf->isLiterate()) ; @@ -536,6 +528,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const else if (argument == "custom") disable = (! buf->isLatex() && ! buf->isLiterate()); break; +#endif case LFUN_UNDO: disable = buf->undostack.empty(); break; @@ -581,6 +574,7 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const getStatus(argument); } flag |= ret; + disable = false; } else { static InsetTabular inset(owner->buffer(), 1, 1); func_status ret; @@ -607,6 +601,9 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const case LFUN_VC_HISTORY: disable = !buf->lyxvc.inUse(); break; + case LFUN_REF_BACK: + disable = owner->view()->NoSavedPositions(); + break; default: break; } @@ -650,18 +647,19 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const } -string LyXFunc::Dispatch(string const & s) +string const LyXFunc::Dispatch(string const & s) { // Split command string into command and argument - string cmd, line = frontStrip(s); + string cmd; + string line = frontStrip(s); string arg = strip(frontStrip(split(line, cmd, ' '))); - return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg.c_str()); + return Dispatch(lyxaction.LookupFunc(cmd.c_str()), arg); } -string LyXFunc::Dispatch(int ac, - char const * do_not_use_this_arg) +string const LyXFunc::Dispatch(int ac, + string const & do_not_use_this_arg) { string argument; kb_action action; @@ -679,7 +677,7 @@ string LyXFunc::Dispatch(int ac, argument = tmparg; } else { action = static_cast(ac); - if (do_not_use_this_arg) + if (!do_not_use_this_arg.empty()) argument = do_not_use_this_arg; // except here } @@ -971,6 +969,15 @@ string LyXFunc::Dispatch(int ac, reloadBuffer(); break; +#ifdef NEW_EXPORT + case LFUN_UPDATE: + Exporter::Export(owner->buffer(), argument, true); + break; + + case LFUN_PREVIEW: + Exporter::Preview(owner->buffer(), argument); + break; +#else case LFUN_PREVIEW: PreviewDVI(owner->buffer()); break; @@ -982,6 +989,11 @@ string LyXFunc::Dispatch(int ac, case LFUN_RUNLATEX: MenuRunLaTeX(owner->buffer()); break; + + case LFUN_RUNDVIPS: + CreatePostscript(owner->buffer(), false); + break; +#endif case LFUN_BUILDPROG: MenuBuildProg(owner->buffer()); @@ -990,11 +1002,7 @@ string LyXFunc::Dispatch(int ac, case LFUN_RUNCHKTEX: MenuRunChktex(owner->buffer()); break; - - case LFUN_RUNDVIPS: - CreatePostscript(owner->buffer(), false); - break; - + case LFUN_MENUPRINT: owner->getDialogs()->showPrint(); break; @@ -1004,7 +1012,11 @@ string LyXFunc::Dispatch(int ac, break; case LFUN_EXPORT: +#ifdef NEW_EXPORT + Exporter::Export(owner->buffer(), argument, false); +#else MenuExport(owner->buffer(), argument); +#endif break; case LFUN_IMPORT: @@ -1057,7 +1069,7 @@ string LyXFunc::Dispatch(int ac, break; } - case LFUN_TABLE: + case LFUN_DIALOG_TABULAR_INSERT: #ifndef NEW_TABULAR Table(); #else @@ -1377,7 +1389,7 @@ string LyXFunc::Dispatch(int ac, Dispatch(int(LFUN_LAYOUT), textclasslist.NameOfLayout(owner->view() ->buffer()->params.textclass, - sel).c_str()); + sel)); return string(); } @@ -1565,26 +1577,22 @@ string LyXFunc::Dispatch(int ac, MenuInsertLabel(argument.c_str()); break; - case LFUN_REF_CREATE: - { - InsetCommandParams p( "ref" ); - owner->getDialogs()->createRef( p.getAsString() ); - } - break; - case LFUN_REF_INSERT: - { - InsetCommandParams p; - p.setFromString( argument ); + if (argument.empty()) { + InsetCommandParams p("ref"); + owner->getDialogs()->createRef(p.getAsString()); + } else { + InsetCommandParams p; + p.setFromString(argument); + + InsetRef * inset = new InsetRef(p); + if (!owner->view()->insertInset(inset)) + delete inset; + else + owner->view()->updateInset(inset, true); + } + break; - InsetRef * inset = new InsetRef( p ); - if (!owner->view()->insertInset(inset)) - delete inset; - else - owner->view()->updateInset( inset, true ); - } - break; - case LFUN_REF_BACK: { owner->view()->restorePosition(); @@ -1612,11 +1620,7 @@ string LyXFunc::Dispatch(int ac, break; case LFUN_MENU_OPEN_BY_NAME: -#ifdef NEW_MENUBAR owner->getMenubar()->openByName(argument); -#else - owner->getMenus()->openByName(argument); -#endif break; // RVDK_PATCH_5 case LFUN_SPELLCHECK: @@ -2214,11 +2218,8 @@ string LyXFunc::Dispatch(int ac, cur_value = par->spacing.getValue(); } -#ifdef HAVE_SSTREAM istringstream istr(argument); -#else - istrstream istr(argument.c_str()); -#endif + string tmp; istr >> tmp; Spacing::Space new_spacing = cur_spacing; @@ -2514,6 +2515,24 @@ string LyXFunc::Dispatch(int ac, } break; + case LFUN_GOTO_PARAGRAPH: + { + istringstream istr(argument); + + int id; + istr >> id; + LyXParagraph * par = owner->view()->text->GetParFromID(id); + + // Set the cursor + owner->view()->text->SetCursor(owner->view(), par, 0); + owner->view()->setState(); + owner->showState(); + + // Recenter screen + owner->view()->center(); + } + break; + case LFUN_APROPOS: case LFUN_GETTIP: { @@ -3188,12 +3207,13 @@ void LyXFunc::MenuNew(bool fromTemplate) } } } else { - s = lyxrc.document_path + "newfile" + tostr(++newfile_number); + s = AddPath(lyxrc.document_path, + "newfile" + tostr(++newfile_number)); FileInfo fi(s); while (bufferlist.exists(s) || fi.readable()) { ++newfile_number; - s = lyxrc.document_path + "newfile" + - tostr(newfile_number); + s = AddPath(lyxrc.document_path, + "newfile" + tostr(newfile_number)); fi.newFile(s); } }