]>
git.proxmox.com Git - grub2.git/blob - commands/terminal.c
1 /* terminal.c - command to show and select a terminal */
3 * PUPA -- Preliminary Universal Programming Architecture for GRUB
4 * Copyright (C) 2003 Free Software Foundation, Inc.
6 * PUPA is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with PUPA; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <pupa/normal.h>
24 #include <pupa/misc.h>
25 #include <pupa/term.h>
28 pupa_cmd_terminal (struct pupa_arg_list
*state
__attribute__ ((unused
)),
29 int argc
, char **args
)
33 auto int print_terminal (pupa_term_t
);
34 auto int find_terminal (pupa_term_t
);
36 int print_terminal (pupa_term_t t
)
38 pupa_printf (" %s", t
->name
);
42 int find_terminal (pupa_term_t t
)
44 if (pupa_strcmp (t
->name
, args
[0]) == 0)
55 pupa_printf ("Available terminal(s):");
56 pupa_term_iterate (print_terminal
);
59 pupa_printf ("Current terminal: %s\n", pupa_term_get_current ()->name
);
63 pupa_term_iterate (find_terminal
);
65 return pupa_error (PUPA_ERR_BAD_ARGUMENT
, "no such terminal");
67 pupa_term_set_current (term
);
76 pupa_terminal_init (void)
78 pupa_register_command ("terminal", pupa_cmd_terminal
, PUPA_COMMAND_FLAG_BOTH
,
79 "terminal [TERM...]", "Select a terminal.", 0);
83 pupa_terminal_fini (void)
85 pupa_unregister_command ("terminal");
87 #else /* ! PUPA_UTIL */
90 (void)mod
; /* To stop warning. */
91 pupa_register_command ("terminal", pupa_cmd_terminal
, PUPA_COMMAND_FLAG_BOTH
,
92 "terminal [TERM...]", "Select a terminal.", 0);
97 pupa_unregister_command ("terminal");
99 #endif /* ! PUPA_UTIL */