mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Add -b flags to insert a window before (like the existing -a for after)
to break-pane, move-window, new-window. GitHub issue 2261.
This commit is contained in:
		
							
								
								
									
										12
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								window.c
									
									
									
									
									
								
							@@ -1490,13 +1490,16 @@ winlink_clear_flags(struct winlink *wl)
 | 
			
		||||
 | 
			
		||||
/* Shuffle window indexes up. */
 | 
			
		||||
int
 | 
			
		||||
winlink_shuffle_up(struct session *s, struct winlink *wl)
 | 
			
		||||
winlink_shuffle_up(struct session *s, struct winlink *wl, int before)
 | 
			
		||||
{
 | 
			
		||||
	int	 idx, last;
 | 
			
		||||
 | 
			
		||||
	if (wl == NULL)
 | 
			
		||||
		return (-1);
 | 
			
		||||
	idx = wl->idx + 1;
 | 
			
		||||
	if (before)
 | 
			
		||||
		idx = wl->idx;
 | 
			
		||||
	else
 | 
			
		||||
		idx = wl->idx + 1;
 | 
			
		||||
 | 
			
		||||
	/* Find the next free index. */
 | 
			
		||||
	for (last = idx; last < INT_MAX; last++) {
 | 
			
		||||
@@ -1509,8 +1512,9 @@ winlink_shuffle_up(struct session *s, struct winlink *wl)
 | 
			
		||||
	/* Move everything from last - 1 to idx up a bit. */
 | 
			
		||||
	for (; last > idx; last--) {
 | 
			
		||||
		wl = winlink_find_by_index(&s->windows, last - 1);
 | 
			
		||||
		server_link_window(s, wl, s, last, 0, 0, NULL);
 | 
			
		||||
		server_unlink_window(s, wl);
 | 
			
		||||
		RB_REMOVE(winlinks, &s->windows, wl);
 | 
			
		||||
		wl->idx++;
 | 
			
		||||
		RB_INSERT(winlinks, &s->windows, wl);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return (idx);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user