X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/71581f966353977ea2ee12e2ec02ac5905fdcb5d..d0f67860ecd249433504f0f2b2cc1c4908adc3a1:/mac/macdlg.c diff --git a/mac/macdlg.c b/mac/macdlg.c index 2ec10625..0b28cf9f 100644 --- a/mac/macdlg.c +++ b/mac/macdlg.c @@ -66,7 +66,6 @@ static void mac_config(int midsession) { Session *s; WinInfo *wi; - static struct sesslist sesslist; Str255 mactitle; char *str; @@ -77,18 +76,23 @@ static void mac_config(int midsession) memset(s, 0, sizeof(*s)); do_defaults(NULL, &s->cfg); s->hasfile = FALSE; + s->session_closed = FALSE; } + /* Copy the configuration somewhere else in case this is a * + * reconfiguration and the user cancels the operation */ + + s->temp_cfg = s->cfg; + if (HAVE_COLOR_QD()) s->settings_window = GetNewCWindow(wSettings, NULL, (WindowPtr)-1); else s->settings_window = GetNewWindow(wSettings, NULL, (WindowPtr)-1); - get_sesslist(&sesslist, TRUE); s->ctrlbox = ctrl_new_box(); - setup_config_box(s->ctrlbox, &sesslist, midsession, 0, 0); + setup_config_box(s->ctrlbox, midsession, 0, 0); - s->settings_ctrls.data = &s->cfg; + s->settings_ctrls.data = &s->temp_cfg; if (midsession) s->settings_ctrls.end = &mac_enddlg_reconfig; else @@ -113,6 +117,7 @@ static void mac_config(int midsession) else str = dupprintf("%s Configuration", appname); c2pstrcpy(mactitle, str); + sfree(str); SetWTitle(s->settings_window, mactitle); ShowWindow(s->settings_window); } @@ -134,6 +139,7 @@ static void mac_enddlg_config(WindowPtr window, int value) if (value == 0) mac_closedlg(window); else { + s->cfg = s->temp_cfg; mac_startsession(s); mac_closedlg(window); } @@ -146,7 +152,49 @@ static void mac_enddlg_reconfig(WindowPtr window, int value) if (value == 0) mac_closedlg(window); else { + Config prev_cfg = s->cfg; + s->cfg = s->temp_cfg; mac_closedlg(window); + + /* Pass new config data to the logging module */ + log_reconfig(s->logctx, &s->cfg); + + /* + * Flush the line discipline's edit buffer in the + * case where local editing has just been disabled. + */ + if (s->ldisc) + ldisc_send(s->ldisc, NULL, 0, 0); + + /* Change the palette */ + palette_reset(s); + + /* Reinitialise line codepage */ + init_ucs(s); + + /* Pass new config data to the terminal */ + term_reconfig(s->term, &s->cfg); + + /* Pass new config data to the back end */ + if (s->back) + s->back->reconfig(s->backhandle, &s->cfg); + + /* Screen size changed ? */ + if (s->cfg.height != prev_cfg.height || + s->cfg.width != prev_cfg.width || + s->cfg.savelines != prev_cfg.savelines) { + request_resize(s, s->cfg.width, s->cfg.height); + } + + /* Set the window title */ + if (s->cfg.wintitle[0]) + set_title(s, s->cfg.wintitle); + + /* Scroll bar */ + if (s->cfg.scrollbar != prev_cfg.scrollbar) + request_resize(s, s->cfg.width, s->cfg.height); + + /* TODO: zoom, font */ } } @@ -189,7 +237,7 @@ static OSErr mac_opensessionfrom(FSSpec *fss) err = -9999; goto fail; } - load_open_settings(sesshandle, TRUE, &s->cfg); + load_open_settings(sesshandle, &s->cfg); close_settings_r(sesshandle); mac_startsession(s); @@ -273,7 +321,7 @@ void mac_savesession(void) assert(s->hasfile); sesshandle = open_settings_w_fsp(&s->savefile); if (sesshandle == NULL) return; /* XXX report error */ - save_open_settings(sesshandle, TRUE, &s->cfg); + save_open_settings(sesshandle, &s->cfg); close_settings_w(sesshandle); } @@ -294,7 +342,7 @@ void mac_savesessionas(void) } sesshandle = open_settings_w_fsp(&sfr.sfFile); if (sesshandle == NULL) return; /* XXX report error */ - save_open_settings(sesshandle, TRUE, &s->cfg); + save_open_settings(sesshandle, &s->cfg); close_settings_w(sesshandle); s->hasfile = TRUE; s->savefile = sfr.sfFile;