diff --git a/doc_src/doc.hdr b/doc_src/doc.hdr index 64b165e5e..e1ef257ce 100644 --- a/doc_src/doc.hdr +++ b/doc_src/doc.hdr @@ -915,17 +915,11 @@ The default \c fish prompt is
function fish_prompt -d "Write out the prompt" - printf '\%s\@\%s\%s\\n\%s\%s\\n> ' (whoami) (hostname|cut -d . -f 1) (set_color \$fish_color_cwd) (prompt_pwd) (set_color normal) + printf '\%s\@\%s\%s\%s\%s> ' (whoami) (hostname|cut -d . -f 1) (set_color \$fish_color_cwd) (prompt_pwd) (set_color normal) end-If you are using \c set_color or other commands that output escape -codes to change the font settings of the terminal, you must always and -every such sequence with a newline. This is needed since fish needs to -know that exact length of the prompt in order to tetect when the -cursor reaches the end of the line. Any newlines in the output of the -\c fish_prompt command are ignored. \subsection title Programmable title diff --git a/init/fish_interactive.fish.in b/init/fish_interactive.fish.in index fc55b7785..11c2f08f0 100644 --- a/init/fish_interactive.fish.in +++ b/init/fish_interactive.fish.in @@ -29,7 +29,7 @@ end # long it is. function fish_prompt -d "Write out the prompt" - printf '%s@%s \n%s\n%s\n%s\n> ' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) + printf '%s@%s %s%s%s> \n' (whoami) (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal) end # diff --git a/output.c b/output.c index e1e2f8481..4578acb58 100644 --- a/output.c +++ b/output.c @@ -128,7 +128,7 @@ void set_color( int c, int c2 ) { c = c2 = FISH_COLOR_NORMAL; if( fg ) - writembs( tparm( set_a_foreground, 0 ) ); + writembs( tparm( fg, 0 ) ); writembs( exit_attribute_mode ); return; } diff --git a/reader.c b/reader.c index c41839160..e790db3bf 100644 --- a/reader.c +++ b/reader.c @@ -620,6 +620,129 @@ void reader_write_title() set_color( FISH_COLOR_RESET, FISH_COLOR_RESET ); } +/** + Tests if the specified narrow character sequence is present at the + specified position of the specified wide character string. All of + \c seq must match, but str may be longer than seq. +*/ +static int try_sequence( char *seq, wchar_t *str ) +{ + int i; + + for( i=0;; i++ ) + { + if( !seq[i] ) + return i; + + if( seq[i] != str[i] ) + return 0; + } + + return 0; +} + +/** + Calculate the width of the specified prompt. Does some clever magic + to detect common escape sequences that may be embeded in a prompt, + such as color codes. +*/ +static int calc_prompt_width( array_list_t *arr ) +{ + int res = 0; + int i, j, k; + + for( i=0; i