mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 05:55:34 +00:00
A few patches I forgot to commit on friday.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1272 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4abaf6ab91
commit
891bff2bfe
55
ChangeLog
55
ChangeLog
@ -1,3 +1,58 @@
|
||||
2000-12-11 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* lib/languages: Change description of german to "German (new
|
||||
spelling)".
|
||||
|
||||
2000-12-07 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* src/frontends/xforms/FormInset.C (createInset): activate "Ok",
|
||||
"Apply" buttons if arg is non-zero.
|
||||
|
||||
* src/lyxfunc.C (Dispatch): enable citation to be inserted without
|
||||
launching the popup if sufficient info is passed to
|
||||
LFUN_CITATION_CREATE.
|
||||
|
||||
2000-11-23 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* src/lyx_cb.C (MenuInsertLabel): Compute a default value for new
|
||||
labels (disabled in 1.1.6).
|
||||
|
||||
* src/lyxrc.[Ch]: New variable label_init_length
|
||||
|
||||
* mathed/formula.C (LocalDispatch): Preserve the label when
|
||||
changing from display math to eqnarray (however, the label
|
||||
do not appear at the first line, as one might expects, but at the
|
||||
second line).
|
||||
(LocalDispatch): When inserting a label to a formula which already
|
||||
have a label, the old label is used as default value.
|
||||
Also, if the label is changed, then all references to the label
|
||||
are changed.
|
||||
|
||||
* src/mathed/math_iter.C (setLabel): Allow to set the label
|
||||
even if it is empty. This is needed to allow deletion of a label
|
||||
in an eqnarray.
|
||||
|
||||
* src/BufferView2.C (ChangeRefsIfUnique): New method. Changes the
|
||||
refernces only if the old label appears once in the document.
|
||||
|
||||
2000-12-07 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* lib/languages: added ngerman. Patch courtesy of Andreas Gehlert
|
||||
<gehlert@Rcs1.urz.tu-dresden.de>
|
||||
|
||||
* src/frontends/xforms/FormBase.C: comment out debug.h
|
||||
|
||||
* src/frontends/xforms/FormGraphics.[Ch] (browseFile): removed. Reuse
|
||||
code in xform_helpers instead.
|
||||
(d-tor): comment out "delete dialog;" and so prevent a crash on exit.
|
||||
|
||||
* src/frontends/xforms/FormPreferences.C: use AddName() in more places.
|
||||
Use N_(), rather than _() when creating strings to pass to browseFile()
|
||||
because browseFile calls gettext() itself now.
|
||||
|
||||
* src/frontends/xforms/xform_helpers.C (browseFile): call gettext() and
|
||||
display the filename correctly.
|
||||
|
||||
2000-12-09 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* src/converter.C (Move): New method. Used to move file or files
|
||||
|
@ -24,6 +24,7 @@ galician galician "Galician" false iso8859-1 gl_ES
|
||||
# There are two Galicia's one in Spain one in E.Europe. Because of
|
||||
# the font encoding I am assuming this is the one in Spain. (Garst)
|
||||
german german "German" false iso8859-1 de
|
||||
ngerman ngerman "German (new spelling)" false iso8859-1 de
|
||||
greek greek "Greek" false iso8859-7 el_GR
|
||||
hebrew hebrew "Hebrew" true cp1255 he_IL
|
||||
#hungarian hungarian "Hungarian" false iso8859-2 ""
|
||||
|
@ -156,6 +156,14 @@
|
||||
#
|
||||
#\date_insert_format "%A, %e. %B %Y"
|
||||
|
||||
|
||||
# Maximum number of words in the initialization string for a new label.
|
||||
# If it is set to 0, then the init. string will only contain the prefix
|
||||
# (e.g. "sec:"). If it is set to -1, the init. string will be empty.
|
||||
# This feature is disabled in 1.1.6.
|
||||
#
|
||||
#\label_init_length 0
|
||||
|
||||
#
|
||||
# SCREEN & FONTS SECTION #################################################
|
||||
#
|
||||
|
@ -249,6 +249,8 @@ public:
|
||||
///
|
||||
bool ChangeRefs(string const & from, string const & to);
|
||||
///
|
||||
bool ChangeRefsIfUnique(string const & from, string const & to);
|
||||
///
|
||||
void pasteClipboard(bool asPara);
|
||||
///
|
||||
void stuffClipboard(string const &) const;
|
||||
|
@ -39,6 +39,7 @@ using std::endl;
|
||||
using std::ifstream;
|
||||
using std::vector;
|
||||
using std::find;
|
||||
using std::count;
|
||||
|
||||
// Inserts a file into current document
|
||||
bool BufferView::insertLyXFile(string const & filen)
|
||||
@ -897,6 +898,16 @@ bool BufferView::ChangeRefs(string const & from, string const & to)
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::ChangeRefsIfUnique(string const & from, string const & to)
|
||||
{
|
||||
// Check if the label 'from' appears more than once
|
||||
vector<string> labels = buffer()->getLabelList();
|
||||
if (count(labels.begin(), labels.end(), from) > 1)
|
||||
return false;
|
||||
|
||||
return ChangeRefs(from, to);
|
||||
}
|
||||
|
||||
UpdatableInset * BufferView::theLockingInset() const
|
||||
{
|
||||
return text->the_locking_inset;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "FormBase.h"
|
||||
#include "LyXView.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "debug.h"
|
||||
//#include "debug.h"
|
||||
|
||||
extern "C" int C_FormBaseWMHideCB(FL_FORM * ob, void * d)
|
||||
{
|
||||
@ -60,7 +60,6 @@ FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
|
||||
|
||||
FormBase::~FormBase()
|
||||
{
|
||||
//lyxerr << "bp_[" << bp_ << "]" << endl;
|
||||
delete bp_;
|
||||
}
|
||||
|
||||
|
@ -2,13 +2,6 @@
|
||||
* FormGraphics Interface Class Implementation
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
* * Handle the case when the buffer is read-only.
|
||||
* Initial work is done, if we are read-only the ok/cancel are
|
||||
* disabled. Probably we need to find a better way to deal with it.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
@ -25,9 +18,9 @@
|
||||
|
||||
#include "debug.h" // for lyxerr
|
||||
|
||||
#include "support/lstrings.h" // for strToDbl & tostr
|
||||
#include "support/FileInfo.h" // for FileInfo
|
||||
#include "filedlg.h" // for LyXFileDlg
|
||||
#include "support/lstrings.h" // for strToDbl & tostr
|
||||
#include "support/FileInfo.h" // for FileInfo
|
||||
#include "xform_helpers.h" // for browseFile
|
||||
#include "support/filetools.h" // for AddName
|
||||
#include "insets/insetgraphics.h"
|
||||
#include "insets/insetgraphicsParams.h"
|
||||
@ -37,7 +30,7 @@
|
||||
#include "support/LAssert.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
using std::make_pair;
|
||||
|
||||
FormGraphics::FormGraphics(LyXView * lv, Dialogs * d)
|
||||
: FormInset(lv, d, _("Graphics"), new NoRepeatedApplyReadOnlyPolicy),
|
||||
@ -62,7 +55,7 @@ FormGraphics::~FormGraphics()
|
||||
displayButtons.reset();
|
||||
|
||||
// Free the form.
|
||||
delete dialog_;
|
||||
// delete dialog_;
|
||||
}
|
||||
|
||||
|
||||
@ -357,68 +350,31 @@ bool FormGraphics::checkInput()
|
||||
// We need these in the file browser.
|
||||
extern string system_lyxdir;
|
||||
extern string user_lyxdir;
|
||||
//extern string system_tempdir;
|
||||
|
||||
|
||||
// Need to move this to the form_graphics
|
||||
string FormGraphics::browseFile(string const & filename)
|
||||
{
|
||||
if (! filename.empty() )
|
||||
last_image_path = OnlyPath(filename);
|
||||
|
||||
// Does user clipart directory exist?
|
||||
string bufclip = AddName (user_lyxdir, "clipart");
|
||||
FileInfo fileInfo(bufclip);
|
||||
if (!(fileInfo.isOK() && fileInfo.isDir()))
|
||||
// No - bail out to system clipart directory
|
||||
bufclip = AddName (system_lyxdir, "clipart");
|
||||
|
||||
LyXFileDlg fileDlg;
|
||||
fileDlg.SetButton(0, _("Clipart"), bufclip);
|
||||
|
||||
bool error = false;
|
||||
string buf;
|
||||
do {
|
||||
string p = fileDlg.Select(_("Graphics"),
|
||||
last_image_path,
|
||||
"*(ps|png)", filename);
|
||||
|
||||
if (p.empty()) return p;
|
||||
|
||||
last_image_path = OnlyPath(p);
|
||||
|
||||
if (p.find_first_of("#~$% ") != string::npos) {
|
||||
WriteAlert(_("Filename can't contain any "
|
||||
"of these characters:"),
|
||||
// xgettext:no-c-format
|
||||
_("space, '#', '~', '$' or '%'."));
|
||||
error = true;
|
||||
} else {
|
||||
error = false;
|
||||
buf = p;
|
||||
}
|
||||
} while (error);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void FormGraphics::browse()
|
||||
{
|
||||
// Get the filename from the dialog
|
||||
string const filename = fl_get_input(dialog_->input_filename);
|
||||
|
||||
string const title = N_("Graphics");
|
||||
string const pattern = "*(ps|png)";
|
||||
|
||||
// Does user clipart directory exist?
|
||||
string clipdir = AddName (user_lyxdir, "clipart");
|
||||
FileInfo fileInfo(clipdir);
|
||||
if (!(fileInfo.isOK() && fileInfo.isDir()))
|
||||
// No - bail out to system clipart directory
|
||||
clipdir = AddName (system_lyxdir, "clipart");
|
||||
pair<string, string> dir1(N_("Clipart"), clipdir);
|
||||
|
||||
// Show the file browser dialog
|
||||
string const new_filename = browseFile(filename);
|
||||
string const new_filename =
|
||||
browseFile(filename, title, pattern, dir1,
|
||||
make_pair(string(), string()));
|
||||
|
||||
// Save the filename to the dialog
|
||||
if (new_filename != filename && ! new_filename.empty()) {
|
||||
fl_set_input(dialog_->input_filename,
|
||||
new_filename.c_str());
|
||||
// The above set input doesn't cause an input event so we do
|
||||
// it manually. Otherwise the user needs to cause an input event
|
||||
// to get the ok/apply buttons to be activated.
|
||||
if (new_filename != filename && !new_filename.empty()) {
|
||||
fl_set_input(dialog_->input_filename, new_filename.c_str());
|
||||
input(0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,8 +90,6 @@ private:
|
||||
bool checkInput();
|
||||
/// Open the file browse dialog to select an image file.
|
||||
void browse();
|
||||
/// Display a file browser dialog and return the file chosen.
|
||||
string browseFile(string const & filename);
|
||||
|
||||
/// Pointer to the actual instantiation of the xform's form
|
||||
virtual FL_FORM * form() const;
|
||||
|
@ -94,5 +94,7 @@ void FormCommand::createInset(string const & arg)
|
||||
}
|
||||
|
||||
params.setFromString(arg);
|
||||
if ( !arg.empty() )
|
||||
bc_.valid(); // so that the user can press Ok
|
||||
show();
|
||||
}
|
||||
|
@ -1574,28 +1574,28 @@ FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
|
||||
bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
|
||||
{
|
||||
if (ob == dialog_->button_bind_file_browse) {
|
||||
string dir = system_lyxdir + string("bind");
|
||||
string name = _("Sys Bind");
|
||||
string dir = AddName(system_lyxdir, "bind");
|
||||
string name = N_("Sys Bind");
|
||||
pair<string,string> dir1(name, dir);
|
||||
|
||||
dir = user_lyxdir + string("bind");
|
||||
name = _("User Bind");
|
||||
dir = AddName(user_lyxdir, "bind");
|
||||
name = N_("User Bind");
|
||||
pair<string,string> dir2(name, dir);
|
||||
|
||||
parent_.browse(dialog_->input_bind_file,
|
||||
_("Bind file"), "*.bind", dir1, dir2);
|
||||
N_("Bind file"), "*.bind", dir1, dir2);
|
||||
|
||||
} else if (ob == dialog_->button_ui_file_browse) {
|
||||
string dir = system_lyxdir + string("ui");
|
||||
string name = _("Sys UI");
|
||||
string dir = AddName(system_lyxdir, "ui");
|
||||
string name = N_("Sys UI");
|
||||
pair<string,string> dir1(name, dir);
|
||||
|
||||
dir = user_lyxdir + string("ui");
|
||||
name = _("User UI");
|
||||
dir = AddName(user_lyxdir, "ui");
|
||||
name = N_("User UI");
|
||||
pair<string,string> dir2(name, dir);
|
||||
|
||||
parent_.browse(dialog_->input_ui_file,
|
||||
_("UI file"), "*.ui", dir1, dir2);
|
||||
N_("UI file"), "*.ui", dir1, dir2);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1790,21 +1790,21 @@ bool FormPreferences::Language::input(FL_OBJECT const * const ob)
|
||||
}
|
||||
|
||||
if (ob == dialog_->button_kbmap1_browse) {
|
||||
string const dir = system_lyxdir + string("kbd");
|
||||
string const dir = AddName(system_lyxdir, "kbd");
|
||||
string const name = N_("Key maps");
|
||||
pair<string, string> dir1(name, dir);
|
||||
|
||||
parent_.browse(dialog_->input_kbmap1,
|
||||
_("Keyboard map"), "*.kmap", dir1,
|
||||
make_pair(string(), string()));
|
||||
N_("Keyboard map"), "*.kmap", dir1,
|
||||
make_pair(string(), string()));
|
||||
} else if (ob == dialog_->button_kbmap2_browse) {
|
||||
string const dir = system_lyxdir + string("kbd");
|
||||
string const dir = AddName(system_lyxdir, "kbd");
|
||||
string const name = N_("Key maps");
|
||||
pair<string, string> dir1(name, dir);
|
||||
|
||||
parent_.browse(dialog_->input_kbmap2,
|
||||
_("Keyboard map"), "*.kmap", dir1,
|
||||
make_pair(string(), string()));
|
||||
N_("Keyboard map"), "*.kmap", dir1,
|
||||
make_pair(string(), string()));
|
||||
}
|
||||
|
||||
return activate;
|
||||
@ -2228,35 +2228,35 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
|
||||
|
||||
if (ob == dialog_->button_default_path_browse) {
|
||||
parent_.browse(dialog_->input_default_path,
|
||||
_("Default path"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
N_("Default path"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
} else if (ob == dialog_->button_template_path_browse) {
|
||||
parent_.browse(dialog_->input_template_path,
|
||||
_("Template path"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
N_("Template path"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
} else if (ob == dialog_->button_temp_dir_browse) {
|
||||
parent_.browse(dialog_->input_temp_dir,
|
||||
_("Temp dir"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
N_("Temp dir"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
} else if (ob == dialog_->button_lastfiles_browse) {
|
||||
pair<string, string> dir(_("User"), user_lyxdir);
|
||||
|
||||
parent_.browse(dialog_->input_lastfiles,
|
||||
_("Lastfiles"), string(), dir,
|
||||
make_pair(string(), string()));
|
||||
N_("Lastfiles"), string(), dir,
|
||||
make_pair(string(), string()));
|
||||
} else if (ob == dialog_->button_backup_path_browse) {
|
||||
parent_.browse(dialog_->input_backup_path,
|
||||
_("Backup path"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
N_("Backup path"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
} else if (ob == dialog_->button_serverpipe_browse) {
|
||||
parent_.browse(dialog_->input_serverpipe,
|
||||
_("LyX Server pipes"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
N_("LyX Server pipes"), string(),
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
}
|
||||
|
||||
return activate;
|
||||
@ -2949,9 +2949,9 @@ bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
|
||||
|
||||
if (ob == dialog_->button_personal_dict) {
|
||||
parent_.browse(dialog_->input_personal_dict,
|
||||
_("Personal dictionary"), "*.ispell",
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
N_("Personal dictionary"), "*.ispell",
|
||||
make_pair(string(), string()),
|
||||
make_pair(string(), string()));
|
||||
}
|
||||
|
||||
return true; // All input is valid!
|
||||
|
@ -83,21 +83,21 @@ string const browseFile( string const & filename,
|
||||
if( !dir1.second.empty() ) {
|
||||
FileInfo fileInfo( dir1.second );
|
||||
if( fileInfo.isOK() && fileInfo.isDir() )
|
||||
fileDlg.SetButton( 0, dir1.first, dir1.second );
|
||||
fileDlg.SetButton( 0, _(dir1.first), dir1.second );
|
||||
}
|
||||
|
||||
if( !dir2.second.empty() ) {
|
||||
FileInfo fileInfo( dir2.second );
|
||||
if( fileInfo.isOK() && fileInfo.isDir() )
|
||||
fileDlg.SetButton( 1, dir2.first, dir2.second );
|
||||
fileDlg.SetButton( 1, _(dir2.first), dir2.second );
|
||||
}
|
||||
|
||||
bool error = false;
|
||||
string buf;
|
||||
do {
|
||||
string p = fileDlg.Select(title,
|
||||
string p = fileDlg.Select(_(title),
|
||||
lastPath,
|
||||
pattern, filename );
|
||||
pattern, OnlyFilename(filename) );
|
||||
|
||||
if (p.empty()) return p;
|
||||
|
||||
@ -121,7 +121,6 @@ string const browseFile( string const & filename,
|
||||
// sorted by hand to prevent LyXLex from complaining on read().
|
||||
static
|
||||
keyword_item xformTags[] = {
|
||||
// { "\\gui_active_tab", FL_LIGHTER_COL1 },
|
||||
{ "\\gui_background", FL_COL1 },
|
||||
{ "\\gui_buttonbottom", FL_BOTTOM_BCOL },
|
||||
{ "\\gui_buttonleft", FL_LEFT_BCOL },
|
||||
|
@ -52,8 +52,9 @@ void InsetLabel::Edit(BufferView * bv, int, int, unsigned int)
|
||||
if (!new_contents.empty() &&
|
||||
getContents() != new_contents) {
|
||||
bv->buffer()->markDirty();
|
||||
bool flag = bv->ChangeRefs(getContents(),new_contents);
|
||||
setContents( new_contents );
|
||||
bool flag = bv->ChangeRefsIfUnique(getContents(),
|
||||
new_contents);
|
||||
setContents(new_contents);
|
||||
bv->text->RedoParagraph(bv);
|
||||
if (flag) {
|
||||
bv->redraw();
|
||||
|
71
src/lyx_cb.C
71
src/lyx_cb.C
@ -518,8 +518,75 @@ void MenuInsertLabel(BufferView * bv, string const & arg)
|
||||
string label(arg);
|
||||
ProhibitInput(bv);
|
||||
if (label.empty()) {
|
||||
pair<bool, string>
|
||||
result = askForText(_("Enter new label to insert:"));
|
||||
#ifdef LABEL_INIT
|
||||
#ifndef NEW_INSETS
|
||||
LyXParagraph * par =
|
||||
bv->text->cursor.par()->FirstPhysicalPar();
|
||||
#else
|
||||
LyXParagraph * par = bv->text->cursor.par();
|
||||
#endif
|
||||
LyXLayout const * layout =
|
||||
&textclasslist.Style(bv->buffer()->params.textclass,
|
||||
par->GetLayout());
|
||||
|
||||
if (layout->latextype == LATEX_PARAGRAPH && par->previous) {
|
||||
#ifndef NEW_INSETS
|
||||
LyXParagraph * par2 = par->previous->FirstPhysicalPar();
|
||||
#else
|
||||
LyXParagraph * par2 = par->previous;
|
||||
#endif
|
||||
LyXLayout const * layout2 =
|
||||
&textclasslist.Style(bv->buffer()->params.textclass,
|
||||
par2->GetLayout());
|
||||
if (layout2->latextype != LATEX_PARAGRAPH) {
|
||||
par = par2;
|
||||
layout = layout2;
|
||||
}
|
||||
}
|
||||
string text = layout->latexname().substr(0, 3);
|
||||
if (layout->latexname() == "theorem")
|
||||
text = "thm"; // Create a correct prefix for prettyref
|
||||
#ifndef NEW_INSETS
|
||||
if (par->footnoteflag==LyXParagraph::OPEN_FOOTNOTE)
|
||||
switch (par->footnotekind) {
|
||||
case LyXParagraph::FIG:
|
||||
case LyXParagraph::WIDE_FIG:
|
||||
text = "fig";
|
||||
break;
|
||||
case LyXParagraph::TAB:
|
||||
case LyXParagraph::WIDE_TAB:
|
||||
text = "tab";
|
||||
break;
|
||||
case LyXParagraph::ALGORITHM:
|
||||
text = "alg";
|
||||
break;
|
||||
case LyXParagraph::FOOTNOTE:
|
||||
case LyXParagraph::MARGIN:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
text += ":";
|
||||
if (layout->latextype == LATEX_PARAGRAPH ||
|
||||
lyxrc.label_init_length < 0)
|
||||
text.erase();
|
||||
string par_text = par->String(bv->buffer(), false);
|
||||
for (int i = 0; i < lyxrc.label_init_length; ++i) {
|
||||
if (par_text.empty())
|
||||
break;
|
||||
string head;
|
||||
par_text = split(par_text, head, ' ');
|
||||
if (i > 0)
|
||||
text += '_'; // Is it legal to use spaces in
|
||||
// labels ?
|
||||
text += head;
|
||||
}
|
||||
|
||||
pair<bool, string> result =
|
||||
askForText(_("Enter new label to insert:"), text);
|
||||
#else
|
||||
pair<bool, string> result =
|
||||
askForText(_("Enter new label to insert:"));
|
||||
#endif
|
||||
if (result.first) {
|
||||
label = frontStrip(strip(result.second));
|
||||
}
|
||||
|
@ -2529,17 +2529,22 @@ string const LyXFunc::Dispatch(int ac,
|
||||
|
||||
case LFUN_CITATION_CREATE:
|
||||
{
|
||||
// Should do this "at source"
|
||||
InsetCommandParams p( "cite" );
|
||||
|
||||
if (contains(argument, "|")) {
|
||||
p.setContents( token(argument, '|', 0) );
|
||||
p.setOptions( token(argument, '|', 1) );
|
||||
} else {
|
||||
p.setContents( argument );
|
||||
}
|
||||
|
||||
owner->getDialogs()->createCitation( p.getAsString() );
|
||||
if (!argument.empty()) {
|
||||
// This should be set at source, ie when typing
|
||||
// "citation-insert foo" in the minibuffer.
|
||||
// Question: would pybibliographer also need to be
|
||||
// changed. Suspect so. Leave as-is therefore.
|
||||
if (contains(argument, "|")) {
|
||||
p.setContents( token(argument, '|', 0) );
|
||||
p.setOptions( token(argument, '|', 1) );
|
||||
} else {
|
||||
p.setContents( argument );
|
||||
}
|
||||
Dispatch(LFUN_CITATION_INSERT, p.getAsString());
|
||||
} else
|
||||
owner->getDialogs()->createCitation( p.getAsString() );
|
||||
}
|
||||
break;
|
||||
|
||||
|
18
src/lyxrc.C
18
src/lyxrc.C
@ -78,6 +78,7 @@ keyword_item lyxrcTags[] = {
|
||||
{ "\\kbmap", LyXRC::RC_KBMAP },
|
||||
{ "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
|
||||
{ "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
|
||||
{ "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
|
||||
{ "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
|
||||
{ "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
|
||||
{ "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
|
||||
@ -238,6 +239,7 @@ void LyXRC::setDefaults() {
|
||||
date_insert_format = "%A, %e %B %Y";
|
||||
show_banner = true;
|
||||
cursor_follows_scrollbar = false;
|
||||
label_init_length = 3;
|
||||
|
||||
/// These variables are not stored on disk (perhaps they
|
||||
// should be moved from the LyXRC class).
|
||||
@ -901,6 +903,11 @@ int LyXRC::read(string const & filename)
|
||||
default_language = lexrc.GetString();
|
||||
break;
|
||||
|
||||
case RC_LABEL_INIT_LENGTH:
|
||||
if (lexrc.next())
|
||||
label_init_length = lexrc.GetInteger();
|
||||
break;
|
||||
|
||||
case RC_LAST: break; // this is just a dummy
|
||||
}
|
||||
}
|
||||
@ -1062,7 +1069,12 @@ void LyXRC::output(ostream & os) const
|
||||
os << "\\date_insert_format \"" << date_insert_format
|
||||
<< "\"\n";
|
||||
}
|
||||
|
||||
case RC_LABEL_INIT_LENGTH:
|
||||
if (label_init_length != system_lyxrc.label_init_length) {
|
||||
os << "\\label_init_length " << label_init_length
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
os << "\n#\n"
|
||||
<< "# SCREEN & FONTS SECTION ############################\n"
|
||||
<< "#\n\n";
|
||||
@ -1895,6 +1907,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
|
||||
case RC_DEFAULT_LANGUAGE:
|
||||
str = N_("New documents will be assigned this language.");
|
||||
break;
|
||||
|
||||
case RC_LABEL_INIT_LENGTH:
|
||||
str = N_("Maximum number of words in the initialization string for a new label");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -118,6 +118,7 @@ enum LyXRCTags {
|
||||
RC_FORMAT,
|
||||
RC_NEW_ASK_FILENAME,
|
||||
RC_DEFAULT_LANGUAGE,
|
||||
RC_LABEL_INIT_LENGTH,
|
||||
RC_LAST
|
||||
};
|
||||
|
||||
@ -331,6 +332,8 @@ enum LyXRCTags {
|
||||
string default_language;
|
||||
///
|
||||
bool cursor_follows_scrollbar;
|
||||
///
|
||||
int label_init_length;
|
||||
};
|
||||
|
||||
///
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "Painter.h"
|
||||
#include "font.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "lyxrc.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::istream;
|
||||
@ -794,6 +795,10 @@ InsetFormula::LocalDispatch(BufferView * bv,
|
||||
case LFUN_BREAKLINE:
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->Insert(' ', LM_TC_CR);
|
||||
if (!label.empty()) {
|
||||
mathcursor->setLabel(label);
|
||||
label.erase();
|
||||
}
|
||||
par = mathcursor->GetPar();
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
@ -1047,28 +1052,43 @@ InsetFormula::LocalDispatch(BufferView * bv,
|
||||
case LFUN_INSERT_LABEL:
|
||||
{
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
if (par->GetType() < LM_OT_PAR) break;
|
||||
string lb = arg;
|
||||
if (lb.empty()) {
|
||||
pair<bool, string>
|
||||
res = askForText(_("Enter new label to insert:"));
|
||||
if (res.first) {
|
||||
lb = res.second;
|
||||
}
|
||||
if (par->GetType() < LM_OT_PAR)
|
||||
break;
|
||||
|
||||
string old_label = (par->GetType() == LM_OT_MPARN)
|
||||
? mathcursor->getLabel() : label;
|
||||
string new_label = arg;
|
||||
if (new_label.empty()) {
|
||||
#ifdef LABEL_INIT
|
||||
string default_label = (lyxrc.label_init_length >= 0) ? "eq:" : "";
|
||||
pair<bool, string> res = old_label.empty()
|
||||
? askForText(_("Enter new label to insert:"), default_label)
|
||||
#else
|
||||
pair<bool, string> res = old_label.empty()
|
||||
? askForText(_("Enter new label to insert:"))
|
||||
#endif
|
||||
: askForText(_("Enter label:"), old_label);
|
||||
if (!res.first)
|
||||
break;
|
||||
new_label = frontStrip(strip(res.second));
|
||||
}
|
||||
if (!lb.empty() && lb[0] > ' ') {
|
||||
|
||||
if (new_label == old_label)
|
||||
break; // Nothing to do
|
||||
|
||||
if (!new_label.empty())
|
||||
SetNumber(true);
|
||||
if (par->GetType() == LM_OT_MPARN) {
|
||||
mathcursor->setLabel(lb);
|
||||
// MathMatrixInset *mt = (MathMatrixInset*)par;
|
||||
// mt->SetLabel(lb);
|
||||
} else {
|
||||
//if (label.notEmpty()) delete label;
|
||||
label = lb;
|
||||
}
|
||||
UpdateLocal(bv);
|
||||
} else
|
||||
label.erase();
|
||||
|
||||
if (!new_label.empty() && bv->ChangeRefsIfUnique(old_label, new_label))
|
||||
bv->redraw();
|
||||
|
||||
if (par->GetType() == LM_OT_MPARN)
|
||||
mathcursor->setLabel(new_label);
|
||||
// MathMatrixInset *mt = (MathMatrixInset*)par;
|
||||
// mt->SetLabel(new_label);
|
||||
else
|
||||
label = new_label;
|
||||
UpdateLocal(bv);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,10 @@ class MathedCursor {
|
||||
///
|
||||
void setLabel(string const &);
|
||||
///
|
||||
string const & getLabel() const {
|
||||
return cursor->getLabel();
|
||||
}
|
||||
///
|
||||
bool Limits();
|
||||
/// Set accent: if argument = 0 it's considered consumed
|
||||
void setAccent(int ac = 0);
|
||||
|
@ -964,7 +964,7 @@ bool MathedXIter::setNumbered(bool numb)
|
||||
|
||||
bool MathedXIter::setLabel(string const & label)
|
||||
{
|
||||
if (!label.empty() && crow) {
|
||||
if (crow) {
|
||||
crow->setLabel(label);
|
||||
return true;
|
||||
}
|
||||
|
@ -222,6 +222,10 @@ class MathedXIter: public MathedIter {
|
||||
///
|
||||
bool setLabel(string const & label);
|
||||
///
|
||||
string const & getLabel() const {
|
||||
return crow->getLabel();
|
||||
}
|
||||
///
|
||||
bool setNumbered(bool);
|
||||
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user