Beispiel #1
0
void disperror( char *p_string ) {
	clear_message( );                                       /* from printing.obj */
	dispstrhgc( p_string, 40 - ( strlen( p_string ) / 2 ), 13, REVERSEATTR );
	/* errorsound( ); */
	while ( !keypressed( ) );
	clear_message( );                                       /* from printing.obj */
}
Beispiel #2
0
/*
 * Print a formatted message to stderr, no colour is added.
 * Interesting - this function implicitly clears 'errno'
 */
void
error_message(
	const char *fmt,
	...)
{
	va_list ap;

	va_start(ap, fmt);

	errno = 0;
	clear_message();
	vsnprintf(mesg, sizeof(mesg), fmt, ap);

	my_fputs(mesg, stderr);	/* don't use my_fprintf() here due to %format chars */
	my_fflush(stderr);

	if (cmd_line) {
		my_fputc('\n', stderr);
		fflush(stderr);
	} else {
		stow_cursor();
		(void) sleep(2);
		clear_message();
	}

	va_end(ap);
}
Beispiel #3
0
unsigned int playlist_loadlist_mainload(struct playlist_side_info *psi,char *listname,unsigned int loadtype,char *filtermask)
{
 struct listhandler_s *listhand;
 struct playlist_entry_info *laste;
 char loaddir[MAX_PATHNAMELEN];

 display_clear_timed_message();

 display_message(0,0,"Loading list (press ESC to stop) ...");

 laste=psi->lastentry;

 if(loadtype&PLL_STDIN){
  load_m3u(psi,stdin,mpxplay_playlist_startdir(),filtermask);
 }else{
  listhand=select_listhandler_by_ext(listname);
  if(listhand){
   pds_getpath_from_fullname(loaddir,listname);
   listhand->loadlist(psi,listname,loaddir,filtermask);
  }
 }

 if(psi->lastentry>=psi->firstentry)
  playlist_enable_side(psi);
 else
  playlist_disable_side_full(psi);

 clear_message();

 if(psi->lastentry>laste)
  return 1;
 return 0;
}
Beispiel #4
0
/*
 * Print a formatted colour message at the bottom of the screen, wait a while
 */
void
wait_message(
	unsigned int sdelay,
	const char *fmt,
	...)
{
	va_list ap;

	va_start(ap, fmt);

	clear_message();
#ifdef HAVE_COLOR
	fcol(tinrc.col_message);
#endif /* HAVE_COLOR */

	vsnprintf(mesg, sizeof(mesg), fmt, ap);
	my_fputs(mesg, stdout);

#ifdef HAVE_COLOR
	fcol(tinrc.col_normal);
#endif /* HAVE_COLOR */
	cursoron();
	my_flush();

	(void) sleep(sdelay);
/*	clear_message(); would be nice, but tin doesn't expect this yet */
	va_end(ap);
}
Beispiel #5
0
/*
 * Centre a formatted colour message at the bottom of the screen
 */
void
info_message(
	const char *fmt,
	...)
{
	va_list ap;

	va_start(ap, fmt);

	clear_message();
#ifdef HAVE_COLOR
	fcol(tinrc.col_message);
#endif /* HAVE_COLOR */

	vsnprintf(mesg, sizeof(mesg), fmt, ap);

	center_line(cLINES, FALSE, mesg);	/* center the message at screen bottom */

#ifdef HAVE_COLOR
	fcol(tinrc.col_normal);
#endif /* HAVE_COLOR */
	stow_cursor();

	va_end(ap);
}
Beispiel #6
0
static void search_selection()
{
	GtkTextIter start;
	GtkTextIter end;
	gchar *text;
	gchar *euc_str;
	gint method;

	LOG(LOG_DEBUG, "IN : search_selection()");

	gtk_text_buffer_get_selection_bounds(text_buffer, &start, &end);
	text = gtk_text_buffer_get_text(text_buffer, &start, &end, FALSE);

	if(strlen(text) == 0)
		return;
	gtk_entry_set_text(GTK_ENTRY(word_entry), text);
	euc_str = iconv_convert("utf-8", "euc-jp", text);

	method = ebook_search_method();
	if(method == SEARCH_METHOD_INTERNET){
		web_search();
	} else 	if(method == SEARCH_METHOD_GREP){
		clear_message();
		grep_search(euc_str);
	} else {
		clear_message();
		ebook_search(euc_str, method);
		if(search_result == NULL)
			push_message(_("No hit."));
	}

	save_word_history(text);
	gtk_editable_select_region(GTK_EDITABLE(word_entry), 
				   0,
				   GTK_ENTRY(word_entry)->text_length);
//	show_result_tree();
	g_free(euc_str);

	LOG(LOG_DEBUG, "OUT : search_selection()");
}
Beispiel #7
0
/*
 * Reconnect to server after a timeout, reissue last command to
 * get us back into the pre-timeout state
 */
static int
reconnect(
	int retry)
{
	char buf[NNTP_STRLEN];

	/*
	 * Tear down current connection
	 */
	NNTP_HARD_CLOSE;
	if (!tinrc.auto_reconnect)
		ring_bell();

	DEBUG_IO((stderr, _("\nServer timed out, trying reconnect # %d\n"), retry));

	/*
	 * Exit tin if the user says no to reconnect. The exit code stops tin from trying
	 * to disconnect again - the connection is already dead
	 */
	if (!tinrc.auto_reconnect && prompt_yn(cLINES, _(txt_reconnect_to_news_server), TRUE) != 1)
		tin_done(NNTP_ERROR_EXIT);		/* user said no to reconnect */

	clear_message();

	strcpy(buf, last_put);			/* Keep copy here, it will be clobbered a lot otherwise */

	if (!nntp_open()) {
		/*
		 * Re-establish our current group and resend last command
		 */
		if (curr_group != NULL) {
			DEBUG_IO((stderr, _("Rejoin current group\n")));
			sprintf(last_put, "GROUP %s", curr_group->name);
			put_server(last_put);
			s_gets(last_put, NNTP_STRLEN, nntp_rd_fp);
#		ifdef DEBUG
			debug_nntp("<<<", last_put);
#		endif /* DEBUG */
			DEBUG_IO((stderr, _("Read (%s)\n"), last_put));
		}
		DEBUG_IO((stderr, _("Resend last command (%s)\n"), buf));
		put_server(buf);
		return 0;
	}

	if (--retry == 0)					/* No more tries? */
		tin_done(NNTP_ERROR_EXIT);

	return retry;
}
Beispiel #8
0
Datei: cmds.c Projekt: hankem/jed
/* I should try it like emacs--- if prefix argument, then save all without user
 intervention */
int save_some_buffers (void)
{
   Buffer *b, *tmp;
   int ans = 0;
   int err;

   b = CBuf;
   do
     {
	if ((b->flags & BUFFER_MODIFIED)
	    && (*b->file))
	  {
	     if (b->flags & AUTO_SAVE_JUST_SAVE) ans = 1;
	     else ans = jed_vget_y_n ("Buffer %s not saved. Save it",
				      b->name);

	     if (ans == -1)
	       /* warning--- bug here if user edits file at
		startup and forgets to save it then aborts. */
	       return -1;

	     if (ans == 1)
	       {
		  tmp = CBuf;
		  switch_to_buffer(b);

		  /* It should not be necessary to do this here.  Lower
		   * level routines will do it.
		   */
		  /* while (b->narrow != NULL) widen_buffer(b); */

		  err = jed_save_buffer_cmd ();
		  switch_to_buffer(tmp);
		  if (err < 0) return -1;
		  /* b->flags &= ~BUFFER_MODIFIED; */
		  /* b->flags |= AUTO_SAVE_BUFFER; */
		  b->hits = 0;
	       }
	  }

	b = b->next;
     }
   while (b != CBuf);

   clear_message ();
   return 1;
}
Beispiel #9
0
gboolean
mouse_leave_cb (GtkWidget * widget, GdkEventCrossing * e, gpointer data)
{
  /* Because sloppy focus is evil and produces extra leave and enter
   * events. */
  if (e->mode != GDK_CROSSING_NORMAL)
    return FALSE;

  clear_message ();

  if (game_state == GAME_SELECTED) {
    stop_spinning ();
    game_state = GAME_IDLE;
  }

  return FALSE;
}
Beispiel #10
0
void jouer_ui(jeu_s jeu, aff_s aff)
{
    coup_s c;
    int erreur=0;
    int x, y;

    while(!is_end(jeu))
    {
        maj_affichage(jeu, aff);
        if (jeu->participant[jeu->g->joueur].is_ai)
            c = choix_coup_ai(jeu);
        else
            c = saisir_coups(jeu, aff);
        erreur = jouer(jeu, c);


    if(!erreur == 0)
    {
        char buf[256];
        snprintf(buf, sizeof buf, "%s %d|%d -> %d|%d", error[erreur-1],
          c->source[ORD], c->source[ABS], c->destination[ORD], c->destination[ABS]);
        afficher_message(aff, buf);
    }
    else
    {
        clear_message(aff);
    }

    }
        clear();
        getmaxyx(stdscr, y, x);
        attron(A_BOLD | A_REVERSE); 
        keypad(stdscr, FALSE);
        if (jeu->participant[TIGRE].score == 7)
            mvprintw((y/2), (x/2)-23, "Les tigres ont gagnés !");
        else
            mvprintw((y/2), (x/2)-24, "Les chèvres ont gagnés !");  

    getch();
}
Beispiel #11
0
/*
 * Print a formatted error message to stderr, no colour is added.
 * This function implicitly clears 'errno'
 */
void
perror_message(
	const char *fmt,
	...)
{
	char buf[LEN];
	int err;
	va_list ap;

	err = errno;
	va_start(ap, fmt);

	clear_message();

	vsnprintf(buf, sizeof(buf), fmt, ap);

	va_end(ap);

	error_message("%s: Error: %s", buf, strerror(err));

	return;
}
Beispiel #12
0
static void search_selected(gchar *str)
{
	gchar *euc_str;
	gint method;
	glong len;

	LOG(LOG_DEBUG, "IN : search_selected(%s)", str);

	if(selection_mode <= SELECTION_DO_NOTHING) {
		LOG(LOG_DEBUG, "OUT : search_selected() = NOP1");
		return;
	}

	if(strcmp(previous, str) == 0){
		// Do nothing if the word is the save as before.
		LOG(LOG_DEBUG, "same as before");
		;
	} else {

		euc_str = iconv_convert("utf-8", "euc-jp", str);
		if(validate_euc_str(euc_str) == FALSE) {
			g_free(euc_str);
			LOG(LOG_DEBUG, "OUT : search_selected() = INVALID");
			return;
		}
		remove_space(euc_str);

		len = g_utf8_strlen(str, -1);

		if((auto_minchar <= len) && (len <= auto_maxchar)) {
			gtk_entry_set_text(GTK_ENTRY(word_entry), str);

			method = ebook_search_method();
			if((method == SEARCH_METHOD_INTERNET) ||
			   (method == SEARCH_METHOD_MULTI) ||
			   (method == SEARCH_METHOD_FULL_TEXT)){
				LOG(LOG_DEBUG, "OUT : search_selected() = NOP2");
				return;
			}

			if(selection_mode <= SELECTION_COPY_ONLY) {
				LOG(LOG_DEBUG, "OUT : search_selected() = COPY");
				return;
			}
			
			clear_message();
			clear_search_result();

			if(method == SEARCH_METHOD_GREP){
				grep_search(euc_str);
				show_result_tree();
				select_first_item();
				if(selection_mode == SELECTION_SEARCH_TOP)
					bring_to_top(main_window);
				save_word_history(str);
			} else {
				ebook_search_auto(euc_str, method);
				show_result_tree();
				if(search_result){
					if(selection_mode == SELECTION_POPUP) {
						show_result_in_popup();
					} else {
						select_first_item();
						if(selection_mode == SELECTION_SEARCH_TOP)
							bring_to_top(main_window);
					}
					save_word_history(str);
				} else {
					current_in_result = NULL;
					set_current_result(NULL);
					if(selection_mode == SELECTION_POPUP) {
						beep();
					} else {
						if(selection_mode == SELECTION_SEARCH_TOP)
							bring_to_top(main_window);
						push_message(_("No hit."));
					}
				}
			}
			
			sprintf(previous, "%s", str);
		} else {
			LOG(LOG_DEBUG, "OUT : search_selected() = LENGTH");
		}
		g_free(euc_str);
	}

	LOG(LOG_DEBUG, "OUT : search_selected()");
}
Beispiel #13
0
VOID c_serial_handler( VOID )
{
	atomic_up();
	
	CharIn = '\0';
	BYTE interrupt_status;
    interrupt_status = SERIAL1_USR;    
	SERIAL1_IMR = 3;
	
    if( interrupt_status & 1 )
    {
		CharIn = SERIAL1_RD;
		CharOut = CharIn;
    }  
	while (!(interrupt_status & 4))
	{
		interrupt_status = SERIAL1_USR;
	}
	SERIAL1_IMR = 2;  
    if ( interrupt_status & 4 )
    {
		switch(CharIn){
			case '\r':
				uprintf(crlfgt);
				if(command_flag == 1){
					store_message((CHAR)'\0');
					void * p = request_memory_block();
					send_message(KCD_PID,write_message(p, kcd_msg));
					command_flag = 0;
					clear_message();
				}
				break;
			case '%':
				SERIAL1_WD = '%';
				command_flag = 1;	
				break;
			case '!':
				SERIAL1_WD = CharOut;
				display_queue_all();	
				sleep(6);
				break;
			case '@':
				SERIAL1_WD = CharOut;
				task_manager();	
				sleep(6);
				break;
			case '#':
				display_mailbox();
				sleep(6);
				break;
			default:
				if(command_flag == 1){
					store_message((CHAR)CharOut);
				}
				SERIAL1_WD = CharOut;
				break;
		}
    }  	      
	
	atomic_down();
    return;
}
Beispiel #14
0
static unsigned int loaddir_scansubdirs(struct playlist_side_info *psi,char *searchpath)
{
 struct playlist_entry_info *pei;
 unsigned int filecount=0,scansupportedfilenamesonly;
 char *ext;
 struct mpxplay_diskdrive_data_s *mdds;
 struct pds_subdirscan_t dsi;
 char sout[128];

 if(!searchpath || !searchpath[0])
  return 0;

 mdds=playlist_loaddir_drivenum_to_drivemap(pds_getdrivenum_from_path(searchpath));
 if(!mdds){ // possible virtual drive path (only single files work!)
  if(!mpxplay_diskdrive_search_driver(searchpath))
   return 0;
  pei=playlist_editlist_add_entry(psi);
  if(!pei)
   return 0;
  if(playlist_editlist_add_filename(psi,pei,searchpath)<=0){
   playlist_editlist_del_entry(psi,pei);
   return 0;
  }
  goto finish_scan;
 }

 if(mpxplay_diskdrive_subdirscan_open(mdds,searchpath,_A_NORMAL,&dsi))
  return 0;

 display_clear_timed_message();

 ext=pds_strrchr(searchpath,'.');
 if(!funcbit_test(desktopmode,DTM_EDIT_ALLFILES) && ext && pds_strcmp(ext,".*")==0)
  scansupportedfilenamesonly=1;
 else
  scansupportedfilenamesonly=0;

 do{
  int fferror=mpxplay_diskdrive_subdirscan_findnextfile(mdds,&dsi);
  if(fferror<0)
   break;
  if(dsi.flags&SUBDIRSCAN_FLAG_SUBDIR)
   display_message(1,0,dsi.currdir);
  if((fferror==0) && !(dsi.ff->attrib&(_A_SUBDIR|_A_VOLID)) && (!scansupportedfilenamesonly || mpxplay_infile_check_extension(dsi.ff->name,mdds))){
   int len;
   pei=playlist_editlist_add_entry(psi);
   if(!pei)
    break;
   len=playlist_editlist_add_filename(psi,pei,dsi.fullname);
   if(len<=0){
    playlist_editlist_del_entry(psi,pei);
    if(len<0)
     break;
   }else{
    pei->filesize=dsi.ff->size;
    pds_memcpy(&pei->filedate,&dsi.ff->fdate,sizeof(pei->filedate));
    pei->mdds=mdds;
   }
   if(!(filecount&31)){
    snprintf(sout,sizeof(sout),"Read filenames (%3d) from ",(filecount+1));
    display_message(0,0,sout);
   }
   filecount++;
  }
 }while(pds_look_extgetch()!=KEY_ESC);

 mpxplay_diskdrive_subdirscan_close(mdds,&dsi);

finish_scan:

 if(psi->lastentry && (psi->lastentry>=psi->firstentry))
  playlist_enable_side(psi);
 else
  playlist_disable_side_full(psi);

 clear_message();

 if(pds_look_extgetch()==KEY_ESC){
  pds_extgetch();
  return KEY_ESC;
 }
 return 1;
}
Beispiel #15
0
/*
 * progressmeter in %
 */
void
show_progress(
	const char *txt,
	long count,
	long total)
{
	char display[LEN];
	int ratio;
	time_t curr_time;
	static char last_display[LEN];
	static const char *last_txt;
	static int last_length;
	static int last_ratio;
	static long last_total;
	static time_t last_update;
#ifdef HAVE_GETTIMEOFDAY
	static long last_count;
	static int average;
	static int samples;
	static int sum;
	static struct timeval last_time;
	static struct timeval this_time;
	int time_diff;
	int secs_left;
	long count_diff;
#endif /* HAVE_GETTIMEOFDAY */

	if (batch_mode || count <= 0 || total == 0)
		return;

	/* If this is a new progress meter, start recalculating */
	if ((last_txt != txt) || (last_total != total)) {
		last_length = 0;
		last_ratio = -1;
		last_display[0] = '\0';
		last_update = time(NULL) - 2;
	}

	curr_time = time(NULL);
	ratio = (int) ((count * 100) / total);
	if ((ratio == last_ratio) && (curr_time - last_update < 2))
		/*
		 * return if ratio did not change and less than 1-2 seconds since last
		 * update to reduce output
		 */
		return;

	last_update = curr_time;

#ifdef HAVE_GETTIMEOFDAY
	if (last_length == 0) {
		/* Don't print a "time remaining" this time */
		snprintf(display, sizeof(display), "%s %3d%%", txt, ratio);
		display[sizeof(display) - 1] = '\0';
		last_length = strlen(txt) + 5;

		/* Reset the variables */
		sum = average = samples = 0;
	} else {
		/* Get the current time */
		gettimeofday(&this_time, NULL);
		time_diff = (this_time.tv_sec - last_time.tv_sec) * 1000000;
		time_diff += (this_time.tv_usec - last_time.tv_usec);

		count_diff = (count - last_count);

		if (!count_diff) /* avoid div by zero */
			count_diff++;

		/*
		 * Calculate a running average based on the last 20 samples. For the
		 * first 19 samples just add all and divide by the number of samples.
		 * From the 20th sample on use only the last 20 samples to calculate
		 * the running averave. To make things easier we don't want to store
		 * and keep track of all of them, so we assume that the first sample
		 * was close to the current average and substract it from sum. Then,
		 * the new sample is added to the sum and the sum is divided by 20 to
		 * get the new average.
		 */
		if (samples == 20) {
			sum -= average;
			sum += (time_diff / count_diff);
			average = sum / 20;
		} else {
			sum += (time_diff / count_diff);
			average = sum / ++samples;
		}

		if (average >= 1000000)
			secs_left = (total - count) * (average / 1000000);
		else
			secs_left = ((total - count) * average) / 1000000;

		if (secs_left < 0)
			secs_left = 0;

		/* TODO: -> lang.c, difficult with hardcoded last_length */
		snprintf(display, sizeof(display), "%s %3d%% (%d:%02d remaining)", txt, ratio, secs_left / 60, secs_left % 60);
		last_length = strlen(txt) + 21 + secs_left / 600;
	}

	last_count = count;
	gettimeofday(&last_time, NULL);

#else /* HAVE_GETTIMEOFDAY */
	snprintf(display, sizeof(display), "%s %3d%%", txt, ratio);
#endif /* HAVE_GETTIMEOFDAY */

	/* Only display text if it changed from last time */
	if (strcmp(display, last_display)) {
		clear_message();
		MoveCursor(cLINES, 0);

#	ifdef HAVE_COLOR
		fcol(tinrc.col_message);
#	endif /* HAVE_COLOR */

		my_printf("%s", display);

#	ifdef HAVE_COLOR
		fcol(tinrc.col_normal);
#	endif /* HAVE_COLOR */

		my_flush();
		STRCPY(last_display, display);
	}

	last_txt = txt;
	last_total = total;
	last_ratio = ratio;
}