--- os2sdk/demos/apps/sse/keyfunc1.c 2018/08/09 12:25:13 1.1.1.1 +++ os2sdk/demos/apps/sse/keyfunc1.c 2018/08/09 12:26:05 1.1.1.2 @@ -1,11 +1,16 @@ +/* Created by Microsoft Corp. 1987 */ + +#define INCL_SUB + +#include +#include #include -#include #include "ssedefs.h" -/*** creturn - handles carage return +/*** creturn - handles carriage return * * creturn breaks the line reference by linenum at the * current cursor position and inserts the second half of @@ -25,8 +30,8 @@ * CharsMarked - by clearing it if set * MarkedChar - by clearing it if set * MarkedLine - by clearing it if set - * LineTable - by insterting the second part of the line - * and via 'addline' + * LineTable - by inserting the second part of the line + * via 'addline' * CurRow - by incrementing it * TopRow - by incrementing it * CurCol - by setting it to zero @@ -46,8 +51,8 @@ void creturn() { - register unsigned short i; - register unsigned short linenum; + register USHORT i; + register USHORT linenum; /* clear flags if set */ if (EditBuffDirty) { /* this call will change */ @@ -68,8 +73,8 @@ void creturn() linenum = TopRow + CurRow; if ( !(linenum == TotalLines)) { deleteline(linenum); /* mark orginal line as deleted */ - for (i = TotalLines; i > (linenum +1); i--) - LineTable[i] = LineTable[i -1]; + for (i = 0; i < TotalLines - (linenum +1); i++) + LineTable[TotalLines-i] = LineTable[TotalLines-i-1]; ++TotalLines; } else { @@ -96,7 +101,7 @@ void creturn() else ++TopRow; CurCol = 0; - VIOSETCURPOS(CurRow, CurCol, 0); + VioSetCurPos(CurRow, CurCol, 0); drawscr(TopRow); getline(linenum, EditBuff); /* set EditBuff to the current line */ @@ -146,7 +151,7 @@ void creturn() void ctrl_b() { - register unsigned short i; + register USHORT i; if (EditBuffDirty) { /* this call will change */ EditBuffDirty = 0; /* cursor line, so flush */ @@ -163,8 +168,8 @@ void ctrl_b() } /* expand LineTable to insert the new line below */ - for (i = TotalLines; i > (TopRow + CurRow +1); i--) - LineTable[i] = LineTable[i -1]; + for (i = 0; i < TotalLines - (TopRow + CurRow +1); i++) + LineTable[TotalLines-i] = LineTable[TotalLines-i-1]; if ( (TopRow + CurRow) == TotalLines) { ++TotalLines; if ((addline(TopRow +CurRow, 0, 0) != 0) || !(TotalLines < MAXLINES)) @@ -184,7 +189,7 @@ void ctrl_b() ++TopRow; /* redraw the screen with the new line below */ - VIOSETCURPOS(CurRow, CurCol, 0); + VioSetCurPos(CurRow, CurCol, 0); drawscr(TopRow); getline( (TopRow + CurRow), &EditBuff[0] ); @@ -235,7 +240,7 @@ void ctrl_b() void ctrl_n() { - register unsigned short i; + register USHORT i; if (EditBuffDirty) { /* this call will change */ EditBuffDirty = 0; /* cursor line, so flush */ @@ -252,8 +257,8 @@ void ctrl_n() } /* expand LineTable to insert the new line above */ - for (i = TotalLines; i > (TopRow + CurRow); i--) - LineTable[i] = LineTable[i -1]; + for (i = 0; i < TotalLines - (TopRow + CurRow); i++) + LineTable[TotalLines-i] = LineTable[TotalLines-i-1]; /* insert the new line above current line */ if ( (TopRow + CurRow) == TotalLines) { ++TotalLines; @@ -270,7 +275,7 @@ void ctrl_n() if (CurRow > 0) { --CurRow; ++TopRow; - VIOSETCURPOS(CurRow, CurCol, 0); + VioSetCurPos(CurRow, CurCol, 0); } drawscr(TopRow); getline( (TopRow + CurRow), &EditBuff[0] ); @@ -310,7 +315,7 @@ void ctrl_n() void ctrl_y() { - register unsigned short i; + register USHORT i; if (EditBuffDirty) { /* this call will change */ EditBuffDirty = 0; /* cursor line, so flush */ @@ -366,9 +371,9 @@ void ctrl_y() void tab() { - unsigned short ensp = FALSE; /* enough space to add the tab */ - unsigned short tabshift; /* number of spaces to the next tab */ - unsigned short i, j; /* indexes */ + USHORT ensp = FALSE; /* enough space to add the tab */ + USHORT tabshift; /* number of spaces to the next tab */ + USHORT i, j; /* indexes */ if ( LinesMarked || CharsMarked ) { @@ -397,7 +402,7 @@ void tab() /* redraw the line with the tab */ drawline(); CurCol += tabshift; - VIOSETCURPOS(CurRow, CurCol, 0); + VioSetCurPos(CurRow, CurCol, 0); EditBuffDirty = TRUE; } else badkey();