#include "bufferview_funcs.h"
#include "TextCache.h"
#include "bufferlist.h"
-#include "lyx_gui_misc.h"
#include "lyxrc.h"
#include "intl.h"
// added for Dispatch functions
#include <clocale>
-extern lyx::layout_type current_layout;
+extern string current_layout;
using std::vector;
using std::find_if;
using SigC::slot;
using lyx::pos_type;
-using lyx::layout_type;
using lyx::textclass_type;
/* the selection possible is needed, that only motion events are
extern BufferList bufferlist;
extern char ascii_type;
-extern void sigchldchecker(pid_t pid, int * status);
extern int bibitemMaxWidth(BufferView *, LyXFont const &);
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);
-#if 0
+ bv_->text->first_y = screen_->topCursorVisible(bv_->text);
+ // please tell me WHY the heck you deactivated this code, whoever
+ // 'you' are (Jug 20020311)
+#if 1
buffer_->resizeInsets(bv_);
#endif
// this will scroll the screen such that the cursor becomes visible
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;
selection_possible = false;
owner_->updateLayoutChoice();
owner_->message(inset->editMessage());
+ // IMO the inset has to be first in edit-mode and then we send the
+ // button press. (Jug 20020222)
+ inset->edit(bv_); //, xpos, ypos, button);
inset->insetButtonPress(bv_, xpos, ypos, button);
- inset->edit(bv_, xpos, ypos, button);
return;
}
void BufferView::Pimpl::selectionLost()
{
- hideCursor();
- toggleSelection();
- bv_->getLyXText()->clearSelection();
- showCursor();
+ if (active() && available()) {
+ hideCursor();
+ toggleSelection();
+ bv_->getLyXText()->clearSelection();
+ showCursor();
+ }
}
// Did we hit an editable inset?
if (inset_hit) {
- // Inset like error, notes and figures
selection_possible = false;
// if we reach this point with a selection, it
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
- bibitemMaxWidth(bv_, textclasslist.
- TextClass(buffer_->
- params.textclass).defaultfont())) {
+ bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) {
bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, 0);
}
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);
// Callback for cursor timer
void BufferView::Pimpl::cursorToggle()
{
- // Quite a nice place for asyncron Inset updating, isn't it?
- // Actually no! This is run even if no buffer exist... so (Lgb)
if (!buffer_) {
cursor_timeout.restart();
return;
}
- int status = 1;
- int const pid = waitpid(static_cast<pid_t>(0), &status, WNOHANG);
- if (pid == -1) // error find out what is wrong
- ; // ignore it for now.
- else if (pid > 0)
- sigchldchecker(pid, &status);
-
- updatelist.update(bv_);
-
if (!screen_.get()) {
cursor_timeout.restart();
return;
}
+ /* FIXME */
+ extern void reapSpellchecker(void);
+ reapSpellchecker();
+
if (!bv_->theLockingInset()) {
screen_->cursorToggle(bv_);
} else {
if (!text->cursor.row()->previous())
return;
- int y = text->first;
- if (text->inset_owner)
- y += bv_->text->first;
+ int y = text->first_y;
Row * cursorrow = text->cursor.row();
+
text->setCursorFromCoordinates(bv_, bv_->text->cursor.x_fix(), y);
finishUndo();
// This is to allow jumping over large insets
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);
bool BufferView::Pimpl::available() const
{
- if (buffer_ && bv_->text) return true;
+ if (buffer_ && bv_->text)
+ return true;
return false;
}
break;
}
- case LFUN_TABULAR_FEATURE:
case LFUN_SCROLL_INSET:
// this is not handled here as this funktion is only aktive
// if we have a locking_inset and that one is (or contains)
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
textclass_type tclass = buffer_->params.textclass;
- pair <bool, layout_type> layout =
- textclasslist.NumberOfLayout(tclass, argument);
+ bool hasLayout =
+ textclasslist[tclass].hasLayout(argument);
+ string layout = argument;
// If the entry is obsolete, use the new one instead.
- if (layout.first) {
- string obs = textclasslist.Style(tclass, layout.second)
+ if (hasLayout) {
+ string const & obs = textclasslist[tclass][layout]
.obsoleted_by();
if (!obs.empty())
- layout = textclasslist.NumberOfLayout(tclass, obs);
+ layout = obs;
}
- // see if we found the layout number:
- if (!layout.first) {
+ if (!hasLayout) {
owner_->getLyXFunc()->setErrorMessage(
string(N_("Layout ")) + argument +
N_(" not known"));
break;
}
- if (current_layout != layout.second) {
+ if (current_layout != layout) {
LyXText * lt = bv_->getLyXText();
hideCursor();
- current_layout = layout.second;
+ current_layout = layout;
update(lt,
BufferView::SELECT
| BufferView::FITCUR);
- lt->setLayout(bv_, layout.second);
- owner_->setLayout(layout.second);
+ lt->setLayout(bv_, layout);
+ owner_->setLayout(layout);
update(lt,
BufferView::SELECT
| BufferView::FITCUR
{
LyXText * lt = bv_->getLyXText();
- LyXLayout const & style = textclasslist
- .Style(buffer_->params.textclass,
- lt->cursor.par()->getLayout());
+ LyXLayout const & style = textclasslist[buffer_->params.textclass][lt->cursor.par()->layout()];
if (style.free_spacing) {
lt->insertChar(bv_, ' ');
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);
break;
case LFUN_GETLAYOUT:
- owner_->getLyXFunc()->setMessage(tostr(bv_->getLyXText()->cursor.par()->layout));
+ owner_->getLyXFunc()->setMessage(tostr(bv_->getLyXText()->cursor.par()->layout()));
break;
case LFUN_GETFONT:
hideCursor();
- LyXLayout const & style = textclasslist.Style(
- bv_->buffer()->params.textclass, par->getLayout());
+ LyXLayout const & style =
+ textclasslist[bv_->buffer()->params.textclass][par->layout()];
if (style.pass_thru ||
(!insertInset(new InsetQuotes(c, bv_->buffer()->params))))
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
}
- pair<bool, layout_type> lres =
- textclasslist.NumberOfLayout(buffer_->params .textclass, lout);
- layout_type lay = 0;
- if (lres.first != false) {
+ string lres = lout;
+ LyXTextClass const & tclass =
+ textclasslist[buffer_->params.textclass];
+ bool hasLayout = tclass.hasLayout(lres);
+ string lay = tclass.defaultLayoutName();
+
+ if (hasLayout != false) {
// layout found
- lay = lres.second;
+ lay = lres;
} else {
- // layout not fount using default "Standard" (0)
- lay = 0;
+ // layout not fount using default
+ lay = tclass.defaultLayoutName();
}
-
+
bv_->text->setLayout(bv_, lay);
bv_->text->setParagraph(bv_, 0, 0,
void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
{
- if (!inset)
+ if (!inset || !available())
return;
// first check for locking insets
}
}
- // then check the current buffer
- if (available()) {
- hideCursor();
+ // then check if the inset is a top_level inset (has no owner)
+ // if yes do the update as always otherwise we have to update the
+ // toplevel inset where this inset is inside
+ Inset * tl_inset = inset;
+ while(tl_inset->owner())
+ tl_inset = tl_inset->owner();
+ hideCursor();
+ if (tl_inset == inset) {
update(bv_->text, BufferView::UPDATE);
if (bv_->text->updateInset(bv_, inset)) {
if (mark_dirty) {
}
return;
}
+ } else if (static_cast<UpdatableInset *>(tl_inset)
+ ->updateInsetInInset(bv_, inset))
+ {
+ if (bv_->text->updateInset(bv_, tl_inset)) {
+ update();
+ updateScrollbar();
+ }
}
}