mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
fitcursor work
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8591 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5d2127ac8e
commit
0d47b55a84
@ -379,23 +379,10 @@ void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
|
|||||||
par[i].inset().edit(cursor(), true);
|
par[i].inset().edit(cursor(), true);
|
||||||
|
|
||||||
cursor().setCursor(makeDocIterator(par, pos), false);
|
cursor().setCursor(makeDocIterator(par, pos), false);
|
||||||
|
par[0].text()->redoParagraph(par[0].par());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if the fitCursor call refers to some point in never-explored-land, then we
|
|
||||||
don't have y information in insets there, then we cannot even do an update
|
|
||||||
to get it (because we need the y infomation for setting top_y first). So
|
|
||||||
this is solved in putSelectionAt with:
|
|
||||||
|
|
||||||
- setting top_y to the y of the outerPar (that has good info)
|
|
||||||
- calling update
|
|
||||||
- calling cursor().updatePos()
|
|
||||||
- then call fitCursor()
|
|
||||||
|
|
||||||
Ab.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void BufferView::putSelectionAt(DocIterator const & cur,
|
void BufferView::putSelectionAt(DocIterator const & cur,
|
||||||
int length, bool backwards)
|
int length, bool backwards)
|
||||||
{
|
{
|
||||||
@ -403,16 +390,8 @@ void BufferView::putSelectionAt(DocIterator const & cur,
|
|||||||
|
|
||||||
cursor().clearSelection();
|
cursor().clearSelection();
|
||||||
|
|
||||||
LyXText & text = *cur[0].text();
|
|
||||||
setCursor(par, cur.pos());
|
setCursor(par, cur.pos());
|
||||||
|
|
||||||
// hack for the chicken and egg problem
|
|
||||||
top_y(text.getPar(par.outerPar()).y);
|
|
||||||
|
|
||||||
update();
|
|
||||||
//text.setCursor(cursor(), cur.par(), cur.pos());
|
|
||||||
cursor().updatePos();
|
|
||||||
|
|
||||||
if (length) {
|
if (length) {
|
||||||
if (backwards) {
|
if (backwards) {
|
||||||
cursor().setSelection(cursor(), -length);
|
cursor().setSelection(cursor(), -length);
|
||||||
@ -424,7 +403,6 @@ void BufferView::putSelectionAt(DocIterator const & cur,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fitCursor();
|
fitCursor();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,11 +355,14 @@ void BufferView::Pimpl::setBuffer(Buffer * b)
|
|||||||
lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
|
lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool BufferView::Pimpl::fitCursor()
|
bool BufferView::Pimpl::fitCursor()
|
||||||
{
|
{
|
||||||
|
// this is enough to get the right y cursor info for fitCursor
|
||||||
|
cursor_.top().text()->redoParagraph(cursor_.top().par());
|
||||||
|
|
||||||
if (!screen().fitCursor(bv_))
|
if (!screen().fitCursor(bv_))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
updateScrollbar();
|
updateScrollbar();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -388,7 +391,6 @@ void BufferView::Pimpl::resizeCurrentBuffer()
|
|||||||
|
|
||||||
text->init(bv_);
|
text->init(bv_);
|
||||||
update();
|
update();
|
||||||
bv_->cursor().updatePos();
|
|
||||||
fitCursor();
|
fitCursor();
|
||||||
|
|
||||||
switchKeyMap();
|
switchKeyMap();
|
||||||
@ -892,14 +894,12 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd0)
|
|||||||
|
|
||||||
// If the request was dispatched the temp cursor should have been
|
// If the request was dispatched the temp cursor should have been
|
||||||
// in a way to be used as new 'real' cursor.
|
// in a way to be used as new 'real' cursor.
|
||||||
if (res.dispatched())
|
if (res.dispatched()) {
|
||||||
bv_->cursor() = cur;
|
bv_->cursor() = cur;
|
||||||
|
|
||||||
// Redraw if requested or necessary.
|
// Redraw if requested or necessary.
|
||||||
if (res.update())
|
if (fitCursor() || res.update())
|
||||||
update();
|
|
||||||
if (fitCursor())
|
|
||||||
update();
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
// see workAreaKeyPress
|
// see workAreaKeyPress
|
||||||
cursor_timeout.restart();
|
cursor_timeout.restart();
|
||||||
|
@ -1,4 +1,18 @@
|
|||||||
|
|
||||||
|
2004-04-03 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
|
* cursor.[Ch] (LCursor): remove cached_y_ and updatePos
|
||||||
|
(getDim) remove outdated comment
|
||||||
|
|
||||||
|
* BufferView_pimpl.C (fitCursor): call redoParagraph on the outer
|
||||||
|
cursor paragraph to obtain good cursor y info
|
||||||
|
(workAreaDispatch): remove unneeded update call
|
||||||
|
|
||||||
|
* BufferView.C (setCursor): call redoParagraph, as some insets
|
||||||
|
could have been opened
|
||||||
|
(putSelectionAt): remove the double update and all that cleverness
|
||||||
|
(simplified and transfered to fitCursor where it belongs).
|
||||||
|
|
||||||
2004-04-01 Alfredo Braunstein <abraunst@lyx.org>
|
2004-04-01 Alfredo Braunstein <abraunst@lyx.org>
|
||||||
|
|
||||||
* text3.C (getStatus): add LFUN_BEGINNINGBUF
|
* text3.C (getStatus): add LFUN_BEGINNINGBUF
|
||||||
|
23
src/cursor.C
23
src/cursor.C
@ -84,8 +84,7 @@ void region(CursorSlice const & i1, CursorSlice const & i2,
|
|||||||
|
|
||||||
|
|
||||||
LCursor::LCursor(BufferView & bv)
|
LCursor::LCursor(BufferView & bv)
|
||||||
: DocIterator(), bv_(&bv),
|
: DocIterator(), bv_(&bv), anchor_(), x_target_(-1),
|
||||||
anchor_(), cached_y_(0), x_target_(-1),
|
|
||||||
selection_(false), mark_(false)
|
selection_(false), mark_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -95,7 +94,6 @@ void LCursor::reset(InsetBase & inset)
|
|||||||
clear();
|
clear();
|
||||||
push_back(CursorSlice(inset));
|
push_back(CursorSlice(inset));
|
||||||
anchor_ = DocIterator(inset);
|
anchor_ = DocIterator(inset);
|
||||||
cached_y_ = 0;
|
|
||||||
clearTargetX();
|
clearTargetX();
|
||||||
selection_ = false;
|
selection_ = false;
|
||||||
mark_ = false;
|
mark_ = false;
|
||||||
@ -236,15 +234,6 @@ int LCursor::currentMode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LCursor::updatePos()
|
|
||||||
{
|
|
||||||
BOOST_ASSERT(!empty());
|
|
||||||
if (size() > 1)
|
|
||||||
cached_y_ = bv().top_y() + back().inset().yo();
|
|
||||||
//cached_y_ = back().inset().yo();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LCursor::getDim(int & asc, int & des) const
|
void LCursor::getDim(int & asc, int & des) const
|
||||||
{
|
{
|
||||||
if (inMathed()) {
|
if (inMathed()) {
|
||||||
@ -270,16 +259,6 @@ void LCursor::getPos(int & x, int & y) const
|
|||||||
y = 0;
|
y = 0;
|
||||||
if (!empty())
|
if (!empty())
|
||||||
inset().getCursorPos(back(), x, y);
|
inset().getCursorPos(back(), x, y);
|
||||||
// getCursorPos gives _screen_ coordinates. We need to add
|
|
||||||
// top_y to get document coordinates. This is hidden in cached_y_.
|
|
||||||
//y += cached_y_ - inset().yo();
|
|
||||||
// The rest is non-obvious. The reason we have to have these
|
|
||||||
// extra computation is that the getCursorPos() calls rely
|
|
||||||
// on the inset's own knowledge of its screen position.
|
|
||||||
// If we scroll up or down in a big enough increment,
|
|
||||||
// inset->draw() is not called: this doesn't update
|
|
||||||
// inset.yo_, so getCursor() returns an old value.
|
|
||||||
// Ugly as you like.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,8 +149,6 @@ public:
|
|||||||
CursorSlice & anchor();
|
CursorSlice & anchor();
|
||||||
/// access to selection anchor
|
/// access to selection anchor
|
||||||
CursorSlice const & anchor() const;
|
CursorSlice const & anchor() const;
|
||||||
/// cache the absolute coordinate from the top inset
|
|
||||||
void updatePos();
|
|
||||||
/// sets anchor to cursor position
|
/// sets anchor to cursor position
|
||||||
void resetAnchor();
|
void resetAnchor();
|
||||||
/// access to owning BufferView
|
/// access to owning BufferView
|
||||||
@ -187,8 +185,6 @@ public:
|
|||||||
DispatchResult disp_;
|
DispatchResult disp_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
|
||||||
int cached_y_;
|
|
||||||
/**
|
/**
|
||||||
* The target x position of the cursor. This is used for when
|
* The target x position of the cursor. This is used for when
|
||||||
* we have text like :
|
* we have text like :
|
||||||
|
@ -1362,7 +1362,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
|
|||||||
if (view()->available()) {
|
if (view()->available()) {
|
||||||
view()->fitCursor();
|
view()->fitCursor();
|
||||||
view()->update();
|
view()->update();
|
||||||
view()->cursor().updatePos();
|
|
||||||
// if we executed a mutating lfun, mark the buffer as dirty
|
// if we executed a mutating lfun, mark the buffer as dirty
|
||||||
if (getStatus(cmd).enabled()
|
if (getStatus(cmd).enabled()
|
||||||
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
|
&& !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
|
||||||
|
@ -1136,9 +1136,6 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
finishUndo();
|
finishUndo();
|
||||||
cur.x_target() = cursorX(cur.top());
|
cur.x_target() = cursorX(cur.top());
|
||||||
|
|
||||||
if (bv->fitCursor())
|
|
||||||
selection_possible = false;
|
|
||||||
|
|
||||||
// Insert primary selection with middle mouse
|
// Insert primary selection with middle mouse
|
||||||
// if there is a local selection in the current buffer,
|
// if there is a local selection in the current buffer,
|
||||||
// insert this
|
// insert this
|
||||||
|
Loading…
Reference in New Issue
Block a user