1 /*
2  * Tlf - contest logging program for amateur radio operators
3  * Copyright (C) 2001-2002-2003 Rein Couperus <pa0rct@amsat.org>
4  * 		 2013           Thomas Beierlein <tb@forth-ev.de
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 
21 /* ------------------------------------------------------------
22  *       Clear_display takes  care of status lines  and
23  *       backgrounds (general repaint of the screen)
24  *--------------------------------------------------------------*/
25 
26 
27 #include <stdio.h>
28 #include <string.h>
29 
30 #include "cw_utils.h"
31 #include "get_time.h"
32 #include "getwwv.h"
33 #include "globalvars.h"		// Includes glib.h and tlf.h
34 #include "muf.h"
35 #include "printcall.h"
36 #include "qsonr_to_str.h"
37 #include "searchlog.h"		// Includes glib.h
38 #include "showscore.h"
39 #include "tlf_curses.h"
40 #include "ui_utils.h"
41 
42 
show_header_line()43 void show_header_line() {
44     extern cqmode_t cqmode;
45     extern int cqdelay;
46     extern const char headerline[];
47 
48     char *mode = "";
49     switch (cqmode) {
50 	case CQ:
51 	    mode = "Log";
52 	    break;
53 	case S_P:
54 	    mode = "S&P";
55 	    break;
56 	case AUTO_CQ:
57 	    mode = "AUTO_CQ";
58 	    break;
59 	case KEYBOARD:
60 	    mode = "Keyboard";
61 	    break;
62 	default:
63 	    ;   // should not happen
64     }
65 
66     attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);
67     mvaddstr(0, 0, spaces(29));
68     mvprintw(0, 0, "  %-8s  S=%2i D=%i ", mode, GetCWSpeed(), cqdelay);
69     mvaddstr(0, 21, headerline);
70 }
71 
72 
clear_display(void)73 void clear_display(void) {
74     extern char terminal1[];
75     extern char terminal2[];
76     extern char terminal3[];
77     extern char terminal4[];
78     extern char band[NBANDS][4];
79     extern int bandinx;
80     extern int trxmode;
81     extern char my_rst[];
82     extern char his_rst[];
83     extern char qsonrstr[];
84     extern int cqww;
85     extern int arrldx_usa;
86     extern char comment[];
87     extern int searchflg;
88     extern struct tm *time_ptr;
89     extern char whichcontest[];
90     extern int no_rst;
91 
92     char time_buf[80];
93     int cury, curx;
94 
95     getyx(stdscr, cury, curx);
96 
97     show_header_line();
98 
99     attron(modify_attr(COLOR_PAIR(C_LOG) | A_STANDOUT));
100     mvaddstr(1, 0, terminal1);
101     mvaddstr(2, 0, terminal2);
102     mvaddstr(3, 0, terminal3);
103     mvaddstr(4, 0, terminal4);
104     mvaddstr(5, 0, backgrnd_str);
105 
106     attron(COLOR_PAIR(C_HEADER));
107     mvaddstr(6, 0, backgrnd_str);
108     mvprintw(6, (80 - strlen(whichcontest)) / 2 - 4, " == %s == ", whichcontest);
109 
110     showscore();
111 
112     attron(modify_attr(COLOR_PAIR(C_LOG) | A_STANDOUT));
113     mvaddstr(7, 0, logline0);
114     mvaddstr(8, 0, logline1);
115     mvaddstr(9, 0, logline2);
116     mvaddstr(10, 0, logline3);
117     mvaddstr(11, 0, logline4);
118 
119     attron(COLOR_PAIR(C_WINDOW));
120     mvaddstr(12, 0, backgrnd_str);
121 
122     mvaddstr(12, 0, band[bandinx]);
123 
124     get_time();
125 
126     if (trxmode == CWMODE)
127 	strftime(time_buf, 60, "CW  %d-%b-%y %H:%M ", time_ptr);
128     else if (trxmode == SSBMODE)
129 	strftime(time_buf, 60, "SSB %d-%b-%y %H:%M ", time_ptr);
130     else
131 	strftime(time_buf, 60, "DIG %d-%b-%y %H:%M ", time_ptr);
132 
133     month = time_ptr->tm_mon;	/* month for muf calc */
134 
135     mvaddstr(12, 3, time_buf);
136 
137     qsonr_to_str();
138     mvaddstr(12, 23, qsonrstr);
139 
140     if (trxmode != SSBMODE) {
141 	my_rst[2] = '9';
142 	his_rst[2] = '9';
143     } else {
144 	my_rst[2] = ' ';
145 	his_rst[2] = ' ';
146     }
147 
148     if (no_rst) {
149 	mvaddstr(12, 44, "   ");
150 	mvaddstr(12, 49, "   ");
151     } else {
152 	mvaddstr(12, 44, his_rst);
153 	mvaddstr(12, 49, my_rst);
154     }
155 
156     if (cqww == 1) {
157 	attron(modify_attr(COLOR_PAIR(NORMCOLOR)));
158 	mvaddstr(12, 54, comment);
159     }
160 
161     if (arrldx_usa == 1) {
162 	attron(modify_attr(COLOR_PAIR(NORMCOLOR)));
163 	mvaddstr(12, 54, comment);
164     }
165 
166     if (searchflg == SEARCHWINDOW)
167 	searchlog();
168 
169     printcall();
170 
171     attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);
172     mvaddstr(LINES - 1, 0, backgrnd_str);
173     wwv_show_footer();
174 
175     attron(modify_attr(COLOR_PAIR(NORMCOLOR)));
176     move(cury, curx);
177     refreshp();
178 }
179