a few small new features

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2289 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-07-20 09:38:19 +00:00
parent 251921c456
commit 76a135cf07
15 changed files with 198 additions and 186 deletions

View File

@ -1,3 +1,7 @@
2001-07-19 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* ui/default.ui: change a shortcut
2001-07-19 Angus Leeming <a.leeming@ic.ac.uk>
* chkconfig.ltx: test for the presence of natbib.

View File

@ -45,7 +45,7 @@ Menuset
Item "Close|C" "buffer-close"
Item "Save|S" "buffer-write"
Item "Save As...|A" "buffer-write-as"
Item "Revert to Saved|d" "buffer-reload"
Item "Revert to Saved|R" "buffer-reload"
Submenu "Version Control|V" "file_vc"
Separator
Submenu "Import|I" "file_import"
@ -217,6 +217,7 @@ Menuset
Item "Subscript|u" "command-sequence math-insert _;math-mode;"
Item "HFill|H" "hfill-insert"
Item "Hyphenation Point|P" "hyphenation-point-insert"
Item "Hyphenation break|k" "hyphenation-break-insert"
Item "Protected Blank|B" "protected-space-insert"
Item "Linebreak|L" "break-line"
Item "Ellipsis|i" "dots-insert"

View File

@ -1520,19 +1520,23 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
}
case LFUN_HYPHENATION:
hyphenationPoint();
specialChar(InsetSpecialChar::HYPHENATION);
break;
case LFUN_HYPHENATION_BREAK:
specialChar(InsetSpecialChar::HYPHENATION_BREAK);
break;
case LFUN_LDOTS:
ldots();
specialChar(InsetSpecialChar::LDOTS);
break;
case LFUN_END_OF_SENTENCE:
endOfSentenceDot();
specialChar(InsetSpecialChar::END_OF_SENTENCE);
break;
case LFUN_MENU_SEPARATOR:
menuSeparator();
specialChar(InsetSpecialChar::MENU_SEPARATOR);
break;
case LFUN_HFILL:
@ -3015,24 +3019,21 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
case LFUN_INDEX_CREATE:
{
InsetCommandParams p( "index" );
InsetCommandParams p("index");
if (argument.empty()) {
// Get the word immediately preceding the cursor
Paragraph::size_type curpos =
bv_->getLyXText()->cursor.pos() - 1;
// Get word or selection
bv_->getLyXText()->selectWordWhenUnderCursor(bv_);
string const curstring =
bv_->getLyXText()->selectionAsString(buffer_);
string curstring;
if (curpos >= 0 )
curstring = bv_->getLyXText()
->cursor.par()->getWord(curpos);
p.setContents( curstring );
p.setContents(curstring);
} else {
p.setContents( argument );
p.setContents(argument);
}
owner_->getDialogs()->createIndex( p.getAsString() );
owner_->getDialogs()->createIndex(p.getAsString());
}
break;
@ -3051,14 +3052,11 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
case LFUN_INDEX_INSERT_LAST:
{
// Get word immediately preceding the cursor
Paragraph::size_type curpos =
bv_->getLyXText()->cursor.pos() - 1;
// Can't do that at the beginning of a paragraph
if (curpos < 0) break;
// Get word or selection
bv_->getLyXText()->selectWordWhenUnderCursor(bv_);
string const curstring(bv_->getLyXText()
->cursor.par()->getWord(curpos));
string const curstring =
bv_->getLyXText()->selectionAsString(buffer_);
InsetCommandParams p("index", curstring);
InsetIndex * inset = new InsetIndex(p);
@ -3252,6 +3250,12 @@ void BufferView::Pimpl::protectedBlank(LyXText * lt)
update(lt, BufferView::SELECT|BufferView::FITCUR);
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
#ifdef WITH_WARNINGS
#warning Why is this code different from specialChar() below? (JMarc)
// the code in specialChar is a generic version of what used to exist
// for other special chars. I did not merge this case because of the
// call to updateInset(), but what does it do?
#endif
if (!insertInset(new_inset))
delete new_inset;
else
@ -3259,8 +3263,7 @@ void BufferView::Pimpl::protectedBlank(LyXText * lt)
}
}
void BufferView::Pimpl::menuSeparator()
void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
{
if (available()) {
LyXText * lt = bv_->getLyXText();
@ -3268,43 +3271,7 @@ void BufferView::Pimpl::menuSeparator()
hideCursor();
update(lt, BufferView::SELECT|BufferView::FITCUR);
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR);
insertInset(new_inset);
}
}
void BufferView::Pimpl::endOfSentenceDot()
{
if (available()) {
hideCursor();
update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::END_OF_SENTENCE);
insertInset(new_inset);
}
}
void BufferView::Pimpl::ldots()
{
if (available()) {
hideCursor();
update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::LDOTS);
insertInset(new_inset);
}
}
void BufferView::Pimpl::hyphenationPoint()
{
if (available()) {
hideCursor();
update(bv_->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::HYPHENATION);
new InsetSpecialChar(kind);
insertInset(new_inset);
}
}

View File

@ -11,6 +11,7 @@
#include "frontends/Timeout.h"
#include "WorkArea.h"
#include "paragraph.h"
#include "insets/insetspecialchar.h"
#ifdef __GNUG__
#pragma interface
@ -131,19 +132,13 @@ private:
bool open_new_inset(UpdatableInset * new_inset, bool behind = false);
///
void protectedBlank(LyXText * lt);
///
void specialChar(InsetSpecialChar::Kind);
///
void newline();
///
void hfill();
///
void menuSeparator();
///
void endOfSentenceDot();
///
void ldots();
///
void hyphenationPoint();
///
void insertNote();
///
void gotoInset(std::vector<Inset::Code> const & codes,

View File

@ -1,3 +1,21 @@
2001-07-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* BufferView_pimpl.C (specialChar): new method. Obsoletes
menuSeparator(), endOfSentenceDot(), ldots() and
hyphenationPoint(), which are therefore removed.
(Dispatch): handle LFUN_HYPHENATION_BREAK.
* LyXAction.C (init):
* commandtags.h: add LFUN_HYPHENATION_BREAK.
* paragraph.C (getWord): removed.
* BufferView_pimpl.C (Dispatch): use last word or selection for
LFUN_INDEX_INSERT_LAST and LFUN_INDEX_CREATE.
* lyx_main.C (queryUserLyXDir): do not ask before creating
user_dir, except if it has been named explicitely.
2001-07-20 Angus Leeming <a.leeming@ic.ac.uk>
* BufferView_pimpl.C (updateScrollbar): Fix crash when reading in

View File

@ -232,6 +232,8 @@ void LyXAction::init()
{ LFUN_HTMLURL, "html-insert", "", Noop },
{ LFUN_HYPHENATION, "hyphenation-point-insert",
N_("Insert hyphenation point"), Noop },
{ LFUN_HYPHENATION_BREAK, "hyphenation-break-insert",
N_("Insert hyphenation break"), Noop },
{ LFUN_INDEX_CREATE, "index-insert",
N_("Insert index item"), Noop },
{ LFUN_INDEX_INSERT_LAST, "index-insert-last",

View File

@ -51,6 +51,7 @@ enum kb_action {
LFUN_GOTONOTE,
LFUN_INSET_TOGGLE,
LFUN_HYPHENATION,
LFUN_HYPHENATION_BREAK,
LFUN_HFILL,
LFUN_DEPTH,
LFUN_FREE, // 30

View File

@ -1,3 +1,13 @@
2001-07-19 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetspecialchar.[Ch]: add support for HYPHENATION_BREAK. some
reformatting
* insetquotes.C: general cleanup
(dispString): add spaces inside french double quotes.
(latex): ditto. Moreover, treat first the case where the frenchb
or french options have been given.
2001-07-19 Angus Leeming <a.leeming@ic.ac.uk>
* insetcite.[Ch] (latex, validate): new methods, required for natbib

View File

@ -73,25 +73,25 @@ InsetQuotes::InsetQuotes(string const & str)
}
InsetQuotes::InsetQuotes(InsetQuotes::quote_language l,
InsetQuotes::quote_side s,
InsetQuotes::quote_times t)
: language(l), side(s), times(t)
InsetQuotes::InsetQuotes(quote_language l,
quote_side s,
quote_times t)
: language_(l), side_(s), times_(t)
{}
InsetQuotes::InsetQuotes(char c, BufferParams const & params)
: language(params.quotes_language), times(params.quotes_times)
: language_(params.quotes_language), times_(params.quotes_times)
{
// Decide whether left or right
switch (c) {
case ' ': case '(': case '{': case '[': case '-': case ':':
case Paragraph::META_HFILL:
case Paragraph::META_NEWLINE:
side = InsetQuotes::LeftQ; // left quote
side_ = LeftQ; // left quote
break;
default:
side = InsetQuotes::RightQ; // right quote
side_ = RightQ; // right quote
}
}
@ -109,47 +109,47 @@ void InsetQuotes::parseString(string const & s)
for (i = 0; i < 6; ++i) {
if (str[0] == language_char[i]) {
language = InsetQuotes::quote_language(i);
language_ = quote_language(i);
break;
}
}
if (i >= 6) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad language specification." << endl;
language = InsetQuotes::EnglishQ;
language_ = EnglishQ;
}
for (i = 0; i < 2; ++i) {
if (str[1] == side_char[i]) {
side = InsetQuotes::quote_side(i);
side_ = quote_side(i);
break;
}
}
if (i >= 2) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad side specification." << endl;
side = InsetQuotes::LeftQ;
side_ = LeftQ;
}
for (i = 0; i < 2; ++i) {
if (str[2] == times_char[i]) {
times = InsetQuotes::quote_times(i);
times_ = quote_times(i);
break;
}
}
if (i >= 2) {
lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
" bad times specification." << endl;
times = InsetQuotes::DoubleQ;
times_ = DoubleQ;
}
}
string const InsetQuotes::dispString() const
string const InsetQuotes::dispString(Language const * doclang) const
{
string disp;
disp += quote_char[quote_index[side][language]];
if (times == InsetQuotes::DoubleQ)
disp += quote_char[quote_index[side_][language_]];
if (times_ == DoubleQ)
disp += disp;
if (lyxrc.font_norm_type == LyXRC::ISO_8859_1
@ -158,6 +158,14 @@ string const InsetQuotes::dispString() const
disp = '«';
else if (disp == ">>")
disp = '»';
// in french, spaces are added inside double quotes
if (times_ == DoubleQ && doclang->code() == "fr") {
if (side_ == LeftQ)
disp += " ";
else
disp = " " + disp;
}
return disp;
}
@ -175,9 +183,9 @@ int InsetQuotes::descent(BufferView *, LyXFont const & font) const
}
int InsetQuotes::width(BufferView *, LyXFont const & font) const
int InsetQuotes::width(BufferView * bv, LyXFont const & font) const
{
string text = dispString();
string text = dispString(bv->buffer()->getLanguage());
int w = 0;
for (string::size_type i = 0; i < text.length(); ++i) {
@ -207,7 +215,7 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
{
string text = dispString();
string text = dispString(bv->buffer()->getLanguage());
bv->painter().text(int(x), baseline, text, font);
x += width(bv, font);
@ -217,9 +225,9 @@ void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
void InsetQuotes::write(Buffer const *, ostream & os) const
{
string text;
text += language_char[language];
text += side_char[side];
text += times_char[times];
text += language_char[language_];
text += side_char[side_];
text += times_char[times_];
os << "Quotes " << text;
}
@ -241,27 +249,33 @@ extern bool use_babel;
int InsetQuotes::latex(Buffer const * buf, ostream & os,
bool /*fragile*/, bool) const
{
string const doclang = buf->getLanguage()->lang();
int quoteind = quote_index[side][language];
string const doclang = buf->getLanguage()->babel();
int quoteind = quote_index[side_][language_];
string qstr;
if (lyxrc.fontenc == "T1") {
qstr = latex_quote_t1[times][quoteind];
if (language_ == FrenchQ && times_ == DoubleQ) {
if (doclang == "frenchb") {
if (side_ == LeftQ)
qstr = "\\og "; //the spaces are important here
else
qstr = " \\fg "; //and here
} else if (doclang == "french") {
if (side_ == LeftQ)
qstr = "<< "; //the spaces are important here
else
qstr = " >>"; //and here
}
} else if (lyxrc.fontenc == "T1") {
qstr = latex_quote_t1[times_][quoteind];
#ifdef DO_USE_DEFAULT_LANGUAGE
} else if (doclang == "default") {
#else
} else if (!use_babel) {
#endif
qstr = latex_quote_ot1[times][quoteind];
} else if (language == InsetQuotes::FrenchQ
&& times == InsetQuotes::DoubleQ
&& doclang == "frenchb") {
if (side == InsetQuotes::LeftQ)
qstr = "\\og{}";
else
qstr = " \\fg{}";
} else
qstr = latex_quote_babel[times][quoteind];
qstr = latex_quote_ot1[times_][quoteind];
} else {
qstr = latex_quote_babel[times_][quoteind];
}
// Always guard against unfortunate ligatures (!` ?`)
if (prefixIs(qstr, "`"))
@ -288,13 +302,13 @@ int InsetQuotes::linuxdoc(Buffer const *, ostream & os) const
int InsetQuotes::docBook(Buffer const *, ostream & os) const
{
if (times == InsetQuotes::DoubleQ) {
if (side == InsetQuotes::LeftQ)
if (times_ == DoubleQ) {
if (side_ == LeftQ)
os << "&ldquo;";
else
os << "&rdquo;";
} else {
if (side == InsetQuotes::LeftQ)
if (side_ == LeftQ)
os << "&lsquo;";
else
os << "&rsquo;";
@ -305,11 +319,11 @@ int InsetQuotes::docBook(Buffer const *, ostream & os) const
void InsetQuotes::validate(LaTeXFeatures & features) const
{
char type = quote_char[quote_index[side][language]];
char type = quote_char[quote_index[side_][language_]];
if (features.bufferParams().language->lang() == "default"
&& lyxrc.fontenc != "T1") {
if (times == InsetQuotes::SingleQ)
if (times_ == SingleQ)
switch (type) {
case ',': features.quotesinglbase = true; break;
case '<': features.guilsinglleft = true; break;
@ -329,7 +343,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
Inset * InsetQuotes::clone(Buffer const &, bool) const
{
return new InsetQuotes(language, side, times);
return new InsetQuotes(language_, side_, times_);
}

View File

@ -19,6 +19,7 @@
#include "inset.h"
class BufferParams;
class Language;
struct LaTeXFeatures;
@ -102,11 +103,11 @@ public:
Inset::Code lyxCode() const;
private:
///
quote_language language;
quote_language language_;
///
quote_side side;
quote_side side_;
///
quote_times times;
quote_times times_;
/** The parameters of the constructor are the language, the
side and the multiplicity of the quote.
@ -115,7 +116,7 @@ private:
///
void parseString(string const &);
///
string const dispString() const;
string const dispString(Language const *) const;
};
#endif

View File

@ -50,6 +50,10 @@ int InsetSpecialChar::width(BufferView *, LyXFont const & font) const
w -= 2; // to make it look shorter
return w;
}
case HYPHENATION_BREAK:
{
return lyxfont::width('|', font);
}
case END_OF_SENTENCE:
{
return lyxfont::width('.', font);
@ -86,6 +90,13 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
x += width(bv, font);
break;
}
case HYPHENATION_BREAK:
{
font.setColor(LColor::special);
pain.text(int(x), baseline, "|", font);
x += width(bv, font);
break;
}
case END_OF_SENTENCE:
{
font.setColor(LColor::special);
@ -148,10 +159,21 @@ void InsetSpecialChar::write(Buffer const *, ostream & os) const
{
string command;
switch (kind) {
case HYPHENATION: command = "\\-"; break;
case END_OF_SENTENCE: command = "\\@."; break;
case LDOTS: command = "\\ldots{}"; break;
case MENU_SEPARATOR: command = "\\menuseparator"; break;
case HYPHENATION:
command = "\\-";
break;
case HYPHENATION_BREAK:
command = "\\textcompwordmark{}";
break;
case END_OF_SENTENCE:
command = "\\@.";
break;
case LDOTS:
command = "\\ldots{}";
break;
case MENU_SEPARATOR:
command = "\\menuseparator";
break;
case PROTECTED_SEPARATOR:
//command = "\\protected_separator";
command = "~";
@ -169,6 +191,8 @@ void InsetSpecialChar::read(Buffer const *, LyXLex & lex)
if (command == "\\-")
kind = HYPHENATION;
else if (command == "\\textcompwordmark{}")
kind = HYPHENATION_BREAK;
else if (command == "\\@.")
kind = END_OF_SENTENCE;
else if (command == "\\ldots{}")
@ -187,11 +211,24 @@ int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/,
bool free_space) const
{
switch (kind) {
case HYPHENATION: os << "\\-"; break;
case END_OF_SENTENCE: os << "\\@."; break;
case LDOTS: os << "\\ldots{}"; break;
case MENU_SEPARATOR: os << "\\lyxarrow{}"; break;
case PROTECTED_SEPARATOR: os << (free_space ? " " : "~"); break;
case HYPHENATION:
os << "\\-";
break;
case HYPHENATION_BREAK:
os << "\\textcompwordmark{}";
break;
case END_OF_SENTENCE:
os << "\\@.";
break;
case LDOTS:
os << "\\ldots{}";
break;
case MENU_SEPARATOR:
os << "\\lyxarrow{}";
break;
case PROTECTED_SEPARATOR:
os << (free_space ? " " : "~");
break;
}
return 0;
}
@ -200,11 +237,21 @@ int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/,
int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const
{
switch (kind) {
case HYPHENATION: break;
case END_OF_SENTENCE: os << "."; break;
case LDOTS: os << "..."; break;
case MENU_SEPARATOR: os << "->"; break;
case PROTECTED_SEPARATOR: os << " "; break;
case HYPHENATION:
case HYPHENATION_BREAK:
break;
case END_OF_SENTENCE:
os << ".";
break;
case LDOTS:
os << "...";
break;
case MENU_SEPARATOR:
os << "->";
break;
case PROTECTED_SEPARATOR:
os << " ";
break;
}
return 0;
}

View File

@ -28,6 +28,8 @@ public:
enum Kind {
/// Optional hyphenation point (\-)
HYPHENATION,
/// Hyphenation break point (\textcompwordmark)
HYPHENATION_BREAK,
/// ... (\ldots)
LDOTS,
/// End of sentence punctuation (\@)

View File

@ -550,15 +550,13 @@ void LyX::queryUserLyXDir(bool explicit_userdir)
first_start = false;
return;
} else {
first_start = true;
first_start = !explicit_userdir;
}
// Nope
// Different wording if the user specifically requested a directory
if (!AskQuestion( explicit_userdir
? _("You have specified an invalid LyX directory.")
: _("You don't have a personal LyX directory.") ,
// If the user specified explicitely a directory, ask whether
// to create it (otherwise, always create it)
if (explicit_userdir &&
!AskQuestion(_("You have specified an invalid LyX directory."),
_("It is needed to keep your own configuration."),
_("Should I try to set it up for you (recommended)?"))) {
lyxerr << _("Running without personal LyX directory.") << endl;

View File

@ -707,52 +707,6 @@ Paragraph::getUChar(BufferParams const & bparams,
}
// return an string of the current word, and the end of the word in lastpos.
string const Paragraph::getWord(Paragraph::size_type & lastpos) const
{
lyx::Assert(lastpos >= 0);
// the current word is defined as starting at the first character
// from the immediate left of lastpospos which meets the definition
// of IsLetter(), continuing to the last character to the right
// of this meeting IsLetter.
string theword;
// grab a word
// move back until we have a letter
//there's no real reason to have firstpos & lastpos as
//separate variables as this is written, but maybe someon
// will want to return firstpos in the future.
//since someone might have typed a punctuation first
int firstpos = lastpos;
while ((firstpos >= 0) && !isLetter(firstpos))
--firstpos;
// now find the beginning by looking for a nonletter
while ((firstpos>= 0) && isLetter(firstpos))
--firstpos;
// the above is now pointing to the preceeding non-letter
++firstpos;
lastpos = firstpos;
// so copy characters into theword until we get a nonletter
// note that this can easily exceed lastpos, wich means
// that if used in the middle of a word, the whole word
// is included
while (isLetter(lastpos)) theword += getChar(lastpos++);
return theword;
}
void Paragraph::setFont(Paragraph::size_type pos,
LyXFont const & font)
{

View File

@ -260,8 +260,6 @@ public:
void setChar(size_type pos, value_type c);
///
void setFont(size_type pos, LyXFont const & font);
///
string const getWord(size_type &) const;
/// Returns the height of the highest font in range
LyXFont::FONT_SIZE highestFontInRange(size_type startpos,
size_type endpos) const;