Пример #1
0
// This is basically a rewrite of the putp that's supposed to appear in
// term.h, except it uses our "mini buffered IO code" from above
static void putp( char *s )
{
    int         c;
    int         pad;
    int         mand = FALSE;
    int         i;
    char        *bbuf;

    if( s == NULL )
        return;
    while( (c = *s++) != '\0' ) {
        // check and see if we're at the start of a padding sequence
        if( c == '$' && *s == '<' ) {
            bbuf = s;
            s++;
            pad = 0;
            // read until the end of the sequence or the end of the string
            while( (c = *s++) != '\0' && ( c != '>' ) ) {
                // suck up digits
                if( c >= '0' && c <= '9' ) {
                    pad *= 10;
                    pad += c;
                } else if( c == '.' ) {
                    // Skip tenth's
                    if( (c = *s) >= '0' && c <= '9' ) {
                        s++;
                        // cheap rounding
                        if( c >= '5' ) {
                            pad++;
                        }
                    }
                // Pay attention to the mandatory flag
                } else if( c == '/' ) {
                    mand = TRUE;
                }
                // Note that I'm completely ignoring the * flag( proportional
                // to number of lines padding ). I'm just assuming 1 line
                // always. This should work virtually all of the time because
                // we don't do anything excessively weird. ( like insert over
                // multiple lines )
                // Actually, we ignore any extra chars that end up in here.
            }
            if( c == '>' ) {
                // output padding only if required
                if( !xon_xoff || mand ) {
                    mand = FALSE;
                    for( i = 0; i < pad; i++ ) {
                        __putchar( pad_char[0] );
                    }
                }
            } else {
                __putchar( '$' );
                __puts( bbuf );
                return;
            }
        } else {
            __putchar( c );
        }
    }
}
Пример #2
0
int
_write (int    file,
    char * ptr,
    int    len)
{
    int r;

//    for(r=0;r<len;r++) uart_putc(ptr[r]);
#if 0	// UART������STM����������������
  int index;

  /* For example, output string by UART */
  for(index=0; index<len; index++)
  {
    if (ptr[index] == '\n')
    {
      __putchar('\r');
    }

    __putchar(ptr[index]);
  }
#endif

  return len;
}
Пример #3
0
int puts(const char * str)
{
	// There must be at least 1ms between USB frames (of up to 64 bytes)
	// This buffers all data and writes it out from the buffer one frame
	// and one millisecond at a time
#ifdef CFG_PRINTF_USBCDC
    if (USB_Configuration) 
    {
		while(*str)
			cdcBufferWrite(*str++);
		// Check if we can flush the buffer now or if we need to wait
		unsigned int currentTick = systickGetTicks();
		if (currentTick != lastTick)
		{
			uint8_t frame[64];
			uint32_t bytesRead = 0;
			while (cdcBufferDataPending())
			{
				// Read up to 64 bytes as long as possible
				bytesRead = cdcBufferReadLen(frame, 64);
				USB_WriteEP (CDC_DEP_IN, frame, bytesRead);
				systickDelay(1);
			}
			lastTick = currentTick;
		}
    }
#else
    // Handle output character by character in __putchar
    while(*str) __putchar(*str++);
#endif
	
	return 0;
}
Пример #4
0
void putstring(char *s, int x, int y, unsigned long *offscreen) {
	int i;
	
	for (i=0; i<strlen(s); i++) {
		__putchar(s[i], x+(i*FONT_WIDTH), y, offscreen);
	}	
}
Пример #5
0
static void __puts( char *s )
{
    int     c;

    if( s == NULL )
        return;
    while( (c = *s++) != '\0' ) {
        __putchar(c);
    }
}
int _write_r (struct _reent *r, int file, char * ptr, int len)
{  
  r = r;
  file = file;
  ptr = ptr;

#if 0
  int index;
  
  /* For example, output string by UART */
  for(index=0; index<len; index++)
  {
    if (ptr[index] == '\n')
    {
      __putchar('\r');
    }  

    __putchar(ptr[index]);
  }  
#endif   
  
  return len;
}
Пример #7
0
static int TI_PUT_FILE( char *fnam )
{
    fnam = fnam;
#if 0 //NYI: have to re-implement
    char        c;
    FILE        *fil;

    if( fnam!=NULL && fnam[0]!='\0' ){
        // open file
        fil= ti_fopen( fnam );
        if( fil==NULL ) return( FALSE );

        // output file to terminal
        while( ( c= fgetc( fil ) )!=EOF ){
            __putchar( c );
        }
        fclose( fil );
    }
#endif
    return( TRUE );
}
Пример #8
0
/* Repeat character c, n times. "a" indicates alternate character set.
 * x is the first column that we should be printing on. (used for a little
 * optimization)
 */
static void TI_REPEAT_CHAR( char c, int n, bool a, ORD x )
{
    bool        blank;
    int         len;
    char        *cparm_right;

    if( n == 0 )
        return;

    blank = OptimizeTerminfo && ( TI_FillColourSet ) && c == ' ' && !a;
    if( blank
      && x == ( UIData->width - n )
      && (len = strlen( clr_eol )) > 0
      && n > len ) {
        putp( clr_eol );
    } else if( blank
      && x == 0
      && clr_bol[0] != '\0'
      && n > (len = (strlen( cparm_right = tparm( parm_right_cursor, n )) + strlen( clr_bol ) ))
      && len > 0 ) {
        putp( cparm_right );
        putp( clr_bol );
    } else {
        if( a ) {
            TI_ACS_ON();
        }

        if( n >= TI_repeat_cutoff ) {
            putp( tparm( repeat_char, c, n ) );
        } else {
            for( ; n > 0; n-- ) {
                __putchar( c );
            }
        }

        if( a ) {
            TI_ACS_OFF();
        }
    }
}
Пример #9
0
static void QNX_SETCOLOUR( int f, int b )
{
    __putchar( 033 ); __putchar( '@' );
    __putchar( '0' + f );
    __putchar( '0' + b );
}
Пример #10
0
static void QNX_CURSOR_MOVE( int c, int r )
{
    __putchar( 033 ); __putchar( '=' );
    __putchar( r + ' ' );
    __putchar( c + ' ' );
}
Пример #11
0
static void QNX_SETCOLOUR( register int f, register int b )
{
    __putchar(033); __putchar('@');
    __putchar('0' + f);
    __putchar('0' + b);
}
Пример #12
0
static int td_refresh( int must )
/*******************************/
{
    int             i;
    int             incr;
    LP_PIXEL        bufp, sbufp;

    must |= UserForcedTermRefresh;
    UserForcedTermRefresh = false;

    if( dirty_area.row0 == dirty_area.row1 && dirty_area.col0 == dirty_area.col1 ) {
        td_hwcursor();
        __flush();
        return( 0 );
    }

QNXDebugPrintf4("td_refresh (%d,%d)->(%d,%d)", dirty_area.row0, dirty_area.col0, dirty_area.row1, dirty_area.col1);

    if( UIData->cursor_type != C_OFF )
        QNX_CURSOR_OFF();

    bufp = UIData->screen.origin;
    incr = UIData->screen.increment;
    sbufp = shadow;
    bufp += dirty_area.row0 * incr;
    sbufp += dirty_area.row0 * incr;

/*-
* minimize updates
*/
    for( i = dirty_area.row0; i < dirty_area.row1; i++ ) {
        int     j;
        int     lastattr = -1;      // invalid to start
        bool    ca_valid = false;   // is cursor address valid?

        for( j = dirty_area.col0; j < dirty_area.col1; j++ ) {
            if( !must && PIXELEQUAL( bufp[j], sbufp[j] ) ) {
                ca_valid = false;
                lastattr = -1;
                continue;
            }

            if( !ca_valid ) {
QNXDebugPrintf2("cursor address %d,%d\n",j,i);
                QNX_CURSOR_MOVE( j, i );
                ca_valid = true;
            }
            if( bufp[j].attr != lastattr ) {
                lastattr = new_attr( bufp[j].attr, lastattr );
            }
            if( bufp[j].ch < 0x20 )
                __putchar( 033 );
            __putchar( bufp[j].ch );
            sbufp[j] = bufp[j];
        }
        bufp += incr;
        sbufp += incr;
    }
    dirty_area.row0 = dirty_area.row1 = 0;
    dirty_area.col0 = dirty_area.col1 = 0;

    td_hwcursor();
    __flush();

    return( 0 );
}
Пример #13
0
void _ttywrch(int ch)
{
  __putchar(ch);
}
Пример #14
0
int fputc(int ch, FILE *f)
{
  __putchar(ch);
  return ch;
}
Пример #15
0
int puts(const char * str)
{
  while(*str) __putchar(*str++);

  return 0;
}
Пример #16
0
void putchar(const char c)
{
	__putchar(c);
}
Пример #17
0
static int __oflush( int c )
{
    __flush();
    //assert( _con_out.curp < _con_out.ebuf );
    return( __putchar( c ) );
}
Пример #18
0
static void QNX_CURSOR_MOVE( register int c, register int r )
{
    __putchar(033); __putchar('=');
    __putchar(r+' ');
    __putchar(c+' ');
}