Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FKEY-HEADER #232

Merged
merged 3 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rules/cqww
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ F12=++++TEST---- % %
CQ_TU_MSG=TU %
S&P_TU_MSG=TU 5NN 14
#
#FKEY-HEADER= 1=CQ 2=DE 3=RST 4=73 5=HIS 6=MY 7=B4 8=AGN 9=?
#
#ALT_0=
#ALT_1=
#ALT_2=
Expand Down
9 changes: 1 addition & 8 deletions src/clear_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@


void show_header_line() {
extern const char headerline[];

char *mode = "";
switch (cqmode) {
case CQ:
Expand All @@ -68,16 +66,11 @@ void show_header_line() {
attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);
mvaddstr(0, 0, spaces(29));
mvprintw(0, 0, " %-8s S=%2i D=%i ", mode, GetCWSpeed(), cqdelay);
mvaddstr(0, 21, headerline);
mvaddstr(0, 21, fkey_header);
}


void clear_display(void) {
extern char terminal1[];
extern char terminal2[];
extern char terminal3[];
extern char terminal4[];

int cury, curx;

getyx(stdscr, cury, curx);
Expand Down
7 changes: 7 additions & 0 deletions src/globalvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ extern char logline_edit[5][LOGLINELEN + 1];
#define logline3 logline_edit[3]
#define logline4 logline_edit[4]

extern char terminal1[];
extern char terminal2[];
extern char terminal3[];
extern char terminal4[];

extern char band[NBANDS][4];
extern freq_t bandfrequency[NBANDS];

Expand Down Expand Up @@ -233,6 +238,8 @@ extern char *config_file;
extern int bandindexarray[];
extern int tlfcolors[8][2];

extern char fkey_header[60];

extern SCREEN *mainscreen;

extern bool mult_side;
Expand Down
23 changes: 18 additions & 5 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,8 @@ int txdelay = 0;
int weight = 0;
char weightbuf[4];
int cqdelay = 8;
int k_tune;
int k_pin14;
int k_ptt;
int k_pin14 = 0;
int k_ptt = 0;

int miniterm = 0; /* is miniterm for digimode active? */
char modem_mode[8];
Expand Down Expand Up @@ -381,8 +380,8 @@ freq_t bandfrequency[NBANDS] = {
28025000, 0.
};

const char headerline[] =
" 1=CQ 2=DE 3=RST 4=73 5=HIS 6=MY 7=B4 8=AGN 9=? ";
char fkey_header[60] =
"1=CQ 2=DE 3=RST 4=73 5=HIS 6=MY 7=B4 8=AGN 9=?";
const char *backgrnd_str;

char logline_edit[5][LOGLINELEN + 1];
Expand Down Expand Up @@ -593,6 +592,19 @@ void ui_color_init() {
}
}

static void center_fkey_header() {
int width = sizeof(fkey_header) - 1;
if (strlen(fkey_header) == width) {
return; // already OK
}
int right_padding = (width - strlen(fkey_header)) / 2;
int left_padding = width - strlen(fkey_header) - right_padding;
char tmp[sizeof(fkey_header)];
strcpy(tmp, fkey_header);
sprintf(fkey_header, "%s%s%s",
spaces(left_padding), tmp, spaces(right_padding));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had done it in show_header_line, but that is another way. Fine.

Copy link
Member Author

@zcsahok zcsahok Jan 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way it's done once at start. All else stays as-is.
When we'll have variable width, then we can re-think this and probably other stuff as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Imho, centering would possibly be better off in parse_logcfg, needed only once per config-file re-read
  • just because the next idea is almost completely implemented by now, needing only to conditionally zero out left- or right padding, would it be too much Left|Centered|Right aligning instead of centering, FKEY_HEADER=[L:|C:|R:]text, defaulting to "C:" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Centering will be just a nice to have once we implement leading/trailing whitespace for config values. This is on my list. With whitespace the user will have better control on the appearance of the text.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much, fully agree on whitespaces with you.

static void init_variables() {

iscontest = false;
Expand Down Expand Up @@ -985,6 +997,7 @@ int main(int argc, char *argv[]) {

packet_init();

center_fkey_header();
clear_display(); /* tidy up the display */
attron(COLOR_PAIR(C_LOG) | A_STANDOUT);
for (j = 13; j <= LINES - 1; j++) { /* wipe lower window */
Expand Down
1 change: 1 addition & 0 deletions src/parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ static config_t logcfg_configs[] = {
{"SC_DEVICE", CFG_STRING_STATIC(sc_device, 40)},
{"INITIAL_EXCHANGE", CFG_STRING_STATIC(exchange_list, 40)},
{"DIGIMODEM", CFG_STRING_STATIC(rttyoutput, 120)},
{"FKEY-HEADER", CFG_STRING_STATIC(fkey_header, sizeof(fkey_header))},

{"CABRILLO", CFG_STRING(cabrillo)},
{"CALLMASTER", CFG_STRING(callmaster_filename)},
Expand Down
4 changes: 3 additions & 1 deletion test/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ char message[25][80] = /**< Array of CW/DigiMode messages
"", "", "", "", "", "", "", "", "", "", ""
};

char fkey_header[60] =
" 1=CQ 2=DE 3=RST 4=73 5=HIS 6=MY 7=B4 8=AGN 9=? ";

dl1jbe marked this conversation as resolved.
Show resolved Hide resolved
char *digi_message[sizeof(message) / sizeof(message[0])];

char ph_message[14][80] = /**< Array of file names for voice keyer messages
Expand Down Expand Up @@ -270,7 +273,6 @@ char wkeyerbuffer[400];
int data_ready = 0;
char keyer_device[10] = ""; // ttyS0, ttyS1, lp0-2
int keyer_backspace = 0;
int k_tune;
int k_pin14;
int k_ptt;
char controllerport[80] = "/dev/ttyS0";
Expand Down
6 changes: 6 additions & 0 deletions test/test_parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,12 @@ void test_qs_vkcqm(void **state) {
assert_string_equal(qtc_phsend_message[CQ_TU_MSG], "b.wav");
}

void test_fkey_header(void **state) {
int rc = call_parse_logcfg("FKEY-HEADER = F1=CQ F2=XYZ \r\n");
assert_int_equal(rc, PARSE_OK);
assert_string_equal(fkey_header, "F1=CQ F2=XYZ");
}

void test_call(void **state) {
int rc = call_parse_logcfg("CALL = AB1CD\r\n");
assert_int_equal(rc, PARSE_OK);
Expand Down
7 changes: 7 additions & 0 deletions tlf.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,13 @@ message.
Up to 10 additional messages.
.
.TP
\fBFKEY-HEADER\fR=\fI"short description of your defined F-keys"\fR
The actual F-key assignments shown on the top of the main logging screen.
Maximum length is 59.
The default is:
\(lq1=CQ\ \ 2=DE\ \ 3=RST\ 4=73\ \ 5=HIS\ \ 6=MY\ \ 7=B4\ \ \ 8=AGN\ \ 9=?\(rq
.
.TP
.B SHORT_SERIAL
Uses short form for serial number (599=5NN, 001=TT1).
.
Expand Down