mirror of
https://github.com/tmux/tmux.git
synced 2024-12-25 02:48:47 +00:00
Allow search across wrapped lines and fix some inconsistencies in how th
position is represented, GitHub issue 2014 from Anindya Mukherjee.
This commit is contained in:
parent
f733d3f3eb
commit
ab630f72ed
@ -2082,16 +2082,24 @@ static int
|
|||||||
window_copy_search_lr(struct grid *gd,
|
window_copy_search_lr(struct grid *gd,
|
||||||
struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis)
|
struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis)
|
||||||
{
|
{
|
||||||
u_int ax, bx, px;
|
u_int ax, bx, px, pywrap, endline;
|
||||||
int matched;
|
int matched;
|
||||||
|
|
||||||
|
endline = gd->hsize + gd->sy - 1;
|
||||||
for (ax = first; ax < last; ax++) {
|
for (ax = first; ax < last; ax++) {
|
||||||
if (ax + sgd->sx > gd->sx)
|
|
||||||
break;
|
|
||||||
for (bx = 0; bx < sgd->sx; bx++) {
|
for (bx = 0; bx < sgd->sx; bx++) {
|
||||||
px = ax + bx;
|
px = ax + bx;
|
||||||
matched = window_copy_search_compare(gd, px, py, sgd,
|
pywrap = py;
|
||||||
bx, cis);
|
/* Wrap line. */
|
||||||
|
while (px >= gd->sx && pywrap < endline) {
|
||||||
|
px -= gd->sx;
|
||||||
|
pywrap++;
|
||||||
|
}
|
||||||
|
/* We have run off the end of the grid. */
|
||||||
|
if (px >= gd->sx)
|
||||||
|
break;
|
||||||
|
matched = window_copy_search_compare(gd, px, pywrap,
|
||||||
|
sgd, bx, cis);
|
||||||
if (!matched)
|
if (!matched)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2107,16 +2115,24 @@ static int
|
|||||||
window_copy_search_rl(struct grid *gd,
|
window_copy_search_rl(struct grid *gd,
|
||||||
struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis)
|
struct grid *sgd, u_int *ppx, u_int py, u_int first, u_int last, int cis)
|
||||||
{
|
{
|
||||||
u_int ax, bx, px;
|
u_int ax, bx, px, pywrap, endline;
|
||||||
int matched;
|
int matched;
|
||||||
|
|
||||||
for (ax = last + 1; ax > first; ax--) {
|
endline = gd->hsize + gd->sy - 1;
|
||||||
if (gd->sx - (ax - 1) < sgd->sx)
|
for (ax = last; ax > first; ax--) {
|
||||||
continue;
|
|
||||||
for (bx = 0; bx < sgd->sx; bx++) {
|
for (bx = 0; bx < sgd->sx; bx++) {
|
||||||
px = ax - 1 + bx;
|
px = ax - 1 + bx;
|
||||||
matched = window_copy_search_compare(gd, px, py, sgd,
|
pywrap = py;
|
||||||
bx, cis);
|
/* Wrap line. */
|
||||||
|
while (px >= gd->sx && pywrap < endline) {
|
||||||
|
px -= gd->sx;
|
||||||
|
pywrap++;
|
||||||
|
}
|
||||||
|
/* We have run off the end of the grid. */
|
||||||
|
if (px >= gd->sx)
|
||||||
|
break;
|
||||||
|
matched = window_copy_search_compare(gd, px, pywrap,
|
||||||
|
sgd, bx, cis);
|
||||||
if (!matched)
|
if (!matched)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2135,7 +2151,7 @@ window_copy_move_left(struct screen *s, u_int *fx, u_int *fy, int wrapflag)
|
|||||||
if (*fy == 0) { /* top */
|
if (*fy == 0) { /* top */
|
||||||
if (wrapflag) {
|
if (wrapflag) {
|
||||||
*fx = screen_size_x(s) - 1;
|
*fx = screen_size_x(s) - 1;
|
||||||
*fy = screen_hsize(s) + screen_size_y(s);
|
*fy = screen_hsize(s) + screen_size_y(s) - 1;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2149,7 +2165,7 @@ static void
|
|||||||
window_copy_move_right(struct screen *s, u_int *fx, u_int *fy, int wrapflag)
|
window_copy_move_right(struct screen *s, u_int *fx, u_int *fy, int wrapflag)
|
||||||
{
|
{
|
||||||
if (*fx == screen_size_x(s) - 1) { /* right */
|
if (*fx == screen_size_x(s) - 1) { /* right */
|
||||||
if (*fy == screen_hsize(s) + screen_size_y(s)) { /* bottom */
|
if (*fy == screen_hsize(s) + screen_size_y(s) - 1) { /* bottom */
|
||||||
if (wrapflag) {
|
if (wrapflag) {
|
||||||
*fx = 0;
|
*fx = 0;
|
||||||
*fy = 0;
|
*fy = 0;
|
||||||
@ -2199,12 +2215,12 @@ window_copy_search_jump(struct window_mode_entry *wme, struct grid *gd,
|
|||||||
} else {
|
} else {
|
||||||
for (i = fy + 1; endline < i; i--) {
|
for (i = fy + 1; endline < i; i--) {
|
||||||
found = window_copy_search_rl(gd, sgd, &px, i - 1, 0,
|
found = window_copy_search_rl(gd, sgd, &px, i - 1, 0,
|
||||||
fx, cis);
|
fx + 1, cis);
|
||||||
if (found) {
|
if (found) {
|
||||||
i--;
|
i--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fx = gd->sx;
|
fx = gd->sx - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user