From dd83d47626fdef308c92839aca2c79a1ed51fdc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonathan=20Neusch=C3=A4fer?= Date: Wed, 2 May 2012 16:57:58 +0200 Subject: [PATCH] add an initial version of a chat screen --- Makefile.am | 5 +++++ configure.ac | 14 ++++++++++++++ doc/config.sample | 2 +- doc/ncmpc.1 | 2 +- src/command.c | 5 +++++ src/command.h | 1 + src/options.c | 3 +++ src/screen.c | 6 ++++++ src/screen_chat.c | 32 ++++++++++++++++++++++++++++++++ src/screen_chat.h | 32 ++++++++++++++++++++++++++++++++ src/screen_help.c | 10 ++++++++++ src/screen_list.c | 4 ++++ src/title_bar.c | 3 +++ 13 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 src/screen_chat.c create mode 100644 src/screen_chat.h diff --git a/Makefile.am b/Makefile.am index 17cdb9f..ae6d556 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,6 +58,7 @@ ncmpc_headers = \ src/screen_keydef.h \ src/screen_lyrics.h \ src/screen_outputs.h \ + src/screen_chat.h \ src/screen_text.h \ src/plugin.h \ src/lyrics.h \ @@ -163,6 +164,10 @@ if ENABLE_OUTPUTS_SCREEN src_ncmpc_SOURCES += src/screen_outputs.c endif +if ENABLE_CHAT_SCREEN +src_ncmpc_SOURCES += src/screen_chat.c +endif + if ENABLE_LIRC src_ncmpc_SOURCES += src/lirc.c endif diff --git a/configure.ac b/configure.ac index c50445e..4e29197 100644 --- a/configure.ac +++ b/configure.ac @@ -339,6 +339,20 @@ AM_CONDITIONAL(ENABLE_OUTPUTS_SCREEN, test x$enable_outputs_screen = xyes) AC_MSG_RESULT([$enable_outputs_screen]) +dnl Optional screen - client-to-client chat +AC_MSG_CHECKING([whether to include the chat screen]) +AC_ARG_ENABLE([chat-screen], + AC_HELP_STRING([--enable-chat-screen], + [Enable chat screen @<:@default=no@:>@]),, + [enable_chat_screen=no]) +AC_MSG_RESULT([$enable_chat_screen]) +if test "x$enable_chat_screen" = "xyes" ; then + AC_DEFINE(ENABLE_CHAT_SCREEN, 1, [Enable chat screen]) +fi + +AM_CONDITIONAL(ENABLE_CHAT_SCREEN, test x$enable_chat_screen = xyes) + + dnl dnl Windows OS Resource File dnl diff --git a/doc/config.sample b/doc/config.sample index 54fa82f..5f1f93f 100644 --- a/doc/config.sample +++ b/doc/config.sample @@ -21,7 +21,7 @@ ## A list of screens to cycle through when using ## the previous/next screen commands (tab and shift+tab). -## names: playlist browse help artist search song keydef lyrics outputs +## names: playlist browse help artist search song keydef lyrics outputs chat #screen-list = playlist browse ## Default search mode for the search screen. The mode is an diff --git a/doc/ncmpc.1 b/doc/ncmpc.1 index f72c99c..0aabe94 100644 --- a/doc/ncmpc.1 +++ b/doc/ncmpc.1 @@ -85,7 +85,7 @@ configuration file or in the environment, the default is 5 seconds. Enable mouse support (if enabled at compile time). .TP .B screen\-list = SCREEN1 SCREEN2... -A list of screens to cycle through when using the previous/next screen commands. Valid choices, if enabled at compile time, are playlist, browse, artist, help, search, song, keydef, lyrics, and outputs. +A list of screens to cycle through when using the previous/next screen commands. Valid choices, if enabled at compile time, are playlist, browse, artist, help, search, song, keydef, lyrics, outputs, and chat. .TP .B search\-mode = MODE Default search mode for the search screen. MODE must be one of title, artist, album, filename, and artist+title, or an interger index (0 for title, 1 for artist etc.). diff --git a/src/command.c b/src/command.c index e366333..9495b79 100644 --- a/src/command.c +++ b/src/command.c @@ -56,6 +56,7 @@ #define F6 KEY_F(6) #define F7 KEY_F(7) #define F8 KEY_F(8) +#define F9 KEY_F(9) #define C(x) KEY_CTL(x) static command_definition_t cmds[] = { @@ -244,6 +245,10 @@ static command_definition_t cmds[] = { N_("Outputs screen") }, #endif +#ifdef ENABLE_CHAT_SCREEN + { {'9', F9, 0}, 0, CMD_SCREEN_CHAT, "screen-chat", + N_("Chat screen") }, +#endif { { -1, -1, -1 }, 0, CMD_NONE, NULL, NULL } }; diff --git a/src/command.h b/src/command.h index 847d5ed..9e8b166 100644 --- a/src/command.h +++ b/src/command.h @@ -96,6 +96,7 @@ typedef enum { CMD_SCREEN_HELP, CMD_SCREEN_LYRICS, CMD_SCREEN_OUTPUTS, + CMD_SCREEN_CHAT, CMD_LYRICS_UPDATE, CMD_EDIT, CMD_INTERRUPT, diff --git a/src/options.c b/src/options.c index c331fa5..0129b23 100644 --- a/src/options.c +++ b/src/options.c @@ -215,6 +215,9 @@ handle_option(int c, const char *arg) #ifdef ENABLE_OUTPUTS_SCREEN " outputs-screen" #endif +#ifdef ENABLE_CHAT_SCREEN + " chat-screen" +#endif "\n"); #ifndef NCMPC_MINI diff --git a/src/screen.c b/src/screen.c index c34d396..4050add 100644 --- a/src/screen.c +++ b/src/screen.c @@ -39,6 +39,7 @@ #include "screen_keydef.h" #include "screen_lyrics.h" #include "screen_outputs.h" +#include "screen_chat.h" #include @@ -569,6 +570,11 @@ screen_cmd(struct mpdclient *c, command_t cmd) case CMD_SCREEN_OUTPUTS: screen_switch(&screen_outputs, c); break; +#endif +#ifdef ENABLE_CHAT_SCREEN + case CMD_SCREEN_CHAT: + screen_switch(&screen_chat, c); + break; #endif case CMD_SCREEN_SWAP: screen_swap(c, NULL); diff --git a/src/screen_chat.c b/src/screen_chat.c new file mode 100644 index 0000000..94aee1d --- /dev/null +++ b/src/screen_chat.c @@ -0,0 +1,32 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2012 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "screen_interface.h" +#include "mpdclient.h" + +static bool +screen_chat_cmd(G_GNUC_UNUSED struct mpdclient *c, + G_GNUC_UNUSED command_t cmd) +{ + return false; +} + +const struct screen_functions screen_chat = { + .cmd = screen_chat_cmd, +}; diff --git a/src/screen_chat.h b/src/screen_chat.h new file mode 100644 index 0000000..f2cc063 --- /dev/null +++ b/src/screen_chat.h @@ -0,0 +1,32 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2012 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_CHAT_H +#define NCMPC_SCREEN_CHAT_H + +#include "config.h" + +#ifdef ENABLE_CHAT_SCREEN + +struct screen_functions; +extern const struct screen_functions screen_chat; + +#endif + +#endif diff --git a/src/screen_help.c b/src/screen_help.c index e0e705b..ed4db1f 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -72,6 +72,9 @@ static const struct help_text_row help_text[] = { #ifdef ENABLE_OUTPUTS_SCREEN { 0, CMD_SCREEN_OUTPUTS, NULL }, #endif +#ifdef ENABLE_CHAT_SCREEN + { 0, CMD_SCREEN_CHAT, NULL }, +#endif #ifdef ENABLE_KEYDEF_SCREEN { 0, CMD_SCREEN_KEYDEF, NULL }, #endif @@ -173,6 +176,13 @@ static const struct help_text_row help_text[] = { { 2, CMD_NONE, NULL }, { 0, CMD_PLAY, N_("Enable/disable output") }, #endif +#ifdef ENABLE_CHAT_SCREEN + { 0, CMD_NONE, NULL }, + { 0, CMD_NONE, NULL }, + { 1, CMD_NONE, N_("Chat screen") }, + { 2, CMD_NONE, NULL }, + { 0, CMD_PLAY, N_("Write a message (not yet implemented)") }, +#endif #ifdef ENABLE_KEYDEF_SCREEN { 0, CMD_NONE, NULL }, { 0, CMD_NONE, NULL }, diff --git a/src/screen_list.c b/src/screen_list.c index e0ddecf..5ef6ddb 100644 --- a/src/screen_list.c +++ b/src/screen_list.c @@ -29,6 +29,7 @@ #include "screen_keydef.h" #include "screen_lyrics.h" #include "screen_outputs.h" +#include "screen_chat.h" #include @@ -60,6 +61,9 @@ static const struct #ifdef ENABLE_OUTPUTS_SCREEN { "outputs", &screen_outputs }, #endif +#ifdef ENABLE_CHAT_SCREEN + { "chat", &screen_chat }, +#endif }; void diff --git a/src/title_bar.c b/src/title_bar.c index 7fdce0c..e831565 100644 --- a/src/title_bar.c +++ b/src/title_bar.c @@ -90,6 +90,9 @@ title_bar_paint(const struct title_bar *p, const char *title, #ifdef ENABLE_OUTPUTS_SCREEN print_hotkey(w, CMD_SCREEN_OUTPUTS, _("Outputs")); #endif +#ifdef ENABLE_CHAT_SCREEN + print_hotkey(w, CMD_SCREEN_CHAT, _("Chat")); +#endif #endif } -- 2.30.2