From 90d24917036e91b5ace0b54ab7f0df26ae3c5f2b Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Wed, 19 Nov 2025 22:02:42 +0000 Subject: [PATCH] Make Enter and similar keys keep working when editing call and exchange When editing the call field, Enter didn't anything. When editing the exchange field, Enter at least exited the edit mode, but did not log the QSO. Make Enter, Backslash, Tab and similar keys exit editing, and perform their normal function so QSOs can be logged faster. This also fixes the bug that editing the call did not terminate on unhandled keys (like End in that context). --- src/calledit.c | 17 +++++++++++++---- src/calledit.h | 2 +- src/callinput.c | 6 ++++-- src/getexchange.c | 20 ++++++++++++++++---- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/calledit.c b/src/calledit.c index f45311891..9043f38e7 100644 --- a/src/calledit.c +++ b/src/calledit.c @@ -37,11 +37,11 @@ #include "ui_utils.h" -void calledit(void) { +int calledit(void) { int i = 0, l, b; int j = 0; - int x = 0; + int x = -1; int cnt = 0, insertflg = 0; char call1[30], call2[10]; @@ -79,7 +79,7 @@ void calledit(void) { // Ctrl-A (^A) or , move to head of callsign field. if (i == CTRL_A || i == KEY_HOME) { b = 0; - x = 0; + i = 0; } // Ctrl-E (^E) or , move to end of callsign field, exit edit mode. @@ -140,6 +140,13 @@ void calledit(void) { else insertflg = 0; + // these keys terminate the callinput() loop so they should also + // terminate calledit(); pass them through + } else if (i == '\n' || i == KEY_ENTER || i == SPACE || i == TAB + || i == CTRL_K || i == ',' || i == BACKSLASH) { + x = i; + break; + // Any character left other than . } else if (i != ESCAPE) { @@ -177,7 +184,7 @@ void calledit(void) { searchlog(); - } else if (x != 0) + } else if (i != 0) i = ESCAPE; } else @@ -194,6 +201,8 @@ void calledit(void) { attron(A_STANDOUT); searchlog(); + + return x; } int insert_char(int curposition) { diff --git a/src/calledit.h b/src/calledit.h index 867d279f8..c3607137c 100644 --- a/src/calledit.h +++ b/src/calledit.h @@ -21,7 +21,7 @@ #ifndef CALLEDIT_H #define CALLEDIT_H -void calledit(void); +int calledit(void); int insert_char(int); #endif /* CALLEDIT_H */ diff --git a/src/callinput.c b/src/callinput.c index a91354ec3..195e64183 100644 --- a/src/callinput.c +++ b/src/callinput.c @@ -312,7 +312,7 @@ int callinput(void) { // , enter call edit when call field is not empty. case KEY_HOME: { if ((*current_qso.call != '\0') && (ungetch(x) == OK)) { - calledit(); + x = calledit(); // pass through KEY_ENTER and friends from editing } break; @@ -321,7 +321,7 @@ int callinput(void) { // Left Arrow, enter call edit when call field is not empty, or band down. case KEY_LEFT: { if (*current_qso.call != '\0') { - calledit(); + x = calledit(); // pass through KEY_ENTER and friends from editing } else { handle_bandswitch(BAND_DOWN); } @@ -827,6 +827,8 @@ int callinput(void) { } } + /* end call input */ + /* keep this list of keys in sync with the list in calledit() */ if (x == '\n' || x == KEY_ENTER || x == SPACE || x == TAB || x == CTRL_K || x == ',' || x == BACKSLASH) { break; diff --git a/src/getexchange.c b/src/getexchange.c index b5e74403b..49e5603c4 100644 --- a/src/getexchange.c +++ b/src/getexchange.c @@ -62,7 +62,7 @@ #include "getexchange.h" -void exchange_edit(void); +static int exchange_edit(void); static void serial_up_down(char *exchange, int delta) { /* length of serial part in "001" or "001 EU-001" */ @@ -176,7 +176,7 @@ int getexchange(void) { x = KEY_LEFT; continue; } - case 19: { // Ctl+s (^S)--Open QTC panel for sending QTCs + case CTRL_S: { // Ctl+s (^S)--Open QTC panel for sending QTCs if (qtcdirection == 2 || qtcdirection == 3) { // in case of QTC=SEND or QTC=BOTH qtc_main_panel(SEND); } @@ -299,7 +299,7 @@ int getexchange(void) { case KEY_LEFT: { /* Left Arrow--edit exchange field */ if (current_qso.comment[0] != '\0') { - exchange_edit(); + x = exchange_edit(); // pass through KEY_ENTER and friends from editing } break; } @@ -348,6 +348,8 @@ int getexchange(void) { } /* , , Ctl-K, '\' */ + /* end exchange input */ + /* keep this list of keys in sync with the list in exchange_edit() */ if (x == '\n' || x == KEY_ENTER || x == TAB || x == CTRL_K || x == BACKSLASH) { @@ -807,10 +809,11 @@ void checkexchange(struct qso_t *qso, bool interactive) { /** Edit exchange field */ -void exchange_edit(void) { +static int exchange_edit(void) { int l, b; int i = 0, j; + int x = -1; char comment2[27]; l = strlen(current_qso.comment); @@ -874,6 +877,13 @@ void exchange_edit(void) { } } + // these keys terminate the getexchange() loop so they should also + // terminate exchange_edit(); pass them through + } else if (i == '\n' || i == KEY_ENTER || i == TAB + || i == CTRL_K || i == BACKSLASH) { + x = i; + break; + // not received. } else if (i != ESCAPE) { @@ -903,4 +913,6 @@ void exchange_edit(void) { attron(A_STANDOUT); refresh_comment(); + + return x; }