Color None
EndFont
+DefaultStyle Dialogue
# Dialogue style definition. Actor dialog
Style Dialogue
updateScreen();
updateScrollbar();
}
- bv_->text->first = screen_->topCursorVisible(bv_->text);
+ bv_->text->first_y = screen_->topCursorVisible(bv_->text);
owner_->updateMenubar();
owner_->updateToolbar();
// Similarly, buffer-dependent dialogs should be updated or
// remake the inset locking
bv_->theLockingInset(the_locking_inset);
}
- bv_->text->first = screen_->topCursorVisible(bv_->text);
+ bv_->text->first_y = screen_->topCursorVisible(bv_->text);
#if 0
buffer_->resizeInsets(bv_);
#endif
if (text_height <= work_height) {
workarea_.setScrollbarBounds(0.0, 0.0);
- current_scrollbar_value = bv_->text->first;
+ current_scrollbar_value = bv_->text->first_y;
workarea_.setScrollbar(current_scrollbar_value, 1.0);
return;
}
workarea_.setScrollbarIncrements(lineh);
old_lineh = lineh;
}
- if (current_scrollbar_value != bv_->text->first
+ if (current_scrollbar_value != bv_->text->first_y
|| slider_size != old_slider_size) {
- current_scrollbar_value = bv_->text->first;
+ current_scrollbar_value = bv_->text->first_y;
workarea_.setScrollbar(current_scrollbar_value, slider_size);
old_slider_size = slider_size;
}
LyXText * vbt = bv_->text;
int const height = vbt->defaultHeight();
- int const first = static_cast<int>((bv_->text->first + height));
- int const last = static_cast<int>((bv_->text->first + workarea_.height() - height));
+ int const first = static_cast<int>((bv_->text->first_y + height));
+ int const last = static_cast<int>((bv_->text->first_y + workarea_.height() - height));
if (vbt->cursor.y() < first)
vbt->setCursorFromCoordinates(bv_, 0, first);
bv_->theLockingInset()->
insetMotionNotify(bv_,
x - start_x,
- y - cursor.y() + bv_->text->first,
+ y - cursor.y() + bv_->text->first_y,
state);
return;
}
screen_->hideCursor();
- bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first);
+ bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first_y);
if (!bv_->text->selection.set())
update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
selection_possible = true;
screen_->hideCursor();
- int const screen_first = bv_->text->first;
+ int const screen_first = bv_->text->first_y;
// Middle button press pastes if we have a selection
bool paste_internally = false;
if (!screen_.get())
return 0;
- int y_tmp = y + text->first;
+ int y_tmp = y + text->first_y;
LyXCursor cursor;
text->setCursorFromCoordinates(bv_, cursor, x, y_tmp);
if (!text->cursor.row()->previous())
return;
- int y = text->first;
+ int y = text->first_y;
if (text->inset_owner)
- y += bv_->text->first;
+ y += bv_->text->first_y;
Row * cursorrow = text->cursor.row();
text->setCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
finishUndo();
if (!text->cursor.row()->next())
return;
- int y = text->first + workarea_.height();
+ int y = text->first_y + workarea_.height();
// if (text->inset_owner)
// y += bv_->text->first;
text->getRowNearY(y);
break;
case LFUN_INSET_TEXT:
- insertAndEditInset(new InsetText);
+ insertAndEditInset(new InsetText(buffer_->params));
break;
case LFUN_INSET_ERT:
- insertAndEditInset(new InsetERT);
+ insertAndEditInset(new InsetERT(buffer_->params));
break;
case LFUN_INSET_EXTERNAL:
break;
case LFUN_INSET_FOOTNOTE:
- insertAndEditInset(new InsetFoot);
+ insertAndEditInset(new InsetFoot(buffer_->params));
break;
case LFUN_INSET_MARGINAL:
- insertAndEditInset(new InsetMarginal);
+ insertAndEditInset(new InsetMarginal(buffer_->params));
break;
case LFUN_INSET_MINIPAGE:
- insertAndEditInset(new InsetMinipage);
+ insertAndEditInset(new InsetMinipage(buffer_->params));
break;
case LFUN_INSERT_NOTE:
- insertAndEditInset(new InsetNote);
+ insertAndEditInset(new InsetNote(buffer_->params));
break;
case LFUN_INSET_FLOAT:
// check if the float type exist
if (floatList.typeExist(argument)) {
- insertAndEditInset(new InsetFloat(argument));
+ insertAndEditInset(new InsetFloat(buffer_->params,
+ argument));
} else {
lyxerr << "Non-existent float type: "
<< argument << endl;
{
// check if the float type exist
if (floatList.typeExist(argument)) {
- InsetFloat * new_inset = new InsetFloat(argument);
+ InsetFloat * new_inset =
+ new InsetFloat(buffer_->params, argument);
new_inset->wide(true);
if (insertInset(new_inset))
new_inset->edit(bv_);
if (bv_->theLockingInset()) {
lyxerr << "Locking inset code: "
<< static_cast<int>(bv_->theLockingInset()->lyxCode());
- InsetCaption * new_inset = new InsetCaption;
+ InsetCaption * new_inset =
+ new InsetCaption(buffer_->params);
new_inset->setOwner(bv_->theLockingInset());
new_inset->setAutoBreakRows(true);
new_inset->setDrawFrame(0, InsetText::LOCKED);
if (!ert_comp.contents.empty()) {
lyxerr[Debug::INSETS] << "ERT contents:\n'"
<< ert_comp.contents << "'" << endl;
- Inset * inset = new InsetERT(params.language, ert_comp.contents, true);
+ Inset * inset = new InsetERT(params, params.language,
+ ert_comp.contents, true);
par->insertInset(pos++, inset, ert_comp.font);
ert_comp.contents.erase();
}
insertErtContents(par, pos);
#endif
lex.eatLine();
- string const layoutname = lowercase(lex.getString());
- //lyxerr << "Looking for layout '"
- // << layoutname << "'!" << endl;
-
- //lyxerr << "Result: " << pp.first << "/" << pp.second << endl;
+ string const layoutname = lex.getString();
+ LyXTextClass const & tclass = textclasslist[params.textclass];
+ bool hasLayout = tclass.hasLayout(layoutname);
+ if (!hasLayout) {
+ lyxerr << "Layout '" << layoutname << "' does not"
+ << " exist in textclass '" << tclass.name()
+ << "'." << endl;
+ }
#ifndef NO_COMPABILITY
if (compare_no_case(layoutname, "latex") == 0) {
stringstream old_float;
if (tmptok == "footnote") {
- inset = new InsetFoot;
+ inset = new InsetFoot(params);
old_float << "collapsed true\n";
} else if (tmptok == "margin") {
- inset = new InsetMarginal;
+ inset = new InsetMarginal(params);
old_float << "collapsed true\n";
} else if (tmptok == "fig") {
- inset = new InsetFloat("figure");
+ inset = new InsetFloat(params, "figure");
old_float << "placement htbp\n"
<< "wide false\n"
<< "collapsed false\n";
} else if (tmptok == "tab") {
- inset = new InsetFloat("table");
+ inset = new InsetFloat(params, "table");
old_float << "placement htbp\n"
<< "wide false\n"
<< "collapsed false\n";
} else if (tmptok == "alg") {
- inset = new InsetFloat("algorithm");
+ inset = new InsetFloat(params, "algorithm");
old_float << "placement htbp\n"
<< "wide false\n"
<< "collapsed false\n";
} else if (tmptok == "wide-fig") {
- inset = new InsetFloat("figure");
+ inset = new InsetFloat(params, "figure");
//InsetFloat * tmp = new InsetFloat("figure");
//tmp->wide(true);
//inset = tmp;
<< "wide true\n"
<< "collapsed false\n";
} else if (tmptok == "wide-tab") {
- inset = new InsetFloat("table");
+ inset = new InsetFloat(params, "table");
//InsetFloat * tmp = new InsetFloat("table");
//tmp->wide(true);
//inset = tmp;
p->params().depth(parBeforeMinipage->params().depth());
parBeforeMinipage = p;
}
- InsetMinipage * mini = new InsetMinipage;
+ InsetMinipage * mini = new InsetMinipage(params);
mini->pos(static_cast<InsetMinipage::Position>(par->params().pextraAlignment()));
mini->pageWidth(LyXLength(par->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
if (!first_par || (first_par == par))
first_par = p;
- InsetMinipage * mini = new InsetMinipage;
+ InsetMinipage * mini = new InsetMinipage(params);
mini->pos(static_cast<InsetMinipage::Position>(minipar->params().pextraAlignment()));
mini->pageWidth(LyXLength(minipar->params().pextraWidth()));
if (!par->params().pextraWidthp().empty()) {
true);
alreadyread = true;
} else if (tmptok == "Note") {
- inset = new InsetNote;
+ inset = new InsetNote(params);
} else if (tmptok == "Include") {
InsetCommandParams p("Include");
inset = new InsetInclude(p, *this);
} else if (tmptok == "ERT") {
- inset = new InsetERT;
+ inset = new InsetERT(params);
} else if (tmptok == "Tabular") {
inset = new InsetTabular(*this);
} else if (tmptok == "Text") {
- inset = new InsetText;
+ inset = new InsetText(params);
} else if (tmptok == "Foot") {
- inset = new InsetFoot;
+ inset = new InsetFoot(params);
} else if (tmptok == "Marginal") {
- inset = new InsetMarginal;
+ inset = new InsetMarginal(params);
} else if (tmptok == "Minipage") {
- inset = new InsetMinipage;
+ inset = new InsetMinipage(params);
} else if (tmptok == "Float") {
lex.next();
string tmptok = lex.getString();
- inset = new InsetFloat(tmptok);
+ inset = new InsetFloat(params, tmptok);
#if 0
} else if (tmptok == "List") {
inset = new InsetList;
inset = new InsetList;
#endif
} else if (tmptok == "Caption") {
- inset = new InsetCaption;
+ inset = new InsetCaption(params);
} else if (tmptok == "FloatList") {
inset = new InsetFloatList;
}
#endif
// First write the layout
- string const & tmp = lowercase(par->layout());
- if (tmp == "itemize") {
+ string const & tmp = par->layout();
+ if (compare_no_case(tmp, "itemize") == 0) {
ltype = 1;
ltype_depth = depth + 1;
- } else if (tmp == "enumerate") {
+ } else if (compare_no_case(tmp, "enumerate") == 0) {
ltype = 2;
ltype_depth = depth + 1;
- } else if (contains(tmp, "ection")) {
+ } else if (contains(lowercase(tmp), "ection")) {
ltype = 3;
ltype_depth = depth + 1;
- } else if (contains(tmp, "aragraph")) {
+ } else if (contains(lowercase(tmp), "aragraph")) {
ltype = 4;
ltype_depth = depth + 1;
- } else if (tmp == "description") {
+ } else if (compare_no_case(tmp, "description") == 0) {
ltype = 5;
ltype_depth = depth + 1;
- } else if (tmp == "abstract") {
+ } else if (compare_no_case(tmp, "abstract") == 0) {
ltype = 6;
ltype_depth = 0;
- } else if (tmp == "bibliography") {
+ } else if (compare_no_case(tmp, "bibliography") == 0) {
ltype = 7;
ltype_depth = 0;
} else {
#include "LyXView.h"
#include "vc-backend.h"
#include "TextCache.h"
+#include "lyxtextclasslist.h"
#include "frontends/Alert.h"
MakeDisplayPath(tname));
// no template, start with empty buffer
b->paragraph = new Paragraph;
+ b->paragraph->layout(textclasslist[b->params.textclass].defaultLayoutName());
}
} else { // start with empty buffer
b->paragraph = new Paragraph;
+ b->paragraph->layout(textclasslist[b->params.textclass].defaultLayoutName());
}
if (!lyxrc.new_ask_filename && !isNamed) {
using std::ostream;
using std::endl;
-InsetCaption::InsetCaption()
- : InsetText()
+InsetCaption::InsetCaption(BufferParams const & bp)
+ : InsetText(bp)
{
setAutoBreakRows(true);
setDrawFrame(0, InsetText::LOCKED);
class InsetCaption : public InsetText {
public:
///
- InsetCaption();
+ InsetCaption(BufferParams const &);
///
void write(Buffer const * buf, std::ostream & os) const;
///
class LyXText;
-InsetCollapsable::InsetCollapsable(bool collapsed)
- : UpdatableInset(), collapsed_(collapsed),
+InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
+ : UpdatableInset(), collapsed_(collapsed), inset(bp),
button_length(0), button_top_y(0), button_bottom_y(0),
need_update(NONE), label("Label"),
#if 0
InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id)
- : UpdatableInset(in, same_id), collapsed_(in.collapsed_),
- framecolor(in.framecolor), labelfont(in.labelfont),
+ : UpdatableInset(in, same_id), collapsed_(in.collapsed_),
+ framecolor(in.framecolor), labelfont(in.labelfont), inset(in.inset),
button_length(0), button_top_y(0), button_bottom_y(0),
need_update(NONE), label(in.label),
#if 0
///
static int const TEXT_TO_BOTTOM_OFFSET = 2;
/// inset is initially collapsed if bool = true
- InsetCollapsable(bool = false);
+ InsetCollapsable(BufferParams const &, bool = false);
///
InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
///
}
-InsetERT::InsetERT(bool collapsed)
- : InsetCollapsable(collapsed)
+InsetERT::InsetERT(BufferParams const & bp, bool collapsed)
+ : InsetCollapsable(bp, collapsed)
{
if (collapsed)
status_ = Collapsed;
}
-InsetERT::InsetERT(Language const * l, string const & contents, bool collapsed)
- : InsetCollapsable(collapsed)
+InsetERT::InsetERT(BufferParams const & bp,
+ Language const * l, string const & contents, bool collapsed)
+ : InsetCollapsable(bp, collapsed)
{
if (collapsed)
status_ = Collapsed;
Inlined
};
///
- InsetERT(bool collapsed=false);
+ InsetERT(BufferParams const &, bool collapsed = false);
///
InsetERT(InsetERT const &, bool same_id = false);
///
Inset * clone(Buffer const &, bool same_id = false) const;
///
- InsetERT(Language const *, string const & contents, bool collapsed);
+ InsetERT(BufferParams const &,
+ Language const *, string const & contents, bool collapsed);
///
~InsetERT();
///
//
// Lgb
-InsetFloat::InsetFloat(string const & type)
- : InsetCollapsable(), wide_(false)
+InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
+ : InsetCollapsable(bp), wide_(false)
{
string lab(_("float:"));
lab += type;
class InsetFloat : public InsetCollapsable {
public:
///
- InsetFloat(string const &);
+ InsetFloat(BufferParams const &, string const &);
///
InsetFloat(InsetFloat const &, bool same_id = false);
///
using std::ostream;
-InsetFoot::InsetFoot()
- : InsetFootlike()
+InsetFoot::InsetFoot(BufferParams const & bp)
+ : InsetFootlike(bp)
{
setLabel(_("foot"));
setInsetName("Foot");
class InsetFoot : public InsetFootlike {
public:
///
- InsetFoot();
+ InsetFoot(BufferParams const &);
///
InsetFoot(InsetFoot const &, bool same_id = false);
///
using std::ostream;
-InsetFootlike::InsetFootlike()
- : InsetCollapsable()
+InsetFootlike::InsetFootlike(BufferParams const & bp)
+ : InsetCollapsable(bp)
{
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
class InsetFootlike : public InsetCollapsable {
public:
///
- InsetFootlike();
+ InsetFootlike(BufferParams const &);
///
InsetFootlike(InsetFootlike const &, bool same_id = false);
///
using std::ostream;
-InsetMarginal::InsetMarginal()
- : InsetFootlike()
+InsetMarginal::InsetMarginal(BufferParams const & bp)
+ : InsetFootlike(bp)
{
setLabel(_("margin"));
setInsetName("Marginal");
class InsetMarginal : public InsetFootlike {
public:
///
- InsetMarginal();
+ InsetMarginal(BufferParams const &);
///
InsetMarginal(InsetMarginal const &, bool same_id = false);
///
// have to output "" for minipages.
// (Lgb)
-InsetMinipage::InsetMinipage()
- : InsetCollapsable(), pos_(center),
+InsetMinipage::InsetMinipage(BufferParams const & bp)
+ : InsetCollapsable(bp), pos_(center),
inner_pos_(inner_center), width_(100, LyXLength::PW)
{
setLabel(_("minipage"));
inner_stretch
};
///
- InsetMinipage();
+ InsetMinipage(BufferParams const &);
///
InsetMinipage(InsetMinipage const &, bool same_id = false);
///
}
-InsetNote::InsetNote()
- : InsetCollapsable()
+InsetNote::InsetNote(BufferParams const & bp)
+ : InsetCollapsable(bp)
{
init();
}
// This constructor is used for reading old InsetInfo
InsetNote::InsetNote(Buffer const * buf, string const & contents,
bool collapsed)
- : InsetCollapsable(collapsed)
+ : InsetCollapsable(buf->params, collapsed)
{
init();
class InsetNote : public InsetCollapsable {
public:
///
- InsetNote();
+ InsetNote(BufferParams const &);
///
InsetNote(InsetNote const &, bool same_id = false);
///
rows = 1;
if (columns <= 0)
columns = 1;
- tabular.reset(new LyXTabular(this, rows, columns));
+ tabular.reset(new LyXTabular(buf.params, this, rows, columns));
// for now make it always display as display() inset
// just for test!!!
the_locking_inset = 0;
bool same_id)
: UpdatableInset(tab, same_id), buffer(&buf)
{
- tabular.reset(new LyXTabular(this, *(tab.tabular), same_id));
+ tabular.reset(new LyXTabular(buf.params,
+ this, *(tab.tabular), same_id));
the_locking_inset = 0;
old_locking_inset = 0;
locked = false;
}
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
- if (bv->text->first + bv->painter().paperHeight() <
+ if (bv->text->first_y + bv->painter().paperHeight() <
(top_baseline + tabular->GetHeightOfTabular()))
{
- bv->scrollCB(bv->text->first + bv->painter().paperHeight());
+ bv->scrollCB(bv->text->first_y + bv->painter().paperHeight());
code = FULL;
actcell = tabular->GetCellBelow(first_visible_cell) + column;
} else {
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
if (top_baseline < 0) {
- bv->scrollCB(bv->text->first - bv->painter().paperHeight());
+ bv->scrollCB(bv->text->first_y - bv->painter().paperHeight());
code = FULL;
if (top_baseline > 0)
actcell = column;
}
maxCols = max(cols, maxCols);
delete paste_tabular;
- paste_tabular = new LyXTabular(this, rows, maxCols);
+ paste_tabular = new LyXTabular(bv->buffer()->params,
+ this, rows, maxCols);
string::size_type op = 0;
int cell = 0;
int cells = paste_tabular->GetNumberOfCells();
case LyXTabular::APPEND_ROW:
// append the row into the tabular
unlockInsetInInset(bv, the_locking_inset);
- tabular->AppendRow(actcell);
+ tabular->AppendRow(bv->buffer()->params, actcell);
updateLocal(bv, INIT, true);
break;
case LyXTabular::APPEND_COLUMN:
// append the column into the tabular
unlockInsetInInset(bv, the_locking_inset);
- tabular->AppendColumn(actcell);
+ tabular->AppendColumn(bv->buffer()->params, actcell);
actcell = tabular->GetCellNumber(row, column);
updateLocal(bv, INIT, true);
break;
int const rows = sel_row_end - sel_row_start + 1;
delete paste_tabular;
- paste_tabular = new LyXTabular(this, *tabular); // rows, columns);
+ paste_tabular = new LyXTabular(bv->buffer()->params,
+ this, *tabular); // rows, columns);
for (int i = 0; i < sel_row_start; ++i)
paste_tabular->DeleteRow(0);
while (paste_tabular->rows() > rows)
}
-InsetText::InsetText()
+InsetText::InsetText(BufferParams const & bp)
: UpdatableInset(), lt(0), in_update(false), do_resize(0),
do_reinit(false)
{
par = new Paragraph;
+ par->layout(textclasslist[bp.textclass].defaultLayoutName());
+
init();
}
}
if (y_offset < 0)
y_offset = y;
- lt->first = first;
+ lt->first_y = first;
if (cleared || (need_update&(INIT|FULL))) {
int yf = y_offset;
y = 0;
mouse_y = y;
int tmp_x = x - drawTextXOffset;
- int tmp_y = y + insetAscent - getLyXText(bv)->first;
+ int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
hideInsetCursor(bv);
button);
}
int tmp_x = x - drawTextXOffset;
- int tmp_y = y + insetAscent - getLyXText(bv)->first;
+ int tmp_y = y + insetAscent - getLyXText(bv)->first_y;
Inset * inset = bv->checkInsetHit(getLyXText(bv), tmp_x, tmp_y);
bool ret = false;
if (inset) {
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
textclass_type tclass = bv->buffer()->params.textclass;
- string layout = lowercase(arg);
+ string layout = arg;
bool hasLayout = textclasslist[tclass].hasLayout(layout);
// If the entry is obsolete, use the new one instead.
textclasslist[tclass][layout].
obsoleted_by();
if (!obs.empty())
- layout = lowercase(obs);
+ layout = obs;
}
// see if we found the layout number:
}
if (bv->screen()) {
- t->first = bv->screen()->topCursorVisible(t);
+ t->first_y = bv->screen()->topCursorVisible(t);
}
if (!owner()) {
updateLocal(bv, FULL, false);
inset_y = cy(bv) + drawTextYOffset;
}
if (bv->screen()) {
- t->first = bv->screen()->topCursorVisible(t);
+ t->first_y = bv->screen()->topCursorVisible(t);
}
if (!owner()) {
updateLocal(bv, FULL, false);
class Painter;
class BufferView;
class Buffer;
+class BufferParams;
class LyXCursor;
class LyXText;
class LyXScreen;
ALWAYS
};
///
- InsetText();
+ InsetText(BufferParams const &);
///
explicit
InsetText(InsetText const &, bool same_id = false);
case LT_COPYSTYLE: // initialize with a known style
if (lexrc.next()) {
- string const style = lowercase(lexrc.getString());
+ string const style = lexrc.getString();
if (tclass.hasLayout(style)) {
- string const tmpname = lowercase(name_);
+ string const tmpname = name_;
this->operator=(tclass[style]);
- name_ = lowercase(tmpname);
+ name_ = tmpname;
} else {
lyxerr << "Cannot copy unknown style `" << style << "'" << endl;
LyXTextClass::const_iterator it = tclass.begin();
case LT_OBSOLETEDBY: // replace with a known style
if (lexrc.next()) {
- string const style = lowercase(lexrc.getString());
+ string const style = lexrc.getString();
if (tclass.hasLayout(style)) {
string const tmpname = name_;
string const & LyXLayout::name() const
{
- static string name_t;
- name_t = lowercase(name_);
- return name_t;
+ return name_;
}
void LyXLayout::setName(string const & n)
{
- name_ = lowercase(n);
+ name_ = n;
}
string const & LyXLayout::obsoleted_by() const
{
- static string obsoleted_by_t;
- obsoleted_by_t = lowercase(obsoleted_by_);
- return obsoleted_by_t;
+ return obsoleted_by_;
}
mutable LyXFont real_current_font;
/// first visible pixel-row is set from LyXScreen!!!
// unsigned is wrong here for text-insets!
- int first;
+ int first_y;
///
BufferView * bv_owner;
///
private:
///
mutable Row * firstrow;
+
///
mutable Row * lastrow;
-
+
/** Copybuffer for copy environment type.
Asger has learned that this should be a buffer-property instead
Lgb has learned that 'char' is a lousy type for non-characters
case TC_DEFAULTSTYLE:
if (lexrc.next()) {
- string const name = subst(lowercase(lexrc.getString()), '_', ' ');
+ string const name = subst(lexrc.getString(),
+ '_', ' ');
defaultlayout_ = name;
}
break;
case TC_STYLE:
if (lexrc.next()) {
- string const name = subst(lowercase(lexrc.getString()),
+ string const name = subst(lexrc.getString(),
'_', ' ');
if (hasLayout(name)) {
LyXLayout & lay = operator[](name);
lay.setName(name);
if (!(error = do_readStyle(lexrc, lay)))
layoutlist.push_back(lay);
+ if (defaultlayout_.empty()) {
+ // We do not have a default
+ // layout yet, so we choose
+ // the first layout we
+ // encounter.
+ defaultlayout_ = name;
+ }
}
}
else {
case TC_NOSTYLE:
if (lexrc.next()) {
- string const style = subst(lowercase(lexrc.getString()),
+ string const style = subst(lexrc.getString(),
'_', ' ');
if (!delete_layout(style))
lyxerr << "Cannot delete style `" << style << "'" << endl;
bool LyXTextClass::hasLayout(string const & n) const
{
- string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+ string const name = (n.empty() ? defaultLayoutName() : n);
return find_if(layoutlist.begin(), layoutlist.end(),
lyx::compare_memfun(&LyXLayout::name, name))
if (n.empty())
lyxerr << "Operator[] called with empty n" << endl;
- string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+ string const name = (n.empty() ? defaultLayoutName() : n);
LayoutList::const_iterator cit =
find_if(layoutlist.begin(),
if (n.empty())
lyxerr << "Operator[] called with empty n" << endl;
- string const name = (n.empty() ? defaultLayoutName() : lowercase(n));
+ string const name = (n.empty() ? defaultLayoutName() : n);
LayoutList::iterator it =
find_if(layoutlist.begin(),
}
-bool LyXTextClass::delete_layout(string const & n)
+bool LyXTextClass::delete_layout(string const & name)
{
- string const name = lowercase(n);
-
if (name == defaultLayoutName())
return false;
{
// create a new paragraph
Paragraph * tmp = new Paragraph(this);
+ tmp->layout(layout());
+
// remember to set the inset_owner
tmp->setInsetOwner(inInset());
int y1, int y2, int y_offset, int x_offset,
bool internal)
{
- int y_text = text->first + y1;
+ int y_text = text->first_y + y1;
// get the first needed row
Row * row = text->getRowNearY(y_text);
// y_text is now the real beginning of the row
- int y = y_text - text->first;
+ int y = y_text - text->first_y;
// y1 is now the real beginning of row on the screen
while (row != 0 && y < y2) {
LyXText::text_status st = text->status();
text->getVisibleRow(bv, y + y_offset,
- x_offset, row, y + text->first);
+ x_offset, row, y + text->first_y);
internal = internal && (st != LyXText::CHANGED_IN_DRAW);
while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
if (text->fullRebreak(bv)) {
}
text->status(bv, st);
text->getVisibleRow(bv, y + y_offset,
- x_offset, row, y + text->first);
+ x_offset, row, y + text->first_y);
}
y += row->height();
row = row->next();
void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
int y_text, int y_offset, int x_offset)
{
- int const y = y_text - text->first + y_offset;
+ int const y = y_text - text->first_y + y_offset;
if (((y + row->height()) > 0) &&
((y - row->height()) <= static_cast<int>(owner.height()))) {
do {
bv->text->status(bv, st);
text->getVisibleRow(bv, y, x_offset, row,
- y + text->first);
+ y + text->first_y);
} while (!text->inset_owner &&
text->status() == LyXText::CHANGED_IN_DRAW);
bv->text->status(bv, st);
#else
- text->getVisibleRow(bv, y, x_offset, row, y + text->first);
+ text->getVisibleRow(bv, y, x_offset, row, y + text->first_y);
#endif
}
force_clear = false;
{
if (cursor_visible) hideCursor();
- int const old_first = text->first;
+ int const old_first = text->first_y;
bool internal = (text == bv->text);
- text->first = y;
+ text->first_y = y;
// is any optimiziation possible?
if ((y - old_first) < owner.height()
&& (old_first - y) < owner.height())
{
- if (text->first < old_first) {
- drawFromTo(text, bv, 0, old_first - text->first, 0, 0, internal);
+ if (text->first_y < old_first) {
+ drawFromTo(text, bv, 0,
+ old_first - text->first_y, 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
owner.xpos(),
owner.ypos(),
owner.workWidth(),
- owner.height() - old_first + text->first,
+ owner.height() - old_first + text->first_y,
owner.xpos(),
- owner.ypos() + old_first - text->first
+ owner.ypos() + old_first - text->first_y
);
// expose the area drawn
expose(0, 0,
owner.workWidth(),
- old_first - text->first);
+ old_first - text->first_y);
} else {
drawFromTo(text, bv,
- owner.height() + old_first - text->first,
+ owner.height() + old_first - text->first_y,
owner.height(), 0, 0, internal);
XCopyArea (fl_get_display(),
owner.getWin(),
owner.getWin(),
gc_copy,
owner.xpos(),
- owner.ypos() + text->first - old_first,
+ owner.ypos() + text->first_y - old_first,
owner.workWidth(),
- owner.height() + old_first - text->first,
+ owner.height() + old_first - text->first_y,
owner.xpos(),
owner.ypos());
// expose the area drawn
- expose(0, owner.height() + old_first - text->first,
- owner.workWidth(), text->first - old_first);
+ expose(0, owner.height() + old_first - text->first_y,
+ owner.workWidth(), text->first_y - old_first);
}
} else {
// make a dumb new-draw
bool LyXScreen::fitManualCursor(LyXText * text, BufferView * bv,
int /*x*/, int y, int asc, int desc)
{
- int newtop = text->first;
+ int newtop = text->first_y;
- if (y + desc - text->first >= static_cast<int>(owner.height()))
+ if (y + desc - text->first_y >= static_cast<int>(owner.height()))
newtop = y - 3 * owner.height() / 4; // the scroll region must be so big!!
- else if (y - asc < static_cast<int>(text->first)
- && text->first > 0) {
+ else if (y - asc < text->first_y
+ && text->first_y > 0) {
newtop = y - owner.height() / 4;
}
newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
- if (newtop != static_cast<int>(text->first)) {
+ if (newtop != text->first_y) {
draw(text, bv, newtop);
- text->first = newtop;
+ text->first_y = newtop;
return true;
}
return false;
// Update the cursor color.
setCursorColor();
- int const y1 = max(y - text->first - asc, 0);
- int const y_tmp = min(y - text->first + desc,
+ int const y1 = max(y - text->first_y - asc, 0);
+ int const y_tmp = min(y - text->first_y + desc,
static_cast<int>(owner.height()));
// Secure against very strange situations
/* returns a new top so that the cursor is visible */
unsigned int LyXScreen::topCursorVisible(LyXText const * text)
{
- int newtop = text->first;
+ int newtop = text->first_y;
Row * row = text->cursor.row();
return max(newtop, 0);
if (text->cursor.y() - row->baseline() + row->height()
- - text->first >= owner.height()) {
+ - text->first_y >= owner.height()) {
if (row->height() < owner.height()
&& row->height() > owner.height() / 4) {
newtop = text->cursor.y()
}
} else if (static_cast<int>((text->cursor.y()) - row->baseline()) <
- text->first && text->first > 0) {
+ text->first_y && text->first_y > 0) {
if (row->height() < owner.height()
&& row->height() > owner.height() / 4) {
newtop = text->cursor.y() - row->baseline();
} else {
// scroll up
newtop = text->cursor.y() - owner.height() / 2;
- newtop = min(newtop, int(text->first));
+ newtop = min(newtop, text->first_y);
}
}
{
// Is a change necessary?
int const newtop = topCursorVisible(text);
- bool const result = (newtop != text->first);
+ bool const result = (newtop != text->first_y);
if (result)
draw(text, bv, newtop);
return result;
switch (text->status()) {
case LyXText::NEED_MORE_REFRESH:
{
- int const y = max(int(text->refresh_y - text->first), 0);
+ int const y = max(int(text->refresh_y - text->first_y), 0);
drawFromTo(text, bv, y, owner.height(), y_offset, x_offset);
text->refresh_y = 0;
// otherwise this is called ONLY from BufferView_pimpl(update)
// or we should see to set this flag accordingly
if (text != bv->text)
text->status(bv, LyXText::UNCHANGED);
- expose(0, text->refresh_y - text->first + y_offset,
+ expose(0, text->refresh_y - text->first_y + y_offset,
owner.workWidth(), text->refresh_row->height());
}
}
max(static_cast<int>(text->selection.end.y()
- text->selection.end.row()->baseline()
+ text->selection.end.row()->height()),
- text->first),
- static_cast<int>(text->first + owner.height()));
+ text->first_y),
+ static_cast<int>(text->first_y + owner.height()));
int const top = min(
max(static_cast<int>(text->selection.start.y() -
text->selection.start.row()->baseline()),
- text->first),
- static_cast<int>(text->first + owner.height()));
+ text->first_y),
+ static_cast<int>(text->first_y + owner.height()));
if (kill_selection)
text->selection.set(false);
- drawFromTo(text, bv, top - text->first, bottom - text->first,
+ drawFromTo(text, bv, top - text->first_y, bottom - text->first_y,
y_offset, x_offset);
- expose(0, top - text->first,
+ expose(0, top - text->first_y,
owner.workWidth(),
- bottom - text->first - (top - text->first));
+ bottom - text->first_y - (top - text->first_y));
}
- text->toggle_end_cursor.row()->baseline()
+ text->toggle_end_cursor.row()->height();
- int const bottom = min(max(bottom_tmp, text->first),
- static_cast<int>(text->first + owner.height()));
- int const top = min(max(top_tmp, text->first),
- static_cast<int>(text->first + owner.height()));
+ int const bottom = min(max(bottom_tmp, text->first_y),
+ static_cast<int>(text->first_y + owner.height()));
+ int const top = min(max(top_tmp, text->first_y),
+ static_cast<int>(text->first_y + owner.height()));
- drawFromTo(text, bv, top - text->first, bottom - text->first, y_offset,
+ drawFromTo(text, bv, top - text->first_y,
+ bottom - text->first_y, y_offset,
x_offset);
- expose(0, top - text->first, owner.workWidth(),
- bottom - text->first - (top - text->first));
+ expose(0, top - text->first_y, owner.workWidth(),
+ bottom - text->first_y - (top - text->first_y));
}
#include <config.h>
#include "tabular.h"
+#include "buffer.h"
#include "debug.h"
+
#include "support/lstrings.h"
#include "support/textutils.h"
return;
if (!getTokenValue(line, "columns", columns_arg))
return;
- Init(rows_arg, columns_arg);
+ Init(buf->params, rows_arg, columns_arg);
l_getline(is, line);
if (!prefixIs(line, "<Features ")) {
lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
/// Define a few methods for the inner structs
-LyXTabular::cellstruct::cellstruct()
+LyXTabular::cellstruct::cellstruct(BufferParams const & bg)
+ : inset(bg)
{
cellno = 0;
width_of_cell = 0;
/* konstruktor */
-LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
+LyXTabular::LyXTabular(BufferParams const & bp,
+ InsetTabular * inset, int rows_arg, int columns_arg)
{
owner_ = inset;
cur_cell = -1;
- Init(rows_arg, columns_arg);
+ Init(bp, rows_arg, columns_arg);
}
-LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt,
+LyXTabular::LyXTabular(BufferParams const & bp,
+ InsetTabular * inset, LyXTabular const & lt,
bool same_id)
{
owner_ = inset;
cur_cell = -1;
- Init(lt.rows_, lt.columns_, <);
+ Init(bp, lt.rows_, lt.columns_, <);
// we really should change again to have InsetText as a pointer
// and allocate it then we would not have to do this stuff all
// double!
}
-LyXTabular * LyXTabular::clone(InsetTabular * inset, bool same_id)
+LyXTabular * LyXTabular::clone(BufferParams const & bp,
+ InsetTabular * inset, bool same_id)
{
- LyXTabular * result = new LyXTabular(inset, *this, same_id);
+ LyXTabular * result = new LyXTabular(bp, inset, *this, same_id);
#if 0
// don't know if this is good but I need to Clone also
// the text-insets here, this is for the Undo-facility!
/* activates all lines and sets all widths to 0 */
-void LyXTabular::Init(int rows_arg, int columns_arg, LyXTabular const * lt)
+void LyXTabular::Init(BufferParams const & bp,
+ int rows_arg, int columns_arg, LyXTabular const * lt)
{
rows_ = rows_arg;
columns_ = columns_arg;
row_info = row_vector(rows_, rowstruct());
column_info = column_vector(columns_, columnstruct());
- cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct()));
+ cell_info = cell_vvector(rows_, cell_vector(columns_, cellstruct(bp)));
if (lt) {
operator=(*lt);
}
-void LyXTabular::AppendRow(int cell)
+void LyXTabular::AppendRow(BufferParams const & bp, int cell)
{
++rows_;
row_vector::iterator rit = row_info.begin() + row;
row_info.insert(rit, rowstruct());
// now set the values of the row before
- row_info[row] = row_info[row+1];
+ row_info[row] = row_info[row + 1];
#if 0
cell_vvector::iterator cit = cell_info.begin() + row;
- cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
+ cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct(bp)));
#else
cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
- cellstruct()));
+ cellstruct(bp)));
for (int i = 0; i <= row; ++i) {
for (int j = 0; j < columns_; ++j) {
}
-void LyXTabular::AppendColumn(int cell)
+void LyXTabular::AppendColumn(BufferParams const & bp, int cell)
{
++columns_;
cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
- cellstruct()));
+ cellstruct(bp)));
int const column = column_of_cell(cell);
column_vector::iterator cit = column_info.begin() + column + 1;
column_info.insert(cit, columnstruct());
// set the column values of the column before
- column_info[column+1] = column_info[column];
+ column_info[column + 1] = column_info[column];
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j <= column; ++j) {
l_getline(is, line);
if (!prefixIs(line, "<lyxtabular ")
&& !prefixIs(line, "<LyXTabular ")) {
- OldFormatRead(lex, line);
+ OldFormatRead(buf->params, lex, line);
return;
}
row_info[--fhr].endfirsthead = true;
row_info[fhr].endhead = false;
}
- } else if (row_info[fhr-1].endhead) {
+ } else if (row_info[fhr - 1].endhead) {
endfirsthead.empty = true;
} else {
while((fhr > 0) && !row_info[--fhr].endhead) {
row_info[fr].endfoot = true;
row_info[fr].endfirsthead = false;
}
- } else if (!row_info[fr-1].endhead && !row_info[fr-1].endfirsthead) {
+ } else if (!row_info[fr - 1].endhead && !row_info[fr - 1].endfirsthead) {
while((fr > 0) && !row_info[--fr].endhead &&
!row_info[fr].endfirsthead)
{
}
// set lastfooter info
if (lfr && (lfr < rows_)) {
- if (row_info[lfr].endhead && row_info[lfr-1].endhead) {
+ if (row_info[lfr].endhead && row_info[lfr - 1].endhead) {
while((lfr > 0) && !row_info[--lfr].endhead) {
row_info[lfr].endlastfoot = true;
row_info[lfr].endhead = false;
}
} else if (row_info[lfr].endfirsthead &&
- row_info[lfr-1].endfirsthead)
+ row_info[lfr - 1].endfirsthead)
{
while((lfr > 0) && !row_info[--lfr].endfirsthead) {
row_info[lfr].endlastfoot = true;
row_info[lfr].endfirsthead = false;
}
- } else if (row_info[lfr].endfoot && row_info[lfr-1].endfoot) {
+ } else if (row_info[lfr].endfoot
+ && row_info[lfr - 1].endfoot) {
while((lfr > 0) && !row_info[--lfr].endfoot) {
row_info[lfr].endlastfoot = true;
row_info[lfr].endfoot = false;
}
- } else if (!row_info[fr-1].endhead && !row_info[fr-1].endfirsthead &&
- !row_info[fr-1].endfoot)
+ } else if (!row_info[fr - 1].endhead
+ && !row_info[fr - 1].endfirsthead &&
+ !row_info[fr - 1].endfoot)
{
while((lfr > 0) &&
!row_info[--lfr].endhead && !row_info[lfr].endfirsthead &&
}
void LyXTabular::ReadNew(Buffer const * buf, istream & is,
- LyXLex & lex, string const & l, int const version)
+ LyXLex & lex, string const & l, int const version)
{
string line(l);
int rows_arg;
int columns_arg;
if (!getTokenValue(line, "columns", columns_arg))
return;
- Init(rows_arg, columns_arg);
+ Init(buf->params, rows_arg, columns_arg);
l_getline(is, line);
if (!prefixIs(line, "<features")) {
lyxerr << "Wrong tabular format (expected <features ...> got" <<
}
-void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
+void LyXTabular::OldFormatRead(BufferParams const & bp,
+ LyXLex & lex, string const & fl)
{
int version;
int i;
>> rotate_arg >> a >> b >> c >> d;
} else
is >> rows_arg >> columns_arg;
- Init(rows_arg, columns_arg);
+ Init(bp, rows_arg, columns_arg);
cont_row_info = vector<int>(rows_arg);
SetLongTabular(is_long_tabular_arg);
SetRotateTabular(rotate_arg);
} else {
is >> rows_arg >> columns_arg >> is_long_tabular_arg
>> rotate_arg >> a >> b >> c >> d;
- Init(rows_arg, columns_arg);
+ Init(bp, rows_arg, columns_arg);
cont_row_info = vector<int>(rows_arg);
SetLongTabular(is_long_tabular_arg);
SetRotateTabular(rotate_arg);
/* konstruktor */
///
- LyXTabular(InsetTabular *, int columns_arg, int rows_arg);
+ LyXTabular(BufferParams const &,
+ InsetTabular *, int columns_arg, int rows_arg);
///
- LyXTabular(InsetTabular *, LyXTabular const &, bool same_id = false);
+ LyXTabular(BufferParams const &,
+ InsetTabular *, LyXTabular const &, bool same_id = false);
///
explicit
LyXTabular(Buffer const *, InsetTabular *, LyXLex & lex);
///
LyXTabular & operator=(LyXTabular const &);
///
- LyXTabular * clone(InsetTabular *, bool same_id = false);
+ LyXTabular * clone(BufferParams const &,
+ InsetTabular *, bool same_id = false);
/// Returns true if there is a topline, returns false if not
bool TopLine(int cell, bool onlycolumn = false) const;
///
int GetBeginningOfTextInCell(int cell) const;
///
- void AppendRow(int cell);
+ void AppendRow(BufferParams const &, int cell);
///
void DeleteRow(int row);
///
- void AppendColumn(int cell);
+ void AppendColumn(BufferParams const &, int cell);
///
void DeleteColumn(int column);
///
///
void Read(Buffer const *, LyXLex &);
///
- void OldFormatRead(LyXLex &, string const &);
+ void OldFormatRead(BufferParams const &, LyXLex &, string const &);
///
int latex(Buffer const *, std::ostream &, bool, bool) const;
///
///
struct cellstruct {
///
- cellstruct();
+ cellstruct(BufferParams const &);
///
int cellno;
///
InsetTabular * owner_;
///
- void Init(int columns_arg, int rows_arg, LyXTabular const * lt = 0);
+ void Init(BufferParams const &,
+ int columns_arg, int rows_arg, LyXTabular const * lt = 0);
///
void Reinit(bool reset_widths = true);
///
Row * LyXText::getRowNearY(int & y) const
{
+#if 1
// If possible we should optimize this method. (Lgb)
Row * tmprow = firstrow;
int tmpy = 0;
}
y = tmpy; // return the real y
+
+ lyxerr << "returned y = " << y << endl;
+
return tmprow;
+#else
+ // Search from the current cursor position.
+
+ Row * tmprow = cursor.row();
+ int tmpy = cursor.y() - tmprow->baseline();
+
+ lyxerr << "cursor.y() = " << tmpy << endl;
+ lyxerr << "tmprow->height() = " << tmprow->height() << endl;
+ lyxerr << "tmprow->baseline() = " << tmprow->baseline() << endl;
+ lyxerr << "first = " << first << endl;
+ lyxerr << "y = " << y << endl;
+
+ if (y < tmpy) {
+ lyxerr << "up" << endl;
+#if 0
+ while (tmprow && tmpy - tmprow->height() >= y) {
+ tmpy -= tmprow->height();
+ tmprow = tmprow->previous();
+ }
+#else
+ do {
+ tmpy -= tmprow->height();
+ tmprow = tmprow->previous();
+ } while (tmprow && tmpy - tmprow->height() >= y);
+#endif
+ } else if (y > tmpy) {
+ lyxerr << "down" << endl;
+
+ while (tmprow->next() && tmpy + tmprow->height() <= y) {
+ tmpy += tmprow->height();
+ tmprow = tmprow->next();
+ }
+ } else {
+ lyxerr << "equal" << endl;
+ }
+
+ y = tmpy; // return the real y
+
+ lyxerr << "returned y = " << y << endl;
+
+ return tmprow;
+
+#endif
}
LyXText::LyXText(BufferView * bv)
- : number_of_rows(0), height(0), width(0), first(0),
+ : number_of_rows(0), height(0), width(0), first_y(0),
bv_owner(bv), inset_owner(0), the_locking_inset(0),
need_break_row(0), refresh_y(0), refresh_row(0),
status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
LyXText::LyXText(InsetText * inset)
- : number_of_rows(0), height(0), width(0), first(0),
+ : number_of_rows(0), height(0), width(0), first_y(0),
bv_owner(0), inset_owner(inset), the_locking_inset(0),
need_break_row(0), refresh_y(0), refresh_row(0),
status_(LyXText::UNCHANGED), firstrow(0), lastrow(0)
delete firstrow;
firstrow = tmprow;
}
- lastrow = refresh_row = need_break_row = 0;
+
+ lastrow = 0;
+ refresh_row = 0;
+ need_break_row = 0;
width = height = 0;
copylayouttype.erase();
- number_of_rows = first = refresh_y = 0;
+ number_of_rows = first_y = refresh_y = 0;
status_ = LyXText::UNCHANGED;
} else if (firstrow)
return;
Paragraph * par = ownerParagraph();
current_font = getFont(bview->buffer(), par, 0);
+
while (par) {
insertParagraph(bview, par, lastrow);
par = par->next();