1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -05:00

Replace integer context2 encoding in conf_editbox_handler.

I was just about to add another ordinary edit box control, and found I
couldn't remember what went in the context2 argument to conf_editbox.
When I looked it up, I realised it was one of those horrid integer
encodings of the form '1 means this, -1 means that, less than -1 means
some parametrised property where the parameter is obtained by negating
the encoded integer'.

Those are always awkward to remember, and worse to extend. So I've
replaced the integer context2 used with conf_editbox_handler with a
pointer to a small struct type in which the types and parameters have
sensible names and are documented.

(To avoid annoying const warnings everywhere, this also meant
extending the 'intorptr' union to have a const void * branch as well
as a 'void *'. Surprised I haven't needed that before. But if I
introduce any more of these parameter structures, it'll come in useful
again.)
This commit is contained in:
Simon Tatham
2022-08-24 07:56:45 +01:00
parent 6a1b713e13
commit 761df2fca6
4 changed files with 93 additions and 53 deletions

View File

@ -112,7 +112,7 @@ void gtk_setup_config_box(struct controlbox *b, bool midsession, void *win)
HELPCTX(no_help));
ctrl_editbox(s, "Horizontal offset for shadow bold:", 'z', 20,
HELPCTX(no_help), conf_editbox_handler,
I(CONF_shadowboldoffset), I(-1));
I(CONF_shadowboldoffset), ED_INT);
/*
* Markus Kuhn feels, not totally unreasonably, that it's good
@ -155,6 +155,6 @@ void gtk_setup_config_box(struct controlbox *b, bool midsession, void *win)
"X Window System settings");
ctrl_editbox(s, "Window class name:", 'z', 50,
HELPCTX(no_help), conf_editbox_handler,
I(CONF_winclass), I(1));
I(CONF_winclass), ED_STR);
}
}