somewhat quick & dirty, but you get the idea.
I wouldn't expect it to work on corner cases ;)
qt frontend only.
Please tell me what do you think.
Alfredo
? save2
? save
Index: lyxtext.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/lyxtext.h,v
retrieving revision 1.139
diff -u -p -u -r1.139 lyxtext.h
--- lyxtext.h 2003/03/10 00:05:05 1.139
+++ lyxtext.h 2003/03/11 01:40:11
@@ -79,7 +79,13 @@ public:
mutable LyXFont current_font;
/// the current font
mutable LyXFont real_current_font;
+ /// query if we are about to break;
+ bool aboutToBreak() const;
+ /// set if we are about to break;
+ void aboutToBreak(bool breaking) const;
private:
+ /// we are in the middle of two pars
+ mutable bool breaking_;
/** the first visible row on screen
* declared mutable because removeRow is const
*/
Index: text.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text.C,v
retrieving revision 1.306
diff -u -p -u -r1.306 text.C
--- text.C 2003/03/10 05:03:31 1.306
+++ text.C 2003/03/11 01:40:18
@@ -1371,6 +1371,16 @@ void LyXText::breakAgainOneRow(BufferVie
}
+void LyXText::aboutToBreak(bool breaking) const
+{
+ breaking_ = breaking;
+}
+
+bool LyXText::aboutToBreak() const
+{
+ return breaking_ ;
+}
+
void LyXText::breakParagraph(BufferView * bview,
ParagraphList & paragraphs, char keep_layout)
{
@@ -1379,6 +1389,7 @@ void LyXText::breakParagraph(BufferView
&& cursor.par()->isChangeEdited(0, cursor.pos()))
return;
+
LyXTextClass const & tclass =
bview->buffer()->params.getLyXTextClass();
LyXLayout_ptr const & layout = cursor.par()->layout();
@@ -1411,8 +1422,8 @@ void LyXText::breakParagraph(BufferView
// paragraph before or behind and we should react on that one
// but we can fix this in 1.3.0 (Jug 20020509)
bool const isempty = (layout->keepempty && cursor.par()->empty());
- ::breakParagraph(bview->buffer()->params, paragraphs, cursor.par(), cursor.pos(),
- keep_layout);
+ ::breakParagraph(bview->buffer()->params, paragraphs,
+ cursor.par(), cursor.pos(), keep_layout);
// well this is the caption hack since one caption is really enough
if (layout->labeltype == LABEL_SENSITIVE) {
Index: text2.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text2.C,v
retrieving revision 1.285
diff -u -p -u -r1.285 text2.C
--- text2.C 2003/03/10 05:03:32 1.285
+++ text2.C 2003/03/11 01:40:22
@@ -1743,7 +1743,8 @@ bool LyXText::setCursor(BufferView * bvi
{
LyXCursor old_cursor = cursor;
setCursorIntern(bview, par, pos, setfont, boundary);
- return deleteEmptyParagraphMechanism(bview, old_cursor);
+ aboutToBreak(false);
+// return deleteEmptyParagraphMechanism(bview, old_cursor);
}
@@ -2061,7 +2062,8 @@ void LyXText::setCursorFromCoordinates(B
setCursorFromCoordinates(bview, cursor, x, y);
setCurrentFont(bview);
- deleteEmptyParagraphMechanism(bview, old_cursor);
+ aboutToBreak(false);
+// deleteEmptyParagraphMechanism(bview, old_cursor);
}
Index: text3.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/text3.C,v
retrieving revision 1.42
diff -u -p -u -r1.42 text3.C
--- text3.C 2003/03/09 09:38:47 1.42
+++ text3.C 2003/03/11 01:40:24
@@ -828,6 +828,14 @@ Inset::RESULT LyXText::dispatch(FuncRequ
break;
case LFUN_BREAKPARAGRAPH:
+ if (aboutToBreak())
+ break;
+ if (!cursor.pos())
+ cursorLeft(bv);
+ if (cursor.pos() == cursor.par()->size()) {
+ aboutToBreak(true);
+ break;
+ }
bv->beforeChange(this);
breakParagraph(bv, bv->buffer()->paragraphs, 0);
update(bv);
@@ -837,6 +845,13 @@ Inset::RESULT LyXText::dispatch(FuncRequ
break;
case LFUN_BREAKPARAGRAPHKEEPLAYOUT:
+ if (aboutToBreak())
+ break;
+ if (!cursor.pos())
+ cursorLeft(bv);
+ if (cursor.pos() == cursor.par()->size()) {
+ aboutToBreak(true);
+ }
bv->beforeChange(this);
breakParagraph(bv, bv->buffer()->paragraphs, 1);
update(bv);
@@ -846,6 +861,14 @@ Inset::RESULT LyXText::dispatch(FuncRequ
break;
case LFUN_BREAKPARAGRAPH_SKIP: {
+ if (aboutToBreak())
+ break;
+ if (!cursor.pos())
+ cursorLeft(bv);
+ if (cursor.pos() == cursor.par()->size()) {
+ aboutToBreak(true);
+ break;
+ }
// When at the beginning of a paragraph, remove
// indentation and add a "defskip" at the top.
// Otherwise, do the same as LFUN_BREAKPARAGRAPH.
@@ -1554,6 +1577,13 @@ Inset::RESULT LyXText::dispatch(FuncRequ
}
bv->beforeChange(this);
+
+ if (aboutToBreak()) {
+ breakParagraph(bv, bv->buffer()->paragraphs, 0);
+ aboutToBreak(false);
+ }
+
+
LyXFont const old_font(real_current_font);
string::const_iterator cit = cmd.argument.begin();
Index: frontends/screen.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/screen.C,v
retrieving revision 1.31
diff -u -p -u -r1.31 screen.C
--- frontends/screen.C 2003/03/06 20:21:18 1.31
+++ frontends/screen.C 2003/03/11 01:40:25
@@ -140,7 +140,9 @@ void LyXScreen::showCursor(LyXText const
BufferParams const & bp(bv->buffer()->params);
LyXFont const & realfont(text->real_current_font);
- if (realfont.language() != bp.language
+ if (bv->text->aboutToBreak()) {
+ shape = HORIZONTAL_SHAPE;
+ } else if (realfont.language() != bp.language
|| realfont.isVisibleRightToLeft()
!= bp.language->RightToLeft()) {
shape = (realfont.isVisibleRightToLeft())
Index: frontends/screen.h
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/screen.h,v
retrieving revision 1.12
diff -u -p -u -r1.12 screen.h
--- frontends/screen.h 2003/02/26 12:49:01 1.12
+++ frontends/screen.h 2003/03/11 01:40:26
@@ -41,7 +41,9 @@ public:
/// L-shape for locked insets of a different language
L_SHAPE,
/// reverse L-shape for RTL text
- REVERSED_L_SHAPE
+ REVERSED_L_SHAPE,
+ /// horizontal line between two paragraphs
+ HORIZONTAL_SHAPE
};
LyXScreen();
Index: frontends/qt2/qscreen.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/frontends/qt2/qscreen.C,v
retrieving revision 1.14
diff -u -p -u -r1.14 qscreen.C
--- frontends/qt2/qscreen.C 2003/03/06 20:21:18 1.14
+++ frontends/qt2/qscreen.C 2003/03/11 01:40:28
@@ -66,19 +66,28 @@ void QScreen::showManualCursor(LyXText c
int const y2 = max(y_tmp, y1);
if (y2 > 0 && y1 < owner_.height()) {
- cursor_h_ = y2 - y1 + 1;
- cursor_y_ = y1;
-
switch (shape) {
+ case HORIZONTAL_SHAPE:
+ cursor_h_ = 1;
+ cursor_y_ = y2;
+ cursor_w_ = 25;
+ cursor_x_ = 50;
+ break;
case BAR_SHAPE:
+ cursor_h_ = y2 - y1 + 1;
+ cursor_y_ = y1;
cursor_w_ = 1;
cursor_x_ = x;
break;
case L_SHAPE:
+ cursor_h_ = y2 - y1 + 1;
+ cursor_y_ = y1;
cursor_w_ = cursor_h_ / 3;
cursor_x_ = x;
break;
case REVERSED_L_SHAPE:
+ cursor_h_ = y2 - y1 + 1;
+ cursor_y_ = y1;
cursor_w_ = cursor_h_ / 3;
cursor_x_ = x - cursor_w_ + 1;
break;
@@ -96,16 +105,20 @@ void QScreen::showManualCursor(LyXText c
bitBlt(nocursor_pixmap_.get(), 0, 0, owner_.getPixmap(),
cursor_x_, cursor_y_, cursor_w_, cursor_h_);
- owner_.getPainter().line(x, y1, x, y2, LColor::cursor);
+ int const rectangle_h = (cursor_h_ + 10) / 20;
switch (shape) {
- case BAR_SHAPE:
- break;
case L_SHAPE:
case REVERSED_L_SHAPE:
- int const rectangle_h = (cursor_h_ + 10) / 20;
owner_.getPainter().fillRectangle(
cursor_x_, y2 - rectangle_h + 1,
cursor_w_ - 1, rectangle_h, LColor::cursor);
+ case BAR_SHAPE:
+ owner_.getPainter().line(x, y1, x, y2, LColor::cursor);
+ break;
+ case HORIZONTAL_SHAPE:
+ owner_.getPainter().line(cursor_x_, cursor_y_,
+ cursor_x_ + cursor_w_ - 1,
+ cursor_y_, LColor::cursor);
break;
}