#include "insets/inseterror.h"
#include "insets/insetbib.h"
#include "insets/insetspecialchar.h"
+#include "insets/insettext.h"
#include "layout.h"
#include "LyXView.h"
#include "support/textutils.h"
lastrow = 0;
number_of_rows = 0;
refresh_y = 0;
- height = width = 0;
+ height = 0;
+ width = 0;
+ first = 0;
status = LyXText::UNCHANGED;
// set cursor at the very top position
selection = true; /* these setting is necessary
par = par->Next();
}
SetCursorIntern(bview, firstrow->par(), 0);
-#if 1
+#if 0
// Dump all rowinformation:
Row * tmprow = firstrow;
lyxerr << "Width = " << width << endl;
}
-#if 0
-void LyXText::owner(BufferView * bv)
-{
- if (bv_owner && bv) lyxerr << "LyXText::bv_owner already set!" << endl;
- bv_owner = bv;
-}
-#endif
-
// Gets the fully instantiated font at a given position in a paragraph
// Basically the same routine as LyXParagraph::getFont() in paragraph.C.
// The difference is that this one is used for displaying, and thus we
tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+#ifndef NEW_INSETS
// Cosmetic improvement: If this is an open footnote, make the font
// smaller.
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
tmpfont.decSize();
}
-
+#endif
return tmpfont;
}
layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+#ifndef NEW_INSETS
if (par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
&& par->footnotekind == LyXParagraph::FOOTNOTE) {
layoutfont.decSize();
}
-
+#endif
// Now, reduce font against full layout font
font.reduce(layoutfont);
AppendParagraph(bview, row->next());
}
}
-
+
+#ifndef NEW_INSETS
void LyXText::ToggleFootnote(BufferView * bview)
{
LyXParagraph * par = cursor.par()->ParFromPos(cursor.pos());
CloseFootnote(bview);
}
}
+#endif
void LyXText::OpenStuff(BufferView * bview)
}
+#ifndef NEW_INSETS
void LyXText::CloseFootnote(BufferView * bview)
{
LyXParagraph * tmppar;
if (cursor.row()->next())
SetHeightOfRow(bview, cursor.row()->next());
}
+#endif
/* used in setlayout */
// Asger is not sure we want to do this...
-void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf, LyXParagraph * par)
+void LyXText::MakeFontEntriesLayoutSpecific(Buffer const * buf,
+ LyXParagraph * par)
{
LyXLayout const & layout =
}
}
+
LyXParagraph * LyXText::SetLayout(BufferView * bview,
LyXCursor & cur, LyXCursor & sstart_cur,
LyXCursor & send_cur,
}
// We end at the next paragraph with depth 0
- LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next();
+ LyXParagraph * endpar =
+ sel_end_cursor.par()->LastPhysicalPar()->Next();
LyXParagraph * undoendpar = endpar;
if (endpar && endpar->GetDepth()) {
bool LyXText::FullRebreak(BufferView * bview)
{
+ if (!firstrow) {
+ init(bview);
+ return true;
+ }
if (need_break_row) {
BreakAgain(bview, need_break_row);
need_break_row = 0;
}
-void LyXText::ToggleFree(BufferView * bview, LyXFont const & font, bool toggleall)
+void LyXText::ToggleFree(BufferView * bview,
+ LyXFont const & font, bool toggleall)
{
// If the mask is completely neutral, tell user
if (font == LyXFont(LyXFont::ALL_IGNORE)) {
LyXParagraph::size_type
-LyXText::BeginningOfMainBody(Buffer const * buf, LyXParagraph const * par) const
+LyXText::BeginningOfMainBody(Buffer const * buf,
+ LyXParagraph const * par) const
{
if (textclasslist.Style(buf->params.textclass,
par->GetLayout()).labeltype != LABEL_MANUAL)
}
+#ifndef NEW_INSETS
/* if there is a selection, reset every environment you can find
* in the selection, otherwise just the environment you are in */
void LyXText::MeltFootnoteEnvironment(BufferView * bview)
ClearSelection();
}
+#endif
/* the DTP switches for paragraphs. LyX will store them in the
par->itemdepth = 0;
}
+#ifndef NEW_INSETS
// if this is an open marginnote and this is the first
// entry in the marginnote and the enclosing
// environment is an enum/item then correct for the
par->enumdepth++;
par->itemdepth++;
}
-
+#endif
/* Maybe we have to increment the enumeration depth.
* BUT, enumeration in a footnote is considered in isolation from its
* surrounding paragraph so don't increment if this is the
/* Rebreak the paragraph */
RemoveParagraph(row);
AppendParagraph(bview, row);
-
+
+#ifndef NEW_INSETS
/* think about the damned open footnotes! */
while (par->Next() &&
(par->Next()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
AppendParagraph(bview, row);
}
}
+#endif
}
par = par->LastPhysicalPar()->Next();
/* insets an inset. */
-void LyXText::InsertInset(BufferView * bview, Inset *inset)
+void LyXText::InsertInset(BufferView * bview, Inset * inset)
{
if (!cursor.par()->InsertInsetAllowed(inset))
return;
SetUndo(bview->buffer(), Undo::INSERT,
cursor.par()->ParFromPos(cursor.pos())->previous,
cursor.par()->ParFromPos(cursor.pos())->next);
- cursor.par()->InsertChar(cursor.pos(), LyXParagraph::META_INSET);
cursor.par()->InsertInset(cursor.pos(), inset);
InsertChar(bview, LyXParagraph::META_INSET); /* just to rebreak and refresh correctly.
* The character will not be inserted a
// OK, we have a selection. This is always between sel_start_cursor
// and sel_end cursor
LyXParagraph * tmppar;
-
+
+#ifndef NEW_INSETS
// Check whether there are half footnotes in the selection
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
|| sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
tmppar = tmppar->Next();
}
}
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table) {
// ok we have a selection. This is always between sel_start_cursor
// and sel_end cursor
LyXParagraph * tmppar;
-
+
+#ifndef NEW_INSETS
/* check wether there are half footnotes in the selection */
if (sel_start_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE
|| sel_end_cursor.par()->footnoteflag != LyXParagraph::NO_FOOTNOTE) {
tmppar = tmppar->Next();
}
}
-
+#endif
#ifndef NEW_TABULAR
/* table stuff -- begin */
if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){
// Insert the new string
for (int i = 0; str[i]; ++i) {
- sel_end_cursor.par()->InsertChar(pos, str[i]);
- sel_end_cursor.par()->SetFont(pos, font);
+ sel_end_cursor.par()->InsertChar(pos, str[i], font);
++pos;
}
if (str[i] == ' '
&& i + 1 < str.length() && str[i + 1] != ' '
&& pos && par->GetChar(pos - 1)!= ' ') {
- par->InsertChar(pos,' ');
- par->SetFont(pos, current_font);
+ par->InsertChar(pos, ' ', current_font);
++pos;
#ifndef NEW_TABLAR
} else if (par->table) {
break;
} else if ((str[i] != 13) &&
((str[i] & 127) >= ' ')) {
- par->InsertChar(pos, str[i]);
- par->SetFont(pos, current_font);
+ par->InsertChar(pos, str[i],
+ current_font);
++pos;
}
#endif
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
+ par->InsertInset(pos, new_inset,
+ current_font);
} else {
delete new_inset;
}
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
+ par->InsertInset(pos, new_inset,
+ current_font);
} else {
delete new_inset;
}
} else if (str[i] != 13 &&
// Ignore unprintables
(str[i] & 127) >= ' ') {
- par->InsertChar(pos, str[i]);
- par->SetFont(pos, current_font);
+ par->InsertChar(pos, str[i], current_font);
++pos;
}
} else {
InsetSpecialChar * new_inset =
new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
if (par->InsertInsetAllowed(new_inset)) {
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->SetFont(pos, current_font);
- par->InsertInset(pos, new_inset);
+ par->InsertInset(pos,
+ new_inset,
+ current_font);
} else {
delete new_inset;
}
}
-// returns 0 if inset wasn't found
-int LyXText::UpdateInset(BufferView * bview, Inset * inset)
+// returns false if inset wasn't found
+bool LyXText::UpdateInset(BufferView * bview, Inset * inset)
{
// first check the current paragraph
int pos = cursor.par()->GetPositionOfInset(inset);
if (pos != -1){
CheckParagraph(bview, cursor.par(), pos);
- return 1;
+ return true;
}
// check every paragraph
pos = par->GetPositionOfInset(inset);
if (pos != -1){
CheckParagraph(bview, par, pos);
- return 1;
+ return true;
}
}
par = par->Next();
} while (par);
- return 0;
+ return false;
}
pos = par->PositionInParFromPos(pos);
par = tmppar;
}
+#ifndef NEW_INSETS
if (par->IsDummy() && par->previous &&
par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
while (par->previous &&
}
pos += par->size() + 1;
}
-
+#endif
cur.par(par);
cur.pos(pos);
cur.boundary(boundary);
bool setfont, bool boundary) const
{
SetCursor(bview, cursor, par, pos, boundary);
-// #warning Remove this when verified working (Jug 20000413)
-#if 0
- // correct the cursor position if impossible
- if (pos > par->Last()){
- LyXParagraph * tmppar = par->ParFromPos(pos);
- pos = par->PositionInParFromPos(pos);
- par = tmppar;
- }
- if (par->IsDummy() && par->previous &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) {
- while (par->previous &&
- ((par->previous->IsDummy() && par->previous->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE) ||
- (par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE))) {
- par = par->previous ;
- if (par->IsDummy() &&
- par->previous->footnoteflag == LyXParagraph::CLOSED_FOOTNOTE)
- pos += par->size() + 1;
- }
- if (par->previous) {
- par = par->previous;
- }
- pos += par->size() + 1;
- }
-
- cursor.par() = par;
- cursor.pos() = pos;
-
- /* get the cursor y position in text */
- long y = 0;
- Row * row = GetRow(par, pos, y);
- /* y is now the beginning of the cursor row */
- y += row->baseline();
- /* y is now the cursor baseline */
- cursor.y() = y;
-
- /* now get the cursors x position */
- float x;
- float fill_separator, fill_hfill, fill_label_hfill;
- PrepareToPrint(row, x, fill_separator, fill_hfill, fill_label_hfill);
- LyXParagraph::size_type cursor_vpos;
- LyXParagraph::size_type last = RowLastPrintable(row);
-
- if (pos > last + 1) // This shouldn't happen.
- pos = last+1;
-
- if (last < row->pos())
- cursor_vpos = 0;
- else if (pos > last ||
- (pos - 1 >= row->pos() &&
- (row->par()->IsSeparator(pos) ||
- (row->par()->table && row->par()->IsNewline(pos))
- )))
- /// Place cursor after char at (logical) position pos-1
- cursor_vpos = (bidi_level(pos-1) % 2 == 0)
- ? log2vis(pos-1) + 1 : log2vis(pos-1);
- else
- /// Place cursor before char at (logical) position pos
- cursor_vpos = (bidi_level(pos) % 2 == 0)
- ? log2vis(pos) : log2vis(pos) + 1;
-
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
- if (row->par()->table) {
- int cell = NumberOfCell(row->par(), row->pos());
- float x_old = x;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- for (LyXParagraph::size_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (row->par()->IsNewline(pos)) {
- x = x_old + row->par()->table->WidthOfColumn(cell);
- x_old = x;
- ++cell;
- x += row->par()->table->GetBeginningOfTextInCell(cell);
- } else {
- x += SingleWidth(row->par(), pos);
- }
- }
- } else {
- /* table stuff -- end*/
-#endif
- LyXParagraph::size_type main_body =
- BeginningOfMainBody(row->par());
- if (main_body > 0 &&
- (main_body-1 > last ||
- !row->par()->IsLineSeparator(main_body-1)))
- main_body = 0;
-
- for (LyXParagraph::size_type vpos = row->pos(); vpos < cursor_vpos; ++vpos) {
- pos = vis2log(vpos);
- if (main_body > 0 && pos == main_body-1) {
- x += fill_label_hfill +
- lyxfont::width(textclasslist
- .Style(bview->buffer()->params.textclass,
- row->par()->GetLayout())
- .labelsep,
- GetFont(row->par(), -2));
- if (row->par()->IsLineSeparator(main_body-1))
- x -= SingleWidth(row->par(), main_body-1);
- }
- if (HfillExpansion(row, pos)) {
- x += SingleWidth(row->par(), pos);
- if (pos >= main_body)
- x += fill_hfill;
- else
- x += fill_label_hfill;
- }
- else if (row->par()->IsSeparator(pos)) {
- x += SingleWidth(row->par(), pos);
- if (pos >= main_body)
- x += fill_separator;
- } else
- x += SingleWidth(row->par(), pos);
- }
-#ifndef NEW_TABULAR
- }
-#endif
- cursor.x = int(x);
-
- cursor.x_fix = cursor.x;
- cursor.row() = row;
-#endif
if (setfont)
SetCurrentFont(bview);
}
}
}
- current_font = cursor.par()->GetFontSettings(bview->buffer()->params, pos);
+ current_font =
+ cursor.par()->GetFontSettings(bview->buffer()->params, pos);
real_current_font = GetFont(bview->buffer(), cursor.par(), pos);
}