1 /*
2  * Tlf - contest logging program for amateur radio operators
3  * Copyright (C) 2001-2002-2003 Rein Couperus <pa0rct@amsat.org>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 /* ------------------------------------------------------------
20 *        List  CW messages
21 *
22 *--------------------------------------------------------------*/
23 
24 
25 #include <string.h>
26 
27 #include <glib.h>
28 
29 #include "clear_display.h"
30 #include "globalvars.h"
31 #include "nicebox.h"		// Includes curses.h
32 #include "tlf.h"
33 #include "ui_utils.h"
34 
35 #define LIST_HEIGHT 15
36 #define LIST_WIDTH  78
37 #define LIST_UPPER  7
38 #define LIST_LEFT   0
39 
40 char  printbuffer[160];
41 
formatMessage(int i)42 char *formatMessage(int i) {
43     extern char message[][80];
44 
45     /* copy the message string WITHOUT trailing newline/space */
46     if (trxmode == DIGIMODE)
47 	g_strlcpy(printbuffer,  digi_message[i],  strlen(digi_message[i]));
48     else
49 	g_strlcpy(printbuffer,  message[i],  strlen(message[i]));
50     /* and fill up with spaces */
51     strcat(printbuffer, backgrnd_str);
52     printbuffer[LIST_WIDTH - 7] = '\0';
53 
54     return printbuffer;
55 }
56 
listmessages(void)57 void listmessages(void) {
58 
59     int i;
60 
61     nicebox(LIST_UPPER, LIST_LEFT, LIST_HEIGHT, LIST_WIDTH, "Messages");
62     attron(COLOR_PAIR(C_WINDOW) | A_STANDOUT);
63 
64     for (i = 0  ; i  < 12 ; i++) {
65 	mvprintw(i + LIST_UPPER + 1, 1, " %2i  : %s",  i + 1, formatMessage(i));
66     }
67 
68     mvprintw(12 + LIST_UPPER + 1, 1, " SPmg: %s", formatMessage(SP_TU_MSG));
69     mvprintw(13 + LIST_UPPER + 1, 1, " CQmg: %s", formatMessage(CQ_TU_MSG));
70     mvprintw(14 + LIST_UPPER + 1, 1, " SPCa: %s", formatMessage(SP_CALL_MSG));
71 
72     attroff(A_STANDOUT);
73     mvprintw(23, 30,  "Press any key");
74     refreshp();
75 
76     (void)key_get();
77 
78     clear_display();
79 
80     attron(COLOR_PAIR(C_LOG)  |  A_STANDOUT);
81     for (i = 13 ;  i  <= 23 ; i++) {
82 	mvprintw(i, 0, backgrnd_str);
83     }
84 
85     refreshp();
86 
87     return;
88 }
89 
90