1 /* 2 * Copyright 2008-2013 Various Authors 3 * Copyright 2004-2006 Timo Hirvonen 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License as 7 * published by the Free Software Foundation; either version 2 of the 8 * License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef CMUS_COMMAND_MODE_H 20 #define CMUS_COMMAND_MODE_H 21 22 #include "uchar.h" 23 24 #if defined(__sun__) 25 #include <ncurses.h> 26 #else 27 #include <curses.h> 28 #endif 29 30 enum { 31 /* executing command is disabled over net */ 32 CMD_UNSAFE = 1 << 0, 33 /* execute command after every typed/deleted character */ 34 CMD_LIVE = 1 << 1, 35 }; 36 37 struct command { 38 const char *name; 39 void (*func)(char *arg); 40 41 /* min/max number of arguments */ 42 int min_args; 43 int max_args; 44 45 void (*expand)(const char *str); 46 47 /* bind count (0 means: unbound) */ 48 int bc; 49 50 /* CMD_* */ 51 unsigned int flags; 52 }; 53 54 extern struct command commands[]; 55 extern int run_only_safe_commands; 56 57 void command_mode_ch(uchar ch); 58 void command_mode_escape(int c); 59 void command_mode_key(int key); 60 void command_mode_mouse(MEVENT *event); 61 void commands_init(void); 62 void commands_exit(void); 63 int parse_command(const char *buf, char **cmdp, char **argp); 64 char **parse_cmd(const char *cmd, int *args_idx, int *ac); 65 void run_parsed_command(char *cmd, char *arg); 66 void run_command(const char *buf); 67 68 struct command *get_command(const char *str); 69 70 void view_clear(int view); 71 void view_add(int view, char *arg, int prepend); 72 void view_load(int view, char *arg); 73 void view_save(int view, char *arg, int to_stdout, int filtered, int extended); 74 75 struct window *current_win(void); 76 77 #endif 78