+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.
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"
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"
}
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:
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;
-
- string curstring;
- if (curpos >= 0 )
- curstring = bv_->getLyXText()
- ->cursor.par()->getWord(curpos);
+ // Get word or selection
+ bv_->getLyXText()->selectWordWhenUnderCursor(bv_);
+
+ string const curstring =
+ bv_->getLyXText()->selectionAsString(buffer_);
- p.setContents( curstring );
+ p.setContents(curstring);
} else {
- p.setContents( argument );
+ p.setContents(argument);
}
- owner_->getDialogs()->createIndex( p.getAsString() );
+ owner_->getDialogs()->createIndex(p.getAsString());
}
break;
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);
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
}
}
-
-void BufferView::Pimpl::menuSeparator()
+void BufferView::Pimpl::specialChar(InsetSpecialChar::Kind kind)
{
if (available()) {
LyXText * lt = bv_->getLyXText();
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);
}
}
#include "frontends/Timeout.h"
#include "WorkArea.h"
#include "paragraph.h"
+#include "insets/insetspecialchar.h"
#ifdef __GNUG__
#pragma interface
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,
+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
{ 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",
LFUN_GOTONOTE,
LFUN_INSET_TOGGLE,
LFUN_HYPHENATION,
+ LFUN_HYPHENATION_BREAK,
LFUN_HFILL,
LFUN_DEPTH,
LFUN_FREE, // 30
+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
}
-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
}
}
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
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;
}
}
-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) {
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);
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;
}
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, "`"))
int InsetQuotes::docBook(Buffer const *, ostream & os) const
{
- if (times == InsetQuotes::DoubleQ) {
- if (side == InsetQuotes::LeftQ)
+ if (times_ == DoubleQ) {
+ if (side_ == LeftQ)
os << "“";
else
os << "”";
} else {
- if (side == InsetQuotes::LeftQ)
+ if (side_ == LeftQ)
os << "‘";
else
os << "’";
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;
Inset * InsetQuotes::clone(Buffer const &, bool) const
{
- return new InsetQuotes(language, side, times);
+ return new InsetQuotes(language_, side_, times_);
}
#include "inset.h"
class BufferParams;
+class Language;
struct LaTeXFeatures;
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.
///
void parseString(string const &);
///
- string const dispString() const;
+ string const dispString(Language const *) const;
};
#endif
w -= 2; // to make it look shorter
return w;
}
+ case HYPHENATION_BREAK:
+ {
+ return lyxfont::width('|', font);
+ }
case END_OF_SENTENCE:
{
return lyxfont::width('.', font);
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);
{
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 = "~";
if (command == "\\-")
kind = HYPHENATION;
+ else if (command == "\\textcompwordmark{}")
+ kind = HYPHENATION_BREAK;
else if (command == "\\@.")
kind = END_OF_SENTENCE;
else if (command == "\\ldots{}")
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;
}
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;
}
enum Kind {
/// Optional hyphenation point (\-)
HYPHENATION,
+ /// Hyphenation break point (\textcompwordmark)
+ HYPHENATION_BREAK,
/// ... (\ldots)
LDOTS,
/// End of sentence punctuation (\@)
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;
}
-// 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)
{
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;