mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Show count of search results in copy mode.
This commit is contained in:
		
							
								
								
									
										2
									
								
								colour.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								colour.c
									
									
									
									
									
								
							@@ -48,7 +48,7 @@ colour_to_6cube(int v)
 | 
				
			|||||||
 * map our RGB colour to the closest in the cube, also work out the closest
 | 
					 * map our RGB colour to the closest in the cube, also work out the closest
 | 
				
			||||||
 * grey, and use the nearest of the two.
 | 
					 * grey, and use the nearest of the two.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Note that the xterm has much lower resolution for darker colors (they are
 | 
					 * Note that the xterm has much lower resolution for darker colours (they are
 | 
				
			||||||
 * not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f
 | 
					 * not evenly spread out), so our 6 levels are not evenly spread: 0x0, 0x5f
 | 
				
			||||||
 * (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more
 | 
					 * (95), 0x87 (135), 0xaf (175), 0xd7 (215) and 0xff (255). Greys are more
 | 
				
			||||||
 * evenly spread (8, 18, 28 ... 238).
 | 
					 * evenly spread (8, 18, 28 ... 238).
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -174,6 +174,8 @@ struct window_copy_mode_data {
 | 
				
			|||||||
	int		 searchtype;
 | 
						int		 searchtype;
 | 
				
			||||||
	char		*searchstr;
 | 
						char		*searchstr;
 | 
				
			||||||
	bitstr_t        *searchmark;
 | 
						bitstr_t        *searchmark;
 | 
				
			||||||
 | 
						u_int		 searchcount;
 | 
				
			||||||
 | 
						int		 searchthis;
 | 
				
			||||||
	int		 searchx;
 | 
						int		 searchx;
 | 
				
			||||||
	int		 searchy;
 | 
						int		 searchy;
 | 
				
			||||||
	int		 searcho;
 | 
						int		 searcho;
 | 
				
			||||||
@@ -1170,7 +1172,7 @@ window_copy_search_marks(struct window_pane *wp, struct screen *ssp)
 | 
				
			|||||||
	struct screen			*s = data->backing, ss;
 | 
						struct screen			*s = data->backing, ss;
 | 
				
			||||||
	struct screen_write_ctx		 ctx;
 | 
						struct screen_write_ctx		 ctx;
 | 
				
			||||||
	struct grid			*gd = s->grid;
 | 
						struct grid			*gd = s->grid;
 | 
				
			||||||
	int				 found, cis;
 | 
						int				 found, cis, which = -1;
 | 
				
			||||||
	u_int				 px, py, b, nfound = 0, width;
 | 
						u_int				 px, py, b, nfound = 0, width;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ssp == NULL) {
 | 
						if (ssp == NULL) {
 | 
				
			||||||
@@ -1196,7 +1198,10 @@ window_copy_search_marks(struct window_pane *wp, struct screen *ssp)
 | 
				
			|||||||
			    px, gd->sx, cis);
 | 
								    px, gd->sx, cis);
 | 
				
			||||||
			if (!found)
 | 
								if (!found)
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			nfound++;
 | 
								nfound++;
 | 
				
			||||||
 | 
								if (px == data->cx && py == gd->hsize + data->cy - data->oy)
 | 
				
			||||||
 | 
									which = nfound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			b = (py * gd->sx) + px;
 | 
								b = (py * gd->sx) + px;
 | 
				
			||||||
			bit_nset(data->searchmark, b, b + width - 1);
 | 
								bit_nset(data->searchmark, b, b + width - 1);
 | 
				
			||||||
@@ -1205,6 +1210,12 @@ window_copy_search_marks(struct window_pane *wp, struct screen *ssp)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (which != -1)
 | 
				
			||||||
 | 
							data->searchthis = 1 + nfound - which;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							data->searchthis = -1;
 | 
				
			||||||
 | 
						data->searchcount = nfound;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ssp == &ss)
 | 
						if (ssp == &ss)
 | 
				
			||||||
		screen_free(&ss);
 | 
							screen_free(&ss);
 | 
				
			||||||
	return (nfound);
 | 
						return (nfound);
 | 
				
			||||||
@@ -1262,8 +1273,21 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
 | 
				
			|||||||
	gc.flags |= GRID_FLAG_NOPALETTE;
 | 
						gc.flags |= GRID_FLAG_NOPALETTE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (py == 0) {
 | 
						if (py == 0) {
 | 
				
			||||||
		size = xsnprintf(hdr, sizeof hdr,
 | 
							if (data->searchmark == NULL) {
 | 
				
			||||||
		    "[%u/%u]", data->oy, screen_hsize(data->backing));
 | 
								size = xsnprintf(hdr, sizeof hdr,
 | 
				
			||||||
 | 
								    "[%u/%u]", data->oy, screen_hsize(data->backing));
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								if (data->searchthis == -1) {
 | 
				
			||||||
 | 
									size = xsnprintf(hdr, sizeof hdr,
 | 
				
			||||||
 | 
									    "(%u results) [%d/%u]", data->searchcount,
 | 
				
			||||||
 | 
									    data->oy, screen_hsize(data->backing));
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									size = xsnprintf(hdr, sizeof hdr,
 | 
				
			||||||
 | 
									    "(%u/%u results) [%d/%u]", data->searchthis,
 | 
				
			||||||
 | 
									    data->searchcount, data->oy,
 | 
				
			||||||
 | 
									    screen_hsize(data->backing));
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if (size > screen_size_x(s))
 | 
							if (size > screen_size_x(s))
 | 
				
			||||||
			size = screen_size_x(s);
 | 
								size = screen_size_x(s);
 | 
				
			||||||
		screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
 | 
							screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user