mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
setFont rework + some code simplification
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8140 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
328760c223
commit
0ca871014a
@ -1,3 +1,12 @@
|
|||||||
|
|
||||||
|
2003-11-27 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* text2.C (setFont): rework using PosIterator (no more recursive)
|
||||||
|
(setCharFont): no more needed
|
||||||
|
(setLayout): no more selection cursors fiddling (done by redoCursor)
|
||||||
|
* text.C: cursorRight(bv)->cursorRight(true) (TODO: find and
|
||||||
|
destroy remaining ones)
|
||||||
|
|
||||||
2003-11-26 Alfredo Braunstein <abraunst@lyx.org>
|
2003-11-26 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
* bufferview_funcs.[Ch]: split changeDepthAllowed from changeDepth
|
* bufferview_funcs.[Ch]: split changeDepthAllowed from changeDepth
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
2003-11-27 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* insettext.[Ch]:
|
||||||
|
* inset.[Ch]:
|
||||||
|
* insetcollapsable.[Ch]:
|
||||||
|
* insetert.[Ch]:
|
||||||
|
* insettabular.[Ch]: remove setFont
|
||||||
|
|
||||||
2003-11-25 Alfredo Braunstein <abraunst@lyx.org>
|
2003-11-25 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
* render_graphic.[Ch]: adjust comments
|
* render_graphic.[Ch]: adjust comments
|
||||||
|
@ -92,10 +92,6 @@ LColor_color InsetOld::backgroundColor() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetOld::setFont(BufferView *, LyXFont const &, bool, bool)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
|
bool InsetOld::forceDefaultParagraphs(InsetOld const * inset) const
|
||||||
{
|
{
|
||||||
if (owner())
|
if (owner())
|
||||||
|
@ -239,10 +239,6 @@ public:
|
|||||||
/// check if the font of the char we want inserting is correct
|
/// check if the font of the char we want inserting is correct
|
||||||
/// and modify it if it is not.
|
/// and modify it if it is not.
|
||||||
virtual bool checkInsertChar(LyXFont &);
|
virtual bool checkInsertChar(LyXFont &);
|
||||||
/// we need this here because collapsed insets are only EDITABLE
|
|
||||||
virtual void setFont(BufferView *, LyXFont const &,
|
|
||||||
bool toggleall = false, bool selectall = false);
|
|
||||||
|
|
||||||
// should this inset be handled like a normal charater
|
// should this inset be handled like a normal charater
|
||||||
virtual bool isChar() const { return false; }
|
virtual bool isChar() const { return false; }
|
||||||
// is this equivalent to a letter?
|
// is this equivalent to a letter?
|
||||||
|
@ -337,13 +337,6 @@ void InsetCollapsable::getCursorPos(int & x, int & y) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::setFont(BufferView * bv, LyXFont const & font,
|
|
||||||
bool toggleall, bool selectall)
|
|
||||||
{
|
|
||||||
inset.setFont(bv, font, toggleall, selectall);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetCollapsable::getLabelList(Buffer const & buffer,
|
void InsetCollapsable::getLabelList(Buffer const & buffer,
|
||||||
std::vector<string> & list) const
|
std::vector<string> & list) const
|
||||||
{
|
{
|
||||||
|
@ -79,9 +79,6 @@ public:
|
|||||||
/// get the screen x,y of the cursor
|
/// get the screen x,y of the cursor
|
||||||
void getCursorPos(int & x, int & y) const;
|
void getCursorPos(int & x, int & y) const;
|
||||||
///
|
///
|
||||||
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
|
|
||||||
bool selectall = false);
|
|
||||||
///
|
|
||||||
void setLabel(std::string const & l) const;
|
void setLabel(std::string const & l) const;
|
||||||
///
|
///
|
||||||
void setLabelFont(LyXFont & f);
|
void setLabelFont(LyXFont & f);
|
||||||
|
@ -224,19 +224,6 @@ bool InsetERT::insertInset(BufferView *, InsetOld *)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall)
|
|
||||||
{
|
|
||||||
#ifdef WITH_WARNINGS
|
|
||||||
#warning FIXME. More UI stupidity...
|
|
||||||
#endif
|
|
||||||
// if selectall is activated then the fontchange was an outside general
|
|
||||||
// fontchange and this messages is not needed
|
|
||||||
if (!selectall)
|
|
||||||
Alert::error(_("Cannot change font"),
|
|
||||||
_("You cannot change font settings inside TeX code."));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetERT::updateStatus(bool swap) const
|
void InsetERT::updateStatus(bool swap) const
|
||||||
{
|
{
|
||||||
if (status_ != Inlined) {
|
if (status_ != Inlined) {
|
||||||
|
@ -61,9 +61,6 @@ public:
|
|||||||
return code == InsetOld::NEWLINE_CODE;
|
return code == InsetOld::NEWLINE_CODE;
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
void setFont(BufferView *, LyXFont const &,
|
|
||||||
bool toggleall = false, bool selectall = false);
|
|
||||||
///
|
|
||||||
EDITABLE editable() const;
|
EDITABLE editable() const;
|
||||||
///
|
///
|
||||||
int latex(Buffer const &, std::ostream &,
|
int latex(Buffer const &, std::ostream &,
|
||||||
|
@ -1212,38 +1212,6 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetTabular::setFont(BufferView * bv, LyXFont const & font, bool tall,
|
|
||||||
bool selectall)
|
|
||||||
{
|
|
||||||
if (selectall) {
|
|
||||||
setSelection(0, tabular.getNumberOfCells() - 1);
|
|
||||||
}
|
|
||||||
if (hasSelection()) {
|
|
||||||
recordUndo(bv, Undo::ATOMIC);
|
|
||||||
bool const frozen = undo_frozen;
|
|
||||||
if (!frozen)
|
|
||||||
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)
|
|
||||||
unFreezeUndo();
|
|
||||||
if (selectall)
|
|
||||||
clearSelection();
|
|
||||||
updateLocal(bv);
|
|
||||||
}
|
|
||||||
if (the_locking_inset)
|
|
||||||
the_locking_inset->setFont(bv, font, tall);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
|
bool InsetTabular::tabularFeatures(BufferView * bv, string const & what)
|
||||||
{
|
{
|
||||||
LyXTabular::Feature action = LyXTabular::LAST_ACTION;
|
LyXTabular::Feature action = LyXTabular::LAST_ACTION;
|
||||||
|
@ -119,9 +119,6 @@ public:
|
|||||||
///
|
///
|
||||||
int getActCell() const { return actcell; }
|
int getActCell() const { return actcell; }
|
||||||
///
|
///
|
||||||
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
|
|
||||||
bool selectall = false);
|
|
||||||
///
|
|
||||||
void openLayoutDialog(BufferView *) const;
|
void openLayoutDialog(BufferView *) const;
|
||||||
///
|
///
|
||||||
bool showInsetDialog(BufferView *) const;
|
bool showInsetDialog(BufferView *) const;
|
||||||
|
@ -305,7 +305,7 @@ void InsetText::sanitizeEmptyText(BufferView * bv)
|
|||||||
&& bv->getParentLanguage(this) != text_.current_font.language()) {
|
&& bv->getParentLanguage(this) != text_.current_font.language()) {
|
||||||
LyXFont font(LyXFont::ALL_IGNORE);
|
LyXFont font(LyXFont::ALL_IGNORE);
|
||||||
font.setLanguage(bv->getParentLanguage(this));
|
font.setLanguage(bv->getParentLanguage(this));
|
||||||
setFont(bv, font, false);
|
text_.setFont(font, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ DispatchResult InsetText::priv_dispatch(FuncRequest const & cmd,
|
|||||||
paragraphs.size() == 1) {
|
paragraphs.size() == 1) {
|
||||||
LyXFont font(LyXFont::ALL_IGNORE);
|
LyXFont font(LyXFont::ALL_IGNORE);
|
||||||
font.setLanguage(bv->getParentLanguage(this));
|
font.setLanguage(bv->getParentLanguage(this));
|
||||||
setFont(bv, font, false);
|
text_.setFont(font, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
lyxerr << "InsetText::priv_dispatch (end)" << endl;
|
lyxerr << "InsetText::priv_dispatch (end)" << endl;
|
||||||
@ -489,34 +489,6 @@ void InsetText::getLabelList(Buffer const & buffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
|
||||||
bool selectall)
|
|
||||||
{
|
|
||||||
if ((paragraphs.size() == 1 && paragraphs.begin()->empty())
|
|
||||||
|| cpar()->empty()) {
|
|
||||||
text_.setFont(font, toggleall);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text_.selection.set())
|
|
||||||
text_.recUndo(text_.cursor.par());
|
|
||||||
|
|
||||||
if (selectall) {
|
|
||||||
text_.cursorTop();
|
|
||||||
text_.selection.cursor = text_.cursor;
|
|
||||||
text_.cursorBottom();
|
|
||||||
text_.setSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
text_.toggleFree(font, toggleall);
|
|
||||||
|
|
||||||
if (selectall)
|
|
||||||
text_.clearSelection();
|
|
||||||
|
|
||||||
updateLocal(bv, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetText::markNew(bool track_changes)
|
void InsetText::markNew(bool track_changes)
|
||||||
{
|
{
|
||||||
ParagraphList::iterator pit = paragraphs.begin();
|
ParagraphList::iterator pit = paragraphs.begin();
|
||||||
|
@ -1281,7 +1281,7 @@ void LyXText::Delete()
|
|||||||
LyXCursor old_cursor = cursor;
|
LyXCursor old_cursor = cursor;
|
||||||
|
|
||||||
// just move to the right
|
// just move to the right
|
||||||
cursorRight(bv());
|
cursorRight(true);
|
||||||
|
|
||||||
// if you had success make a backspace
|
// if you had success make a backspace
|
||||||
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
|
if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) {
|
||||||
|
104
src/text2.C
104
src/text2.C
@ -43,6 +43,7 @@
|
|||||||
#include "paragraph.h"
|
#include "paragraph.h"
|
||||||
#include "paragraph_funcs.h"
|
#include "paragraph_funcs.h"
|
||||||
#include "ParagraphParameters.h"
|
#include "ParagraphParameters.h"
|
||||||
|
#include "PosIterator.h"
|
||||||
#include "undo.h"
|
#include "undo.h"
|
||||||
#include "vspace.h"
|
#include "vspace.h"
|
||||||
|
|
||||||
@ -178,27 +179,6 @@ LyXFont LyXText::getLabelFont(ParagraphList::iterator pit) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCharFont(ParagraphList::iterator pit,
|
|
||||||
pos_type pos, LyXFont const & fnt,
|
|
||||||
bool toggleall)
|
|
||||||
{
|
|
||||||
BufferParams const & params = bv()->buffer()->params();
|
|
||||||
LyXFont font = getFont(pit, pos);
|
|
||||||
font.update(fnt, params.language, toggleall);
|
|
||||||
// Let the insets convert their font
|
|
||||||
if (pit->isInset(pos)) {
|
|
||||||
InsetOld * inset = pit->getInset(pos);
|
|
||||||
if (isEditableInset(inset)) {
|
|
||||||
static_cast<UpdatableInset *>(inset)
|
|
||||||
->setFont(bv(), fnt, toggleall, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plug through to version below:
|
|
||||||
setCharFont(pit, pos, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LyXText::setCharFont(
|
void LyXText::setCharFont(
|
||||||
ParagraphList::iterator pit, pos_type pos, LyXFont const & fnt)
|
ParagraphList::iterator pit, pos_type pos, LyXFont const & fnt)
|
||||||
{
|
{
|
||||||
@ -349,14 +329,7 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
|
|||||||
// set layout over selection and make a total rebreak of those paragraphs
|
// set layout over selection and make a total rebreak of those paragraphs
|
||||||
void LyXText::setLayout(string const & layout)
|
void LyXText::setLayout(string const & layout)
|
||||||
{
|
{
|
||||||
LyXCursor tmpcursor = cursor; // store the current cursor
|
setSelection();
|
||||||
|
|
||||||
// if there is no selection just set the layout
|
|
||||||
// of the current paragraph
|
|
||||||
if (!selection.set()) {
|
|
||||||
selection.start = cursor; // dummy selection
|
|
||||||
selection.end = cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// special handling of new environment insets
|
// special handling of new environment insets
|
||||||
BufferParams const & params = bv()->buffer()->params();
|
BufferParams const & params = bv()->buffer()->params();
|
||||||
@ -371,8 +344,7 @@ void LyXText::setLayout(string const & layout)
|
|||||||
if (bv()->insertInset(inset)) {
|
if (bv()->insertInset(inset)) {
|
||||||
//inset->edit(bv());
|
//inset->edit(bv());
|
||||||
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
//bv()->owner()->dispatch(FuncRequest(LFUN_PASTE));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
delete inset;
|
delete inset;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -380,16 +352,8 @@ void LyXText::setLayout(string const & layout)
|
|||||||
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
ParagraphList::iterator endpit = setLayout(cursor, selection.start,
|
||||||
selection.end, layout);
|
selection.end, layout);
|
||||||
redoParagraphs(getPar(selection.start), endpit);
|
redoParagraphs(getPar(selection.start), endpit);
|
||||||
|
|
||||||
// we have to reset the selection, because the
|
|
||||||
// geometry could have changed
|
|
||||||
setCursor(selection.start.par(), selection.start.pos(), false);
|
|
||||||
selection.cursor = cursor;
|
|
||||||
setCursor(selection.end.par(), selection.end.pos(), false);
|
|
||||||
updateCounters();
|
updateCounters();
|
||||||
clearSelection();
|
redoCursor();
|
||||||
setSelection();
|
|
||||||
setCursor(tmpcursor.par(), tmpcursor.pos(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -499,39 +463,28 @@ void LyXText::setFont(LyXFont const & font, bool toggleall)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LyXCursor tmpcursor = cursor; // store the current cursor
|
// ok we have a selection.
|
||||||
|
|
||||||
// ok we have a selection. This is always between sel_start_cursor
|
|
||||||
// and sel_end cursor
|
|
||||||
|
|
||||||
recUndo(selection.start.par(), selection.end.par());
|
recUndo(selection.start.par(), selection.end.par());
|
||||||
freezeUndo();
|
freezeUndo();
|
||||||
cursor = selection.start;
|
|
||||||
while (cursor.par() != selection.end.par() ||
|
ParagraphList::iterator beg = getPar(selection.start.par());
|
||||||
cursor.pos() < selection.end.pos())
|
ParagraphList::iterator end = getPar(selection.end.par());
|
||||||
{
|
|
||||||
if (cursor.pos() < cursorPar()->size()) {
|
PosIterator pos(&ownerParagraphs(), beg, selection.start.pos());
|
||||||
// an open footnote should behave like a closed one
|
PosIterator posend(&ownerParagraphs(), end, selection.end.pos());
|
||||||
setCharFont(cursorPar(), cursor.pos(), font, toggleall);
|
|
||||||
cursor.pos(cursor.pos() + 1);
|
BufferParams const & params = bv()->buffer()->params();
|
||||||
} else {
|
|
||||||
cursor.pos(0);
|
for (; pos != posend; ++pos) {
|
||||||
cursor.par(cursor.par() + 1);
|
LyXFont f = getFont(pos.pit(), pos.pos());
|
||||||
}
|
f.update(font, params.language, toggleall);
|
||||||
|
setCharFont(pos.pit(), pos.pos(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
unFreezeUndo();
|
unFreezeUndo();
|
||||||
|
|
||||||
redoParagraph(getPar(selection.start));
|
redoParagraphs(beg, ++end);
|
||||||
|
redoCursor();
|
||||||
// we have to reset the selection, because the
|
|
||||||
// geometry could have changed, but we keep
|
|
||||||
// it for user convenience
|
|
||||||
setCursor(selection.start.par(), selection.start.pos());
|
|
||||||
selection.cursor = cursor;
|
|
||||||
setCursor(selection.end.par(), selection.end.pos());
|
|
||||||
setSelection();
|
|
||||||
setCursor(tmpcursor.par(), tmpcursor.pos(), true,
|
|
||||||
tmpcursor.boundary());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -665,12 +618,7 @@ void LyXText::setParagraph(VSpace const & space_top,
|
|||||||
string const & labelwidthstring,
|
string const & labelwidthstring,
|
||||||
bool noindent)
|
bool noindent)
|
||||||
{
|
{
|
||||||
LyXCursor tmpcursor = cursor;
|
setSelection();
|
||||||
if (!selection.set()) {
|
|
||||||
selection.start = cursor;
|
|
||||||
selection.end = cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure that the depth behind the selection are restored, too
|
// make sure that the depth behind the selection are restored, too
|
||||||
ParagraphList::iterator endpit = boost::next(getPar(selection.end));
|
ParagraphList::iterator endpit = boost::next(getPar(selection.end));
|
||||||
ParagraphList::iterator undoendpit = endpit;
|
ParagraphList::iterator undoendpit = endpit;
|
||||||
@ -716,13 +664,7 @@ void LyXText::setParagraph(VSpace const & space_top,
|
|||||||
}
|
}
|
||||||
|
|
||||||
redoParagraphs(getPar(selection.start), endpit);
|
redoParagraphs(getPar(selection.start), endpit);
|
||||||
|
redoCursor();
|
||||||
clearSelection();
|
|
||||||
setCursor(selection.start.par(), selection.start.pos());
|
|
||||||
selection.cursor = cursor;
|
|
||||||
setCursor(selection.end.par(), selection.end.pos());
|
|
||||||
setSelection();
|
|
||||||
setCursor(tmpcursor.par(), tmpcursor.pos());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user