1 /*****************************************************************************
2 * ncurses.c : NCurses plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: ncurses.c,v 1.9 2001/12/30 07:09:56 sam Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
29 #include <errno.h> /* ENOMEM */
34 #include <videolan/vlc.h>
36 #include "stream_control.h"
37 #include "input_ext-intf.h"
39 #include "interface.h"
41 /*****************************************************************************
43 *****************************************************************************/
44 static void intf_getfunctions ( function_list_t * p_function_list );
45 static int intf_Probe ( probedata_t *p_data );
46 static int intf_Open ( intf_thread_t *p_intf );
47 static void intf_Close ( intf_thread_t *p_intf );
48 static void intf_Run ( intf_thread_t *p_intf );
50 /*****************************************************************************
51 * Building configuration tree
52 *****************************************************************************/
54 ADD_WINDOW( "Configuration for NCurses module" )
55 ADD_COMMENT( "For now, the NCurses module cannot be configured" )
59 p_module->i_capabilities = MODULE_CAPABILITY_NULL
60 | MODULE_CAPABILITY_INTF;
61 p_module->psz_longname = "ncurses interface module";
62 ADD_SHORTCUT( "ncurses" )
66 intf_getfunctions( &p_module->p_functions->intf );
69 MODULE_DEACTIVATE_START
70 MODULE_DEACTIVATE_STOP
72 /*****************************************************************************
73 * intf_sys_t: description and status of ncurses interface
74 *****************************************************************************/
75 typedef struct intf_sys_s
78 vlc_mutex_t change_lock; /* the change lock */
82 /*****************************************************************************
83 * Functions exported as capabilities. They are declared as static so that
84 * we don't pollute the namespace too much.
85 *****************************************************************************/
86 static void intf_getfunctions( function_list_t * p_function_list )
88 p_function_list->pf_probe = intf_Probe;
89 p_function_list->functions.intf.pf_open = intf_Open;
90 p_function_list->functions.intf.pf_close = intf_Close;
91 p_function_list->functions.intf.pf_run = intf_Run;
94 /*****************************************************************************
95 * intf_Probe: probe the interface and return a score
96 *****************************************************************************
97 * This function tries to initialize ncurses and returns a score to the
98 * plugin manager so that it can select the best plugin.
99 *****************************************************************************/
100 static int intf_Probe( probedata_t *p_data )
105 /*****************************************************************************
106 * intf_Open: initialize and create window
107 *****************************************************************************/
108 static int intf_Open( intf_thread_t *p_intf )
110 /* Allocate instance and initialize some members */
111 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
112 if( p_intf->p_sys == NULL )
114 intf_ErrMsg( "intf error: %s", strerror(ENOMEM) );
118 /* Initialize the curses library */
120 /* Don't do NL -> CR/NL */
122 /* Take input chars one at a time */
133 /*****************************************************************************
134 * intf_Close: destroy interface window
135 *****************************************************************************/
136 static void intf_Close( intf_thread_t *p_intf )
138 /* Close the ncurses interface */
141 /* Destroy structure */
142 free( p_intf->p_sys );
145 /*****************************************************************************
146 * intf_Run: ncurses thread
147 *****************************************************************************/
148 static void intf_Run( intf_thread_t *p_intf )
152 while( !p_intf->b_die )
154 p_intf->pf_manage( p_intf );
156 msleep( INTF_IDLE_SLEEP );
158 mvaddstr( 1, 2, VOUT_TITLE " (ncurses interface)" );
159 mvaddstr( 3, 2, "keys:" );
160 mvaddstr( 4, 2, "Q,q.......quit" );
161 //mvaddstr( 5, 2, "No other keys are active yet." );
163 while( (i_key = getch()) != -1 )
179 /* following functions are local */