Skip to content

Commit

Permalink
Fix compilation with Sun Studio compiler changing \e to \x1b as it do…
Browse files Browse the repository at this point in the history
…es not support \e as an escape character.

darcs-hash:20070822075239-cac88-1a9768bf35295615d553192d9a494f00db26f742.gz
  • Loading branch information
Claes Nästén committed Aug 22, 2007
1 parent baeca81 commit 2994378
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 57 deletions.
9 changes: 2 additions & 7 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,11 +755,6 @@ wchar_t *escape( const wchar_t *in,
*(pos++) = L'r';
break;

case L'\e':
*(pos++) = L'\\';
*(pos++) = L'e';
break;

case L'\\':
case L'&':
case L'$':
Expand Down Expand Up @@ -999,9 +994,9 @@ wchar_t *unescape( const wchar_t * orig, int flags )
}

/*
\e means escape
\x1b means escape
*/
case L'e':
case L'\x1b':
{
in[out_pos]=L'\x1b';
break;
Expand Down
2 changes: 1 addition & 1 deletion expand.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static int is_quotable( wchar_t *str )
case L'\t':
case L'\r':
case L'\b':
case L'\e':
case L'\x1b':
return 0;

default:
Expand Down
4 changes: 2 additions & 2 deletions fish_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ static wint_t readch()
struct mapping m[]=
{
{
"\e[A", LINE_UP
"\x1b[A", LINE_UP
}
,
{
key_up, LINE_UP
}
,
{
"\e[B", LINE_DOWN
"\x1b[B", LINE_DOWN
}
,
{
Expand Down
84 changes: 42 additions & 42 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ static wchar_t *input_symbolic_sequence( const wchar_t *in )
}
if( has_meta )
{
res = wcsdup( L"\ea" );
res = wcsdup( L"\x1ba" );
res[1]=1+c-L'a';
}
else
Expand All @@ -485,7 +485,7 @@ static wchar_t *input_symbolic_sequence( const wchar_t *in )
else if( wcsncmp( in, META_SYMBOL, wcslen(META_SYMBOL) ) == 0 )
{
in += wcslen(META_SYMBOL);
res = wcsdup( L"\e" );
res = wcsdup( L"\x1b" );
debug( 4, L"Got meta" );
}
else
Expand All @@ -510,7 +510,7 @@ static wchar_t *input_symbolic_sequence( const wchar_t *in )
,
{
L"esc",
"\e"
"\x1b"
}
,
{
Expand Down Expand Up @@ -626,7 +626,7 @@ static wchar_t *input_expand_sequence( const wchar_t *in )
break;

case L'e':
*(out++)=L'\e';
*(out++)=L'\x1b';
break;

case L'\\':
Expand Down Expand Up @@ -761,7 +761,7 @@ static wchar_t *input_expand_sequence( const wchar_t *in )
(*in < L'a'+32) )
{
if( has_escape )
*(out++)=L'\e';
*(out++)=L'\x1b';
*(out++)=*in-L'a'+1;
break;
}
Expand All @@ -770,7 +770,7 @@ static wchar_t *input_expand_sequence( const wchar_t *in )
(*in < L'A'+32) )
{
if( has_escape )
*(out++)=L'\e';
*(out++)=L'\x1b';
*(out++)=*in-L'A'+1;
break;
}
Expand Down Expand Up @@ -798,7 +798,7 @@ static wchar_t *input_expand_sequence( const wchar_t *in )
error=1;
break;
}
*(out++)=L'\e';
*(out++)=L'\x1b';

break;
}
Expand Down Expand Up @@ -1236,19 +1236,19 @@ static void add_common_bindings()
self-insert ignored the escape character unless it is the
only character of the sequence.
*/
add_mapping( name[i], L"\e\n", L"Meta-newline", L"self-insert" );
add_mapping( name[i], L"\x1b\n", L"Meta-newline", L"self-insert" );
/*
We need alternative keybidnings for arrowkeys, since
terminfo sometimes specifies a different sequence than what
keypresses actually generate
*/
add_mapping( name[i], L"\e[A", L"Up", L"history-search-backward" );
add_mapping( name[i], L"\e[B", L"Down", L"history-search-forward" );
add_mapping( name[i], L"\x1b[A", L"Up", L"history-search-backward" );
add_mapping( name[i], L"\x1b[B", L"Down", L"history-search-forward" );
add_terminfo_mapping( name[i], (key_up), L"Up", L"history-search-backward" );
add_terminfo_mapping( name[i], (key_down), L"Down", L"history-search-forward" );

add_mapping( name[i], L"\e[C", L"Right", L"forward-char" );
add_mapping( name[i], L"\e[D", L"Left", L"backward-char" );
add_mapping( name[i], L"\x1b[C", L"Right", L"forward-char" );
add_mapping( name[i], L"\x1b[D", L"Left", L"backward-char" );
add_terminfo_mapping( name[i], (key_right), L"Right", L"forward-char" );
add_terminfo_mapping( name[i], (key_left), L"Left", L"backward-char" );

Expand All @@ -1257,8 +1257,8 @@ static void add_common_bindings()
add_terminfo_mapping( name[i], (key_backspace), L"Backspace", L"backward-delete-char" );
add_mapping( name[i], L"\x7f", L"Backspace", L"backward-delete-char" );

add_mapping( name[i], L"\e[H", L"Home", L"beginning-of-line" );
add_mapping( name[i], L"\e[F", L"End", L"end-of-line" );
add_mapping( name[i], L"\x1b[H", L"Home", L"beginning-of-line" );
add_mapping( name[i], L"\x1b[F", L"End", L"end-of-line" );
add_terminfo_mapping( name[i], (key_home), L"Home", L"beginning-of-line" );
add_terminfo_mapping( name[i], (key_end), L"End", L"end-of-line" );

Expand All @@ -1269,27 +1269,27 @@ static void add_common_bindings()
generated
*/

add_mapping( name[i], L"\e\eOC", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\e\eOD", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\e\e[C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\e\e[D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\eO3C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\eO3D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\e[3C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\e[3D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\e[1;3C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\e[1;3D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\x1b\x1bOC", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\x1b\x1bOD", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\x1b\x1b[C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\x1b\x1b[D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\x1bO3C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\x1bO3D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\x1b[3C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\x1b[3D", L"Alt-Left", L"prevd-or-backward-word" );
add_mapping( name[i], L"\x1b[1;3C", L"Alt-Right", L"nextd-or-forward-word" );
add_mapping( name[i], L"\x1b[1;3D", L"Alt-Left", L"prevd-or-backward-word" );

add_mapping( name[i], L"\e\eOA", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\e\eOB", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\e\e[A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\e\e[B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\eO3A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\eO3B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\e[3A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\e[3B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\e[1;3A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\e[1;3B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\x1b\x1bOA", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\x1b\x1bOB", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\x1b\x1b[A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\x1b\x1b[B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\x1bO3A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\x1bO3B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\x1b[3A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\x1b[3B", L"Alt-Down", L"history-token-search-forward" );
add_mapping( name[i], L"\x1b[1;3A", L"Alt-Up", L"history-token-search-backward" );
add_mapping( name[i], L"\x1b[1;3B", L"Alt-Down", L"history-token-search-forward" );
}

/*
Expand Down Expand Up @@ -1320,22 +1320,22 @@ static void add_emacs_bindings()
add_escaped_mapping( L"emacs", (L"\\C-n"), L"Control-n", L"history-search-forward" );
add_escaped_mapping( L"emacs", (L"\\C-f"), L"Control-f", L"forward-char" );
add_escaped_mapping( L"emacs", (L"\\C-b"), L"Control-b", L"backward-char" );
add_escaped_mapping( L"emacs", (L"\e\x7f"), L"Alt-backspace", L"backward-kill-word" );
add_escaped_mapping( L"emacs", (L"\eb"), L"Alt-b", L"backward-word" );
add_escaped_mapping( L"emacs", (L"\ef"), L"Alt-f", L"forward-word" );
add_escaped_mapping( L"emacs", (L"\ed"), L"Alt-d", L"forward-kill-word" );
add_escaped_mapping( L"emacs", (L"\x1b\x7f"), L"Alt-backspace", L"backward-kill-word" );
add_escaped_mapping( L"emacs", (L"\x1bb"), L"Alt-b", L"backward-word" );
add_escaped_mapping( L"emacs", (L"\x1bf"), L"Alt-f", L"forward-word" );
add_escaped_mapping( L"emacs", (L"\x1bd"), L"Alt-d", L"forward-kill-word" );
add_terminfo_mapping( L"emacs", (key_ppage), L"Page Up", L"beginning-of-history" );
add_terminfo_mapping( L"emacs", (key_npage), L"Page Down", L"end-of-history" );
add_escaped_mapping( L"emacs", (L"\e<"), L"Alt-<", L"beginning-of-buffer" );
add_escaped_mapping( L"emacs", (L"\e>"), L"Alt->", L"end-of-buffer" );
add_escaped_mapping( L"emacs", (L"\x1b<"), L"Alt-<", L"beginning-of-buffer" );
add_escaped_mapping( L"emacs", (L"\x1b>"), L"Alt->", L"end-of-buffer" );
}

/**
Add vi-specific bindings
*/
static void add_vi_bindings()
{
add_mapping( L"vi", L"\e", L"Escape", L"bind -M vi-command" );
add_mapping( L"vi", L"\x1b", L"Escape", L"bind -M vi-command" );

add_mapping( L"vi-command", L"i", L"i", L"bind -M vi" );
add_mapping( L"vi-command", L"I", L"I", L"bind -M vi" );
Expand Down Expand Up @@ -1540,7 +1540,7 @@ static wint_t input_exec_binding( mapping *m, const wchar_t *seq )
{
int idx = 0;

if( seq[0] == L'\e' && seq[1] )
if( seq[0] == L'\x1b' && seq[1] )
{
idx = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion input_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Implementation file for the low level input library

/**
Time in milliseconds to wait for another byte to be available for
reading after \e is read before assuming that escape key was
reading after \x1b is read before assuming that escape key was
pressed, and not an escape sequence.
*/
#define WAIT_ON_ESCAPE 10
Expand Down
4 changes: 2 additions & 2 deletions reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ void reader_write_title()
int i;
if( al_get_count( &l ) > 0 )
{
writestr( L"\e]2;" );
writestr( L"\x1b]2;" );
for( i=0; i<al_get_count( &l ); i++ )
{
writestr( (wchar_t *)al_get( &l, i ) );
Expand Down Expand Up @@ -2619,7 +2619,7 @@ wchar_t *reader_readline()
}

/* Escape was pressed */
case L'\e':
case L'\x1b':
{
if( search_mode )
{
Expand Down
4 changes: 2 additions & 2 deletions screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int calc_prompt_width( wchar_t *prompt )

for( j=0; prompt[j]; j++ )
{
if( prompt[j] == L'\e' )
if( prompt[j] == L'\x1b' )
{
/*
This is the start of an escape code. Try to guess it's width.
Expand Down Expand Up @@ -201,7 +201,7 @@ static int calc_prompt_width( wchar_t *prompt )
wchar_t *end;
j+=2;
found = 1;
end = wcsstr( &prompt[j], L"\e\\" );
end = wcsstr( &prompt[j], L"\x1b\\" );
if( end )
{
/*
Expand Down

0 comments on commit 2994378

Please sign in to comment.