Joerg Fischer wrote:
> also be 0 in the case 'wrap at width of window'. But then I can't see
> a working condition...
My mistake didn't let me sleep ;-) Here is the correction, but please
double check before checking it in.
Jörg
Index: nedit/source/textDisp.c
===================================================================
--- nedit/source/textDisp.c (revision 5)
+++ nedit/source/textDisp.c (working copy)
@@ -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,24 @@
? 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 (textD->continuousWrap) {
+ if (column > 0 && lineStartPos == textD->cursorPos) {
+ if (lineStartPos == TextDEndOfLine(textD, lineStartPos - 1, False))
+ 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 +1348,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 +1368,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 we are already on the next line! */
+ if (textD->continuousWrap) {
+ if (column > 0 && lineStartPos == textD->cursorPos) {
+ if (lineStartPos == TextDEndOfLine(textD, lineStartPos - 1, False))
+ 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