mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 14:23:38 +08:00
Formatting
This commit is contained in:
parent
8a66ba6c35
commit
e31431140a
|
@ -1009,7 +1009,8 @@ static int builtin_emit(parser_t &parser, wchar_t **argv)
|
|||
|
||||
}
|
||||
|
||||
if(!argv[woptind]) {
|
||||
if (!argv[woptind])
|
||||
{
|
||||
append_format(stderr_buffer, L"%ls: expected event name\n", argv[0]);
|
||||
return STATUS_BUILTIN_ERROR;
|
||||
}
|
||||
|
|
48
event.cpp
48
event.cpp
|
@ -225,38 +225,53 @@ static void show_all_handlers(void)
|
|||
Give a more condensed description of \c event compared to \c event_get_desc.
|
||||
It includes what function will fire if the \c event is an event handler.
|
||||
*/
|
||||
static wcstring event_desc_compact(const event_t &event) {
|
||||
static wcstring event_desc_compact(const event_t &event)
|
||||
{
|
||||
wcstring res;
|
||||
wchar_t const *temp;
|
||||
int sig;
|
||||
switch(event.type) {
|
||||
switch (event.type)
|
||||
{
|
||||
case EVENT_ANY:
|
||||
res = L"EVENT_ANY";
|
||||
break;
|
||||
case EVENT_VARIABLE:
|
||||
if(event.str_param1.c_str()) {
|
||||
if (event.str_param1.c_str())
|
||||
{
|
||||
res = format_string(L"EVENT_VARIABLE($%ls)", event.str_param1.c_str());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
res = L"EVENT_VARIABLE([any])";
|
||||
}
|
||||
break;
|
||||
case EVENT_SIGNAL:
|
||||
sig = event.param1.signal;
|
||||
if(sig == EVENT_ANY_SIGNAL) {
|
||||
if (sig == EVENT_ANY_SIGNAL)
|
||||
{
|
||||
temp = L"[all signals]";
|
||||
} else if(sig == 0) {
|
||||
}
|
||||
else if (sig == 0)
|
||||
{
|
||||
temp = L"not set";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = sig2wcs(sig);
|
||||
}
|
||||
res = format_string(L"EVENT_SIGNAL(%ls)", temp);
|
||||
break;
|
||||
case EVENT_EXIT:
|
||||
if(event.param1.pid == EVENT_ANY_PID) {
|
||||
if (event.param1.pid == EVENT_ANY_PID)
|
||||
{
|
||||
res = wcstring(L"EVENT_EXIT([all child processes])");
|
||||
} else if (event.param1.pid > 0) {
|
||||
}
|
||||
else if (event.param1.pid > 0)
|
||||
{
|
||||
res = format_string(L"EVENT_EXIT(pid %d)", event.param1.pid);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
job_t *j = job_get_from_pid(-event.param1.pid);
|
||||
if (j)
|
||||
res = format_string(L"EVENT_EXIT(jobid %d: \"%ls\")", j->job_id, j->command_wcstr());
|
||||
|
@ -279,9 +294,12 @@ static wcstring event_desc_compact(const event_t &event) {
|
|||
default:
|
||||
res = format_string(L"unknown/illegal event(%x)", event.type);
|
||||
}
|
||||
if(event.function_name.size()) {
|
||||
if (event.function_name.size())
|
||||
{
|
||||
return format_string(L"%ls: \"%ls\"", res.c_str(), event.function_name.c_str());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +309,8 @@ void event_add_handler(const event_t &event)
|
|||
{
|
||||
event_t *e;
|
||||
|
||||
if(debug_level >= 3) {
|
||||
if (debug_level >= 3)
|
||||
{
|
||||
wcstring desc = event_desc_compact(event);
|
||||
debug(3, "register: %ls\n", desc.c_str());
|
||||
}
|
||||
|
@ -315,7 +334,8 @@ void event_remove(const event_t &criterion)
|
|||
size_t i;
|
||||
event_list_t new_list;
|
||||
|
||||
if(debug_level >= 3) {
|
||||
if (debug_level >= 3)
|
||||
{
|
||||
wcstring desc = event_desc_compact(criterion);
|
||||
debug(3, "unregister: %ls\n", desc.c_str());
|
||||
}
|
||||
|
|
|
@ -674,7 +674,8 @@ static void test_path()
|
|||
}
|
||||
}
|
||||
|
||||
enum word_motion_t {
|
||||
enum word_motion_t
|
||||
{
|
||||
word_motion_left,
|
||||
word_motion_right
|
||||
};
|
||||
|
@ -684,7 +685,8 @@ static void test_1_word_motion(word_motion_t motion, move_word_style_t style, co
|
|||
std::set<size_t> stops;
|
||||
|
||||
// Carets represent stops and should be cut out of the command
|
||||
for (size_t i=0; i < test.size(); i++) {
|
||||
for (size_t i=0; i < test.size(); i++)
|
||||
{
|
||||
wchar_t wc = test.at(i);
|
||||
if (wc == L'^')
|
||||
{
|
||||
|
|
|
@ -820,9 +820,12 @@ bool move_word_state_machine_t::consume_char(wchar_t c)
|
|||
{
|
||||
switch (style)
|
||||
{
|
||||
case move_word_style_punctuation: return consume_char_punctuation(c);
|
||||
case move_word_style_path_components: return consume_char_path_components(c);
|
||||
default: return false;
|
||||
case move_word_style_punctuation:
|
||||
return consume_char_punctuation(c);
|
||||
case move_word_style_path_components:
|
||||
return consume_char_path_components(c);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user