mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
fix double space editing, small change to make Path more foolproof, dont use reserve in paragraph add some resize instead, fix a bug in LyXLeX::next that were only present on conforming std::istream.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@421 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8f41c87a46
commit
ed22adefc6
43
ChangeLog
43
ChangeLog
@ -13,6 +13,49 @@
|
||||
where a "struct utimbuf" is allocated with "new" and deleted with
|
||||
"delete[]".
|
||||
|
||||
2000-01-13 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/text2.C (CutSelection): don't delete double spaces.
|
||||
(PasteSelection): ditto
|
||||
(CopySelection): ditto
|
||||
|
||||
* src/text.C (Backspace): don't delete double spaces.
|
||||
|
||||
* src/lyxlex.C (next): fix a bug that were only present with
|
||||
conformant std::istream::get to read comment lines, use
|
||||
std::istream::getline instead. This seems to fix the problem.
|
||||
|
||||
2000-01-12 Lars Gullik Bjønnes <larsbj@lyx.org>
|
||||
|
||||
* src/text2.C (DeleteEmptyParagraphMechanism): fix for the "not
|
||||
allowed to insert space before space" editing problem. Please read
|
||||
commends at the beginning of the function. Comments about usage
|
||||
are very welcome.
|
||||
|
||||
* src/text.C (InsertChar): fix for the "not allowed to insert
|
||||
space before space" editing problem.
|
||||
|
||||
* src/text2.C (DeleteEmptyParagraphMechanism): when
|
||||
IsEmptyTableRow can only return false this last "else if" will
|
||||
always be a no-op. Commented out.
|
||||
|
||||
* src/text.C (RedoParagraph): As far as I can understand tmp
|
||||
cursor is not really needed.
|
||||
|
||||
* src/lyxtext.[Ch] (IsEmptyTableCell): commented out. As used at
|
||||
present it could only return false anyway.
|
||||
(several functions): Did something not so smart...added a const
|
||||
specifier on a lot of methods.
|
||||
|
||||
* src/paragraph.C (BreakParagraph): removed the tmp->text.reserve
|
||||
and add a tmp->text.resize. The LyXParagraph constructor does the
|
||||
resize for us.
|
||||
(BreakParagraphConservative): ditto
|
||||
|
||||
* src/support/path.h (Path): add a define so that the wrong usage
|
||||
"Path("/tmp") will be flagged as a compilation error:
|
||||
"`unnamed_Path' undeclared (first use this function)"
|
||||
|
||||
2000-01-12 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
|
||||
|
||||
* config/lyxinclude.m4 (LYX_FUNC_PUTENV_ARGTYPE): fix the macro,
|
||||
|
@ -36,7 +36,6 @@
|
||||
(May 19 1996, 12:04, RvdK)
|
||||
*/
|
||||
|
||||
|
||||
// These are globals.
|
||||
LyXAction lyxaction;
|
||||
|
||||
|
@ -33,8 +33,7 @@ FD_form_bullet *create_form_form_bullet(void)
|
||||
fl_set_bmtable_file(obj, 6, 6,
|
||||
LibFileSearch("images",
|
||||
"standard.xbm").c_str());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
fl_set_bmtable_pixmap_file(obj, 6, 6,
|
||||
LibFileSearch("images",
|
||||
"standard.xpm").c_str());
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "lyx_gui_misc.h" // CancelCloseBoxCB + WriteAlert
|
||||
|
||||
extern int mono_video;
|
||||
|
||||
extern BufferView * current_view;
|
||||
FD_form_bullet * fd_form_bullet;
|
||||
|
||||
@ -23,8 +24,8 @@ static int current_bullet_depth;
|
||||
void bulletForm()
|
||||
{
|
||||
if (!fd_form_bullet) {
|
||||
if (!mono_video
|
||||
&& (XpmVersion < 4
|
||||
if (!mono_video &&
|
||||
(XpmVersion < 4
|
||||
|| (XpmVersion == 4 && XpmRevision < 7))) {
|
||||
WriteAlert(_("Sorry, your libXpm is too old."),
|
||||
_("This feature requires xpm-4.7 (a.k.a 3.4g) or newer."),
|
||||
@ -224,8 +225,7 @@ void BulletPanelCB(FL_OBJECT * /*ob*/, long data)
|
||||
new_panel += ".xbm";
|
||||
fl_set_bmtable_file(fd_form_bullet->bmtable_bullet_panel, 6, 6,
|
||||
LibFileSearch("images", new_panel.c_str()).c_str());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
new_panel += ".xpm";
|
||||
fl_set_bmtable_pixmap_file(fd_form_bullet->bmtable_bullet_panel, 6, 6,
|
||||
LibFileSearch("images", new_panel.c_str()).c_str());
|
||||
|
@ -372,7 +372,6 @@ GC GetSelectionGC()
|
||||
val.foreground= WhitePixel(fl_display,
|
||||
DefaultScreen(fl_display));
|
||||
}
|
||||
|
||||
val.function= GXcopy;
|
||||
val.graphics_exposures = false;
|
||||
if (!fast_selection && selection_color[0] != 0) {
|
||||
|
14
src/lyxlex.C
14
src/lyxlex.C
@ -261,9 +261,9 @@ bool LyXLex::next(bool esc)
|
||||
c = cc;
|
||||
if (c == '#') {
|
||||
// Read rest of line (fast :-)
|
||||
is.get(buff, sizeof(buff));
|
||||
lyxerr[Debug::LYXLEX] << "Comment read: " << c
|
||||
<< buff << endl;
|
||||
is.getline(buff, sizeof(buff));
|
||||
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
|
||||
<< buff << "'" << endl;
|
||||
++lineno;
|
||||
continue;
|
||||
}
|
||||
@ -371,9 +371,9 @@ bool LyXLex::next(bool esc)
|
||||
|
||||
if (c == '#') {
|
||||
// Read rest of line (fast :-)
|
||||
is.get(buff, sizeof(buff));
|
||||
lyxerr[Debug::LYXLEX] << "Comment read: " << c
|
||||
<< buff << endl;
|
||||
is.getline(buff, sizeof(buff));
|
||||
lyxerr[Debug::LYXLEX] << "Comment read: `" << c
|
||||
<< buff << "'" << endl;
|
||||
++lineno;
|
||||
continue;
|
||||
}
|
||||
@ -443,7 +443,7 @@ bool LyXLex::next(bool esc)
|
||||
|
||||
if (status) return true;
|
||||
|
||||
status = is.eof() ? LEX_FEOF: LEX_UNDEF;
|
||||
status = is.eof() ? LEX_FEOF : LEX_UNDEF;
|
||||
buff[0] = '\0';
|
||||
return false;
|
||||
}
|
||||
|
@ -822,10 +822,12 @@ int LyXRC::read(string const & filename)
|
||||
if (lexrc.next())
|
||||
cursor_follows_scrollbar = lexrc.GetBool();
|
||||
break;
|
||||
|
||||
case RC_FAST_SELECTION:
|
||||
if (lexrc.next())
|
||||
fast_selection = lexrc.GetBool();
|
||||
break;
|
||||
|
||||
case RC_BACKGROUND_COLOR:
|
||||
if (lexrc.next())
|
||||
background_color = lexrc.GetString();
|
||||
|
@ -24,7 +24,7 @@ struct Row {
|
||||
unsigned short baseline;
|
||||
/** what is missing to a full row can be negative.
|
||||
Needed for hfills, flushright, block etc. */
|
||||
int fill;
|
||||
mutable int fill;
|
||||
///
|
||||
unsigned short height;
|
||||
///
|
||||
|
222
src/lyxtext.h
222
src/lyxtext.h
@ -48,13 +48,13 @@ public:
|
||||
/// points to Buffer
|
||||
Buffer * params;
|
||||
///
|
||||
int number_of_rows;
|
||||
mutable int number_of_rows;
|
||||
///
|
||||
long height;
|
||||
mutable long height;
|
||||
/// the current font settings
|
||||
LyXFont current_font;
|
||||
mutable LyXFont current_font;
|
||||
/// the current font
|
||||
LyXFont real_current_font;
|
||||
mutable LyXFont real_current_font;
|
||||
|
||||
/// Constructor
|
||||
LyXText(int paperwidth, Buffer *);
|
||||
@ -64,13 +64,13 @@ public:
|
||||
|
||||
///
|
||||
LyXFont GetFont(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos);
|
||||
LyXParagraph::size_type pos) const;
|
||||
///
|
||||
void SetCharFont(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos,
|
||||
LyXFont font);
|
||||
LyXFont const & font);
|
||||
/// returns a pointer to the very first LyXParagraph
|
||||
LyXParagraph * FirstParagraph();
|
||||
LyXParagraph * FirstParagraph() const;
|
||||
|
||||
/// what you expect when pressing <enter> at cursor position
|
||||
void BreakParagraph(char keep_layout = 0);
|
||||
@ -94,36 +94,37 @@ public:
|
||||
|
||||
/** Get the depth at current cursor position
|
||||
*/
|
||||
int GetDepth() { return cursor.par->GetDepth(); }
|
||||
int GetDepth() const { return cursor.par->GetDepth(); }
|
||||
|
||||
/** set font over selection and make a total rebreak of those
|
||||
paragraphs.
|
||||
toggleall defaults to false.
|
||||
*/
|
||||
void SetFont(LyXFont font, bool toggleall = false);
|
||||
void SetFont(LyXFont const & font, bool toggleall = false);
|
||||
|
||||
/** deletes and inserts again all paragaphs between the cursor
|
||||
and the specified par .The Cursor is needed to set the refreshing
|
||||
and the specified par. The Cursor is needed to set the refreshing
|
||||
parameters.
|
||||
This function is needed after SetLayout and SetFont etc.
|
||||
*/
|
||||
void RedoParagraphs(LyXCursor cursor, LyXParagraph * end_par);
|
||||
void RedoParagraphs(LyXCursor const & cursor,
|
||||
LyXParagraph const * end_par) const;
|
||||
///
|
||||
void RedoParagraph();
|
||||
void RedoParagraph() const;
|
||||
|
||||
///
|
||||
void ToggleFree(LyXFont font, bool toggleall = false);
|
||||
void ToggleFree(LyXFont const & font, bool toggleall = false);
|
||||
|
||||
/** recalculates the heights of all previous rows of the
|
||||
specified paragraph. needed, if the last characters font
|
||||
has changed.
|
||||
*/
|
||||
void RedoHeightOfParagraph(LyXCursor cursor);
|
||||
void RedoHeightOfParagraph(LyXCursor const & cursor);
|
||||
|
||||
/** forces the redrawing of a paragraph. Needed when manipulating a
|
||||
right address box
|
||||
*/
|
||||
void RedoDrawingOfParagraph(LyXCursor cursor);
|
||||
void RedoDrawingOfParagraph(LyXCursor const & cursor);
|
||||
|
||||
/** insert a character, moves all the following breaks in the
|
||||
same Paragraph one to the right and make a little rebreak
|
||||
@ -140,7 +141,7 @@ public:
|
||||
///
|
||||
Row * need_break_row;
|
||||
///
|
||||
long refresh_y;
|
||||
mutable long refresh_y;
|
||||
///
|
||||
int refresh_height;
|
||||
///
|
||||
@ -148,34 +149,34 @@ public:
|
||||
///
|
||||
int refresh_x;
|
||||
///
|
||||
Row * refresh_row;
|
||||
mutable Row * refresh_row;
|
||||
///
|
||||
int refresh_pos;
|
||||
|
||||
/** wether the screen needs a refresh,
|
||||
starting with refresh_y
|
||||
*/
|
||||
text_status status;
|
||||
mutable text_status status;
|
||||
|
||||
/** returns a pointer to the row near the specified y-coordinate
|
||||
(relative to the whole text). y is set to the real beginning
|
||||
of this row
|
||||
*/
|
||||
Row * GetRowNearY(long & y);
|
||||
Row * GetRowNearY(long & y) const;
|
||||
|
||||
/** returns the column near the specified x-coordinate of the row
|
||||
x is set to the real beginning of this column
|
||||
*/
|
||||
int GetColumnNearX(Row * row, int & x);
|
||||
int GetColumnNearX(Row * row, int & x) const;
|
||||
|
||||
/** returns a pointer to a specified row. y is set to the beginning
|
||||
of the row
|
||||
*/
|
||||
Row * GetRow(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos, long & y);
|
||||
LyXParagraph::size_type pos, long & y) const;
|
||||
/** returns the height of a default row, needed for scrollbar
|
||||
*/
|
||||
int DefaultHeight();
|
||||
int DefaultHeight() const;
|
||||
|
||||
/** The cursor.
|
||||
Later this variable has to be removed. There should be now internal
|
||||
@ -186,20 +187,20 @@ public:
|
||||
Since the LyXText now has been moved from Buffer to BufferView
|
||||
it should not be absolutely needed to move the cursor...
|
||||
*/
|
||||
LyXCursor cursor;
|
||||
mutable LyXCursor cursor;
|
||||
|
||||
/* the selection cursor */
|
||||
///
|
||||
bool selection;
|
||||
mutable bool selection;
|
||||
///
|
||||
bool mark_set;
|
||||
mutable bool mark_set;
|
||||
|
||||
///
|
||||
LyXCursor sel_cursor;
|
||||
mutable LyXCursor sel_cursor;
|
||||
///
|
||||
LyXCursor sel_start_cursor;
|
||||
///
|
||||
LyXCursor sel_end_cursor;
|
||||
mutable LyXCursor sel_end_cursor;
|
||||
/// needed for the toggling
|
||||
LyXCursor last_sel_cursor;
|
||||
///
|
||||
@ -210,7 +211,7 @@ public:
|
||||
/// need the selection cursor:
|
||||
void SetSelection();
|
||||
///
|
||||
void ClearSelection();
|
||||
void ClearSelection() const;
|
||||
|
||||
/// just selects the word the cursor is in
|
||||
void SelectWord();
|
||||
@ -225,38 +226,38 @@ public:
|
||||
void SelectSelectedWord();
|
||||
///
|
||||
void SetCursor(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos);
|
||||
LyXParagraph::size_type pos) const;
|
||||
///
|
||||
void SetCursorIntern(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos);
|
||||
LyXParagraph::size_type pos) const;
|
||||
///
|
||||
void SetCursorFromCoordinates(int x, long y);
|
||||
void SetCursorFromCoordinates(int x, long y) const;
|
||||
///
|
||||
void CursorUp();
|
||||
void CursorUp() const;
|
||||
///
|
||||
void CursorDown();
|
||||
void CursorDown() const;
|
||||
///
|
||||
void CursorLeft();
|
||||
void CursorLeft() const;
|
||||
///
|
||||
void CursorRight();
|
||||
void CursorRight() const;
|
||||
///
|
||||
void CursorLeftOneWord();
|
||||
void CursorLeftOneWord() const;
|
||||
///
|
||||
void CursorRightOneWord();
|
||||
void CursorRightOneWord() const;
|
||||
///
|
||||
void CursorUpParagraph();
|
||||
void CursorUpParagraph() const;
|
||||
///
|
||||
void CursorDownParagraph();
|
||||
void CursorDownParagraph() const;
|
||||
///
|
||||
void CursorHome();
|
||||
void CursorHome() const;
|
||||
///
|
||||
void CursorEnd();
|
||||
void CursorEnd() const;
|
||||
///
|
||||
void CursorTab();
|
||||
void CursorTab() const;
|
||||
///
|
||||
void CursorTop();
|
||||
void CursorTop() const;
|
||||
///
|
||||
void CursorBottom();
|
||||
void CursorBottom() const;
|
||||
///
|
||||
void Delete();
|
||||
///
|
||||
@ -332,7 +333,8 @@ public:
|
||||
*/
|
||||
void SetParagraph(bool line_top, bool line_bottom,
|
||||
bool pagebreak_top, bool pagebreak_bottom,
|
||||
VSpace space_top, VSpace space_bottom,
|
||||
VSpace const & space_top,
|
||||
VSpace const & space_bottom,
|
||||
LyXAlignment align,
|
||||
string labelwidthstring,
|
||||
bool noindent);
|
||||
@ -349,7 +351,7 @@ public:
|
||||
*/
|
||||
bool IsStringInText(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos,
|
||||
char const * str);
|
||||
char const * str) const;
|
||||
/** sets the selection over the number of characters of string,
|
||||
no check!!
|
||||
*/
|
||||
@ -358,27 +360,27 @@ public:
|
||||
/** simple replacing. The font of the first selected character
|
||||
is used
|
||||
*/
|
||||
void ReplaceSelectionWithString(char const * string);
|
||||
void ReplaceSelectionWithString(char const * str);
|
||||
|
||||
/** if the string can be found: return true and set the cursor to
|
||||
the new position */
|
||||
bool SearchForward(char const * string);
|
||||
bool SearchBackward(char const * string);
|
||||
bool SearchForward(char const * str) const;
|
||||
bool SearchBackward(char const * str) const;
|
||||
|
||||
/// needed to insert the selection
|
||||
void InsertStringA(LyXParagraph::TextContainer const & text);
|
||||
/// needed to insert the selection
|
||||
void InsertStringB(LyXParagraph::TextContainer const & text);
|
||||
/// needed to insert the selection
|
||||
void InsertStringA(char const * string);
|
||||
void InsertStringA(char const * str);
|
||||
/// needed to insert the selection
|
||||
void InsertStringB(char const * string);
|
||||
void InsertStringB(char const * str);
|
||||
|
||||
/// usefull when texing from within LyX
|
||||
bool GotoNextError();
|
||||
bool GotoNextError() const;
|
||||
|
||||
/// just another feature :)
|
||||
bool GotoNextNote();
|
||||
bool GotoNextNote() const;
|
||||
|
||||
/** needed to switch between different classes this works
|
||||
for a list of paragraphs beginning with the specified par
|
||||
@ -396,19 +398,20 @@ public:
|
||||
LyXParagraph::size_type pos);
|
||||
///
|
||||
int NumberOfCell(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos);
|
||||
LyXParagraph::size_type pos) const;
|
||||
/* table stuff -- begin*/
|
||||
|
||||
/** all table features of the text-class are put together in
|
||||
this function. Possible values of feature are defined in table.h
|
||||
*/
|
||||
void TableFeatures(int feature, string val);
|
||||
void TableFeatures(int feature, string const & val) const;
|
||||
///
|
||||
void TableFeatures(int feature);
|
||||
void TableFeatures(int feature) const;
|
||||
|
||||
/** pos points at the beginning of the next cell (if there is one)
|
||||
*/
|
||||
int WidthOfCell(LyXParagraph * par, LyXParagraph::size_type & pos);
|
||||
int WidthOfCell(LyXParagraph * par,
|
||||
LyXParagraph::size_type & pos) const;
|
||||
///
|
||||
void CheckParagraphInTable(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos);
|
||||
@ -417,18 +420,18 @@ public:
|
||||
///
|
||||
void BackspaceInTable();
|
||||
///
|
||||
bool HitInTable(Row * row, int x);
|
||||
bool HitInTable(Row * row, int x) const;
|
||||
///
|
||||
bool MouseHitInTable(int x, long y);
|
||||
bool MouseHitInTable(int x, long y) const;
|
||||
/* table stuff -- end*/
|
||||
///
|
||||
LyXParagraph * GetParFromID(int id);
|
||||
|
||||
// undo functions
|
||||
/// returns false if no undo possible
|
||||
bool TextUndo();
|
||||
bool TextUndo();
|
||||
/// returns false if no redo possible
|
||||
bool TextRedo();
|
||||
bool TextRedo();
|
||||
/// used by TextUndo/TextRedo
|
||||
bool TextHandleUndo(Undo * undo);
|
||||
/// makes sure the next operation will be stored
|
||||
@ -438,43 +441,47 @@ public:
|
||||
/// this is dangerous and for internal use only
|
||||
void UnFreezeUndo();
|
||||
/// the flag used by FinishUndo();
|
||||
bool undo_finished;
|
||||
mutable bool undo_finished;
|
||||
/// a flag
|
||||
bool undo_frozen;
|
||||
///
|
||||
void SetUndo(Undo::undo_kind kind, LyXParagraph * before,
|
||||
LyXParagraph * end);
|
||||
void SetUndo(Undo::undo_kind kind,
|
||||
LyXParagraph const * before,
|
||||
LyXParagraph const * end) const;
|
||||
///
|
||||
void SetRedo(Undo::undo_kind kind, LyXParagraph * before,
|
||||
LyXParagraph * end);
|
||||
void SetRedo(Undo::undo_kind kind,
|
||||
LyXParagraph const * before,
|
||||
LyXParagraph const * end);
|
||||
///
|
||||
Undo * CreateUndo(Undo::undo_kind kind, LyXParagraph * before,
|
||||
LyXParagraph * end);
|
||||
Undo * CreateUndo(Undo::undo_kind kind,
|
||||
LyXParagraph const * before,
|
||||
LyXParagraph const * end) const;
|
||||
/// for external use in lyx_cb.C
|
||||
void SetCursorParUndo();
|
||||
///
|
||||
void CursorLeftIntern();
|
||||
void CursorLeftIntern() const;
|
||||
///
|
||||
void CursorRightIntern();
|
||||
void CursorRightIntern() const;
|
||||
///
|
||||
void RemoveTableRow(LyXCursor * cursor);
|
||||
void RemoveTableRow(LyXCursor * cursor) const;
|
||||
#if 0
|
||||
///
|
||||
bool IsEmptyTableRow(LyXCursor * cursor) const;
|
||||
bool IsEmptyTableRow(LyXCursor const & cursor) const;
|
||||
#endif
|
||||
///
|
||||
bool IsEmptyTableCell() const;
|
||||
///
|
||||
void toggleAppendix();
|
||||
///
|
||||
unsigned short paperWidth() const { return paperwidth; }
|
||||
|
||||
private:
|
||||
/// width of the paper
|
||||
unsigned short paperwidth;
|
||||
|
||||
///
|
||||
Row * firstrow;
|
||||
mutable Row * firstrow;
|
||||
///
|
||||
Row * lastrow;
|
||||
mutable Row * lastrow;
|
||||
|
||||
/** Copybuffer for copy environment type
|
||||
Asger has learned that this should be a buffer-property instead
|
||||
@ -483,47 +490,48 @@ private:
|
||||
char copylayouttype;
|
||||
|
||||
/// the currentrow is needed to access rows faster*/
|
||||
Row * currentrow; /* pointer to the current row */
|
||||
mutable Row * currentrow; // pointer to the current row
|
||||
/// position in the text
|
||||
long currentrow_y;
|
||||
mutable long currentrow_y;
|
||||
|
||||
/** inserts a new row behind the specified row, increments
|
||||
* the touched counters */
|
||||
void InsertRow(Row * row, LyXParagraph * par,
|
||||
LyXParagraph::size_type pos );
|
||||
LyXParagraph::size_type pos) const;
|
||||
/** removes the row and reset the touched counters */
|
||||
void RemoveRow(Row * row);
|
||||
void RemoveRow(Row * row) const;
|
||||
|
||||
/** remove all following rows of the paragraph of the specified row. */
|
||||
void RemoveParagraph(Row * row);
|
||||
void RemoveParagraph(Row * row) const;
|
||||
|
||||
/** insert the specified paragraph behind the specified row */
|
||||
void InsertParagraph(LyXParagraph * par, Row * row);
|
||||
void InsertParagraph(LyXParagraph * par, Row * row) const;
|
||||
|
||||
/** appends the implizit specified paragraph behind the specified row,
|
||||
* start at the implizit given position */
|
||||
void AppendParagraph(Row * row);
|
||||
void AppendParagraph(Row * row) const;
|
||||
|
||||
///
|
||||
void BreakAgain(Row * row);
|
||||
void BreakAgain(Row * row) const;
|
||||
///
|
||||
void BreakAgainOneRow(Row * row);
|
||||
///
|
||||
void SetHeightOfRow(Row * row_ptr); /* calculate and set the height
|
||||
* of the row */
|
||||
/// Calculate and set the height of the row
|
||||
void SetHeightOfRow(Row * row_ptr) const;
|
||||
|
||||
/** this calculates the specified parameters. needed when setting
|
||||
* the cursor and when creating a visible row */
|
||||
void PrepareToPrint(Row * row, float & x, float & fill_separator,
|
||||
float & fill_hfill, float & fill_label_hfill);
|
||||
void PrepareToPrint(Row * row, float & x,
|
||||
float & fill_separator,
|
||||
float & fill_hfill,
|
||||
float & fill_label_hfill) const;
|
||||
///
|
||||
void DeleteEmptyParagraphMechanism(LyXCursor old_cursor);
|
||||
void DeleteEmptyParagraphMechanism(LyXCursor const & old_cursor) const;
|
||||
|
||||
/** Updates all counters starting BEHIND the row. Changed paragraphs
|
||||
* with a dynamic left margin will be rebroken. */
|
||||
void UpdateCounters(Row * row);
|
||||
void UpdateCounters(Row * row) const;
|
||||
///
|
||||
void SetCounter(LyXParagraph * par);
|
||||
void SetCounter(LyXParagraph * par) const;
|
||||
|
||||
/*
|
||||
* some low level functions
|
||||
@ -531,23 +539,23 @@ private:
|
||||
|
||||
///
|
||||
int SingleWidth(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos);
|
||||
LyXParagraph::size_type pos) const;
|
||||
///
|
||||
int SingleWidth(LyXParagraph * par,
|
||||
LyXParagraph::size_type pos, char c);
|
||||
LyXParagraph::size_type pos, char c) const;
|
||||
///
|
||||
void Draw(Row * row, LyXParagraph::size_type & pos,
|
||||
void Draw(Row const * row, LyXParagraph::size_type & pos,
|
||||
LyXScreen & scr,
|
||||
int offset, float & x);
|
||||
/// get the next breakpoint in a given paragraph
|
||||
LyXParagraph::size_type NextBreakPoint(Row * row,
|
||||
int width);
|
||||
LyXParagraph::size_type NextBreakPoint(Row const * row,
|
||||
int width) const;
|
||||
/// returns the minimum space a row needs on the screen in pixel
|
||||
int Fill(Row * row, int paperwidth);
|
||||
int Fill(Row const * row, int paperwidth) const;
|
||||
|
||||
/** returns the minimum space a manual label needs on the
|
||||
screen in pixel */
|
||||
int LabelFill(Row * row);
|
||||
int LabelFill(Row const * row) const;
|
||||
|
||||
///
|
||||
LyXParagraph::size_type BeginningOfMainBody(LyXParagraph * par) const;
|
||||
@ -556,36 +564,36 @@ private:
|
||||
in LaTeX the beginning of the text fits in some cases
|
||||
(for example sections) exactly the label-width.
|
||||
*/
|
||||
int LeftMargin(Row * row);
|
||||
int LeftMargin(Row const * row) const;
|
||||
///
|
||||
int RightMargin(Row * row);
|
||||
int RightMargin(Row const * row) const;
|
||||
///
|
||||
int LabelEnd (Row * row);
|
||||
int LabelEnd (Row const * row) const;
|
||||
|
||||
/** returns the number of separators in the specified row.
|
||||
The separator on the very last column doesnt count
|
||||
*/
|
||||
int NumberOfSeparators(Row * row);
|
||||
int NumberOfSeparators(Row const * row) const;
|
||||
|
||||
/** returns the number of hfills in the specified row. The
|
||||
LyX-Hfill is a LaTeX \hfill so that the hfills at the
|
||||
beginning and at the end were ignored. This is {\em MUCH}
|
||||
more usefull than not to ignore!
|
||||
*/
|
||||
int NumberOfHfills(Row * row);
|
||||
int NumberOfHfills(Row const * row) const;
|
||||
|
||||
/// like NumberOfHfills, but only those in the manual label!
|
||||
int NumberOfLabelHfills(Row * row);
|
||||
int NumberOfLabelHfills(Row const * row) const;
|
||||
|
||||
/** returns true, if a expansion is needed. Rules are given by
|
||||
LaTeX
|
||||
*/
|
||||
bool HfillExpansion(Row * row_ptr,
|
||||
LyXParagraph::size_type pos);
|
||||
bool HfillExpansion(Row const * row_ptr,
|
||||
LyXParagraph::size_type pos) const;
|
||||
/** returns the paragraph position of the last character in the
|
||||
specified row
|
||||
*/
|
||||
LyXParagraph::size_type RowLast(Row * row);
|
||||
LyXParagraph::size_type RowLast(Row const * row) const;
|
||||
///
|
||||
void charInserted();
|
||||
};
|
||||
|
112
src/paragraph.C
112
src/paragraph.C
@ -95,11 +95,13 @@ LyXParagraph::LyXParagraph(LyXParagraph * par)
|
||||
appendix = false;
|
||||
enumdepth = 0;
|
||||
itemdepth = 0;
|
||||
// double linked list begin
|
||||
next = par->next;
|
||||
if (next)
|
||||
next->previous = this;
|
||||
previous = par;
|
||||
previous->next = this;
|
||||
// end
|
||||
#ifndef NEW_FONTTABLE // OK
|
||||
fonttable = 0;
|
||||
#endif
|
||||
@ -937,13 +939,13 @@ LyXFont LyXParagraph::GetFontSettings(LyXParagraph::size_type pos) const
|
||||
else {
|
||||
// Why is it an error to ask for the font of a
|
||||
// position that does not exist? Would it be
|
||||
// enough for this to be anable on debug?
|
||||
// enough for this to be enabled on debug?
|
||||
// We want strict error checking, but it's ok to only
|
||||
// have it when debugging. (Asger)
|
||||
lyxerr << "ERROR (LyXParagraph::GetFontSettings): "
|
||||
"position does not exist. "
|
||||
<< pos << " (" << static_cast<int>(pos)
|
||||
<< ")\n";
|
||||
<< ")" << endl;
|
||||
}
|
||||
} else if (pos) {
|
||||
return GetFontSettings(pos - 1);
|
||||
@ -962,8 +964,9 @@ LyXFont LyXParagraph::GetFontSettings(LyXParagraph::size_type pos) const
|
||||
LyXFont LyXParagraph::getFont(LyXParagraph::size_type pos) const
|
||||
{
|
||||
LyXFont tmpfont;
|
||||
LyXLayout const & layout = textclasslist.Style(current_view->buffer()->params.textclass,
|
||||
GetLayout());
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(current_view->buffer()->params.textclass,
|
||||
GetLayout());
|
||||
LyXParagraph::size_type main_body = 0;
|
||||
if (layout.labeltype == LABEL_MANUAL)
|
||||
main_body = BeginningOfMainBody();
|
||||
@ -1050,6 +1053,7 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos)
|
||||
"position does not exist."
|
||||
<< pos << " (" << static_cast<int>(pos)
|
||||
<< ")\n";
|
||||
Assert(false);
|
||||
}
|
||||
return '\0';
|
||||
} else {
|
||||
@ -1094,10 +1098,11 @@ char LyXParagraph::GetChar(LyXParagraph::size_type pos) const
|
||||
return NextAfterFootnote()
|
||||
->GetChar(pos - text.size() - 1);
|
||||
else {
|
||||
lyxerr << "ERROR (LyXParagraph::GetChar): "
|
||||
lyxerr << "ERROR (LyXParagraph::GetChar const): "
|
||||
"position does not exist."
|
||||
<< pos << " (" << static_cast<int>(pos)
|
||||
<< ")\n";
|
||||
Assert(false);
|
||||
}
|
||||
return '\0';
|
||||
} else {
|
||||
@ -1133,10 +1138,10 @@ string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
|
||||
{
|
||||
Assert(lastpos>=0);
|
||||
|
||||
// the current word is defined as starting at the first character from
|
||||
// the immediate left of lastpospos which meets the definition of IsLetter(),
|
||||
// continuing to the last character to the right of this meeting
|
||||
// IsLetter.
|
||||
// the current word is defined as starting at the first character
|
||||
// from the immediate left of lastpospos which meets the definition
|
||||
// of IsLetter(), continuing to the last character to the right
|
||||
// of this meeting IsLetter.
|
||||
|
||||
string theword;
|
||||
|
||||
@ -1157,11 +1162,11 @@ string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
|
||||
// now find the beginning by looking for a nonletter
|
||||
|
||||
while ((firstpos>= 0) && IsLetter(firstpos))
|
||||
firstpos--;
|
||||
--firstpos;
|
||||
|
||||
// the above is now pointing to the preceeding non-letter
|
||||
firstpos++;
|
||||
lastpos= firstpos;
|
||||
++firstpos;
|
||||
lastpos = firstpos;
|
||||
|
||||
// so copy characters into theword until we get a nonletter
|
||||
// note that this can easily exceed lastpos, wich means
|
||||
@ -1170,7 +1175,7 @@ string LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
|
||||
|
||||
while (IsLetter(lastpos)) theword += GetChar(lastpos++);
|
||||
|
||||
return theword;
|
||||
return theword;
|
||||
|
||||
}
|
||||
|
||||
@ -1199,8 +1204,7 @@ LyXParagraph * LyXParagraph::ParFromPos(LyXParagraph::size_type pos)
|
||||
lyxerr << "ERROR (LyXParagraph::ParFromPos): "
|
||||
"position does not exist." << endl;
|
||||
return this;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1231,7 +1235,8 @@ void LyXParagraph::SetFont(LyXParagraph::size_type pos,
|
||||
// > because last is the next unused position, and you can
|
||||
// use it if you want
|
||||
if (pos > size()) {
|
||||
if (next && next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
|
||||
if (next &&
|
||||
next->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
|
||||
NextAfterFootnote()->SetFont(pos - text.size() - 1,
|
||||
font);
|
||||
} else {
|
||||
@ -1487,8 +1492,7 @@ LyXParagraph * LyXParagraph::Next()
|
||||
paragraph */
|
||||
else
|
||||
return next; // This should never happen!
|
||||
}
|
||||
else
|
||||
} else
|
||||
return next;
|
||||
}
|
||||
|
||||
@ -1504,8 +1508,7 @@ LyXParagraph * LyXParagraph::NextAfterFootnote()
|
||||
in a logical paragraph */
|
||||
else
|
||||
return next; // This should never happen!
|
||||
}
|
||||
else
|
||||
} else
|
||||
return next;
|
||||
}
|
||||
|
||||
@ -1521,8 +1524,7 @@ LyXParagraph const * LyXParagraph::NextAfterFootnote() const
|
||||
in a logical paragraph */
|
||||
else
|
||||
return next; // This should never happen!
|
||||
}
|
||||
else
|
||||
} else
|
||||
return next;
|
||||
}
|
||||
|
||||
@ -1539,8 +1541,7 @@ LyXParagraph * LyXParagraph::PreviousBeforeFootnote()
|
||||
in a logical paragraph */
|
||||
else
|
||||
return previous; // This should never happen!
|
||||
}
|
||||
else
|
||||
} else
|
||||
return previous;
|
||||
}
|
||||
|
||||
@ -1566,13 +1567,15 @@ LyXParagraph * LyXParagraph::FirstPhysicalPar()
|
||||
return this;
|
||||
LyXParagraph * tmppar = this;
|
||||
|
||||
while (tmppar && (tmppar->IsDummy()
|
||||
|| tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
|
||||
while (tmppar &&
|
||||
(tmppar->IsDummy()
|
||||
|| tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
|
||||
tmppar = tmppar->previous;
|
||||
|
||||
if (!tmppar)
|
||||
if (!tmppar) {
|
||||
Assert(false); // let's get an abort then
|
||||
return this; // This should never happen!
|
||||
else
|
||||
} else
|
||||
return tmppar;
|
||||
}
|
||||
|
||||
@ -1587,9 +1590,10 @@ LyXParagraph const * LyXParagraph::FirstPhysicalPar() const
|
||||
|| tmppar->footnoteflag != LyXParagraph::NO_FOOTNOTE))
|
||||
tmppar = tmppar->previous;
|
||||
|
||||
if (!tmppar)
|
||||
if (!tmppar) {
|
||||
Assert(false); // let's get an abort then
|
||||
return this; // This should never happen!
|
||||
else
|
||||
} else
|
||||
return tmppar;
|
||||
}
|
||||
|
||||
@ -1612,8 +1616,7 @@ LyXParagraph * LyXParagraph::Previous()
|
||||
|
||||
else
|
||||
return previous;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return previous;
|
||||
}
|
||||
|
||||
@ -1636,8 +1639,7 @@ LyXParagraph const * LyXParagraph::Previous() const
|
||||
|
||||
else
|
||||
return previous;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return previous;
|
||||
}
|
||||
|
||||
@ -1651,12 +1653,12 @@ void LyXParagraph::BreakParagraph(LyXParagraph::size_type pos,
|
||||
LyXParagraph * firstpar = FirstPhysicalPar();
|
||||
|
||||
LyXParagraph * tmp = new LyXParagraph(par);
|
||||
|
||||
|
||||
tmp->footnoteflag = footnoteflag;
|
||||
tmp->footnotekind = footnotekind;
|
||||
|
||||
// this is an idea for a more userfriendly layout handling, I will
|
||||
// see what the users say */
|
||||
// see what the users say
|
||||
|
||||
// layout stays the same with latex-environments
|
||||
if (flag) {
|
||||
@ -1686,14 +1688,15 @@ void LyXParagraph::BreakParagraph(LyXParagraph::size_type pos,
|
||||
pos_first++;
|
||||
|
||||
pos_end = pos_first + par->text.size() - 1;
|
||||
if (pos_end > pos)
|
||||
tmp->text.reserve(pos_end - pos);
|
||||
// The constructor has already reserved 500 elements
|
||||
//if (pos_end > pos)
|
||||
// tmp->text.reserve(pos_end - pos);
|
||||
|
||||
for (i = pos; i <= pos_end; i++) {
|
||||
par->CutIntoMinibuffer(i - pos_first);
|
||||
tmp->InsertFromMinibuffer(i - pos);
|
||||
}
|
||||
|
||||
tmp->text.resize(tmp->text.size());
|
||||
for (i = pos_end; i >= pos; i--)
|
||||
par->Erase(i - pos_first);
|
||||
|
||||
@ -1833,36 +1836,38 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par)
|
||||
|
||||
void LyXParagraph::BreakParagraphConservative(LyXParagraph::size_type pos)
|
||||
{
|
||||
size_type i, pos_end, pos_first;
|
||||
|
||||
// create a new paragraph
|
||||
LyXParagraph * par = ParFromPos(pos);
|
||||
|
||||
LyXParagraph * tmp = new LyXParagraph(par);
|
||||
|
||||
tmp->MakeSameLayout(par);
|
||||
|
||||
|
||||
// When can pos < Last()?
|
||||
// I guess pos == Last() is possible.
|
||||
if (Last() > pos) {
|
||||
// copy everything behind the break-position to the new
|
||||
// paragraph
|
||||
pos_first = 0;
|
||||
size_type pos_first = 0;
|
||||
while (ParFromPos(pos_first) != par)
|
||||
pos_first++;
|
||||
pos_end = pos_first + par->text.size() - 1;
|
||||
// make shure there is enough memory for the now larger
|
||||
++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!!)
|
||||
if (pos_end > pos)
|
||||
tmp->text.reserve(pos_end - pos);
|
||||
// Not needed since the constructor aleady have
|
||||
// reserved 500 elements in text.
|
||||
//if (pos_end > pos)
|
||||
// tmp->text.reserve(pos_end - pos);
|
||||
|
||||
for (i = pos; i <= pos_end; i++) {
|
||||
|
||||
for (size_type i = pos; i <= pos_end; ++i) {
|
||||
par->CutIntoMinibuffer(i - pos_first);
|
||||
tmp->InsertFromMinibuffer(i - pos);
|
||||
}
|
||||
for (i = pos_end; i >= pos; i--)
|
||||
tmp->text.resize(tmp->text.size());
|
||||
for (size_type i = pos_end; i >= pos; --i)
|
||||
par->Erase(i - pos_first);
|
||||
|
||||
par->text.resize(par->text.size());
|
||||
@ -2271,8 +2276,9 @@ LyXParagraph * LyXParagraph::TeXOnePar(string & file, TexRow & texrow,
|
||||
{
|
||||
lyxerr[Debug::LATEX] << "TeXOnePar... " << this << endl;
|
||||
LyXParagraph * par = next;
|
||||
LyXLayout const & style = textclasslist.Style(current_view->buffer()->params.textclass,
|
||||
layout);
|
||||
LyXLayout const & style =
|
||||
textclasslist.Style(current_view->buffer()->params.textclass,
|
||||
layout);
|
||||
|
||||
bool further_blank_line = false;
|
||||
if (IsDummy())
|
||||
|
@ -21,7 +21,6 @@
|
||||
extern int mono_video;
|
||||
extern int fast_selection;
|
||||
|
||||
|
||||
// Constructor
|
||||
LyXScreen::LyXScreen(Window window,
|
||||
Dimension width,
|
||||
@ -280,7 +279,7 @@ void LyXScreen::ShowManualCursor(long x, long y, int asc, int desc)
|
||||
if (y2 > _height)
|
||||
y2 = _height;
|
||||
|
||||
if (fast_selection || mono_video){
|
||||
if (fast_selection || mono_video) {
|
||||
if (y2 > 0 && y1 < _height) {
|
||||
XDrawLine(fl_display,
|
||||
_window, getGC(gc_select),
|
||||
@ -332,7 +331,7 @@ void LyXScreen::HideCursor()
|
||||
{
|
||||
if (!cursor_visible) return;
|
||||
|
||||
if (fast_selection || mono_video){
|
||||
if (fast_selection || mono_video) {
|
||||
cursor_visible = false;
|
||||
ShowCursor();
|
||||
cursor_visible = false;
|
||||
@ -489,7 +488,7 @@ void LyXScreen::ToggleSelection(bool kill_selection)
|
||||
long bottom = 0;
|
||||
|
||||
|
||||
if (fast_selection || mono_video){
|
||||
if (fast_selection || mono_video) {
|
||||
|
||||
/* selection only in one row ?*/
|
||||
if (text->sel_start_cursor.y == text->sel_end_cursor.y) {
|
||||
|
@ -18,6 +18,10 @@ template<class A> inline void Assert(A assertion)
|
||||
#ifdef HAVE_PARTIAL_SPECIALIZATION
|
||||
// Not too sure if this is the correct way to specialize
|
||||
template<class A> inline void Assert(A * ptr)
|
||||
{
|
||||
Assert<void const *>(ptr);
|
||||
}
|
||||
template<> inline void Assert(void const * ptr)
|
||||
{
|
||||
if (!ptr) {
|
||||
abort();
|
||||
|
@ -831,7 +831,7 @@ string MakeRelPath(string const & abspath0, string const & basepath0)
|
||||
int j = i;
|
||||
while (j < baselen) {
|
||||
if (basepath[j] == '/') {
|
||||
if (j+1 == baselen) break;
|
||||
if (j + 1 == baselen) break;
|
||||
buf += "../";
|
||||
}
|
||||
++j;
|
||||
|
@ -53,4 +53,11 @@ private:
|
||||
string pushedDir_;
|
||||
};
|
||||
|
||||
// To avoid the wrong usage:
|
||||
// Path("/tmp"); // wrong
|
||||
// Path p("/tmp"); // right
|
||||
// we add this macro:
|
||||
#define Path(x) unnamed_Path;
|
||||
// Tip gotten from Bobby Schmidt's column in C/C++ Users Journal
|
||||
|
||||
#endif
|
||||
|
1479
src/text.C
1479
src/text.C
File diff suppressed because it is too large
Load Diff
1479
src/text2.C
1479
src/text2.C
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user