+2001-05-28 Juergen Vigna <jug@sad.it>
+
+ * text.C (SetHeightOfRow): added the update() call again as it is
+ needed to initialize inset dimensions!
+
+2001-05-16 Juergen Vigna <jug@sad.it>
+
+ * text2.C (SetCharFont): Add new function with BufferView * and
+ bool toggleall parameters for setting insets internal fonts.
+ (SetFont): Freeze the undo as we may change fonts in Insets and
+ all this change should be inside only one Undo!
+
+ * bufferview_funcs.C (ToggleAndShow): fixed this functions for
+ setting font's in insets as for them we have the SetFont function!
+
+2001-05-15 Juergen Vigna <jug@sad.it>
+
+ * text2.C (ClearSelection): to be sure we REALLY don't have any
+ selection anymore!
+
+ * tabular.C (TeXCellPreamble): fixed the left border problem for
+ multicolumn cells.
+
2001-05-27 Dekel Tsur <dekelts@tau.ac.il>
* LaTeX.C (deplog): Make sure that the main .tex file is in the
void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
{
if (bv->available()) {
+ if (bv->theLockingInset()) {
+ bv->theLockingInset()->SetFont(bv, font, toggleall);
+ return;
+ }
LyXText * text = bv->getLyXText();
bv->hideCursor();
if (font.language() != ignore_language ||
font.latex() != LyXFont::IGNORE ||
- font.number() != LyXFont::IGNORE) {
+ font.number() != LyXFont::IGNORE)
+ {
LyXCursor & cursor = text->cursor;
text->ComputeBidiTables(bv->buffer(), cursor.row());
if (cursor.boundary() !=
+2001-05-28 Juergen Vigna <jug@sad.it>
+
+ * insettext.C (resizeLyXText): clear LyXText ONLY if we don't have
+ a endless-width inset (maxWidth < 0).
+ (Edit): change language only if not equal.
+
+ * insettabular.C (resetPos): call UpdateLocal only on REAL scroll!
+
+ * insettext.C (draw): fixed draw/clear of InsetText-Frame
+
+2001-05-16 Juergen Vigna <jug@sad.it>
+
+ * insettext.C (selectAll): added
+ (clearSelection): added
+
+ * insettabular.C (SetFont): now we may set a font on a whole selection!
+ (getSelection): added helper function.
+
2001-05-27 Dekel Tsur <dekelts@tau.ac.il>
* insetcite.C (Ascii): Add method.
}
-void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
+void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool, bool )
{}
}
-void InsetCollapsable::SetFont(BufferView * bv,
- LyXFont const & font, bool toggleall)
+void InsetCollapsable::SetFont(BufferView * bv, LyXFont const & font,
+ bool toggleall, bool selectall)
{
- inset.SetFont(bv, font, toggleall);
+ inset.SetFont(bv, font, toggleall, selectall);
}
///
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
///
- void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+ bool selectall = false);
///
void setLabel(string const & l) { label = l; }
///
}
-void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
+void InsetERT::SetFont(BufferView *, LyXFont const &, bool, bool selectall)
{
- WriteAlert(_("Impossible Operation!"),
- _("Not permitted to change font-types inside ERT-insets!"),
- _("Sorry."));
+ // if selectall is activated then the fontchange was an outside general
+ // fontchange and this messages is not needed
+ if (!selectall)
+ WriteAlert(_("Impossible Operation!"),
+ _("Not permitted to change font-types inside ERT-insets!"),
+ _("Sorry."));
}
///
bool InsertInset(BufferView *, Inset *) { return false; }
///
- void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+ bool selectall = false);
///
void Edit(BufferView *, int, int, unsigned int);
};
void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
{
- string token;
-
- if (lex.IsOK()) {
- lex.next();
- token = lex.GetString();
- if (token == "position") {
- lex.next();
- pos_ = static_cast<Position>(lex.GetInteger());
- token = string();
- } else {
- lyxerr << "InsetMinipage::Read: Missing 'position'-tag!"
- << endl;
- }
- }
- if (lex.IsOK()) {
- if (token.empty()) {
- lex.next();
- token = lex.GetString();
- }
- if (token == "inner_position") {
- lex.next();
- inner_pos_ = static_cast<InnerPosition>(lex.GetInteger());
- token = string();
- } else {
- lyxerr << "InsetMinipage::Read: Missing 'inner_position'-tag!"
- << endl;
- }
- }
- if (lex.IsOK()) {
- if (token.empty()) {
- lex.next();
- token = lex.GetString();
+ string token;
+
+ if (lex.IsOK()) {
+ lex.next();
+ token = lex.GetString();
+ if (token == "position") {
+ lex.next();
+ pos_ = static_cast<Position>(lex.GetInteger());
+ token = string();
+ } else {
+ lyxerr << "InsetMinipage::Read: Missing 'position'-tag!"
+ << endl;
+ }
}
- if (token == "height") {
- lex.next();
- height_ = lex.GetString();
- token = string();
- } else {
- lyxerr << "InsetMinipage::Read: Missing 'height'-tag!"
- << endl;
+ if (lex.IsOK()) {
+ if (token.empty()) {
+ lex.next();
+ token = lex.GetString();
+ }
+ if (token == "inner_position") {
+ lex.next();
+ inner_pos_ = static_cast<InnerPosition>(lex.GetInteger());
+ token = string();
+ } else {
+ lyxerr << "InsetMinipage::Read: Missing 'inner_position'-tag!"
+ << endl;
+ }
}
- }
- if (lex.IsOK()) {
- if (token.empty()) {
- lex.next();
- token = lex.GetString();
+ if (lex.IsOK()) {
+ if (token.empty()) {
+ lex.next();
+ token = lex.GetString();
+ }
+ if (token == "height") {
+ lex.next();
+ height_ = lex.GetString();
+ token = string();
+ } else {
+ lyxerr << "InsetMinipage::Read: Missing 'height'-tag!"
+ << endl;
+ }
}
- if (token == "width") {
- lex.next();
- width_ = lex.GetString();
- token = string();
- } else {
- lyxerr << "InsetMinipage::Read: Missing 'width'-tag!"
- << endl;
+ if (lex.IsOK()) {
+ if (token.empty()) {
+ lex.next();
+ token = lex.GetString();
+ }
+ if (token == "width") {
+ lex.next();
+ width_ = lex.GetString();
+ token = string();
+ } else {
+ lyxerr << "InsetMinipage::Read: Missing 'width'-tag!"
+ << endl;
+ }
}
- }
#ifdef WITH_WARNINGS
#warning Remove me before final 1.2.0 (Jug)
#warning Can we please remove this as soon as possible? (Lgb)
#endif
- // this is only for compatibility to the intermediate format and should
- // vanish till the final 1.2.0!
- if (lex.IsOK()) {
- if (token.empty()) {
- lex.next();
- token = lex.GetString();
- }
- if (token == "widthp") {
- lex.next();
- // only do this if the width_-string was not already set!
- if (width_.empty())
- width_ = lex.GetString() + "%";
- token = string();
- } else {
- lyxerr << "InsetMinipage::Read: Missing 'widthp_'-tag!"
- << endl;
+ // this is only for compatibility to the intermediate format and should
+ // vanish till the final 1.2.0!
+ if (lex.IsOK()) {
+ if (token.empty()) {
+ lex.next();
+ token = lex.GetString();
+ }
+ if (token == "widthp") {
+ lex.next();
+ // only do this if the width_-string was not already set!
+ if (width_.empty())
+ width_ = lex.GetString() + "%";
+ token = string();
+ }
}
- }
- if (!token.empty())
- lex.pushToken(token);
- InsetCollapsable::Read(buf, lex);
+ if (!token.empty())
+ lex.pushToken(token);
+ InsetCollapsable::Read(buf, lex);
}
bool InsetMinipage::ShowInsetDialog(BufferView * bv) const
{
- if (!inset.ShowInsetDialog(bv))
+ if (!inset.ShowInsetDialog(bv))
bv->owner()->getDialogs()->showMinipage(const_cast<InsetMinipage *>(this));
- return true;
+ return true;
}
void InsetMinipage::InsetButtonRelease(BufferView * bv, int x, int y,
int button)
{
- if (button == 3) {
+ if (button == 3) {
ShowInsetDialog(bv);
return;
- }
- InsetCollapsable::InsetButtonRelease(bv, x, y, button);
+ }
+ InsetCollapsable::InsetButtonRelease(bv, x, y, button);
}
int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
- const
+ const
{
- if (!width_.empty())
+ if (!width_.empty())
return VSpace(width_).inPixels(bv);
- // this should not happen!
- return InsetCollapsable::getMaxWidth(bv, inset);
+ // this should not happen!
+ return InsetCollapsable::getMaxWidth(bv, inset);
}
{
if (nodraw())
return;
- if (bv->text->status == LyXText::CHANGED_IN_DRAW)
- return;
-
-// lyxerr << "InsetTabular::draw(" << need_update << ")\n";
+#if 0
+ if (need_update == INIT) {
+ if (calculate_dimensions_of_cells(bv, font, true))
+ bv->text->status = LyXText::CHANGED_IN_DRAW;
+ need_update = FULL;
+ }
+#endif
Painter & pain = bv->painter();
int i;
float cx = dx;
//cx = dx = nx + tabular->GetBeginningOfTextInCell(cell);
tabular->GetCellInset(cell)->draw(bv,font,baseline, dx, false);
+#if 0
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
return;
+#endif
// clear only if we didn't have a change
if (need_update == CELL) {
// clear before the inset
}
x -= ADD_TO_TABULAR_WIDTH;
x += width(bv, font);
- if (bv->text->status == LyXText::CHANGED_IN_DRAW)
- need_update = INIT;
- else
+ if (bv->text->status == LyXText::CHANGED_IN_DRAW) {
+ int i=0;
+ for(Inset * inset=owner();inset;++i)
+ inset = inset->owner();
+ if (calculate_dimensions_of_cells(bv, font, false))
+ need_update = INIT;
+ } else {
need_update = NONE;
+ }
}
case LFUN_SHIFT_TAB:
case LFUN_TAB:
{
+ if (GetFirstLockingInsetOfType(Inset::TABULAR_CODE))
+ break;
HideInsetCursor(bv);
if (the_locking_inset) {
UnlockInsetInInset(bv, the_locking_inset);
} else if (the_locking_inset &&
(tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) {
int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
- if (xx > (bv->workWidth()-20))
+ if (xx > (bv->workWidth()-20)) {
scroll(bv, -(xx - bv->workWidth() + 60));
- else if (xx < 20) {
+ UpdateLocal(bv, FULL, false);
+ } else if (xx < 20) {
if (xx < 0)
xx = -xx + 60;
else
xx = 60;
scroll(bv, xx);
+ UpdateLocal(bv, FULL, false);
}
- UpdateLocal(bv, FULL, false);
} else if ((cursor.x() - offset) > 20 &&
(cursor.x() - offset + tabular->GetWidthOfColumn(actcell))
> (bv->workWidth() - 20)) {
}
-void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
+void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall,
+ bool selectall)
{
+ if (selectall) {
+ sel_cell_start = 0;
+ sel_cell_end = tabular->GetNumberOfCells() - 1;
+ }
+ if (hasSelection()) {
+ bool frozen;
+ bv->text->SetUndo(bv->buffer(), Undo::EDIT,
+ bv->text->cursor.par()->previous(),
+ bv->text->cursor.par()->next());
+ frozen = bv->text->undo_frozen;
+ if (!frozen)
+ bv->text->FreezeUndo();
+ // apply the fontchange on the whole selection
+ int sel_row_start;
+ int sel_row_end;
+ int sel_col_start;
+ int sel_col_end;
+ getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
+ for(int i=sel_row_start; i <= sel_row_end; ++i) {
+ for(int j=sel_col_start; j <= sel_col_end; ++j) {
+ tabular->GetCellInset(i, j)->SetFont(bv, font, tall, true);
+ }
+ }
+ if (!frozen)
+ bv->text->UnFreezeUndo();
+ UpdateLocal(bv, INIT, true);
+ }
if (the_locking_inset)
the_locking_inset->SetFont(bv, font, tall);
}
break;
}
if (hasSelection()) {
- sel_col_start = tabular->column_of_cell(sel_cell_start);
- sel_col_end = tabular->column_of_cell(sel_cell_end);
- if (sel_col_start > sel_col_end) {
- sel_col_end = sel_col_start;
- sel_col_start = tabular->column_of_cell(sel_cell_end);
- } else {
- sel_col_end = tabular->right_column_of_cell(sel_cell_end);
- }
-
- sel_row_start = tabular->row_of_cell(sel_cell_start);
- sel_row_end = tabular->row_of_cell(sel_cell_end);
- if (sel_row_start > sel_row_end) {
- //int tmp = sel_row_start;
- //sel_row_start = sel_row_end;
- //sel_row_end = tmp;
- swap(sel_row_start, sel_row_end);
- }
+ getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
} else {
sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
bool flag = true;
if (hasSelection()) {
- sel_row_start = tabular->row_of_cell(sel_cell_start);
- sel_row_end = tabular->row_of_cell(sel_cell_end);
- if (sel_row_start > sel_row_end) {
- //int tmp = sel_row_start;
- //sel_row_start = sel_row_end;
- //sel_row_end = tmp;
- swap(sel_row_start, sel_row_end);
- }
+ getSelection(sel_row_start, sel_row_end, dummy, dummy);
} else {
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
}
{
return !locked || (need_update & (FULL|INIT));
}
+
+void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol) const
+{
+ srow = tabular->row_of_cell(sel_cell_start);
+ erow = tabular->row_of_cell(sel_cell_end);
+ if (srow > erow)
+ swap(srow, erow);
+
+ scol = tabular->column_of_cell(sel_cell_start);
+ ecol = tabular->column_of_cell(sel_cell_end);
+ if (scol > ecol)
+ swap(scol, ecol);
+ else
+ ecol = tabular->right_column_of_cell(sel_cell_end);
+}
+
/* Emacs:
* Local variables:
* tab-width: 4
///
int GetActCell() const { return actcell; }
///
- void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+ bool selectall = false);
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
bool cutSelection();
///
bool isRightToLeft(BufferView *);
+ ///
+ void getSelection(int & scol, int & ecol, int & srow, int & erow) const;
//
// Private structures and variables
insetDescent = 0;
insetWidth = 0;
the_locking_inset = 0;
- interline_space = 1;
+ old_max_width = 0;
no_selection = false;
need_update = INIT;
drawTextXOffset = 0;
x += width(bv, f);
if (!cleared && (need_update & CLEAR_FRAME))
clearFrame(pain, cleared);
+ else if (cleared)
+ frame_is_visible = false;
need_update = NONE;
return;
}
if (!owner())
x += static_cast<float>(scroll());
#endif
+#if 0
// update insetWidth and insetHeight with dummy calls
(void)ascent(bv, f);
(void)descent(bv, f);
(void)width(bv, f);
+#endif
// if top_x differs we have a rule down and we don't have to clear anything
if (!cleared && (top_x == int(x)) &&
cleared = true;
need_update = FULL;
}
+ if (cleared)
+ frame_is_visible = false;
+
if (!cleared && (need_update == NONE))
return;
if (top_x != int(x)) {
- need_update |= INIT;
+ if ((getMaxWidth(bv, this) > 0) && (TEXT(bv)->width != old_max_width)){
+ resizeLyXText(bv);
+ need_update |= FULL;
+ old_max_width = TEXT(bv)->width;
+ bv->text->status = LyXText::CHANGED_IN_DRAW;
+ }
top_x = int(x);
- bv->text->status = LyXText::CHANGED_IN_DRAW;
+#if 1
+ cleared = true;
+#else
return;
+#endif
}
// lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
y = 0;
while ((row != 0) && (yf < ph)) {
TEXT(bv)->GetVisibleRow(bv, y+y_offset, int(x), row,
- y+first, cleared);
- y += row->height();
- yf += row->height();
- row = row->next();
+ y+first, cleared);
+ y += row->height();
+ yf += row->height();
+ row = row->next();
}
} else if (!locked) {
if (need_update & CURSOR) {
UpdateLocal(bv, CURSOR, false);
// If the inset is empty set the language of the current font to the
- // language to the surronding text.
- if (par->size() == 0 && !par->next()) {
+ // language to the surronding text (if different).
+ if (par->size() == 0 && !par->next() &&
+ bv->getParentLanguage(this) != TEXT(bv)->current_font.language())
+ {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
SetFont(bv, font, false);
HideInsetCursor(bv);
no_selection = false;
locked = false;
- UpdateLocal(bv, CLEAR_FRAME|CURSOR, false);
- if (owner())
+ int code = CURSOR|CLEAR_FRAME;
+ if (TEXT(bv)->selection) {
+ TEXT(bv)->ClearSelection(bv);
+ code = FULL;
+ } else if (owner())
bv->owner()->setLayout(owner()->getLyXText(bv)
- ->cursor.par()->GetLayout());
+ ->cursor.par()->GetLayout());
else
bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
+ UpdateLocal(bv, code, false);
}
}
-void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
+void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall,
+ bool selectall)
{
if (TEXT(bv)->selection) {
bv->text->SetUndo(bv->buffer(), Undo::EDIT,
bv->text->cursor.par()->previous(),
bv->text->cursor.par()->next());
}
+ if (selectall)
+ selectAll(bv);
TEXT(bv)->SetFont(bv, font, toggleall);
+ if (selectall)
+ TEXT(bv)->ClearSelection(bv);
bv->fitCursor(TEXT(bv));
- UpdateLocal(bv, CURSOR_PAR, true);
+ if (selectall || TEXT(bv)->selection)
+ UpdateLocal(bv, FULL, true);
+ else
+ UpdateLocal(bv, CURSOR_PAR, true);
}
void InsetText::resizeLyXText(BufferView * bv) const
{
- if (!par->next() && !par->size()) // resize not neccessary!
+ if (!par->next() && !par->size()) // no data, resize not neccessary!
+ return;
+ if (getMaxWidth(bv, this) < 0) // one endless line, no resize necessary
return;
if ((cache.find(bv) == cache.end()) || !cache[bv])
return;
{
return !locked || (need_update & (FULL|INIT));
}
+
+void InsetText::selectAll(BufferView * bv)
+{
+ TEXT(bv)->CursorTop(bv);
+ TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+ TEXT(bv)->CursorBottom(bv);
+ TEXT(bv)->SetSelection(bv);
+}
+
+void InsetText::clearSelection(BufferView * bv)
+{
+ TEXT(bv)->ClearSelection(bv);
+}
+
/* Emacs:
* Local variables:
* tab-width: 4
///
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
///
- void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+ bool selectall = false);
///
int getMaxWidth(BufferView *, UpdatableInset const *) const;
///
void scroll(BufferView *bv, int offset) const {
UpdatableInset::scroll(bv, offset);
}
+ ///
+ void selectAll(BufferView *bv);
+ ///
+ void clearSelection(BufferView *bv);
LyXParagraph * par;
///
///
mutable int inset_y;
///
- int interline_space;
+ mutable int old_max_width;
///
bool no_selection;
///
int baseline, float & x, bool cleared) const;
///
virtual void SetFont(BufferView *, LyXFont const &,
- bool toggleall = false);
+ bool toggleall = false, bool selectall = false);
///
virtual bool InsertInset(BufferView *, Inset *) { return false; }
///
LyXParagraph::size_type pos) const;
///
void SetCharFont(Buffer const *, LyXParagraph * par,
- LyXParagraph::size_type pos,
- LyXFont const & font);
+ LyXParagraph::size_type pos, LyXFont const & font);
+ void SetCharFont(BufferView *, LyXParagraph * par,
+ LyXParagraph::size_type pos,
+ LyXFont const & font, bool toggleall);
/// returns a pointer to the very first LyXParagraph
LyXParagraph * FirstParagraph() const;
///
mutable LyXCursor sel_cursor;
///
- LyXCursor sel_start_cursor;
+ mutable LyXCursor sel_start_cursor;
///
mutable LyXCursor sel_end_cursor;
/// needed for the toggling
if (!cellinfo_of_cell(cell)->align_special.empty()) {
os << cellinfo_of_cell(cell)->align_special << "}{";
} else {
- if (LeftLine(cell))
+ if (LeftLine(cell) &&
+ (IsFirstCellInRow(cell) ||
+ (!IsMultiColumn(cell-1) && !LeftLine(cell, true) &&
+ !RightLine(cell-1, true))))
+ {
os << '|';
+ }
if (!GetPWidth(cell).empty()) {
switch (GetVAlignment(cell)) {
case LYX_VALIGN_TOP:
InsetText * LyXTabular::GetCellInset(int row, int column) const
{
- return GetCellInset(GetCellNumber(row, column));
+ return & cell_info[row][column].inset;
}
} else if (c == LyXParagraph::META_INSET) {
Inset * tmpinset = par->GetInset(pos);
if (tmpinset) {
+#if 0 // seems not to be needed, but ...
tmpinset->update(bview, font);
+#endif
return tmpinset->width(bview, font);
} else
return 0;
if (c == LyXParagraph::META_INSET) {
Inset * tmpinset = row->par()->GetInset(pos);
if (tmpinset) {
-// tmpinset->update(bview, font, false);
+ tmpinset->update(bview, font, false);
tmpinset->draw(bview, font, offset+row->baseline(), x,
- cleared);
+ cleared);
#ifdef SEEMS_TO_BE_NOT_NEEDED
if (status == CHANGED_IN_DRAW) {
UpdateInset(bview, tmpinset);
tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
tmpinset = row_ptr->par()->GetInset(pos);
if (tmpinset) {
-// tmpinset->update(bview, tmpfont);
+#if 1 // this is needed for deep update on initialitation
+ tmpinset->update(bview, tmpfont);
+#endif
asc = tmpinset->ascent(bview, tmpfont);
desc = tmpinset->descent(bview, tmpfont);
maxwidth += tmpinset->width(bview, tmpfont);
void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
- Row * row_ptr, int y, bool cleared)
+ Row * row_ptr, int y, bool cleared)
{
// returns a printed row
Painter & pain = bview->painter();
SetCursorIntern(bview, firstrow->par(), 0);
sel_cursor = cursor;
#if 0
+ printf("TP = %x\n",inset_owner->owner());
// Dump all rowinformation:
Row * tmprow = firstrow;
lyxerr << "Width = " << width << endl;
}
+void LyXText::SetCharFont(BufferView * bv, LyXParagraph * par,
+ LyXParagraph::size_type pos, LyXFont const & fnt,
+ bool toggleall)
+{
+ Buffer const * buf = bv->buffer();
+ LyXFont font = GetFont(buf, par, pos);
+ font.update(fnt, buf->params.language, toggleall);
+ // Let the insets convert their font
+ if (par->GetChar(pos) == LyXParagraph::META_INSET) {
+ Inset * inset = par->GetInset(pos);
+ if (inset) {
+ if (inset->Editable()==Inset::HIGHLY_EDITABLE) {
+ UpdatableInset * uinset = static_cast<UpdatableInset *>(inset);
+ uinset->SetFont(bv, fnt, toggleall, true);
+ }
+ font = inset->ConvertFont(font);
+ }
+ }
+
+ LyXLayout const & layout =
+ textclasslist.Style(buf->params.textclass,
+ par->GetLayout());
+
+ // Get concrete layout font to reduce against
+ LyXFont layoutfont;
+
+ if (pos < BeginningOfMainBody(buf, par))
+ layoutfont = layout.labelfont;
+ else
+ layoutfont = layout.font;
+
+ // Realize against environment font information
+ if (par->GetDepth()){
+ LyXParagraph * tp = par;
+ while (!layoutfont.resolved() && tp && tp->GetDepth()) {
+ tp = tp->DepthHook(tp->GetDepth()-1);
+ if (tp)
+ layoutfont.realize(textclasslist.
+ Style(buf->params.textclass,
+ tp->GetLayout()).font);
+ }
+ }
+
+ layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+
+ // Now, reduce font against full layout font
+ font.reduce(layoutfont);
+
+ par->SetFont(pos, font);
+}
+
void LyXText::SetCharFont(Buffer const * buf, LyXParagraph * par,
- LyXParagraph::size_type pos,
- LyXFont const & fnt)
+ LyXParagraph::size_type pos, LyXFont const & fnt)
{
LyXFont font(fnt);
// Let the insets convert their font
if (par->GetChar(pos) == LyXParagraph::META_INSET) {
- if (par->GetInset(pos))
- font = par->GetInset(pos)->ConvertFont(font);
+ font = par->GetInset(pos)->ConvertFont(font);
}
LyXLayout const & layout =
SetUndo(bview->buffer(), Undo::EDIT,
sel_start_cursor.par()->previous(),
sel_end_cursor.par()->next());
+ FreezeUndo();
cursor = sel_start_cursor;
while (cursor.par() != sel_end_cursor.par() ||
(cursor.pos() < sel_end_cursor.pos())) {
if (cursor.pos() < cursor.par()->size()) {
// an open footnote should behave
// like a closed one
- LyXFont newfont = GetFont(bview->buffer(),
- cursor.par(), cursor.pos());
- newfont.update(font,
- bview->buffer()->params.language,
- toggleall);
- SetCharFont(bview->buffer(),
- cursor.par(), cursor.pos(), newfont);
+ SetCharFont(bview, cursor.par(), cursor.pos(), font, toggleall);
cursor.pos(cursor.pos() + 1);
} else {
cursor.pos(0);
cursor.par(cursor.par()->next());
}
}
+ UnFreezeUndo();
RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next());
{
selection = false;
mark_set = false;
+ sel_end_cursor = sel_start_cursor = cursor;
}
void LyXText::ToggleFree(BufferView * bview,
- LyXFont const & font, bool toggleall)
+ LyXFont const & font, bool toggleall)
{
// If the mask is completely neutral, tell user
if (font == LyXFont(LyXFont::ALL_IGNORE)) {