/* This file is part of * ====================================================== * * LyX, The Document Processor * * Copyright (C) 1995 Matthias Ettrich * Copyright (C) 1995-1998 The LyX Team. *
*======================================================*/
// codes used to read/write quotes to LyX files staticcharconst *language_char = "esgpfa"; staticcharconst *side_char = "lr" ; staticcharconst *times_char ="sd";
// List of known quote chars staticcharconst *quote_char = ",'`<>";
// Index of chars used for the quote. Index is [side,language] int quote_index[2][6] =
{ { 2, 1, 0, 0, 3, 4 }, // "'',,<>"
{ 1, 1, 2, 1, 4, 3 } }; // "`'`'><"
// Corresponding LaTeX code, for double and single quotes. staticcharconst *latex_quote_t1[2][5] =
{ { "\\quotesinglbase{}", "'", "`", "\\guilsinglleft{}", "\\guilsinglright{}" },
{ ",,", "''", "``", "<<", ">>" } };
InsetQuotes::InsetQuotes(char c, BufferParams const ¶ms)
: language(params.quotes_language), times(params.quotes_times)
{ // Decide whether left or right switch(c) { case' ': case'(': case'{': case'[': case'-': case':': case LYX_META_HFILL: case LYX_META_PROTECTED_SEPARATOR: case LYX_META_NEWLINE:
side = InsetQuotes::LeftQ; // left quote break; default:
side = InsetQuotes::RightQ; // right quote
}
}
void InsetQuotes::ParseString(LString string)
{ int i; if (string.length() != 3) {
lyxerr.print("ERROR (InsetQuotes::InsetQuotes):" " bad string length.");
string = "eld";
}
for (i=0;i<6;i++) { if (string[0] == language_char[i]) {
language = (InsetQuotes::quote_language)i; break;
}
} if (i>=6) {
lyxerr.print("ERROR (InsetQuotes::InsetQuotes):" " bad language specification.");
language = InsetQuotes::EnglishQ;
}
for (i=0;i<2;i++) { if (string[1] == side_char[i]) {
side = (InsetQuotes::quote_side)i; break;
}
} if (i>=2) {
lyxerr.print("ERROR (InsetQuotes::InsetQuotes):" " bad side specification.");
side = InsetQuotes::LeftQ;
}
for (i=0;i<2;i++) { if (string[2] == times_char[i]) {
times = (InsetQuotes::quote_times)i; break;
}
} if (i>=2) {
lyxerr.print("ERROR (InsetQuotes::InsetQuotes):" " bad times specification.");
times = InsetQuotes::DoubleQ;
}
}
if (lyxrc->font_norm == "iso8859-1") if (disp == "<<")
disp = '«'; elseif (disp == ">>")
disp = '»';
return disp;
}
int InsetQuotes::Ascent(LyXFont const &font) const
{ return font.maxAscent();
}
int InsetQuotes::Descent(LyXFont const &font) const
{ return font.maxDescent();
}
int InsetQuotes::Width(LyXFont const &font) const
{
LString text = DispString(); int w = 0;
for (int i = 0; i < text.length(); i++) { if (text[i] == ' ')
w += font.width('i'); elseif (i == 0 || text[i] != text[i-1])
w += font.width(text[i]); else
w += font.width(',');
}
return w;
}
LyXFont InsetQuotes::ConvertFont(LyXFont font)
{ /* quotes-insets cannot be latex of any kind */
font.setLatex(LyXFont::OFF); return font;
}
void InsetQuotes::Draw(LyXFont font, LyXScreen &scr, int baseline, float &x)
{
LString text = DispString();
for (int i = 0; i < text.length(); i++) { if (text[i] == ' ')
x += font.width('i'); elseif (i == text.length()-1 || text[i] != text[i+1]) {
scr.drawString(font, &text[i], baseline, int(x));
x += font.width(text[i]);
} else {
scr.drawString(font, &text[i+1], baseline, int(x));
x += font.width(',');
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.