of PuTTY (terminal, backend, logctx etc) take a `void *' handle
passed to them from the frontend, and used as a context for all
their callbacks. Most of these point at the frontend structure
itself (on platforms where this is meaningful), except that the
handle passed to the backend has always pointed at the terminal
because from_backend() was implemented in terminal.c. This has
finally bitten Unix PuTTY, because both backend and logctx have
been passing their respective and very different frontend handles to
logevent(), so I've fixed it.
from_backend() is now a function supplied by the _frontend_ itself,
in all cases, and the frontend handle passed to backends must be the
same as that passed to everything else. What was from_backend() in
terminal.c is now called term_data(), and the typical implementation
of from_backend() in a GUI frontend will just extract the terminal
handle from the frontend structure and delegate to that.
This appears to work on Unix and Windows, but has most likely broken
the Mac build.
git-svn-id: svn://svn.tartarus.org/sgt/putty@3100
cda61777-01e9-0310-a592-
d414129be87e
void frontend_keypress(void *frontend);
void ldisc_update(void *frontend, int echo, int edit);
void update_specials_menu(void *frontend);
+int from_backend(void *frontend, int is_stderr, const char *data, int len);
#define OPTIMISE_IS_SCROLL 1
void set_iconic(void *frontend, int iconic);
void term_copyall(Terminal *);
void term_reconfig(Terminal *, Config *);
void term_seen_key_event(Terminal *);
-int from_backend(void *, int is_stderr, const char *data, int len);
+int term_data(Terminal *, int is_stderr, const char *data, int len);
void term_provide_resize_fn(Terminal *term,
void (*resize_fn)(void *, int, int),
void *resize_ctx);
return FALSE;
}
-/*
- * from_backend(), to get data from the backend for the terminal.
- */
-int from_backend(void *vterm, int is_stderr, const char *data, int len)
+int term_data(Terminal *term, int is_stderr, const char *data, int len)
{
- Terminal *term = (Terminal *)vterm;
-
assert(len > 0);
bufchain_add(&term->inbuf, data, len);
void connection_fatal(void *frontend, char *p, ...)
{
- Terminal *term = (Terminal *)frontend;
- struct gui_data *inst = (struct gui_data *)term->frontend;
+ struct gui_data *inst = (struct gui_data *)frontend;
va_list ap;
char *msg;
return 2;
}
+int from_backend(void *frontend, int is_stderr, const char *data, int len)
+{
+ struct gui_data *inst = (struct gui_data *)frontend;
+ return term_data(inst->term, is_stderr, data, len);
+}
+
void logevent(void *frontend, char *string)
{
- Terminal *term = (Terminal *)frontend;
- struct gui_data *inst = (struct gui_data *)term->frontend;
+ struct gui_data *inst = (struct gui_data *)frontend;
log_eventlog(inst->logctx, string);
*/
void *get_window(void *frontend)
{
- Terminal *term = (Terminal *)frontend;
- struct gui_data *inst = (struct gui_data *)term->frontend;
+ struct gui_data *inst = (struct gui_data *)frontend;
return inst->window;
}
{
struct gui_data *inst = (struct gui_data *)data;
if (inst->cfg.warn_on_close) {
- if (!reallyclose(inst->term))
+ if (!reallyclose(inst))
return TRUE;
}
return FALSE;
long get_windowid(void *frontend)
{
- Terminal *term = (Terminal *)frontend;
- struct gui_data *inst = (struct gui_data *)(term->frontend);
+ struct gui_data *inst = (struct gui_data *)frontend;
return (long)GDK_WINDOW_XWINDOW(inst->area->window);
}
oldcfg.window_border != cfg2.window_border || need_size) {
set_geom_hints(inst);
request_resize(inst, cfg2.width, cfg2.height);
- //term_size(inst->term, cfg2.height, cfg2.width, cfg2.savelines);
- // where TF is our configure event going?!
}
term_invalidate(inst->term);
void update_specials_menu(void *frontend)
{
- Terminal *term = (Terminal *)frontend;
- struct gui_data *inst = (struct gui_data *)term->frontend;
+ struct gui_data *inst = (struct gui_data *)frontend;
const struct telnet_special *specials;
{
char *realhost, *error;
- error = inst->back->init((void *)inst->term, &inst->backhandle,
+ error = inst->back->init((void *)inst, &inst->backhandle,
&inst->cfg, inst->cfg.host, inst->cfg.port,
&realhost, inst->cfg.tcp_nodelay);
}
}
inst->back->provide_logctx(inst->backhandle, inst->logctx);
- update_specials_menu(inst->term);
+ update_specials_menu(inst);
term_provide_resize_fn(inst->term, inst->back->size, inst->backhandle);
/*
* TODO:
*
- * - Copy-and-paste from the Event Log.
+ * - Go through all the config options and ensure they can all be
+ * configured and reconfigured properly.
*
* - Remainder of the context menu:
*
- * - New Session and Duplicate Session (perhaps in pterm, in fact?!)
+ * - New Session, Duplicate Session and the Saved Sessions
+ * submenu.
+ * + at least New and Duplicate probably _should_ be in
+ * pterm.
* + Duplicate Session will be fun, since we must work out
* how to pass the config data through.
* + In fact this should be easier on Unix, since fork() is
* already have dropped privileges by this point, so we
* can't get another pty. Sigh. Looks like exec has to be
* the way forward then :-/
- *
- * - Saved Sessions submenu (not in pterm of course)
- *
- * - Copy All to Clipboard (for what that's worth)
*/
/*
char msg[1024], *title;
char *realhost;
- error = back->init((void *)term, &backhandle, &cfg,
+ error = back->init(NULL, &backhandle, &cfg,
cfg.host, cfg.port, &realhost, cfg.tcp_nodelay);
back->provide_logctx(backhandle, logctx);
if (error) {
*/
return;
}
+
+int from_backend(void *frontend, int is_stderr, const char *data, int len)
+{
+ return term_data(term, is_stderr, data, len);
+}