mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 03:22:48 -05:00
Add a Seat vtable method to get a stripctrl.
If centralised code like the SSH implementation wants to sanitise escape sequences out of a piece of server-provided text, it will need to do it by making a locale-based StripCtrlChars if it's running in a console context, or a Terminal-based one if it's in a GUI terminal- window application. All the other changes of behaviour needed between those two contexts are handled by providing reconfigurable methods in the Seat vtable; this one is no different. So now there's a new method in the Seat vtable that will construct a StripCtrlChars appropriate to that kind of seat. Terminal-window seats (gtkwin.c, window.c) implement it by calling the new stripctrl_new_term(), and console ones use the locale- based stripctrl_new().
This commit is contained in:
@ -351,6 +351,13 @@ static bool gtk_seat_get_window_pixel_size(Seat *seat, int *w, int *h)
|
||||
return true;
|
||||
}
|
||||
|
||||
StripCtrlChars *gtk_seat_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution)
|
||||
{
|
||||
GtkFrontend *inst = container_of(seat, GtkFrontend, seat);
|
||||
return stripctrl_new_term(bs_out, permit_cr, substitution, inst->term);
|
||||
}
|
||||
|
||||
static void gtk_seat_notify_remote_exit(Seat *seat);
|
||||
static void gtk_seat_update_specials_menu(Seat *seat);
|
||||
static void gtk_seat_set_busy_status(Seat *seat, BusyStatus status);
|
||||
@ -380,6 +387,7 @@ static const SeatVtable gtk_seat_vt = {
|
||||
gtk_seat_get_windowid,
|
||||
#endif
|
||||
gtk_seat_get_window_pixel_size,
|
||||
gtk_seat_stripctrl_new,
|
||||
};
|
||||
|
||||
static void gtk_eventlog(LogPolicy *lp, const char *string)
|
||||
|
@ -465,6 +465,12 @@ static void console_eventlog(LogPolicy *lp, const char *string)
|
||||
console_logging_error(lp, string);
|
||||
}
|
||||
|
||||
StripCtrlChars *console_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution)
|
||||
{
|
||||
return stripctrl_new(bs_out, permit_cr, substitution);
|
||||
}
|
||||
|
||||
/*
|
||||
* Special functions to read and print to the console for password
|
||||
* prompts and the like. Uses /dev/tty or stdin/stderr, in that order
|
||||
|
@ -403,6 +403,7 @@ static const SeatVtable plink_seat_vt = {
|
||||
nullseat_get_x_display,
|
||||
nullseat_get_windowid,
|
||||
nullseat_get_window_pixel_size,
|
||||
console_stripctrl_new,
|
||||
};
|
||||
static Seat plink_seat[1] = {{ &plink_seat_vt }};
|
||||
|
||||
|
Reference in New Issue
Block a user