Simplify logic in InsetRef::latex().

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37958 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2011-03-19 10:31:43 +00:00
parent c6eca6e90b
commit e52af5f897
8 changed files with 2915 additions and 3931 deletions

View File

@ -1,22 +1,22 @@
# Inspired by #7363.
#
Lang it_IT.utf8
TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
KK: \Cm
KK: x_v \C\[Home]
KK: \Cs
KK: \CF
KK: \Cm
KK: v\[Return]
TestEnd
Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n.*idx: 1 par: 0 pos: 0\n with len: 1' lyx-log.txt
TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
KK: \C\[Home]
KK: \CF
# Uncheck ignore format
KK: \Az\Ag\Ae
KK: \Cm
KK: v\[Return]
TestEnd
Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n.*idx: 1 par: 0 pos: 0\n with len: 1' lyx-log.txt
# Inspired by #7363.
#
Lang it_IT.utf8
TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
KK: \Cm
KK: x_v \C\[Home]
KK: \Cs
KK: \CF
KK: \Cm
KK: v\[Return]
TestEnd
Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n.*idx: 1 par: 0 pos: 0\n with len: 1' lyx-log.txt
TestBegin test.lyx -dbg find > lyx-log.txt 2>&1
KK: \C\[Home]
KK: \CF
# Uncheck ignore format
KK: \Az\Ag\Ae
KK: \Cm
KK: v\[Return]
TestEnd
Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n.*idx: 0 par: 0 pos: 0\n.*idx: 1 par: 0 pos: 0\n with len: 1' lyx-log.txt

6703
po/it.po

File diff suppressed because it is too large Load Diff

View File

@ -2364,42 +2364,6 @@ void BufferView::putSelectionAt(DocIterator const & cur,
}
bool BufferView::selectIfEmpty(DocIterator & cur)
{
if (!cur.paragraph().empty())
return false;
pit_type const beg_pit = cur.pit();
if (beg_pit > 0) {
// The paragraph associated to this item isn't
// the first one, so it can be selected
cur.backwardPos();
} else {
// We have to resort to select the space between the
// end of this item and the begin of the next one
cur.forwardPos();
}
if (cur.empty()) {
// If it is the only item in the document,
// nothing can be selected
return false;
}
pit_type const end_pit = cur.pit();
pos_type const end_pos = cur.pos();
d->cursor_.clearSelection();
d->cursor_.reset();
d->cursor_.setCursor(cur);
d->cursor_.pit() = beg_pit;
d->cursor_.pos() = 0;
d->cursor_.setSelection(false);
d->cursor_.resetAnchor();
d->cursor_.pit() = end_pit;
d->cursor_.pos() = end_pos;
d->cursor_.setSelection();
return true;
}
Cursor & BufferView::cursor()
{
return d->cursor_;

View File

@ -247,9 +247,6 @@ public:
void putSelectionAt(DocIterator const & cur,
int length, bool backwards);
/// selects the item at cursor if its paragraph is empty.
bool selectIfEmpty(DocIterator & cur);
/// update the internal \c ViewMetricsInfo.
void updateMetrics();

View File

@ -1577,7 +1577,7 @@ void GuiDocument::changeNoteFontColor()
void GuiDocument::deleteNoteFontColor()
{
// set the button color back to pref
theApp()->getRgbColor(Color_greyedouttext, set_notefontcolor);
theApp()->getRgbColor(Color_notebg, set_notefontcolor);
colorModule->noteFontColorPB->setStyleSheet(
colorButtonStyleSheet(rgb2qcolor(set_notefontcolor)));
changed();

View File

@ -172,17 +172,11 @@ bool GuiErrorList::goTo(int item)
return false;
}
// If this paragraph is empty, highlight the previous one
while (dit.paragraph().empty())
dit.backwardPos();
// Now make the selection.
BufferView * bv = const_cast<BufferView *>(bufferview());
if (bv->selectIfEmpty(dit)) {
// The paragraph is empty but can be selected
bv->processUpdateFlags(Update::Force | Update::FitCursor);
return true;
}
if (dit.empty()) {
// The paragraph is empty and cannot be selected
return false;
}
// if pos_end is 0, this means it is end-of-paragraph
pos_type const s = dit.paragraph().size();
pos_type const end = err.pos_end ? min(err.pos_end, s) : s;
@ -190,6 +184,7 @@ bool GuiErrorList::goTo(int item)
pos_type const range = end == start ? s - start : end - start;
// end-of-paragraph cannot be highlighted, so highlight the last thing
dit.pos() = range ? start : end - 1;
BufferView * bv = const_cast<BufferView *>(bufferview());
// FIXME LFUN
// If we used an LFUN, we would not need these lines:
bv->putSelectionAt(dit, max(range, pos_type(1)), false);

View File

@ -49,10 +49,15 @@ GuiSelectionManager::GuiSelectionManager(
QPushButton * down,
QAbstractListModel * amod,
QAbstractListModel * smod)
: availableLV(avail), selectedLV(sel), addPB(add), deletePB(del),
upPB(up), downPB(down), availableModel(amod), selectedModel(smod),
selectedHasFocus_(false)
{
availableLV = avail;
selectedLV = sel;
addPB = add;
deletePB = del;
upPB = up;
downPB = down;
availableModel = amod;
selectedModel = smod;
selectedLV->setModel(smod);
availableLV->setModel(amod);
@ -82,6 +87,7 @@ GuiSelectionManager::GuiSelectionManager(
availableLV->installEventFilter(this);
selectedLV->installEventFilter(this);
selectedHasFocus_ = false;
}

View File

@ -140,34 +140,25 @@ docstring InsetRef::getEscapedLabel(OutputParams const & rp) const
void InsetRef::latex(otexstream & os, OutputParams const & rp) const
{
string const cmd = getCmdName();
docstring const data = getEscapedLabel(rp);
// refstyle defines its own version of \eqref
if (cmd != "formatted" &&
!(cmd == "eqref" && buffer().params().use_refstyle)
) {
if (cmd == "eqref" && buffer().params().use_refstyle) {
os << '(' << from_ascii("\\ref{") << data << from_ascii("})");
}
else if (cmd == "formatted") {
docstring label;
docstring prefix;
docstring const fcmd = getFormattedCmd(data, label, prefix);
os << fcmd << '{' << label << '}';
}
else {
// We don't want to output p_["name"], since that is only used
// in docbook. So we construct new params, without it, and use that.
InsetCommandParams p(REF_CODE, cmd);
docstring const ref = getParam("reference");
p["reference"] = ref;
os << p.getCommand(rp);
return;
}
// so we're doing a formatted reference of some kind.
docstring const data = getEscapedLabel(rp);
// what we say in the UI is that an "eqref" is supposed to surround the
// reference with parentheses, so let's do that.
if (cmd == "eqref" /* && buffer().params().use_refstyle */) {
os << '(' << from_ascii("\\ref{") << data << from_ascii("})");
return;
}
docstring label;
docstring prefix;
docstring const fcmd = getFormattedCmd(data, label, prefix);
os << fcmd << '{' << label << '}';
}