mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Several InsetBibKey fixes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1428 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1f98760c51
commit
f8e05c6800
@ -1,3 +1,7 @@
|
||||
2001-01-31 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* paragraph.C (GetPositionOfInset): Handle bibkey.
|
||||
|
||||
2001-01-29 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* BufferView_pimpl.h: change type of Position::par_pos to
|
||||
|
@ -933,7 +933,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par,
|
||||
++pos;
|
||||
} else if (token == "\\bibitem") { // ale970302
|
||||
if (!par->bibkey) {
|
||||
InsetCommandParams p( "bibitem" );
|
||||
InsetCommandParams p("bibitem", "dummy");
|
||||
par->bibkey = new InsetBibKey(p);
|
||||
}
|
||||
par->bibkey->Read(this, lex);
|
||||
|
@ -1,3 +1,10 @@
|
||||
2001-01-31 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* insetbib.C (InsetBibKey): Better computation of default key.
|
||||
(getScreenLabel) Show both the key and the label.
|
||||
(getBibLabel): New method.
|
||||
(callback): Force a redraw if the inset have been changed.
|
||||
|
||||
2001-01-26 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* insetref.C (getType, getName): Move methods from
|
||||
|
@ -27,6 +27,7 @@ using std::getline;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::max;
|
||||
|
||||
FD_bibitem_form * bibitem_form = 0;
|
||||
|
||||
@ -76,10 +77,15 @@ FD_bibitem_form * create_form_bibitem_form(void)
|
||||
}
|
||||
|
||||
|
||||
int InsetBibKey::key_counter = 0;
|
||||
const string key_prefix = "key-";
|
||||
|
||||
InsetBibKey::InsetBibKey(InsetCommandParams const & p)
|
||||
: InsetCommand(p)
|
||||
{
|
||||
counter = 1;
|
||||
if (getContents().empty())
|
||||
setContents(key_prefix + tostr(++key_counter));
|
||||
}
|
||||
|
||||
|
||||
@ -113,6 +119,9 @@ void InsetBibKey::callback( FD_bibitem_form * form, long data )
|
||||
// shouldn't mark the buffer dirty unless
|
||||
// something was actually altered
|
||||
current_view->updateInset( this, true );
|
||||
// We need to do a redraw becuase the maximum
|
||||
// InsetBibKey width could have changed.
|
||||
current_view->redraw();
|
||||
} // fall through to Cancel
|
||||
case 0:
|
||||
fl_hide_form(form->bibitem_form);
|
||||
@ -124,9 +133,6 @@ void InsetBibKey::callback( FD_bibitem_form * form, long data )
|
||||
void InsetBibKey::setCounter(int c)
|
||||
{
|
||||
counter = c;
|
||||
|
||||
if (getCmdName().empty())
|
||||
setCmdName( tostr(counter) );
|
||||
}
|
||||
|
||||
|
||||
@ -157,17 +163,25 @@ void InsetBibKey::Read(Buffer const *, LyXLex & lex)
|
||||
scanCommand(token);
|
||||
} else
|
||||
lex.printError("InsetCommand: Parse error: `$$Token'");
|
||||
|
||||
if (prefixIs(getContents(), key_prefix)) {
|
||||
int key = strToInt(getContents().substr(key_prefix.length()));
|
||||
key_counter = max(key_counter, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string const InsetBibKey::getScreenLabel() const
|
||||
string const InsetBibKey::getBibLabel() const
|
||||
{
|
||||
if (! getOptions().empty())
|
||||
return getOptions();
|
||||
|
||||
return tostr(counter);
|
||||
}
|
||||
|
||||
string const InsetBibKey::getScreenLabel() const
|
||||
{
|
||||
return getContents() + " [" + getBibLabel() + "]";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The value in "Key:" isn't allways set right after a few bibkey insets have
|
||||
@ -398,7 +412,7 @@ string const bibitemWidest(Buffer const * buffer)
|
||||
while (par) {
|
||||
if (par->bibkey) {
|
||||
int const wx =
|
||||
lyxfont::width(par->bibkey->getScreenLabel(),
|
||||
lyxfont::width(par->bibkey->getBibLabel(),
|
||||
font);
|
||||
if (wx > w) {
|
||||
w = wx;
|
||||
@ -408,8 +422,8 @@ string const bibitemWidest(Buffer const * buffer)
|
||||
par = par->next;
|
||||
}
|
||||
|
||||
if (bkey && !bkey->getScreenLabel().empty())
|
||||
return bkey->getScreenLabel();
|
||||
if (bkey && !bkey->getBibLabel().empty())
|
||||
return bkey->getBibLabel();
|
||||
|
||||
return "99";
|
||||
}
|
||||
|
@ -58,6 +58,8 @@ public:
|
||||
///
|
||||
int getCounter() const { return counter; }
|
||||
///
|
||||
string const getBibLabel() const;
|
||||
///
|
||||
void callback( FD_bibitem_form *, long );
|
||||
///
|
||||
struct Holder {
|
||||
@ -70,6 +72,8 @@ private:
|
||||
int counter;
|
||||
///
|
||||
Holder holder;
|
||||
///
|
||||
static int key_counter;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2205,6 +2205,9 @@ int LyXParagraph::GetPositionOfInset(Inset * inset) const
|
||||
return (*cit).pos;
|
||||
}
|
||||
}
|
||||
if (inset == bibkey)
|
||||
return 0;
|
||||
|
||||
#ifndef NEW_INSETS
|
||||
// Think about footnotes.
|
||||
if (footnoteflag == LyXParagraph::NO_FOOTNOTE
|
||||
|
Loading…
Reference in New Issue
Block a user