GNU Binutils with patches for OS216
修訂 | 97605e61a14518b1a0ac2a576f4f3c843743e4d5 (tree) |
---|---|
時間 | 2015-07-13 23:47:06 |
作者 | Andrew Burgess <andrew.burgess@embe...> |
Commiter | Andrew Burgess |
gdb/tui: Add command completion to winheight command.
Share the window name completion code from the focus command with the
winheight command, providing window name completion for the winheight
command.
gdb/ChangeLog:
* tui/tui-win.c (window_name_completer): New function.
(focus_completer): Call window_name_completer. All old content
moved into window_name_completer.
(winheight_completer): New function.
(_initialize_tui_win): Rename variable. Add completer to
winheight command. Update doc string on winheight.
@@ -1,3 +1,12 @@ | ||
1 | +2015-07-13 Andrew Burgess <andrew.burgess@embecosm.com> | |
2 | + | |
3 | + * tui/tui-win.c (window_name_completer): New function. | |
4 | + (focus_completer): Call window_name_completer. All old content | |
5 | + moved into window_name_completer. | |
6 | + (winheight_completer): New function. | |
7 | + (_initialize_tui_win): Rename variable. Add completer to | |
8 | + winheight command. Update doc string on winheight. | |
9 | + | |
1 | 10 | 2015-07-12 Sandra Loosemore <sandra@codesourcery.com> |
2 | 11 | |
3 | 12 | * nios2-linux-tdep.c (_initialize_nios2_linux_tdep): Register |
@@ -354,12 +354,14 @@ tui_set_var_cmd (char *null_args, int from_tty, struct cmd_list_element *c) | ||
354 | 354 | tui_rehighlight_all (); |
355 | 355 | } |
356 | 356 | |
357 | -/* Complete possible window names to focus on. TEXT is the complete text | |
358 | - entered so far, WORD is the word currently being completed. */ | |
357 | +/* Generic window name completion function. Complete window name pointed | |
358 | + to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special | |
359 | + window names 'next' and 'prev' will also be considered as possible | |
360 | + completions of the window name. */ | |
359 | 361 | |
360 | 362 | static VEC (char_ptr) * |
361 | -focus_completer (struct cmd_list_element *ignore, | |
362 | - const char *text, const char *word) | |
363 | +window_name_completer (int include_next_prev_p, | |
364 | + const char *text, const char *word) | |
363 | 365 | { |
364 | 366 | VEC (const_char_ptr) *completion_name_vec = NULL; |
365 | 367 | VEC (char_ptr) *matches_vec; |
@@ -389,10 +391,13 @@ focus_completer (struct cmd_list_element *ignore, | ||
389 | 391 | VEC_safe_push (const_char_ptr, completion_name_vec, CMD_NAME); |
390 | 392 | } |
391 | 393 | |
392 | - VEC_safe_push (const_char_ptr, completion_name_vec, "next"); | |
393 | - VEC_safe_push (const_char_ptr, completion_name_vec, "prev"); | |
394 | - VEC_safe_push (const_char_ptr, completion_name_vec, NULL); | |
394 | + if (include_next_prev_p) | |
395 | + { | |
396 | + VEC_safe_push (const_char_ptr, completion_name_vec, "next"); | |
397 | + VEC_safe_push (const_char_ptr, completion_name_vec, "prev"); | |
398 | + } | |
395 | 399 | |
400 | + VEC_safe_push (const_char_ptr, completion_name_vec, NULL); | |
396 | 401 | matches_vec |
397 | 402 | = complete_on_enum (VEC_address (const_char_ptr, completion_name_vec), |
398 | 403 | text, word); |
@@ -402,6 +407,32 @@ focus_completer (struct cmd_list_element *ignore, | ||
402 | 407 | return matches_vec; |
403 | 408 | } |
404 | 409 | |
410 | +/* Complete possible window names to focus on. TEXT is the complete text | |
411 | + entered so far, WORD is the word currently being completed. */ | |
412 | + | |
413 | +static VEC (char_ptr) * | |
414 | +focus_completer (struct cmd_list_element *ignore, | |
415 | + const char *text, const char *word) | |
416 | +{ | |
417 | + return window_name_completer (1, text, word); | |
418 | +} | |
419 | + | |
420 | +/* Complete possible window names for winheight command. TEXT is the | |
421 | + complete text entered so far, WORD is the word currently being | |
422 | + completed. */ | |
423 | + | |
424 | +static VEC (char_ptr) * | |
425 | +winheight_completer (struct cmd_list_element *ignore, | |
426 | + const char *text, const char *word) | |
427 | +{ | |
428 | + /* The first word is the window name. That we can complete. Subsequent | |
429 | + words can't be completed. */ | |
430 | + if (word != text) | |
431 | + return NULL; | |
432 | + | |
433 | + return window_name_completer (0, text, word); | |
434 | +} | |
435 | + | |
405 | 436 | /* Function to initialize gdb commands, for tui window |
406 | 437 | manipulation. */ |
407 | 438 |
@@ -413,7 +444,7 @@ _initialize_tui_win (void) | ||
413 | 444 | { |
414 | 445 | static struct cmd_list_element *tui_setlist; |
415 | 446 | static struct cmd_list_element *tui_showlist; |
416 | - struct cmd_list_element *focus_cmd; | |
447 | + struct cmd_list_element *cmd; | |
417 | 448 | |
418 | 449 | /* Define the classes of commands. |
419 | 450 | They will appear in the help list in the reverse of this order. */ |
@@ -431,8 +462,8 @@ _initialize_tui_win (void) | ||
431 | 462 | add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ |
432 | 463 | Set the width (in characters) of tab stops.\n\ |
433 | 464 | Usage: tabset <n>\n")); |
434 | - add_com ("winheight", class_tui, tui_set_win_height_command, _("\ | |
435 | -Set the height of a specified window.\n\ | |
465 | + cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ | |
466 | +Set or modify the height of a specified window.\n\ | |
436 | 467 | Usage: winheight <win_name> [+ | -] <#lines>\n\ |
437 | 468 | Window names are:\n\ |
438 | 469 | src : the source window\n\ |
@@ -440,9 +471,10 @@ cmd : the command window\n\ | ||
440 | 471 | asm : the disassembly window\n\ |
441 | 472 | regs : the register display\n")); |
442 | 473 | add_com_alias ("wh", "winheight", class_tui, 0); |
474 | + set_cmd_completer (cmd, winheight_completer); | |
443 | 475 | add_info ("win", tui_all_windows_info, |
444 | 476 | _("List of all displayed windows.\n")); |
445 | - focus_cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ | |
477 | + cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ | |
446 | 478 | Set focus to named window or next/prev window.\n\ |
447 | 479 | Usage: focus {<win> | next | prev}\n\ |
448 | 480 | Valid Window names are:\n\ |
@@ -451,7 +483,7 @@ asm : the disassembly window\n\ | ||
451 | 483 | regs : the register display\n\ |
452 | 484 | cmd : the command window\n")); |
453 | 485 | add_com_alias ("fs", "focus", class_tui, 0); |
454 | - set_cmd_completer (focus_cmd, focus_completer); | |
486 | + set_cmd_completer (cmd, focus_completer); | |
455 | 487 | add_com ("+", class_tui, tui_scroll_forward_command, _("\ |
456 | 488 | Scroll window forward.\n\ |
457 | 489 | Usage: + [win] [n]\n")); |