#include "BufferView.h"
#include "ColorHandler.h"
#include "lyxserver.h"
-#include "figure_form.h"
#include "intl.h"
#include "lyx_main.h"
#include "lyx_cb.h"
#include "mathed/formulamacro.h"
#include "mathed/math_cursor.h"
#include "mathed/math_inset.h"
-#include "spellchecker.h"
#include "minibuffer.h"
#include "vspace.h"
#include "LyXView.h"
#include "FontLoader.h"
#include "TextCache.h"
#include "lyxfind.h"
+#include "undo_funcs.h"
using std::pair;
using std::make_pair;
bool tmp_sc = show_sc;
show_sc = false;
- Dispatch(action, argument);
+ dispatch(action, argument);
show_sc = tmp_sc;
//return 0;
case LFUN_BOOKMARK_GOTO:
disable = !owner->view()->
isSavedPosition(strToUnsignedInt(argument));
+
case LFUN_MATH_VALIGN: {
- Inset * tli = owner->view()->theLockingInset();
- if (tli && (tli->lyxCode() == Inset::MATH_CODE
- || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
+ // I think this test can be simplified (Andre')
+ // mathcursor is != 0 iff we are in math mode
+ //Inset * tli = owner->view()->theLockingInset();
+ //if (tli && (tli->lyxCode() == Inset::MATH_CODE
+ // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
+ //
+ if (mathcursor) {
char align = mathcursor->valign();
if (align == '\0') {
disable = true;
break;
}
case LFUN_MATH_HALIGN: {
- Inset * tli = owner->view()->theLockingInset();
- if (tli && (tli->lyxCode() == Inset::MATH_CODE
- || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
+ //Inset * tli = owner->view()->theLockingInset();
+ //if (tli && (tli->lyxCode() == Inset::MATH_CODE
+ // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
+ if (mathcursor) {
char align = mathcursor->halign();
if (align == '\0') {
disable = true;
disable = true;
break;
}
+
+ // we just need to be in math mode to enable that
+ case LFUN_MATH_SIZE:
+ case LFUN_MATH_LIMITS:
+ case LFUN_MATH_NONUMBER:
+ case LFUN_MATH_NUMBER:
+ disable = !mathcursor;
+ break;
+
+ // we need to be math mode and a math array for that
+ // Hack: halign produces non-zero result iff we are in a math array
+ case LFUN_MATH_ROW_INSERT:
+ case LFUN_MATH_ROW_DELETE:
+ case LFUN_MATH_COLUMN_INSERT:
+ case LFUN_MATH_COLUMN_DELETE:
+ disable = !mathcursor || !mathcursor->halign();
+ break;
+
default:
break;
}
void LyXFunc::miniDispatch(string const & s)
{
if (!s.empty()) {
- Dispatch(s);
+ dispatch(s);
}
}
-string const LyXFunc::Dispatch(string const & s)
+string const LyXFunc::dispatch(string const & s)
{
// Split command string into command and argument
string cmd;
string line = frontStrip(s);
string const arg = strip(frontStrip(split(line, cmd, ' ')));
- return Dispatch(lyxaction.LookupFunc(cmd), arg);
+ return dispatch(lyxaction.LookupFunc(cmd), arg);
}
-string const LyXFunc::Dispatch(int ac,
+string const LyXFunc::dispatch(int ac,
string const & do_not_use_this_arg)
{
lyxerr[Debug::ACTION] << "LyXFunc::Dispatch: action[" << ac
argument = keyseq.getiso();
}
// Undo/Redo is a bit tricky for insets.
- if (action == LFUN_UNDO) {
+ if (action == LFUN_UNDO) {
+#ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
int slx;
int sly;
UpdatableInset * inset =
- owner->view()->theLockingInset();
+ owner->view()->theLockingInset()->getLockingInset();
+ int inset_id = inset->id();
inset->getCursorPos(owner->view(), slx, sly);
owner->view()->unlockInset(inset);
+#else
+ owner->view()->unlockInset(owner->view()->theLockingInset());
+#endif
owner->view()->menuUndo();
+#ifdef RETHINK_THIS_FOR_NOW_WE_LEAVE_ALL_UNLOCKED
+#if 0
if (TEXT()->cursor.par()->
isInset(TEXT()->cursor.pos())) {
inset = static_cast<UpdatableInset*>(
} else {
inset = 0;
}
+#else
+ inset = static_cast<UpdatableInset *>(owner->view()->buffer()->getInsetFromID(inset_id));
+#endif
if (inset)
inset->edit(owner->view(),slx,sly,0);
+#endif
return string();
} else if (action == LFUN_REDO) {
int slx;
// Move cursor so that successive C-s 's will not stand in place.
if (action == LFUN_WORDFINDFORWARD )
TEXT()->cursorRightOneWord(owner->view());
- TEXT()->finishUndo();
+ finishUndo();
moveCursorUpdate(true, false);
// ??? Needed ???
meta_fake_bit = 0;
if (owner->view()->available())
// cancel any selection
- Dispatch(LFUN_MARK_OFF);
+ dispatch(LFUN_MARK_OFF);
setMessage(N_("Cancel"));
break;
// --- Menus -----------------------------------------------
case LFUN_MENUNEW:
- MenuNew(false);
+ menuNew(false);
break;
case LFUN_MENUNEWTMPLT:
- MenuNew(true);
+ menuNew(true);
break;
case LFUN_CLOSEBUFFER:
- CloseBuffer();
+ closeBuffer();
break;
case LFUN_MENUWRITE:
#warning Find another implementation here (or another lyxfunc)!
#endif
#endif
- case LFUN_HELP_COPYRIGHT:
- owner->getDialogs()->showCopyright();
+ case LFUN_HELP_ABOUTLYX:
+ owner->getDialogs()->showAboutlyx();
break;
+ case LFUN_HELP_COPYRIGHT:
case LFUN_HELP_CREDITS:
- owner->getDialogs()->showCredits();
- break;
+
case LFUN_HELP_OPEN:
{
setErrorMessage(N_("Missing argument"));
break;
}
- ProhibitInput(owner->view());
+ owner->prohibitInput();
string const fname = i18nLibFileSearch("doc", arg, "lyx");
if (fname.empty()) {
lyxerr << "LyX: unable to find documentation file `"
<< arg << "'. Bad installation?" << endl;
- AllowInput(owner->view());
+ owner->allowInput();
break;
}
ostringstream str;
str << _("Opening help file") << ' '
<< MakeDisplayPath(fname) << "...";
owner->message(str.str().c_str());
- owner->view()->buffer(bufferlist.loadLyXFile(fname,false));
- AllowInput(owner->view());
+ owner->view()->buffer(bufferlist.loadLyXFile(fname, false));
+ owner->allowInput();
break;
}
- case LFUN_HELP_VERSION: {
- ProhibitInput(owner->view());
- string msg(_("LyX Version "));
- msg += LYX_VERSION;
- msg += " of ";
- msg += LYX_RELEASE;
- fl_show_message(msg.c_str(),
- (_("Library directory: ")
- + MakeDisplayPath(system_lyxdir)).c_str(),
- (_("User directory: ")
- + MakeDisplayPath(user_lyxdir)).c_str());
- AllowInput(owner->view());
- break;
- }
+ case LFUN_HELP_VERSION:
// --- version control -------------------------------
case LFUN_VC_REGISTER:
break;
case LFUN_FILE_OPEN:
- Open(argument);
+ open(argument);
break;
case LFUN_LATEX_LOG:
--sel; // sel 1..., but layout 0...
// Pretend we got the name instead.
- Dispatch(int(LFUN_LAYOUT),
+ dispatch(int(LFUN_LAYOUT),
textclasslist.NameOfLayout(owner->view()
->buffer()->params.textclass,
sel));
case LFUN_SPELLCHECK:
if (lyxrc.isp_command != "none")
- ShowSpellChecker(owner->view());
- break; // RVDK_PATCH_5
+ owner->getDialogs()->showSpellchecker();
+ break;
// --- lyxserver commands ----------------------------
#else
string file_name;
int row;
- istringstream istr(argument);
- istr >> filename >> row;
+ istringstream istr(argument.c_str());
+ istr >> file_name >> row;
#endif
// Must replace extension of the file to be .lyx and get full path
string const s(ChangeExtension(file_name, ".lyx"));
case LFUN_GOTO_PARAGRAPH:
{
- istringstream istr(argument);
+ istringstream istr(argument.c_str());
int id;
istr >> id;
- Paragraph * par = TEXT()->getParFromID(id);
+ Paragraph * par = owner->buffer()->getParFromID(id);
if (par == 0) {
lyxerr[Debug::INFO] << "No matching paragraph found! ["
<< id << "]" << std::endl;
} else {
p.setContents( argument );
}
- Dispatch(LFUN_CITATION_INSERT, p.getAsString());
+ dispatch(LFUN_CITATION_INSERT, p.getAsString());
} else
owner->getDialogs()->createCitation( p.getAsString() );
}
while (argument.find(';') != string::npos) {
string first;
argument = split(argument, first, ';');
- Dispatch(first);
+ dispatch(first);
}
}
break;
// Then if it was none of the above
if (!owner->view()->Dispatch(action, argument))
lyxerr << "A truly unknown func ["
- << action << "]!" << endl;
+ << lyxaction.getActionName(action) << "]!"
+ << endl;
break;
} // end of switch
}
-void LyXFunc::MenuNew(bool fromTemplate)
+void LyXFunc::menuNew(bool fromTemplate)
{
string initpath = lyxrc.document_path;
}
-void LyXFunc::Open(string const & fname)
+void LyXFunc::open(string const & fname)
{
string initpath = lyxrc.document_path;
}
-void LyXFunc::CloseBuffer()
+void LyXFunc::closeBuffer()
{
if (bufferlist.close(owner->buffer()) && !quitting) {
if (bufferlist.empty()) {