Esempio n. 1
0
// draw a box directly to display memory
int _near Drawbox_Cmd( LPTSTR pszCmdLine )
{
	register TCHAR *pszArg, *pszLine;
	int nTop, nLeft, nBottom, nRight, nStyle, nAttribute = -1, nFill = -1, n, nFlags = 0, nShade;

	if (( pszCmdLine == NULL ) || ( *pszCmdLine == _TEXT('\0') ))
		return ( Usage( DRAWBOX_USAGE ));

	// get the arguments & colors
	if ( sscanf( pszCmdLine, _TEXT("%d%d%d%d%d%n"), &nTop, &nLeft, &nBottom, &nRight, &nStyle, &n ) == 6 ) {

		pszLine = pszCmdLine + n;
		nAttribute = GetColors( pszLine, 0 );

		// check for a FILL color
		if (( *pszLine ) && ( _strnicmp( first_arg( pszLine ), BOX_FILL, 3 ) == 0 ) && (( pszArg = first_arg( next_arg( pszLine, 1 ))) != NULL )) {

			if ( _strnicmp( pszArg, BRIGHT, 3 ) == 0 ) {
				// set intensity bit
				nFill = 0x80;
				if (( pszArg = first_arg( next_arg( pszLine, 1 ))) == NULL )
					return ( Usage( DRAWBOX_USAGE ));
			} else
				nFill = 0;

			if (( nShade = color_shade( pszArg )) <= 15 ) {
				nFill |= ( nShade << 4 );
				next_arg( pszLine, 1 );
			}
		}

		// check for a SHADOW or ZOOM
		while ( *pszLine ) {
			if ( _strnicmp( pszLine, BOX_SHADOW, 3 ) == 0 )
				nFlags |= BOX_SHADOWED;
			else if ( _strnicmp( pszLine, BOX_ZOOM, 3 ) == 0 )
				nFlags |= BOX_ZOOMED;
			next_arg( pszLine, 1 );
		}
	}

	if (( nAttribute == -1 ) || ( verify_row_col( nTop, nLeft )) || ( verify_row_col( nBottom, nRight )))
		return ( Usage( DRAWBOX_USAGE ));

	if ( nLeft == 999 ) {
		if (( nLeft = (( GetScrCols() - nRight ) / 2 )) < 0 )
			nLeft = 0;
		nRight += nLeft;
	}

	if ( nTop == 999 ) {
		if (( nTop = (( GetScrRows() - nBottom ) / 2 )) < 0 )
			nTop = 0;
		nBottom += nTop;
	}

	_box( nTop, nLeft, nBottom, nRight, nStyle, nAttribute, nFill, nFlags, 1 );

	return 0;
}
Esempio n. 2
0
// draw a horizontal or vertical line directly to the display
static int _fastcall __drawline( LPTSTR pszCmdLine, int fVertical )
{
	register int nAttribute = -1;
	int nRow, nColumn, nLength, nStyle, n;

	// get the arguments & colors
	if (( pszCmdLine == NULL ) || ( *pszCmdLine == _TEXT('\0') ))
		return ( Usage( (( fVertical ) ? DRAWVLINE_USAGE : DRAWHLINE_USAGE )));

	if ( sscanf( pszCmdLine, _TEXT("%d%d%d%d%n"), &nRow, &nColumn, &nLength, &nStyle, &n ) == 5 )
		nAttribute = GetColors( pszCmdLine+n, 0 );

	// if row or column == 999, center the line
	if ( nColumn == 999 ) {
		nColumn = ( GetScrCols() - (( fVertical ) ? 0 : nLength )) / 2;
		if ( nColumn < 0 )
			nColumn = 0;
	}

	if ( nRow == 999 ) {
		nRow = ( GetScrRows() - (( fVertical ) ? nLength : 0 )) / 2;
		if ( nRow < 0 )
			nRow = 0;
	}

	return ((( nAttribute == -1 ) || ( verify_row_col( nRow, nColumn )) || ( _line( nRow, nColumn, nLength, nStyle, fVertical, nAttribute, 1 ) != 0 )) ? Usage( (( fVertical ) ? DRAWVLINE_USAGE : DRAWHLINE_USAGE ) ) : 0 );
}
Esempio n. 3
0
// Make sure the specified row & column are on the screen!
int verify_row_col( unsigned int row, unsigned int col )
{
	return ((( row > (unsigned int)GetScrRows() ) && ( row != 999 )) || (( col > (unsigned int)( GetScrCols() - 1 )) && ( col != 999 )));
}
Esempio n. 4
0
// draw a line, making proper connectors along the way
int _line(int row, int col, int len, int width, int direction, int attribute, int connector)
{
	int ch, i;
	int s_row, s_col, bits, bottom, right;
	unsigned char buffer[256];

	// truncate overly long lines
	if ( len > 255 )
		len = 255;

	// save starting row & column
	s_row = row;
	s_col = col;

	bottom = GetScrRows();
	right = GetScrCols() - 1;

	for ( i = 0; ( i < len ); ) {

		// Read original character - if not a line drawing char,
		//   just write over it.  Otherwise, try to make a connector
		//   if "connector" != 0
		if ( width == 0 )
			buffer[i] = gchBlock;

		else if (((connector == 0) && (i != 0) && (i != len - 1)) || ((ch = get_line_char(row,col)) == -1)) {

			if (direction == 0)
				buffer[i] = (char)((width == 1) ? 'Ä' : 'Í');
			else
				buffer[i] = (char)((width == 1) ? '³' : 'º');

		} else {

			bits = (char)((direction == 0) ? (breakdown[ch] & ~H2) | W | E | ((width == 1) ? 0 : H2) : (breakdown[ch] & ~V2) | N | S | ((width == 1) ? 0 : V2));

			if (( i == 0 ) || ( direction )) {

				// at start look & see if connect needed
				bits &= ~W;

				if (( col > 0 ) && (( ch = get_line_char( row, col-1 )) >= 0 )) {
					if ( breakdown[ ch ] & E )
						bits |= W;
				}
			}

			if (( i == len - 1 ) || ( direction )) {

				// at end look & see if connect needed
				bits &= ~E;

				if ((col < right) && ((ch = get_line_char(row, col+1)) >= 0)) {
					if (breakdown[ch] & W)
						bits |= E;
				}
			}

			if (( direction == 0 ) || ( i == 0 )) {

				// at start look & see if connect needed
				bits &= ~N;

				if (( row > 0 ) && (( ch = get_line_char(row-1, col)) >= 0)) {
					if ( breakdown[ ch ] & S )
						bits |= N;
				}
			}

			if (( direction == 0 ) || ( i == len - 1 )) {

				// at end look & see if connect needed
				bits &= ~S;

				if (( row < bottom ) && (( ch = get_line_char(row+1, col)) >= 0)) {
					if ( breakdown[ ch ] & N )
						bits |= S;
				}
			}

			buffer[i] = line_chars[ bits ];
		}

		i++;

		if ( direction == 0 ) {
			if ( ++col > right )
				break;
		} else {
			if ( ++row > bottom )
				break;
		}
	}

	buffer[i] = '\0';

	// write the line directly to the display
	if ( direction == 0 )
		WriteStrAtt( s_row, s_col, attribute, buffer );
	else
		WriteVStrAtt( s_row, s_col, attribute, buffer );

	return 0;
}
Esempio n. 5
0
// create or display environment variables or aliases
int set_cmd( int argc, char **argv )
{
    char *arg;
    long fSet;
    PCH feptr, pchList;
    char szBuffer[CMDBUFSIZ];

    init_page_size();

    // set the pointer to either the environment or the alias list
    if ( _stricmp( gpInternalName, SET_COMMAND ) == 0 )  {

        pchList = 0L;

    } else
        pchList = glpAliasList;

    // strip leading switches
    if (( GetSwitches( argv[1], "AMPR", &fSet, 1 ) != 0) || (( fSet & SET_READ ) && ( first_arg( argv[1] ) == NULL )))
        return ( usage(( pchList == glpAliasList ) ? ALIAS_USAGE : SET_USAGE ));

    // check for master environment set
    if (( pchList == 0L ) && ( fSet & SET_MASTER ))
        pchList = glpMasterEnvironment;

    // read environment or alias file(s)
    if ( fSet & SET_READ )
        return ( SetFromFile( argv[1], pchList, 0 ));

    // pause after each page
    if ( fSet & SET_PAUSE ) {
        gnPageLength = GetScrRows();
    }

    if ( first_arg( argv[1] ) == NULL ) {

        if ( pchList == 0L )
            pchList = glpEnvironment;

        // print all the variables or aliases
        for ( feptr = pchList; ( *feptr != '\0' ); feptr = next_env( feptr ) ) {
            more_page( feptr, 0 );
        }

        if ( pchList == glpEnvironment ) {

            if (( arg = get_list( BEGINLIBPATH, pchList )) != 0L ) {
                sprintf( szBuffer, FMT_TWO_EQUAL_STR, BEGINLIBPATH, arg );
                more_page( szBuffer, 0 );
            }

            if (( arg = get_list( ENDLIBPATH, pchList )) != 0L ) {
                sprintf( szBuffer, FMT_TWO_EQUAL_STR, ENDLIBPATH, arg );
                more_page( szBuffer, 0 );
            }
        }

        // return an error message if no aliases exist
        // just return if no environment variables exist
        return (( feptr == glpAliasList ) ? error( ERROR_4DOS_NO_ALIASES, NULL ) : 0 );
    }

    if ( fSet & SET_EXPRESSION ) {

        if (( arg = strchr( argv[1], '=' )) != NULL )
            arg = skipspace( ++arg );
        else
            arg = argv[1];

        evaluate( arg );
        if ( cv.bn < 0 )
            qputs( arg );

        // create/modify/delete a variable
        return (( arg == argv[1] ) ? 0 : add_list( argv[1], pchList ));
    }

    // display the current variable or alias argument?
    // (setting environment vars requires a '='; it's optional with aliases)
    if ((( arg = strchr( argv[1], '=' )) == NULL ) && (( pchList == 0L ) || ( ntharg( argv[1], 1 ) == NULL ))) {

        if (( feptr = get_list( argv[1], pchList )) == 0L ) {
            return ( error((( pchList == glpAliasList ) ? ERROR_4DOS_NOT_ALIAS : ERROR_4DOS_NOT_IN_ENVIRONMENT),argv[1]));
        }

        printf( FMT_FAR_STR_CRLF, feptr );
        return 0;
    }

    // create/modify/delete a variable or alias
    return ( add_list( argv[1], pchList ));
}
Esempio n. 6
0
// Make sure the specified row & column are on the screen!
int _fastcall verify_row_col( unsigned int nRow, unsigned int nColumn )
{
	return ((( nRow > (unsigned int)GetScrRows() ) && ( nRow != 999 )) || (( nColumn > (unsigned int)( GetScrCols() - 1 )) && ( nColumn != 999 )));
}
Esempio n. 7
0
// draw a line, making proper connectors along the way
int PASCAL _line( int nRow, int nColumn, int nLength, int nWidth, int nDirection, int nAttribute, int nConnector )
{
	register int ch, i;
	int nSavedRow, nSavedColumn, nBits, nBottom, nRight;
	TCHAR szBuffer[256];

	// truncate overly long lines
	if ( nLength > 255 )
		nLength = 255;

	// save starting row & column
	nSavedRow = nRow;
	nSavedColumn = nColumn;

	nBottom = GetScrRows();
	nRight = GetScrCols() - 1;

	// check for non-ASCII character sets
	if ( QueryCodePage() == 932 )
		nWidth = 0;

	for ( i = 0; ( i < nLength ); ) {

		// Read original character - if not a line drawing char,
		//   just write over it.  Otherwise, try to make a connector
		//   if "connector" != 0
		if ( nWidth == 0 )
			szBuffer[i] = gchBlock;

		else if ((( nConnector == 0 ) && ( i != 0 ) && ( i != nLength - 1 )) || (( ch = GetLineChar( nRow, nColumn )) == -1 )) {

			if ( nDirection == 0 )
				szBuffer[i] = (( nWidth == 1 ) ? 'Ä' : 'Í' );
			else
				szBuffer[i] = (( nWidth == 1 ) ? '³' : 'º' );

		} else {

			nBits = (( nDirection == 0 ) ? ( szBreakdown[ch] & ~H2 ) | W | E | (( nWidth == 1 ) ? 0 : H2 ) : ( szBreakdown[ch] & ~V2 ) | N | S | (( nWidth == 1 ) ? 0 : V2 ));

			if (( i == 0 ) || ( nDirection )) {

				// at start look & see if connect needed
				nBits &= ~W;

				if (( nColumn > 0 ) && (( ch = GetLineChar( nRow, nColumn-1 )) >= 0 )) {
					if ( szBreakdown[ ch ] & E )
						nBits |= W;
				}
			}

			if (( i == nLength - 1 ) || ( nDirection )) {

				// at end look & see if connect needed
				nBits &= ~E;

				if ((nColumn < nRight) && ((ch = GetLineChar(nRow, nColumn+1)) >= 0)) {
					if (szBreakdown[ch] & W)
						nBits |= E;
				}
			}

			if (( nDirection == 0 ) || ( i == 0 )) {

				// at start look & see if connect needed
				nBits &= ~N;

				if (( nRow > 0 ) && (( ch = GetLineChar(nRow-1, nColumn)) >= 0)) {
					if ( szBreakdown[ ch ] & S )
						nBits |= N;
				}
			}

			if (( nDirection == 0 ) || ( i == nLength - 1 )) {

				// at end look & see if connect needed
				nBits &= ~S;

				if (( nRow < nBottom ) && (( ch = GetLineChar(nRow+1, nColumn)) >= 0)) {
					if ( szBreakdown[ ch ] & N )
						nBits |= S;
				}
			}

			szBuffer[i] = szLineChars[ nBits ];
		}

		i++;

		if ( nDirection == 0 ) {
			if ( ++nColumn > nRight )
				break;
		} else {
			if ( ++nRow > nBottom )
				break;
		}
	}

	szBuffer[i] = '\0';

	// write the line directly to the display
	if ( nDirection == 0 )
		WriteStrAtt( nSavedRow, nSavedColumn, nAttribute, szBuffer );
	else
		WriteVStrAtt( nSavedRow, nSavedColumn, nAttribute, szBuffer );

	return 0;
}
Esempio n. 8
0
// print the file on the default printer
void ListPrintFile( void )
{
	register int i, n;
	int c, nRows, nBytesPrinted, nFH;
	long lTemp;
	POPWINDOWPTR wn;
	TCHAR szBuffer[MAXLISTLINE+1];
	int fKBHit;
	
	// disable ^C / ^BREAK handling
	HoldSignals();
	
	wn = wOpen( 2, 1, 4, strlen( LIST_PRINTING ) + 8, nInverse, LIST_PRINT_TITLE, NULL );
	wn->nAttrib = nNormal;
	wClear();
	sprintf( szBuffer, LIST_QUERY_PRINT, LIST_PRINT_FILE_CHAR, LIST_PRINT_PAGE_CHAR );
	wWriteListStr( 0, 1, wn, szBuffer );
	
	if ((( c = GetKeystroke( EDIT_ECHO | EDIT_UC_SHIFT | EDIT_BIOS_KEY )) == LIST_PRINT_FILE_CHAR ) || ( c == LIST_PRINT_PAGE_CHAR )) {
		
		// save start position
		lTemp = LFile.lViewPtr;
		
		// display "Printing ..."
		wWriteListStr( 0, 1, wn, LIST_PRINTING );
	
		if (( nFH = _sopen((( gpIniptr->Printer != INI_EMPTYSTR ) ? gpIniptr->StrData + gpIniptr->Printer : _TEXT("LPT1") ), (_O_BINARY | _O_WRONLY | _O_CREAT), _SH_DENYNO, _S_IWRITE | _S_IREAD )) >= 0 ) {

			if ( setjmp( cv.env ) == -1 ) {
				_close( nFH );
				return;
			}

			// reset to beginning of file
			if ( c == LIST_PRINT_FILE_CHAR )
				ListSetCurrent( 0L );
			else {
				nRows = GetScrRows();
				ListSetCurrent( LFile.lViewPtr );
			}
			
			// print the header (filename, date & time)
			qprintf( nFH, _TEXT("%s   %s  %s\r\n\r\n"), LFile.szName, gdate( 0 ), gtime( gaCountryInfo.fsTimeFmt ) );

			do {
				// abort printing if a key is hit

				// kbhit() in DOS tries to read from STDIN, which screws
				//	 up a LIST /S pipe
				_asm {
					mov 	ah, 1
					int 	16h
					mov 	fKBHit, 1
					jnz 	KBHDone
					mov 	fKBHit, 0
KBHDone:
				}
				if ( fKBHit && ( GetKeystroke( EDIT_NO_ECHO | EDIT_BIOS_KEY ) == ESC ))
					break;

				i = FormatLine( szBuffer, MAXLISTLINE, LFile.lViewPtr, &nBytesPrinted, TRUE );
				LFile.lViewPtr += 16;
				
				// replace 0-31 with "."
				if ( lListFlags & LIST_HEX ) {
					for ( n = 0; ( n < i ); n++ ) {
						if ( szBuffer[n] < 32 )
							szBuffer[n] = _TEXT('.');
					}
				}
				
				if (( c == LIST_PRINT_PAGE_CHAR ) && ( nRows-- <= 0 ))
					break;
				
			} while (( nBytesPrinted > 0 ) && ( qprintf( nFH, _TEXT("%.*s\r\n"), i, szBuffer ) > 0 ));
			
			// print a formfeed
			qputc( nFH, _TEXT('\014') );
			_close( nFH );
			
			// restore start position
			LFile.lViewPtr = lTemp;
			ListSetCurrent( LFile.lViewPtr );
			
		} else
			honk();
	}
	
	wRemove( wn );
	
	// enable ^C / ^BREAK handling
	EnableSignals();
}
Esempio n. 9
0
// create or display environment variables or aliases
static int _fastcall __Set( LPTSTR pszCmdLine, TCHAR _far * pchList )
{
	LPTSTR pszArg;
	long fSet = 0L;
	TCHAR _far *lpszVars;

	init_page_size();

	// set the pointer to the environment, alias, or function list

	// strip leading switches
	if (( pszCmdLine != NULL ) && ( *pszCmdLine == gpIniptr->SwChr )) {
		if ( GetSwitches( pszCmdLine, "AMPR", &fSet, 1 ) != 0 )
			return USAGE_ERR;
	}

	// check for master environment set
	if (( pchList == glpEnvironment ) && ( fSet & SET_MASTER ))
		pchList = glpMasterEnvironment;

	// read environment or alias file(s)
	if ( fSet & SET_READ )
		return ( SetFromFile( pszCmdLine, pchList, fSet & ( SET_DEFAULT | SET_SYSTEM | SET_USER | SET_VOLATILE )));

	if ( setjmp( cv.env ) == -1 )
		return CTRLC;

	// pause after each page
	if ( fSet & SET_PAUSE ) {
		gnPageLength = GetScrRows();
	}

	if (( pszCmdLine == NULL ) || ( *(pszCmdLine = skipspace( pszCmdLine )) == _TEXT('\0'))) {

		// print all the variables or aliases
		for ( lpszVars = pchList; ( *lpszVars != _TEXT('\0') ); lpszVars = next_env( lpszVars ) ) {

			more_page( lpszVars, 0 );
		}

		// return an error if no entries exist
		return (( lpszVars == pchList ) ? ERROR_LIST_EMPTY : 0 );
	}

	if ( fSet & SET_EXPRESSION ) {

		if (( pszArg = strchr( pszCmdLine, _TEXT('=') )) != NULL ) {

			if (( pszArg > pszCmdLine ) && ( strchr( _TEXT("+-*/%&^|><"), pszArg[-1] ) != NULL )) {

				TCHAR szBuf[256];

				// it's an assignment operator ("set /a test+=2")
				sscanf( pszCmdLine, _TEXT(" %[^ +-*/%&^|><=]"), szBuf );
				strcpy( pszArg, pszArg+1 );

				strins( pszCmdLine, _TEXT("=") );
				strins( pszCmdLine, szBuf );
				pszArg = pszCmdLine + strlen( szBuf ) + 1;

			} else
				pszArg = skipspace( pszArg+1 );

		} else
			pszArg = pszCmdLine;
		StripQuotes( pszArg );

		evaluate( pszArg );
		if ( cv.bn < 0 ) {
			qputs( pszArg );
			crlf();
		}

		// create/modify/delete a variable
		return (( pszArg == pszCmdLine ) ? 0 : add_list( pszCmdLine, pchList ));
	}

	// display the current variable or alias argument?
	// (setting environment vars requires a '='; it's optional with aliases)
	if ((( pszArg = strchr( pszCmdLine, _TEXT('=') )) == NULL ) && (( pchList == 0L ) || ( ntharg( pszCmdLine, 0x8001 ) == NULL ))) {

		if (( lpszVars = get_list( pszCmdLine, pchList )) == 0L ) {

			return ERROR_NOT_IN_LIST;
		}

		printf( FMT_FAR_STR_CRLF, lpszVars );
		return 0;
	}

	// create/modify/delete a variable or alias
	return ( add_list( pszCmdLine, pchList ));
}