mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
move some stuff from BufferView_pimpl.C to text3.C and lose a few lines...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5072 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4df4a61701
commit
107ecefbad
@ -122,18 +122,6 @@ void BufferView::redoCurrentBuffer()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::cursorPrevious(LyXText * text)
|
||||
{
|
||||
pimpl_->cursorPrevious(text);
|
||||
}
|
||||
|
||||
|
||||
void BufferView::cursorNext(LyXText * text)
|
||||
{
|
||||
pimpl_->cursorNext(text);
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::available() const
|
||||
{
|
||||
return pimpl_->available();
|
||||
|
@ -82,10 +82,6 @@ public:
|
||||
///
|
||||
void redoCurrentBuffer();
|
||||
///
|
||||
void cursorPrevious(LyXText *);
|
||||
///
|
||||
void cursorNext(LyXText *);
|
||||
///
|
||||
bool available() const;
|
||||
///
|
||||
LyXView * owner() const;
|
||||
|
@ -1083,113 +1083,6 @@ void BufferView::Pimpl::cursorToggle()
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::cursorPrevious(LyXText * text)
|
||||
{
|
||||
if (!text->cursor.row()->previous()) {
|
||||
if (text->first_y > 0) {
|
||||
int new_y = bv_->text->first_y - workarea().workHeight();
|
||||
screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
|
||||
updateScrollbar();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int y = text->first_y;
|
||||
Row * cursorrow = text->cursor.row();
|
||||
|
||||
text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y);
|
||||
finishUndo();
|
||||
|
||||
int new_y;
|
||||
if (cursorrow == bv_->text->cursor.row()) {
|
||||
// we have a row which is higher than the workarea so we leave the
|
||||
// cursor on the start of the row and move only the draw up as soon
|
||||
// as we move the cursor or do something while inside the row (it may
|
||||
// span several workarea-heights) we'll move to the top again, but this
|
||||
// is better than just jump down and only display part of the row.
|
||||
new_y = bv_->text->first_y - workarea().workHeight();
|
||||
} else {
|
||||
if (text->inset_owner) {
|
||||
new_y = bv_->text->cursor.iy()
|
||||
+ bv_->theLockingInset()->insetInInsetY() + y
|
||||
+ text->cursor.row()->height()
|
||||
- workarea().workHeight() + 1;
|
||||
} else {
|
||||
new_y = text->cursor.y()
|
||||
- text->cursor.row()->baseline()
|
||||
+ text->cursor.row()->height()
|
||||
- workarea().workHeight() + 1;
|
||||
}
|
||||
}
|
||||
screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
|
||||
if (text->cursor.row()->previous()) {
|
||||
LyXCursor cur;
|
||||
text->setCursor(bv_, cur, text->cursor.row()->previous()->par(),
|
||||
text->cursor.row()->previous()->pos(), false);
|
||||
if (cur.y() > text->first_y) {
|
||||
text->cursorUp(bv_, true);
|
||||
}
|
||||
}
|
||||
updateScrollbar();
|
||||
}
|
||||
|
||||
|
||||
void BufferView::Pimpl::cursorNext(LyXText * text)
|
||||
{
|
||||
if (!text->cursor.row()->next()) {
|
||||
int y = text->cursor.y() - text->cursor.row()->baseline() +
|
||||
text->cursor.row()->height();
|
||||
if (y > int(text->first_y + workarea().workHeight())) {
|
||||
screen().draw(bv_->text, bv_,
|
||||
bv_->text->first_y + workarea().workHeight());
|
||||
updateScrollbar();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int y = text->first_y + workarea().workHeight();
|
||||
if (text->inset_owner && !text->first_y) {
|
||||
y -= (bv_->text->cursor.iy()
|
||||
- bv_->text->first_y
|
||||
+ bv_->theLockingInset()->insetInInsetY());
|
||||
}
|
||||
|
||||
text->getRowNearY(y);
|
||||
|
||||
Row * cursorrow = text->cursor.row();
|
||||
text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y); // + workarea().workHeight());
|
||||
finishUndo();
|
||||
|
||||
int new_y;
|
||||
if (cursorrow == bv_->text->cursor.row()) {
|
||||
// we have a row which is higher than the workarea so we leave the
|
||||
// cursor on the start of the row and move only the draw down as soon
|
||||
// as we move the cursor or do something while inside the row (it may
|
||||
// span several workarea-heights) we'll move to the top again, but this
|
||||
// is better than just jump down and only display part of the row.
|
||||
new_y = bv_->text->first_y + workarea().workHeight();
|
||||
} else {
|
||||
if (text->inset_owner) {
|
||||
new_y = bv_->text->cursor.iy()
|
||||
+ bv_->theLockingInset()->insetInInsetY()
|
||||
+ y - text->cursor.row()->baseline();
|
||||
} else {
|
||||
new_y = text->cursor.y() - text->cursor.row()->baseline();
|
||||
}
|
||||
}
|
||||
screen().draw(bv_->text, bv_, new_y);
|
||||
if (text->cursor.row()->next()) {
|
||||
LyXCursor cur;
|
||||
text->setCursor(bv_, cur, text->cursor.row()->next()->par(),
|
||||
text->cursor.row()->next()->pos(), false);
|
||||
if (cur.y() < int(text->first_y + workarea().workHeight())) {
|
||||
text->cursorDown(bv_, true);
|
||||
}
|
||||
}
|
||||
updateScrollbar();
|
||||
}
|
||||
|
||||
|
||||
bool BufferView::Pimpl::available() const
|
||||
{
|
||||
if (buffer_ && bv_->text)
|
||||
|
@ -92,10 +92,6 @@ struct BufferView::Pimpl : public boost::signals::trackable {
|
||||
///
|
||||
void cursorToggle();
|
||||
///
|
||||
void cursorPrevious(LyXText *);
|
||||
///
|
||||
void cursorNext(LyXText *);
|
||||
///
|
||||
bool available() const;
|
||||
///
|
||||
void beforeChange(LyXText *);
|
||||
|
@ -39,8 +39,6 @@ void WriteStream::addlines(unsigned int n)
|
||||
|
||||
void WriteStream::pendingSpace(bool how)
|
||||
{
|
||||
if (how)
|
||||
os_ << ' ';
|
||||
pendingspace_ = how;
|
||||
}
|
||||
|
||||
@ -61,11 +59,6 @@ WriteStream & operator<<(WriteStream & ws, MathArray const & ar)
|
||||
|
||||
WriteStream & operator<<(WriteStream & ws, char const * s)
|
||||
{
|
||||
if (ws.pendingSpace()) {
|
||||
lyxerr << "writing a space in a string\n";
|
||||
ws.os() << ' ';
|
||||
ws.pendingSpace(false);
|
||||
}
|
||||
ws.os() << s;
|
||||
ws.addlines(int(lyx::count(s, s + strlen(s), '\n')));
|
||||
return ws;
|
||||
@ -75,12 +68,8 @@ WriteStream & operator<<(WriteStream & ws, char const * s)
|
||||
WriteStream & operator<<(WriteStream & ws, char c)
|
||||
{
|
||||
if (ws.pendingSpace()) {
|
||||
//if (isalpha(c))
|
||||
// ws.os() << ' ';
|
||||
if (!isalpha(c)) {
|
||||
lyxerr << "I'd like to suppress writing a space\n";
|
||||
}
|
||||
ws.os() << ' ';
|
||||
if (isalpha(c))
|
||||
ws.os() << ' ';
|
||||
ws.pendingSpace(false);
|
||||
}
|
||||
ws.os() << c;
|
||||
|
@ -323,11 +323,8 @@ MathInset::result_type MathNestInset::dispatch
|
||||
switch (cmd.action) {
|
||||
|
||||
case LFUN_PASTE: {
|
||||
lyxerr << "pasting '" << cmd.argument << "'\n";
|
||||
MathArray ar;
|
||||
mathed_parse_cell(ar, cmd.argument);
|
||||
lyxerr << "pasting '" << ar << "'\n";
|
||||
lyxerr << "cell(idx) '" << cell(idx) << "'\n";
|
||||
cell(idx).insert(pos, ar);
|
||||
pos += ar.size();
|
||||
return DISPATCHED;
|
||||
|
@ -105,7 +105,7 @@ void MathSpaceInset::octavize(OctaveStream & os) const
|
||||
|
||||
void MathSpaceInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[space " << int(space_) << ' ' << latex_mathspace[space_] << "] ";
|
||||
os << "[space " << int(space_) << "] ";
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,10 @@
|
||||
|
||||
WriteStream & operator<<(WriteStream & ws, string const & s)
|
||||
{
|
||||
if (ws.pendingSpace()) {
|
||||
ws.os() << ' ';
|
||||
ws.pendingSpace(false);
|
||||
}
|
||||
ws.os() << s;
|
||||
ws.addlines(int(lyx::count(s.begin(), s.end(), '\n')));
|
||||
return ws;
|
||||
|
122
src/text3.C
122
src/text3.C
@ -24,15 +24,129 @@
|
||||
#include "intl.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "frontends/LyXView.h"
|
||||
#include "frontends/screen.h"
|
||||
#include "frontends/WorkArea.h"
|
||||
#include "insets/insetspecialchar.h"
|
||||
#include "insets/insettext.h"
|
||||
#include "undo_funcs.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
extern string current_layout;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void cursorPrevious(LyXText * text, BufferView * bv)
|
||||
{
|
||||
if (!text->cursor.row()->previous()) {
|
||||
if (text->first_y > 0) {
|
||||
int new_y = bv->text->first_y - bv->workarea().workHeight();
|
||||
bv->screen().draw(bv->text, bv, new_y < 0 ? 0 : new_y);
|
||||
bv->updateScrollbar();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int y = text->first_y;
|
||||
Row * cursorrow = text->cursor.row();
|
||||
|
||||
text->setCursorFromCoordinates(bv, text->cursor.x_fix(), y);
|
||||
finishUndo();
|
||||
|
||||
int new_y;
|
||||
if (cursorrow == bv->text->cursor.row()) {
|
||||
// we have a row which is higher than the workarea so we leave the
|
||||
// cursor on the start of the row and move only the draw up as soon
|
||||
// as we move the cursor or do something while inside the row (it may
|
||||
// span several workarea-heights) we'll move to the top again, but this
|
||||
// is better than just jump down and only display part of the row.
|
||||
new_y = bv->text->first_y - bv->workarea().workHeight();
|
||||
} else {
|
||||
if (text->inset_owner) {
|
||||
new_y = bv->text->cursor.iy()
|
||||
+ bv->theLockingInset()->insetInInsetY() + y
|
||||
+ text->cursor.row()->height()
|
||||
- bv->workarea().workHeight() + 1;
|
||||
} else {
|
||||
new_y = text->cursor.y()
|
||||
- text->cursor.row()->baseline()
|
||||
+ text->cursor.row()->height()
|
||||
- bv->workarea().workHeight() + 1;
|
||||
}
|
||||
}
|
||||
bv->screen().draw(bv->text, bv, new_y < 0 ? 0 : new_y);
|
||||
if (text->cursor.row()->previous()) {
|
||||
LyXCursor cur;
|
||||
text->setCursor(bv, cur, text->cursor.row()->previous()->par(),
|
||||
text->cursor.row()->previous()->pos(), false);
|
||||
if (cur.y() > text->first_y) {
|
||||
text->cursorUp(bv, true);
|
||||
}
|
||||
}
|
||||
bv->updateScrollbar();
|
||||
}
|
||||
|
||||
|
||||
void cursorNext(LyXText * text, BufferView * bv)
|
||||
{
|
||||
if (!text->cursor.row()->next()) {
|
||||
int y = text->cursor.y() - text->cursor.row()->baseline() +
|
||||
text->cursor.row()->height();
|
||||
if (y > int(text->first_y + bv->workarea().workHeight())) {
|
||||
bv->screen().draw(bv->text, bv,
|
||||
bv->text->first_y + bv->workarea().workHeight());
|
||||
bv->updateScrollbar();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int y = text->first_y + bv->workarea().workHeight();
|
||||
if (text->inset_owner && !text->first_y) {
|
||||
y -= (bv->text->cursor.iy()
|
||||
- bv->text->first_y
|
||||
+ bv->theLockingInset()->insetInInsetY());
|
||||
}
|
||||
|
||||
text->getRowNearY(y);
|
||||
|
||||
Row * cursorrow = text->cursor.row();
|
||||
text->setCursorFromCoordinates(bv, text->cursor.x_fix(), y);
|
||||
// + workarea().workHeight());
|
||||
finishUndo();
|
||||
|
||||
int new_y;
|
||||
if (cursorrow == bv->text->cursor.row()) {
|
||||
// we have a row which is higher than the workarea so we leave the
|
||||
// cursor on the start of the row and move only the draw down as soon
|
||||
// as we move the cursor or do something while inside the row (it may
|
||||
// span several workarea-heights) we'll move to the top again, but this
|
||||
// is better than just jump down and only display part of the row.
|
||||
new_y = bv->text->first_y + bv->workarea().workHeight();
|
||||
} else {
|
||||
if (text->inset_owner) {
|
||||
new_y = bv->text->cursor.iy()
|
||||
+ bv->theLockingInset()->insetInInsetY()
|
||||
+ y - text->cursor.row()->baseline();
|
||||
} else {
|
||||
new_y = text->cursor.y() - text->cursor.row()->baseline();
|
||||
}
|
||||
}
|
||||
bv->screen().draw(bv->text, bv, new_y);
|
||||
if (text->cursor.row()->next()) {
|
||||
LyXCursor cur;
|
||||
text->setCursor(bv, cur, text->cursor.row()->next()->par(),
|
||||
text->cursor.row()->next()->pos(), false);
|
||||
if (cur.y() < int(text->first_y + bv->workarea().workHeight())) {
|
||||
text->cursorDown(bv, true);
|
||||
}
|
||||
}
|
||||
bv->updateScrollbar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LyXText::update(BufferView * bv, bool changed)
|
||||
{
|
||||
BufferView::UpdateCodes c = BufferView::SELECT | BufferView::FITCUR;
|
||||
@ -197,13 +311,13 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
|
||||
case LFUN_PRIORSEL:
|
||||
update(bv, false);
|
||||
bv->cursorPrevious(this);
|
||||
cursorPrevious(this, bv);
|
||||
bv->finishChange(true);
|
||||
break;
|
||||
|
||||
case LFUN_NEXTSEL:
|
||||
update(bv, false);
|
||||
bv->cursorNext(this);
|
||||
cursorNext(this, bv);
|
||||
bv->finishChange();
|
||||
break;
|
||||
|
||||
@ -319,7 +433,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
if (!selection.mark())
|
||||
bv->beforeChange(this);
|
||||
bv->update(this, BufferView::UPDATE);
|
||||
bv->cursorPrevious(this);
|
||||
cursorPrevious(this, bv);
|
||||
bv->finishChange(false);
|
||||
// was:
|
||||
// finishUndo();
|
||||
@ -331,7 +445,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
|
||||
if (!selection.mark())
|
||||
bv->beforeChange(this);
|
||||
bv->update(this, BufferView::UPDATE);
|
||||
bv->cursorNext(this);
|
||||
cursorNext(this, bv);
|
||||
bv->finishChange(false);
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user