Exemplo n.º 1
0
int
do_More(int *linesp)
{
    int ret = TRUE;
    if (! tty)
	return TRUE;
    save_Tty(0);
    set_Raw(0);
    clr_Echo(0);
    SetStandout();
    prnt_Prompt("More ? [n|<return>|<space>] ");
    ClrStandout();
    (void) fflush(stdout);
    switch (hm_getchar()) {
	case 'Q' :
	case 'q' :
	case 'N' :
	case 'n' :
	    ret = FALSE;
	    break;
	case LF :
	case CR :
	    *linesp = 1;
	    break;
	default :
	    *linesp = (PROMPT_LINE-TOP_SCROLL_WIN);
	    break;
    }
    reset_Tty(0);
    return ret;
}
Exemplo n.º 2
0
/*	g e t _ R e g i o n _ N a m e ( )
	TENEX-style name completion.
	Returns a linked-list of pointers to octree leaf nodes.
*/
OcList	*
get_Region_Name(char *inbuf, int bufsz, char *msg)
{
    static char	buffer[BUFSIZ];
    char	*p = buffer;
    int	c;
    OcList		*oclistp = OCLIST_NULL;
    if ( tty )
    {
	save_Tty( 0 );
	set_Raw( 0 );
	clr_Echo( 0 );
    }
    prnt_Prompt( msg );
    *p = NUL;
    do
    {
	(void) fflush( stdout );
	c = hm_getchar();
	switch ( c )
	{
	    case SP :
	    {
		if (	reg_triep == TRIE_NULL
			||	(oclistp = get_Trie( buffer, reg_triep ))
			== OCLIST_NULL
		    )
		    (void) putchar( BEL );
		for (; p > buffer; p-- )
		    (void) putchar( BS );
		(void) printf( "%s", buffer );
		(void) ClrEOL();
		(void) fflush( stdout );
		p += strlen( buffer );
		break;
	    }
	    case Ctrl('A') : /* Cursor to beginning of line.	*/
		if ( p == buffer )
		{
		    ring_Bell();
		    break;
		}
		for (; p > buffer; p-- )
		    (void) putchar( BS );
		break;
	    case Ctrl('B') :
	    case BS : /* Move cursor back one character.		*/
		if ( p == buffer )
		{
		    ring_Bell();
		    break;
		}
		(void) putchar( BS );
		--p;
		break;
	    case Ctrl('D') : /* Delete character under cursor.	*/
	    {
		char	*q = p;
		if ( *p == NUL )
		{
		    ring_Bell();
		    break;
		}
		for (; *q != NUL; ++q )
		{
		    *q = *(q+1);
		    (void) putchar( *q != NUL ? *q : SP );
		}
		for (; q > p; --q )
		    (void) putchar( BS );
		break;
	    }
	    case Ctrl('E') : /* Cursor to end of line.		*/
		if ( *p == NUL )
		{
		    ring_Bell();
		    break;
		}
		(void) printf( "%s", p );
		p += strlen( p );
		break;
	    case Ctrl('F') : /* Cursor forward one character.	*/
		if ( *p == NUL || p-buffer >= bufsz-2 )
		{
		    ring_Bell();
		    break;
		}
		(void) putchar( *p++ );
		break;
	    case Ctrl('G') : /* Abort input.			*/
		ring_Bell();
		prnt_Event( "Aborted." );
		goto	clean_return;
	    case Ctrl('K') : /* Erase from cursor to end of line.	*/
		if ( *p == NUL )
		{
		    ring_Bell();
		    break;
		}
		ClrEOL();
		*p = NUL;
		break;
	    case Ctrl('P') : /* Yank previous contents of "inbuf".	*/
	    {
		int	len = strlen( inbuf );
		if ( (p + len) - buffer >= BUFSIZ )
		{
		    ring_Bell();
		    break;
		}
		bu_strlcpy( p, inbuf, (size_t)bufsz );
		printf( "%s", p );
		p += len;
		break;
	    }
	    case Ctrl('U') : /* Erase from start of line to cursor.	*/
		if ( p == buffer )
		{
		    ring_Bell();
		    break;
		}
		for (; p > buffer; --p )
		{
		    char	*q = p;
		    (void) putchar( BS );
		    for (; *(q-1) != NUL; ++q )
		    {
			*(q-1) = *q;
			(void) putchar( *q != NUL ? *q : SP );
		    }
		    for (; q > p; --q )
			(void) putchar( BS );
		}
		break;
	    case Ctrl('R') : /* Print line, cursor doesn't move.	*/
	    {
		int	i;
		if ( buffer[0] == NUL )
		    break;
		for ( i = p - buffer; i > 0; i-- )
		    (void) putchar( BS );
		(void) printf( "%s", buffer );
		for ( i = strlen( buffer ) - (p - buffer); i > 0; i-- )
		    (void) putchar( BS );
		break;
	    }
	    case DEL : /* Delete character behind cursor.		*/
	    {
		char	*q = p;
		if ( p == buffer )
		{
		    ring_Bell();
		    break;
		}
		(void) putchar( BS );
		for (; *(q-1) != NUL; ++q )
		{
		    *(q-1) = *q;
		    (void) putchar( *q != NUL ? *q : SP );
		}
		for (; q > p; --q )
		    (void) putchar( BS );
		p--;
		break;
	    }
	    case CR :
	    case LF :
	    case EOF :
		if (	reg_triep == TRIE_NULL
			||	(oclistp = get_Trie( buffer, reg_triep ))
			== OCLIST_NULL
		    )
		{
		    (void) putchar( BEL );
		    break;
		}
		else
		{
		    bu_strlcpy( inbuf, buffer, (size_t)bufsz );
		    prnt_Event( "" );
		    goto clean_return;
		}
	    case Ctrl('V') :
		/* Escape character, do not process next char.	*/
		c = hm_getchar();
		/* Fall through to default case!		*/
	    default : /* Insert character at cursor.		*/
	    {
		char	*q = p;
		int	len = strlen( p );
		/* Scroll characters forward.			*/
		if ( c >= NUL && c < SP )
		    (void) printf( "%s", char_To_String( c ) );
		else
		    (void) putchar( c );
		for (; len >= 0; len--, q++ )
		    (void) putchar( *q == NUL ? SP : *q );
		for (; q > p; q-- )
		{
		    (void) putchar( BS );
		    *q = *(q-1);
		}
		*p++ = c;
		break;
	    }
	} /* End switch. */
    }
    while ( strlen( buffer ) < BUFSIZ);
    ring_Bell();
    prnt_Event( "Buffer full." );
    clean_return :
	prnt_Prompt( "" );
    if ( tty )
	reset_Tty( 0 );
    return	oclistp;
}