#include <config.h>
-#ifdef HAVE_SSTREAM
-#include <sstream>
-using std::istringstream;
-#else
-#include <strstream>
-#endif
+#include "Lsstream.h"
#include <time.h>
#include <locale.h>
#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"
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;
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;
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();
lyxerr << "Key ["
<< action << "]["
<< buf << "]"
-#if 0
- << "["
- << num_bytes << "]"
-#endif
<< endl;
}
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;
}
-#if FL_REVISION < 89
+#if 0
int LyXFunc::processKeyEvent(XEvent * ev)
{
char s_r[10];
bool tmp_sc = show_sc;
show_sc = false;
- Dispatch(action, argument.c_str());
+ Dispatch(action, argument);
show_sc = tmp_sc;
return 0;
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;
case LFUN_RUNDVIPS:
disable = noLaTeX;
break;
+#endif
case LFUN_MENUPRINT:
disable = noLaTeX || lyxrc.print_command == "none";
break;
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()) ;
else if (argument == "custom")
disable = (! buf->isLatex() && ! buf->isLiterate());
break;
+#endif
case LFUN_UNDO:
disable = buf->undostack.empty();
break;
case LFUN_TABULAR_FEATURE:
disable = true;
if (owner->view()->the_locking_inset) {
- int ret = 0;
+ func_status ret = LyXFunc::Disabled;
if (owner->view()->the_locking_inset->LyxCode() == Inset::TABULAR_CODE) {
ret = static_cast<InsetTabular *>
(owner->view()->the_locking_inset)->
GetFirstLockingInsetOfType(Inset::TABULAR_CODE))->
getStatus(argument);
}
- switch(ret) {
- case 0:
- break;
- case 1:
- disable = false;
- break;
- case 2:
- disable = false;
- flag |= LyXFunc::ToggleOn;
- break;
- case 3:
- disable = false;
- flag |= LyXFunc::ToggleOff;
- break;
- }
+ flag |= ret;
+ disable = false;
+ } else {
+ static InsetTabular inset(owner->buffer(), 1, 1);
+ func_status ret;
+
+ disable = true;
+ ret = inset.getStatus(argument);
+ if ((ret & LyXFunc::ToggleOn) ||
+ (ret & LyXFunc::ToggleOff))
+ flag |= LyXFunc::ToggleOff;
}
break;
case LFUN_VC_HISTORY:
disable = !buf->lyxvc.inUse();
break;
+ case LFUN_REF_BACK:
+ disable = owner->view()->NoSavedPositions();
+ break;
default:
break;
}
if (buf) {
func_status box = LyXFunc::ToggleOff;
- LyXFont font = owner->view()->text->real_current_font;
+ LyXFont font;
+ if (owner->view()->the_locking_inset &&
+ owner->view()->the_locking_inset->getLyXText(owner->view()))
+ font = owner->view()->the_locking_inset->
+ getLyXText(owner->view())->real_current_font;
+ else
+ font = owner->view()->text->real_current_font;
switch (action) {
case LFUN_EMPH:
if (font.emph() == LyXFont::ON)
}
-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;
argument = tmparg;
} else {
action = static_cast<kb_action>(ac);
- if (do_not_use_this_arg)
+ if (!do_not_use_this_arg.empty())
argument = do_not_use_this_arg; // except here
}
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;
case LFUN_RUNLATEX:
MenuRunLaTeX(owner->buffer());
break;
+
+ case LFUN_RUNDVIPS:
+ CreatePostscript(owner->buffer(), false);
+ break;
+#endif
case LFUN_BUILDPROG:
MenuBuildProg(owner->buffer());
case LFUN_RUNCHKTEX:
MenuRunChktex(owner->buffer());
break;
-
- case LFUN_RUNDVIPS:
- CreatePostscript(owner->buffer(), false);
- break;
-
+
case LFUN_MENUPRINT:
owner->getDialogs()->showPrint();
break;
break;
case LFUN_EXPORT:
+#ifdef NEW_EXPORT
+ Exporter::Export(owner->buffer(), argument, false);
+#else
MenuExport(owner->buffer(), argument);
+#endif
break;
case LFUN_IMPORT:
break;
}
- case LFUN_TABLE:
+ case LFUN_DIALOG_TABULAR_INSERT:
#ifndef NEW_TABULAR
Table();
#else
Dispatch(int(LFUN_LAYOUT),
textclasslist.NameOfLayout(owner->view()
->buffer()->params.textclass,
- sel).c_str());
+ sel));
return string();
}
break;
case LFUN_LAYOUT_DOCUMENT:
-#ifdef USE_OLD_LAYOUT
+#ifdef USE_OLD_DOCUMENT_LAYOUT
MenuLayoutDocument();
#else
owner->getDialogs()->showLayoutDocument();
break;
case LFUN_LAYOUT_PAPER:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
MenuLayoutPaper();
+#endif
break;
case LFUN_LAYOUT_QUOTES:
+#ifdef USE_OLD_DOCUMENT_LAYOUT
MenuLayoutQuotes();
+#endif
break;
case LFUN_LAYOUT_PREAMBLE:
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();
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:
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;
}
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:
{
}
}
} 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);
}
}