1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Make HelpCtx a per-platform type, not an intorptr.

Partly, this just seems more sensible, since it may well vary per
platform beyond the ability of intorptr to specify. But more
immediately it means the definition of the HELPCTX macro doesn't have
to use the P() function from dialog.h, which isn't defined in any
circumstances outside the config subsystem. And I'm about to want to
put a help context well outside that subsystem.
This commit is contained in:
Simon Tatham 2022-07-05 18:11:54 +01:00
parent a77040afa1
commit d8f8c8972a
7 changed files with 37 additions and 32 deletions

View File

@ -1588,7 +1588,7 @@ static void clipboard_selector_handler(dlgcontrol *ctrl, dlgparam *dlg,
}
static void clipboard_control(struct controlset *s, const char *label,
char shortcut, int percentage, intorptr helpctx,
char shortcut, int percentage, HelpCtx helpctx,
int setting, int strsetting)
{
#ifdef NAMED_CLIPBOARDS

View File

@ -205,7 +205,7 @@ void *ctrl_alloc(struct controlbox *b, size_t size)
}
static dlgcontrol *ctrl_new(struct controlset *s, int type,
intorptr helpctx, handler_fn handler,
HelpCtx helpctx, handler_fn handler,
intorptr context)
{
dlgcontrol *c = snew(dlgcontrol);
@ -228,7 +228,7 @@ static dlgcontrol *ctrl_new(struct controlset *s, int type,
/* `ncolumns' is followed by that many percentages, as integers. */
dlgcontrol *ctrl_columns(struct controlset *s, int ncolumns, ...)
{
dlgcontrol *c = ctrl_new(s, CTRL_COLUMNS, P(NULL), NULL, P(NULL));
dlgcontrol *c = ctrl_new(s, CTRL_COLUMNS, NULL_HELPCTX, NULL, P(NULL));
assert(s->ncolumns == 1 || ncolumns == 1);
c->columns.ncols = ncolumns;
s->ncolumns = ncolumns;
@ -248,7 +248,7 @@ dlgcontrol *ctrl_columns(struct controlset *s, int ncolumns, ...)
dlgcontrol *ctrl_editbox(struct controlset *s, const char *label,
char shortcut, int percentage,
intorptr helpctx, handler_fn handler,
HelpCtx helpctx, handler_fn handler,
intorptr context, intorptr context2)
{
dlgcontrol *c = ctrl_new(s, CTRL_EDITBOX, helpctx, handler, context);
@ -263,7 +263,7 @@ dlgcontrol *ctrl_editbox(struct controlset *s, const char *label,
dlgcontrol *ctrl_combobox(struct controlset *s, const char *label,
char shortcut, int percentage,
intorptr helpctx, handler_fn handler,
HelpCtx helpctx, handler_fn handler,
intorptr context, intorptr context2)
{
dlgcontrol *c = ctrl_new(s, CTRL_EDITBOX, helpctx, handler, context);
@ -283,7 +283,7 @@ dlgcontrol *ctrl_combobox(struct controlset *s, const char *label,
* is NO_SHORTCUT.
*/
dlgcontrol *ctrl_radiobuttons_fn(struct controlset *s, const char *label,
char shortcut, int ncolumns, intorptr helpctx,
char shortcut, int ncolumns, HelpCtx helpctx,
handler_fn handler, intorptr context, ...)
{
va_list ap;
@ -329,7 +329,7 @@ dlgcontrol *ctrl_radiobuttons_fn(struct controlset *s, const char *label,
}
dlgcontrol *ctrl_pushbutton(struct controlset *s, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context);
@ -341,7 +341,7 @@ dlgcontrol *ctrl_pushbutton(struct controlset *s, const char *label,
}
dlgcontrol *ctrl_listbox(struct controlset *s, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
@ -358,7 +358,7 @@ dlgcontrol *ctrl_listbox(struct controlset *s, const char *label,
}
dlgcontrol *ctrl_droplist(struct controlset *s, const char *label,
char shortcut, int percentage, intorptr helpctx,
char shortcut, int percentage, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
@ -375,7 +375,7 @@ dlgcontrol *ctrl_droplist(struct controlset *s, const char *label,
}
dlgcontrol *ctrl_draglist(struct controlset *s, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
@ -393,7 +393,7 @@ dlgcontrol *ctrl_draglist(struct controlset *s, const char *label,
dlgcontrol *ctrl_filesel(struct controlset *s, const char *label,
char shortcut, const char *filter, bool write,
const char *title, intorptr helpctx,
const char *title, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context);
@ -406,7 +406,7 @@ dlgcontrol *ctrl_filesel(struct controlset *s, const char *label,
}
dlgcontrol *ctrl_fontsel(struct controlset *s, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context);
@ -417,13 +417,13 @@ dlgcontrol *ctrl_fontsel(struct controlset *s, const char *label,
dlgcontrol *ctrl_tabdelay(struct controlset *s, dlgcontrol *ctrl)
{
dlgcontrol *c = ctrl_new(s, CTRL_TABDELAY, P(NULL), NULL, P(NULL));
dlgcontrol *c = ctrl_new(s, CTRL_TABDELAY, NULL_HELPCTX, NULL, P(NULL));
c->tabdelay.ctrl = ctrl;
return c;
}
dlgcontrol *ctrl_text(struct controlset *s, const char *text,
intorptr helpctx)
HelpCtx helpctx)
{
dlgcontrol *c = ctrl_new(s, CTRL_TEXT, helpctx, NULL, P(NULL));
c->label = dupstr(text);
@ -432,7 +432,7 @@ dlgcontrol *ctrl_text(struct controlset *s, const char *text,
}
dlgcontrol *ctrl_checkbox(struct controlset *s, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context)
{
dlgcontrol *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context);

View File

@ -161,7 +161,7 @@ struct dlgcontrol {
* platform-specific driver can use to ensure it brings up the
* right piece of help text.
*/
intorptr helpctx;
HelpCtx helpctx;
/*
* Setting this to non-NULL coerces two or more controls to have
* their y-coordinates adjusted so that they can sit alongside
@ -519,11 +519,11 @@ void *ctrl_alloc_with_free(struct controlbox *b, size_t size,
/* `ncolumns' is followed by that many percentages, as integers. */
dlgcontrol *ctrl_columns(struct controlset *, int ncolumns, ...);
dlgcontrol *ctrl_editbox(struct controlset *, const char *label,
char shortcut, int percentage, intorptr helpctx,
char shortcut, int percentage, HelpCtx helpctx,
handler_fn handler,
intorptr context, intorptr context2);
dlgcontrol *ctrl_combobox(struct controlset *, const char *label,
char shortcut, int percentage, intorptr helpctx,
char shortcut, int percentage, HelpCtx helpctx,
handler_fn handler,
intorptr context, intorptr context2);
/*
@ -533,33 +533,33 @@ dlgcontrol *ctrl_combobox(struct controlset *, const char *label,
* is NO_SHORTCUT.
*/
dlgcontrol *ctrl_radiobuttons_fn(struct controlset *, const char *label,
char shortcut, int ncolumns, intorptr helpctx,
char shortcut, int ncolumns, HelpCtx helpctx,
handler_fn handler, intorptr context, ...);
#define ctrl_radiobuttons(...) \
ctrl_radiobuttons_fn(__VA_ARGS__, (const char *)NULL)
dlgcontrol *ctrl_pushbutton(struct controlset *, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_listbox(struct controlset *, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_droplist(struct controlset *, const char *label,
char shortcut, int percentage, intorptr helpctx,
char shortcut, int percentage, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_draglist(struct controlset *, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_filesel(struct controlset *, const char *label,
char shortcut, const char *filter, bool write,
const char *title, intorptr helpctx,
const char *title, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_fontsel(struct controlset *, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_text(struct controlset *, const char *text,
intorptr helpctx);
HelpCtx helpctx);
dlgcontrol *ctrl_checkbox(struct controlset *, const char *label,
char shortcut, intorptr helpctx,
char shortcut, HelpCtx helpctx,
handler_fn handler, intorptr context);
dlgcontrol *ctrl_tabdelay(struct controlset *, dlgcontrol *);

View File

@ -78,7 +78,9 @@ extern const struct BackendVtable pty_backend;
/*
* Under GTK, there is no context help available.
*/
#define HELPCTX(x) P(NULL)
typedef void *HelpCtx;
#define NULL_HELPCTX ((HelpCtx)NULL)
#define HELPCTX(x) NULL
#define FILTER_KEY_FILES NULL /* FIXME */
#define FILTER_DYNLIB_FILES NULL /* FIXME */

View File

@ -2,6 +2,7 @@
* Helper function from the dialog.h mechanism.
*/
#include "putty.h"
#include "misc.h"
#include "dialog.h"

View File

@ -2131,12 +2131,12 @@ bool winctrl_context_help(struct dlgparam *dp, HWND hwnd, int id)
/*
* This is the Windows front end, so we're allowed to assume
* `helpctx.p' is a context string.
* `helpctx' is a context string.
*/
if (!c->ctrl || !c->ctrl->helpctx.p)
if (!c->ctrl || !c->ctrl->helpctx)
return false; /* no help available for this ctrl */
launch_help(hwnd, c->ctrl->helpctx.p);
launch_help(hwnd, c->ctrl->helpctx);
return true;
}

View File

@ -9,7 +9,9 @@
/* These are used in the cross-platform configuration dialog code. */
#define HELPCTX(x) P(WINHELP_CTX_ ## x)
typedef const char *HelpCtx;
#define NULL_HELPCTX NULL
#define HELPCTX(x) WINHELP_CTX_ ## x
#define WINHELP_CTX_no_help NULL