mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	Add some additional cursor format variables. From shiro at usagi dot io
in GitHub issue 4414.
This commit is contained in:
		
							
								
								
									
										69
									
								
								format.c
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								format.c
									
									
									
									
									
								
							@@ -1119,6 +1119,20 @@ format_cb_cursor_character(struct format_tree *ft)
 | 
				
			|||||||
	return (value);
 | 
						return (value);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callback for cursor_colour. */
 | 
				
			||||||
 | 
					static void *
 | 
				
			||||||
 | 
					format_cb_cursor_colour(struct format_tree *ft)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct window_pane	*wp = ft->wp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (wp == NULL || wp->screen == NULL)
 | 
				
			||||||
 | 
							return (NULL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (wp->screen->ccolour != -1)
 | 
				
			||||||
 | 
							return (xstrdup(colour_tostring(wp->screen->ccolour)));
 | 
				
			||||||
 | 
						return (xstrdup(colour_tostring(wp->screen->default_ccolour)));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Callback for mouse_word. */
 | 
					/* Callback for mouse_word. */
 | 
				
			||||||
static void *
 | 
					static void *
 | 
				
			||||||
format_cb_mouse_word(struct format_tree *ft)
 | 
					format_cb_mouse_word(struct format_tree *ft)
 | 
				
			||||||
@@ -1593,6 +1607,37 @@ format_cb_cursor_flag(struct format_tree *ft)
 | 
				
			|||||||
	return (NULL);
 | 
						return (NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callback for cursor_shape. */
 | 
				
			||||||
 | 
					static void *
 | 
				
			||||||
 | 
					format_cb_cursor_shape(struct format_tree *ft)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (ft->wp != NULL && ft->wp->screen != NULL) {
 | 
				
			||||||
 | 
							switch (ft->wp->screen->cstyle) {
 | 
				
			||||||
 | 
							case SCREEN_CURSOR_BLOCK:
 | 
				
			||||||
 | 
								return (xstrdup("block"));
 | 
				
			||||||
 | 
					    		case SCREEN_CURSOR_UNDERLINE:
 | 
				
			||||||
 | 
								return (xstrdup("underline"));
 | 
				
			||||||
 | 
					    		case SCREEN_CURSOR_BAR:
 | 
				
			||||||
 | 
								return (xstrdup("bar"));
 | 
				
			||||||
 | 
					    		default:
 | 
				
			||||||
 | 
								return (xstrdup("default"));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return (NULL);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callback for cursor_very_visible. */
 | 
				
			||||||
 | 
					static void *
 | 
				
			||||||
 | 
					format_cb_cursor_very_visible(struct format_tree *ft)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (ft->wp != NULL && ft->wp->screen != NULL) {
 | 
				
			||||||
 | 
							if (ft->wp->screen->mode & MODE_CURSOR_VERY_VISIBLE)
 | 
				
			||||||
 | 
								return (xstrdup("1"));
 | 
				
			||||||
 | 
							return (xstrdup("0"));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return (NULL);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Callback for cursor_x. */
 | 
					/* Callback for cursor_x. */
 | 
				
			||||||
static void *
 | 
					static void *
 | 
				
			||||||
format_cb_cursor_x(struct format_tree *ft)
 | 
					format_cb_cursor_x(struct format_tree *ft)
 | 
				
			||||||
@@ -1611,6 +1656,18 @@ format_cb_cursor_y(struct format_tree *ft)
 | 
				
			|||||||
	return (NULL);
 | 
						return (NULL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Callback for cursor_blinking. */
 | 
				
			||||||
 | 
					static void *
 | 
				
			||||||
 | 
					format_cb_cursor_blinking(struct format_tree *ft)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (ft->wp != NULL && ft->wp->screen != NULL) {
 | 
				
			||||||
 | 
							if (ft->wp->screen->mode & MODE_CURSOR_BLINKING)
 | 
				
			||||||
 | 
								return (xstrdup("1"));
 | 
				
			||||||
 | 
							return (xstrdup("0"));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return (NULL);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Callback for history_limit. */
 | 
					/* Callback for history_limit. */
 | 
				
			||||||
static void *
 | 
					static void *
 | 
				
			||||||
format_cb_history_limit(struct format_tree *ft)
 | 
					format_cb_history_limit(struct format_tree *ft)
 | 
				
			||||||
@@ -2918,12 +2975,24 @@ static const struct format_table_entry format_table[] = {
 | 
				
			|||||||
	{ "config_files", FORMAT_TABLE_STRING,
 | 
						{ "config_files", FORMAT_TABLE_STRING,
 | 
				
			||||||
	  format_cb_config_files
 | 
						  format_cb_config_files
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{ "cursor_blinking", FORMAT_TABLE_STRING,
 | 
				
			||||||
 | 
						  format_cb_cursor_blinking
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{ "cursor_character", FORMAT_TABLE_STRING,
 | 
						{ "cursor_character", FORMAT_TABLE_STRING,
 | 
				
			||||||
	  format_cb_cursor_character
 | 
						  format_cb_cursor_character
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{ "cursor_colour", FORMAT_TABLE_STRING,
 | 
				
			||||||
 | 
						  format_cb_cursor_colour
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{ "cursor_flag", FORMAT_TABLE_STRING,
 | 
						{ "cursor_flag", FORMAT_TABLE_STRING,
 | 
				
			||||||
	  format_cb_cursor_flag
 | 
						  format_cb_cursor_flag
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						{ "cursor_shape", FORMAT_TABLE_STRING,
 | 
				
			||||||
 | 
						  format_cb_cursor_shape
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						{ "cursor_very_visible", FORMAT_TABLE_STRING,
 | 
				
			||||||
 | 
						  format_cb_cursor_very_visible
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	{ "cursor_x", FORMAT_TABLE_STRING,
 | 
						{ "cursor_x", FORMAT_TABLE_STRING,
 | 
				
			||||||
	  format_cb_cursor_x
 | 
						  format_cb_cursor_x
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user