mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Revert previous for now, it will break TERM=screen.
This commit is contained in:
		
							
								
								
									
										45
									
								
								xterm-keys.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								xterm-keys.c
									
									
									
									
									
								
							@@ -50,17 +50,7 @@ struct xterm_keys_entry {
 | 
			
		||||
	const char	*template;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct xterm_keys_entry xterm_keys_standard[] = {
 | 
			
		||||
	{ KEYC_HOME,	"\033[H" },
 | 
			
		||||
	{ KEYC_END,	"\033[F" },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct xterm_keys_entry xterm_keys_cursor[] = {
 | 
			
		||||
	{ KEYC_HOME,	"\033OH" },
 | 
			
		||||
	{ KEYC_END,	"\033OF" },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static const struct xterm_keys_entry xterm_keys_modified[] = {
 | 
			
		||||
static const struct xterm_keys_entry xterm_keys_table[] = {
 | 
			
		||||
	{ KEYC_F1,	"\033[1;_P" },
 | 
			
		||||
	{ KEYC_F1,	"\033O1;_P" },
 | 
			
		||||
	{ KEYC_F1,	"\033O_P" },
 | 
			
		||||
@@ -199,8 +189,8 @@ xterm_keys_find(const char *buf, size_t len, size_t *size, key_code *key)
 | 
			
		||||
	int				 matched;
 | 
			
		||||
	key_code			 modifiers;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < nitems(xterm_keys_modified); i++) {
 | 
			
		||||
		entry = &xterm_keys_modified[i];
 | 
			
		||||
	for (i = 0; i < nitems(xterm_keys_table); i++) {
 | 
			
		||||
		entry = &xterm_keys_table[i];
 | 
			
		||||
 | 
			
		||||
		matched = xterm_keys_match(entry->template, buf, len, size,
 | 
			
		||||
		    &modifiers);
 | 
			
		||||
@@ -215,10 +205,10 @@ xterm_keys_find(const char *buf, size_t len, size_t *size, key_code *key)
 | 
			
		||||
 | 
			
		||||
/* Lookup a key number from the table. */
 | 
			
		||||
char *
 | 
			
		||||
xterm_keys_lookup(key_code key, int mode)
 | 
			
		||||
xterm_keys_lookup(key_code key)
 | 
			
		||||
{
 | 
			
		||||
	const struct xterm_keys_entry	*table, *entry;
 | 
			
		||||
	u_int				 items, i;
 | 
			
		||||
	const struct xterm_keys_entry	*entry;
 | 
			
		||||
	u_int				 i;
 | 
			
		||||
	key_code			 modifiers;
 | 
			
		||||
	char				*out;
 | 
			
		||||
 | 
			
		||||
@@ -234,32 +224,21 @@ xterm_keys_lookup(key_code key, int mode)
 | 
			
		||||
	 * If the key has no modifiers, return NULL and let it fall through to
 | 
			
		||||
	 * the normal lookup.
 | 
			
		||||
	 */
 | 
			
		||||
	if (modifiers != 1) {
 | 
			
		||||
		table = xterm_keys_modified;
 | 
			
		||||
		items = nitems(xterm_keys_modified);
 | 
			
		||||
	} else {
 | 
			
		||||
		if (mode & MODE_KCURSOR) {
 | 
			
		||||
			table = xterm_keys_cursor;
 | 
			
		||||
			items = nitems(xterm_keys_cursor);
 | 
			
		||||
		} else {
 | 
			
		||||
			table = xterm_keys_standard;
 | 
			
		||||
			items = nitems(xterm_keys_standard);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (modifiers == 1)
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	/* Otherwise, find the key in the table. */
 | 
			
		||||
	key &= ~(KEYC_SHIFT|KEYC_ESCAPE|KEYC_CTRL);
 | 
			
		||||
	for (i = 0; i < items; i++) {
 | 
			
		||||
		entry = &table[i];
 | 
			
		||||
	for (i = 0; i < nitems(xterm_keys_table); i++) {
 | 
			
		||||
		entry = &xterm_keys_table[i];
 | 
			
		||||
		if (key == entry->key)
 | 
			
		||||
			break;
 | 
			
		||||
	}
 | 
			
		||||
	if (i == items)
 | 
			
		||||
	if (i == nitems(xterm_keys_table))
 | 
			
		||||
		return (NULL);
 | 
			
		||||
 | 
			
		||||
	/* Copy the template and replace the modifier. */
 | 
			
		||||
	out = xstrdup(entry->template);
 | 
			
		||||
	if (modifiers != 1)
 | 
			
		||||
		out[strcspn(out, "_")] = '0' + modifiers;
 | 
			
		||||
	out[strcspn(out, "_")] = '0' + modifiers;
 | 
			
		||||
	return (out);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user