logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0004-Don-t-wrap-when-adding-past-last-line-in-non-scrolli.patch (3542B)


  1. From de7a1acf3168a35c19a569cc7f6f572c39e96c82 Mon Sep 17 00:00:00 2001
  2. From: Michael Forney <mforney@mforney.org>
  3. Date: Thu, 3 Jun 2021 00:32:57 -0700
  4. Subject: [PATCH] Don't wrap when adding past last line in non-scrolling window
  5. X/Open curses says
  6. > If scrolling is disabled, any characters that would extend beyond
  7. > the last column of the last line are truncated.
  8. However, currently libcurses wraps the cursor back to the beginning
  9. of the last line.
  10. To fix this, when we try to add a character that would go past the
  11. end of the last line, leave the cursor where it is. If the character
  12. goes exactly to the end of the last line, add the character but set
  13. the cursor to the last column (to match ncurses behavior).
  14. [0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/intov.html#tag_001_004_002_002
  15. ---
  16. lib/libcurses/addbytes.c | 20 +++++++++++---------
  17. 1 file changed, 11 insertions(+), 9 deletions(-)
  18. diff --git a/lib/libcurses/addbytes.c b/lib/libcurses/addbytes.c
  19. index 9fd917ca..e52dc310 100644
  20. --- a/lib/libcurses/addbytes.c
  21. +++ b/lib/libcurses/addbytes.c
  22. @@ -232,8 +232,6 @@ _cursesi_addbyte(WINDOW *win, __LINE **lp, int *y, int *x, int c,
  23. #endif
  24. if (char_interp && ((*lp)->flags & __ISPASTEOL)) {
  25. - *x = 0;
  26. - (*lp)->flags &= ~__ISPASTEOL;
  27. if (*y == win->scr_b) {
  28. #ifdef DEBUG
  29. __CTRACE(__CTRACE_INPUT,
  30. @@ -246,6 +244,8 @@ _cursesi_addbyte(WINDOW *win, __LINE **lp, int *y, int *x, int c,
  31. } else {
  32. (*y)++;
  33. }
  34. + *x = 0;
  35. + (*lp)->flags &= ~__ISPASTEOL;
  36. *lp = win->alines[*y];
  37. if (c == '\n')
  38. return OK;
  39. @@ -341,8 +341,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  40. return OK;
  41. case L'\n':
  42. wclrtoeol(win);
  43. - *x = 0;
  44. - (*lnp)->flags &= ~__ISPASTEOL;
  45. if (*y == win->scr_b) {
  46. if (!(win->flags & __SCROLLOK))
  47. return ERR;
  48. @@ -350,6 +348,8 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  49. } else {
  50. (*y)++;
  51. }
  52. + *x = 0;
  53. + (*lnp)->flags &= ~__ISPASTEOL;
  54. return OK;
  55. case L'\t':
  56. cc.vals[0] = L' ';
  57. @@ -395,8 +395,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  58. }
  59. /* check for new line first */
  60. if (char_interp && ((*lnp)->flags & __ISPASTEOL)) {
  61. - *x = 0;
  62. - (*lnp)->flags &= ~__ISPASTEOL;
  63. if (*y == win->scr_b) {
  64. if (!(win->flags & __SCROLLOK))
  65. return ERR;
  66. @@ -404,6 +402,8 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  67. } else {
  68. (*y)++;
  69. }
  70. + *x = 0;
  71. + (*lnp)->flags &= ~__ISPASTEOL;
  72. (*lnp) = win->alines[*y];
  73. lp = &win->alines[*y]->line[*x];
  74. }
  75. @@ -459,7 +459,6 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  76. if (newx > *(*lnp)->lastchp)
  77. *(*lnp)->lastchp = newx;
  78. __touchline(win, *y, sx, (int) win->maxx - 1);
  79. - sx = *x = 0;
  80. if (*y == win->scr_b) {
  81. if (!(win->flags & __SCROLLOK))
  82. return ERR;
  83. @@ -467,6 +466,7 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  84. } else {
  85. (*y)++;
  86. }
  87. + sx = *x = 0;
  88. lp = &win->alines[*y]->line[0];
  89. (*lnp) = win->alines[*y];
  90. }
  91. @@ -547,14 +547,16 @@ _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x,
  92. if (newx > *(*lnp)->lastchp)
  93. *(*lnp)->lastchp = newx;
  94. __touchline(win, *y, sx, (int) win->maxx - 1);
  95. - *x = sx = 0;
  96. if (*y == win->scr_b) {
  97. - if (!(win->flags & __SCROLLOK))
  98. + if (!(win->flags & __SCROLLOK)) {
  99. + *x = win->maxx - 1;
  100. return ERR;
  101. + }
  102. scroll(win);
  103. } else {
  104. (*y)++;
  105. }
  106. + *x = sx = 0;
  107. lp = &win->alines[*y]->line[0];
  108. (*lnp) = win->alines[*y];
  109. } else {
  110. --
  111. 2.31.1