Code

add an initial version of a chat screen
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 2 May 2012 14:57:58 +0000 (16:57 +0200)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Wed, 2 May 2012 14:57:58 +0000 (16:57 +0200)
13 files changed:
Makefile.am
configure.ac
doc/config.sample
doc/ncmpc.1
src/command.c
src/command.h
src/options.c
src/screen.c
src/screen_chat.c [new file with mode: 0644]
src/screen_chat.h [new file with mode: 0644]
src/screen_help.c
src/screen_list.c
src/title_bar.c

index 17cdb9f72b3c0f9ee52ad82c4a0ddf5495232489..ae6d5560f77d8ebdbde6c354c4fd476643efdadb 100644 (file)
@@ -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
index c50445eaa898f18f2e4fc8ee0c287463f4ee4252..4e29197256965c347cd73d5e32d5f6f2a7397729 100644 (file)
@@ -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
index 54fa82febbe6f7dd57795d359d7d35d21a9aaa9e..5f1f93f6e452cfb95ffe48560a9b1b0c6f19d26e 100644 (file)
@@ -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
index f72c99c8cc6bc2c6afbdce77673d13f49774f10e..0aabe94ff0782fffb41d05a6a5009dec2e0a9ca0 100644 (file)
@@ -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.).
index e3663339ee9837436bbfec350b4690024c32ba69..9495b79aa5ea62301478d9ee0e433c8315824194 100644 (file)
@@ -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 }
 };
index 847d5ed7c22c2edf466fc6b58da11897c484ce96..9e8b1664d2475d585be84d71e392753fa26b9d8f 100644 (file)
@@ -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,
index c331fa54c897a109b69a77e59c848c0216c1c1e1..0129b235eb31f554cd24a91d7d980b0ec91fff2d 100644 (file)
@@ -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
index c34d3962e35b4afb20f48f62e9fa66b34c7d3d2e..4050add277367c224a45b949ffc010a9e8a73b0d 100644 (file)
@@ -39,6 +39,7 @@
 #include "screen_keydef.h"
 #include "screen_lyrics.h"
 #include "screen_outputs.h"
+#include "screen_chat.h"
 
 #include <mpd/client.h>
 
@@ -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 (file)
index 0000000..94aee1d
--- /dev/null
@@ -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 (file)
index 0000000..f2cc063
--- /dev/null
@@ -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
index e0e705b9697b1cd57065bd1b02398518f315d127..ed4db1fc2f668d17411ab662a0efc0486aadadc5 100644 (file)
@@ -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 },
index e0ddecf53390c13c73cbd2aaa4935306f48dd312..5ef6ddba172224f0168389df77aec598c0b573b0 100644 (file)
@@ -29,6 +29,7 @@
 #include "screen_keydef.h"
 #include "screen_lyrics.h"
 #include "screen_outputs.h"
+#include "screen_chat.h"
 
 #include <string.h>
 
@@ -60,6 +61,9 @@ static const struct
 #ifdef ENABLE_OUTPUTS_SCREEN
        { "outputs", &screen_outputs },
 #endif
+#ifdef ENABLE_CHAT_SCREEN
+       { "chat", &screen_chat },
+#endif
 };
 
 void
index 7fdce0c21dd9a0f63fa83106bf8d27a65943ffd4..e83156519a4890ef2a10c13248638ecdcba00b04 100644 (file)
@@ -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
        }