--- os2sdk/demos/apps/sse/keyfuncs.c 2018/08/09 12:25:13 1.1 +++ os2sdk/demos/apps/sse/keyfuncs.c 2018/08/09 12:26:05 1.1.1.2 @@ -1,11 +1,14 @@ /****** KEYFUNCS.C - a collection of routines to service special keys * each routine has the name of the key it services + * + * Created by Microsoft Corp. 1987 */ +#define INCL_SUB + #include -#include -#include -#include +#include +#include #include "ssedefs.h" #include "keydefs.h" @@ -45,19 +48,19 @@ insert(c) char c; /* the character we are to insert, already validated */ { - register short i; /* indexing variable */ + register SHORT i; /* indexing variable */ if (LinesMarked || CharsMarked) /* if there is marked text around, */ del(); /* we first want to delete it */ if ( EditBuff[LINESIZE - 1] == ' ') /* can only insert when there's room */ { - for ( i = (LINESIZE - 1); i > CurCol; i-- ) - EditBuff[i] = EditBuff[i-1]; /* shift everything over one */ + for ( i = 0; i < LINESIZE-CurCol-1; ++i ) + EditBuff[LINESIZE-i-1] = EditBuff[LINESIZE-i-2];/* shift end by one */ EditBuff[CurCol] = c; /* put in the new character */ drawline(); CurCol += 1; /* update display */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); EditBuffDirty = 1; /* mark edit buffer as dirty */ } @@ -114,15 +117,15 @@ void up() if ( (TopRow + CurRow) != 0 ) { /* if top of file, do nothing */ if ( CurRow == 0 ) { TopRow -= 1; /* if top of screen, scroll down */ - VIOSCROLLDN( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, + (PBYTE)buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); drawline(); } else { CurRow -= 1; /* otherwise just move cursor up */ getline( (TopRow + CurRow), &EditBuff[0] ); - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } } @@ -131,7 +134,7 @@ void up() } -/*** down() - moves the cursor up one row +/*** down() - moves the cursor down one row * * down() moves the cursor down one row. If we are at the top of * the screen already, down() scrolls the screen up one line. If we @@ -179,15 +182,15 @@ void down() if ( (TopRow + CurRow) < (TotalLines) ) { /* if EOF, do nothing */ if ( CurRow == (PageSize - 1) ) { /* if end of screen, scroll up */ TopRow += 1; - VIOSCROLLUP( 0, 0, CurRow, (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1, + (PBYTE)buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); drawline(); } else { CurRow += 1; /* else move cursor down */ getline( (TopRow + CurRow), &EditBuff[0] ); - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } } @@ -244,7 +247,7 @@ void home() for( j = 0; ( j <= i ) && !isgraph(EditBuff[j]); j++ ); CurCol = j; /* j is position of */ - VIOSETCURPOS( CurRow, CurCol, 0 ); /* first non-blank */ + VioSetCurPos( CurRow, CurCol, 0 ); /* first non-blank */ } @@ -296,7 +299,7 @@ void end_() else i = 0; CurCol = i; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } @@ -344,7 +347,7 @@ void pgup() else { TopRow = 0; /* otherwise just go to top of file */ CurRow = 0; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } drawscr(TopRow); /* redraw screen and */ @@ -398,7 +401,7 @@ void pgdn() if ( TopRow > (TotalLines - (PageSize -1)) ) { /* if there's room, */ TopRow = (TotalLines - (PageSize -1)); /* else stop at last */ CurRow = (PageSize -1); /* full page */ - VIOSETCURPOS(CurRow, CurCol, 0); + VioSetCurPos(CurRow, CurCol, 0); } drawscr(TopRow); /* redraw screen and */ @@ -450,7 +453,7 @@ void bksp() badkey(); else { CurCol -= 1; /* otherwise, move left one and del */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); del(); } } @@ -510,7 +513,7 @@ void del() for( i = 0; i < MAXLINES; i++ ) /* clear line marking flags */ MarkedLine[i] = 0; drawscr(TopRow); /* redraw screen */ - VIOSETCURPOS(CurRow, CurCol, 0); + VioSetCurPos(CurRow, CurCol, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload EditBuff[] */ } @@ -518,7 +521,7 @@ void del() for( i = 0; !MarkedChar[i] & ( i < LINESIZE ); i++ ); j = i; /* i, j refer to first marked character */ CurCol = j; - VIOSETCURPOS(CurRow, CurCol, 0); /* adjust cursor position */ + VioSetCurPos(CurRow, CurCol, 0); /* adjust cursor position */ for( ; MarkedChar[i] & (i < LINESIZE); i++ ); /* i now first unmarked */ for( ; i < LINESIZE; i++, j++ ) EditBuff[j] = EditBuff[i]; /* remove characters between i and j */ @@ -548,7 +551,7 @@ void del() * * F9() save the file being edited with any changes that have been made * and exits the editor. The user is given a prompt to be sure they want - * do quit; hitting carriage return goes ahead with the save-and-quit, + * to quit; hitting carriage return goes ahead with the save-and-quit, * while any other key returns you to the editor. * * EFFECTS: If quit not completed: EditBuff[] - gets flushed @@ -559,7 +562,7 @@ void F9() { static char message[LINESIZE] = "Save file as:"; - struct KeyData keydata; + KBDKEYINFO keydata; char attrib = Fore25 + Back25; int i; @@ -571,15 +574,15 @@ void F9() for( i = 0; (i < 65) && (fname[i] != 0); message[i + 14] = fname[i], i++ ); /* copy filename into prompt message */ - VIOWRTCHARSTRATT( message, 80, PageSize, 0, &attrib, 0 ); + VioWrtCharStrAtt( message, 80, PageSize, 0, &attrib, 0 ); /* write out message */ - KBDCHARIN( &keydata, 0, 0 ); /* wait for user response */ + KbdCharIn( &keydata, 0, 0 ); /* wait for user response */ - if( keydata.char_code == CRETURN_CHAR ) { /* if response was ... */ + if( keydata.chChar == CRETURN_CHAR ) { /* if response was ... */ if ( !savefile(fhandle)) { freesegs(); - VIOSETCURPOS( 24, 0, 0 ); /* ... clean up and quit */ + VioSetCurPos( 24, 0, 0 ); /* ... clean up and quit */ quit(0); } else error25(11); @@ -604,7 +607,7 @@ void F9() void F10() { static char message[51] = "WARNING: Any edits will be lost (y/n)? "; - struct KeyData keydata; + KBDKEYINFO keydata; char attrib = Fore25 + Back25; /* attributes for message */ int row, col; /* to save current cursor position */ int done = 0; /* flag to be set when have a valid response */ @@ -614,21 +617,21 @@ void F10() flushline((TopRow + CurRow), EditBuff); } - VIOWRTCHARSTRATT( message, 51, PageSize, 0, &attrib, 0 ); - VIOGETCURPOS( &row, &col, 0 ); /* print prompt and set */ - VIOSETCURPOS( PageSize, 42, 0 ); /* cursor to await reply */ + VioWrtCharStrAtt( message, 51, PageSize, 0, &attrib, 0 ); + VioGetCurPos( &row, &col, 0 ); /* print prompt and set */ + VioSetCurPos( PageSize, 42, 0 ); /* cursor to await reply */ while( !done ) { - KBDCHARIN( &keydata, 0, 0 ); /* get a character from KBD */ + KbdCharIn( &keydata, 0, 0 ); /* get a character from KBD */ - if( (keydata.char_code == 'y') || (keydata.char_code == 'Y') ) { - VIOWRTCHARSTRATT( &keydata.char_code, 1, PageSize, 42, &attrib, 0 ); + if( (keydata.chChar == 'y') || (keydata.chChar == 'Y') ) { + VioWrtCharStrAtt( &keydata.chChar, 1, PageSize, 42, &attrib, 0 ); freesegs(); quit(0); /* if Y, quit without saving */ } - else if( (keydata.char_code == 'n') || (keydata.char_code == 'N') ) { - VIOSETCURPOS( row, col, 0 ); + else if( (keydata.chChar == 'n') || (keydata.chChar == 'N') ) { + VioSetCurPos( row, col, 0 ); name25(); done = 1; /* if N, return to editor */ } @@ -682,7 +685,7 @@ void ctrl_home() if ( CurRow != 0 || CurCol != 0 ) { CurRow = 0; /* reposition to (0,0) */ CurCol = 0; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); getline( (TopRow + CurRow), &EditBuff[0] ); } @@ -733,7 +736,7 @@ void ctrl_end() if( CurRow != (PageSize - 1) || CurCol != 0 ) { CurRow = (PageSize - 1); /* reposition cursor */ CurCol = 0; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); getline( (TopRow + CurRow), &EditBuff[0] ); } @@ -784,7 +787,7 @@ void ctrl_pgup() TopRow = 0; CurRow = 0; /* reposition and redraw */ CurCol = 0; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); drawscr(TopRow); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload EditBuff[] */ line25(); /* update 25th line */ @@ -834,7 +837,7 @@ void ctrl_pgdn() else TopRow = 0; CurRow = TotalLines - TopRow; /* set cursor row and column */ CurCol = 0; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload EditBuff[] */ drawscr(TopRow); /* redraw screen */ line25(); /* update 25th line */ @@ -861,12 +864,12 @@ void shift_left() if ( LinesMarked ) { /* if this line is marked, just move left */ if ( CurCol > 0 ) { CurCol -= 1; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } } else if( CurCol > 0 ) { /* otherwise, see if there's room... */ CurCol -= 1; - VIOSETCURPOS( CurRow, CurCol, 0 ); /* ...if so move left */ + VioSetCurPos( CurRow, CurCol, 0 ); /* ...if so move left */ CharsMarked = 1; if (MarkedChar[CurCol]) MarkedChar[CurCol] = 0; /* and set marking for that character */ @@ -897,7 +900,7 @@ void shift_right() if ( LinesMarked ) { /* if this line marked, just move right */ if (CurCol < (LINESIZE - 1)) { CurCol += 1; - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } } else if( CurCol < (LINESIZE - 1)) { /* otherwise, see if there's room.. */ @@ -906,7 +909,7 @@ void shift_right() MarkedChar[CurCol] = 0; else MarkedChar[CurCol] = 1; CurCol += 1; /* then move right one */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); drawline(); /* and redraw line */ } @@ -966,14 +969,14 @@ void shift_up() MarkedLine[ TopRow + CurRow - 1 ] = 1; /* mark line above */ if ( CurRow == 0 ) { TopRow -= 1; /* ...may have to scroll */ - VIOSCROLLDN( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, + buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ } else { /* ...or may not have to scroll */ CurRow -= 1; getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } drawline(); /* redraw new line */ } @@ -985,14 +988,14 @@ void shift_up() MarkedLine[ TopRow + CurRow - 1 ] = 1; /* mark next line up */ if ( CurRow == 0 ) { TopRow -= 1; /* ...may have to scroll */ - VIOSCROLLDN( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, + buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ } else { CurRow -= 1; /* ...or may not have to scroll */ getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } drawline(); /* redraw line move to */ } @@ -1005,14 +1008,14 @@ void shift_up() if( (TopRow + CurRow) != 0 ) { if( CurRow == 0 ) { /* ...may have to scroll down */ TopRow -= 1; - VIOSCROLLDN( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollDn( 0, 0, (PageSize - 1), (LINESIZE - 1), 1, + buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ } else { /* or may not have to scroll down */ CurRow -= 1; getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } if( !MarkedLine[ TopRow + CurRow - 1 ] ) { /* if line moved to */ MarkedLine[ TopRow + CurRow ] = 0; /* is last marked, */ @@ -1080,14 +1083,14 @@ void shift_down() MarkedLine[ TopRow + CurRow + 1 ] = 1; /* mark line below */ if ( CurRow == (PageSize - 1) ) { TopRow += 1; /* ...may have to scroll */ - VIOSCROLLUP( 0, 0, CurRow, (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1, + buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ } else { /* ...or may not have to scroll */ CurRow += 1; getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } drawline(); /* redraw new line */ } @@ -1099,14 +1102,14 @@ void shift_down() MarkedLine[ TopRow + CurRow + 1 ] = 1; /* mark line below */ if ( CurRow == (PageSize - 1) ) { TopRow += 1; /* ...may have to scroll */ - VIOSCROLLUP( 0, 0, CurRow, (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1, + buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ } else { /* ...or may not have to scroll */ CurRow += 1; getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } drawline(); /* redraw the current line to show markings */ } @@ -1119,14 +1122,14 @@ void shift_down() if ( (TopRow + CurRow) < TotalLines ) { if ( CurRow == (PageSize - 1) ) { TopRow += 1; /* ...may have to scroll */ - VIOSCROLLUP( 0, 0, CurRow, (LINESIZE - 1), 1, - (char far *)buff, 0); + VioScrollUp( 0, 0, CurRow, (LINESIZE - 1), 1, + buff, 0); getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ } else { /* ...or may not have to scroll */ CurRow += 1; getline( (TopRow + CurRow), &EditBuff[0] ); /* reload */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); } } if( (TopRow + CurRow) < TotalLines ) { @@ -1200,7 +1203,7 @@ void shift_home() } CurCol = j; /* if lines are marked, just move */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); drawline(); /* redraw line to show markings */ } @@ -1260,7 +1263,7 @@ void shift_end() } CurCol = i; /* if line is marked, just move */ - VIOSETCURPOS( CurRow, CurCol, 0 ); + VioSetCurPos( CurRow, CurCol, 0 ); drawline(); /* redraw */ }