#include "ParagraphParameters.h"
#include "undo.h"
+#include "insets/insetbox.h"
+#include "insets/insetbranch.h"
#include "insets/insetcommand.h"
+#include "insets/insetert.h"
#include "insets/insetexternal.h"
+#include "insets/insetfloat.h"
+#include "insets/insetgraphics.h"
+#include "insets/insetnote.h"
#include "insets/insettabular.h"
#include "insets/insetvspace.h"
-
-#include "mathed/math_cursor.h"
+#include "insets/insetwrap.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
#include "support/forkedcontr.h"
+#include "support/globbing.h"
#include "support/path.h"
#include "support/path_defines.h"
#include "support/tostr.h"
using lyx::support::AddPath;
using lyx::support::bformat;
using lyx::support::ChangeExtension;
+using lyx::support::FileFilterList;
using lyx::support::FileInfo;
using lyx::support::FileSearch;
using lyx::support::ForkedcallsController;
using std::endl;
using std::make_pair;
+using std::pair;
using std::string;
using std::istringstream;
// actions
keyseq.clear();
// copied verbatim from do_accent_char
+ view()->cursor().resetAnchor();
view()->update();
- view()->getLyXText()->selection.cursor = view()->getLyXText()->cursor;
}
-void LyXFunc::processKeySym(LyXKeySymPtr keysym,
- key_modifier::state state)
+void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
{
- string argument;
-
- if (lyxerr.debugging(Debug::KEY)) {
- lyxerr << "KeySym is "
- << keysym->getSymbolName()
- << endl;
- }
+ lyxerr[Debug::KEY] << "KeySym is " << keysym->getSymbolName() << endl;
// Do nothing if we have nothing (JMarc)
if (!keysym->isOK()) {
if (encoded_last_key != 0) {
string arg;
arg += encoded_last_key;
-
- dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
-
- lyxerr[Debug::KEY] << "SelfInsert arg[`"
- << argument << "']" << endl;
+ lyxerr << "SelfInsert arg[`"
+ << arg << "']" << endl;
+ dispatch(FuncRequest(LFUN_SELFINSERT, arg));
+ lyxerr[Debug::KEY]
+ << "SelfInsert arg[`" << arg << "']" << endl;
}
} else {
dispatch(func);
}
}
- UpdatableInset * tli = view()->cursor().innerInset();
+ UpdatableInset * tli = view()->cursor().inset()
+ ? view()->cursor().inset()->asUpdatableInset() : 0;
InsetTabular * tab = view()->cursor().innerInsetTabular();
// I would really like to avoid having this switch and rather try to
if (tab && tab->hasSelection())
disable = false;
else
- disable = !mathcursor && !view()->getLyXText()->selection.set();
+ disable = !view()->cursor().inMathed() && !view()->cursor().selection();
break;
case LFUN_RUNCHKTEX:
case LFUN_TABULAR_FEATURE:
#if 0
- if (mathcursor) {
+ if (view()->cursor().inMathed()) {
// FIXME: check temporarily disabled
// valign code
- char align = mathcursor->valign();
+ char align = mathcursor::valign();
if (align == '\0') {
disable = true;
break;
} else {
disable = true;
- char align = mathcursor->halign();
+ char align = mathcursor::halign();
if (align == '\0') {
disable = true;
break;
}
flag.setOnOff(ev.argument[0] == align);
- disable = !mathcursor->halign();
+ disable = !mathcursor::halign();
break;
}
disable = !buf->params().tracking_changes;
break;
- case LFUN_INSET_TOGGLE: {
- LyXText * lt = view()->getLyXText();
- disable = !(isEditableInset(lt->getInset())
- || (lt->inset_owner
- && lt->inset_owner->owner()
- && lt->inset_owner->owner()->isOpen()));
- break;
- }
-
case LFUN_INSET_SETTINGS: {
disable = true;
- UpdatableInset * inset = view()->cursor().innerInset();
+ UpdatableInset * inset = view()->cursor().inset()
+ ? view()->cursor().inset()->asUpdatableInset() : 0;
if (!inset)
break;
case InsetOld::FLOAT_CODE:
disable = ev.argument != "float";
break;
- case InsetOld::MINIPAGE_CODE:
- disable = ev.argument != "minipage";
- break;
case InsetOld::WRAP_CODE:
disable = ev.argument != "wrap";
break;
}
case LFUN_MATH_MUTATE:
- if (mathcursor)
- //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
+ if (view()->cursor().inMathed())
+ //flag.setOnOff(mathcursor::formula()->hullType() == ev.argument);
flag.setOnOff(false);
else
disable = true;
case LFUN_MATH_NONUMBER:
case LFUN_MATH_NUMBER:
case LFUN_MATH_EXTERN:
- disable = !mathcursor;
+ disable = !view()->cursor().inMathed();
break;
case LFUN_DIALOG_SHOW: {
disable = !Exporter::IsExportable(*buf, "dvi") ||
lyxrc.print_command == "none";
} else if (name == "character") {
- UpdatableInset * tli = view()->cursor().innerInset();
- disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
+ InsetBase * inset = view()->cursor().inset();
+ disable = inset && inset->lyxCode() == InsetOld::ERT_CODE;
} else if (name == "vclog") {
disable = !buf->lyxvc().inUse();
} else if (name == "latexlog") {
code = InsetOld::BIBITEM_CODE;
else if (ev.argument == "bibtex")
code = InsetOld::BIBTEX_CODE;
+ else if (ev.argument == "box")
+ code = InsetOld::BOX_CODE;
+ else if (ev.argument == "branch")
+ code = InsetOld::BRANCH_CODE;
else if (ev.argument == "citation")
code = InsetOld::CITE_CODE;
else if (ev.argument == "ert")
code = InsetOld::INDEX_CODE;
else if (ev.argument == "label")
code = InsetOld::LABEL_CODE;
- else if (ev.argument == "minipage")
- code = InsetOld::MINIPAGE_CODE;
+ else if (ev.argument == "note")
+ code = InsetOld::NOTE_CODE;
else if (ev.argument == "ref")
code = InsetOld::REF_CODE;
else if (ev.argument == "toc")
case LFUN_INSET_MARGINAL:
code = InsetOld::MARGIN_CODE;
break;
- case LFUN_INSET_MINIPAGE:
- code = InsetOld::MINIPAGE_CODE;
- break;
case LFUN_INSET_FLOAT:
case LFUN_INSET_WIDE_FLOAT:
code = InsetOld::FLOAT_CODE;
code = InsetOld::OPTARG_CODE;
break;
case LFUN_ENVIRONMENT_INSERT:
- code = InsetOld::MINIPAGE_CODE;
+ code = InsetOld::BOX_CODE;
break;
case LFUN_INDEX_INSERT:
code = InsetOld::INDEX_CODE;
break;
case LFUN_SPACE_INSERT:
// slight hack: we know this is allowed in math mode
- if (!mathcursor)
+ if (!view()->cursor().inMathed())
code = InsetOld::SPACE_CODE;
break;
case LFUN_INSET_DIALOG_SHOW: {
- InsetOld * inset = view()->getLyXText()->getInset();
+ InsetBase * inset = view()->cursor().nextInset();
disable = !inset;
- if (!disable) {
+ if (inset) {
code = inset->lyxCode();
if (!(code == InsetOld::INCLUDE_CODE
|| code == InsetOld::BIBTEX_CODE
#ifdef LOCK
// the font related toggles
- if (!mathcursor) {
+ if (!view()->cursor().inMathed()) {
LyXFont const & font = view()->getLyXText()->real_current_font;
switch (ev.action) {
case LFUN_EMPH:
break;
}
} else {
- string tc = mathcursor->getLastCode();
+ string tc = mathcursor::getLastCode();
switch (ev.action) {
case LFUN_BOLD:
flag.setOnOff(tc == "mathbf");
} //namespace anon
-void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
+void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
{
- string argument = func.argument;
- kb_action action = func.action;
+ string argument = cmd.argument;
+ kb_action action = cmd.action;
- //lyxerr[Debug::ACTION] << "LyXFunc::dispatch: cmd: " << func << endl;
- lyxerr << "LyXFunc::dispatch: cmd: " << func << endl;
+ lyxerr[Debug::ACTION] << "LyXFunc::dispatch: cmd: " << cmd << endl;
+ //lyxerr << "*** LyXFunc::dispatch: cmd: " << cmd << endl;
// we have not done anything wrong yet.
errorstat = false;
dispatch_buffer.erase();
-
-#ifdef NEW_DISPATCHER
- // We try do call the most specific dispatcher first:
- // 1. the lockinginset's dispatch
- // 2. the bufferview's dispatch
- // 3. the lyxview's dispatch
-#endif
-
selection_possible = false;
// We cannot use this function here
- if (getStatus(func).disabled()) {
+ if (getStatus(cmd).disabled()) {
lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
<< lyxaction.getActionName(action)
<< " [" << action << "] is disabled at this location"
if (!argument.empty()) {
last_search = argument;
searched_string = argument;
- } else {
+ } else
searched_string = last_search;
- }
- bool fw = (action == LFUN_WORDFINDFORWARD);
- if (!searched_string.empty())
- lyx::find::find(view(), searched_string,
- true, false, fw);
+
+ if (searched_string.empty())
+ break;
+
+ bool const fw = action == LFUN_WORDFINDFORWARD;
+ string const data =
+ lyx::find::find2string(searched_string, true, false, fw);
+ view()->dispatch(FuncRequest(LFUN_WORD_FIND, data));
break;
}
<< " found." << endl;
}
- par.lockPath(view());
- LyXText * lt = par.text(view());
-
// Set the cursor
- lt->setCursor(par.pit(), 0);
+ view()->setCursor(par, 0);
+
view()->switchKeyMap();
owner->view_state_changed();
setErrorMessage(N_("This is only allowed in math mode!"));
break;
- // passthrough hat and underscore outside mathed:
- case LFUN_SUBSCRIPT:
- dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
- break;
-
- case LFUN_SUPERSCRIPT:
- dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
- break;
-
case LFUN_DIALOG_SHOW: {
- string const name = func.getArg(0);
- string data = trim(func.argument.substr(name.size()));
+ string const name = cmd.getArg(0);
+ string data = trim(cmd.argument.substr(name.size()));
if (name == "character") {
data = freefont2string();
if (!data.empty())
owner->getDialogs().show("character", data);
- } else if (name == "document")
+ }
+ else if (name == "document")
owner->getDialogs().showDocument();
- else if (name == "findreplace")
- owner->getDialogs().showSearch();
else if (name == "forks")
owner->getDialogs().showForks();
else if (name == "preamble")
owner->getDialogs().showPrint();
else if (name == "spellchecker")
owner->getDialogs().showSpellchecker();
+
+ else if (name == "latexlog") {
+ pair<Buffer::LogType, string> const logfile =
+ owner->buffer()->getLogName();
+ switch (logfile.first) {
+ case Buffer::latexlog:
+ data = "latex ";
+ break;
+ case Buffer::buildlog:
+ data = "literate ";
+ break;
+ }
+ data += logfile.second;
+ owner->getDialogs().show("log", data);
+ }
+ else if (name == "vclog") {
+ string const data = "vc " +
+ owner->buffer()->lyxvc().getLogFile();
+ owner->getDialogs().show("log", data);
+ }
else
owner->getDialogs().show(name, data);
break;
}
case LFUN_DIALOG_SHOW_NEW_INSET: {
- string const & name = argument;
- string data;
+ string const name = cmd.getArg(0);
+ string data = trim(cmd.argument.substr(name.size()));
if (name == "bibitem" ||
- name == "bibtex" ||
- name == "include" ||
- name == "index" ||
- name == "ref" ||
- name == "toc" ||
- name == "url") {
+ name == "bibtex" ||
+ name == "include" ||
+ name == "index" ||
+ name == "label" ||
+ name == "ref" ||
+ name == "toc" ||
+ name == "url") {
InsetCommandParams p(name);
data = InsetCommandMailer::params2string(name, p);
+ } else if (name == "box") {
+ // \c data == "Boxed" || "Frameless" etc
+ InsetBoxParams p(data);
+ data = InsetBoxMailer::params2string(p);
+ } else if (name == "branch") {
+ InsetBranchParams p;
+ data = InsetBranchMailer::params2string(p);
} else if (name == "citation") {
InsetCommandParams p("cite");
data = InsetCommandMailer::params2string(name, p);
+ } else if (name == "ert") {
+ data = InsetERTMailer::params2string(InsetCollapsable::Open);
+ } else if (name == "external") {
+ InsetExternalParams p;
+ Buffer const & buffer = *owner->buffer();
+ data = InsetExternalMailer::params2string(p, buffer);
+ } else if (name == "float") {
+ InsetFloatParams p;
+ data = InsetFloatMailer::params2string(p);
+ } else if (name == "graphics") {
+ InsetGraphicsParams p;
+ Buffer const & buffer = *owner->buffer();
+ data = InsetGraphicsMailer::params2string(p, buffer);
+ } else if (name == "note") {
+ InsetNoteParams p;
+ data = InsetNoteMailer::params2string(p);
} else if (name == "vspace") {
VSpace space;
data = InsetVSpaceMailer::params2string(space);
+ } else if (name == "wrap") {
+ InsetWrapParams p;
+ data = InsetWrapMailer::params2string(p);
}
owner->getDialogs().show(name, data, 0);
break;
break;
case LFUN_INSET_DIALOG_SHOW: {
- InsetOld * inset = view()->getLyXText()->getInset();
+ InsetBase * inset = view()->cursor().nextInset();
if (inset)
- inset->dispatch(FuncRequest(view(), LFUN_INSET_DIALOG_SHOW));
+ inset->dispatch(view()->cursor(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
break;
}
// Can only update a dialog connected to an existing inset
InsetBase * inset = owner->getDialogs().getOpenInset(name);
if (inset) {
- FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
- func.argument);
- inset->dispatch(fr);
+ FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument);
+ inset->dispatch(view()->cursor(), fr);
} else if (name == "paragraph") {
dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
}
(lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
x11_name != lcolor.getX11Name(LColor::graphicsbg));
- if (!lcolor.setColor(lyx_name, x11_name)) {
+ LColor::color col = lcolor.getFromLyXName(lyx_name);
+ if (!lcolor.setColor(col, x11_name)) {
setErrorMessage(
bformat(_("Set-color \"%1$s\" failed "
"- color is undefined or "
break;
case LFUN_EXTERNAL_EDIT:
- InsetExternal().dispatch(FuncRequest(view(), action, argument));
+ InsetExternal().dispatch(view()->cursor(), FuncRequest(action, argument));
break;
- default: {
- DispatchResult result =
- view()->cursor().dispatch(FuncRequest(func, view()));
- if (result.dispatched())
- lyxerr << "dispatched by Cursor::dispatch()" << endl;
- else
- lyxerr << "### NOT DISPATCHED BY Cursor::dispatch() ###" << endl;
- break;
- }
+ default:
+ DispatchResult res = view()->cursor().dispatch(cmd);
+ if (!res.dispatched());
+ view()->dispatch(cmd);
+ break;
}
}
- view()->owner()->updateLayoutChoice();
+ if (!view()->cursor().inMathed())
+ view()->owner()->updateLayoutChoice();
if (view()->available()) {
view()->fitCursor();
view()->update();
view()->cursor().updatePos();
// if we executed a mutating lfun, mark the buffer as dirty
- if (!getStatus(func).disabled()
- && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)
- && !lyxaction.funcHasFlag(func.action, LyXAction::ReadOnly))
+ if (!getStatus(cmd).disabled()
+ && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
+ && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly))
view()->buffer()->markDirty();
}
- sendDispatchMessage(getMessage(), func, verbose);
+ if (!view()->cursor().inMathed())
+ sendDispatchMessage(getMessage(), cmd, verbose);
}
void LyXFunc::sendDispatchMessage(string const & msg,
- FuncRequest const & func, bool verbose)
+ FuncRequest const & cmd, bool verbose)
{
owner->updateMenubar();
owner->updateToolbar();
- if (func.action == LFUN_SELFINSERT || !verbose) {
+ if (cmd.action == LFUN_SELFINSERT || !verbose) {
lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
if (!msg.empty())
owner->message(msg);
if (!dispatch_msg.empty())
dispatch_msg += ' ';
- string comname = lyxaction.getActionName(func.action);
+ string comname = lyxaction.getActionName(cmd.action);
bool argsadded = false;
- if (!func.argument.empty()) {
- if (func.action != LFUN_UNKNOWN_ACTION) {
- comname += ' ' + func.argument;
+ if (!cmd.argument.empty()) {
+ if (cmd.action != LFUN_UNKNOWN_ACTION) {
+ comname += ' ' + cmd.argument;
argsadded = true;
}
}
- string const shortcuts = toplevel_keymap->findbinding(func);
+ string const shortcuts = toplevel_keymap->findbinding(cmd);
if (!shortcuts.empty()) {
comname += ": " + shortcuts;
- } else if (!argsadded && !func.argument.empty()) {
- comname += ' ' + func.argument;
+ } else if (!argsadded && !cmd.argument.empty()) {
+ comname += ' ' + cmd.argument;
}
if (!comname.empty()) {
FileDialog::Result result =
fileDlg.open(lyxrc.template_path,
- _("*.lyx| LyX Documents (*.lyx)"));
+ FileFilterList(_("LyX Documents (*.lyx)")),
+ string());
if (result.first == FileDialog::Later)
return;
FileDialog::Result result =
fileDlg.open(initpath,
- _("*.lyx| LyX Documents (*.lyx)"));
+ FileFilterList(_("LyX Documents (*.lyx)")),
+ string());
if (result.first == FileDialog::Later)
return;
make_pair(string(_("Examples|#E#e")),
string(AddPath(system_lyxdir(), "examples"))));
- string const extension = "*." + formats.extension(format)
- + "| " + formats.prettyName(format)
+ string const filter = formats.prettyName(format)
+ " (*." + formats.extension(format) + ')';
- FileDialog::Result result = fileDlg.open(initpath,
- extension);
+ FileDialog::Result result =
+ fileDlg.open(initpath,
+ FileFilterList(filter),
+ string());
if (result.first == FileDialog::Later)
return;
// Each "owner" should have it's own message method. lyxview and
// the minibuffer would use the minibuffer, but lyxserver would
// send an ERROR signal to its client. Alejandro 970603
-// This func is bit problematic when it comes to NLS, to make the
+// This function is bit problematic when it comes to NLS, to make the
// lyx servers client be language indepenent we must not translate
// strings sent to this func.
void LyXFunc::setErrorMessage(string const & m) const