mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-11 15:37:24 +00:00
Clean up reader_write_title to work with wcstring
This commit is contained in:
parent
87abcecca6
commit
b97a94ccc8
3 changed files with 15 additions and 18 deletions
|
@ -3251,7 +3251,7 @@ static int builtin_fg(parser_t &parser, wchar_t **argv)
|
|||
const wcstring ft = tok_first(j->command_wcstr());
|
||||
if (! ft.empty())
|
||||
env_set(L"_", ft.c_str(), ENV_EXPORT);
|
||||
reader_write_title(j->command_wcstr());
|
||||
reader_write_title(j->command());
|
||||
|
||||
make_first(j);
|
||||
job_set_flag(j, JOB_FOREGROUND, 1);
|
||||
|
|
29
reader.cpp
29
reader.cpp
|
@ -902,9 +902,8 @@ bool reader_thread_job_is_stale()
|
|||
return (void*)(uintptr_t) s_generation_count != pthread_getspecific(generation_count_key);
|
||||
}
|
||||
|
||||
void reader_write_title(const wchar_t *cmd)
|
||||
void reader_write_title(const wcstring &cmd)
|
||||
{
|
||||
const wchar_t *title;
|
||||
const env_var_t term_str = env_get_string(L"TERM");
|
||||
|
||||
/*
|
||||
|
@ -934,7 +933,6 @@ void reader_write_title(const wchar_t *cmd)
|
|||
{
|
||||
char *n = ttyname(STDIN_FILENO);
|
||||
|
||||
|
||||
if (contains(term, L"linux"))
|
||||
{
|
||||
return;
|
||||
|
@ -942,24 +940,23 @@ void reader_write_title(const wchar_t *cmd)
|
|||
|
||||
if (strstr(n, "tty") || strstr(n, "/vc/"))
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
wcstring fish_title = L"fish_title";
|
||||
if (cmd) {
|
||||
fish_title.append(L" ");
|
||||
fish_title.append(parse_util_escape_string_with_quote(cmd, L'\0'));
|
||||
wcstring fish_title_command = DEFAULT_TITLE;
|
||||
if (function_exists(L"fish_title"))
|
||||
{
|
||||
fish_title_command = L"fish_title";
|
||||
if (! cmd.empty())
|
||||
{
|
||||
fish_title_command.append(L" ");
|
||||
fish_title_command.append(parse_util_escape_string_with_quote(cmd, L'\0'));
|
||||
}
|
||||
}
|
||||
title = function_exists(L"fish_title")?fish_title.c_str():DEFAULT_TITLE;
|
||||
|
||||
if (wcslen(title) ==0)
|
||||
return;
|
||||
|
||||
wcstring_list_t lst;
|
||||
|
||||
proc_push_interactive(0);
|
||||
if (exec_subshell(title, lst, false /* do not apply exit status */) != -1)
|
||||
if (exec_subshell(fish_title_command, lst, false /* do not apply exit status */) != -1)
|
||||
{
|
||||
if (! lst.empty())
|
||||
{
|
||||
|
@ -1020,7 +1017,7 @@ static void exec_prompt()
|
|||
}
|
||||
|
||||
/* Write the screen title */
|
||||
reader_write_title(0);
|
||||
reader_write_title(L"");
|
||||
}
|
||||
|
||||
void reader_init()
|
||||
|
@ -2540,7 +2537,7 @@ void reader_run_command(parser_t &parser, const wcstring &cmd)
|
|||
if (! ft.empty())
|
||||
env_set(L"_", ft.c_str(), ENV_GLOBAL);
|
||||
|
||||
reader_write_title(cmd.c_str());
|
||||
reader_write_title(cmd);
|
||||
|
||||
term_donate();
|
||||
|
||||
|
|
2
reader.h
2
reader.h
|
@ -119,7 +119,7 @@ void reader_pop_current_filename();
|
|||
|
||||
\param cmd Command line string passed to \c fish_title if is defined.
|
||||
*/
|
||||
void reader_write_title(const wchar_t *cmd);
|
||||
void reader_write_title(const wcstring &cmd);
|
||||
|
||||
/**
|
||||
Call this function to tell the reader that a repaint is needed, and
|
||||
|
|
Loading…
Reference in a new issue