// 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; }
// 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; }