mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
New citation popup from Angus
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@800 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3be457e011
commit
474b65cd25
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2000-06-06 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* forms/cite.fd: new citation dialog
|
||||
|
||||
* src/insetcite.[Ch]: the new citation dialog is moved into
|
||||
its own files.
|
||||
|
||||
* src/insetbib.C: InsetBibtex::getKeys() uses STL containers
|
||||
(Dekel).
|
||||
|
||||
* src/insets/insetcommand.h: data members made private.
|
||||
|
||||
2000-06-06 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* LyX 1.1.5 released
|
||||
|
@ -6,102 +6,6 @@ Internal Form Definition File
|
||||
Number of forms: 2
|
||||
Unit of measure: FL_COORD_PIXEL
|
||||
|
||||
=============== FORM ===============
|
||||
Name: citation_form
|
||||
Width: 220
|
||||
Height: 130
|
||||
Number of Objects: 5
|
||||
|
||||
--------------------
|
||||
class: FL_BOX
|
||||
type: UP_BOX
|
||||
box: 0 0 220 130
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label:
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
type: NORMAL_INPUT
|
||||
box: 80 10 130 30
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_MCOL
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_NORMAL_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Key:|#K
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: key
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: RETURN_BUTTON
|
||||
box: 20 90 90 30
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_NORMAL_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: OK
|
||||
shortcut: ^M
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback: bibitem_cb
|
||||
argument: 1
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 120 90 90 30
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_NORMAL_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Cancel|^[
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback: bibitem_cb
|
||||
argument: 0
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
type: NORMAL_INPUT
|
||||
box: 80 50 130 30
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_MCOL
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_NORMAL_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Remark:|#R
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name: label
|
||||
callback:
|
||||
argument:
|
||||
|
||||
=============== FORM ===============
|
||||
Name: bibitem_form
|
||||
Width: 220
|
||||
|
250
forms/cite.fd
Normal file
250
forms/cite.fd
Normal file
@ -0,0 +1,250 @@
|
||||
Magic: 13000
|
||||
|
||||
Internal Form Definition File
|
||||
(do not change)
|
||||
|
||||
Number of forms: 1
|
||||
Unit of measure: FL_COORD_PIXEL
|
||||
|
||||
=============== FORM ===============
|
||||
Name: citation_form
|
||||
Width: 440
|
||||
Height: 790
|
||||
Number of Objects: 13
|
||||
|
||||
--------------------
|
||||
class: FL_BOX
|
||||
type: UP_BOX
|
||||
box: 0 0 440 790
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label:
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BROWSER
|
||||
type: HOLD_BROWSER
|
||||
box: 20 40 170 370
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_YELLOW
|
||||
alignment: FL_ALIGN_TOP_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Inset keys
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BROWSER
|
||||
type: HOLD_BROWSER
|
||||
box: 250 40 170 370
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_YELLOW
|
||||
alignment: FL_ALIGN_TOP_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Bibliography keys
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 200 40 40 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: @4->
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 200 90 40 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: @9+
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 200 140 40 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: @8->
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 200 190 40 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: @2->
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BROWSER
|
||||
type: NORMAL_BROWSER
|
||||
box: 20 440 400 110
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_YELLOW
|
||||
alignment: FL_ALIGN_TOP_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Info
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_CHOICE
|
||||
type: NORMAL_CHOICE
|
||||
box: 160 570 130 30
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_BLACK
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Citation style
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
type: NORMAL_INPUT
|
||||
box: 100 620 250 30
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_MCOL
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Text before
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_INPUT
|
||||
type: NORMAL_INPUT
|
||||
box: 100 660 250 30
|
||||
boxtype: FL_DOWN_BOX
|
||||
colors: FL_COL1 FL_MCOL
|
||||
alignment: FL_ALIGN_LEFT
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Text after
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: RETURN_BUTTON
|
||||
box: 190 730 110 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: OK
|
||||
shortcut: ^M
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
--------------------
|
||||
class: FL_BUTTON
|
||||
type: NORMAL_BUTTON
|
||||
box: 310 730 110 40
|
||||
boxtype: FL_UP_BOX
|
||||
colors: FL_COL1 FL_COL1
|
||||
alignment: FL_ALIGN_CENTER
|
||||
style: FL_NORMAL_STYLE
|
||||
size: FL_DEFAULT_SIZE
|
||||
lcol: FL_BLACK
|
||||
label: Cancel
|
||||
shortcut:
|
||||
resize: FL_RESIZE_ALL
|
||||
gravity: FL_NoGravity FL_NoGravity
|
||||
name:
|
||||
callback:
|
||||
argument:
|
||||
|
||||
==============================
|
||||
create_the_forms
|
@ -17,15 +17,15 @@ SHELL = /bin/sh
|
||||
# Various commands
|
||||
FDESIGN = fdesign
|
||||
|
||||
SRCS = bullet_forms.fd credits_form.fd form1.fd \
|
||||
SRCS = bullet_forms.fd cite.fd credits_form.fd form1.fd \
|
||||
latexoptions.fd layout_forms.fd lyx.fd lyx_sendfax.fd math_forms.fd \
|
||||
print_form.fd sp_form.fd
|
||||
|
||||
OBJS = bullet_forms.c credits_form.c form1.c \
|
||||
OBJS = bullet_forms.c cite.c credits_form.c form1.c \
|
||||
latexoptions.c layout_forms.c lyx.c lyx_sendfax.c math_forms.c \
|
||||
print_form.c sp_form.c
|
||||
|
||||
COBJS = bullet_forms.C credits_form.C form1.C \
|
||||
COBJS = bullet_forms.C cite.C credits_form.C form1.C \
|
||||
latexoptions.C layout_forms.C lyx.C lyx_sendfax.C math_forms.C \
|
||||
print_form.C sp_form.C
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2000-06-06 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* fr.po: update from Emmanuel
|
||||
|
||||
2000-06-06 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* de.po: updated
|
||||
|
@ -6,11 +6,20 @@
|
||||
/**** Forms and Objects ****/
|
||||
|
||||
typedef struct {
|
||||
FL_FORM *citation_form;
|
||||
FL_FORM *form;
|
||||
void *vdata;
|
||||
long ldata;
|
||||
FL_OBJECT *key;
|
||||
FL_OBJECT *label;
|
||||
FL_OBJECT *box;
|
||||
FL_OBJECT *citeBrsr;
|
||||
FL_OBJECT *bibBrsr;
|
||||
FL_OBJECT *infoBrsr;
|
||||
FL_OBJECT *textAftr;
|
||||
FL_OBJECT *addBtn;
|
||||
FL_OBJECT *delBtn;
|
||||
FL_OBJECT *upBtn;
|
||||
FL_OBJECT *downBtn;
|
||||
FL_OBJECT *ok;
|
||||
FL_OBJECT *cancel;
|
||||
} FD_citation_form;
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@ void fl_set_bmtable_file(FL_OBJECT * ob, int nx, int ny, char const * filename)
|
||||
|
||||
void fl_set_bmtable_pixmap_file(FL_OBJECT *ob, int nx, int ny, char const *filename)
|
||||
{
|
||||
//extern Colormap color_map;
|
||||
/* extern Colormap color_map; */
|
||||
BMTABLE_SPEC *sp = (BMTABLE_SPEC *)ob->spec;
|
||||
if (sp) {
|
||||
Pixmap dummy_shapemask = 0;
|
||||
@ -343,7 +343,7 @@ void fl_set_bmtable_pixmap_file(FL_OBJECT *ob, int nx, int ny, char const *filen
|
||||
XFreePixmap(fl_display, dummy_shapemask);
|
||||
}
|
||||
}
|
||||
//XFlush(fl_display);
|
||||
/* XFlush(fl_display); */
|
||||
}
|
||||
}
|
||||
|
||||
|
37
src/buffer.C
37
src/buffer.C
@ -60,6 +60,7 @@
|
||||
#include "insets/insetquotes.h"
|
||||
#include "insets/insetlatexaccent.h"
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insetcite.h"
|
||||
#include "insets/insetindex.h"
|
||||
#include "insets/insetinclude.h"
|
||||
#include "insets/insettoc.h"
|
||||
@ -3833,49 +3834,43 @@ vector<vector<Buffer::TocItem> > Buffer::getTocList()
|
||||
}
|
||||
|
||||
// This is also a buffer property (ale)
|
||||
string Buffer::getBibkeyList(char delim)
|
||||
vector<pair<string,string> > Buffer::getBibkeyList()
|
||||
{
|
||||
/// if this is a child document and the parent is already loaded
|
||||
/// Use the parent's list instead [ale990412]
|
||||
if (!params.parentname.empty() && bufferlist.exists(params.parentname)) {
|
||||
Buffer * tmp = bufferlist.getBuffer(params.parentname);
|
||||
if (tmp)
|
||||
return tmp->getBibkeyList(delim);
|
||||
return tmp->getBibkeyList();
|
||||
}
|
||||
|
||||
string bibkeys;
|
||||
vector<pair<string,string> > keys;
|
||||
LyXParagraph * par = paragraph;
|
||||
while (par) {
|
||||
if (par->bibkey) {
|
||||
if (!bibkeys.empty())
|
||||
bibkeys += delim;
|
||||
bibkeys += par->bibkey->getContents();
|
||||
}
|
||||
if (par->bibkey)
|
||||
keys.push_back(pair<string,string>(par->bibkey->getContents(),
|
||||
par->String(false)));
|
||||
par = par->next;
|
||||
}
|
||||
|
||||
// Might be either using bibtex or a child has bibliography
|
||||
if (bibkeys.empty()) {
|
||||
if (keys.empty()) {
|
||||
for (inset_iterator it = inset_iterator_begin();
|
||||
it != inset_iterator_end(); ++it) {
|
||||
it != inset_iterator_end(); ++it) {
|
||||
// Search for Bibtex or Include inset
|
||||
if ((*it)->LyxCode() == Inset::BIBTEX_CODE) {
|
||||
if (!bibkeys.empty())
|
||||
bibkeys += delim;
|
||||
bibkeys += static_cast<InsetBibtex *>(*it)->getKeys(delim);
|
||||
vector<pair<string,string> > tmp =
|
||||
static_cast<InsetBibtex*>(*it)->getKeys();
|
||||
keys.insert(keys.end(), tmp.begin(), tmp.end());
|
||||
} else if ((*it)->LyxCode() == Inset::INCLUDE_CODE) {
|
||||
string bk(static_cast<InsetInclude *>(*it)->getKeys(delim));
|
||||
if (!bk.empty()) {
|
||||
if (!bibkeys.empty())
|
||||
bibkeys += delim;
|
||||
bibkeys += bk;
|
||||
}
|
||||
vector<pair<string,string> > tmp =
|
||||
static_cast<InsetInclude*>(*it)->getKeys();
|
||||
keys.insert(keys.end(), tmp.begin(), tmp.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lyxerr.debug() << "Bibkeys(" << bibkeys << ")" << endl;
|
||||
return bibkeys;
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,7 +291,7 @@ public:
|
||||
///
|
||||
string getIncludeonlyList(char delim = ',');
|
||||
///
|
||||
string getBibkeyList(char delim = '|');
|
||||
std::vector<std::pair<string,string> > getBibkeyList();
|
||||
///
|
||||
struct TocItem {
|
||||
LyXParagraph * par;
|
||||
|
@ -16,6 +16,8 @@ libinsets_la_SOURCES = \
|
||||
inset.C \
|
||||
insetbib.C \
|
||||
insetbib.h \
|
||||
insetcite.C \
|
||||
insetcite.h \
|
||||
insetcollapsable.C \
|
||||
insetcollapsable.h \
|
||||
insetcommand.C \
|
||||
|
@ -24,48 +24,28 @@ using std::ostream;
|
||||
using std::ifstream;
|
||||
using std::getline;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
|
||||
extern BufferView * current_view;
|
||||
|
||||
FD_citation_form * citation_form = 0;
|
||||
FD_bibitem_form * bibitem_form = 0;
|
||||
static Combox * bibcombox = 0;
|
||||
|
||||
void BibitemUpdate(Combox *);
|
||||
FD_citation_form * create_form_citation_form(void);
|
||||
FD_bibitem_form * create_form_bibitem_form(void);
|
||||
|
||||
|
||||
extern "C" void bibitem_cb(FL_OBJECT *, long data)
|
||||
{
|
||||
switch (data) {
|
||||
case 1: // OK, citation
|
||||
{
|
||||
InsetCitation::Holder * holder =
|
||||
static_cast<InsetCitation::Holder*>
|
||||
(citation_form->citation_form->u_vdata);
|
||||
if(!holder->view->buffer()->isReadonly()) {
|
||||
|
||||
InsetCitation * inset = holder->inset;
|
||||
inset->setContents(bibcombox->getline());
|
||||
inset->setOptions(fl_get_input(citation_form->label));
|
||||
fl_hide_form(citation_form->citation_form);
|
||||
// shouldn't mark the buffer dirty unless something
|
||||
// was actually altered
|
||||
holder->view->updateInset(inset, true);
|
||||
break;
|
||||
}
|
||||
// fall through to Cancel on RO-mode
|
||||
}
|
||||
case 0: fl_hide_form(citation_form->citation_form);
|
||||
break;
|
||||
case 3: // OK, bibitem
|
||||
{
|
||||
switch (data)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
InsetBibKey::Holder * holder =
|
||||
static_cast<InsetBibKey::Holder*>
|
||||
(bibitem_form->bibitem_form->u_vdata);
|
||||
|
||||
if(!holder->view->buffer()->isReadonly()) {
|
||||
if(!holder->view->buffer()->isReadonly())
|
||||
{
|
||||
InsetBibKey * inset = holder->inset;
|
||||
inset->setContents(fl_get_input(bibitem_form->key));
|
||||
inset->setOptions(fl_get_input(bibitem_form->label));
|
||||
@ -75,46 +55,14 @@ extern "C" void bibitem_cb(FL_OBJECT *, long data)
|
||||
holder->view->update(1);
|
||||
break;
|
||||
} // fall through to Cancel on RO-mode
|
||||
}
|
||||
case 2: // Cancel, bibitem
|
||||
fl_hide_form(bibitem_form->bibitem_form); // Cancel, bibitem
|
||||
}
|
||||
case 0:
|
||||
fl_hide_form(bibitem_form->bibitem_form);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FD_citation_form * create_form_citation_form(void)
|
||||
{
|
||||
FL_OBJECT * obj;
|
||||
FD_citation_form * fdui = (FD_citation_form *) fl_calloc(1, sizeof(FD_citation_form));
|
||||
|
||||
fdui->citation_form = fl_bgn_form(FL_NO_BOX, 220, 130);
|
||||
obj = fl_add_box(FL_UP_BOX, 0, 0, 220, 130, "");
|
||||
fdui->key = obj = fl_add_text(FL_NORMAL_TEXT, 20, 10, 60, 30, _("Key:"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_lalign(obj, FL_ALIGN_RIGHT);
|
||||
|
||||
bibcombox = new Combox(FL_COMBOX_INPUT);
|
||||
bibcombox->add(80, 10, 130, 30, 300);
|
||||
|
||||
obj = fl_add_button(FL_RETURN_BUTTON, 20, 90, 90, 30, _("OK"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, bibitem_cb, 1);
|
||||
obj = fl_add_button(FL_NORMAL_BUTTON, 120, 90, 90, 30, idex(_("Cancel|^[")));
|
||||
fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, bibitem_cb, 0);
|
||||
fdui->label = obj = fl_add_input(FL_NORMAL_INPUT, 80, 50, 130, 30, idex(_("Remark:|#R")));
|
||||
fl_set_input_shortcut(obj, scex(_("Remark:|#R")), 1);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_end_form();
|
||||
|
||||
//fdui->citation_form->fdui = fdui;
|
||||
|
||||
return fdui;
|
||||
}
|
||||
/*---------------------------------------*/
|
||||
|
||||
FD_bibitem_form * create_form_bibitem_form(void)
|
||||
{
|
||||
FL_OBJECT * obj;
|
||||
@ -127,11 +75,11 @@ FD_bibitem_form * create_form_bibitem_form(void)
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
obj = fl_add_button(FL_RETURN_BUTTON, 20, 90, 90, 30, _("OK"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, bibitem_cb, 3);
|
||||
fl_set_object_callback(obj, bibitem_cb, 1);
|
||||
obj = fl_add_button(FL_NORMAL_BUTTON, 120, 90, 90, 30, idex(_("Cancel|^[")));
|
||||
fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, bibitem_cb, 2);
|
||||
fl_set_object_callback(obj, bibitem_cb, 0);
|
||||
fdui->label = obj = fl_add_input(FL_NORMAL_INPUT, 80, 50, 130, 30, idex(_("Label:|#L")));
|
||||
fl_set_input_shortcut(obj, scex(_("Label:|#L")), 1);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
@ -141,86 +89,19 @@ FD_bibitem_form * create_form_bibitem_form(void)
|
||||
|
||||
return fdui;
|
||||
}
|
||||
/*---------------------------------------*/
|
||||
|
||||
|
||||
InsetCitation::InsetCitation(string const & key, string const & note)
|
||||
: InsetCommand("cite", key, note)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
InsetCitation::~InsetCitation()
|
||||
{
|
||||
if(citation_form && citation_form->citation_form
|
||||
&& citation_form->citation_form->visible
|
||||
&& citation_form->citation_form->u_vdata == &holder)
|
||||
fl_hide_form(citation_form->citation_form);
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::Edit(BufferView * bv, int, int, unsigned int)
|
||||
{
|
||||
if(bv->buffer()->isReadonly())
|
||||
WarnReadonly(bv->buffer()->fileName());
|
||||
|
||||
if (!citation_form) {
|
||||
citation_form = create_form_citation_form();
|
||||
fl_set_form_atclose(citation_form->citation_form,
|
||||
CancelCloseBoxCB, 0);
|
||||
}
|
||||
|
||||
holder.inset = this;
|
||||
holder.view = bv;
|
||||
|
||||
citation_form->citation_form->u_vdata = &holder;
|
||||
|
||||
BibitemUpdate(bibcombox);
|
||||
if (!bibcombox->select_text(getContents().c_str()))
|
||||
bibcombox->addline(getContents().c_str());
|
||||
|
||||
fl_set_input(citation_form->label, getOptions().c_str());
|
||||
if (citation_form->citation_form->visible) {
|
||||
fl_raise_form(citation_form->citation_form);
|
||||
} else {
|
||||
fl_show_form(citation_form->citation_form,
|
||||
FL_PLACE_MOUSE, FL_FULLBORDER,
|
||||
_("Citation"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string InsetCitation::getScreenLabel() const
|
||||
{
|
||||
string temp("[");
|
||||
|
||||
temp += contents;
|
||||
|
||||
if (!options.empty()) {
|
||||
temp += ", " + options;
|
||||
}
|
||||
|
||||
return temp + ']';
|
||||
}
|
||||
|
||||
int InsetCitation::Ascii(ostream & os) const
|
||||
{
|
||||
os << getScreenLabel();;
|
||||
return 0;
|
||||
}
|
||||
|
||||
InsetBibKey::InsetBibKey(string const & key, string const & label):
|
||||
InsetCommand("bibitem", key, label)
|
||||
{
|
||||
counter = 1;
|
||||
if (key.empty())
|
||||
contents = ' ';
|
||||
setCmdName(" ");
|
||||
}
|
||||
|
||||
|
||||
InsetBibKey::InsetBibKey(InsetBibKey const * b):
|
||||
InsetCommand("bibitem", b->contents, b->options)
|
||||
InsetCommand("bibitem", b->getContents(), b->getOptions())
|
||||
{
|
||||
counter = b->counter;
|
||||
}
|
||||
@ -238,8 +119,8 @@ void InsetBibKey::setCounter(int c)
|
||||
{
|
||||
counter = c;
|
||||
|
||||
if (contents.empty())
|
||||
contents += tostr(counter);
|
||||
if (getCmdName().empty())
|
||||
setCmdName( tostr(counter) );
|
||||
}
|
||||
|
||||
|
||||
@ -250,19 +131,19 @@ void InsetBibKey::setCounter(int c)
|
||||
void InsetBibKey::Write(ostream & os) const
|
||||
{
|
||||
os << "\\bibitem ";
|
||||
if (!options.empty()) {
|
||||
if (! getOptions().empty()) {
|
||||
os << '['
|
||||
<< options << ']';
|
||||
<< getOptions() << ']';
|
||||
}
|
||||
os << '{'
|
||||
<< contents << "}\n";
|
||||
<< getContents() << "}\n";
|
||||
}
|
||||
|
||||
|
||||
string InsetBibKey::getScreenLabel() const
|
||||
{
|
||||
if (!options.empty())
|
||||
return options;
|
||||
if (! getOptions().empty())
|
||||
return getOptions();
|
||||
|
||||
return tostr(counter);
|
||||
}
|
||||
@ -306,7 +187,6 @@ void InsetBibKey::Edit(BufferView * bv, int, int, unsigned int)
|
||||
}
|
||||
|
||||
|
||||
|
||||
InsetBibtex::InsetBibtex(string const & dbase, string const & style,
|
||||
Buffer * o)
|
||||
: InsetCommand("BibTeX", dbase, style), owner(o)
|
||||
@ -370,7 +250,7 @@ int InsetBibtex::Latex(ostream & os,
|
||||
|
||||
|
||||
// This method returns a comma separated list of Bibtex entries
|
||||
string InsetBibtex::getKeys(char delim)
|
||||
vector<pair<string,string> > InsetBibtex::getKeys() const
|
||||
{
|
||||
// This hack is copied from InsetBibtex::Latex.
|
||||
// Is it still needed? Probably yes.
|
||||
@ -384,7 +264,8 @@ string InsetBibtex::getKeys(char delim)
|
||||
|
||||
Path p(owner->filepath);
|
||||
|
||||
string tmp, keys;
|
||||
vector<pair<string,string> > keys;
|
||||
string tmp;
|
||||
string bibfiles = getContents();
|
||||
bibfiles = split(bibfiles, tmp, ',');
|
||||
while(!tmp.empty()) {
|
||||
@ -398,23 +279,24 @@ string InsetBibtex::getKeys(char delim)
|
||||
// in @ and not being @preamble and @string entries.
|
||||
// It does NOT do any syntax checking!
|
||||
ifstream ifs(fil.c_str());
|
||||
string linebuf;
|
||||
while (getline(ifs, linebuf)) {
|
||||
linebuf = frontStrip(linebuf);
|
||||
string linebuf0;
|
||||
while (getline(ifs, linebuf0)) {
|
||||
string linebuf = frontStrip(strip(linebuf0));
|
||||
if( linebuf.empty() ) continue;
|
||||
if (prefixIs(linebuf, "@")) {
|
||||
linebuf = subst(linebuf, '{', '(');
|
||||
linebuf = split(linebuf, tmp, '(');
|
||||
tmp = lowercase(tmp);
|
||||
if (!prefixIs(tmp, "@string")
|
||||
&& !prefixIs(tmp, "@preamble")) {
|
||||
linebuf = split(linebuf,
|
||||
tmp, ',');
|
||||
tmp = frontStrip(strip(tmp));
|
||||
linebuf = split(linebuf, tmp, ',');
|
||||
tmp = frontStrip(tmp);
|
||||
if (!tmp.empty()) {
|
||||
keys += tmp;
|
||||
keys += delim;
|
||||
keys.push_back(pair<string,string>(tmp,string()));
|
||||
}
|
||||
}
|
||||
} else if( !keys.empty() ) {
|
||||
keys.back().second += linebuf + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -454,10 +336,10 @@ void InsetBibtex::Edit(BufferView * bv, int, int, unsigned int)
|
||||
|
||||
bool InsetBibtex::addDatabase(string const & db)
|
||||
{
|
||||
if (!contains(contents, db.c_str())) {
|
||||
if (!contents.empty())
|
||||
contents += ',';
|
||||
contents += db;
|
||||
if (!contains(getContents(), db.c_str())) {
|
||||
if (!getContents().empty())
|
||||
addContents(",");
|
||||
addContents(db);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -466,16 +348,16 @@ bool InsetBibtex::addDatabase(string const & db)
|
||||
|
||||
bool InsetBibtex::delDatabase(string const & db)
|
||||
{
|
||||
if (contains(contents, db.c_str())) {
|
||||
if (contains(getContents(), db.c_str())) {
|
||||
string bd = db;
|
||||
int n = tokenPos(contents, ',', bd);
|
||||
int n = tokenPos(getContents(), ',', bd);
|
||||
if (n > 0) {
|
||||
// Weird code, would someone care to explain this?(Lgb)
|
||||
string tmp(", ");
|
||||
tmp += bd;
|
||||
contents = subst(contents, tmp.c_str(), ", ");
|
||||
setContents(subst(getContents(), tmp.c_str(), ", "));
|
||||
} else if (n == 0)
|
||||
contents = split(contents, bd, ',');
|
||||
setContents(split(getContents(), bd, ','));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -483,23 +365,6 @@ bool InsetBibtex::delDatabase(string const & db)
|
||||
}
|
||||
|
||||
|
||||
// This function should be in LyXView when multiframe works ale970302
|
||||
void BibitemUpdate(Combox * combox)
|
||||
{
|
||||
combox->clear();
|
||||
|
||||
if (!current_view->available()) return;
|
||||
|
||||
string tmp, bibkeys = current_view->buffer()->getBibkeyList(',');
|
||||
bibkeys = split(bibkeys, tmp,',');
|
||||
while (!tmp.empty()) {
|
||||
combox->addto(tmp.c_str());
|
||||
bibkeys = split(bibkeys, tmp,',');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ale070405 This function maybe shouldn't be here. We'll fix this at 0.13.
|
||||
int bibitemMaxWidth(Painter & pain, LyXFont const & font)
|
||||
{
|
||||
@ -519,7 +384,7 @@ int bibitemMaxWidth(Painter & pain, LyXFont const & font)
|
||||
|
||||
|
||||
// ale070405
|
||||
string bibitemWidthest(Painter & pain)
|
||||
string bibitemWidest(Painter & pain)
|
||||
{
|
||||
int w = 0;
|
||||
// Does look like a hack? It is! (but will change at 0.13)
|
||||
|
@ -17,45 +17,10 @@
|
||||
#endif
|
||||
|
||||
#include "insetcommand.h"
|
||||
#include <vector>
|
||||
|
||||
class Buffer;
|
||||
|
||||
/** Used to insert citations
|
||||
*/
|
||||
class InsetCitation: public InsetCommand {
|
||||
public:
|
||||
///
|
||||
InsetCitation() : InsetCommand("cite") {}
|
||||
///
|
||||
explicit
|
||||
InsetCitation(string const & key, string const & note = string());
|
||||
///
|
||||
~InsetCitation();
|
||||
///
|
||||
Inset * Clone() const {
|
||||
return new InsetCitation(contents, options);
|
||||
}
|
||||
///
|
||||
string getScreenLabel()const;
|
||||
///
|
||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||
///
|
||||
EDITABLE Editable() const {
|
||||
return IS_EDITABLE;
|
||||
}
|
||||
int Ascii(std::ostream &) const;
|
||||
///
|
||||
struct Holder {
|
||||
InsetCitation * inset;
|
||||
BufferView * view;
|
||||
};
|
||||
|
||||
private:
|
||||
///
|
||||
Holder holder;
|
||||
};
|
||||
|
||||
|
||||
/** Used to insert bibitem's information (key and label)
|
||||
|
||||
Must be automatically inserted as the first object in a
|
||||
@ -122,7 +87,7 @@ public:
|
||||
|
||||
///
|
||||
Inset * Clone() const {
|
||||
return new InsetBibtex(contents, options, 0);
|
||||
return new InsetBibtex(getCmdName(), getOptions(), 0);
|
||||
}
|
||||
///
|
||||
Inset::Code LyxCode() const
|
||||
@ -136,7 +101,7 @@ public:
|
||||
///
|
||||
int Latex(std::ostream &, bool fragile, bool freespace) const;
|
||||
///
|
||||
string getKeys(char delim);
|
||||
std::vector< std::pair<string,string> > getKeys() const;
|
||||
///
|
||||
EDITABLE Editable() const {
|
||||
return IS_EDITABLE;
|
||||
|
483
src/insets/insetcite.C
Normal file
483
src/insets/insetcite.C
Normal file
@ -0,0 +1,483 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include FORMS_H_LOCATION
|
||||
#include "insetcite.h"
|
||||
#include "buffer.h"
|
||||
#include "debug.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "BufferView.h"
|
||||
#include "gettext.h"
|
||||
#include "lyxtext.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
using std::getline;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::max;
|
||||
using std::min;
|
||||
using std::find;
|
||||
|
||||
FD_citation_form * citation_form = 0;
|
||||
FD_citation_form * create_form_citation_form(void);
|
||||
void set_size_citation_form(FD_citation_form *, int, bool);
|
||||
|
||||
static vector<pair<string,string> > bibkeys_info;
|
||||
static vector<string> bibkeys;
|
||||
static vector<string> insetkeys;
|
||||
|
||||
extern "C" void citation_cb( FL_OBJECT *, long data )
|
||||
{
|
||||
InsetCitation::Holder * holder =
|
||||
static_cast<InsetCitation::Holder*>(citation_form->form->u_vdata);
|
||||
|
||||
holder->inset->callback( citation_form,
|
||||
static_cast<InsetCitation::State>(data) );
|
||||
}
|
||||
|
||||
|
||||
FD_citation_form * create_form_citation_form(void)
|
||||
{
|
||||
FL_OBJECT * obj;
|
||||
FD_citation_form * fdui = (FD_citation_form *) fl_calloc(1, sizeof(*fdui));
|
||||
|
||||
// NOTE: dialog geometry is set in setSize().
|
||||
// Initial size is simply non-zero.
|
||||
fdui->form = fl_bgn_form(FL_NO_BOX, 10, 10);
|
||||
fdui->box = obj = fl_add_box(FL_UP_BOX, 0, 0, 10, 10, "");
|
||||
|
||||
fdui->citeBrsr = obj =
|
||||
fl_add_browser(FL_HOLD_BROWSER, 0, 0, 10, 10, _("Citation keys"));
|
||||
fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::CITEBRSR);
|
||||
|
||||
fdui->bibBrsr = obj =
|
||||
fl_add_browser(FL_HOLD_BROWSER, 0, 0, 10, 10, _("Bibliography keys"));
|
||||
fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::BIBBRSR);
|
||||
|
||||
fdui->addBtn = obj =
|
||||
fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@4->");
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::ADD);
|
||||
|
||||
fdui->delBtn = obj =
|
||||
fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@9+");
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::DELETE);
|
||||
|
||||
fdui->upBtn = obj =
|
||||
fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@8->");
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::UP);
|
||||
|
||||
fdui->downBtn = obj =
|
||||
fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, "@2->");
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::DOWN);
|
||||
|
||||
fdui->infoBrsr = obj =
|
||||
fl_add_browser(FL_NORMAL_BROWSER, 0, 0, 10, 10, _("Info"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE) ;
|
||||
fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
|
||||
|
||||
fdui->textAftr = obj =
|
||||
fl_add_input(FL_NORMAL_INPUT, 0, 0, 10, 10, _("Text after"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
|
||||
fdui->ok = obj =
|
||||
fl_add_button(FL_RETURN_BUTTON, 0, 0, 10, 10, _("OK"));
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::OK);
|
||||
|
||||
fdui->cancel = obj =
|
||||
fl_add_button(FL_NORMAL_BUTTON, 0, 0, 10, 10, idex(_("Cancel|^[")));
|
||||
fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
|
||||
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
|
||||
fl_set_object_callback(obj, citation_cb, InsetCitation::CANCEL);
|
||||
|
||||
fl_end_form();
|
||||
|
||||
return fdui;
|
||||
}
|
||||
|
||||
|
||||
InsetCitation::InsetCitation(string const & key, string const & note)
|
||||
: InsetCommand("cite", key, note)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
InsetCitation::~InsetCitation()
|
||||
{
|
||||
if(citation_form && citation_form->form
|
||||
&& citation_form->form->visible
|
||||
&& citation_form->form->u_vdata == &holder)
|
||||
fl_hide_form(citation_form->form);
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::Edit( BufferView * bv, int, int, unsigned int )
|
||||
{
|
||||
if ( !citation_form ) {
|
||||
citation_form = create_form_citation_form();
|
||||
fl_set_form_atclose( citation_form->form,
|
||||
CancelCloseBoxCB, 0 );
|
||||
}
|
||||
|
||||
holder.inset = this;
|
||||
holder.view = bv;
|
||||
|
||||
citation_form->form->u_vdata = &holder;
|
||||
|
||||
// update the browsers, noting the number of keys.
|
||||
bibkeys_info = bv->buffer()->getBibkeyList();
|
||||
bibkeys.clear();
|
||||
insetkeys.clear();
|
||||
for( unsigned int i = 0; i < bibkeys_info.size(); ++i )
|
||||
bibkeys.push_back(bibkeys_info[i].first);
|
||||
|
||||
string tmp;
|
||||
string keys = getContents();
|
||||
keys = frontStrip( split(keys, tmp, ',') );
|
||||
while( !tmp.empty() ) {
|
||||
insetkeys.push_back( tmp );
|
||||
keys = frontStrip( split(keys, tmp, ',') );
|
||||
}
|
||||
|
||||
updateBrowser( citation_form->bibBrsr, bibkeys );
|
||||
updateBrowser( citation_form->citeBrsr, insetkeys );
|
||||
fl_clear_browser( citation_form->infoBrsr );
|
||||
|
||||
// No keys have been selected yet, so...
|
||||
setBibButtons( citation_form, OFF );
|
||||
setCiteButtons( citation_form, OFF );
|
||||
|
||||
int noKeys = max( bibkeys.size(), insetkeys.size() );
|
||||
|
||||
// Place bounds, so that 4 <= noKeys <= 15
|
||||
noKeys = max( 4, min(15, noKeys) );
|
||||
|
||||
// Re-size the form to accommodate the new browser size
|
||||
int size = 20 * noKeys;
|
||||
bool bibPresent = ( bibkeys.size() > 0 );
|
||||
setSize(citation_form, size, bibPresent);
|
||||
|
||||
fl_set_input( citation_form->textAftr, getOptions().c_str() );
|
||||
if( holder.view->buffer()->isReadonly() )
|
||||
fl_deactivate_object( citation_form->textAftr );
|
||||
|
||||
if( citation_form->form->visible ) {
|
||||
fl_raise_form( citation_form->form );
|
||||
} else {
|
||||
fl_show_form( citation_form->form,
|
||||
FL_PLACE_MOUSE, FL_FULLBORDER,
|
||||
_("Citation") );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::updateBrowser( FL_OBJECT * browser,
|
||||
vector<string> const & inkeys ) const
|
||||
{
|
||||
fl_clear_browser( browser );
|
||||
|
||||
fl_freeze_form( browser->form );
|
||||
for( unsigned int i = 0; i < inkeys.size(); ++i )
|
||||
fl_add_browser_line( browser, inkeys[i].c_str() );
|
||||
fl_unfreeze_form( browser->form );
|
||||
}
|
||||
|
||||
void InsetCitation::callback( FD_citation_form * form, State cb )
|
||||
{
|
||||
switch( cb ) {
|
||||
case BIBBRSR: {
|
||||
fl_deselect_browser( form->citeBrsr );
|
||||
|
||||
unsigned int sel = fl_get_browser( form->bibBrsr );
|
||||
if( sel < 1 || sel > bibkeys.size() ) break;
|
||||
|
||||
// Put into infoBrsr the additional info associated with
|
||||
// the selected bibBrsr key
|
||||
fl_clear_browser( form->infoBrsr );
|
||||
fl_add_browser_line( form->infoBrsr,
|
||||
bibkeys_info[sel-1].second.c_str() );
|
||||
|
||||
// Highlight the selected bibBrsr key in citeBrsr if present
|
||||
vector<string>::iterator it =
|
||||
find( insetkeys.begin(), insetkeys.end(), bibkeys[sel-1] );
|
||||
|
||||
if( it != insetkeys.end() ) {
|
||||
int n = it - insetkeys.begin();
|
||||
fl_select_browser_line( form->citeBrsr, n+1 );
|
||||
fl_set_browser_topline( form->citeBrsr, n+1 );
|
||||
}
|
||||
|
||||
if( !holder.view->buffer()->isReadonly() ) {
|
||||
if( it != insetkeys.end() ) {
|
||||
setBibButtons( form, OFF );
|
||||
setCiteButtons( form, ON );
|
||||
} else {
|
||||
setBibButtons( form, ON );
|
||||
setCiteButtons( form, OFF );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
} case CITEBRSR: {
|
||||
unsigned int sel = fl_get_browser( form->citeBrsr );
|
||||
if( sel < 1 || sel > insetkeys.size() ) break;
|
||||
|
||||
if( !holder.view->buffer()->isReadonly() ) {
|
||||
setBibButtons( form, OFF );
|
||||
setCiteButtons( form, ON );
|
||||
}
|
||||
|
||||
// Highlight the selected citeBrsr key in bibBrsr
|
||||
vector<string>::iterator it =
|
||||
find( bibkeys.begin(), bibkeys.end(), insetkeys[sel-1] );
|
||||
|
||||
if (it != bibkeys.end()) {
|
||||
int n = it - bibkeys.begin();
|
||||
fl_select_browser_line( form->bibBrsr, n+1 );
|
||||
fl_set_browser_topline( form->bibBrsr, n+1 );
|
||||
|
||||
// Put into infoBrsr the additional info associated with
|
||||
// the selected citeBrsr key
|
||||
fl_clear_browser( form->infoBrsr );
|
||||
fl_add_browser_line( form->infoBrsr,
|
||||
bibkeys_info[n].second.c_str() );
|
||||
}
|
||||
break;
|
||||
|
||||
} case ADD: {
|
||||
if( holder.view->buffer()->isReadonly() ) break;
|
||||
|
||||
unsigned int sel = fl_get_browser( form->bibBrsr );
|
||||
if( sel < 1 || sel > bibkeys.size() ) break;
|
||||
|
||||
// Add the selected bibBrsr key to citeBrsr
|
||||
fl_addto_browser( form->citeBrsr,
|
||||
bibkeys[sel-1].c_str() );
|
||||
insetkeys.push_back( bibkeys[sel-1] );
|
||||
|
||||
int n = insetkeys.size();
|
||||
fl_select_browser_line( form->citeBrsr, n );
|
||||
|
||||
setBibButtons( form, OFF );
|
||||
setCiteButtons( form, ON );
|
||||
|
||||
break;
|
||||
|
||||
} case DELETE: {
|
||||
if( holder.view->buffer()->isReadonly() ) break;
|
||||
|
||||
unsigned int sel = fl_get_browser( form->citeBrsr );
|
||||
if( sel < 1 || sel > insetkeys.size() ) break;
|
||||
|
||||
// Remove the selected key from citeBrsr
|
||||
fl_delete_browser_line( form->citeBrsr, sel ) ;
|
||||
insetkeys.erase( insetkeys.begin() + sel-1 );
|
||||
|
||||
setBibButtons( form, ON );
|
||||
setCiteButtons( form, OFF );
|
||||
break;
|
||||
|
||||
} case UP: {
|
||||
if( holder.view->buffer()->isReadonly() ) break;
|
||||
|
||||
unsigned int sel = fl_get_browser( form->citeBrsr );
|
||||
if( sel < 2 || sel > insetkeys.size() ) break;
|
||||
|
||||
// Move the selected key up one line
|
||||
vector<string>::iterator it = insetkeys.begin() + sel-1;
|
||||
string tmp = *it;
|
||||
|
||||
fl_delete_browser_line( form->citeBrsr, sel );
|
||||
insetkeys.erase( it );
|
||||
|
||||
fl_insert_browser_line( form->citeBrsr, sel-1, tmp.c_str() );
|
||||
fl_select_browser_line( form->citeBrsr, sel-1 );
|
||||
insetkeys.insert( it-1, tmp );
|
||||
setCiteButtons( form, ON );
|
||||
|
||||
break;
|
||||
|
||||
} case DOWN: {
|
||||
if( holder.view->buffer()->isReadonly() ) break;
|
||||
|
||||
unsigned int sel = fl_get_browser( form->citeBrsr );
|
||||
if( sel < 1 || sel > insetkeys.size()-1 ) break;
|
||||
|
||||
// Move the selected key down one line
|
||||
vector<string>::iterator it = insetkeys.begin() + sel-1;
|
||||
string tmp = *it;
|
||||
|
||||
fl_delete_browser_line( form->citeBrsr, sel );
|
||||
insetkeys.erase( it );
|
||||
|
||||
fl_insert_browser_line( form->citeBrsr, sel+1, tmp.c_str() );
|
||||
fl_select_browser_line( form->citeBrsr, sel+1 );
|
||||
insetkeys.insert( it+1, tmp );
|
||||
setCiteButtons( form, ON );
|
||||
|
||||
break;
|
||||
|
||||
} case OK: {
|
||||
// The inset contains a comma separated list of the keys
|
||||
// in citeBrsr
|
||||
if( !holder.view->buffer()->isReadonly() )
|
||||
{
|
||||
string tmp;
|
||||
for( unsigned int i = 0; i < insetkeys.size(); ++i ) {
|
||||
if (i > 0)
|
||||
tmp += ", ";
|
||||
tmp += insetkeys[i];
|
||||
}
|
||||
setContents( tmp );
|
||||
setOptions( fl_get_input(form->textAftr) );
|
||||
// shouldn't mark the buffer dirty unless something
|
||||
// was actually altered
|
||||
holder.view->updateInset( this, true );
|
||||
}
|
||||
// fall through to Cancel
|
||||
|
||||
} case CANCEL: {
|
||||
fl_hide_form( form->form );
|
||||
break;
|
||||
|
||||
} default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::setSize( FD_citation_form * form,
|
||||
int brsrHeight, bool bibPresent ) const
|
||||
{
|
||||
int const infoHeight = 110;
|
||||
int const otherHeight = 140;
|
||||
brsrHeight = max( brsrHeight, 175 );
|
||||
int formHeight = brsrHeight + otherHeight;
|
||||
|
||||
if( bibPresent ) formHeight += infoHeight + 30;
|
||||
fl_set_form_size( form->form, 430, formHeight );
|
||||
|
||||
int ypos = 0;
|
||||
fl_set_object_geometry( form->box, 0, ypos, 430, formHeight );
|
||||
ypos += 30;
|
||||
fl_set_object_geometry( form->citeBrsr, 10, ypos, 180, brsrHeight );
|
||||
fl_set_object_geometry( form->bibBrsr, 240, ypos, 180, brsrHeight );
|
||||
fl_set_object_geometry( form->addBtn, 200, ypos, 30, 30 );
|
||||
ypos += 35;
|
||||
fl_set_object_geometry( form->delBtn, 200, ypos, 30, 30 );
|
||||
ypos += 35;
|
||||
fl_set_object_geometry( form->upBtn, 200, ypos, 30, 30 );
|
||||
ypos += 35;
|
||||
fl_set_object_geometry( form->downBtn, 200, ypos, 30, 30 );
|
||||
|
||||
ypos = brsrHeight+30; // base of Citation/Bibliography browsers
|
||||
|
||||
if( bibPresent ) {
|
||||
ypos += 30;
|
||||
fl_set_object_geometry( form->infoBrsr, 10, ypos, 410, infoHeight );
|
||||
fl_show_object( form->infoBrsr );
|
||||
ypos += infoHeight;
|
||||
}
|
||||
else
|
||||
fl_hide_object( form->infoBrsr );
|
||||
|
||||
ypos += 20;
|
||||
fl_set_object_geometry( form->textAftr, 100, ypos, 250, 30 );
|
||||
fl_set_object_geometry( form->ok, 230, ypos+50, 90, 30 );
|
||||
fl_set_object_geometry( form->cancel, 330, ypos+50, 90, 30 );
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::setBibButtons( FD_citation_form * form, State status ) const
|
||||
{
|
||||
switch (status) {
|
||||
case ON:
|
||||
{
|
||||
fl_activate_object( form->addBtn );
|
||||
fl_set_object_lcol( form->addBtn, FL_BLACK );
|
||||
|
||||
break;
|
||||
}
|
||||
case OFF:
|
||||
{
|
||||
fl_deactivate_object( form->addBtn );
|
||||
fl_set_object_lcol( form->addBtn, FL_INACTIVE );
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetCitation::setCiteButtons( FD_citation_form * form, State status ) const
|
||||
{
|
||||
switch( status ) {
|
||||
case ON:
|
||||
{
|
||||
fl_activate_object( form->delBtn );
|
||||
fl_set_object_lcol( form->delBtn, FL_BLACK );
|
||||
|
||||
unsigned int sel = fl_get_browser( form->citeBrsr );
|
||||
|
||||
if( sel != 1 ) {
|
||||
fl_activate_object( form->upBtn );
|
||||
fl_set_object_lcol( form->upBtn, FL_BLACK );
|
||||
} else {
|
||||
fl_deactivate_object( form->upBtn );
|
||||
fl_set_object_lcol( form->upBtn, FL_INACTIVE );
|
||||
}
|
||||
|
||||
if( sel != fl_get_browser_maxline( form->citeBrsr ) ) {
|
||||
fl_activate_object( form->downBtn );
|
||||
fl_set_object_lcol( form->downBtn, FL_BLACK );
|
||||
} else {
|
||||
fl_deactivate_object( form->downBtn );
|
||||
fl_set_object_lcol( form->downBtn, FL_INACTIVE );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case OFF:
|
||||
{
|
||||
fl_deactivate_object( form->delBtn );
|
||||
fl_set_object_lcol( form->delBtn, FL_INACTIVE );
|
||||
|
||||
fl_deactivate_object( form->upBtn );
|
||||
fl_set_object_lcol( form->upBtn, FL_INACTIVE );
|
||||
|
||||
fl_deactivate_object( form->downBtn );
|
||||
fl_set_object_lcol( form->downBtn, FL_INACTIVE );
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string InsetCitation::getScreenLabel() const
|
||||
{
|
||||
string temp("[");
|
||||
|
||||
temp += getContents();
|
||||
|
||||
if( !getOptions().empty() ) {
|
||||
temp += ", " + getOptions();
|
||||
}
|
||||
|
||||
return temp + ']';
|
||||
}
|
82
src/insets/insetcite.h
Normal file
82
src/insets/insetcite.h
Normal file
@ -0,0 +1,82 @@
|
||||
// -*- C++ -*-
|
||||
/* This file is part of*
|
||||
* ======================================================
|
||||
*
|
||||
* LyX, The Document Processor
|
||||
*
|
||||
* Copyright 1995 Matthias Ettrich
|
||||
* Copyright 1995-2000 The LyX Team.
|
||||
*
|
||||
* ====================================================== */
|
||||
|
||||
#ifndef INSET_CITE_H
|
||||
#define INSET_CITE_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "insetcommand.h"
|
||||
#include "bibforms.h"
|
||||
#include <vector>
|
||||
|
||||
class Buffer;
|
||||
|
||||
/** Used to insert citations
|
||||
*/
|
||||
class InsetCitation: public InsetCommand {
|
||||
public:
|
||||
///
|
||||
enum State {
|
||||
CANCEL,
|
||||
OK,
|
||||
DOWN,
|
||||
UP,
|
||||
DELETE,
|
||||
ADD,
|
||||
BIBBRSR,
|
||||
CITEBRSR,
|
||||
ON,
|
||||
OFF
|
||||
};
|
||||
///
|
||||
InsetCitation() : InsetCommand("cite") {}
|
||||
///
|
||||
explicit
|
||||
InsetCitation(string const & key, string const & note = string());
|
||||
///
|
||||
~InsetCitation();
|
||||
///
|
||||
Inset * Clone() const {
|
||||
return new InsetCitation(getContents(), getOptions());
|
||||
}
|
||||
///
|
||||
string getScreenLabel()const;
|
||||
///
|
||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||
///
|
||||
void callback( FD_citation_form *, State );
|
||||
///
|
||||
EDITABLE Editable() const {
|
||||
return IS_EDITABLE;
|
||||
}
|
||||
///
|
||||
struct Holder {
|
||||
InsetCitation * inset;
|
||||
BufferView * view;
|
||||
};
|
||||
|
||||
private:
|
||||
///
|
||||
void setSize( FD_citation_form *, int, bool ) const;
|
||||
///
|
||||
void setBibButtons( FD_citation_form *, State ) const;
|
||||
///
|
||||
void setCiteButtons( FD_citation_form *, State ) const;
|
||||
///
|
||||
void updateBrowser( FL_OBJECT *, std::vector<string> const & ) const;
|
||||
///
|
||||
Holder holder;
|
||||
};
|
||||
|
||||
#endif // INSET_CITE_H
|
@ -29,7 +29,7 @@ InsetCommand::InsetCommand()
|
||||
|
||||
InsetCommand::InsetCommand(string const & cmd, string const & arg,
|
||||
string const & opt)
|
||||
: command(cmd), options(opt), contents(arg)
|
||||
: cmdname(cmd), options(opt), contents(arg)
|
||||
{
|
||||
}
|
||||
|
||||
@ -125,46 +125,46 @@ void InsetCommand::Write(ostream & os) const
|
||||
|
||||
void InsetCommand::scanCommand(string const & cmd)
|
||||
{
|
||||
string tcommand, toptions, tcontents;
|
||||
string tcmdname, toptions, tcontents;
|
||||
|
||||
if (cmd.empty()) return;
|
||||
|
||||
enum { WS, Command, Option, Content } state = WS;
|
||||
enum { WS, CMDNAME, OPTION, CONTENT } state = WS;
|
||||
|
||||
// Used to handle things like \command[foo[bar]]{foo{bar}}
|
||||
int nestdepth = 0;
|
||||
|
||||
for (string::size_type i = 0; i < cmd.length(); ++i) {
|
||||
char c = cmd[i];
|
||||
if ((state == Command && c == ' ') ||
|
||||
(state == Command && c == '[') ||
|
||||
(state == Command && c == '{')) {
|
||||
if ((state == CMDNAME && c == ' ') ||
|
||||
(state == CMDNAME && c == '[') ||
|
||||
(state == CMDNAME && c == '{')) {
|
||||
state = WS;
|
||||
}
|
||||
if ((state == Option && c == ']') ||
|
||||
(state == Content && c == '}')) {
|
||||
if ((state == OPTION && c == ']') ||
|
||||
(state == CONTENT && c == '}')) {
|
||||
if (nestdepth == 0) {
|
||||
state = WS;
|
||||
} else {
|
||||
--nestdepth;
|
||||
}
|
||||
}
|
||||
if ((state == Option && c == '[') ||
|
||||
(state == Content && c == '{')) {
|
||||
if ((state == OPTION && c == '[') ||
|
||||
(state == CONTENT && c == '{')) {
|
||||
++nestdepth;
|
||||
}
|
||||
switch (state) {
|
||||
case Command: tcommand += c; break;
|
||||
case Option: toptions += c; break;
|
||||
case Content: tcontents += c; break;
|
||||
case CMDNAME: tcmdname += c; break;
|
||||
case OPTION: toptions += c; break;
|
||||
case CONTENT: tcontents += c; break;
|
||||
case WS:
|
||||
if (c == '\\') {
|
||||
state = Command;
|
||||
state = CMDNAME;
|
||||
} else if (c == '[') {
|
||||
state = Option;
|
||||
state = OPTION;
|
||||
nestdepth = 0; // Just to be sure
|
||||
} else if (c == '{') {
|
||||
state = Content;
|
||||
state = CONTENT;
|
||||
nestdepth = 0; // Just to be sure
|
||||
}
|
||||
break;
|
||||
@ -172,7 +172,7 @@ void InsetCommand::scanCommand(string const & cmd)
|
||||
}
|
||||
|
||||
// Don't mess with this.
|
||||
if (!tcommand.empty()) command = tcommand;
|
||||
if (!tcmdname.empty()) cmdname = tcmdname;
|
||||
if (!toptions.empty()) options = toptions;
|
||||
if (!tcontents.empty()) setContents(tcontents);
|
||||
// setContents is overloaded in InsetInclude
|
||||
@ -224,14 +224,14 @@ int InsetCommand::DocBook(ostream &) const
|
||||
|
||||
Inset * InsetCommand::Clone() const
|
||||
{
|
||||
return new InsetCommand(command, contents, options);
|
||||
return new InsetCommand(cmdname, contents, options);
|
||||
}
|
||||
|
||||
|
||||
string InsetCommand::getCommand() const
|
||||
{
|
||||
string s;
|
||||
if (!command.empty()) s += "\\"+command;
|
||||
if (!cmdname.empty()) s += "\\"+cmdname;
|
||||
if (!options.empty()) s += "["+options+']';
|
||||
s += "{"+contents+'}';
|
||||
return s;
|
||||
|
@ -74,12 +74,12 @@ public:
|
||||
{
|
||||
return getCommand();
|
||||
}
|
||||
|
||||
|
||||
/// Build the complete LaTeX command
|
||||
string getCommand() const;
|
||||
///
|
||||
string const & getCmdName() const {
|
||||
return command;
|
||||
return cmdname;
|
||||
}
|
||||
///
|
||||
string const & getOptions() const {
|
||||
@ -91,7 +91,7 @@ public:
|
||||
}
|
||||
///
|
||||
void setCmdName(string const & n) {
|
||||
command = n;
|
||||
cmdname = n;
|
||||
}
|
||||
///
|
||||
void setOptions(string const & o) {
|
||||
@ -101,9 +101,13 @@ public:
|
||||
virtual void setContents(string const & c) {
|
||||
contents = c;
|
||||
}
|
||||
protected:
|
||||
///
|
||||
void addContents(string const & c) {
|
||||
contents += c;
|
||||
}
|
||||
private:
|
||||
///
|
||||
string command;
|
||||
string cmdname;
|
||||
///
|
||||
string options;
|
||||
///
|
||||
|
@ -26,6 +26,7 @@
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
|
||||
extern BufferView * current_view;
|
||||
|
||||
@ -216,7 +217,7 @@ InsetInclude::~InsetInclude()
|
||||
|
||||
Inset * InsetInclude::Clone() const
|
||||
{
|
||||
InsetInclude * ii = new InsetInclude (contents, master);
|
||||
InsetInclude * ii = new InsetInclude (getContents(), master);
|
||||
ii->setNoLoad(isNoLoad());
|
||||
// By default, the newly created inset is of `include' type,
|
||||
// so we do not test this case.
|
||||
@ -241,7 +242,7 @@ void InsetInclude::Edit(BufferView * bv, int, int, unsigned int)
|
||||
}
|
||||
form->include->u_vdata = this;
|
||||
|
||||
fl_set_input(form->input, contents.c_str());
|
||||
fl_set_input(form->input, getContents().c_str());
|
||||
fl_set_button(form->flag1, int(isNoLoad()));
|
||||
fl_set_button(form->flag2, int(isInput()));
|
||||
fl_set_button(form->flag3, int(isInclude()));
|
||||
@ -302,10 +303,10 @@ string InsetInclude::getScreenLabel() const
|
||||
} else temp += _("Include");
|
||||
temp += ": ";
|
||||
|
||||
if (contents.empty()) {
|
||||
if (getContents().empty()) {
|
||||
temp+= "???";
|
||||
} else {
|
||||
temp+= contents;
|
||||
temp+= getContents();
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
@ -314,7 +315,7 @@ string InsetInclude::getScreenLabel() const
|
||||
void InsetInclude::setContents(string const & c)
|
||||
{
|
||||
InsetCommand::setContents(c);
|
||||
filename = MakeAbsPath(contents,
|
||||
filename = MakeAbsPath(getContents(),
|
||||
OnlyPath(getMasterFilename()));
|
||||
}
|
||||
|
||||
@ -337,12 +338,12 @@ int InsetInclude::Latex(ostream & os,
|
||||
bool /*fragile*/, bool /*fs*/) const
|
||||
{
|
||||
// Do nothing if no file name has been specified
|
||||
if (contents.empty())
|
||||
if (getContents().empty())
|
||||
return 0;
|
||||
|
||||
// Use += to force a copy of contents (JMarc)
|
||||
// How does that force anything? (Lgb)
|
||||
string incfile(contents);
|
||||
string incfile(getContents());
|
||||
|
||||
if (loadIfNeeded()) {
|
||||
Buffer * tmp = bufferlist.getBuffer(getFileName());
|
||||
@ -381,21 +382,21 @@ int InsetInclude::Latex(ostream & os,
|
||||
}
|
||||
|
||||
if (isVerb()) {
|
||||
os << '\\' << command << '{' << incfile << '}';
|
||||
os << '\\' << getCmdName() << '{' << incfile << '}';
|
||||
}
|
||||
else if (isInput()) {
|
||||
// \input wants file with extension (default is .tex)
|
||||
if (!IsLyXFilename(getFileName())) {
|
||||
os << '\\' << command << '{' << incfile << '}';
|
||||
os << '\\' << getCmdName() << '{' << incfile << '}';
|
||||
} else {
|
||||
os << '\\' << command << '{'
|
||||
os << '\\' << getCmdName() << '{'
|
||||
<< ChangeExtension(incfile, ".tex")
|
||||
<< '}';
|
||||
}
|
||||
} else {
|
||||
// \include don't want extension and demands that the
|
||||
// file really have .tex
|
||||
os << '\\' << command << '{'
|
||||
os << '\\' << getCmdName() << '{'
|
||||
<< ChangeExtension(incfile, string())
|
||||
<< '}';
|
||||
}
|
||||
@ -436,16 +437,16 @@ vector<string> InsetInclude::getLabelList() const
|
||||
}
|
||||
|
||||
|
||||
string InsetInclude::getKeys(char delim) const
|
||||
vector<pair<string,string> > InsetInclude::getKeys() const
|
||||
{
|
||||
string lst;
|
||||
vector<pair<string,string> > keys;
|
||||
|
||||
if (loadIfNeeded()) {
|
||||
Buffer *tmp = bufferlist.getBuffer(getFileName());
|
||||
tmp->setParentName("");
|
||||
lst = tmp->getBibkeyList(delim);
|
||||
keys = tmp->getBibkeyList();
|
||||
tmp->setParentName(getMasterFilename());
|
||||
}
|
||||
|
||||
return lst;
|
||||
return keys;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
/// This returns the list of labels on the child buffer
|
||||
std::vector<string> getLabelList() const;
|
||||
/// This returns the list of bibkeys on the child buffer
|
||||
string getKeys(char delim) const;
|
||||
std::vector< std::pair<string,string> > getKeys() const;
|
||||
///
|
||||
void Edit(BufferView *, int x, int y, unsigned int button);
|
||||
///
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
///
|
||||
~InsetIndex();
|
||||
///
|
||||
Inset * Clone() const { return new InsetIndex(contents);}
|
||||
Inset * Clone() const { return new InsetIndex(getContents());}
|
||||
///
|
||||
void Edit(BufferView *, int, int, unsigned int);
|
||||
///
|
||||
|
@ -42,7 +42,7 @@ Inset * InsetLabel::Clone() const
|
||||
|
||||
vector<string> InsetLabel::getLabelList() const
|
||||
{
|
||||
return vector<string>(1,contents);
|
||||
return vector<string>(1,getContents());
|
||||
}
|
||||
|
||||
|
||||
@ -53,15 +53,14 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int)
|
||||
return;
|
||||
}
|
||||
|
||||
pair<bool, string> result = askForText(_("Enter label:"),
|
||||
contents);
|
||||
pair<bool, string> result = askForText(_("Enter label:"), getContents());
|
||||
if (result.first) {
|
||||
string new_contents = frontStrip(strip(result.second));
|
||||
if (!new_contents.empty() &&
|
||||
contents != new_contents) {
|
||||
getContents() != new_contents) {
|
||||
bv->buffer()->markDirty();
|
||||
bool flag = bv->ChangeRefs(contents,new_contents);
|
||||
contents = new_contents;
|
||||
bool flag = bv->ChangeRefs(getContents(),new_contents);
|
||||
setContents( new_contents );
|
||||
bv->text->RedoParagraph();
|
||||
if (flag) {
|
||||
bv->redraw();
|
||||
|
@ -175,8 +175,8 @@ void CloseAllBufferRelatedPopups()
|
||||
}
|
||||
}
|
||||
if (citation_form) {
|
||||
if (citation_form->citation_form->visible) {
|
||||
fl_hide_form(citation_form->citation_form);
|
||||
if (citation_form->form->visible) {
|
||||
fl_hide_form(citation_form->form);
|
||||
}
|
||||
}
|
||||
if (bibitem_form) {
|
||||
@ -323,8 +323,8 @@ void updateAllVisibleBufferRelatedPopups()
|
||||
}
|
||||
#endif
|
||||
if (citation_form) {
|
||||
if (citation_form->citation_form->visible) {
|
||||
fl_hide_form(citation_form->citation_form);
|
||||
if (citation_form->form->visible) {
|
||||
fl_hide_form(citation_form->form);
|
||||
}
|
||||
}
|
||||
if (bibitem_form) {
|
||||
|
@ -49,6 +49,7 @@ using std::istringstream;
|
||||
#include "insets/insetindex.h"
|
||||
#include "insets/insetinclude.h"
|
||||
#include "insets/insetbib.h"
|
||||
#include "insets/insetcite.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "insets/insetert.h"
|
||||
#include "insets/insetgraphics.h"
|
||||
|
@ -46,10 +46,7 @@ int tex_code_break_column = 72; // needs non-zero initialization. set later.
|
||||
// this is a bad idea, but how can LyXParagraph find its buffer to get
|
||||
// parameters? (JMarc)
|
||||
extern BufferView * current_view;
|
||||
|
||||
|
||||
// ale970405
|
||||
extern string bibitemWidthest(Painter &);
|
||||
extern string bibitemWidest(Painter &);
|
||||
|
||||
// this is a minibuffer
|
||||
static char minibuffer_char;
|
||||
@ -3644,7 +3641,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(ostream & os, TexRow & texrow,
|
||||
} else if (style.labeltype == LABEL_BIBLIO) {
|
||||
// ale970405
|
||||
os << "\\begin{" << style.latexname() << "}{"
|
||||
<< bibitemWidthest(current_view->painter())
|
||||
<< bibitemWidest(current_view->painter())
|
||||
<< "}\n";
|
||||
} else if (style.latextype == LATEX_ITEM_ENVIRONMENT) {
|
||||
#ifdef FANCY_FOOTNOTE_CODE
|
||||
|
@ -40,9 +40,6 @@ using std::endl;
|
||||
using std::pair;
|
||||
|
||||
static const int LYX_PAPER_MARGIN = 20;
|
||||
|
||||
|
||||
// ale070405
|
||||
extern int bibitemMaxWidth(Painter &, LyXFont const &);
|
||||
|
||||
static int iso885968x[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user