diff options
author | fvogel <fvogelnew1@free.fr> | 2019-08-21 19:15:40 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2019-08-21 19:15:40 (GMT) |
commit | ab838eaa979595c207c2537e57e143d0c882ba62 (patch) | |
tree | 480fb0075189fbe5a92472d373730c57e09bce00 /generic/tkTextIndex.c | |
parent | 5cb6e4e4c70b200024f59d7feb363b6bd7dd3d67 (diff) | |
parent | 2d7db39df89bdae1d575bbbf3bfad5dc6f4b818c (diff) | |
download | tk-ab838eaa979595c207c2537e57e143d0c882ba62.zip tk-ab838eaa979595c207c2537e57e143d0c882ba62.tar.gz tk-ab838eaa979595c207c2537e57e143d0c882ba62.tar.bz2 |
Fix [c8ccd1899c]: Pressing the up arrow key on the first line of a [text] does not move the cursor to 1.0
Diffstat (limited to 'generic/tkTextIndex.c')
-rw-r--r-- | generic/tkTextIndex.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 2870c07..523a8cb 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -1298,6 +1298,7 @@ ForwBack( if (forward) { TkTextFindDisplayLineEnd(textPtr, indexPtr, 1, &xOffset); while (count-- > 0) { + /* * Go to the end of the line, then forward one char/byte * to get to the beginning of the next line. @@ -1310,17 +1311,31 @@ ForwBack( } else { TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, &xOffset); while (count-- > 0) { + TkTextIndex indexPtr2; + /* * Go to the beginning of the line, then backward one * char/byte to get to the end of the previous line. */ TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); - TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr, + TkTextIndexBackChars(textPtr, indexPtr, 1, &indexPtr2, COUNT_DISPLAY_INDICES); + + /* + * If we couldn't go to the previous line, then we wanted + to go before the start of the text: arrange for returning + the first index of the first display line. + */ + + if (!TkTextIndexCmp(indexPtr, &indexPtr2)) { + xOffset = 0; + break; + } + *indexPtr = indexPtr2; } - TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); } + TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL); /* * This call assumes indexPtr is the beginning of a display line |