home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
MNO100.ZIP
/
MNOEXAMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-19
|
16KB
|
567 lines
/*------------------------------------------------------------*/
/* MNOEXAMP.C ( OS/2 ) */
/* */
/* */
/* Demonstrate the MNOCALLS library functions. */
/* */
/* */
/*------------------------------------------------------------*/
#include <stdio.h> /* Library I/O routines. */
#include <stdlib.h> /* Library common routines. */
#include <string.h> /* Library string routines. */
#define INCL_BASE
#include <os2.h>
#include "SYMTYPES.H" /* Type definitions. */
#include "MNOCALLS.H" /* DLL function definitions.*/
main ()
{
{
USHORT usRow ;
USHORT usColumn ;
USHORT fStatus ;
fStatus = MnoGetCurPos ( &usRow, &usColumn, 0 ) ;
if ( ! fStatus )
{
if ( fStatus == ERROR_OPEN_FAILED )
fprintf (
stderr,
"\nMNOEXAMP has failed because the MNODRVR.SYS device\n"
"driver did not open properly. Status: %u.\n",
fStatus ) ;
else
fprintf (
stderr,
"\nMNOEXAMP has failed on the first attempt to use\n"
"MNOCALLS.DLL. Status: %u.\n",
fStatus ) ;
exit ( 1 ) ;
}
}
{
USHORT usRow ;
USHORT usColumn ;
USHORT fStatus ;
usRow = 1 ;
usColumn = 10 ;
fStatus = MnoSetCurPos ( usRow, usColumn, 0 ) ;
// This sets the cursor position to (1, 10),
// where the origin (0, 0) is defined as the
// upper left corner of the screen.
if ( ! fStatus )
{
// Error handling.
}
}
{
VIOCURSORINFO vioCursorInfo ;
USHORT fStatus ;
fStatus = MnoGetCurType ( &vioCursorInfo, 0 ) ;
// This gets the monochrome cursor type
// information.
if ( ! fStatus )
{
// Error handling.
}
}
{
VIOCURSORINFO vioCursorInfo ;
USHORT fStatus ;
vioCursorInfo.yStart = 0 ;
vioCursorInfo.cEnd = 13 ;
vioCursorInfo.cx = 1 ;
vioCursorInfo.attr = 0 ;
fStatus = MnoSetCurType ( &vioCursorInfo, 0 ) ;
// This sets the monochrome cursor as a full
// 14 scan lines in height and it is made
// visible.
if ( ! fStatus )
{
// Error handling.
}
}
{
VIOPHYSBUF vioPhysBuf ;
USHORT fStatus ;
USHORT fDetachStatus ;
USHORT fAnsi ;
BYTE fLockStatus ;
PCH pchMonoBuffer ;
/*---------------------------------------------*/
/* Here is how to test for a detached process. */
/*---------------------------------------------*/
fDetachStatus = MnoGetAnsi ( &fAnsi, 0 ) ;
if ( fDetachStatus == ERROR_VIO_DETACHED )
{
/*---------------------------------------------*/
/* Use other Mno functions to manipulate the */
/* MDA video buffer since we cannot detect */
/* screen group switching. */
/*---------------------------------------------*/
}
else
{
/*---------------------------------------------*/
/* If this is the foreground process, */
/* then prevent screen group switching until */
/* this function completes. */
/*---------------------------------------------*/
fStatus = VioScrLock ( LOCKIO_NOWAIT, &fLockStatus, 0 ) ;
fStatus = MnoGetPhysBuf ( &vioPhysBuf, 0 ) ;
pchMonoBuffer = MAKEP ( vioPhysBuf.asel [ 0 ], 0 ) ;
/*---------------------------------------------*/
/* At this point, pchMonoBuffer is a read/write*/
/* pointer into the MDA video buffer, which is */
/* an array of 2000 character-attribute cells. */
/*---------------------------------------------*/
// Bright 'A' in the
*pchMonoBuffer++ = 'A' ;
// first buffer position.
*pchMonoBuffer = 0x0F ;
if ( fLockStatus == LOCK_SUCCESS )
fStatus = VioScrUnLock ( 0 ) ;
}
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus ;
USHORT fAnsi ;
fStatus = MnoGetAnsi ( &fAnsi, 0 ) ;
// fAnsi is either ANSI_ON or ANSI_OFF.
if ( fStatus )
{
// Handle Detached Status or Error.
}
}
{
USHORT fStatus ;
USHORT fAnsi ;
fAnsi = ANSI_ON ;
fStatus = MnoSetAnsi ( fAnsi, 0 ) ;
fStatus = MnoWrtTTY ( "\n\n\n\t\bSample Text\r\n", 18, 0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
USHORT cText = 0 ;
UCHAR achText [ 500 ] = "" ;
// Read 30 characters starting at
// the 11th line and 2nd column.
cText = 30 ;
fStatus = MnoReadCharStr ( achText, &cText, 10, 1, 0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
USHORT cText = 0 ;
UCHAR achText [ 500 ] = "" ;
// Read 15 characters-attribute pairs
// starting at the 1st line and 5th
// column.
cText = 30 ;
fStatus = MnoReadCellStr ( achText, &cText, 0, 4, 0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
BYTE abCell [ 2 ] = { 0 } ;
/* Erase monochrome display. */
abCell [ 0 ] = ' ' ;
abCell [ 1 ] = 0x07 ;
fStatus = MnoScrollDn ( 0, // usTopRow.
0, // usLeftCol.
0xFFFF, // usBotRow.
0xFFFF, // usRightCol.
0xFFFF, // cbLines.
abCell,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
BYTE abCell [ 2 ] = { 0 } ;
abCell [ 0 ] = '.' ;
abCell [ 1 ] = 0x0F ;
/*---------------------------------------------*/
/* Scroll the box at (row,col): */
/* */
/* (0,74)----------+ */
/* | | */
/* | | */
/* | | */
/* +----------(24,79) */
/* */
/* Up 1 row. */
/*---------------------------------------------*/
fStatus = MnoScrollUp ( 0, 74, 24, 79, 1, abCell, 0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
BYTE abCell [ 2 ] = { 0 } ;
// Fill character.
abCell [ 0 ] = '#' ;
abCell [ 1 ] = 0x0F ;
/*---------------------------------------------*/
/* Scroll the box at (row,col): */
/* */
/* (0,0)-----------+ */
/* | | */
/* | | */
/* | | */
/* +----------(5,79) */
/* */
/* Left 10 columns. */
/*---------------------------------------------*/
fStatus = MnoScrollLf ( 0, 0, 5, 79, 10, abCell, 0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
BYTE abCell [ 2 ] = { 0 } ;
// Fill character.
abCell [ 0 ] = '.' ;
abCell [ 1 ] = 0x07 ;
/*---------------------------------------------*/
/* Scroll the box at (row,col): */
/* */
/* (0,0)-----------+ */
/* | | */
/* | | */
/* | | */
/* +----------(24,79) */
/* */
/* Right 80 columns. */
/*---------------------------------------------*/
fStatus = MnoScrollRt ( 0, // usTopRow.
0, // usLeftCol.
0xFFFF, // usBotRow.
0xFFFF, // usRightCol.
0xFFFF, // cbLines.
abCell,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
UCHAR szText [ 20 ] = "hello world" ;
// Display string at 2nd row, 1st column.
fStatus = MnoWrtCharStr ( szText,
strlen ( szText ),
1,
0,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
UCHAR szText [ 200 ] = "" ;
// Display string at 11th row, 2nd column.
strcpy ( szText,
"T\07e\07s\07t\07 \07o\07f\07 \07"
"W\07r\07t\07C\07e\07l\07l\07S\07"
"t\07r\07" ) ;
fStatus = MnoWrtCellStr ( szText,
strlen ( szText ),
10,
1,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
UCHAR szText [ 50 ] = "" ;
BYTE bAttr = 0x00 ;
bAttr = 0x70 ;
strcpy ( szText, "hello world" ) ;
// Display 'hello world' on the 6th row
// and 11th column.
fStatus = MnoWrtCharStr ( szText,
strlen ( szText ),
5,
10,
0 ) ;
// Set the attributes for 'hello world'.
fStatus = MnoWrtNAttr ( &bAttr,
strlen ( szText ),
5,
10,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
USHORT usRow = 0 ;
USHORT usColumn = 0 ;
BYTE chChar = ' ' ;
PBYTE pchChar = &chChar ;
USHORT cChars = 0 ;
// Set the last line of the display to all 'E'.
chChar = 'E' ;
usRow = 24 ;
usColumn = 0 ;
cChars = 80 ;
fStatus = MnoWrtNChar ( pchChar,
cChars,
usRow,
usColumn,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
USHORT cCells = 0 ;
USHORT usRow = 0 ;
USHORT usColumn = 0 ;
BYTE abCell [ 2 ] = { 0 } ;
// Display ten 'A' starting at the 3rd row,
// 79th column, and wrapping onto the 4th row,
// through the eight column. The attribute
// has been set to the normal intensity.
abCell [ 0 ] = 'A' ;
abCell [ 1 ] = 0x07 ;
cCells = 10 ;
usRow = 2 ;
usColumn = 78 ;
fStatus = MnoWrtNCell ( abCell,
cCells,
usRow,
usColumn,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
USHORT usRow = 0 ;
USHORT usColumn = 0 ;
BYTE bAttr = 0x07 ;
UCHAR szText [ 80 ] = "" ;
strcpy ( szText, "Some sample text in reverse video" ) ;
bAttr = 0x70 ;
fStatus = MnoWrtCharStrAtt ( szText,
strlen ( szText ),
0,
5,
&bAttr,
0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
{
USHORT fStatus = 0 ;
UCHAR szText [ 200 ] ;
VIOCURSORINFO vioCursorInfo ;
// Display "HELLO WORLD" followed by
// Carriage return - line feed.
strcpy ( szText, "HELLO WORLD\r\n" ) ;
fStatus = MnoWrtTTY ( szText, strlen ( szText ), 0 ) ;
// Erase the screen, move the cursor to the upper
// left position. Reset all attributes and use
// normal intensity white text on a dark
// background. Then display "HELLO WORLD". The
// cursor will be placed to the right of the tex>.
strcpy ( szText, "\033[2J\033[0mHELLO WORLD" ) ;
fStatus = MnoWrtTTY ( szText, strlen ( szText ), 0 ) ;
// Display cursor attributes.
fStatus = MnoGetCurType ( &vioCursorInfo, 0 ) ;
sprintf ( szText,
"\r\nCursor Start=%d End=%d Width=%d attr=%x\r\n",
vioCursorInfo.yStart,
vioCursorInfo.cEnd,
vioCursorInfo.cx,
vioCursorInfo.attr ) ;
fStatus = MnoWrtTTY ( szText, strlen ( szText ), 0 ) ;
if ( ! fStatus )
{
// Error handling.
}
}
exit ( 0 ) ;
}