mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 11:45:08 +00:00
Run restyle.sh to enforce style rules.
This commit is contained in:
parent
fe3b439e31
commit
0d3169ef70
30 changed files with 450 additions and 443 deletions
18
builtin.cpp
18
builtin.cpp
|
@ -421,17 +421,17 @@ static void builtin_bind_list(const wchar_t *bind_mode)
|
||||||
|
|
||||||
if (bind_mode != NULL && bind_mode != mode)
|
if (bind_mode != NULL && bind_mode != mode)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wcstring tname;
|
wcstring tname;
|
||||||
if (input_terminfo_get_name(seq, tname))
|
if (input_terminfo_get_name(seq, tname))
|
||||||
{
|
{
|
||||||
append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", tname.c_str(), mode.c_str(), sets_mode.c_str());
|
append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", tname.c_str(), mode.c_str(), sets_mode.c_str());
|
||||||
for(int i = 0; i < ecmds.size(); i++)
|
for (int i = 0; i < ecmds.size(); i++)
|
||||||
{
|
{
|
||||||
wcstring ecmd = ecmds.at(i);
|
wcstring ecmd = ecmds.at(i);
|
||||||
append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
|
append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
|
||||||
}
|
}
|
||||||
append_format(stdout_buffer, L"\n");
|
append_format(stdout_buffer, L"\n");
|
||||||
}
|
}
|
||||||
|
@ -439,10 +439,10 @@ static void builtin_bind_list(const wchar_t *bind_mode)
|
||||||
{
|
{
|
||||||
const wcstring eseq = escape_string(seq, 1);
|
const wcstring eseq = escape_string(seq, 1);
|
||||||
append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", eseq.c_str(), mode.c_str(), sets_mode.c_str());
|
append_format(stdout_buffer, L"bind -k %ls -M %ls -m %ls", eseq.c_str(), mode.c_str(), sets_mode.c_str());
|
||||||
for(int i = 0; i < ecmds.size(); i++)
|
for (int i = 0; i < ecmds.size(); i++)
|
||||||
{
|
{
|
||||||
wcstring ecmd = ecmds.at(i);
|
wcstring ecmd = ecmds.at(i);
|
||||||
append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
|
append_format(stdout_buffer, L" %ls", escape(ecmd.c_str(), 1));
|
||||||
}
|
}
|
||||||
append_format(stdout_buffer, L"\n");
|
append_format(stdout_buffer, L"\n");
|
||||||
}
|
}
|
||||||
|
@ -674,9 +674,9 @@ static int builtin_bind(parser_t &parser, wchar_t **argv)
|
||||||
/*
|
/*
|
||||||
* if mode is given, but not new mode, default to new mode to mode
|
* if mode is given, but not new mode, default to new mode to mode
|
||||||
*/
|
*/
|
||||||
if(bind_mode_given && !sets_bind_mode_given)
|
if (bind_mode_given && !sets_bind_mode_given)
|
||||||
{
|
{
|
||||||
sets_bind_mode = bind_mode;
|
sets_bind_mode = bind_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
|
|
|
@ -431,16 +431,16 @@ static int builtin_commandline(parser_t &parser, wchar_t **argv)
|
||||||
const wchar_t *buffer = reader_get_buffer();
|
const wchar_t *buffer = reader_get_buffer();
|
||||||
if (reader_get_selection(&start, &len))
|
if (reader_get_selection(&start, &len))
|
||||||
{
|
{
|
||||||
wchar_t *selection = new wchar_t[len + 1];
|
wchar_t *selection = new wchar_t[len + 1];
|
||||||
selection[len] = L'\0';
|
selection[len] = L'\0';
|
||||||
selection = wcsncpy(selection, buffer + start, len);
|
selection = wcsncpy(selection, buffer + start, len);
|
||||||
|
|
||||||
append_format(stdout_buffer, selection);
|
append_format(stdout_buffer, selection);
|
||||||
delete selection;
|
delete selection;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
append_format(stdout_buffer, L"");
|
append_format(stdout_buffer, L"");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,7 +516,7 @@ static int builtin_complete(parser_t &parser, wchar_t **argv)
|
||||||
wcstring faux_cmdline_with_completion = completion_apply_to_command_line(next.completion, next.flags, faux_cmdline, &tmp_cursor, false);
|
wcstring faux_cmdline_with_completion = completion_apply_to_command_line(next.completion, next.flags, faux_cmdline, &tmp_cursor, false);
|
||||||
|
|
||||||
/* completion_apply_to_command_line will append a space unless COMPLETE_NO_SPACE is set. We don't want to set COMPLETE_NO_SPACE because that won't close quotes. What we want is to close the quote, but not append the space. So we just look for the space and clear it. */
|
/* completion_apply_to_command_line will append a space unless COMPLETE_NO_SPACE is set. We don't want to set COMPLETE_NO_SPACE because that won't close quotes. What we want is to close the quote, but not append the space. So we just look for the space and clear it. */
|
||||||
if (! (next.flags & COMPLETE_NO_SPACE) && string_suffixes_string(L" ", faux_cmdline_with_completion))
|
if (!(next.flags & COMPLETE_NO_SPACE) && string_suffixes_string(L" ", faux_cmdline_with_completion))
|
||||||
{
|
{
|
||||||
faux_cmdline_with_completion.resize(faux_cmdline_with_completion.size() - 1);
|
faux_cmdline_with_completion.resize(faux_cmdline_with_completion.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1860,7 +1860,7 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> &comps
|
||||||
bool use_function = 1;
|
bool use_function = 1;
|
||||||
bool use_builtin = 1;
|
bool use_builtin = 1;
|
||||||
|
|
||||||
//debug( 1, L"Complete '%ls'", cmd.c_str() );
|
//debug( 1, L"Complete '%ls'", cmd.c_str() );
|
||||||
|
|
||||||
const wchar_t *cmd_cstr = cmd.c_str();
|
const wchar_t *cmd_cstr = cmd.c_str();
|
||||||
const wchar_t *tok_begin = NULL, *prev_begin = NULL, *prev_end = NULL;
|
const wchar_t *tok_begin = NULL, *prev_begin = NULL, *prev_end = NULL;
|
||||||
|
|
54
expand.cpp
54
expand.cpp
|
@ -902,20 +902,20 @@ void expand_variable_error(parser_t &parser, const wcstring &token, size_t token
|
||||||
if (is_var)
|
if (is_var)
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
error_pos,
|
error_pos,
|
||||||
COMPLETE_VAR_BRACKET_DESC,
|
COMPLETE_VAR_BRACKET_DESC,
|
||||||
cpy,
|
cpy,
|
||||||
name,
|
name,
|
||||||
post);
|
post);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
error_pos,
|
error_pos,
|
||||||
COMPLETE_VAR_BRACKET_DESC,
|
COMPLETE_VAR_BRACKET_DESC,
|
||||||
L"",
|
L"",
|
||||||
L"VARIABLE",
|
L"VARIABLE",
|
||||||
L"");
|
L"");
|
||||||
}
|
}
|
||||||
free(cpy);
|
free(cpy);
|
||||||
|
|
||||||
|
@ -925,16 +925,16 @@ void expand_variable_error(parser_t &parser, const wcstring &token, size_t token
|
||||||
case INTERNAL_SEPARATOR:
|
case INTERNAL_SEPARATOR:
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
error_pos,
|
error_pos,
|
||||||
COMPLETE_VAR_PARAN_DESC);
|
COMPLETE_VAR_PARAN_DESC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
error_pos,
|
error_pos,
|
||||||
COMPLETE_VAR_NULL_DESC);
|
COMPLETE_VAR_NULL_DESC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,9 +948,9 @@ void expand_variable_error(parser_t &parser, const wcstring &token, size_t token
|
||||||
token_stop_char = L'*';
|
token_stop_char = L'*';
|
||||||
|
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
error_pos,
|
error_pos,
|
||||||
(token_stop_char == L'?' ? COMPLETE_YOU_WANT_STATUS : COMPLETE_VAR_DESC),
|
(token_stop_char == L'?' ? COMPLETE_YOU_WANT_STATUS : COMPLETE_VAR_DESC),
|
||||||
token_stop_char);
|
token_stop_char);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1133,8 +1133,8 @@ static int expand_variables_internal(parser_t &parser, wchar_t * const in, std::
|
||||||
if (parse_slice(in + slice_start, &slice_end, var_idx_list, var_pos_list, var_item_list.size()))
|
if (parse_slice(in + slice_start, &slice_end, var_idx_list, var_pos_list, var_item_list.size()))
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
stop_pos,
|
stop_pos,
|
||||||
L"Invalid index value");
|
L"Invalid index value");
|
||||||
is_ok = 0;
|
is_ok = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1153,8 +1153,8 @@ static int expand_variables_internal(parser_t &parser, wchar_t * const in, std::
|
||||||
{
|
{
|
||||||
/* The slice was parsed starting at stop_pos, so we have to add that to the error position */
|
/* The slice was parsed starting at stop_pos, so we have to add that to the error position */
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
slice_start + var_src_pos,
|
slice_start + var_src_pos,
|
||||||
ARRAY_BOUNDS_ERR);
|
ARRAY_BOUNDS_ERR);
|
||||||
is_ok=0;
|
is_ok=0;
|
||||||
var_idx_list.resize(j);
|
var_idx_list.resize(j);
|
||||||
break;
|
break;
|
||||||
|
@ -1349,8 +1349,8 @@ static int expand_brackets(parser_t &parser, const wcstring &instr, int flags, s
|
||||||
if (syntax_error)
|
if (syntax_error)
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
SOURCE_LOCATION_UNKNOWN,
|
SOURCE_LOCATION_UNKNOWN,
|
||||||
_(L"Mismatched brackets"));
|
_(L"Mismatched brackets"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,8 +1416,8 @@ static int expand_cmdsubst(parser_t &parser, const wcstring &input, std::vector<
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
SOURCE_LOCATION_UNKNOWN,
|
SOURCE_LOCATION_UNKNOWN,
|
||||||
L"Mismatched parenthesis");
|
L"Mismatched parenthesis");
|
||||||
return 0;
|
return 0;
|
||||||
case 0:
|
case 0:
|
||||||
append_completion(out_list, input);
|
append_completion(out_list, input);
|
||||||
|
@ -1457,8 +1457,8 @@ static int expand_cmdsubst(parser_t &parser, const wcstring &input, std::vector<
|
||||||
if (idx < 1 || (size_t)idx > sub_res.size())
|
if (idx < 1 || (size_t)idx > sub_res.size())
|
||||||
{
|
{
|
||||||
append_syntax_error(errors,
|
append_syntax_error(errors,
|
||||||
SOURCE_LOCATION_UNKNOWN,
|
SOURCE_LOCATION_UNKNOWN,
|
||||||
ARRAY_BOUNDS_ERR);
|
ARRAY_BOUNDS_ERR);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
idx = idx-1;
|
idx = idx-1;
|
||||||
|
|
|
@ -628,33 +628,33 @@ static void test_parser()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! (detect_argument_errors(L"foo$$") & PARSER_TEST_ERROR))
|
if (!(detect_argument_errors(L"foo$$") & PARSER_TEST_ERROR))
|
||||||
{
|
{
|
||||||
err(L"Bad variable expansion not reported as error");
|
err(L"Bad variable expansion not reported as error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (detect_argument_errors(L"foo$@") & PARSER_TEST_ERROR))
|
if (!(detect_argument_errors(L"foo$@") & PARSER_TEST_ERROR))
|
||||||
{
|
{
|
||||||
err(L"Bad variable expansion not reported as error");
|
err(L"Bad variable expansion not reported as error");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Within command substitutions, we should be able to detect everything that parse_util_detect_errors can detect */
|
/* Within command substitutions, we should be able to detect everything that parse_util_detect_errors can detect */
|
||||||
if (! (detect_argument_errors(L"foo(cat | or cat)") & PARSER_TEST_ERROR))
|
if (!(detect_argument_errors(L"foo(cat | or cat)") & PARSER_TEST_ERROR))
|
||||||
{
|
{
|
||||||
err(L"Bad command substitution not reported as error");
|
err(L"Bad command substitution not reported as error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (detect_argument_errors(L"foo\\xFF9") & PARSER_TEST_ERROR))
|
if (!(detect_argument_errors(L"foo\\xFF9") & PARSER_TEST_ERROR))
|
||||||
{
|
{
|
||||||
err(L"Bad escape not reported as error");
|
err(L"Bad escape not reported as error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (detect_argument_errors(L"foo(echo \\xFF9)") & PARSER_TEST_ERROR))
|
if (!(detect_argument_errors(L"foo(echo \\xFF9)") & PARSER_TEST_ERROR))
|
||||||
{
|
{
|
||||||
err(L"Bad escape in command substitution not reported as error");
|
err(L"Bad escape in command substitution not reported as error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (detect_argument_errors(L"foo(echo (echo (echo \\xFF9)))") & PARSER_TEST_ERROR))
|
if (!(detect_argument_errors(L"foo(echo (echo (echo \\xFF9)))") & PARSER_TEST_ERROR))
|
||||||
{
|
{
|
||||||
err(L"Bad escape in nested command substitution not reported as error");
|
err(L"Bad escape in nested command substitution not reported as error");
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,7 +362,7 @@ rgb_color_t highlight_get_color(highlight_spec_t highlight, bool is_background)
|
||||||
rgb_color_t result = rgb_color_t::normal();
|
rgb_color_t result = rgb_color_t::normal();
|
||||||
|
|
||||||
/* If sloppy_background is set, then we look at the foreground color even if is_background is set */
|
/* If sloppy_background is set, then we look at the foreground color even if is_background is set */
|
||||||
bool treat_as_background = is_background && ! (highlight & highlight_modifier_sloppy_background);
|
bool treat_as_background = is_background && !(highlight & highlight_modifier_sloppy_background);
|
||||||
|
|
||||||
/* Get the primary variable */
|
/* Get the primary variable */
|
||||||
size_t idx = highlight_get_primary(highlight);
|
size_t idx = highlight_get_primary(highlight);
|
||||||
|
@ -1325,7 +1325,7 @@ const highlighter_t::color_array_t & highlighter_t::highlight()
|
||||||
|
|
||||||
switch (node.type)
|
switch (node.type)
|
||||||
{
|
{
|
||||||
// Color direct string descendants, e.g. 'for' and 'in'.
|
// Color direct string descendants, e.g. 'for' and 'in'.
|
||||||
case symbol_while_header:
|
case symbol_while_header:
|
||||||
case symbol_begin_header:
|
case symbol_begin_header:
|
||||||
case symbol_function_header:
|
case symbol_function_header:
|
||||||
|
|
68
input.cpp
68
input.cpp
|
@ -312,7 +312,7 @@ void input_set_bind_mode(const wcstring &bm)
|
||||||
*/
|
*/
|
||||||
int input_function_arity(int function)
|
int input_function_arity(int function)
|
||||||
{
|
{
|
||||||
switch(function)
|
switch (function)
|
||||||
{
|
{
|
||||||
case R_FORWARD_JUMP:
|
case R_FORWARD_JUMP:
|
||||||
case R_BACKWARD_JUMP:
|
case R_BACKWARD_JUMP:
|
||||||
|
@ -541,9 +541,9 @@ wchar_t input_function_pop_arg()
|
||||||
void input_function_push_args(int code)
|
void input_function_push_args(int code)
|
||||||
{
|
{
|
||||||
int arity = input_function_arity(code);
|
int arity = input_function_arity(code);
|
||||||
for(int i = 0; i < arity; i++)
|
for (int i = 0; i < arity; i++)
|
||||||
{
|
{
|
||||||
input_function_push_arg(input_common_readch(0));
|
input_function_push_arg(input_common_readch(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ static void input_mapping_execute_matching_or_generic()
|
||||||
{
|
{
|
||||||
generic = &m;
|
generic = &m;
|
||||||
}
|
}
|
||||||
else if(input_mapping_is_match(m))
|
else if (input_mapping_is_match(m))
|
||||||
{
|
{
|
||||||
input_mapping_execute(m);
|
input_mapping_execute(m);
|
||||||
return;
|
return;
|
||||||
|
@ -706,39 +706,39 @@ wint_t input_readch()
|
||||||
|
|
||||||
if (c >= R_MIN && c <= R_MAX)
|
if (c >= R_MIN && c <= R_MAX)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case R_EOF: /* If it's closed, then just return */
|
case R_EOF: /* If it's closed, then just return */
|
||||||
{
|
{
|
||||||
return WEOF;
|
return WEOF;
|
||||||
}
|
}
|
||||||
case R_SELF_INSERT:
|
case R_SELF_INSERT:
|
||||||
{
|
{
|
||||||
return input_common_readch(0);
|
return input_common_readch(0);
|
||||||
}
|
}
|
||||||
case R_AND:
|
case R_AND:
|
||||||
{
|
{
|
||||||
if(input_function_status)
|
if (input_function_status)
|
||||||
{
|
{
|
||||||
return input_readch();
|
return input_readch();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
while((c = input_common_readch(0)) && c >= R_MIN && c <= R_MAX);
|
while ((c = input_common_readch(0)) && c >= R_MIN && c <= R_MAX);
|
||||||
input_unreadch(c);
|
input_unreadch(c);
|
||||||
return input_readch();
|
return input_readch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input_unreadch(c);
|
input_unreadch(c);
|
||||||
input_mapping_execute_matching_or_generic();
|
input_mapping_execute_matching_or_generic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
pager.cpp
20
pager.cpp
|
@ -492,9 +492,9 @@ bool pager_t::completion_try_print(size_t cols, const wcstring &prefix, const co
|
||||||
min += 2;
|
min += 2;
|
||||||
}
|
}
|
||||||
min_width[col] = maxi(min_width[col],
|
min_width[col] = maxi(min_width[col],
|
||||||
min);
|
min);
|
||||||
pref_width[col] = maxi(pref_width[col],
|
pref_width[col] = maxi(pref_width[col],
|
||||||
pref);
|
pref);
|
||||||
}
|
}
|
||||||
min_tot_width += min_width[col];
|
min_tot_width += min_width[col];
|
||||||
pref_tot_width += pref_width[col];
|
pref_tot_width += pref_width[col];
|
||||||
|
@ -689,12 +689,12 @@ page_rendering_t pager_t::render() const
|
||||||
void pager_t::update_rendering(page_rendering_t *rendering) const
|
void pager_t::update_rendering(page_rendering_t *rendering) const
|
||||||
{
|
{
|
||||||
if (rendering->term_width != this->available_term_width ||
|
if (rendering->term_width != this->available_term_width ||
|
||||||
rendering->term_height != this->available_term_height ||
|
rendering->term_height != this->available_term_height ||
|
||||||
rendering->selected_completion_idx != this->visual_selected_completion_index(rendering->rows, rendering->cols) ||
|
rendering->selected_completion_idx != this->visual_selected_completion_index(rendering->rows, rendering->cols) ||
|
||||||
rendering->search_field_shown != this->search_field_shown ||
|
rendering->search_field_shown != this->search_field_shown ||
|
||||||
rendering->search_field_line.text != this->search_field_line.text ||
|
rendering->search_field_line.text != this->search_field_line.text ||
|
||||||
rendering->search_field_line.position != this->search_field_line.position ||
|
rendering->search_field_line.position != this->search_field_line.position ||
|
||||||
(rendering->remaining_to_disclose > 0 && this->fully_disclosed))
|
(rendering->remaining_to_disclose > 0 && this->fully_disclosed))
|
||||||
{
|
{
|
||||||
*rendering = this->render();
|
*rendering = this->render();
|
||||||
}
|
}
|
||||||
|
@ -722,7 +722,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
|
||||||
{
|
{
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
/* These directions do something sane */
|
/* These directions do something sane */
|
||||||
case direction_south:
|
case direction_south:
|
||||||
case direction_next:
|
case direction_next:
|
||||||
case direction_prev:
|
case direction_prev:
|
||||||
|
@ -736,7 +736,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* These do nothing */
|
/* These do nothing */
|
||||||
case direction_north:
|
case direction_north:
|
||||||
case direction_east:
|
case direction_east:
|
||||||
case direction_west:
|
case direction_west:
|
||||||
|
|
8
pager.h
8
pager.h
|
@ -11,7 +11,7 @@
|
||||||
/* Represents rendering from the pager */
|
/* Represents rendering from the pager */
|
||||||
class page_rendering_t
|
class page_rendering_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int term_width;
|
int term_width;
|
||||||
int term_height;
|
int term_height;
|
||||||
size_t rows;
|
size_t rows;
|
||||||
|
@ -58,7 +58,7 @@ class pager_t
|
||||||
size_t visual_selected_completion_index(size_t rows, size_t cols) const;
|
size_t visual_selected_completion_index(size_t rows, size_t cols) const;
|
||||||
|
|
||||||
/** Data structure describing one or a group of related completions */
|
/** Data structure describing one or a group of related completions */
|
||||||
public:
|
public:
|
||||||
struct comp_t
|
struct comp_t
|
||||||
{
|
{
|
||||||
/** The list of all completin strings this entry applies to */
|
/** The list of all completin strings this entry applies to */
|
||||||
|
@ -87,7 +87,7 @@ class pager_t
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<comp_t> comp_info_list_t;
|
typedef std::vector<comp_t> comp_info_list_t;
|
||||||
|
|
||||||
/* The filtered list of completion infos */
|
/* The filtered list of completion infos */
|
||||||
|
@ -111,7 +111,7 @@ class pager_t
|
||||||
line_t completion_print_item(const wcstring &prefix, const comp_t *c, size_t row, size_t column, int width, bool secondary, bool selected, page_rendering_t *rendering) const;
|
line_t completion_print_item(const wcstring &prefix, const comp_t *c, size_t row, size_t column, int width, bool secondary, bool selected, page_rendering_t *rendering) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* The text of the search field */
|
/* The text of the search field */
|
||||||
editable_line_t search_field_line;
|
editable_line_t search_field_line;
|
||||||
|
|
|
@ -116,7 +116,10 @@ public:
|
||||||
parse_execution_context_t(const parse_node_tree_t &t, const wcstring &s, parser_t *p, int initial_eval_level);
|
parse_execution_context_t(const parse_node_tree_t &t, const wcstring &s, parser_t *p, int initial_eval_level);
|
||||||
|
|
||||||
/* Returns the current eval level */
|
/* Returns the current eval level */
|
||||||
int current_eval_level() const { return eval_level; }
|
int current_eval_level() const
|
||||||
|
{
|
||||||
|
return eval_level;
|
||||||
|
}
|
||||||
|
|
||||||
/* Returns the current line number, indexed from 1. Not const since it touches cached_lineno_offset */
|
/* Returns the current line number, indexed from 1. Not const since it touches cached_lineno_offset */
|
||||||
int get_current_line_number();
|
int get_current_line_number();
|
||||||
|
@ -125,7 +128,10 @@ public:
|
||||||
int get_current_source_offset() const;
|
int get_current_source_offset() const;
|
||||||
|
|
||||||
/* Returns the source string */
|
/* Returns the source string */
|
||||||
const wcstring &get_source() const { return src; }
|
const wcstring &get_source() const
|
||||||
|
{
|
||||||
|
return src;
|
||||||
|
}
|
||||||
|
|
||||||
/* Start executing at the given node offset. Returns 0 if there was no error, 1 if there was an error */
|
/* Start executing at the given node offset. Returns 0 if there was no error, 1 if there was an error */
|
||||||
parse_execution_result_t eval_node_at_offset(node_offset_t offset, const block_t *associated_block, const io_chain_t &io);
|
parse_execution_result_t eval_node_at_offset(node_offset_t offset, const block_t *associated_block, const io_chain_t &io);
|
||||||
|
|
|
@ -173,7 +173,7 @@ RESOLVE(statement)
|
||||||
case parse_keyword_end:
|
case parse_keyword_end:
|
||||||
return NO_PRODUCTION;
|
return NO_PRODUCTION;
|
||||||
|
|
||||||
// All other keywords fall through to decorated statement
|
// All other keywords fall through to decorated statement
|
||||||
default:
|
default:
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1502,7 +1502,8 @@ bool parse_node_tree_t::job_should_be_backgrounded(const parse_node_t &job) cons
|
||||||
assert(job.production_idx == 0);
|
assert(job.production_idx == 0);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
const parse_node_t *opt_background = get_child(job, 2, symbol_optional_background);
|
const parse_node_t *opt_background = get_child(job, 2, symbol_optional_background);
|
||||||
if (opt_background != NULL) {
|
if (opt_background != NULL)
|
||||||
|
{
|
||||||
assert(opt_background->production_idx <= 1);
|
assert(opt_background->production_idx <= 1);
|
||||||
result = (opt_background->production_idx == 1);
|
result = (opt_background->production_idx == 1);
|
||||||
}
|
}
|
||||||
|
|
70
reader.cpp
70
reader.cpp
|
@ -487,16 +487,16 @@ static void update_buff_pos(editable_line_t *el, size_t buff_pos)
|
||||||
el->position = buff_pos;
|
el->position = buff_pos;
|
||||||
if (el == &data->command_line && data->sel_active)
|
if (el == &data->command_line && data->sel_active)
|
||||||
{
|
{
|
||||||
if(data->sel_begin_pos <= buff_pos)
|
if (data->sel_begin_pos <= buff_pos)
|
||||||
{
|
{
|
||||||
data->sel_start_pos = data->sel_begin_pos;
|
data->sel_start_pos = data->sel_begin_pos;
|
||||||
data->sel_stop_pos = buff_pos;
|
data->sel_stop_pos = buff_pos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
data->sel_start_pos = buff_pos;
|
data->sel_start_pos = buff_pos;
|
||||||
data->sel_stop_pos = data->sel_begin_pos;
|
data->sel_stop_pos = data->sel_begin_pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ static void reader_repaint()
|
||||||
if (data->sel_active)
|
if (data->sel_active)
|
||||||
{
|
{
|
||||||
highlight_spec_t selection_color = highlight_make_background(highlight_spec_selection);
|
highlight_spec_t selection_color = highlight_make_background(highlight_spec_selection);
|
||||||
for(size_t i = data->sel_start_pos; i <= std::min(len - 1, data->sel_stop_pos); i++)
|
for (size_t i = data->sel_start_pos; i <= std::min(len - 1, data->sel_stop_pos); i++)
|
||||||
{
|
{
|
||||||
colors[i] = selection_color;
|
colors[i] = selection_color;
|
||||||
}
|
}
|
||||||
|
@ -717,15 +717,15 @@ void reader_data_t::command_line_changed(const editable_line_t *el)
|
||||||
{
|
{
|
||||||
size_t len = this->command_line.size();
|
size_t len = this->command_line.size();
|
||||||
|
|
||||||
/* When we grow colors, propagate the last color (if any), under the assumption that usually it will be correct. If it is, it avoids a repaint. */
|
/* When we grow colors, propagate the last color (if any), under the assumption that usually it will be correct. If it is, it avoids a repaint. */
|
||||||
highlight_spec_t last_color = colors.empty() ? highlight_spec_t() : colors.back();
|
highlight_spec_t last_color = colors.empty() ? highlight_spec_t() : colors.back();
|
||||||
colors.resize(len, last_color);
|
colors.resize(len, last_color);
|
||||||
|
|
||||||
indents.resize(len);
|
indents.resize(len);
|
||||||
|
|
||||||
/* Update the gen count */
|
/* Update the gen count */
|
||||||
s_generation_count++;
|
s_generation_count++;
|
||||||
}
|
}
|
||||||
else if (el == &this->pager.search_field_line)
|
else if (el == &this->pager.search_field_line)
|
||||||
{
|
{
|
||||||
this->pager.refilter_completions();
|
this->pager.refilter_completions();
|
||||||
|
@ -1125,7 +1125,7 @@ static bool command_ends_paging(wchar_t c, bool focused_on_search_field)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
/* These commands always end paging */
|
/* These commands always end paging */
|
||||||
case R_HISTORY_SEARCH_BACKWARD:
|
case R_HISTORY_SEARCH_BACKWARD:
|
||||||
case R_HISTORY_SEARCH_FORWARD:
|
case R_HISTORY_SEARCH_FORWARD:
|
||||||
case R_BEGINNING_OF_HISTORY:
|
case R_BEGINNING_OF_HISTORY:
|
||||||
|
@ -1136,7 +1136,7 @@ static bool command_ends_paging(wchar_t c, bool focused_on_search_field)
|
||||||
case R_CANCEL:
|
case R_CANCEL:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* These commands never do */
|
/* These commands never do */
|
||||||
case R_COMPLETE:
|
case R_COMPLETE:
|
||||||
case R_COMPLETE_AND_SEARCH:
|
case R_COMPLETE_AND_SEARCH:
|
||||||
case R_BACKWARD_CHAR:
|
case R_BACKWARD_CHAR:
|
||||||
|
@ -1149,11 +1149,11 @@ static bool command_ends_paging(wchar_t c, bool focused_on_search_field)
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* R_EXECUTE does end paging, but only executes if it was not paging. So it's handled specially */
|
/* R_EXECUTE does end paging, but only executes if it was not paging. So it's handled specially */
|
||||||
case R_EXECUTE:
|
case R_EXECUTE:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* These commands operate on the search field if that's where the focus is */
|
/* These commands operate on the search field if that's where the focus is */
|
||||||
case R_BEGINNING_OF_LINE:
|
case R_BEGINNING_OF_LINE:
|
||||||
case R_END_OF_LINE:
|
case R_END_OF_LINE:
|
||||||
case R_FORWARD_WORD:
|
case R_FORWARD_WORD:
|
||||||
|
@ -1889,7 +1889,7 @@ static bool handle_completions(const std::vector<completion_t> &comp, bool conti
|
||||||
prefix.append(el->text, prefix_start + len - PREFIX_MAX_LEN, PREFIX_MAX_LEN);
|
prefix.append(el->text, prefix_start + len - PREFIX_MAX_LEN, PREFIX_MAX_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t quote;
|
wchar_t quote;
|
||||||
parse_util_get_parameter_info(el->text, el->position, "e, NULL, NULL);
|
parse_util_get_parameter_info(el->text, el->position, "e, NULL, NULL);
|
||||||
|
|
||||||
/* Update the pager data */
|
/* Update the pager data */
|
||||||
|
@ -2370,7 +2370,7 @@ static void move_word(editable_line_t *el, bool move_right, bool erase, enum mov
|
||||||
/* Don't autosuggest after a kill */
|
/* Don't autosuggest after a kill */
|
||||||
if (el == &data->command_line)
|
if (el == &data->command_line)
|
||||||
{
|
{
|
||||||
data->suppress_autosuggestion = true;
|
data->suppress_autosuggestion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (move_right)
|
if (move_right)
|
||||||
|
@ -2807,7 +2807,7 @@ static void reader_super_highlight_me_plenty(int match_highlight_pos_adjust, boo
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Highlighting including I/O proceeds in the background
|
// Highlighting including I/O proceeds in the background
|
||||||
iothread_perform(threaded_highlight, highlight_complete, ctx);
|
iothread_perform(threaded_highlight, highlight_complete, ctx);
|
||||||
}
|
}
|
||||||
highlight_search();
|
highlight_search();
|
||||||
|
|
||||||
|
@ -3955,19 +3955,19 @@ const wchar_t *reader_readline(void)
|
||||||
|
|
||||||
case R_BEGIN_SELECTION:
|
case R_BEGIN_SELECTION:
|
||||||
{
|
{
|
||||||
data->sel_active = true;
|
data->sel_active = true;
|
||||||
data->sel_begin_pos = data->command_line.position;
|
data->sel_begin_pos = data->command_line.position;
|
||||||
data->sel_start_pos = data->command_line.position;
|
data->sel_start_pos = data->command_line.position;
|
||||||
data->sel_stop_pos = data->command_line.position;
|
data->sel_stop_pos = data->command_line.position;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case R_END_SELECTION:
|
case R_END_SELECTION:
|
||||||
{
|
{
|
||||||
data->sel_active = false;
|
data->sel_active = false;
|
||||||
data->sel_start_pos = data->command_line.position;
|
data->sel_start_pos = data->command_line.position;
|
||||||
data->sel_stop_pos = data->command_line.position;
|
data->sel_stop_pos = data->command_line.position;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case R_KILL_SELECTION:
|
case R_KILL_SELECTION:
|
||||||
|
@ -4034,7 +4034,7 @@ const wchar_t *reader_readline(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Expand abbreviations after space */
|
/* Expand abbreviations after space */
|
||||||
should_expand_abbreviations = (c == L' ');
|
should_expand_abbreviations = (c == L' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
reader.h
2
reader.h
|
@ -25,7 +25,7 @@ class history_t;
|
||||||
/* Helper class for storing a command line */
|
/* Helper class for storing a command line */
|
||||||
class editable_line_t
|
class editable_line_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** The command line */
|
/** The command line */
|
||||||
wcstring text;
|
wcstring text;
|
||||||
|
|
Loading…
Reference in a new issue