示例#1
0
int     fleches(struct termios term, t_list **newlist, t_listel *elem)
{
  char  *buffer;

  elem = (*newlist)->racine;
  buffer = malloc(sizeof(char) * 4096);
  while (1)
    {
      bzero(buffer, sizeof(buffer));
      read(0, buffer, 3);
      enter(buffer, elem, newlist);
      if (buffer[0] == 27 && strlen(buffer) <= 2)
        {
          term.c_lflag = (ICANON | ECHO);
          tcsetattr(0, 0, &term);
          return (0);
        }
      else if (buffer[0] == 27 && buffer[2] == 68 && elem->prev)
        {
          elem = elem->prev;
          cleanprint(newlist, elem);
        }
      else if (buffer[0] == 27 && buffer[2] == 67 && elem->next)
        {
          elem = elem->next;
          cleanprint(newlist, elem);
        }
    }
  return (0);
}
示例#2
0
/* Name column */
void xml_namecell(FILE *outf, Outchoices *od, choice rep, char *name,
  choice source, unsigned int width, logical name1st, logical isfirst,
  logical rightalign, Alias *aliashead, Include *linkhead, logical ispage,
  unsigned int spaces, char *baseurl)
{
	char *p, *q;
	int n;

	XML_TRACE(0); 

	// no output aliasing is done yet. not sure it will be done either.


	// we don't care, but by testing it we avoid printing the column twice.
	if ( !isfirst && name )
	{
		XML_OUT( XMLDBG "<col name=\"name\">" );

		switch( rep) {
		case REP_MONTH:
		case REP_YEAR:
		case REP_WEEK:
		case REP_QUARTERLY:
		case REP_DAYREP:
		case REP_HOURREP:
		case REP_QUARTERREP:
		case REP_FIVEREP:
		case REP_DAYSUM:
		case REP_HOURSUM:
		case REP_QUARTERSUM:
		case REP_FIVESUM:
		case REP_WEEKHOUR:	
			// this is split because strtok needs to be called in the right order.
			XML_OUT( "<timespan from=\"%s\" ", strtok(name," ") ); 
			XML_OUT( "to=\"%s\" ", strtok( NULL," ") );
			switch( rep ) {
			case REP_DAYSUM:
				XML_OUT( "dayofweek=\"%s\" />", strtok( NULL," ") );
				break;
			case REP_HOURSUM:
				XML_OUT( "hour=\"%s\" />", strtok( NULL," ") );
				break;
			case REP_QUARTERSUM:
				XML_OUT( "minute=\"%s\" />", strtok( NULL," ") );
				break;
			case REP_FIVESUM:
				XML_OUT( "minute=\"%s\" />", strtok( NULL," ") );
				break;
			case REP_WEEKHOUR:
				XML_OUT( "dayofweek=\"%s\" ", strtok( NULL," ") );
				XML_OUT( "hour=\"%s\" />", strtok( NULL," ") );
				break;
			default:
				XML_OUT( "/>" );
			}
			break;
		case REP_CODE:
			strtok(name, " ");	// assumption: name = "nnn text"
			XML_OUT( name );
			break;
//			n=array_index++;
//			XML_OUT( "%d", (int)(opts->arraydata[rep-FIRST_ARRAYREP][n].threshold) );
//			break;
		case REP_OS:
			// kludge: the hardcoded OS names from tree.c are turned into i18n
			// keys - hardly a well thought out interface, but the best we can do
			// for the moment.
			p=strtolower(name);			// all lowercase
			while ( (q=strchr(p,' ')) ) *q='-';	// replace ' ' with '-'
			while ( (q=strchr(p,'/')) ) *q='-';
			
			XML_OUT( "<i18n key=\"os-%s\"/>", p );
			break;
		case REP_SIZE:
		case REP_PROCTIME:
			n=array_index++;
			XML_OUT( "%f", opts->arraydata[rep-FIRST_ARRAYREP][n].threshold );
			break; 
		case REP_DOM:
		case REP_TYPE:
			// kludge: if the string supplied is delimited by square brackets, 
			// we turn it into an i18n key.
			if ( *name=='[' && *(name+strlen(name)-1)==']' )
			{
				p=strtolower(name+1); 
				*(p+strlen(p)-1)=0;
				while ( (q=strchr(p,' ')) ) *q='-';
				XML_OUT( "<i18n key=\"%s-%s\"/>", rep==REP_DOM?"domain":"type", p );
				break;
			}
			// this is a delibrate fall-thru.
		default:
			XML_OUT( "<![CDATA[%s]]>", cleanprint(name) );
			break;
		}
		XML_OUT( "</col>" );
	}

#if 0
extern char *workspace;

  choice savemultibyte;
  logical linked;
  int i;

  if (name1st != isfirst)
    return;

  if (isfirst)
    matchlengthn(outf, od, width - od->outputter->strlen(name), ' ');
  savemultibyte = od->multibyte;
  if (rep == REP_SIZE || rep == REP_PROCTIME)
    /* Kludge: for these two reports, we know the texts are things like
       "< 1" and we want to convert > and < */
    od->multibyte = FALSE;

  strcpy(workspace, name);
  do_aliasx(workspace, aliashead);

  if (!isfirst) {
    if (rightalign)
      i = (int)width - (int)od->outputter->strlen(workspace) - (int)spaces;
    else
      i = (int)spaces;
    matchlengthn(outf, od, i, ' ');
  }

  linked = (linkhead != NULL && included(name, ispage, linkhead));
  if (linked) {
    /* We link to the unaliased name, because the OUTPUTALIAS is usually in
       the nature of an annotation. */
    fputs("<a href=\"", outf);
    if (baseurl != NULL)
      htmlputs(outf, od, baseurl, IN_HREF);
//    xml_escfprintf(outf, name);
    fputs("\">", outf);
  }

  htmlputs(outf, od, workspace, UNTRUSTED);

  if (linked)
    fputs("</a>", outf);

  if (isfirst)
    fputs(": ", outf);

  od->multibyte = savemultibyte;  /* restore multibyte */
#endif
}