#include "Lsstream.h"
#include "trans_mgr.h"
#include "layout.h"
-#include "WorkArea.h"
#include "bufferview_funcs.h"
#include "minibuffer.h"
#include "vspace.h"
#include "LyXView.h"
-#include "lyx_gui_misc.h"
#include "FloatList.h"
#include "converter.h"
#include "exporter.h"
#include "lyxfind.h"
#include "undo_funcs.h"
#include "ParagraphParameters.h"
-#include "figureForm.h"
#include "insets/inseturl.h"
#include "insets/insetlatexaccent.h"
#include "frontends/Menubar.h"
#include "frontends/Alert.h"
+#include "graphics/GraphicsCache.h"
+
#include "support/lyxalgo.h"
#include "support/LAssert.h"
#include "support/filetools.h"
#include "support/FileInfo.h"
-#include "support/syscall.h"
+#include "support/forkedcontr.h"
#include "support/lstrings.h"
#include "support/path.h"
#include "support/lyxfunctional.h"
using std::make_pair;
using std::endl;
using std::find_if;
+using std::vector;
+using std::transform;
+using std::back_inserter;
extern BufferList bufferlist;
extern LyXServer * lyxserver;
extern bool selection_possible;
-extern void MenuSendto();
extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
// why not return already here if action == -1 and
// num_bytes == 0? (Lgb)
- if (keyseq.length() > 1 && !keyseq.deleted()) {
+ if (keyseq.length() > 1) {
owner->message(keyseq.print());
}
setStatusMessage(N_("Unknown action"));
return flag.unknown(true);
}
+
+ // the default error message if we disable the command
+ setStatusMessage(N_("Command disabled"));
// Check whether we need a buffer
if (!lyxaction.funcHasFlag(action, LyXAction::NoBuffer)) {
}
}
+ UpdatableInset * tli = owner->view()->theLockingInset();
+
// I would really like to avoid having this switch and rather try to
// encode this in the function itself.
bool disable = false;
break;
case LFUN_LAYOUT_TABULAR:
- disable = true;
- if (owner->view()->theLockingInset()) {
- disable = (owner->view()->theLockingInset()->lyxCode() != Inset::TABULAR_CODE) &&
- !owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE);
- }
+ disable = !tli
+ || (tli->lyxCode() != Inset::TABULAR_CODE
+ && !tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE));
break;
+ case LFUN_LAYOUT:
+ case LFUN_LAYOUT_PARAGRAPH: {
+ Inset * inset = TEXT(false)->cursor.par()->inInset();
+ disable = inset && inset->forceDefaultParagraphs(inset);
+ break;
+ }
+
case LFUN_TABULAR_FEATURE:
disable = true;
- if (owner->view()->theLockingInset()) {
+ if (tli) {
FuncStatus ret;
//ret.disabled(true);
- if (owner->view()->theLockingInset()->lyxCode() == Inset::TABULAR_CODE) {
- ret = static_cast<InsetTabular *>
- (owner->view()->theLockingInset())->
- getStatus(argument);
- } else if (owner->view()->theLockingInset()->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
+ if (tli->lyxCode() == Inset::TABULAR_CODE) {
+ ret = static_cast<InsetTabular *>(tli)
+ ->getStatus(argument);
+ } else if (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE)) {
ret = static_cast<InsetTabular *>
- (owner->view()->theLockingInset()->
- getFirstLockingInsetOfType(Inset::TABULAR_CODE))->
- getStatus(argument);
+ (tli->getFirstLockingInsetOfType(Inset::TABULAR_CODE))
+ ->getStatus(argument);
}
flag |= ret;
disable = false;
disable = true;
ret = inset.getStatus(argument);
- if (ret.onoff(true) || ret.onoff(false)) flag.setOnOff(false);
+ if (ret.onoff(true) || ret.onoff(false))
+ flag.setOnOff(false);
}
break;
break;
- case LFUN_INSET_TOGGLE:
- disable = (TEXT(false)->getInset() == 0);
+ case LFUN_INSET_TOGGLE: {
+ LyXText * lt = owner->view()->getLyXText();
+ disable = !(isEditableInset(lt->getInset())
+ || (lt->inset_owner
+ && lt->inset_owner->owner()
+ && lt->inset_owner->owner()->isOpen()));
break;
-
- case LFUN_MATH_VALIGN: {
- // 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)) {
- //
+ }
+ case LFUN_MATH_VALIGN:
if (mathcursor) {
char align = mathcursor->valign();
if (align == '\0') {
} else
disable = true;
break;
- }
- case LFUN_MATH_HALIGN: {
- //Inset * tli = owner->view()->theLockingInset();
- //if (tli && (tli->lyxCode() == Inset::MATH_CODE
- // || tli->lyxCode() == Inset::MATHMACRO_CODE)) {
+
+ case LFUN_MATH_HALIGN:
if (mathcursor) {
char align = mathcursor->halign();
if (align == '\0') {
} else
disable = true;
break;
- }
- case LFUN_MATH_MUTATE: {
- Inset * tli = owner->view()->theLockingInset();
+
+ case LFUN_MATH_MUTATE:
if (tli && (tli->lyxCode() == Inset::MATH_CODE)) {
MathInsetTypes type = mathcursor->formula()->getType();
if (argument == "inline") {
} else
disable = true;
break;
- }
// we just need to be in math mode to enable that
case LFUN_MATH_SIZE:
// the functions which insert insets
Inset::Code code = Inset::NO_CODE;
switch (action) {
- case LFUN_INSET_TEXT:
- code = Inset::TEXT_CODE;
- break;
case LFUN_INSET_ERT:
code = Inset::ERT_CODE;
break;
- case LFUN_FIGURE:
case LFUN_INSET_GRAPHICS:
code = Inset::GRAPHICS_CODE;
break;
default:
break;
}
- if (code != Inset::NO_CODE
- && owner->view()->theLockingInset()
- && !owner->view()->theLockingInset()->insetAllowed(code)) {
+ if (code != Inset::NO_CODE && tli && !tli->insetAllowed(code)) {
disable = true;
}
// A few general toggles
switch (action) {
+ case LFUN_TOOLTIPS_TOGGLE:
+ flag.setOnOff(owner->getDialogs()->tooltipsEnabled());
+ break;
+
case LFUN_READ_ONLY_TOGGLE:
flag.setOnOff(buf->isReadonly());
break;
case LFUN_APPENDIX:
flag.setOnOff(TEXT(false)->cursor.par()->params().startOfAppendix());
break;
+ case LFUN_SWITCHBUFFER:
+ // toggle on the current buffer, but do not toggle off
+ // the other ones (is that a good idea?)
+ if (argument == buf->fileName())
+ flag.setOnOff(true);
+ break;
default:
break;
}
(!keyseq.deleted())))
{
if ((action == LFUN_UNKNOWN_ACTION)
- && argument.empty()){
+ && argument.empty()) {
argument = keyseq.getiso();
}
// Undo/Redo is a bit tricky for insets.
owner->view()->menuRedo();
goto exit_with_message;
} else if (((result=owner->view()->theLockingInset()->
+ // Hand-over to inset's own dispatch:
localDispatch(owner->view(), action, argument)) ==
UpdatableInset::DISPATCHED) ||
(result == UpdatableInset::DISPATCHED_NOUPDATE))
goto exit_with_message;
+ // If UNDISPATCHED, just soldier on
else if (result == UpdatableInset::FINISHED) {
if (TEXT()->cursor.par()->isRightToLeftPar(owner->buffer()->params)) {
TEXT()->cursorRight(owner->view());
}
switch (action) {
-
+
case LFUN_ESCAPE:
{
if (!owner->view()->available()) break;
owner->view()->update(TEXT(),
BufferView::SELECT|BufferView::FITCUR);
}
- owner->message(keyseq.print());
+ owner->message(keyseq.printOptions());
}
break;
// --- Misc -------------------------------------------
case LFUN_EXEC_COMMAND:
{
- std::vector<string> allCmds;
- std::transform(lyxaction.func_begin(), lyxaction.func_end(),
- std::back_inserter(allCmds), lyx::firster());
- static std::vector<string> hist;
+ vector<string> allCmds;
+ transform(lyxaction.func_begin(), lyxaction.func_end(),
+ back_inserter(allCmds), lyx::firster());
+ static vector<string> hist;
owner->getMiniBuffer()->getString(MiniBuffer::spaces,
allCmds, hist);
}
case LFUN_UPDATE:
Exporter::Export(owner->buffer(), argument, true);
break;
-
+
case LFUN_PREVIEW:
Exporter::Preview(owner->buffer(), argument);
break;
-
+
case LFUN_BUILDPROG:
Exporter::Export(owner->buffer(), "program", true);
- break;
-
+ break;
+
case LFUN_RUNCHKTEX:
MenuRunChktex(owner->buffer());
break;
case LFUN_EXPORT:
if (argument == "custom")
- MenuSendto();
+ owner->getDialogs()->showSendto();
else
Exporter::Export(owner->buffer(), argument, false);
break;
#endif
p.setCmdName("tableofcontents");
#if 0
- else if (action == LFUN_LOAVIEW )
+ else if (action == LFUN_LOAVIEW)
p.setCmdName("listof{algorithm}{List of Algorithms}");
else if (action == LFUN_LOFVIEW)
p.setCmdName("listoffigures");
owner->getDialogs()->showTabularCreate();
break;
- case LFUN_FIGURE:
- Figure();
- break;
-
case LFUN_AUTOSAVE:
AutoSave(owner->view());
break;
Paragraph * par = owner->buffer()->getParFromID(id);
if (par == 0) {
lyxerr[Debug::INFO] << "No matching paragraph found! ["
- << id << "]" << std::endl;
+ << id << "]" << endl;
break;
} else {
lyxerr << "Paragraph " << par->id()
case LFUN_CITATION_CREATE:
{
- InsetCommandParams p( "cite" );
+ InsetCommandParams p("cite");
if (!argument.empty()) {
// This should be set at source, ie when typing
// Question: would pybibliographer also need to be
// changed. Suspect so. Leave as-is therefore.
if (contains(argument, "|")) {
- p.setContents( token(argument, '|', 0) );
- p.setOptions( token(argument, '|', 1) );
+ p.setContents(token(argument, '|', 0));
+ p.setOptions( token(argument, '|', 1));
} else {
- p.setContents( argument );
+ p.setContents(argument);
}
dispatch(LFUN_CITATION_INSERT, p.getAsString());
} else
- owner->getDialogs()->createCitation( p.getAsString() );
+ owner->getDialogs()->createCitation(p.getAsString());
}
break;
break;
}
+ bool const graphicsbg_changed =
+ (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
+ x11_name != lcolor.getX11Name(LColor::graphicsbg));
+
if (!lcolor.setColor(lyx_name, x11_name)) {
static string const err1 (N_("Set-color \""));
static string const err2 (
setErrorMessage(_(err1) + lyx_name + _(err2));
break;
}
+
lyxColorHandler->updateColor(lcolor.getFromLyXName(lyx_name));
+
+ if (graphicsbg_changed) {
+ grfx::GCache & gc = grfx::GCache::get();
+ gc.changeDisplay(true);
+ }
+
owner->view()->redraw();
break;
}
owner->messagePop();
break;
+ case LFUN_FORKS_SHOW:
+ owner->getDialogs()->showForks();
+ break;
+
+ case LFUN_FORKS_KILL:
+ {
+ if (!isStrInt(argument))
+ break;
+
+ pid_t const pid = strToInt(argument);
+ ForkedcallsController & fcc = ForkedcallsController::get();
+ fcc.kill(pid);
+ break;
+ }
+
+ case LFUN_TOOLTIPS_TOGGLE:
+ owner->getDialogs()->toggleTooltips();
+ break;
+
default:
// Then if it was none of the above
+ // Trying the BufferView::pimpl dispatch:
if (!owner->view()->Dispatch(action, argument))
lyxerr << "A truly unknown func ["
<< lyxaction.getActionName(action) << "]!"