Alfredo's deconstification

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6525 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-03-18 13:05:08 +00:00
parent a9a4ba97b6
commit 73a37f0b2d
5 changed files with 101 additions and 96 deletions

View File

@ -1,3 +1,10 @@
2003-03-18 Alfredo Braunstein <abraunst@libero.it>
* lyxtext.h: remove almost all mutable keywords
* text.C:
* text2.C:
* text3.C: remove const keywords accordingly
2003-03-17 Lars Gullik Bjønnes <larsbj@gullik.net>
* paragraph_funcs.C (TeXDeeper): reduce number of args, move into

View File

@ -76,22 +76,20 @@ public:
void init(BufferView *, bool reinit = false);
///
mutable int height;
int height;
///
mutable unsigned int width;
unsigned int width;
/// the current font settings
mutable LyXFont current_font;
LyXFont current_font;
/// the current font
mutable LyXFont real_current_font;
LyXFont real_current_font;
private:
/** the first visible row on screen
* declared mutable because removeRow is const
*/
mutable Row * top_row_;
Row * top_row_;
/** the pixel offset with respect to this row of top_y
* declared mutable because removeRow is const
*/
mutable int top_row_offset_;
int top_row_offset_;
public:
/// get the y coord. of the top of the screen (relative to doc start)
int top_y() const;
@ -158,9 +156,9 @@ public:
This function is needed after SetLayout and SetFont etc.
*/
void redoParagraphs(LyXCursor const & cursor,
Paragraph const * end_par) const;
Paragraph const * end_par);
///
void redoParagraph() const;
void redoParagraph();
///
void toggleFree(LyXFont const &, bool toggleall = false);
@ -185,7 +183,7 @@ public:
void fullRebreak();
///
mutable Row * need_break_row;
Row * need_break_row;
/// clear any pending paints
void clearPaint();
@ -232,7 +230,7 @@ private:
* This must be set if the pending update is NEED_LITTLE_REFRESH.
* It doesn't make any difference for NEED_MORE_REFRESH.
*/
mutable Row * refresh_row;
Row * refresh_row;
/// refresh status
text_status status_;
@ -261,7 +259,7 @@ public:
IMO it's stupid to have to allocate a dummy y all the time I need
the first row
*/
Row * firstRow() { return firstrow; }
Row * firstRow() const { return firstrow; }
/** The cursor.
Later this variable has to be removed. There should be now internal
@ -272,7 +270,7 @@ public:
Since the LyXText now has been moved from Buffer to BufferView
it should not be absolutely needed to move the cursor...
*/
mutable LyXCursor cursor; // actual cursor position
LyXCursor cursor; // actual cursor position
/** The structure that keeps track of the selections set. */
struct Selection {
@ -300,27 +298,27 @@ public:
bool mark_; // former mark_set
};
mutable Selection selection;
Selection selection;
// this is used to handle XSelection events in the right manner
mutable Selection xsel_cache;
Selection xsel_cache;
/// needed for the toggling (cursor position on last selection made)
mutable LyXCursor last_sel_cursor;
LyXCursor last_sel_cursor;
/// needed for toggling the selection in screen.C
mutable LyXCursor toggle_cursor;
LyXCursor toggle_cursor;
/// needed for toggling the selection in screen.C
mutable LyXCursor toggle_end_cursor;
LyXCursor toggle_end_cursor;
/// need the selection cursor:
void setSelection();
///
void clearSelection() const;
void clearSelection();
///
string const selectionAsString(Buffer const *, bool label) const;
/// select the word we need depending on word_location
void getWord(LyXCursor & from, LyXCursor & to,
word_location const) const;
word_location const);
/// just selects the word the cursor is in
void selectWord(word_location const);
/// returns the inset at cursor (if it exists), 0 otherwise
@ -337,25 +335,25 @@ public:
to the beginning of this word.
With SelectSelectedWord can this be highlighted really
*/
WordLangTuple const selectNextWordToSpellcheck(float & value) const;
WordLangTuple const selectNextWordToSpellcheck(float & value);
///
void selectSelectedWord();
/// returns true if par was empty and was removed
bool setCursor(Paragraph * par,
lyx::pos_type pos,
bool setfont = true,
bool boundary = false) const;
bool boundary = false);
///
void setCursor(LyXCursor &, Paragraph * par,
lyx::pos_type pos,
bool boundary = false) const;
bool boundary = false);
///
void setCursorIntern(Paragraph * par,
lyx::pos_type pos,
bool setfont = true,
bool boundary = false) const;
bool boundary = false);
///
void setCurrentFont() const;
void setCurrentFont();
///
bool isBoundary(Buffer const *, Paragraph * par,
@ -366,40 +364,40 @@ public:
LyXFont const & font) const;
///
void setCursorFromCoordinates(int x, int y) const;
void setCursorFromCoordinates(int x, int y);
///
void setCursorFromCoordinates(LyXCursor &,
int x, int y) const;
int x, int y);
///
void cursorUp(bool selecting = false) const;
void cursorUp(bool selecting = false);
///
void cursorDown(bool selecting = false) const;
void cursorDown(bool selecting = false);
///
void cursorLeft(bool internal = true) const;
void cursorLeft(bool internal = true);
///
void cursorRight(bool internal = true) const;
void cursorRight(bool internal = true);
///
void cursorLeftOneWord() const;
void cursorLeftOneWord();
///
void cursorRightOneWord() const;
void cursorRightOneWord();
///
void cursorUpParagraph() const;
void cursorUpParagraph();
///
void cursorDownParagraph() const;
void cursorDownParagraph();
///
void cursorHome() const;
void cursorHome();
///
void cursorEnd() const;
void cursorEnd();
///
void cursorPrevious();
///
void cursorNext();
///
void cursorTab() const;
void cursorTab();
///
void cursorTop() const;
void cursorTop();
///
void cursorBottom() const;
void cursorBottom();
///
void Delete();
///
@ -468,7 +466,7 @@ public:
/// Find next inset of some specified type.
bool gotoNextInset(std::vector<Inset::Code> const & codes,
string const & contents = string()) const;
string const & contents = string());
///
void gotoInset(std::vector<Inset::Code> const & codes,
bool same_content);
@ -522,12 +520,12 @@ public:
}
private:
///
mutable Row * firstrow;
Row * firstrow;
///
mutable Row * lastrow;
Row * lastrow;
///
void cursorLeftOneWord(LyXCursor &) const;
void cursorLeftOneWord(LyXCursor &);
///
float getCursorX(Row *, lyx::pos_type pos,
@ -548,44 +546,44 @@ private:
/** inserts a new row behind the specified row, increments
the touched counters */
void insertRow(Row * row, Paragraph * par, lyx::pos_type pos) const;
void insertRow(Row * row, Paragraph * par, lyx::pos_type pos);
/// removes the row and reset the touched counters
void removeRow(Row * row) const;
void removeRow(Row * row);
/// remove all following rows of the paragraph of the specified row.
void removeParagraph(Row * row) const;
void removeParagraph(Row * row);
/// insert the specified paragraph behind the specified row
void insertParagraph(Paragraph * par, Row * row) const;
void insertParagraph(Paragraph * par, Row * row);
/** appends the implizit specified paragraph behind the specified row,
* start at the implizit given position */
void appendParagraph(Row * row) const;
void appendParagraph(Row * row);
///
void breakAgain(Row * row) const;
void breakAgain(Row * row);
/// Calculate and set the height of the row
void setHeightOfRow(Row * row_ptr) const;
void setHeightOfRow(Row * row_ptr);
// fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism
void fixCursorAfterDelete(LyXCursor & cur,
LyXCursor const & where) const;
LyXCursor const & where);
/// delete double space (false) or empty paragraphs (true) around old_cursor
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const;
bool deleteEmptyParagraphMechanism(LyXCursor const & old_cursor);
public:
/** Updates all counters starting BEHIND the row. Changed paragraphs
* with a dynamic left margin will be rebroken. */
void updateCounters() const;
void updateCounters();
///
void update(bool changed = true);
/**
* Returns an inset if inset was hit, or 0 if not.
* If hit, the coordinates are changed relative to the inset.
*/
Inset * checkInsetHit(int & x, int & y) const;
Inset * checkInsetHit(int & x, int & y);
///
int singleWidth(Paragraph * par,
@ -623,7 +621,7 @@ public:
private:
///
void setCounter(Buffer const *, Paragraph * par) const;
void setCounter(Buffer const *, Paragraph * par);
///
void deleteWordForward();
///

View File

@ -937,7 +937,7 @@ LColor::color LyXText::backgroundColor() const
return LColor::background;
}
void LyXText::setHeightOfRow(Row * row) const
void LyXText::setHeightOfRow(Row * row)
{
// get the maximum ascent and the maximum descent
int asc = 0;
@ -1255,7 +1255,7 @@ void LyXText::setHeightOfRow(Row * row) const
// Appends the implicit specified paragraph before the specified row,
// start at the implicit given position
void LyXText::appendParagraph(Row * row) const
void LyXText::appendParagraph(Row * row)
{
pos_type const last = row->par()->size();
bool done = false;
@ -1307,7 +1307,7 @@ void LyXText::markChangeInDraw(Row * row, Row * prev)
}
void LyXText::breakAgain(Row * row) const
void LyXText::breakAgain(Row * row)
{
bool not_ready = true;
@ -1501,7 +1501,7 @@ void LyXText::breakParagraph(ParagraphList & paragraphs, char keep_layout)
// Just a macro to make some thing easier.
void LyXText::redoParagraph() const
void LyXText::redoParagraph()
{
clearSelection();
redoParagraphs(cursor, cursor.par()->next());
@ -1895,7 +1895,7 @@ void LyXText::prepareToPrint(Row * row, float & x,
// realize, that you left an empty paragraph, they will delete it.
// They also delete the corresponding row
void LyXText::cursorRightOneWord() const
void LyXText::cursorRightOneWord()
{
// treat floats, HFills and Insets as words
LyXCursor tmpcursor = cursor;
@ -1927,7 +1927,7 @@ void LyXText::cursorRightOneWord() const
}
void LyXText::cursorTab() const
void LyXText::cursorTab()
{
LyXCursor tmpcursor = cursor;
while (tmpcursor.pos() < tmpcursor.par()->size()
@ -1947,7 +1947,7 @@ void LyXText::cursorTab() const
// Skip initial whitespace at end of word and move cursor to *start*
// of prior word, not to end of next prior word.
void LyXText::cursorLeftOneWord() const
void LyXText::cursorLeftOneWord()
{
LyXCursor tmpcursor = cursor;
cursorLeftOneWord(tmpcursor);
@ -1955,7 +1955,7 @@ void LyXText::cursorLeftOneWord() const
}
void LyXText::cursorLeftOneWord(LyXCursor & cur) const
void LyXText::cursorLeftOneWord(LyXCursor & cur)
{
// treat HFills, floats and Insets as words
cur = cursor;
@ -1987,7 +1987,7 @@ void LyXText::cursorLeftOneWord(LyXCursor & cur) const
// Select current word. This depends on behaviour of
// CursorLeftOneWord(), so it is patched as well.
void LyXText::getWord(LyXCursor & from, LyXCursor & to,
word_location const loc) const
word_location const loc)
{
// first put the cursor where we wana start to select the word
from = cursor;
@ -2107,7 +2107,7 @@ void LyXText::rejectChange()
// This function is only used by the spellchecker for NextWord().
// It doesn't handle LYX_ACCENTs and probably never will.
WordLangTuple const
LyXText::selectNextWordToSpellcheck(float & value) const
LyXText::selectNextWordToSpellcheck(float & value)
{
if (the_locking_inset) {
WordLangTuple word = the_locking_inset->selectNextWordToSpellcheck(bv(), value);

View File

@ -279,7 +279,7 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
// inserts a new row before the specified row, increments
// the touched counters
void LyXText::insertRow(Row * row, Paragraph * par,
pos_type pos) const
pos_type pos)
{
Row * tmprow = new Row;
if (!row) {
@ -308,7 +308,7 @@ void LyXText::insertRow(Row * row, Paragraph * par,
// removes the row and reset the touched counters
void LyXText::removeRow(Row * row) const
void LyXText::removeRow(Row * row)
{
Row * row_prev = row->previous();
if (row->next())
@ -348,7 +348,7 @@ void LyXText::removeRow(Row * row) const
// remove all following rows of the paragraph of the specified row.
void LyXText::removeParagraph(Row * row) const
void LyXText::removeParagraph(Row * row)
{
Paragraph * tmppar = row->par();
row = row->next();
@ -364,7 +364,7 @@ void LyXText::removeParagraph(Row * row) const
// insert the specified paragraph behind the specified row
void LyXText::insertParagraph(Paragraph * par,
Row * row) const
Row * row)
{
// insert a new row, starting at position 0
insertRow(row, par, 0);
@ -746,7 +746,7 @@ void LyXText::redoDrawingOfParagraph(LyXCursor const & cur)
// and the specified par
// This function is needed after SetLayout and SetFont etc.
void LyXText::redoParagraphs(LyXCursor const & cur,
Paragraph const * endpar) const
Paragraph const * endpar)
{
Row * tmprow2;
Paragraph * tmppar = 0;
@ -940,7 +940,7 @@ string const LyXText::selectionAsString(Buffer const * buffer,
}
void LyXText::clearSelection() const
void LyXText::clearSelection()
{
selection.set(false);
selection.mark(false);
@ -951,13 +951,13 @@ void LyXText::clearSelection() const
}
void LyXText::cursorHome() const
void LyXText::cursorHome()
{
setCursor(cursor.par(), cursor.row()->pos());
}
void LyXText::cursorEnd() const
void LyXText::cursorEnd()
{
if (!cursor.row()->next()
|| cursor.row()->next()->par() != cursor.row()->par()) {
@ -975,7 +975,7 @@ void LyXText::cursorEnd() const
}
void LyXText::cursorTop() const
void LyXText::cursorTop()
{
while (cursor.par()->previous())
cursor.par(cursor.par()->previous());
@ -983,7 +983,7 @@ void LyXText::cursorTop() const
}
void LyXText::cursorBottom() const
void LyXText::cursorBottom()
{
while (cursor.par()->next())
cursor.par(cursor.par()->next());
@ -1134,7 +1134,7 @@ void LyXText::setParagraph(bool line_top, bool line_bottom,
// set the counter of a paragraph. This includes the labels
void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
void LyXText::setCounter(Buffer const * buf, Paragraph * par)
{
LyXTextClass const & textclass = buf->params.getLyXTextClass();
LyXLayout_ptr const & layout = par->layout();
@ -1331,7 +1331,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
// Updates all counters. Paragraphs with changed label string will be rebroken
void LyXText::updateCounters() const
void LyXText::updateCounters()
{
Row * row = firstrow;
Paragraph * par = row->par();
@ -1723,7 +1723,7 @@ bool LyXText::updateInset(Inset * inset)
bool LyXText::setCursor(Paragraph * par,
pos_type pos,
bool setfont, bool boundary) const
bool setfont, bool boundary)
{
LyXCursor old_cursor = cursor;
setCursorIntern(par, pos, setfont, boundary);
@ -1732,7 +1732,7 @@ bool LyXText::setCursor(Paragraph * par,
void LyXText::setCursor(LyXCursor & cur, Paragraph * par,
pos_type pos, bool boundary) const
pos_type pos, bool boundary)
{
lyx::Assert(par);
@ -1859,7 +1859,7 @@ float LyXText::getCursorX(Row * row,
void LyXText::setCursorIntern(Paragraph * par,
pos_type pos, bool setfont, bool boundary) const
pos_type pos, bool setfont, bool boundary)
{
InsetText * it = static_cast<InsetText *>(par->inInset());
if (it) {
@ -1893,7 +1893,7 @@ void LyXText::setCursorIntern(Paragraph * par,
}
void LyXText::setCurrentFont() const
void LyXText::setCurrentFont()
{
pos_type pos = cursor.pos();
if (cursor.boundary() && pos > 0)
@ -2042,7 +2042,7 @@ LyXText::getColumnNearX(Row * row, int & x,
}
void LyXText::setCursorFromCoordinates(int x, int y) const
void LyXText::setCursorFromCoordinates(int x, int y)
{
LyXCursor old_cursor = cursor;
@ -2077,7 +2077,7 @@ namespace {
void LyXText::setCursorFromCoordinates(LyXCursor & cur,
int x, int y) const
int x, int y)
{
// Get the row first.
@ -2105,7 +2105,7 @@ void LyXText::setCursorFromCoordinates(LyXCursor & cur,
}
void LyXText::cursorLeft(bool internal) const
void LyXText::cursorLeft(bool internal)
{
if (cursor.pos() > 0) {
bool boundary = cursor.boundary();
@ -2120,7 +2120,7 @@ void LyXText::cursorLeft(bool internal) const
}
void LyXText::cursorRight(bool internal) const
void LyXText::cursorRight(bool internal)
{
if (!internal && cursor.boundary() &&
!cursor.par()->isNewline(cursor.pos()))
@ -2135,7 +2135,7 @@ void LyXText::cursorRight(bool internal) const
}
void LyXText::cursorUp(bool selecting) const
void LyXText::cursorUp(bool selecting)
{
#if 1
int x = cursor.x_fix();
@ -2158,7 +2158,7 @@ void LyXText::cursorUp(bool selecting) const
}
void LyXText::cursorDown(bool selecting) const
void LyXText::cursorDown(bool selecting)
{
#if 1
int x = cursor.x_fix();
@ -2183,7 +2183,7 @@ void LyXText::cursorDown(bool selecting) const
}
void LyXText::cursorUpParagraph() const
void LyXText::cursorUpParagraph()
{
if (cursor.pos() > 0) {
setCursor(cursor.par(), 0);
@ -2194,7 +2194,7 @@ void LyXText::cursorUpParagraph() const
}
void LyXText::cursorDownParagraph() const
void LyXText::cursorDownParagraph()
{
if (cursor.par()->next()) {
setCursor(cursor.par()->next(), 0);
@ -2206,7 +2206,7 @@ void LyXText::cursorDownParagraph() const
// fix the cursor `cur' after a characters has been deleted at `where'
// position. Called by deleteEmptyParagraphMechanism
void LyXText::fixCursorAfterDelete(LyXCursor & cur,
LyXCursor const & where) const
LyXCursor const & where)
{
// if cursor is not in the paragraph where the delete occured,
// do nothing
@ -2228,7 +2228,7 @@ void LyXText::fixCursorAfterDelete(LyXCursor & cur,
}
bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const
bool LyXText::deleteEmptyParagraphMechanism(LyXCursor const & old_cursor)
{
// Would be wrong to delete anything if we have a selection.
if (selection.set())

View File

@ -93,7 +93,7 @@ namespace {
// check if the given co-ordinates are inside an inset at the
// given cursor, if one exists. If so, the inset is returned,
// and the co-ordinates are made relative. Otherwise, 0 is returned.
Inset * checkInset(BufferView * bv, LyXText const & text,
Inset * checkInset(BufferView * bv, LyXText & text,
LyXCursor const & cur, int & x, int & y)
{
lyx::pos_type const pos = cur.pos();
@ -142,7 +142,7 @@ namespace {
} // anon namespace
Inset * LyXText::checkInsetHit(int & x, int & y) const
Inset * LyXText::checkInsetHit(int & x, int & y)
{
int y_tmp = y + top_y();
@ -170,7 +170,7 @@ Inset * LyXText::checkInsetHit(int & x, int & y) const
bool LyXText::gotoNextInset(vector<Inset::Code> const & codes,
string const & contents) const
string const & contents)
{
LyXCursor res = cursor;
Inset * inset;