+2000-04-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
+
+ * src/text.C (Backspace): some additional cleanups (we already
+ know whether cursor.pos is 0 or not).
+
+ * lib/reLyX/Makefile.am (DESTDIR): add an empty value (since
+ automake does not provide one).
+
+ * src/bmtable.h: replace C++ comments with C comments.
+
+2000-04-02 Dekel Tsur <dekel@math.tau.ac.il>
+
+ * src/screen.C (ShowCursor): Change the shape of the cursor if
+ the current language is not equal to the language of the document.
+ (If the cursor change its shape unexpectedly, then you've found a bug)
+
+ * src/insets/insettext.C (LocalDispatch, UpdateLocal) Fixed some
+ bugs [I hope...]
+
+ * src/insets/insetnumber.[Ch]: New files.
+
+ * src/LyXAction.C (init)
+ * src/lyxfunc.C (dispatch): Add command number-inset-insert
+
+ * lyxrc.example
+ * src/lyxrc.C: Renamed command \auto_mathmode to \number_inset
+
+ * src/lyxparagraph.h
+ * src/paragraph.C: Changed insetlist to Vector<InsetTable>.
+ (the vector is kept sorted).
+
+ * src/text.C (GetVisibleRow): Draw selection correctly when there
+ is both LTR and RTL text.
+
+ * src/paragraph.C (Clone): Use the assignment operator for cloning,
+ which is much faster.
+
+ * src/text.C (GetVisibleRow and other): Do not draw the last space
+ in a row if the direction of the last letter is not equal to the
+ direction of the paragraph.
+
+ * src/lyxfont.C (latexWriteStartChanges):
+ Check that font language is not equal to basefont language.
+ (latexWriteEndChanges): ditto
+
+ * src/lyx_cb.C (StyleReset): Don't change the language while using
+ the font-default command.
+
+ * src/paragraph.C (GetFirstFontSettings): Handle correctly an
+ empty paragraph before a footnote.
+
+ * src/insets/insetcommand.C (draw): Increase x correctly.
+
+ * src/screen.C (ShowCursor): Change cursor shape if
+ current language != document language.
+
+ * src/lyxfunc.C (dispatch): Added calls to owner->view()->setState()
+
2000-03-31 Juergen Vigna <jug@sad.it>
* src/paragraph.C (GetInset): commented out text[pos] = ' '
# Arabic). Default is false.
#\rtl true
-# If auto_mathmode is set to "true", each time a digit key is pressed,
-# LyX will automatically enter into math-mode.
-# If auto_mathmode is set to "rtl", the above behavior will take place
-# only when editing right-to-left text.
-# Default is false.
-#\auto_mathmode true
+# If number_inset is set to "true", each time a digit key is pressed,
+# LyX will automatically open a new number inset.
+# If number_inset is set to "rtl", the above behavior will take place
+# only when the cursor is on right-to-left text.
+# Default is rtl.
+#\number_inset true
# The latex command for loading the language package.
# Default is \usepackage{babel}.
#\kbmap_secondary hebrew
#\latex_command elatex
#\font_encoding default
-#\auto_mathmode rtl
+#\number_inset rtl
# You also need to bind a key for switching between Hebrew and English.
# For example,
#\kbmap true
#\kbmap_primary null
#\kbmap_secondary arabic
-#\auto_mathmode false
+#\number_inset false
# You also need to bind a key for switching between Arabic and English.
# For example,
reLyXmain.pl syntax.default test.ltx test.lyx reLyX.man \
RelyxFigure.pm Verbatim.pm \
$(LYXDISTDIRS)
+DESTDIR =
LIBINSTFILES = *.pm *.pl README BUGS CHANGES reLyX.pod syntax.default Text/*.pm
{ LFUN_META_FAKE, "meta-prefix", "", NoBuffer },
{ LFUN_INSERT_NOTE, "note-insert", "", Noop },
{ LFUN_GOTONOTE, "note-next", "", ReadOnly },
+ { LFUN_INSET_NUMBER , "number-inset-insert",
+ N_("Insert a new Number Inset"), Noop },
{ LFUN_OPENSTUFF, "open-stuff", "", ReadOnly },
{ LFUN_DOWN_PARAGRAPH, "paragraph-down",
N_("Go one paragraph down"), ReadOnly },
{
#endif
-///
+/**/
#define FL_BMTABLE 1500
-/// A flat bitmap table
+/* A flat bitmap table */
#define FL_BMTABLE_FLAT 0
-/// A grided bitmap table
+/* A grided bitmap table */
#define FL_BMTABLE_GRID 1
#define FL_BMTABLE_BOXTYPE FL_UP_BOX
-///
+/**/
FL_OBJECT *fl_create_bmtable(int, FL_Coord, FL_Coord,
FL_Coord, FL_Coord, char const *);
-///
+/**/
FL_OBJECT *fl_add_bmtable(int, FL_Coord, FL_Coord,
FL_Coord, FL_Coord, char const *);
/** Same as fl_get_button_numb() */
int fl_get_bmtable_numb(FL_OBJECT *ob);
-///
+/**/
void fl_set_bmtable(FL_OBJECT *, int pushed, int pos);
/** Number of columns and rows, and the background bitmap */
void fl_set_bmtable_data(FL_OBJECT *, int, int, int, int , unsigned char const *);
-///
+/**/
void fl_set_bmtable_pixmap_data(FL_OBJECT *, int, int, char **);
-///
+/**/
void fl_set_bmtable_file(FL_OBJECT *, int, int, char const *);
-///
+/**/
void fl_set_bmtable_pixmap_file(FL_OBJECT *, int, int, char const *);
/** Adjust bitmap origin (ox, oy) and cell dimensions (dx, dy) incrementally */
/** The number of items is by default nc x nr, but you can change it */
void fl_set_bmtable_maxitems(FL_OBJECT *, int);
-///
+/**/
int fl_get_bmtable_maxitems(FL_OBJECT *);
/** Returns the index of the selected item or -1 if none was selected */
#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
#include "insets/insettext.h"
+#include "insets/insetnumber.h"
#include "insets/insetert.h"
#include "insets/insetgraphics.h"
#include "insets/insetfoot.h"
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+ } else if (tmptok == "Number") {
+ inset = new InsetNumber(this);
+ inset->Read(lex);
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->InsertInset(pos, inset);
+ par->SetFont(pos, font);
+ ++pos;
} else if (tmptok == "Foot") {
inset = new InsetFoot(this);
inset->Read(lex);
LFUN_INSET_ERT, // Jug 20000218
LFUN_INSERT_GRAPHICS, // Lgb 20000226
LFUN_INSET_FOOTNOTE, // Jug 20000307
+ LFUN_INSET_NUMBER, // Dekel 20000402
LFUN_LASTACTION /* this marks the end of the table */
};
insetlof.h \
insetlot.C \
insetlot.h \
+ insetnumber.C \
+ insetnumber.h \
insetparent.C \
insetparent.h \
insetquotes.C \
cutSelection();
actpos = selection_start;
par->InsertChar(actpos,arg[0]);
- par->SetFont(actpos,real_current_font);
+ SetCharFont(actpos,current_font);
++actpos;
selection_start = selection_end = actpos;
UpdateLocal(bv, true);
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->previous,
bv->text->cursor.par->ParFromPos(bv->text->cursor.pos)->next);
par->InsertChar(actpos,LyXParagraph::META_NEWLINE);
- par->SetFont(actpos,real_current_font);
+ SetCharFont(actpos,current_font);
UpdateLocal(bv, true);
++actpos;
selection_start = selection_end = actpos;
if (flag) {
computeTextRows(bv->painter(), xpos);
computeBaselines(top_baseline);
- resetPos(bv);
}
bv->updateInset(this, flag);
+ if (flag)
+ resetPos(bv);
ShowInsetCursor(bv);
}
///
MARGIN_CODE,
///
- SPECIALCHAR_CODE
+ SPECIALCHAR_CODE,
+ ///
+ NUMBER_CODE
};
enum EDITABLE {
void StyleReset()
{
- LyXFont font(LyXFont::ALL_INHERIT);
+ LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
ToggleAndShow(current_view, font);
}
if (!current_view->available())
return;
- if (lyxrc.rtl_support) {
- 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;
int count = 0;
bool env = false;
- if (language() != prev.language()) {
+ if (language() != base.language() && language() != prev.language()) {
if (isRightToLeft() != prev.isRightToLeft()) {
if (isRightToLeft()) {
os << "\\R{";
int count = 0;
bool env = false;
- if (language() != next.language()) {
+ if (language() != base.language() && language() != next.language()) {
os << "}";
++count;
env = true; // Size change need not bother about closing env.
#include "insets/insetinclude.h"
#include "insets/insetbib.h"
#include "insets/insettext.h"
+#include "insets/insetnumber.h"
#include "insets/insetert.h"
#include "insets/insetgraphics.h"
#include "insets/insetfoot.h"
setMessage(N_("Text mode"));
LyXDirection direction = owner->view()->text->
cursor.par->getParDirection();
- if ((action == -1) ||
- ((action == LFUN_RIGHT) &&
- (direction == LYX_DIR_LEFT_TO_RIGHT))) {
+ switch(action) {
+ case LFUN_UNKNOWN_ACTION:
+ case LFUN_BREAKPARAGRAPH:
+ case LFUN_BREAKLINE:
owner->view()->text->CursorRight();
- moveCursorUpdate(false);
- owner->getMiniBuffer()->
- Set(CurrentState());
- }
- if ((action == LFUN_LEFT) &&
- (direction == LYX_DIR_RIGHT_TO_LEFT)) {
- owner->view()->text->CursorRight();
- moveCursorUpdate(false);
- owner->getMiniBuffer()->
- Set(CurrentState());
- }
- if ((action == LFUN_LEFT) ||
- (action == LFUN_RIGHT))
+ owner->view()->setState();
+ owner->getMiniBuffer()->Set(CurrentState());
+ break;
+ case LFUN_RIGHT:
+ if (direction == LYX_DIR_LEFT_TO_RIGHT) {
+ owner->view()->text->CursorRight();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->
+ Set(CurrentState());
+ }
+ return string();
+ case LFUN_LEFT:
+ if (direction == LYX_DIR_RIGHT_TO_LEFT) {
+ owner->view()->text->CursorRight();
+ moveCursorUpdate(false);
+ owner->getMiniBuffer()->
+ Set(CurrentState());
+ }
return string();
+ default:
+ break;
+ }
}
}
}
case LFUN_PASTE:
owner->view()->paste();
+ owner->view()->setState();
break;
case LFUN_PASTESELECTION:
case LFUN_LAYOUT_PASTE:
owner->view()->pasteEnvironment();
+ owner->view()->setState();
break;
case LFUN_GOTOERROR:
text->cursor.par->
GetLayout() + 1);
owner->view()->update(1);
+ owner->view()->setState();
}
}
break;
new_inset->Edit(owner->view(), 0, 0, 0);
}
break;
+ case LFUN_INSET_NUMBER:
+ {
+ InsetNumber * new_inset = new InsetNumber(owner->buffer());
+ owner->view()->insertInset(new_inset);
+ new_inset->Edit(owner->view(), 0, 0, 0);
+ }
+ break;
case LFUN_INSET_ERT:
{
InsetERT * new_inset = new InsetERT(owner->buffer());
owner->view()->beforeChange();
if (isdigit(argument[0]) &&
- (lyxrc.auto_mathmode == "true" ||
- (lyxrc.auto_mathmode == "rtl" &&
+ (lyxrc.number_inset == "true" ||
+ (lyxrc.number_inset == "rtl" &&
owner->view()->text->real_current_font.isVisibleRightToLeft()
))) {
- UpdatableInset * tmpinset = new InsetFormula;
- LyXCursor & cursor = owner->view()->text->cursor;
- if (cursor.pos > 0 &&
- cursor.par->GetChar(cursor.pos - 1) == '-' &&
- (cursor.pos == 1 ||
- cursor.par->IsSeparator(cursor.pos - 2) ||
- cursor.par->IsNewline(cursor.pos - 2) )
- ) {
- owner->view()->text->Backspace();
- owner->view()->open_new_inset(tmpinset);
- tmpinset->LocalDispatch(owner->view(),
- LFUN_UNKNOWN_ACTION,
- "-");
- } else {
- owner->view()->open_new_inset(tmpinset);
- }
- tmpinset->LocalDispatch(owner->view(),
- LFUN_UNKNOWN_ACTION,
+ UpdatableInset * tmpinset = new InsetNumber(owner->buffer());
+ owner->view()->open_new_inset(tmpinset);
+ tmpinset->LocalDispatch(owner->view(), action,
argument);
return string();
}
size_type pos;
///
Inset * inset;
+ ///
+ InsetTable(size_type p, Inset * i) { pos = p; inset = i;}
};
///
typedef list<FontTable> FontList;
///
FontList fontlist;
///
- typedef list<InsetTable> InsetList;
+ typedef vector<InsetTable> InsetList;
///
InsetList insetlist;
///
///
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_AUTO_MATHMODE,
+ RC_NUMBER_INSET,
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_mathmode", RC_AUTO_MATHMODE },
{ "\\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;
- auto_mathmode = "rtl";
+ number_inset = "rtl";
language_package = "\\usepackage{babel}";
language_auto_begin = true;
language_auto_end = true;
if (lexrc.next())
rtl_support = lexrc.GetBool();
break;
- case RC_AUTO_MATHMODE:
+ case RC_NUMBER_INSET:
if (lexrc.next())
- auto_mathmode = lowercase(lexrc.GetString());
+ number_inset = lowercase(lexrc.GetString());
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_AUTO_MATHMODE:
- os << "\\auto_mathmode" << auto_mathmode << "\n";
+ case RC_NUMBER_INSET:
+ os << "\\number_inset " << number_inset << "\n";
case RC_LANGUAGE_AUTO_BEGIN:
os << "\\language_auto_begin "
<< tostr(language_auto_begin) << "\n";
///
bool rtl_support;
///
- string auto_mathmode;
+ string number_inset;
///
bool show_banner;
/// Do we have to use a GUI?
decide, wether it is selected text or not. This is a strange
solution but faster.
*/
- void GetVisibleRow(int offset,
- Row * row_ptr, long y);
-
+ void GetVisibleRow(int offset, Row * row_ptr, long y);
+
/* footnotes: */
///
void ToggleFootnote();
///
mutable LyXParagraph::size_type bidi_start;
+ ///
+ mutable bool bidi_same_direction;
+
///
void ComputeBidiTables(Row *row) const;
using std::endl;
using std::fstream;
using std::ios;
-using std::greater;
int tex_code_break_column = 72; // needs non-zero initialization. set later.
// this is a bad idea, but how can LyXParagraph find its buffer to get
// the inset, not just a clone. Otherwise
// the inset would be deleted when calling Erase(pos)
// find the entry
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).pos == pos) {
- (*it).inset = 0;
- break;
- }
-
- }
+ InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ if (it != insetlist.end() && (*it).pos == pos)
+ (*it).inset = 0;
} else {
minibuffer_inset = 0;
minibuffer_char = ' ';
// if it is an inset, delete the inset entry
if (text[pos] == LyXParagraph::META_INSET) {
// find the entry
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).pos == pos) {
- delete (*it).inset;
- insetlist.erase(it);
- break;
- }
+ InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ if (it != insetlist.end() && (*it).pos == pos) {
+ delete (*it).inset;
+ insetlist.erase(it);
}
}
text.erase(text.begin() + pos);
}
// Update the inset table.
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).pos > pos)
- (*it).pos--;
- }
+ for (InsetList::iterator it = upper_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ it != insetlist.end(); ++it)
+ --(*it).pos;
} else {
lyxerr << "ERROR (LyXParagraph::Erase): "
"can't erase non-existant char." << endl;
}
// Update the inset table.
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).pos >= pos)
- (*it).pos++;
- }
+ for (InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ it != insetlist.end(); ++it)
+ ++(*it).pos;
}
if (inset) {
// Add a new entry in the inset table.
- InsetList::iterator it =
- insetlist.insert(insetlist.begin(), InsetTable());
- (*it).inset = inset;
- (*it).pos = pos;
+ InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ 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));
}
}
return 0;
}
// Find the inset.
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).pos == pos) {
- return (*it).inset;
- }
- }
+ InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ if (it != insetlist.end() && (*it).pos == pos)
+ return (*it).inset;
+
lyxerr << "ERROR (LyXParagraph::GetInset): "
"Inset does not exist: " << pos << endl;
// text[pos] = ' '; // WHY!!! does this set the pos to ' '????
return 0;
}
// Find the inset.
- for (InsetList::const_iterator cit = insetlist.begin();
- cit != insetlist.end(); ++cit) {
- if ((*cit).pos == pos) {
- return (*cit).inset;
- }
- }
+ InsetList::const_iterator cit = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ if (cit != insetlist.end() && (*cit).pos == pos)
+ return (*cit).inset;
+
lyxerr << "ERROR (LyXParagraph::GetInset): "
"Inset does not exist: " << pos << endl;
//text[pos] = ' '; // WHY!!! does this set the pos to ' '????
if (0 >= (*cit).pos && 0 <= (*cit).pos_end)
return (*cit).font;
#endif
- }
+ } else if (next && next->footnoteflag != LyXParagraph::NO_FOOTNOTE)
+ return NextAfterFootnote()->GetFirstFontSettings();
return LyXFont(LyXFont::ALL_INHERIT);
}
// copy everything behind the break-position to the new paragraph
- // IMO this is not correct. Here we should not use the Minibuffer to
- // copy stuff, as the Minibuffer is global and we could be in a
- // situation where we copy a paragraph inside a paragraph (this now
- // is possible think of Text-Insets!). So I'm changing this so that
- // then inside the Text-Inset I can use par->Clone() to copy the
- // paragraph data from one inset to the other!
-#if 0
- for (size_type i = 0; i < size(); ++i) {
- CopyIntoMinibuffer(i);
- result->InsertFromMinibuffer(i);
- }
-#else
- for(size_type i = 0; i < size(); ++i) {
- result->InsertChar(i, GetChar(i));
- result->SetFont(i, GetFontSettings(i));
- if ((GetChar(i) == LyXParagraph::META_INSET) && GetInset(i)) {
- result->InsertInset(i, GetInset(i)->Clone());
- }
- }
-#endif
- result->text.resize(result->text.size());
+ result->text = text;
+ result->fontlist = fontlist;
+ result->insetlist = insetlist;
+ for (InsetList::iterator it = result->insetlist.begin();
+ it != result->insetlist.end(); ++it)
+ (*it).inset = (*it).inset->Clone();
return result;
}
int LyXParagraph::AutoDeleteInsets()
{
- vector<size_type> tmpvec;
- int i = 0;
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).inset && (*it).inset->AutoDelete()) {
- tmpvec.push_back((*it).pos);
+ 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.
+ ++count;
+ } else
++i;
- }
- }
- sort(tmpvec.begin(), tmpvec.end(), greater<size_type>());
- for (vector<size_type>::const_iterator cit = tmpvec.begin();
- cit != tmpvec.end(); ++cit) {
- Erase((*cit));
}
- return i;
+ return count;
}
Inset * LyXParagraph::ReturnNextInsetPointer(LyXParagraph::size_type & pos)
{
- InsetList::iterator it2 = insetlist.end();
- for (InsetList::iterator it = insetlist.begin();
- it != insetlist.end(); ++it) {
- if ((*it).pos >= pos) {
- if (it2 == insetlist.end() || (*it).pos < (*it2).pos)
- it2 = it;
- }
- }
- if (it2 != insetlist.end()) {
- pos = (*it2).pos;
- return (*it2).inset;
+ InsetList::iterator it = lower_bound(insetlist.begin(),
+ insetlist.end(),
+ InsetTable(pos,0));
+ if (it != insetlist.end()) {
+ pos = (*it).pos;
+ return (*it).inset;
}
return 0;
}
&& running_font.isRightToLeft()) {
os << "\\L{";
close = true;
+ } else if (inset->LyxCode() == Inset::NUMBER_CODE
+ && running_font.isRightToLeft()) {
+ os << "{\\beginL ";
+ close = true;
}
int tmp = inset->Latex(os, style.isCommand(),
style.free_spacing);
if (close)
- os << "}";
-
+ if (inset->LyxCode() == Inset::NUMBER_CODE)
+ os << "\\endL}";
+ else
+ os << "}";
+
if (tmp) {
column = 0;
} else {
{
if (!cursor_visible) {
Cursor_Shape shape = BAR_SHAPE;
- if (text->real_current_font.isVisibleRightToLeft()
+ if (text->real_current_font.language() !=
+ text->parameters->language_info
+ || text->real_current_font.isVisibleRightToLeft()
!= text->parameters->language_info->RightToLeft)
shape = (text->real_current_font.isVisibleRightToLeft())
? REVERSED_L_SHAPE : L_SHAPE;
void LyXText::ComputeBidiTables(Row * row) const
{
-
+ bidi_same_direction = true;
if (!lyxrc.rtl_support) {
bidi_start = -1;
return;
++lpos;
}
direction = static_cast<LyXDirection>(-direction);
+ bidi_same_direction = false;
}
}
&& !row->par->table
&& last != vis2log(last)
&& row->par->IsLineSeparator(last)) {
- if (!(main_body > 0 && main_body-1 == 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 ||
&& !(cursor.par->Next()
&& cursor.par->footnoteflag == LyXParagraph::NO_FOOTNOTE
&& cursor.par->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)) {
- // This is an empty paragraph and we delete it just by moving the curosr one step
- // left and let the DeleteEmptyParagraphMechanism handle the actual deleteion
+ // This is an empty paragraph and we delete it just by moving the cursor one step
+ // left and let the DeleteEmptyParagraphMechanism handle the actual deletion
// of the paragraph.
if (cursor.par->previous) {
// not a good idea since it triggers the auto-delete
// mechanism. So we do a CursorLeftIntern()-lite,
// without the dreaded mechanism. (JMarc)
- if (cursor.pos > 0) {
- SetCursorIntern(cursor.par, cursor.pos - 1);
- }
- else if (cursor.par->Previous()) {
+ if (cursor.par->Previous()) {
// steps into the above paragraph.
SetCursorIntern(cursor.par->Previous(),
cursor.par->Previous()->Last());
}
-
-#warning See comment on top of text.C
/* Pasting is not allowed, if the paragraphs have different
layout. I think it is a real bug of all other
word processors to allow it. It confuses the user.
// not a good idea since it triggers the auto-delete
// mechanism. So we do a CursorLeftIntern()-lite,
// without the dreaded mechanism. (JMarc)
- if (cursor.pos > 0) {
- SetCursorIntern(cursor.par, cursor.pos - 1);
- }
- else if (cursor.par->Previous()) {
- // steps into the above paragraph.
- SetCursorIntern(cursor.par->Previous(),
- cursor.par->Previous()->Last());
- }
-// CursorLeftIntern();
+ SetCursorIntern(cursor.par, cursor.pos - 1);
// some insets are undeletable here
if (cursor.par->GetChar(cursor.pos) == LyXParagraph::META_INSET) {
if (!cursor.par->GetInset(cursor.pos)->Deletable())
return;
// force complete redo when erasing display insets
- // this is a cruel mathod but save..... Matthias
+ // this is a cruel method but safe..... Matthias
if (cursor.par->GetInset(cursor.pos)->display()){
cursor.par->Erase(cursor.pos);
RedoParagraph();
}
-void LyXText::GetVisibleRow(int offset,
- Row * row_ptr, long y)
+void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
{
/* returns a printed row */
Painter & pain = owner_->painter();
LyXDirection direction = row_ptr->par->getParDirection();
- LyXParagraph::size_type vpos, pos, pos_end;
+ LyXParagraph::size_type last = RowLast(row_ptr);
+
+ LyXParagraph::size_type vpos, pos;
float x, tmpx;
int y_top, y_bottom;
float fill_separator, fill_hfill, fill_label_hfill;
pain.fillRectangle(0, offset, paperwidth, row_ptr->height);
if (selection) {
- /* selection code */
- if (sel_start_cursor.row == row_ptr &&
- sel_end_cursor.row == row_ptr) {
- if (sel_start_cursor.x < sel_end_cursor.x)
- pain.fillRectangle(sel_start_cursor.x, offset,
- sel_end_cursor.x - sel_start_cursor.x,
- row_ptr->height,
- LColor::selection);
- else
- pain.fillRectangle(sel_end_cursor.x, offset,
- sel_start_cursor.x - sel_end_cursor.x,
- 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,
- row_ptr->height,
- LColor::selection);
- else
+ /* selection code */
+ if (bidi_same_direction) {
+ if (sel_start_cursor.row == row_ptr &&
+ sel_end_cursor.row == row_ptr) {
+ if (sel_start_cursor.x < sel_end_cursor.x)
+ pain.fillRectangle(sel_start_cursor.x, offset,
+ sel_end_cursor.x - sel_start_cursor.x,
+ row_ptr->height,
+ LColor::selection);
+ else
+ pain.fillRectangle(sel_end_cursor.x, offset,
+ sel_start_cursor.x - sel_end_cursor.x,
+ 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,
+ row_ptr->height,
+ LColor::selection);
+ else
+ pain.fillRectangle(0, offset,
+ 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,
+ row_ptr->height,
+ LColor::selection);
+ else
+ pain.fillRectangle(sel_end_cursor.x, offset,
+ paperwidth - sel_end_cursor.x,
+ row_ptr->height,
+ LColor::selection);
+ } else if (y > sel_start_cursor.y && y < sel_end_cursor.y) {
pain.fillRectangle(0, offset,
- sel_start_cursor.x,
- row_ptr->height,
+ paperwidth, row_ptr->height,
LColor::selection);
- } else if (sel_end_cursor.row == row_ptr) {
- if (direction == LYX_DIR_LEFT_TO_RIGHT)
+ }
+ } else if ( sel_start_cursor.row != row_ptr &&
+ sel_end_cursor.row != row_ptr &&
+ y > sel_start_cursor.y && y < sel_end_cursor.y) {
+ pain.fillRectangle(0, offset,
+ paperwidth, row_ptr->height,
+ LColor::selection);
+ } else if (sel_start_cursor.row == row_ptr ||
+ sel_end_cursor.row == row_ptr) {
+ float tmpx = x;
+ int cell = 0;
+ if (row_ptr->par->table) {
+ 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))
pain.fillRectangle(0, offset,
- sel_end_cursor.x,
- row_ptr->height,
+ tmpx, row_ptr->height,
LColor::selection);
- else
- pain.fillRectangle(sel_end_cursor.x, offset,
- paperwidth - sel_end_cursor.x,
+ if (row_ptr->par->table) {
+ float x_old = x;
+ for (vpos = row_ptr->pos; vpos <= last; ++vpos) {
+ pos = vis2log(vpos);
+ float old_tmpx = tmpx;
+ if (row_ptr->par->IsNewline(pos)) {
+ tmpx = x_old + row_ptr->par->table->WidthOfColumn(cell);
+ x_old = tmpx;
+ ++cell;
+ tmpx += row_ptr->par->table->GetBeginningOfTextInCell(cell);
+ } else {
+ tmpx += SingleWidth(row_ptr->par, pos);
+ }
+ if ( (sel_start_cursor.row != row_ptr ||
+ sel_start_cursor.pos <= pos) &&
+ (sel_end_cursor.row != row_ptr ||
+ pos < sel_end_cursor.pos) )
+ pain.fillRectangle(old_tmpx, offset,
+ tmpx - old_tmpx + 1,
+ row_ptr->height,
+ LColor::selection);
+ }
+ } else {
+ LyXParagraph::size_type main_body =
+ BeginningOfMainBody(row_ptr->par);
+
+ for (vpos = row_ptr->pos; vpos <= last; ++vpos) {
+ pos = vis2log(vpos);
+ float old_tmpx = tmpx;
+ if (main_body > 0 && pos == main_body-1) {
+ tmpx += fill_label_hfill +
+ GetFont(row_ptr->par, -2).stringWidth(
+ textclasslist.Style(parameters->textclass, row_ptr->par->GetLayout()).labelsep);
+ if (row_ptr->par->IsLineSeparator(main_body-1))
+ tmpx -= SingleWidth(row_ptr->par, main_body-1);
+ }
+ if (HfillExpansion(row_ptr, pos)) {
+ tmpx += SingleWidth(row_ptr->par, pos);
+ if (pos >= main_body)
+ tmpx += fill_hfill;
+ else
+ 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;
+ }
+ } else
+ tmpx += SingleWidth(row_ptr->par, pos);
+
+ if ( (sel_start_cursor.row != row_ptr ||
+ sel_start_cursor.pos <= pos) &&
+ (sel_end_cursor.row != row_ptr ||
+ pos < sel_end_cursor.pos) )
+ pain.fillRectangle(old_tmpx, offset,
+ tmpx - old_tmpx + 1,
+ row_ptr->height,
+ 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) )
+ pain.fillRectangle(tmpx, offset,
+ paperwidth - tmpx,
row_ptr->height,
LColor::selection);
-
- } else if (y > sel_start_cursor.y && y < sel_end_cursor.y) {
- pain.fillRectangle(0, offset,
- paperwidth, row_ptr->height,
- LColor::selection);
}
}
-
+
if (row_ptr->par->appendix){
pain.line(1, offset,
1, offset + row_ptr->height,
/* is it a last row? */
par = row_ptr->par->LastPhysicalPar();
- if (row_ptr->par->ParFromPos(RowLast(row_ptr) + 1) == par
+ if (row_ptr->par->ParFromPos(last + 1) == par
&& (!row_ptr->next || row_ptr->next->par != row_ptr->par)) {
/* think about the margins */
int endlabel = row_ptr->par->GetEndLabel();
if (endlabel == END_LABEL_BOX ||
endlabel == END_LABEL_FILLED_BOX) {
- LyXFont font = GetFont(row_ptr->par, RowLast(row_ptr));
+ LyXFont font = GetFont(row_ptr->par, last);
int size = int(0.75*font.maxAscent());
int y = (offset + row_ptr->baseline) - size;
int x = (direction == LYX_DIR_LEFT_TO_RIGHT)
}
/* draw the text in the pixmap */
- pos_end = RowLast(row_ptr);
vpos = row_ptr->pos;
/* table stuff -- begin*/
float x_old = x;
x += row_ptr->par->table->GetBeginningOfTextInCell(cell);
- while (vpos <= pos_end) {
+ while (vpos <= last) {
pos = vis2log(vpos);
if (row_ptr->par->IsNewline(pos)) {
LyXParagraph::size_type main_body =
BeginningOfMainBody(row_ptr->par);
if (main_body > 0 &&
- (main_body-1 > pos_end ||
+ (main_body-1 > last ||
!row_ptr->par->IsLineSeparator(main_body-1)))
main_body = 0;
- while (vpos <= pos_end) {
+ while (vpos <= last) {
pos = vis2log(vpos);
if (main_body > 0 && pos == main_body-1) {
x += fill_label_hfill
x += 2;
++vpos;
} else if (row_ptr->par->IsSeparator(pos)) {
- tmpx = x;
- x+= SingleWidth(row_ptr->par, pos);
- if (pos >= main_body)
- x+= fill_separator;
+ if (pos != last || !row_ptr->next ||
+ row_ptr->next->par != row_ptr->par ||
+ direction == row_ptr->par->getLetterDirection(last)) {
+#if 0
+ tmpx = x;
+#endif
+ x += SingleWidth(row_ptr->par, pos);
+ if (pos >= main_body)
+ x += fill_separator;
+ }
#warning Think about this
#if 0
/* -------> Only draw protected spaces when
tmpx -= SingleWidth(row->par, main_body-1);
}
- tmpx += SingleWidth(row->par, c);
if (HfillExpansion(row, c)) {
+ x += SingleWidth(row->par, c);
if (c >= main_body)
tmpx += fill_hfill;
else
tmpx += fill_label_hfill;
}
- else if (c >= main_body
- && row->par->IsSeparator(c)) {
- tmpx+= fill_separator;
- }
+ 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;
+ }
+ } else
+ tmpx += SingleWidth(row->par, c);
++vc;
}
// we have to reset the selection, because the
// geometry could have changed */
- SetCursor(sel_start_cursor.par, sel_start_cursor.pos);
+ SetCursor(sel_start_cursor.par, sel_start_cursor.pos, false);
sel_cursor = cursor;
- SetCursor(sel_end_cursor.par, sel_end_cursor.pos);
+ SetCursor(sel_end_cursor.par, sel_end_cursor.pos, false);
UpdateCounters(cursor.row);
ClearSelection();
SetSelection();
- SetCursor(tmpcursor.par, tmpcursor.pos);
+ SetCursor(tmpcursor.par, tmpcursor.pos, true);
}
x -= SingleWidth(row->par, main_body-1);
}
- x += SingleWidth(row->par, pos);
if (HfillExpansion(row, pos)) {
+ x += SingleWidth(row->par, pos);
if (pos >= main_body)
x += fill_hfill;
else
x += fill_label_hfill;
}
- else if (pos >= main_body && row->par->IsSeparator(pos)) {
- x+= fill_separator;
- }
+ 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;
+ }
+ } else
+ x += SingleWidth(row->par, pos);
}
}