1 /*****************************************************************************
2 * ncurses.c : NCurses plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: ncurses.c,v 1.14 2002/04/19 13:56:11 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_Open ( intf_thread_t *p_intf );
46 static void intf_Close ( intf_thread_t *p_intf );
47 static void intf_Run ( intf_thread_t *p_intf );
49 /*****************************************************************************
50 * Building configuration tree
51 *****************************************************************************/
56 SET_DESCRIPTION( _("ncurses interface module") )
57 ADD_CAPABILITY( INTF, 10 )
58 ADD_SHORTCUT( "curses" )
59 ADD_SHORTCUT( "ncurses" )
63 intf_getfunctions( &p_module->p_functions->intf );
66 MODULE_DEACTIVATE_START
67 MODULE_DEACTIVATE_STOP
69 /*****************************************************************************
70 * intf_sys_t: description and status of ncurses interface
71 *****************************************************************************/
72 typedef struct intf_sys_s
75 vlc_mutex_t change_lock; /* the change lock */
79 /*****************************************************************************
80 * Functions exported as capabilities. They are declared as static so that
81 * we don't pollute the namespace too much.
82 *****************************************************************************/
83 static void intf_getfunctions( function_list_t * p_function_list )
85 p_function_list->functions.intf.pf_open = intf_Open;
86 p_function_list->functions.intf.pf_close = intf_Close;
87 p_function_list->functions.intf.pf_run = intf_Run;
90 /*****************************************************************************
91 * intf_Open: initialize and create window
92 *****************************************************************************/
93 static int intf_Open( intf_thread_t *p_intf )
95 /* Allocate instance and initialize some members */
96 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
97 if( p_intf->p_sys == NULL )
99 intf_ErrMsg( "intf error: %s", strerror(ENOMEM) );
103 /* Initialize the curses library */
105 /* Don't do NL -> CR/NL */
107 /* Take input chars one at a time */
118 /*****************************************************************************
119 * intf_Close: destroy interface window
120 *****************************************************************************/
121 static void intf_Close( intf_thread_t *p_intf )
123 /* Close the ncurses interface */
126 /* Destroy structure */
127 free( p_intf->p_sys );
130 /*****************************************************************************
131 * intf_Run: ncurses thread
132 *****************************************************************************/
133 static void intf_Run( intf_thread_t *p_intf )
137 while( !p_intf->b_die )
139 p_intf->pf_manage( p_intf );
141 msleep( INTF_IDLE_SLEEP );
143 mvaddstr( 1, 2, VOUT_TITLE " (ncurses interface)" );
144 mvaddstr( 3, 2, "keys:" );
145 mvaddstr( 4, 2, "Q,q.......quit" );
146 //mvaddstr( 5, 2, "No other keys are active yet." );
148 while( (i_key = getch()) != -1 )
164 /* following functions are local */