diff --git a/expand.h b/expand.h index 6738a04b4..d17899cf9 100644 --- a/expand.h +++ b/expand.h @@ -51,23 +51,32 @@ #define DIRECTORIES_ONLY 32 -/** Character represeting a home directory */ -#define HOME_DIRECTORY 0xfffffffc +/* + Use unencoded private-use keycodes for internal characters +*/ +#define EXPAND_RESERVED 0xf000 -/** Character represeting process expantion */ -#define PROCESS_EXPAND 0xfffffffb +enum +{ + /** Character represeting a home directory */ + HOME_DIRECTORY = EXPAND_RESERVED, -/** Character representing variable expantion */ -#define VARIABLE_EXPAND 0xfffffffa + /** Character represeting process expantion */ + PROCESS_EXPAND, + + /** Character representing variable expantion */ + VARIABLE_EXPAND, -/** Character representing the start of a bracket expantion */ -#define BRACKET_BEGIN 0xfffffff9 + /** Character representing the start of a bracket expantion */ + BRACKET_BEGIN, -/** Character representing the end of a bracket expantion */ -#define BRACKET_END 0xfffffff8 + /** Character representing the end of a bracket expantion */ + BRACKET_END, -/** Character representing separation between two bracket elements */ -#define BRACKET_SEP 0xfffffff7 + /** Character representing separation between two bracket elements */ + BRACKET_SEP, +} + ; /** Character for separating two array elements. We use 30, i.e. the ascii record separator since that seems logical. */ #define ARRAY_SEP 0x1e diff --git a/input_common.h b/input_common.h index a877074a2..20a1cd8fa 100644 --- a/input_common.h +++ b/input_common.h @@ -8,15 +8,19 @@ Header file for the low level input library #include -#ifndef WCHAR_MAX -#define WCHAR_MAX 0x80000000 -#endif - -#define WCHAR_END (WCHAR_MAX + (unsigned long)1) +/* + Use unencoded private-use keycodes for internal characters +*/ +#define INPUT_COMMON_RESERVED 0xe000 enum { - R_NULL = WCHAR_END + (unsigned long)1 + /** + R_NULL is sometimes returned by the input when a character was + requested but none could be delivered, or when an exception + happened. + */ + R_NULL = INPUT_COMMON_RESERVED } ; diff --git a/reader.c b/reader.c index 6a687d825..a553ce952 100644 --- a/reader.c +++ b/reader.c @@ -2392,7 +2392,14 @@ static int can_read( int fd ) return 0; } - +/** + Test if the specified character is in the private use area that fish uses to store internal characters +*/ +static int wchar_private( wchar_t c ) +{ + return ( (c >= 0xe000) && (c <= 0xf8ff ) ); + +} wchar_t *reader_readline() { @@ -2442,7 +2449,7 @@ wchar_t *reader_readline() while( 1 ) { c=input_readch(); - if( (c< WCHAR_END) && (c>31) && (c != 127) ) + if( ( (!wchar_private(c))) && (c>31) && (c != 127) ) { if( can_read(0) ) { @@ -2462,7 +2469,7 @@ wchar_t *reader_readline() break; } c = input_readch(); - if( (c< WCHAR_END) && (c>31) && (c != 127) ) + if( (!wchar_private(c)) && (c>31) && (c != 127) ) { arr[i]=c; c=0; @@ -2835,7 +2842,7 @@ wchar_t *reader_readline() /* Other, if a normal character, we add it to the command */ default: { - if( (c< WCHAR_END) && (c>31) && (c != 127) ) + if( (!wchar_private(c)) && (c>31) && (c != 127) ) insert_char( c ); else debug( 0, L"Unknown keybinding %d", c ); diff --git a/wildcard.h b/wildcard.h index 5db4e38c1..00842c6a5 100644 --- a/wildcard.h +++ b/wildcard.h @@ -15,20 +15,23 @@ #include "util.h" /* - These constants are outside the 31 bit character space of USC4, - thogh they may clash with WEOF. I need to use characters outside of - the regular character space to represent wildcards and such, - in order to do backslash removal before wildcard matching. + Use unencoded private-use keycodes for internal characters */ -/** Character representing any character except '/' */ -#define ANY_CHAR 0xfffffffe +#define WILDCARD_RESERVED 0xf400 -/** Character representing any character string not containing '/' (A slash) */ -#define ANY_STRING 0xfffffffd +enum +{ + /** Character representing any character except '/' */ + ANY_CHAR = WILDCARD_RESERVED, -/** Character representing any character string */ -#define ANY_STRING_RECURSIVE 0xfffffff6 + /** Character representing any character string not containing '/' (A slash) */ + ANY_STRING, + + /** Character representing any character string */ + ANY_STRING_RECURSIVE, +} + ; /** Expand the wildcard by matching against the filesystem.