=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/term.c,v retrieving revision 1.1 retrieving revision 1.1.1.3 diff -u -p -r1.1 -r1.1.1.3 --- OpenXM_contrib/gnuplot/Attic/term.c 2000/01/09 17:00:56 1.1 +++ OpenXM_contrib/gnuplot/Attic/term.c 2003/09/15 07:09:26 1.1.1.3 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: term.c,v 1.1 2000/01/09 17:00:56 maekawa Exp $"; +static char *RCSid = "$Id: term.c,v 1.1.1.3 2003/09/15 07:09:26 ohara Exp $"; #endif /* GNUPLOT - term.c */ @@ -112,6 +112,7 @@ extern float xsize, ysize; /* internal pointsize for do_point */ static double term_pointsize; +int termcomp __PROTO((SORTFUNC_ARGS a, SORTFUNC_ARGS b)); static void term_suspend __PROTO((void)); static void term_close_output __PROTO((void)); static void null_linewidth __PROTO((double)); @@ -819,25 +820,51 @@ struct termentry term_tbl[] = #define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry)) +/* mainly useful for external code */ +GP_INLINE int +term_count() +{ + return TERMCOUNT; +} + void list_terms() { register int i; - char line_buffer[BUFSIZ]; + char *line_buffer = gp_alloc(BUFSIZ, "list_terms"); + int sort_idxs[TERMCOUNT]; + /* sort terminal types alphabetically */ + for( i = 0; i < TERMCOUNT; i++ ) + sort_idxs[i] = i; + qsort( sort_idxs, TERMCOUNT, sizeof(int), termcomp ); + /* now sort_idxs[] contains the sorted indices */ + StartOutput(); - sprintf(line_buffer,"\nAvailable terminal types:\n"); + strcpy(line_buffer, "\nAvailable terminal types:\n"); OutLine(line_buffer); for (i = 0; i < TERMCOUNT; i++) { - sprintf(line_buffer," %15s %s\n", - term_tbl[i].name, term_tbl[i].description); + sprintf(line_buffer, " %15s %s\n", + term_tbl[sort_idxs[i]].name, + term_tbl[sort_idxs[i]].description); OutLine(line_buffer); } EndOutput(); + free(line_buffer); } +int +termcomp(arga, argb) + SORTFUNC_ARGS arga; + SORTFUNC_ARGS argb; +{ + const int *a = arga; + const int *b = argb; + return( strcasecmp( term_tbl[*a].name, term_tbl[*b].name ) ); +} + /* set_term: get terminal number from name on command line * will change 'term' variable if successful */ @@ -961,7 +988,7 @@ void init_terminal() #ifdef NEXT env_term = getenv("TERM"); if (term_name == (char *) NULL - && env_term != (char *) NULL && strcmp(term, "next") == 0) + && env_term != (char *) NULL && strcmp(env_term, "next") == 0) term_name = "next"; #endif /* NeXT */ @@ -1181,6 +1208,7 @@ void test_term() key_entry_height = (t->v_char); /* border linetype */ + (*t->linewidth) (1.0); (*t->linetype) (-2); (*t->move) (0, 0); (*t->vector) (xmax_t - 1, 0);