Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtterm / tests / scroll / scroll.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: scroll.c /main/3 1995/10/31 11:58:41 rswiston $ */
24 #include <stdio.h>
25 #include <math.h>
26 #include  "synvar.h"
27 #include  "common.h"
28
29 #ifdef LOG
30 FILE *TermLog;
31 #define SAVELOG  fclose(TermLog); TermLog = fopen("term.log", "a");
32 #endif
33
34 char LogStr[200];
35
36 void TestScrolling(WinName)
37 char *WinName;
38 {
39
40   int i, NumLines, NumCols;
41   char Str[200];
42
43     START(1,0,0,0,0);
44     if (CheckTermStatus() == -1)
45        {printf("terminal emulator malfunctioning\n"); DONE(); return;} 
46     GetWinSize(&NumLines, &NumCols);
47 #ifdef DEBUG
48 sprintf(LogStr, "WINDOW Size Cols: %d Lines: %d \n", NumCols, NumLines);
49 LogError(LogStr);
50 #endif
51     ClearScreen();  
52     SetScrollType(DECModeSet);
53     SetScrollType(DECModeSave);
54     for (i=0; i < (20*NumLines); i++) {
55       sprintf(Str, "%s%d", "It's in smooth Scroll Mode. is it right", i);
56       WRITETEST(Str);
57       NextLine();
58     }
59     ClearScreen();
60 sleep(2);
61     SetScrollType(DECModeReset);
62     for (i=0; i < (20*NumLines); i++) {
63       sprintf(Str, "%s%d", "It's in Jump Scroll Mode. is it right", i);
64       WRITETEST(Str);
65       NextLine();
66     }
67     SetScrollType(DECModeRestore);
68     ClearScreen();
69 sleep(2);
70     for (i=0; i < (20*NumLines); i++) {
71       sprintf(Str, "%s%d", "It's in smooth Scroll Mode. is it right", i);
72       WRITETEST(Str);
73       NextLine();
74     }
75     DONE();
76 }
77
78 main(argc, argv)
79 int argc;
80 char *argv[];
81 {
82      
83 #ifdef LOG
84 if ((TermLog = fopen("term.log", "a")) == NULL) {
85    if ((TermLog = fopen("term.log", "w")) == NULL)
86       {printf("Logfile could not be opened \n"); exit(-1);}
87 }
88 fprintf(TermLog, "**************************************************\n");
89 LogTime();
90 fprintf(TermLog, "TestName: <%s> STARTS\n", argv[0]);
91 #endif 
92 #ifdef SYNLIB
93      InitTest(argc, argv);
94      AssignWinName("TermWin", TERM_EMU);
95 #endif
96      TestScrolling("TermWin");
97 #ifdef SYNLIB
98      CloseTest(False);
99 #endif
100 #ifdef LOG
101 fprintf(TermLog, "TestName: <%s> ENDS\n", argv[0]);
102 fclose(TermLog);
103 #endif
104 }
105