gitkrinit.c

Go to the documentation of this file.
00001 
00018 #define GITK_RENDERER_C
00019 #define GITKR_INIT_C
00020 
00021 #include "gitkrincludes.h"
00022 
00029 gboolean gitkr_init(guint *argc, gchar ***argv) {
00030   (void)g_log_set_handler(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG|G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_WARNING|G_LOG_LEVEL_ERROR, gitk_log_handler, NULL);
00031   gitk_log("text mode render plugin init beg");
00032 
00033   if(!gitkr_init_process_commandline(argc,argv)) {
00034 
00035     //-- init curses library and set io-params
00036     initscr();
00037     if(has_colors()) {
00038       gitk_log("color output available!");
00039       start_color();  /* we are going to use colors */
00040     }
00041     else {
00042       gitk_log("*no* color output available!");
00043     }
00044     gitk_log1("supported terminal attribute are (0x%012lx)",termattrs());
00045     cbreak();                 /* take input chars one at a time, no wait for \n */
00046     noecho();                 /* disable echo mode */
00047     nonl();                   /* tell curses not to do NL->CR/NL on output */
00048     scrollok(stdscr, FALSE);  /* do not scroll */
00049     intrflush(stdscr, FALSE); /* intermediate display-queue flush, when using break */
00050     keypad(stdscr, TRUE);     /* enable keyboard mapping */
00051     //notimeout(win, TRUE); /** @todo tty this and see what it does with function keys and ESC */
00052     
00053     gitk_log2("curses color capabillities : num_colors=%d max_color_pairs=%d",COLORS,COLOR_PAIRS);
00054 
00055     //-- register signal functions
00056     signal(SIGINT, sighandler_on_sigint);
00057     signal(SIGHUP, sighandler_on_sighup);
00058     signal(SIGWINCH, sighandler_on_sigwinch);
00059     
00060 #ifdef HAVE_SPEECH
00061     if(gitkr_text_speech_name && (!strncmp(gitkr_text_speech_name,"festival\0",9))) {
00062       //-- init speech library and set params
00063       if(!(ftinfo=festival_initialize(NULL,-1,NULL))) {
00064         gitk_log("*no* speech output available!");
00065       }
00066       else {
00067         gitk_log("speech output available!");
00068       }
00069     }
00070 #endif
00071   }
00072   gitk_log("text mode render plugin init end");
00073   return(TRUE);
00074 }
00075 
00080 gboolean gitkr_init_process_commandline(guint *argc, gchar ***argv) {
00081   guint i;
00082   gchar *arg;
00083   gboolean info_only=FALSE; 
00084   gboolean info_help=FALSE, info_version=FALSE;
00085 
00086   gitk_log("gitkr_init_process_commandline() beg");
00087 
00088   //-- check if there have been passed some parameters for libgitk
00089   for (i=1;i<*argc;) {
00090     if (!strcmp("--help", (*argv)[i]) || !strcmp("-h", (*argv)[i])) {
00091       info_only=info_help=TRUE;
00092     }
00093     else if((*argv)[i] && (!strcmp("--version", (*argv)[i]))) {
00094       info_only=info_version=TRUE;
00095     } 
00096 #ifdef HAVE_SPEECH
00097     else if((*argv)[i] && (arg=parse_commandline_arg(argc,argv,&i,"--gitkr-text-speech"))) {
00098       gitkr_text_speech_name=strdup(arg);
00099       gitk_log1("selected speech (par) : \"%s\"",gitkr_text_speech_name);
00100     }
00101 #endif
00102     i++;
00103   }
00104   if(info_help) {
00105     gitk_puts(_("GITK-Renderer-Text options"));
00106 #ifdef HAVE_SPEECH
00107     gitk_puts(_("      --gitkr-text-speech\twhich speech module to use {festival}"));
00108 #endif
00109     putchar('\n');
00110   }
00111   if(info_version) puts(PACKAGE_NAME": version "PACKAGE_VERSION" by "PACKAGE_BUGREPORT);
00112 
00113   //-- remove found parameters
00114   cleanup_commandline_args(argc,argv);
00115   gitk_log1("gitk_init_process_commandline()=%1d end",info_only);
00116   return(info_only);
00117 }

Generated on Thu Oct 28 10:59:11 2004 for gitk by doxygen 1.3.6