> stays at the same line as reported. I can't attache the simple fix here
> unfortunately so I submit it to the develop list.
Here it comes
Jörg
diff -r -u nedit-old/nedit/source/textDisp.c nedit-new/nedit/source/textDisp.c
--- nedit-old/nedit/source/textDisp.c 2007-10-02 15:43:42.000000000 +0200
+++ nedit-new/nedit/source/textDisp.c 2007-10-02 15:44:12.000000000 +0200
@@ -1292,7 +1292,7 @@
int TextDMoveUp(textDisp *textD, int absolute)
{
- int lineStartPos, column, prevLineStartPos, newPos, visLineNum;
+ int lineStartPos, column, prevLineStartPos, newPos, visLineNum, offset = 1;
/* Find the position of the start of the line. Use the line starts array
if possible, to avoid unbounded line-counting in continuous wrap mode */
@@ -1313,13 +1313,20 @@
? textD->cursorPreferredCol
: BufCountDispChars(textD->buffer, lineStartPos, textD->cursorPos);
+ /* In continuous mode if the wrapping occurs at a non-whitespace
character,
+ the cursor is moved to the start of the next line, cf. TextDEndOfLine.
+ Therefore in this rare special case the previous line is two(!)
displayed
+ lines away. */
+ if (column == textD->wrapMargin && lineStartPos == textD->cursorPos)
+ offset = 2;
+
/* count forward from the start of the previous line to reach the column */
if (absolute) {
prevLineStartPos = BufCountBackwardNLines(textD->buffer, lineStartPos,
1);
- } else if (visLineNum != -1 && visLineNum != 0) {
- prevLineStartPos = textD->lineStarts[visLineNum-1];
+ } else if (visLineNum >= offset) {
+ prevLineStartPos = textD->lineStarts[visLineNum - offset];
} else {
- prevLineStartPos = TextDCountBackwardNLines(textD, lineStartPos, 1);
+ prevLineStartPos = TextDCountBackwardNLines(textD, lineStartPos,
offset);
}
newPos = BufCountForwardDispChars(textD->buffer, prevLineStartPos, column);
@@ -1337,7 +1344,7 @@
int TextDMoveDown(textDisp *textD, int absolute)
{
- int lineStartPos, column, nextLineStartPos, newPos, visLineNum;
+ int lineStartPos, column, nextLineStartPos, newPos, visLineNum, offset = 1;
if (textD->cursorPos == textD->buffer->length) {
return False;
@@ -1357,10 +1364,16 @@
? textD->cursorPreferredCol
: BufCountDispChars(textD->buffer, lineStartPos, textD->cursorPos);
+ /* In continuous mode if the wrapping occurs at a non-whitespace
character,
+ the cursor is moved to the start of the next line, cf. TextDEndOfLine.
+ Therefore in this rare special case we are already on the next line! */
+ if (column == textD->wrapMargin && lineStartPos == textD->cursorPos)
+ offset = 0;
+
if (absolute)
nextLineStartPos = BufCountForwardNLines(textD->buffer, lineStartPos,
1);
else
- nextLineStartPos = TextDCountForwardNLines(textD, lineStartPos, 1,
True);
+ nextLineStartPos = TextDCountForwardNLines(textD, lineStartPos,
offset, True);
newPos = BufCountForwardDispChars(textD->buffer, nextLineStartPos, column);
--
NEdit Develop mailing list - [email protected]
http://www.nedit.org/mailman/listinfo/develop