mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
* final splitindex feature addition: support for \printindex* and \printsubindex*
File format change. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29419 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a7e1aac652
commit
dd930b4535
@ -1,9 +1,13 @@
|
||||
LyX file-format changes
|
||||
-----------------------
|
||||
|
||||
2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 354: support for splitindex's
|
||||
\printindex* and \printsubindex*.
|
||||
|
||||
2009-04-26 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 353: support for splitindex's
|
||||
printsubindex.
|
||||
\printsubindex.
|
||||
|
||||
2009-04-15 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 352: splitindex support.
|
||||
|
@ -580,6 +580,31 @@ def revert_subindex(document):
|
||||
i = i + 1
|
||||
|
||||
|
||||
def revert_printindexall(document):
|
||||
" Reverts \\print[sub]index* CommandInset types "
|
||||
i = find_token(document.header, '\\use_indices', 0)
|
||||
if i == -1:
|
||||
document.warning("Malformed LyX document: Missing \\use_indices.")
|
||||
return
|
||||
indices = get_value(document.header, "\\use_indices", i)
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset CommandInset index_print", i)
|
||||
if i == -1:
|
||||
return
|
||||
k = find_end_of_inset(document.body, i)
|
||||
ctype = get_value(document.body, 'LatexCommand', i, k)
|
||||
if ctype != "printindex*" and ctype != "printsubindex*":
|
||||
i = i + 1
|
||||
continue
|
||||
if indices == "false":
|
||||
del document.body[i:k+1]
|
||||
else:
|
||||
subst = [put_cmd_in_ert("\\" + ctype + "{}")]
|
||||
document.body[i:k+1] = subst
|
||||
i = i + 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -592,10 +617,12 @@ convert = [[346, []],
|
||||
[350, []],
|
||||
[351, []],
|
||||
[352, [convert_splitindex]],
|
||||
[353, []]
|
||||
[353, []],
|
||||
[354, []]
|
||||
]
|
||||
|
||||
revert = [[352, [revert_subindex]],
|
||||
revert = [[353, [revert_printindexall]],
|
||||
[352, [revert_subindex]],
|
||||
[351, [revert_splitindex]],
|
||||
[350, [revert_backgroundcolor]],
|
||||
[349, [revert_outputformat]],
|
||||
|
@ -520,6 +520,7 @@ Menuset
|
||||
#
|
||||
|
||||
Menu "context-indexprint"
|
||||
Item "All Indices|A" "next-inset-modify check-printindex*"
|
||||
IndicesListsContext
|
||||
Separator
|
||||
Item "Subindex|b" "next-inset-modify toggle-subindex"
|
||||
|
@ -125,7 +125,7 @@ namespace {
|
||||
|
||||
// Do not remove the comment below, so we get merge conflict in
|
||||
// independent branches. Instead add your own.
|
||||
int const LYX_FORMAT = 353; // jspitzm: subindex support
|
||||
int const LYX_FORMAT = 354; // jspitzm: support for \print[sub]index*
|
||||
|
||||
typedef map<string, bool> DepClean;
|
||||
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
|
||||
|
@ -21,11 +21,14 @@
|
||||
#include "FuncRequest.h"
|
||||
#include "IndicesList.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "insets/InsetCommand.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -58,10 +61,14 @@ void GuiPrintindex::updateContents()
|
||||
typedef IndicesList::const_iterator const_iterator;
|
||||
|
||||
IndicesList const & indiceslist = buffer().params().indiceslist();
|
||||
docstring const cur_index = params_["type"];
|
||||
docstring const cur_index = suffixIs(params_.getCmdName(), '*') ?
|
||||
from_ascii("printall") : params_["type"];
|
||||
|
||||
indicesCO->clear();
|
||||
|
||||
indicesCO->addItem(qt_("<All indices>"),
|
||||
QVariant(QString("printall")));
|
||||
|
||||
const_iterator const begin = indiceslist.begin();
|
||||
const_iterator const end = indiceslist.end();
|
||||
for (const_iterator it = begin; it != end; ++it)
|
||||
@ -78,17 +85,24 @@ void GuiPrintindex::applyView()
|
||||
{
|
||||
QString const index = indicesCO->itemData(
|
||||
indicesCO->currentIndex()).toString();
|
||||
string cmd = "printindex";
|
||||
if (subindexCB->isChecked())
|
||||
params_.setCmdName("printsubindex");
|
||||
cmd = "printsubindex";
|
||||
if (index == QString("printall"))
|
||||
cmd += '*';
|
||||
params_.setCmdName(cmd);
|
||||
if (index == QString("printall"))
|
||||
params_["type"] = docstring();
|
||||
else
|
||||
params_.setCmdName("printindex");
|
||||
params_["type"] = qstring_to_ucs4(index);
|
||||
params_["type"] = qstring_to_ucs4(index);
|
||||
}
|
||||
|
||||
|
||||
void GuiPrintindex::paramsToDialog(InsetCommandParams const & /*icp*/)
|
||||
{
|
||||
int const pos = indicesCO->findData(toqstr(params_["type"]));
|
||||
int const pos = suffixIs(params_.getCmdName(), '*') ?
|
||||
indicesCO->findData(QString("printall")) :
|
||||
indicesCO->findData(toqstr(params_["type"]));
|
||||
subindexCB->setChecked(params_.getCmdName() == "printsubindex");
|
||||
indicesCO->setCurrentIndex(pos);
|
||||
bc().setValid(isValid());
|
||||
|
@ -398,34 +398,53 @@ ParamInfo const & InsetPrintIndex::findInfo(string const & /* cmdName */)
|
||||
|
||||
docstring InsetPrintIndex::screenLabel() const
|
||||
{
|
||||
if ((!buffer().masterBuffer()->params().use_indices
|
||||
bool const printall = suffixIs(getCmdName(), '*');
|
||||
bool const multind = buffer().masterBuffer()->params().use_indices;
|
||||
if ((!multind
|
||||
&& getParam("type") == from_ascii("idx"))
|
||||
|| getParam("type").empty())
|
||||
|| (getParam("type").empty() && !printall))
|
||||
return _("Index");
|
||||
Buffer const & realbuffer = *buffer().masterBuffer();
|
||||
IndicesList const & indiceslist = realbuffer.params().indiceslist();
|
||||
Index const * index = indiceslist.findShortcut(getParam("type"));
|
||||
if (!index)
|
||||
if (!index && !printall)
|
||||
return _("Unknown index type!");
|
||||
docstring res = index->index();
|
||||
if (!buffer().masterBuffer()->params().use_indices)
|
||||
docstring res = printall ? _("All indices") : index->index();
|
||||
if (!multind)
|
||||
res += " (" + _("non-active") + ")";
|
||||
else if (getCmdName() == "printsubindex")
|
||||
else if (contains(getCmdName(), "printsubindex"))
|
||||
res += " (" + _("subindex") + ")";
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
bool InsetPrintIndex::isCompatibleCommand(string const & s)
|
||||
{
|
||||
return s == "printindex" || s == "printsubindex"
|
||||
|| s == "printindex*" || s == "printsubindex*";
|
||||
}
|
||||
|
||||
|
||||
void InsetPrintIndex::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_INSET_MODIFY: {
|
||||
if (cmd.argument() == from_ascii("toggle-subindex")) {
|
||||
if (getCmdName() == "printindex")
|
||||
setCmdName("printsubindex");
|
||||
string cmd = getCmdName();
|
||||
if (contains(cmd, "printindex"))
|
||||
cmd = subst(cmd, "printindex", "printsubindex");
|
||||
else
|
||||
setCmdName("printindex");
|
||||
cmd = subst(cmd, "printsubindex", "printindex");
|
||||
setCmdName(cmd);
|
||||
break;
|
||||
} else if (cmd.argument() == from_ascii("check-printindex*")) {
|
||||
string cmd = getCmdName();
|
||||
if (suffixIs(cmd, '*'))
|
||||
break;
|
||||
cmd += '*';
|
||||
setParam("type", docstring());
|
||||
setCmdName(cmd);
|
||||
break;
|
||||
}
|
||||
InsetCommandParams p(INDEX_PRINT_CODE);
|
||||
@ -455,13 +474,22 @@ bool InsetPrintIndex::getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||
case LFUN_INSET_MODIFY: {
|
||||
if (cmd.argument() == from_ascii("toggle-subindex")) {
|
||||
status.setEnabled(buffer().masterBuffer()->params().use_indices);
|
||||
status.setOnOff(getCmdName() == "printsubindex");
|
||||
status.setOnOff(contains(getCmdName(), "printsubindex"));
|
||||
return true;
|
||||
} else if (cmd.argument() == from_ascii("check-printindex*")) {
|
||||
status.setEnabled(buffer().masterBuffer()->params().use_indices);
|
||||
status.setOnOff(suffixIs(getCmdName(), '*'));
|
||||
return true;
|
||||
} if (cmd.getArg(0) == "index_print"
|
||||
&& cmd.getArg(1) == "CommandInset") {
|
||||
InsetCommandParams p(INDEX_PRINT_CODE);
|
||||
InsetCommand::string2params("index_print",
|
||||
to_utf8(cmd.argument()), p);
|
||||
if (suffixIs(p.getCmdName(), '*')) {
|
||||
status.setEnabled(true);
|
||||
status.setOnOff(false);
|
||||
return true;
|
||||
}
|
||||
Buffer const & realbuffer = *buffer().masterBuffer();
|
||||
IndicesList const & indiceslist =
|
||||
realbuffer.params().indiceslist();
|
||||
|
@ -98,8 +98,7 @@ public:
|
||||
///
|
||||
static std::string defaultCommand() { return "printindex"; };
|
||||
///
|
||||
static bool isCompatibleCommand(std::string const & s)
|
||||
{ return s == "printindex" || s == "printsubindex"; }
|
||||
static bool isCompatibleCommand(std::string const & s);
|
||||
///
|
||||
int latex(odocstream &, OutputParams const &) const;
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user