# HG changeset patch # User Josef 'Jeff' Sipek # Date 1738286522 18000 # Thu Jan 30 20:22:02 2025 -0500 # Node ID 83dac37029fabe76bd377a99fa246e6c135dd9b4 # Parent bed61843c13265b06aa5b421a96275871b277a7b contest: reset the qso when the form becomes empty Users assume that backspacing the form will reset the start time. Let's not surprise them. Note that if the form has whitespace, then it is not considered empty. Signed-off-by: Josef 'Jeff' Sipek diff --git a/hlog/contest/ui-work.c b/hlog/contest/ui-work.c --- a/hlog/contest/ui-work.c +++ b/hlog/contest/ui-work.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022,2024 Josef 'Jeff' Sipek + * Copyright (c) 2021-2022,2024-2025 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,6 +31,22 @@ struct xform work; /* current QSO contest exchange */ +/* return whether or not the form is completely empty */ +static bool form_empty(struct xform *form) +{ + size_t i; + + for (i = 0; i < form->nfields; i++) { + size_t size; + + xform_field_get(form, i, &size); + if (size) + return false; /* this field is not empty */ + } + + return true; +} + static void wrapped_set_field_buffer(struct xform *form, const char *key, const char *value) { @@ -178,13 +194,19 @@ case '\b': case 127: xform_driver(form, XFORM_REQ_DEL_PREV); - field_changed(lua, *qso); /* inform script */ + if (form_empty(form)) + abort_qso(lua, qso); + else + field_changed(lua, *qso); /* inform script */ recent_invalidate(&recent_work_list); break; case KEY_DC: xform_driver(form, XFORM_REQ_DEL_THIS); - field_changed(lua, *qso); /* inform script */ + if (form_empty(form)) + abort_qso(lua, qso); + else + field_changed(lua, *qso); /* inform script */ recent_invalidate(&recent_work_list); break;