+2000-04-11 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/LaTeXFeatures.h: add a const reference to BufferParams, to
+ avoid some uses of current_view. Added also a bufferParams()
+ mathod to get at this.
+
+ * src/lyxtext.h: changed params->buffer and paramters->bparams.
+
+2000-04-10 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * src/lyxparagraph.[Ch]: removed
+ operator<(LyXParagraph::InsetTabe..., added a struct matchIT
+ with operators used by lower_bound and
+ upper_bound in InsetTable's
+ Make struct InsetTable private again. Used matchpos.
+
+2000-04-08 Dekel Tsur <dekel@math.tau.ac.il>
+
+ * src/lyx_cb.C (DocumentApplyCB): When changing the language of the
+ document, the language of existing text is changed (unless the
+ document is multi-lingual)
+
+ * src/buffer.C (ChangeLanguage,isMultiLingual) New methods.
+
+ * src/paragraph.C (ChangeLanguage,isMultiLingual) New methods.
+
+ * A lot of files: A rewrite of the Right-to-Left support.
+
2000-04-10 Juergen Vigna <jug@sad.it>
* src/BufferView2.C (showLockedInsetCursor): small bugfix for
// and cannot do this as the cursor is behind the inset and GetInset
// does not return the inset!
if (inset->IsTextInset()) {
- if (text->cursor.par->getParDirection()==LYX_DIR_LEFT_TO_RIGHT)
- text->CursorLeft();
- else
+ if (text->cursor.par->isRightToLeftPar())
text->CursorRight();
+ else
+ text->CursorLeft();
}
#endif
update(-1);
if (!lyxrc.rtl_support)
return;
- if (bv_->text->real_current_font.isVisibleRightToLeft()) {
+ if (bv_->text->real_current_font.isRightToLeft() &&
+ bv_->text->real_current_font.latex() != LyXFont::ON) {
if (owner_->getIntl()->primarykeymap)
owner_->getIntl()->KeyMapSec();
} else {
#pragma implementation
#endif
+using std::pair;
+
static LyXParagraph * buf = 0;
CutAndPaste::CutAndPaste()
using std::endl;
-LaTeXFeatures::LaTeXFeatures(int n)
- : layout(n, false)
+LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n)
+ : layout(n, false), params(p)
{
// packages
color = false;
}
-string LaTeXFeatures::getPackages(BufferParams const & params)
+string LaTeXFeatures::getPackages()
{
string packages;
- LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass =
+ textclasslist.TextClass(params.textclass);
// color.sty
if (color) {
packages += "\\doublespacing\n";
break;
case Spacing::Other:
- //char value[30];
- //sprintf(value, "%.2f", params.spacing.getValue());
#ifdef HAVE_SSTREAM
std::ostringstream value;
#else
}
-string LaTeXFeatures::getMacros(BufferParams const & /* params */)
+string LaTeXFeatures::getMacros()
{
string macros;
}
-string LaTeXFeatures::getTClassPreamble(BufferParams const & params)
+string LaTeXFeatures::getTClassPreamble()
{
// the text class specific preamble
- LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+ LyXTextClass const & tclass =
+ textclasslist.TextClass(params.textclass);
string tcpreamble = tclass.preamble();
for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
}
-void LaTeXFeatures::showStruct(BufferParams const & params) {
+void LaTeXFeatures::showStruct() {
lyxerr << "LyX needs the following commands when LaTeXing:"
- // packs
- << "\n***** Packages:" << getPackages(params)
- << "\n***** Macros:" << getMacros(params)
- << "\n***** Textclass stuff:" << getTClassPreamble(params)
+ << "\n***** Packages:" << getPackages()
+ << "\n***** Macros:" << getMacros()
+ << "\n***** Textclass stuff:" << getTClassPreamble()
<< "\n***** done." << endl;
}
+
+
+BufferParams const & LaTeXFeatures::bufferParams() const
+{
+ return params;
+}
in buffer.C and paragraph.C when you do so. */
struct LaTeXFeatures {
///
- explicit LaTeXFeatures(int n) ;
+ LaTeXFeatures(BufferParams const &, int n) ;
/// The packaes needed by the document
- string getPackages(BufferParams const & params);
+ string getPackages();
/// The macros definitions needed by the document
- string getMacros(BufferParams const & params);
+ string getMacros();
/// The definitions needed by the document's textclass
- string getTClassPreamble(BufferParams const & params);
+ string getTClassPreamble();
///
- void showStruct(BufferParams const & params);
+ void showStruct();
//@Man: Packages
//@{
///
LanguageList UsedLanguages;
//@}
+ BufferParams const & bufferParams() const;
+private:
+ BufferParams const & params;
};
#endif
text_fits(Buffer * b, unsigned short p)
: buf(b), pw(p) {}
bool operator()(TextCache::value_type & vt) {
- if (vt->params == buf && vt->paperWidth() == pw) return true;
+ if (vt->buffer == buf && vt->paperWidth() == pw) return true;
return false;
}
private:
public:
show_text(ostream & o) : os(o) {}
void operator()(TextCache::value_type & vt) {
- os << "\tBuffer: " << vt->params
+ os << "\tBuffer: " << vt->buffer
<< "\tWidth: " << vt->paperWidth() << endl;
}
private:
void TextCache::add(LyXText * text)
{
lyxerr.debug() << "TextCache::add " << text;
- if (bufferlist.isLoaded(text->params)) {
+ if (bufferlist.isLoaded(text->buffer)) {
cache.push_back(text);
lyxerr.debug() << " added" << endl;
} else {
has_buffer(Buffer * b)
: buf(b) {}
bool operator()(TextCache::value_type & vt) {
- if (vt->params == buf) return true;
+ if (vt->buffer == buf) return true;
return false;
}
private:
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
- LaTeXFeatures features(tclass.numLayouts());
+ LaTeXFeatures features(params, tclass.numLayouts());
validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
string preamble, tmppreamble;
// The optional packages;
- preamble = features.getPackages(params);
+ preamble = features.getPackages();
// this might be useful...
preamble += "\n\\makeatletter\n\n";
// Some macros LyX will need
- tmppreamble = features.getMacros(params);
+ tmppreamble = features.getMacros();
if (!tmppreamble.empty()) {
preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
}
// the text class specific preamble
- tmppreamble = features.getTClassPreamble(params);
+ tmppreamble = features.getTClassPreamble();
if (!tmppreamble.empty()) {
preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"Textclass specific LaTeX commands.\n"
}
if (lyxerr.debugging(Debug::LATEX)) {
- features.showStruct(params);
+ features.showStruct();
}
}
} // end of switch
}
+
+void Buffer::ChangeLanguage(Language const * from, Language const * to)
+{
+
+ LyXParagraph * par = paragraph;
+ while (par) {
+ par->ChangeLanguage(from,to);
+ par = par->next;
+ }
+}
+
+bool Buffer::isMultiLingual()
+{
+
+ LyXParagraph * par = paragraph;
+ while (par) {
+ if (par->isMultiLingual())
+ return true;
+ par = par->next;
+ }
+ return false;
+}
than one user per buffer. */
BufferView * getUser() const { return users; }
+ ///
+ void ChangeLanguage(Language const * from, Language const * to);
+ ///
+ bool isMultiLingual();
+
//@}
/// Does this mean that this is buffer local?
#ifdef WITH_WARNINGS
#warning remove this once we have a proper geometry class
#endif
- BufferParams::PAPER_SIZE ps = static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
+ BufferParams::PAPER_SIZE ps =
+ static_cast<BufferParams::PAPER_SIZE>(bv->buffer()->params.papersize);
switch (ps) {
case BufferParams::PAPER_A4PAPER:
add_flags = "-p a4";
bool redo = false;
BufferParams * params = &(current_view->buffer()->params);
+ Language const * old_language = params->language_info;
+ Language const * new_language;
params->language = combo_language->getline();
Languages::iterator lit = languages.find(params->language);
if (lit != languages.end())
- params->language_info = &(*lit).second;
+ new_language = &(*lit).second;
else
- params->language_info = default_language;
+ new_language = default_language;
+
+ if (current_view->available()) {
+ if (old_language != new_language &&
+ old_language->RightToLeft == new_language->RightToLeft &&
+ ! current_view->buffer()->isMultiLingual() ) {
+ current_view->buffer()->ChangeLanguage(old_language,
+ new_language);
+ current_view->buffer()->redraw();
+ }
+ }
+ params->language_info = new_language;
// If default skip is a "Length" but there's no text in the
// input field, reset the kind to "Medskip", which is the default.
if (!current_view->available())
return;
- current_view->text->SetCursor(current_view->text->cursor.par,
- current_view->text->cursor.pos);
- current_view->setState();
+
+ current_view->text->SetCursor(current_view->text->cursor.par,
+ current_view->text->cursor.pos);
+ current_view->setState();
LyXTextClassList::ClassList::size_type new_class =
fl_get_choice(fd_form_document->choice_class) - 1;
return string();
else {
setMessage(N_("Text mode"));
- LyXDirection direction = owner->view()->text->
- cursor.par->getParDirection();
switch(action) {
case LFUN_UNKNOWN_ACTION:
case LFUN_BREAKPARAGRAPH:
owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_RIGHT:
- if (direction == LYX_DIR_LEFT_TO_RIGHT) {
+ if (!owner->view()->text->cursor.par->isRightToLeftPar()) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
}
return string();
case LFUN_LEFT:
- if (direction == LYX_DIR_RIGHT_TO_LEFT) {
+ if (owner->view()->text->cursor.par->isRightToLeftPar()) {
owner->view()->text->CursorRight();
moveCursorUpdate(false);
owner->getMiniBuffer()->
// Pretend we got the name instead.
Dispatch(int(LFUN_LAYOUT),
textclasslist.NameOfLayout(owner->view()->
- text->parameters->
+ text->bparams->
textclass,
sel).c_str());
return string();
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
LyXTextClassList::ClassList::size_type tclass =
- owner->view()->text->parameters->textclass;
+ owner->view()->text->bparams->textclass;
pair <bool, LyXTextClass::size_type> layout =
textclasslist.NumberOfLayout(tclass, argument);
case LFUN_EMPH:
Emph();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_BOLD:
Bold();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_NOUN:
Noun();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_CODE:
Code();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_SANS:
Sans();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_ROMAN:
Roman();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_DEFAULT:
StyleReset();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_UNDERLINE:
Underline();
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_FONT_SIZE:
FontSize(argument);
+ owner->getMiniBuffer()->Set(CurrentState());
break;
case LFUN_FONT_STATE:
case LFUN_RIGHT:
{
LyXText * tmptext = owner->view()->text;
- LyXDirection direction =
- tmptext->cursor.par->getParDirection();
+ bool is_rtl = tmptext->cursor.par->isRightToLeftPar();
if(!tmptext->mark_set)
owner->view()->beforeChange();
owner->view()->update(-2);
- if (direction == LYX_DIR_RIGHT_TO_LEFT)
+ if (is_rtl)
tmptext->CursorLeft();
if (tmptext->cursor.pos < tmptext->cursor.par->Last()
&& tmptext->cursor.par->GetChar(tmptext->cursor.pos)
tmpinset->Edit(owner->view(), 0, 0, 0);
break;
}
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
+ if (!is_rtl)
tmptext->CursorRight();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
// This is soooo ugly. Isn`t it possible to make
// it simpler? (Lgb)
LyXText * txt = owner->view()->text;
- LyXDirection direction = txt->cursor.par->getParDirection();
+ bool is_rtl = txt->cursor.par->isRightToLeftPar();
if(!txt->mark_set) owner->view()->beforeChange();
owner->view()->update(-2);
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
+ if (!is_rtl)
txt->CursorLeft();
if (txt->cursor.pos < txt->cursor.par->Last()
&& txt->cursor.par->GetChar(txt->cursor.pos)
0, 0);
break;
}
- if (direction == LYX_DIR_RIGHT_TO_LEFT)
+ if (is_rtl)
txt->CursorRight();
owner->view()->text->FinishUndo();
if(!owner->view()->text->mark_set)
owner->view()->beforeChange();
owner->view()->update(-2);
- if (owner->view()->text->cursor.par->getParDirection()
- == LYX_DIR_LEFT_TO_RIGHT)
- owner->view()->text->CursorRightOneWord();
- else
+ if (owner->view()->text->cursor.par->isRightToLeftPar())
owner->view()->text->CursorLeftOneWord();
+ else
+ owner->view()->text->CursorRightOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
if(!owner->view()->text->mark_set)
owner->view()->beforeChange();
owner->view()->update(-2);
- if (owner->view()->text->cursor.par->getParDirection()
- == LYX_DIR_LEFT_TO_RIGHT)
- owner->view()->text->CursorLeftOneWord();
- else
+ if (owner->view()->text->cursor.par->isRightToLeftPar())
owner->view()->text->CursorRightOneWord();
+ else
+ owner->view()->text->CursorLeftOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(false);
owner->getMiniBuffer()->Set(CurrentState());
/* cursor selection ---------------------------- */
case LFUN_RIGHTSEL:
owner->view()->update(-2);
- if (owner->view()->text->cursor.par->getParDirection()
- == LYX_DIR_LEFT_TO_RIGHT)
- owner->view()->text->CursorRight();
- else
+ if (owner->view()->text->cursor.par->isRightToLeftPar())
owner->view()->text->CursorLeft();
+ else
+ owner->view()->text->CursorRight();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
case LFUN_LEFTSEL:
owner->view()->update(-2);
- if (owner->view()->text->cursor.par->getParDirection()
- == LYX_DIR_LEFT_TO_RIGHT)
- owner->view()->text->CursorLeft();
- else
+ if (owner->view()->text->cursor.par->isRightToLeftPar())
owner->view()->text->CursorRight();
+ else
+ owner->view()->text->CursorLeft();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
case LFUN_WORDRIGHTSEL:
owner->view()->update(-2);
- if (owner->view()->text->cursor.par->getParDirection()
- == LYX_DIR_LEFT_TO_RIGHT)
- owner->view()->text->CursorRightOneWord();
- else
+ if (owner->view()->text->cursor.par->isRightToLeftPar())
owner->view()->text->CursorLeftOneWord();
+ else
+ owner->view()->text->CursorRightOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
case LFUN_WORDLEFTSEL:
owner->view()->update(-2);
- if (owner->view()->text->cursor.par->getParDirection()
- == LYX_DIR_LEFT_TO_RIGHT)
- owner->view()->text->CursorLeftOneWord();
- else
+ if (owner->view()->text->cursor.par->isRightToLeftPar())
owner->view()->text->CursorRightOneWord();
+ else
+ owner->view()->text->CursorLeftOneWord();
owner->view()->text->FinishUndo();
moveCursorUpdate(true);
owner->getMiniBuffer()->Set(CurrentState());
#include "vspace.h"
#include "layout.h"
#include "support/block.h"
-#include "direction.h"
#include "language.h"
class BufferParams;
///
Language const * getParLanguage() const;
///
- Language const * getLetterLanguage(size_type pos) const;
-
+ bool isRightToLeftPar() const;
///
- LyXDirection getParDirection() const;
+ void ChangeLanguage(Language const * from, Language const * to);
///
- LyXDirection getLetterDirection(size_type pos) const;
+ bool isMultiLingual();
///
void writeFile(std::ostream &, BufferParams const &, char, char) const;
/** Check if the current paragraph is the last paragraph in a
proof environment */
int GetEndLabel() const;
-
+ ///
Inset * InInset() { return inset_owner; }
- void SetInsetOwner(Inset *i) { inset_owner = i; }
-
+ ///
+ void SetInsetOwner(Inset * i) { inset_owner = i; }
private:
///
TextContainer text;
///
void SimpleDocBookOneTablePar(std::ostream &, string & extra,
int & desc_on, int depth);
+private:
///
struct InsetTable {
///
///
InsetTable(size_type p, Inset * i) { pos = p; inset = i;}
};
-private:
+ ///
+ struct matchIT {
+ /// used by lower_bound
+ inline
+ int operator()(LyXParagraph::InsetTable const & a,
+ LyXParagraph::size_type pos) const {
+ return a.pos < pos;
+ }
+ /// used by upper_bound
+ inline
+ int operator()(LyXParagraph::size_type pos,
+ LyXParagraph::InsetTable const & a) const {
+ return pos < a.pos;
+ }
+ };
/** A font entry covers a range of positions. Notice that the
entries in the list are inserted in random order.
I don't think it's worth the effort to implement a more effective
LyXParagraph * TeXFootnote(std::ostream &, TexRow & texrow,
std::ostream & foot, TexRow & foot_texrow,
int & foot_count,
- LyXDirection par_direction);
+ bool parent_is_rtl);
///
bool SimpleTeXOneTablePar(std::ostream &, TexRow & texrow);
///
static unsigned int paragraph_id;
};
-inline bool operator<(LyXParagraph::InsetTable const & a,
- LyXParagraph::InsetTable const & b)
-{
- return a.pos < b.pos;
-}
-
#endif
RC_MAKE_BACKUP,
RC_BACKUPDIR_PATH,
RC_RTL_SUPPORT,
- RC_NUMBER_INSET,
+ RC_AUTO_NUMBER,
RC_LANGUAGE_PACKAGE,
RC_LANGUAGE_AUTO_BEGIN,
RC_LANGUAGE_AUTO_END,
{ "\\alternate_language", RC_ALT_LANG },
{ "\\ascii_linelen", RC_ASCII_LINELEN },
{ "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
+ { "\\auto_number", RC_AUTO_NUMBER },
{ "\\auto_region_delete", RC_AUTOREGIONDELETE },
{ "\\autosave", RC_AUTOSAVE },
{ "\\background_color", RC_BACKGROUND_COLOR },
{ "\\literate_extension", RC_LITERATE_EXTENSION },
{ "\\make_backup", RC_MAKE_BACKUP },
{ "\\num_lastfiles", RC_NUMLASTFILES },
- { "\\number_inset", RC_NUMBER_INSET },
{ "\\pdf_mode", RC_PDF_MODE },
{ "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
{ "\\pdflatex_command", RC_PDFLATEX_COMMAND },
use_kbmap = false;
hasBindFile = false;
rtl_support = false;
- number_inset = "rtl";
+ auto_number = true;
language_package = "\\usepackage{babel}";
language_auto_begin = true;
language_auto_end = true;
if (lexrc.next())
rtl_support = lexrc.GetBool();
break;
- case RC_NUMBER_INSET:
+ case RC_AUTO_NUMBER:
if (lexrc.next())
- number_inset = lowercase(lexrc.GetString());
+ auto_number = lexrc.GetBool();
break;
case RC_SHOW_BANNER:
if (lexrc.next())
os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
case RC_RTL_SUPPORT:
os << "\\rtl " << tostr(rtl_support) << "\n";
- case RC_NUMBER_INSET:
- os << "\\number_inset " << number_inset << "\n";
+ case RC_AUTO_NUMBER:
+ os << "\\auto_number" << tostr(auto_number) << "\n";
case RC_LANGUAGE_AUTO_BEGIN:
os << "\\language_auto_begin "
<< tostr(language_auto_begin) << "\n";
///
bool rtl_support;
///
- string number_inset;
+ bool auto_number;
///
bool show_banner;
/// Do we have to use a GUI?
FORM_FINAL
};
+ /// Constructor
+ LyXText(BufferView *, int paperwidth, Buffer *);
+
+ /// Destructor
+ ~LyXText();
+
/// points to Buffer.params
- BufferParams * parameters;
+ BufferParams * bparams;
/// points to Buffer
- Buffer * params;
+ Buffer * buffer;
///
mutable int number_of_rows;
///
/// the current font
mutable LyXFont real_current_font;
- /// Constructor
- LyXText(BufferView *, int paperwidth, Buffer *);
-
- /// Destructor
- ~LyXText();
-
///
void owner(BufferView *);
///
mutable std::vector<LyXParagraph::size_type> vis2log_list;
+ ///
+ mutable std::vector<LyXParagraph::size_type> bidi_levels;
+
///
mutable LyXParagraph::size_type bidi_start;
///
void ComputeBidiTables(Row *row) const;
- ///
- void ComputeBidiTablesFromTo(Row *row,
- LyXParagraph::size_type from,
- LyXParagraph::size_type to,
- LyXParagraph::size_type offset) const;
-
/// Maps positions in the visual string to positions in logical string.
inline
LyXParagraph::size_type log2vis(LyXParagraph::size_type pos) const {
return vis2log_list[pos-bidi_start];
}
+ inline
+ int bidi_level(LyXParagraph::size_type pos) const {
+ if (bidi_start == -1)
+ return 0;
+ else
+ return bidi_levels[pos-bidi_start];
+ }
+
///
unsigned char TransformChar(unsigned char c, Letter_Form form) const;
specified row
*/
LyXParagraph::size_type RowLast(Row const * row) const;
+ ///
+ LyXParagraph::size_type RowLastPrintable(Row const * row) const;
+
///
void charInserted();
};
void LyXParagraph::validate(LaTeXFeatures & features) const
{
+ BufferParams const & params = features.bufferParams();
+
// this will be useful later
LyXLayout const & layout =
- textclasslist.Style(current_view->buffer()->params.textclass,
+ textclasslist.Style(params.textclass,
GetLayout());
// check the params.
features.layout[GetLayout()] = true;
// then the fonts
- Language const * doc_language = current_view->buffer()->params.language_info;
+ Language const * doc_language = params.language_info;
+
for (FontList::const_iterator cit = fontlist.begin();
cit != fontlist.end(); ++cit) {
if ((*cit).font.noun() == LyXFont::ON) {
if (layout.needprotect
&& next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
features.NeedLyXFootnoteCode = true;
- if ((current_view->buffer()->params.paragraph_separation == BufferParams::PARSEP_INDENT) &&
- (pextra_type == LyXParagraph::PEXTRA_MINIPAGE))
+ if (params.paragraph_separation == BufferParams::PARSEP_INDENT
+ && pextra_type == LyXParagraph::PEXTRA_MINIPAGE)
features.NeedLyXMinipageIndent = true;
if (table && table->NeedRotating())
features.rotating = true;
// find the entry
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
if (it != insetlist.end() && (*it).pos == pos)
(*it).inset = 0;
} else {
// ale970302
delete bibkey;
+ //
+ lyxerr << "LyXParagraph::paragraph_id = "
+ << LyXParagraph::paragraph_id << endl;
}
// find the entry
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
if (it != insetlist.end() && (*it).pos == pos) {
delete (*it).inset;
insetlist.erase(it);
// Update the inset table.
for (InsetList::iterator it = upper_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
it != insetlist.end(); ++it)
--(*it).pos;
} else {
// Update the inset table.
for (InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
it != insetlist.end(); ++it)
++(*it).pos;
}
// Add a new entry in the inset table.
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
if (it != insetlist.end() && (*it).pos == pos)
lyxerr << "ERROR (LyXParagraph::InsertInset): "
"there is an inset in position: " << pos << endl;
else
- insetlist.insert(it,InsetTable(pos,inset));
+ insetlist.insert(it, InsetTable(pos,inset));
}
}
// Find the inset.
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
if (it != insetlist.end() && (*it).pos == pos)
return (*it).inset;
// Find the inset.
InsetList::const_iterator cit = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos,0));
+ pos, matchIT());
if (cit != insetlist.end() && (*cit).pos == pos)
return (*cit).inset;
++pos_first;
pos_end = pos_first + par->text.size() - 1;
- // The constructor has already reserved 500 elements
- //if (pos_end > pos)
- // tmp->text.reserve(pos_end - pos);
for (i = j = pos; i <= pos_end; ++i) {
par->CutIntoMinibuffer(i - pos_first);
while (ParFromPos(pos_first) != par)
++pos_first;
size_type pos_end = pos_first + par->text.size() - 1;
- // make sure there is enough memory for the now larger
- // paragraph. This is not neccessary, because
- // InsertFromMinibuffer will enlarge the memory (it uses
- // InsertChar of course). But doing it by hand
- // is MUCH faster! (only one time, not thousend times!!)
- // Not needed since the constructor aleady have
- // reserved 500 elements in text.
- //if (pos_end > pos)
- // tmp->text.reserve(pos_end - pos);
size_type i, j;
for (i = j = pos; i <= pos_end; ++i) {
return END_LABEL_NO_LABEL;
}
+
LyXTextClass::size_type LyXParagraph::GetLayout() const
{
return FirstPhysicalPar()->layout;
int LyXParagraph::AutoDeleteInsets()
{
int count = 0;
- unsigned int i = 0;
- while (i < insetlist.size()) {
- if (insetlist[i].inset && insetlist[i].inset->AutoDelete()) {
- Erase(insetlist[i].pos);
- // Erase() calls to insetlist.erase(&insetlist[i])
- // so i shouldn't be increased.
+ InsetList::size_type index = 0;
+ while (index < insetlist.size()) {
+ if (insetlist[index].inset && insetlist[index].inset->AutoDelete()) {
+ Erase(insetlist[index].pos);
+ // Erase() calls to insetlist.erase(&insetlist[index])
+ // so index shouldn't be increased.
++count;
} else
- ++i;
+ ++index;
}
return count;
}
{
InsetList::iterator it = lower_bound(insetlist.begin(),
insetlist.end(),
- InsetTable(pos, 0));
+ pos, matchIT());
if (it != insetlist.end()) {
pos = (*it).pos;
return (*it).inset;
int LyXParagraph::GetPositionOfInset(Inset * inset) const
{
// Find the entry.
+ // We could use lower_bound here too, we just need to add
+ // the approp. operator() to matchIT (and change the name
+ // of that struct). Code would then be:
+ // InsetList::const_iterator cit = lower_bound(insetlist.begin(),
+ // insetlist.end(),
+ // inset, matchIT());
+ // if ((*cit).inset == inset) {
+ // return (*cit).pos;
+ // }
for (InsetList::const_iterator cit = insetlist.begin();
cit != insetlist.end(); ++cit) {
if ((*cit).inset == inset) {
while (par &&
par->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
par->footnoteflag != footnoteflag) {
- LyXDirection dir = (is_rtl)
- ? LYX_DIR_RIGHT_TO_LEFT
- : LYX_DIR_LEFT_TO_RIGHT;
par = par->TeXFootnote(os, texrow, foot,
foot_texrow, foot_count,
- dir);
+ is_rtl);
par->SimpleTeXOnePar(os, texrow);
is_rtl = par->GetFontSettings(par->size()-1).isRightToLeft();
if (par->next &&
&& par->footnoteflag != footnoteflag) {
par = par->TeXFootnote(os, texrow,
foot, foot_texrow, foot_count,
- LYX_DIR_LEFT_TO_RIGHT);
+ false);
par->SimpleTeXOnePar(os, texrow);
par = par->next;
}
texrow.start(this, 0);
+ bool is_rtl = getParLanguage()->RightToLeft;
+ bool first_in_cell = true;
+
for (size_type i = 0; i < size(); ++i) {
char c = GetChar(i);
if (table->IsContRow(current_cell_number + 1)) {
continue;
}
++column;
-
+
+ if (first_in_cell && is_rtl) {
+ os << "\\R{";
+ column += 3;
+ first_in_cell = false;
+ }
+
// Fully instantiated font
LyXFont font = getFont(i);
last_font = running_font;
current_cell_number,
column, texrow);
}
+ if (is_rtl && !first_in_cell) {
+ os << "}";
+ first_in_cell = true;
+ }
+
// if this cell follow only ContRows till end don't
// put the EndOfCell because it is put after the
// for(...)
running_font.latexWriteEndChanges(os, basefont, basefont);
}
++current_cell_number;
+ if (is_rtl && !first_in_cell)
+ os << "}";
tmp = table->TexEndOfCell(os, current_cell_number);
for (; tmp > 0; --tmp)
texrow.newline();
LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
ostream & foot, TexRow & foot_texrow,
int & foot_count,
- LyXDirection parent_direction)
+ bool parent_is_rtl)
{
lyxerr[Debug::LATEX] << "TeXFootnote... " << this << endl;
if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
}
bool need_closing = false;
- LyXDirection direction = getParDirection();
- if (direction != parent_direction) {
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
- os << "\\L{";
- else
+ bool is_rtl = isRightToLeftPar();
+ if (is_rtl != parent_is_rtl) {
+ if (is_rtl)
os << "\\R{";
+ else
+ os << "\\L{";
need_closing = true;
}
return IsWordChar(GetChar(pos)) ;
}
+
Language const * LyXParagraph::getParLanguage() const
{
- if (!table && size() > 0)
- return FirstPhysicalPar()->GetFirstFontSettings().language();
+ if (size() > 0)
+ if (!table)
+ return FirstPhysicalPar()->GetFirstFontSettings()
+ .language();
+ else {
+ for (size_type pos = 0; pos < size(); ++pos)
+ if (IsNewline(pos))
+ return GetFontSettings(pos).language();
+ return GetFirstFontSettings().language();
+ }
else if (previous)
return previous->getParLanguage();
else
return current_view->buffer()->params.language_info;
}
-Language const * LyXParagraph::getLetterLanguage(size_type pos) const
+
+bool LyXParagraph::isRightToLeftPar() const
{
- return GetFontSettings(pos).language();
+ return lyxrc.rtl_support && !table && getParLanguage()->RightToLeft;
}
-LyXDirection LyXParagraph::getParDirection() const
+
+void LyXParagraph::ChangeLanguage(Language const * from, Language const * to)
{
- if (!lyxrc.rtl_support || table)
- return LYX_DIR_LEFT_TO_RIGHT;
- else if (getParLanguage()->RightToLeft)
- return LYX_DIR_RIGHT_TO_LEFT;
- else
- return LYX_DIR_LEFT_TO_RIGHT;
+ for(size_type i = 0; i < size(); ++i) {
+ LyXFont font = GetFontSettings(i);
+ if (font.language() == from) {
+ font.setLanguage(to);
+ SetFont(i,font);
+ }
+ }
}
-LyXDirection
-LyXParagraph::getLetterDirection(LyXParagraph::size_type pos) const
+
+bool LyXParagraph::isMultiLingual()
{
- if (!lyxrc.rtl_support)
- return LYX_DIR_LEFT_TO_RIGHT;
- else if (table && IsNewline(pos))
- return LYX_DIR_LEFT_TO_RIGHT;
-
- bool is_rtl = GetFontSettings(pos).isVisibleRightToLeft();
- if (IsLineSeparator(pos) && 0 < pos && pos < Last() - 1
- && !IsLineSeparator(pos + 1)
- && !(table && IsNewline(pos + 1))
- && ( GetFontSettings(pos - 1).isVisibleRightToLeft() != is_rtl
- || GetFontSettings(pos + 1).isVisibleRightToLeft() != is_rtl))
- return getParDirection();
- else
- return (is_rtl) ? LYX_DIR_RIGHT_TO_LEFT
- : LYX_DIR_LEFT_TO_RIGHT;
+ Language const * doc_language =
+ current_view->buffer()->params.language_info;
+ for(size_type i = 0; i < size(); ++i) {
+ LyXFont font = GetFontSettings(i);
+ if (font.language() != doc_language)
+ return true;
+ }
+ return false;
}
if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE;
if (text->real_current_font.language() !=
- text->parameters->language_info
+ text->bparams->language_info
|| text->real_current_font.isVisibleRightToLeft()
- != text->parameters->language_info->RightToLeft)
+ != text->bparams->language_info->RightToLeft)
shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE;
ShowManualCursor(text->cursor.x, text->cursor.y,
0xfe // 0xea = ya
};
+
bool is_arabic(unsigned char c)
{
return 0xa8 <= c && c <= 0xea && iso885968x[c-0xa8];
}
+
unsigned char LyXText::TransformChar(unsigned char c, Letter_Form form) const
{
if (is_arabic(c) &&
return c;
}
+
unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par,
LyXParagraph::size_type pos) const
{
if (!is_arabic(c))
- return c;
+ if (isdigit(c))
+ return c + (0xb0 - '0');
+ else
+ return c;
bool not_first = (pos > 0 && is_arabic(par->GetChar(pos-1)));
if (pos < par->Last()-1 && is_arabic(par->GetChar(pos+1)))
// The most common case is handled first (Asger)
if (IsPrintable(c)) {
- if (lyxrc.rtl_support && lyxrc.font_norm == "iso8859-6.8x")
+ if (font.language()->lang == "arabic" &&
+ lyxrc.font_norm == "iso8859-6.8x")
c = TransformChar(c, par, pos);
return lyxfont::width(c, font);
}
-
+LyXParagraph::size_type LyXText::RowLastPrintable(Row const * row) const
+{
+ LyXParagraph::size_type last = RowLast(row);
+ if (last >= row->pos && row->next && row->next->par == row->par &&
+ row->par->IsSeparator(last))
+ return last - 1;
+ else
+ return last;
+}
void LyXText::ComputeBidiTables(Row * row) const
bidi_start = -1;
return;
}
- LyXParagraph::size_type last = RowLast(row);
+ LyXParagraph::size_type last = RowLastPrintable(row);
bidi_start = row->pos;
if (bidi_start > last) {
500 : 2 * (last + 2 - bidi_start);
log2vis_list.resize(new_size);
vis2log_list.resize(new_size);
+ bidi_levels.resize(new_size);
}
vis2log_list[last + 1 - bidi_start] = -1;
log2vis_list[last + 1 - bidi_start] = -1;
+ LyXParagraph::size_type stack[2];
+ bool rtl_par = row->par->getParLanguage()->RightToLeft;
+ int level = 0;
+ bool rtl = false;
+ bool rtl0 = false;
LyXParagraph::size_type main_body = BeginningOfMainBody(row->par);
- if (main_body > 0 && row->pos < main_body - 1 && main_body - 1 <= last
- && row->par->IsLineSeparator(main_body - 1)) {
- // This is needed in case there is a direction change in
- // the label which is continued into the main body
- if (row->par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT) {
- ComputeBidiTablesFromTo(row, bidi_start,
- main_body - 2, 0);
- log2vis_list[main_body - 1 - bidi_start] =
- main_body - 1;
- vis2log_list[main_body - 1 - bidi_start] =
- main_body - 1;
- if (main_body <= last)
- ComputeBidiTablesFromTo(row,
- main_body,last, 0);
- } else {
- ComputeBidiTablesFromTo(row, bidi_start,
- main_body - 2,
- last - main_body + 2);
- log2vis_list[main_body - 1 - bidi_start] =
- last - main_body + 1 + bidi_start;
- vis2log_list[last - main_body + 1 - bidi_start] =
- main_body - 1;
- if (main_body <= last)
- ComputeBidiTablesFromTo(row, main_body,
- last, -main_body);
- }
- } else
- ComputeBidiTablesFromTo(row, bidi_start, last, 0);
-}
+ for (LyXParagraph::size_type lpos = bidi_start; lpos <= last; ++lpos) {
+ bool is_space = row->par->IsLineSeparator(lpos);
+ LyXParagraph::size_type pos =
+ (is_space && lpos+1 <= last &&
+ (!row->par->table || !row->par->IsNewline(lpos+1)) )
+ ? lpos + 1 : lpos;
+ LyXFont font = row->par->GetFontSettings(pos);
+ bool new_rtl = font.isVisibleRightToLeft();
+ bool new_rtl0 = font.isRightToLeft();
+ int new_level;
+
+ if (row->par->table && row->par->IsNewline(lpos)) {
+ new_level = 0;
+ new_rtl = new_rtl0 = false;
+ } else if (lpos == main_body - 1 && row->pos < main_body - 1 &&
+ row->par->IsLineSeparator(lpos)) {
+ new_level = (rtl_par) ? 1 : 0;
+ new_rtl = new_rtl0 = rtl_par;
+ } else if (new_rtl0)
+ new_level = (new_rtl) ? 1 : 2;
+ else
+ new_level = (rtl_par) ? 2 : 0;
-void LyXText::ComputeBidiTablesFromTo(Row * row,
- LyXParagraph::size_type from,
- LyXParagraph::size_type to,
- LyXParagraph::size_type offset) const
-{
- LyXParagraph::size_type vpos, old_lpos, stack[2];
- LyXDirection par_direction = row->par->getParDirection();
- LyXDirection direction = par_direction;
- LyXParagraph::size_type lpos = from;
- int level = 0;
+ if (is_space && new_level >= level) {
+ new_level = level;
+ new_rtl = rtl;
+ new_rtl0 = rtl0;
+ }
- while (lpos <= to) {
- if (row->par->getLetterDirection(lpos) == direction) {
- log2vis_list[lpos - bidi_start] = direction;
- ++lpos;
- } else {
- if (level == 0 ||
- (level == 1 && direction == LYX_DIR_RIGHT_TO_LEFT
- && row->par->getFont(lpos).isRightToLeft()
- && row->par->getFont(lpos).latex() == LyXFont::ON
- ) ) {
- // The last check is needed when the
- // char is a space
- stack[level++] = lpos;
- } else {
- old_lpos = stack[--level];
- log2vis_list[old_lpos - bidi_start] =
- log2vis_list[lpos - bidi_start] =
- (old_lpos - lpos) * direction;
- ++lpos;
- }
- direction = static_cast<LyXDirection>(-direction);
- bidi_same_direction = false;
+ int new_level2 = new_level;
+
+ if (level == new_level && rtl0 != new_rtl0) {
+ --new_level2;
+ log2vis_list[lpos - bidi_start] = (rtl) ? 1 : -1;
+ } else if (level < new_level) {
+ log2vis_list[lpos - bidi_start] = (rtl) ? -1 : 1;
+ if (new_level > rtl_par)
+ bidi_same_direction = false;
+ } else
+ log2vis_list[lpos - bidi_start] = (new_rtl) ? -1 : 1;
+ rtl = new_rtl;
+ rtl0 = new_rtl0;
+ bidi_levels[lpos - bidi_start] = new_level;
+
+ while (level > new_level2) {
+ LyXParagraph::size_type old_lpos =
+ stack[--level];
+ int delta = lpos - old_lpos - 1;
+ if (level % 2)
+ delta = -delta;
+ log2vis_list[lpos - bidi_start] += delta;
+ log2vis_list[old_lpos - bidi_start] += delta;
}
+ while (level < new_level)
+ stack[level++] = lpos;
}
while (level > 0) {
- old_lpos = stack[--level];
- log2vis_list[old_lpos - bidi_start] =
- (old_lpos - (to + 1)) * direction;
- direction = static_cast<LyXDirection>(-direction);
+ LyXParagraph::size_type old_lpos = stack[--level];
+ int delta = last - old_lpos;
+ if (level % 2)
+ delta = -delta;
+ log2vis_list[old_lpos - bidi_start] += delta;
}
- vpos = (par_direction == LYX_DIR_LEFT_TO_RIGHT)
- ? from - 1 : to + 1;
- vpos += offset;
- for (lpos = from; lpos <= to; ++lpos) {
+ LyXParagraph::size_type vpos = bidi_start - 1;
+ for (LyXParagraph::size_type lpos = bidi_start; lpos <= last; ++lpos) {
vpos += log2vis_list[lpos - bidi_start];
vis2log_list[vpos - bidi_start] = lpos;
log2vis_list[lpos - bidi_start] = vpos;
int y = offset + row->baseline;
int xp[3], yp[3];
- if (row->par->getLetterDirection(pos) == LYX_DIR_LEFT_TO_RIGHT) {
+ if (bidi_level(pos) % 2 == 0) {
xp[0] = int(x + wid * 0.375);
yp[0] = int(y - 0.875 * asc * 0.75);
// So IMHO we should go with the easier and clearer implementation.
// And even if 1024 is a large number here it might overflow, string
// will only overflow if the machine is out of memory...
- bool do_transform = (lyxrc.rtl_support && lyxrc.font_norm == "iso8859-6.8x");
+ bool do_transform =
+ font2.language()->lang == "arabic" &&
+ lyxrc.font_norm == "iso8859-6.8x";
if (do_transform)
c = TransformChar(c, row->par, pos);
static string textstring;
textstring = c;
++vpos;
- LyXParagraph::size_type last = RowLast(row);
+ LyXParagraph::size_type last = RowLastPrintable(row);
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
// exactly the label-width.
int LyXText::LeftMargin(Row const * row) const
{
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
row->par->GetLayout());
string parindent = layout.parindent;
int x = LYX_PAPER_MARGIN;
x += lyxfont::signedWidth(textclasslist
- .TextClass(parameters->textclass)
+ .TextClass(bparams->textclass)
.leftmargin(),
textclasslist
- .TextClass(parameters->textclass)
+ .TextClass(bparams->textclass)
.defaultfont());
if (row->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXParagraph * newpar = row->par
->DepthHook(row->par->GetDepth());
if (newpar &&
- textclasslist.Style(parameters->textclass,
+ textclasslist.Style(bparams->textclass,
newpar->GetLayout())
.nextnoindent)
parindent.clear();
// check wether it is a sufficent paragraph
if (newpar && newpar->footnoteflag == row->par->footnoteflag
&& textclasslist
- .Style(parameters->textclass,
+ .Style(bparams->textclass,
newpar->GetLayout()).isEnvironment()) {
Row dummyrow;
dummyrow.par = newpar;
parindent.clear();
else
parindent = textclasslist
- .Style(parameters->textclass,
+ .Style(bparams->textclass,
newpar->GetLayout()).parindent;
}
if (!layout.leftmargin.empty()) {
x += lyxfont::signedWidth(layout.leftmargin,
textclasslist
- .TextClass(parameters->
+ .TextClass(bparams->
textclass)
.defaultfont());
}
}
break;
case MARGIN_STATIC:
- x += lyxfont::signedWidth(layout.leftmargin, textclasslist.TextClass(parameters->textclass).defaultfont()) * 4
+ x += lyxfont::signedWidth(layout.leftmargin, textclasslist.TextClass(bparams->textclass).defaultfont()) * 4
/ (row->par->GetDepth() + 4);
break;
case MARGIN_FIRST_DYNAMIC:
x += lyxfont::signedWidth(layout.leftmargin,
textclasslist
- .TextClass(parameters->textclass)
+ .TextClass(bparams->textclass)
.defaultfont());
x += minfill;
}
&& align == LYX_ALIGN_BLOCK
&& !row->par->noindent
&& (row->par->layout ||
- parameters->paragraph_separation ==
+ bparams->paragraph_separation ==
BufferParams::PARSEP_INDENT))
x += lyxfont::signedWidth(parindent,
textclasslist
- .TextClass(parameters
+ .TextClass(bparams
->textclass)
.defaultfont());
else if (layout.labeltype == LABEL_BIBLIO) {
// ale970405 Right width for bibitems
x += bibitemMaxWidth(owner_->painter(),
textclasslist
- .TextClass(parameters
+ .TextClass(bparams
->textclass)
.defaultfont());
}
int LyXText::RightMargin(Row const * row) const
{
LyXLayout const & layout =
- textclasslist.Style(parameters->textclass,
+ textclasslist.Style(bparams->textclass,
row->par->GetLayout());
int x = LYX_PAPER_MARGIN
+ lyxfont::signedWidth(textclasslist
- .TextClass(parameters->textclass)
+ .TextClass(bparams->textclass)
.rightmargin(),
textclasslist
- .TextClass(parameters->textclass)
+ .TextClass(bparams->textclass)
.defaultfont());
if (row->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
// check wether it is a sufficent paragraph
if (newpar && newpar->footnoteflag == row->par->footnoteflag
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
newpar->GetLayout())
.isEnvironment()) {
Row dummyrow;
}
//lyxerr << "rightmargin: " << layout->rightmargin << endl;
- x += lyxfont::signedWidth(layout.rightmargin, textclasslist.TextClass(parameters->textclass).defaultfont()) * 4
+ x += lyxfont::signedWidth(layout.rightmargin, textclasslist.TextClass(bparams->textclass).defaultfont()) * 4
/ (row->par->GetDepth() + 4);
return x;
}
int LyXText::LabelEnd (Row const * row) const
{
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
row->par->GetLayout()).margintype
== MARGIN_MANUAL) {
Row tmprow;
LyXParagraph::size_type main_body = BeginningOfMainBody(par);
LyXLayout const & layout =
- textclasslist.Style(parameters->textclass, par->GetLayout());
+ textclasslist.Style(bparams->textclass, par->GetLayout());
LyXParagraph::size_type i = pos;
if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
{
int w, fill;
// get the pure distance
- LyXParagraph::size_type last = RowLast(row);
+ LyXParagraph::size_type last = RowLastPrintable(row);
/* table stuff -- begin */
if (row->par->table) {
// for tables FILL does calculate the widthes of each cell in
* this point. */
}
/* table stuff -- end*/
-
- // if the row ends with newline, this newline will not be relevant
- //if (last >= 0 && row->par->IsNewline(last))
- // --last;
-
- // if the row ends with a space, this space will not be relevant
- if (last >= 0 && row->par->IsLineSeparator(last))
- --last;
-
+
// special handling of the right address boxes
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
row->par->GetLayout()).margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
int tmpfill = row->fill;
} else
w = LeftMargin(row);
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
row->par->GetLayout());
LyXParagraph::size_type main_body =
BeginningOfMainBody(row->par);
return true;
// in some labels it does not count
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
row_ptr->par->GetLayout()).margintype
!= MARGIN_MANUAL
&& pos < BeginningOfMainBody(row_ptr->par))
LyXParagraph * par = row_ptr->par->LastPhysicalPar();
LyXParagraph * firstpar = row_ptr->par->FirstPhysicalPar();
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
firstpar->GetLayout());
LyXFont font = GetFont(par, par->Last()-1);
int maxasc = int(lyxfont::maxAscent(font) *
layout.spacing.getValue() *
- parameters->spacing.getValue());
+ bparams->spacing.getValue());
int maxdesc = int(lyxfont::maxDescent(font) *
layout.spacing.getValue() *
- parameters->spacing.getValue());
+ bparams->spacing.getValue());
int pos_end = RowLast(row_ptr);
&& row_ptr->par == firstpar) {
/* some parksips VERY EASY IMPLEMENTATION */
- if (parameters->paragraph_separation == BufferParams::PARSEP_SKIP) {
+ if (bparams->paragraph_separation == BufferParams::PARSEP_SKIP) {
if (layout.isParagraph()
&& firstpar->GetDepth() == 0
&& firstpar->Previous())
- maxasc += parameters->getDefSkip().inPixels(owner_);
+ maxasc += bparams->getDefSkip().inPixels(owner_);
else if (firstpar->Previous()
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
firstpar->Previous()->GetLayout()).isParagraph()
&& firstpar->Previous()->GetDepth() == 0)
// is it right to use defskip here too? (AS)
- maxasc += parameters->getDefSkip().inPixels(owner_);
+ maxasc += bparams->getDefSkip().inPixels(owner_);
}
/* the paper margins */
/* this is special code for the chapter, since the label of this
* layout is printed in an extra row */
if (layout.labeltype == LABEL_COUNTER_CHAPTER
- && parameters->secnumdepth>= 0) {
+ && bparams->secnumdepth>= 0) {
labeladdon = int(lyxfont::maxDescent(labelfont) *
layout.spacing.getValue() *
- parameters->spacing.getValue())
+ bparams->spacing.getValue())
+ int(lyxfont::maxAscent(labelfont) *
layout.spacing.getValue() *
- parameters->spacing.getValue());
+ bparams->spacing.getValue());
}
/* special code for the top label */
labeladdon = int(
(lyxfont::maxAscent(labelfont) *
layout.spacing.getValue() *
- parameters->spacing.getValue())
+ bparams->spacing.getValue())
+(lyxfont::maxDescent(labelfont) *
layout.spacing.getValue() *
- parameters->spacing.getValue())
+ bparams->spacing.getValue())
+ layout.topsep * DefaultHeight()
+ layout.labelbottomsep * DefaultHeight());
}
tmptop = layout.topsep;
if (row_ptr->previous->par->GetDepth() >= row_ptr->par->GetDepth())
- tmptop-= textclasslist.Style(parameters->textclass, row_ptr->previous->par->GetLayout()).bottomsep;
+ tmptop-= textclasslist.Style(bparams->textclass, row_ptr->previous->par->GetLayout()).bottomsep;
if (tmptop > 0)
layoutasc = (tmptop * DefaultHeight());
prev = row_ptr->par->DepthHook(row_ptr->par->GetDepth()-1);
if (prev) {
- maxasc += int(textclasslist.Style(parameters->textclass,
+ maxasc += int(textclasslist.Style(bparams->textclass,
prev->GetLayout()).parsep * DefaultHeight());
}
else {
float unusual = 0;
if (comparepar->GetDepth() > nextpar->GetDepth()) {
- usual = (textclasslist.Style(parameters->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
+ usual = (textclasslist.Style(bparams->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
comparepar = comparepar->DepthHook(nextpar->GetDepth());
if (comparepar->GetLayout()!= nextpar->GetLayout()
|| nextpar->GetLabelWidthString() !=
comparepar->GetLabelWidthString())
- unusual = (textclasslist.Style(parameters->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
+ unusual = (textclasslist.Style(bparams->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
if (unusual > usual)
layoutdesc = unusual;
if (comparepar->GetLayout()!= nextpar->GetLayout()
|| nextpar->GetLabelWidthString() !=
comparepar->GetLabelWidthString())
- layoutdesc = int(textclasslist.Style(parameters->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
+ layoutdesc = int(textclasslist.Style(bparams->textclass, comparepar->GetLayout()).bottomsep * DefaultHeight());
}
}
}
void LyXText::BreakParagraph(char keep_layout)
{
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
cursor.par->GetLayout());
/* table stuff -- begin */
* disable the double-space checking */
bool freeSpacing =
- textclasslist.Style(parameters->textclass,
+ textclasslist.Style(bparams->textclass,
cursor.row->par->GetLayout()).free_spacing;
/* table stuff -- begin*/
RedoHeightOfParagraph(cursor);
} else {
/* now the special right address boxes */
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
cursor.par->GetLayout()).margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
RedoDrawingOfParagraph(cursor);
fill_separator = 0;
fill_label_hfill = 0;
- LyXDirection direction = row->par->getParDirection();
+ bool is_rtl = row->par->isRightToLeftPar();
- if (direction == LYX_DIR_RIGHT_TO_LEFT) {
+ if (is_rtl) {
x = RightMargin(row);
if (row->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font);
}
- }
- else
+ } else
x = LeftMargin(row);
/* is there a manual margin with a manual label */
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
row->par->GetLayout()).margintype == MARGIN_MANUAL
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
row->par->GetLayout()).labeltype == LABEL_MANUAL) {
nlh = NumberOfLabelHfills(row) + 1; /* one more since labels
* set x how you need it */
int align;
if (row->par->FirstPhysicalPar()->align == LYX_ALIGN_LAYOUT)
- align = textclasslist.Style(parameters->textclass, row->par->GetLayout()).align;
+ align = textclasslist.Style(bparams->textclass, row->par->GetLayout()).align;
else
align = row->par->FirstPhysicalPar()->align;
&& row->next->par->GetInset(row->next->pos)->display())
)
fill_separator = w / ns;
- else if (direction == LYX_DIR_RIGHT_TO_LEFT)
+ else if (is_rtl)
x += w;
break;
case LYX_ALIGN_RIGHT:
return;
ComputeBidiTables(row);
- if (direction == LYX_DIR_RIGHT_TO_LEFT) {
+ if (is_rtl) {
LyXParagraph::size_type main_body =
BeginningOfMainBody(row->par);
LyXParagraph::size_type last = RowLast(row);
- if (row->pos <= last
- && !row->par->table
- && last != vis2log(last)
- && row->par->IsLineSeparator(last)) {
- if ((main_body = 0 || main_body-1 != last) &&
- (!row->next || row->next->par != row->par ||
- row->par->getLetterDirection(last) ==
- LYX_DIR_RIGHT_TO_LEFT))
- x -= fill_separator+SingleWidth(row->par,last);
- } else if (main_body > 0 &&
- (main_body-1 > last ||
- !row->par->IsLineSeparator(main_body-1))) {
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ if (main_body > 0 &&
+ (main_body-1 > last ||
+ !row->par->IsLineSeparator(main_body-1))) {
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
row->par->GetLayout());
x += lyxfont::width(layout.labelsep,
GetFont(row->par, -2));
RedoHeightOfParagraph(cursor);
} else {
// now the special right address boxes
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
cursor.par->GetLayout()).margintype == MARGIN_RIGHT_ADDRESS_BOX) {
RedoDrawingOfParagraph(cursor);
}
/* returns a printed row */
Painter & pain = owner_->painter();
- LyXDirection direction = row_ptr->par->getParDirection();
- LyXParagraph::size_type last = RowLast(row_ptr);
+ bool is_rtl = row_ptr->par->isRightToLeftPar();
+ LyXParagraph::size_type last = RowLastPrintable(row_ptr);
LyXParagraph::size_type vpos, pos;
float x, tmpx;
row_ptr->height,
LColor::selection);
} else if (sel_start_cursor.row == row_ptr) {
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
- pain.fillRectangle(sel_start_cursor.x, offset,
- paperwidth - sel_start_cursor.x,
+ if (is_rtl)
+ pain.fillRectangle(0, offset,
+ sel_start_cursor.x,
row_ptr->height,
LColor::selection);
else
- pain.fillRectangle(0, offset,
- sel_start_cursor.x,
+ pain.fillRectangle(sel_start_cursor.x, offset,
+ paperwidth - sel_start_cursor.x,
row_ptr->height,
LColor::selection);
} else if (sel_end_cursor.row == row_ptr) {
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
- pain.fillRectangle(0, offset,
- sel_end_cursor.x,
+ if (is_rtl)
+ pain.fillRectangle(sel_end_cursor.x, offset,
+ paperwidth - sel_end_cursor.x,
row_ptr->height,
LColor::selection);
else
- pain.fillRectangle(sel_end_cursor.x, offset,
- paperwidth - sel_end_cursor.x,
+ pain.fillRectangle(0, offset,
+ sel_end_cursor.x,
row_ptr->height,
LColor::selection);
} else if (y > sel_start_cursor.y && y < sel_end_cursor.y) {
cell = NumberOfCell(row_ptr->par, row_ptr->pos);
tmpx += row_ptr->par->table->GetBeginningOfTextInCell(cell);
}
- if ( (sel_start_cursor.row != row_ptr &&
- direction == LYX_DIR_LEFT_TO_RIGHT) ||
- (sel_end_cursor.row != row_ptr &&
- direction == LYX_DIR_RIGHT_TO_LEFT))
+ if ( (sel_start_cursor.row != row_ptr && !is_rtl) ||
+ (sel_end_cursor.row != row_ptr && is_rtl))
pain.fillRectangle(0, offset,
tmpx, row_ptr->height,
LColor::selection);
float old_tmpx = tmpx;
if (main_body > 0 && pos == main_body-1) {
tmpx += fill_label_hfill +
- lyxfont::width(textclasslist.Style(parameters->textclass,
+ lyxfont::width(textclasslist.Style(bparams->textclass,
row_ptr->par->GetLayout()).labelsep,
GetFont(row_ptr->par, -2));
if (row_ptr->par->IsLineSeparator(main_body-1))
tmpx += fill_label_hfill;
}
else if (row_ptr->par->IsSeparator(pos)) {
- if (pos != last || !row_ptr->next ||
- row_ptr->next->par != row_ptr->par ||
- direction == row_ptr->par->getLetterDirection(last)) {
- tmpx += SingleWidth(row_ptr->par, pos);
- if (pos >= main_body)
- tmpx += fill_separator;
- }
+ tmpx += SingleWidth(row_ptr->par, pos);
+ if (pos >= main_body)
+ tmpx += fill_separator;
} else
tmpx += SingleWidth(row_ptr->par, pos);
LColor::selection);
}
}
- if ( (sel_start_cursor.row != row_ptr &&
- direction == LYX_DIR_RIGHT_TO_LEFT) ||
- (sel_end_cursor.row != row_ptr &&
- direction == LYX_DIR_LEFT_TO_RIGHT) )
+ if ( (sel_start_cursor.row != row_ptr && is_rtl) ||
+ (sel_end_cursor.row != row_ptr && !is_rtl) )
pain.fillRectangle(tmpx, offset,
paperwidth - tmpx,
row_ptr->height,
}
LyXLayout const & layout =
- textclasslist.Style(parameters->textclass,
+ textclasslist.Style(bparams->textclass,
row_ptr->par->GetLayout());
firstpar = row_ptr->par->FirstPhysicalPar();
/* think about the parskip */
/* some parskips VERY EASY IMPLEMENTATION */
- if (parameters->paragraph_separation == BufferParams::PARSEP_SKIP) {
+ if (bparams->paragraph_separation == BufferParams::PARSEP_SKIP) {
if (layout.latextype == LATEX_PARAGRAPH
&& firstpar->GetDepth() == 0
&& firstpar->Previous())
- y_top += parameters->getDefSkip().inPixels(owner_);
+ y_top += bparams->getDefSkip().inPixels(owner_);
else if (firstpar->Previous()
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
firstpar->Previous()->GetLayout()).latextype == LATEX_PARAGRAPH
&& firstpar->Previous()->GetDepth() == 0)
// is it right to use defskip here, too? (AS)
- y_top += parameters->getDefSkip().inPixels(owner_);
+ y_top += bparams->getDefSkip().inPixels(owner_);
}
if (row_ptr->par->line_top) { /* draw a top line */
string tmpstring = row_ptr->par->GetLabelstring();
if (layout.labeltype == LABEL_COUNTER_CHAPTER) {
- if (parameters->secnumdepth >= 0){
+ if (bparams->secnumdepth >= 0){
/* this is special code for the chapter layout. This is printed in
* an extra row and has a pagebreak at the top. */
- maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * parameters->spacing.getValue())
+ maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * bparams->spacing.getValue())
+ int(layout.parsep) * DefaultHeight();
- if (direction == LYX_DIR_RIGHT_TO_LEFT)
+ if (is_rtl)
tmpx = paperwidth - LeftMargin(row_ptr) -
lyxfont::width(tmpstring, font);
pain.text(int(tmpx),
tmpstring, font);
}
} else {
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
- tmpx = x - lyxfont::width(layout.labelsep, font)
- - lyxfont::width(tmpstring, font);
- else {
+ if (is_rtl) {
tmpx = paperwidth - LeftMargin(row_ptr)
+ lyxfont::width(layout.labelsep, font);
if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
font.setSize(LyXFont::SIZE_SMALL);
tmpx += lyxfont::width("Mwide-fixM", font);
}
- }
+ } else
+ tmpx = x - lyxfont::width(layout.labelsep, font)
+ - lyxfont::width(tmpstring, font);
+
/* draw it! */
pain.text(int(tmpx),
offset + row_ptr->baseline,
if (!row_ptr->par->GetLabelstring().empty()) {
string tmpstring = row_ptr->par->GetLabelstring();
- maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * parameters->spacing.getValue()
+ maxdesc = int(lyxfont::maxDescent(font) * layout.spacing.getValue() * bparams->spacing.getValue()
+ (layout.labelbottomsep * DefaultHeight()));
tmpx = x;
if (layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT){
- tmpx = ( ((direction == LYX_DIR_LEFT_TO_RIGHT)
- ? x : LeftMargin(row_ptr) )
+ tmpx = ( (is_rtl ? LeftMargin(row_ptr) : x)
+ paperwidth - RightMargin(row_ptr) ) / 2;
tmpx -= lyxfont::width(tmpstring, font) / 2;
- } else if (direction == LYX_DIR_RIGHT_TO_LEFT)
+ } else if (is_rtl)
tmpx = paperwidth - LeftMargin(row_ptr) -
lyxfont::width(tmpstring, font);
pain.text(int(tmpx),
}
if (layout.labeltype == LABEL_BIBLIO && row_ptr->par->bibkey) {
font = GetFont(row_ptr->par, -1);
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
- tmpx = x - lyxfont::width(layout.labelsep, font)
- - row_ptr->par->bibkey->width(owner_->painter(), font);
- else
+ if (is_rtl)
tmpx = paperwidth - LeftMargin(row_ptr)
+ lyxfont::width(layout.labelsep, font);
+ else
+ tmpx = x - lyxfont::width(layout.labelsep, font)
+ - row_ptr->par->bibkey->width(owner_->painter(), font);
row_ptr->par->bibkey->draw(pain,
font,
offset + row_ptr->baseline,
LyXFont font = GetFont(row_ptr->par, last);
int size = int(0.75 * lyxfont::maxAscent(font));
int y = (offset + row_ptr->baseline) - size;
- int x = (direction == LYX_DIR_LEFT_TO_RIGHT)
- ? paperwidth - LYX_PAPER_MARGIN - size
- : LYX_PAPER_MARGIN;
+ int x = is_rtl ? LYX_PAPER_MARGIN
+ : paperwidth - LYX_PAPER_MARGIN - size;
if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
- x -= LYX_PAPER_MARGIN/2;
- else {
+ if (is_rtl) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font);
- }
+ } else
+ x -= LYX_PAPER_MARGIN/2;
if (row_ptr->fill <= size)
- x += (size - row_ptr->fill + 1) * direction;
+ x += (size - row_ptr->fill + 1) * (is_rtl ? -1 : 1);
if (endlabel == END_LABEL_BOX) {
pain.line(x, y, x, y + size,
LColor::eolmarker);
x += 2;
++vpos;
} else if (row_ptr->par->IsSeparator(pos)) {
- if (pos != last || !row_ptr->next ||
- row_ptr->next->par != row_ptr->par ||
- direction == row_ptr->par->getLetterDirection(last)) {
#if 0
- tmpx = x;
+ tmpx = x;
#endif
- x += SingleWidth(row_ptr->par, pos);
- if (pos >= main_body)
- x += fill_separator;
- }
+ x += SingleWidth(row_ptr->par, pos);
+ if (pos >= main_body)
+ x += fill_separator;
#warning Think about this
#if 0
/* -------> Only draw protected spaces when
PrepareToPrint(row, tmpx, fill_separator,
fill_hfill, fill_label_hfill);
- LyXDirection direction = row->par->getParDirection();
LyXParagraph::size_type vc = row->pos;
- LyXParagraph::size_type last = RowLast(row);
+ LyXParagraph::size_type last = RowLastPrintable(row);
LyXParagraph::size_type c = 0;
-
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
row->par->GetLayout());
/* table stuff -- begin */
if (row->par->table) {
- if (row->next && row->next->par == row->par //the last row doesn't need a newline at the end
+ //the last row doesn't need a newline at the end
+ if (row->next && row->next->par == row->par
&& row->par->IsNewline(last))
last--;
int cell = NumberOfCell(row->par, row->pos);
tmpx += fill_label_hfill;
}
else if (row->par->IsSeparator(c)) {
- if (c != last ||
- !row->next ||
- row->next->par != row->par ||
- direction == row->par->getLetterDirection(last)) {
- tmpx += SingleWidth(row->par, c);
- if (c >= main_body)
- tmpx+= fill_separator;
- }
+ tmpx += SingleWidth(row->par, c);
+ if (c >= main_body)
+ tmpx+= fill_separator;
} else
tmpx += SingleWidth(row->par, c);
++vc;
tmpx = last_tmpx;
}
}
- /* make sure that a last space in a row doesnt count */
- if (row->pos <= last
- && !(!row->next || row->next->par != row->par))
- if (direction == LYX_DIR_LEFT_TO_RIGHT && vc > last
- && row->par->IsLineSeparator(vis2log(last)) ) {
- vc = last;
- tmpx -= fill_separator+SingleWidth(row->par, vis2log(last));
- } else if (direction == LYX_DIR_RIGHT_TO_LEFT
- && vc == row->pos
- && row->par->IsLineSeparator(vis2log(row->pos)) ) {
- vc = row->pos+1;
- tmpx += fill_separator+SingleWidth(row->par, vis2log(row->pos));
- }
+
+ if (vc > last + 1) // This shouldn't happen.
+ vc = last+1;
+
if (row->pos > last) // Row is empty?
c = row->pos;
else if (vc > last ||
- (row->par->table && vc > row->pos && row->par->IsNewline(vc)) ){
- int pos = (vc > last+1) ? last : vc - 1;
- c = vis2log(pos);
- if (row->par->getLetterDirection(c) == LYX_DIR_LEFT_TO_RIGHT)
+ (vc - 1 >= row->pos &&
+ ( (row->par->IsSeparator(vis2log(vc)) && vis2log(vc) != last)
+ || (row->par->table && row->par->IsNewline(vc) )
+ ))) {
+ c = vis2log(vc - 1);
+ if (bidi_level(c) % 2 == 0)
++c;
} else {
c = vis2log(vc);
- LyXDirection direction = row->par->getLetterDirection(c);
- if (vc > row->pos && row->par->IsLineSeparator(c)
- && row->par->getLetterDirection(vis2log(vc - 1)) != direction)
- c = vis2log(vc-1);
- if (direction == LYX_DIR_RIGHT_TO_LEFT)
+ if (bidi_level(c) % 2 == 1)
++c;
}
if (!row->par->table && row->pos <= last && c > last
&& row->par->IsNewline(last)) {
- if (row->par->getLetterDirection(last) == LYX_DIR_LEFT_TO_RIGHT)
+ if (bidi_level(last) % 2 == 0)
tmpx -= SingleWidth(row->par, last);
else
tmpx += SingleWidth(row->par, last);
|| kind == LyXParagraph::WIDE_FIG
|| kind == LyXParagraph::ALGORITHM) {
pair<bool, LyXTextClass::size_type> lres =
- textclasslist.NumberOfLayout(parameters->textclass,
+ textclasslist.NumberOfLayout(bparams->textclass,
"Caption");
LyXTextClass::size_type lay;
if (lres.first) {
currentrow = 0;
currentrow_y = 0;
paperwidth = pw;
- parameters = &p->params;
- params = p;
+ bparams = &p->params;
+ buffer = p;
number_of_rows = 0;
refresh_y = 0;
status = LyXText::UNCHANGED;
LyXParagraph::size_type pos) const
{
LyXLayout const & layout =
- textclasslist.Style(parameters->textclass, par->GetLayout());
+ textclasslist.Style(bparams->textclass, par->GetLayout());
char par_depth = par->GetDepth();
// We specialize the 95% common case:
par = par->DepthHook(par_depth - 1);
if (par) {
tmpfont.realize(textclasslist.
- Style(parameters->textclass,
+ Style(bparams->textclass,
par->GetLayout()).font);
par_depth = par->GetDepth();
}
}
- tmpfont.realize(textclasslist.TextClass(parameters->textclass).defaultfont());
+ tmpfont.realize(textclasslist.TextClass(bparams->textclass).defaultfont());
// Cosmetic improvement: If this is an open footnote, make the font
// smaller.
font = par->GetInset(pos)->ConvertFont(font);
}
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
par->GetLayout());
// Get concrete layout font to reduce against
tp = tp->DepthHook(tp->GetDepth()-1);
if (tp)
layoutfont.realize(textclasslist.
- Style(parameters->textclass,
+ Style(bparams->textclass,
tp->GetLayout()).font);
}
}
- layoutfont.realize(textclasslist.TextClass(parameters->textclass).defaultfont());
+ layoutfont.realize(textclasslist.TextClass(bparams->textclass).defaultfont());
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
{
LyXLayout const & layout =
- textclasslist.Style(parameters->textclass, par->GetLayout());
+ textclasslist.Style(bparams->textclass, par->GetLayout());
LyXFont layoutfont, tmpfont;
for (LyXParagraph::size_type pos = 0;
cursor = sel_start_cursor;
LyXLayout const & lyxlayout =
- textclasslist.Style(parameters->textclass, layout);
+ textclasslist.Style(bparams->textclass, layout);
while (cursor.par != sel_end_cursor.par) {
if (cursor.par->footnoteflag ==
// NOTE: you can't change the depth of a bibliography entry
if (cursor.par->footnoteflag ==
sel_start_cursor.par->footnoteflag
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
cursor.par->GetLayout()
).labeltype != LABEL_BIBLIO) {
LyXParagraph * prev =
if (prev
&& (prev->GetDepth() - cursor.par->GetDepth() > 0
|| (prev->GetDepth() == cursor.par->GetDepth()
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
prev->GetLayout()).isEnvironment()))) {
cursor.par->FirstPhysicalPar()->depth++;
anything_changed = true;
else
layoutfont = GetFont(cursor.par, -1);
// Update current font
- real_current_font.update(font, parameters->language_info, toggleall);
+ real_current_font.update(font, bparams->language_info, toggleall);
// Reduce to implicit settings
current_font = real_current_font;
// an open footnote should behave
// like a closed one
LyXFont newfont = GetFont(cursor.par, cursor.pos);
- newfont.update(font, parameters->language_info, toggleall);
+ newfont.update(font, bparams->language_info, toggleall);
SetCharFont(cursor.par, cursor.pos, newfont);
cursor.pos++;
} else {
LyXParagraph::size_type LyXText::BeginningOfMainBody(LyXParagraph * par) const
{
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
par->GetLayout()).labeltype != LABEL_MANUAL)
return 0;
else
tmppar->footnoteflag = LyXParagraph::NO_FOOTNOTE;
/* remember the captions and empty paragraphs */
- if ((textclasslist.Style(parameters->textclass,
+ if ((textclasslist.Style(bparams->textclass,
tmppar->GetLayout())
.labeltype == LABEL_SENSITIVE)
|| !tmppar->Last())
// does the layout allow the new alignment?
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist
- .Style(parameters->textclass,
+ .Style(bparams->textclass,
cursor.par->GetLayout()).align;
if (align & textclasslist
- .Style(parameters->textclass,
+ .Style(bparams->textclass,
cursor.par->GetLayout()).alignpossible) {
if (align == textclasslist
- .Style(parameters->textclass,
+ .Style(bparams->textclass,
cursor.par->GetLayout()).align)
cursor.par->align = LYX_ALIGN_LAYOUT;
else
// this is only relevant for the beginning of paragraph
par = par->FirstPhysicalPar();
- LyXLayout const & layout = textclasslist.Style(parameters->textclass,
+ LyXLayout const & layout = textclasslist.Style(bparams->textclass,
par->GetLayout());
LyXTextClass const & textclass =
- textclasslist.TextClass(parameters->textclass);
+ textclasslist.TextClass(bparams->textclass);
/* copy the prev-counters to this one, unless this is the start of a
footnote or of a bibliography or the very first paragraph */
&& !(par->Previous()->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE)
- && !(textclasslist.Style(parameters->textclass,
+ && !(textclasslist.Style(bparams->textclass,
par->Previous()->GetLayout()
).labeltype != LABEL_BIBLIO
&& layout.labeltype == LABEL_BIBLIO)) {
&& par->Previous()
&& par->Previous()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE
&& (par->PreviousBeforeFootnote()
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
par->PreviousBeforeFootnote()->GetLayout()
).labeltype >= LABEL_COUNTER_ENUMI)) {
// Any itemize or enumerate environment in a marginnote
*/
if (par->Previous()
&& par->Previous()->GetDepth() < par->GetDepth()
- && textclasslist.Style(parameters->textclass,
+ && textclasslist.Style(bparams->textclass,
par->Previous()->GetLayout()
).labeltype == LABEL_COUNTER_ENUMI
&& par->enumdepth < 3
if (layout.labeltype >= LABEL_FIRST_COUNTER) {
int i = layout.labeltype - LABEL_FIRST_COUNTER;
- if (i >= 0 && i<= parameters->secnumdepth) {
+ if (i >= 0 && i<= bparams->secnumdepth) {
par->incCounter(i); // increment the counter
// Is there a label? Useful for Chapter layout
} else { // appendix
switch (2 * LABEL_FIRST_COUNTER - textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(par->getCounter(i));
- else
+ if (par->isRightToLeftPar())
s << hebrewCounter(par->getCounter(i));
+ else
+ s << alphaCounter(par->getCounter(i));
break;
case LABEL_COUNTER_SECTION:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(par->getCounter(i - 1));
- else
+ if (par->isRightToLeftPar())
s << hebrewCounter(par->getCounter(i - 1));
+ else
+ s << alphaCounter(par->getCounter(i - 1));
s << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBSECTION:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(par->getCounter(i - 2));
- else
+ if (par->isRightToLeftPar())
s << hebrewCounter(par->getCounter(i - 2));
+ else
+ s << alphaCounter(par->getCounter(i - 2));
s << '.'
<< par->getCounter(i-1) << '.'
break;
case LABEL_COUNTER_SUBSUBSECTION:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(par->getCounter(i-3));
- else
+ if (par->isRightToLeftPar())
s << hebrewCounter(par->getCounter(i-3));
+ else
+ s << alphaCounter(par->getCounter(i-3));
s << '.'
<< par->getCounter(i-2) << '.'
break;
case LABEL_COUNTER_PARAGRAPH:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(par->getCounter(i-4));
- else
+ if (par->isRightToLeftPar())
s << hebrewCounter(par->getCounter(i-4));
+ else
+ s << alphaCounter(par->getCounter(i-4));
s << '.'
<< par->getCounter(i-3) << '.'
break;
case LABEL_COUNTER_SUBPARAGRAPH:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(par->getCounter(i-5));
- else
+ if (par->isRightToLeftPar())
s << hebrewCounter(par->getCounter(i-5));
+ else
+ s << alphaCounter(par->getCounter(i-5));
s << '.'
<< par->getCounter(i-4) << '.'
#endif
switch (par->enumdepth) {
case 1:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
+ if (par->isRightToLeftPar())
s << '('
- << loweralphaCounter(number)
+ << hebrewCounter(number)
<< ')';
else
s << '('
- << hebrewCounter(number)
+ << loweralphaCounter(number)
<< ')';
break;
case 2:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << romanCounter(number) << '.';
- else
+ if (par->isRightToLeftPar())
s << '.' << romanCounter(number);
+ else
+ s << romanCounter(number) << '.';
break;
case 3:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << alphaCounter(number)
- << '.';
- else
+ if (par->isRightToLeftPar())
s << '.'
<< alphaCounter(number);
+ else
+ s << alphaCounter(number)
+ << '.';
break;
default:
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s << number << '.';
- else
+ if (par->isRightToLeftPar())
s << '.' << number;
+ else
+ s << number << '.';
break;
}
#ifdef HAVE_SSTREAM
if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& (par->footnotekind == LyXParagraph::FIG
|| par->footnotekind == LyXParagraph::WIDE_FIG))
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s = "Figure:";
- else
- s = ":øåéà";
+ s = (par->getParLanguage()->lang == "hebrew")
+ ? ":øåéà" : "Figure:";
else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& (par->footnotekind == LyXParagraph::TAB
|| par->footnotekind == LyXParagraph::WIDE_TAB))
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s = "Table:";
- else
- s = ":äìáè";
+ s = (par->getParLanguage()->lang == "hebrew")
+ ? ":äìáè" : "Table:";
else if (par->footnoteflag != LyXParagraph::NO_FOOTNOTE
&& par->footnotekind == LyXParagraph::ALGORITHM)
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s = "Algorithm:";
- else
- s = ":íúéøåâìà";
+ s = (par->getParLanguage()->lang == "hebrew")
+ ? ":íúéøåâìà" : "Algorithm:";
else {
/* par->SetLayout(0);
s = layout->labelstring; */
- if (par->getParDirection() == LYX_DIR_LEFT_TO_RIGHT)
- s = "Senseless: ";
- else
- s = " :úåòîùî øñç";
-
+ s = (par->getParLanguage()->lang == "hebrew")
+ ? " :úåòîùî øñç" : "Senseless: ";
}
}
par->labelstring = s;
/* now check for the headline layouts. remember that they
* have a dynamic left margin */
if (!par->IsDummy()
- && ( textclasslist.Style(parameters->textclass, par->layout).margintype == MARGIN_DYNAMIC
- || textclasslist.Style(parameters->textclass, par->layout).labeltype == LABEL_SENSITIVE)
+ && ( textclasslist.Style(bparams->textclass, par->layout).margintype == MARGIN_DYNAMIC
+ || textclasslist.Style(bparams->textclass, par->layout).labeltype == LABEL_SENSITIVE)
){
/* Rebreak the paragraph */
DeleteSimpleCutBuffer();
// set the textclass
- simple_cut_buffer_textclass = parameters->textclass;
+ simple_cut_buffer_textclass = bparams->textclass;
#ifdef WITH_WARNINGS
#warning Asger: Make cut more intelligent here.
endpar = sel_start_cursor.par;
cap.cutSelection(sel_start_cursor.par, &endpar,
sel_start_cursor.pos, sel_end_cursor.pos,
- parameters->textclass, doclear);
+ bparams->textclass, doclear);
} else {
endpar = sel_end_cursor.par;
cap.cutSelection(sel_start_cursor.par, &endpar,
sel_start_cursor.pos, sel_end_cursor.pos,
- parameters->textclass, doclear);
+ bparams->textclass, doclear);
cursor.par = sel_end_cursor.par = endpar;
cursor.pos = sel_end_cursor.pos;
}
DeleteSimpleCutBuffer();
// set the textclass
- simple_cut_buffer_textclass = parameters->textclass;
+ simple_cut_buffer_textclass = bparams->textclass;
#ifdef FIX_DOUBLE_SPACE
// copy behind a space if there is one
cap.copySelection(sel_start_cursor.par, sel_end_cursor.par,
sel_start_cursor.pos, sel_end_cursor.pos,
- parameters->textclass);
+ bparams->textclass);
}
#endif
// make sure there is no class difference
cap.SwitchLayoutsBetweenClasses(simple_cut_buffer_textclass,
- parameters->textclass,
+ bparams->textclass,
simple_cut_buffer);
// make the simple_cut_buffer exactly the same layout than
LyXParagraph *actpar = cursor.par;
int endpos = cursor.pos;
- cap.pasteSelection(&actpar, &endpar, endpos, parameters->textclass);
+ cap.pasteSelection(&actpar, &endpar, endpos, bparams->textclass);
RedoParagraphs(cursor, endpar);
// returns a pointer to the very first LyXParagraph
LyXParagraph * LyXText::FirstParagraph() const
{
- return params->paragraph;
+ return buffer->paragraph;
}
SetCursorParUndo();
bool flag =
- textclasslist.Style(parameters->textclass,
+ textclasslist.Style(bparams->textclass,
cursor.par->GetLayout()).isEnvironment();
// only to be sure, should not be neccessary
ClearSelection();
status = LyXText::NEED_MORE_REFRESH;
// check the special right address boxes
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
par->GetLayout()).margintype
== MARGIN_RIGHT_ADDRESS_BOX) {
tmpcursor.par = par;
if (setfont)
if (cursor.pos &&
(cursor.pos == cursor.par->Last() || cursor.par->IsSeparator(cursor.pos)
- || (cursor.pos && cursor.pos == BeginningOfMainBody(cursor.par)
- && !cursor.par->IsSeparator(cursor.pos))
|| (cursor.par->table && cursor.par->IsNewline(cursor.pos))
)) {
current_font = cursor.par->GetFontSettings(cursor.pos - 1);
float fill_separator, fill_hfill, fill_label_hfill;
PrepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill);
LyXParagraph::size_type cursor_vpos;
- LyXParagraph::size_type last = RowLast(row);
- if (row->pos > last)
- cursor_vpos = 0;
- else if (pos > last)
- cursor_vpos = (row->par->getLetterDirection(last) == LYX_DIR_LEFT_TO_RIGHT)
- ? log2vis(last)+1 : log2vis(last);
- else {
- LyXDirection letter_direction =
- row->par->getLetterDirection(pos);
- LyXDirection font_direction =
- (real_current_font.isVisibleRightToLeft())
- ? LYX_DIR_RIGHT_TO_LEFT : LYX_DIR_LEFT_TO_RIGHT;
- if (letter_direction == font_direction
- || pos <= row->pos
- || (row->par->table && row->par->IsNewline(pos-1)))
- cursor_vpos = (letter_direction == LYX_DIR_LEFT_TO_RIGHT)
- ? log2vis(pos) : log2vis(pos) + 1;
- else
- cursor_vpos = (font_direction == LYX_DIR_LEFT_TO_RIGHT)
- ? log2vis(pos-1) + 1 : log2vis(pos - 1);
- }
-
+ LyXParagraph::size_type last = RowLastPrintable(row);
+
+ if (pos > last + 1) // This shouldn't happen.
+ pos = last+1;
+
+ if (last < row->pos)
+ cursor_vpos = 0;
+ else if (pos > last ||
+ (pos - 1 >= row->pos &&
+ (row->par->IsSeparator(pos) ||
+ (row->par->table && row->par->IsNewline(pos))
+ )))
+ /// Place cursor after char at (logical) position pos-1
+ cursor_vpos = (bidi_level(pos-1) % 2 == 0)
+ ? log2vis(pos-1) + 1 : log2vis(pos-1);
+ else
+ /// Place cursor before char at (logical) position pos
+ cursor_vpos = (bidi_level(pos) % 2 == 0)
+ ? log2vis(pos) : log2vis(pos) + 1;
+
/* table stuff -- begin*/
if (row->par->table) {
int cell = NumberOfCell(row->par, row->pos);
if (main_body > 0 && pos == main_body-1) {
x += fill_label_hfill +
lyxfont::width(textclasslist
- .Style(parameters->textclass,
+ .Style(bparams->textclass,
row->par->GetLayout())
.labelsep,
GetFont(row->par, -2));
x += fill_label_hfill;
}
else if (row->par->IsSeparator(pos)) {
- if (pos != last ||
- !row->next ||
- row->next->par != row->par ||
- row->par->getParDirection() ==
- row->par->getLetterDirection(last)) {
- x += SingleWidth(row->par, pos);
- if (pos >= main_body)
- x += fill_separator;
- }
+ x += SingleWidth(row->par, pos);
+ if (pos >= main_body)
+ x += fill_separator;
} else
x += SingleWidth(row->par, pos);
}
if (selection) return;
// We allow all kinds of "mumbo-jumbo" when freespacing.
- if (textclasslist.Style(parameters->textclass,
+ if (textclasslist.Style(bparams->textclass,
old_cursor.par->GetLayout()).free_spacing)
return;
#endif
#if 1
// Do not delete empty paragraphs with keepempty set.
- if ((textclasslist.Style(parameters->textclass,
+ if ((textclasslist.Style(bparams->textclass,
old_cursor.par->GetLayout())).keepempty)
return;
// delete old row
RemoveRow(old_cursor.row);
- if (params->paragraph == old_cursor.par) {
- params->paragraph = params->paragraph->next;
+ if (buffer->paragraph == old_cursor.par) {
+ buffer->paragraph = buffer->paragraph->next;
}
// delete old par
delete old_cursor.par;
// delete old row
RemoveRow(old_cursor.row);
// delete old par
- if (params->paragraph == old_cursor.par) {
- params->paragraph = params->paragraph->next;
+ if (buffer->paragraph == old_cursor.par) {
+ buffer->paragraph = buffer->paragraph->next;
}
delete old_cursor.par;
bool LyXText::TextUndo()
{
// returns false if no undo possible
- Undo * undo = params->undostack.pop();
+ Undo * undo = buffer->undostack.pop();
if (undo) {
FinishUndo();
if (!undo_frozen)
- params->redostack
+ buffer->redostack
.push(CreateUndo(undo->kind,
GetParFromID(undo->number_of_before_par),
GetParFromID(undo->number_of_behind_par)));
bool LyXText::TextRedo()
{
// returns false if no redo possible
- Undo * undo = params->redostack.pop();
+ Undo * undo = buffer->redostack.pop();
if (undo) {
FinishUndo();
if (!undo_frozen)
- params->undostack
+ buffer->undostack
.push(CreateUndo(undo->kind,
GetParFromID(undo->number_of_before_par),
GetParFromID(undo->number_of_behind_par)));
if (before)
tmppar5 = before->next;
else
- tmppar5 = params->paragraph;
+ tmppar5 = buffer->paragraph;
tmppar2 = tmppar3;
while (tmppar5 && tmppar5 != behind){
tmppar = tmppar5;
if (before)
before->next = tmppar3;
else
- params->paragraph = tmppar3;
+ buffer->paragraph = tmppar3;
tmppar3->previous = before;
}
else {
if (!before)
- params->paragraph = behind;
+ buffer->paragraph = behind;
}
if (tmppar4) {
tmppar4->next = behind;
LyXParagraph const * behind) const
{
if (!undo_frozen)
- params->undostack.push(CreateUndo(kind, before, behind));
- params->redostack.clear();
+ buffer->undostack.push(CreateUndo(kind, before, behind));
+ buffer->redostack.clear();
}
void LyXText::SetRedo(Undo::undo_kind kind, LyXParagraph const * before,
LyXParagraph const * behind)
{
- params->redostack.push(CreateUndo(kind, before, behind));
+ buffer->redostack.push(CreateUndo(kind, before, behind));
}
if (!undo_finished && kind != Undo::EDIT &&
kind != Undo::FINISH){
// check wether storing is needed
- if (!params->undostack.empty() &&
- params->undostack.top()->kind == kind &&
- params->undostack.top()->number_of_before_par == before_number &&
- params->undostack.top()->number_of_behind_par == behind_number ){
+ if (!buffer->undostack.empty() &&
+ buffer->undostack.top()->kind == kind &&
+ buffer->undostack.top()->number_of_before_par == before_number &&
+ buffer->undostack.top()->number_of_behind_par == behind_number ){
// no undo needed
return 0;
}