27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#if GTK_CHECK_VERSION(2,0,0)
#include <gtk/gtkimmodule.h>
#endif
#define PUTTY_DO_GLOBALS /* actually _define_ globals */
#include "putty.h"
#include "terminal.h"
#include "gtkfont.h"
#define CAT2(x,y) x ## y
#define CAT(x,y) CAT2(x,y)
#define ASSERT(x) enum {CAT(assertion_,__LINE__) = 1 / (x)}
|
>
>
|
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#if GTK_CHECK_VERSION(2,0,0)
#include <gtk/gtkimmodule.h>
#endif
#define PUTTY_DO_GLOBALS /* actually _define_ globals */
#define MAY_REFER_TO_GTK_IN_HEADERS
#include "putty.h"
#include "terminal.h"
#include "gtkfont.h"
#define CAT2(x,y) x ## y
#define CAT(x,y) CAT2(x,y)
#define ASSERT(x) enum {CAT(assertion_,__LINE__) = 1 / (x)}
|
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
|
if (!frontend_got_net_pending_errors) {
frontend_got_net_pending_errors = TRUE;
frontend_net_pending_error_idle_id =
gtk_idle_add(frontend_net_pending_errors, NULL);
}
}
void setup_fonts_ucs(struct gui_data *inst)
{
int shadowbold = conf_get_int(inst->conf, CONF_shadowbold);
int shadowboldoffset = conf_get_int(inst->conf, CONF_shadowboldoffset);
FontSpec *fs;
if (inst->fonts[0])
unifont_destroy(inst->fonts[0]);
if (inst->fonts[1])
unifont_destroy(inst->fonts[1]);
if (inst->fonts[2])
unifont_destroy(inst->fonts[2]);
if (inst->fonts[3])
unifont_destroy(inst->fonts[3]);
fs = conf_get_fontspec(inst->conf, CONF_font);
inst->fonts[0] = multifont_create(inst->area, fs->name, FALSE, FALSE,
shadowboldoffset, shadowbold);
if (!inst->fonts[0]) {
fprintf(stderr, "%s: unable to load font \"%s\"\n", appname,
fs->name);
exit(1);
}
fs = conf_get_fontspec(inst->conf, CONF_boldfont);
if (shadowbold || !fs->name[0]) {
inst->fonts[1] = NULL;
} else {
inst->fonts[1] = multifont_create(inst->area, fs->name, FALSE, TRUE,
shadowboldoffset, shadowbold);
if (!inst->fonts[1]) {
fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname,
fs->name);
exit(1);
}
}
fs = conf_get_fontspec(inst->conf, CONF_widefont);
if (fs->name[0]) {
inst->fonts[2] = multifont_create(inst->area, fs->name, TRUE, FALSE,
shadowboldoffset, shadowbold);
if (!inst->fonts[2]) {
fprintf(stderr, "%s: unable to load wide font \"%s\"\n", appname,
fs->name);
exit(1);
}
} else {
inst->fonts[2] = NULL;
}
fs = conf_get_fontspec(inst->conf, CONF_wideboldfont);
if (shadowbold || !fs->name[0]) {
inst->fonts[3] = NULL;
} else {
inst->fonts[3] = multifont_create(inst->area, fs->name, TRUE, TRUE,
shadowboldoffset, shadowbold);
if (!inst->fonts[3]) {
fprintf(stderr, "%s: unable to load wide bold font \"%s\"\n", appname,
fs->name);
exit(1);
}
}
inst->font_width = inst->fonts[0]->width;
inst->font_height = inst->fonts[0]->height;
inst->direct_to_font = init_ucs(&inst->ucsdata,
conf_get_str(inst->conf, CONF_line_codepage),
conf_get_int(inst->conf, CONF_utf8_override),
inst->fonts[0]->public_charset,
conf_get_int(inst->conf, CONF_vtmode));
}
void set_geom_hints(struct gui_data *inst)
{
GdkGeometry geom;
geom.min_width = inst->font_width + 2*inst->window_border;
geom.min_height = inst->font_height + 2*inst->window_border;
|
|
|
|
<
<
<
<
<
<
<
|
|
|
|
<
<
|
|
|
|
>
>
|
<
<
|
|
|
>
>
>
|
<
<
|
|
|
|
|
>
>
>
|
|
>
>
|
>
>
>
>
|
>
>
>
>
>
>
|
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
|
if (!frontend_got_net_pending_errors) {
frontend_got_net_pending_errors = TRUE;
frontend_net_pending_error_idle_id =
gtk_idle_add(frontend_net_pending_errors, NULL);
}
}
char *setup_fonts_ucs(struct gui_data *inst)
{
int shadowbold = conf_get_int(inst->conf, CONF_shadowbold);
int shadowboldoffset = conf_get_int(inst->conf, CONF_shadowboldoffset);
FontSpec *fs;
unifont *fonts[4];
int i;
fs = conf_get_fontspec(inst->conf, CONF_font);
fonts[0] = multifont_create(inst->area, fs->name, FALSE, FALSE,
shadowboldoffset, shadowbold);
if (!fonts[0]) {
return dupprintf("unable to load font \"%s\"", fs->name);
}
fs = conf_get_fontspec(inst->conf, CONF_boldfont);
if (shadowbold || !fs->name[0]) {
fonts[1] = NULL;
} else {
fonts[1] = multifont_create(inst->area, fs->name, FALSE, TRUE,
shadowboldoffset, shadowbold);
if (!fonts[1]) {
if (fonts[0])
unifont_destroy(fonts[0]);
return dupprintf("unable to load bold font \"%s\"", fs->name);
}
}
fs = conf_get_fontspec(inst->conf, CONF_widefont);
if (fs->name[0]) {
fonts[2] = multifont_create(inst->area, fs->name, TRUE, FALSE,
shadowboldoffset, shadowbold);
if (!fonts[2]) {
for (i = 0; i < 2; i++)
if (fonts[i])
unifont_destroy(fonts[i]);
return dupprintf("%s: unable to load wide font \"%s\"", fs->name);
}
} else {
fonts[2] = NULL;
}
fs = conf_get_fontspec(inst->conf, CONF_wideboldfont);
if (shadowbold || !fs->name[0]) {
fonts[3] = NULL;
} else {
fonts[3] = multifont_create(inst->area, fs->name, TRUE, TRUE,
shadowboldoffset, shadowbold);
if (!fonts[3]) {
for (i = 0; i < 3; i++)
if (fonts[i])
unifont_destroy(fonts[i]);
return dupprintf("%s: unable to load wide bold font \"%s\"",
fs->name);
}
}
/*
* Now we've got past all the possible error conditions, we can
* actually update our state.
*/
for (i = 0; i < 4; i++) {
if (inst->fonts[i])
unifont_destroy(inst->fonts[i]);
inst->fonts[i] = fonts[i];
}
inst->font_width = inst->fonts[0]->width;
inst->font_height = inst->fonts[0]->height;
inst->direct_to_font = init_ucs(&inst->ucsdata,
conf_get_str(inst->conf, CONF_line_codepage),
conf_get_int(inst->conf, CONF_utf8_override),
inst->fonts[0]->public_charset,
conf_get_int(inst->conf, CONF_vtmode));
return NULL;
}
void set_geom_hints(struct gui_data *inst)
{
GdkGeometry geom;
geom.min_width = inst->font_width + 2*inst->window_border;
geom.min_height = inst->font_height + 2*inst->window_border;
|
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
|
set_title(inst, conf_get_str(newconf, CONF_wintitle));
set_window_titles(inst);
/*
* Redo the whole tangled fonts and Unicode mess if
* necessary.
*/
if (strcmp(conf_get_fontspec(oldconf, CONF_font)->name,
conf_get_fontspec(newconf, CONF_font)->name) ||
strcmp(conf_get_fontspec(oldconf, CONF_boldfont)->name,
conf_get_fontspec(newconf, CONF_boldfont)->name) ||
strcmp(conf_get_fontspec(oldconf, CONF_widefont)->name,
conf_get_fontspec(newconf, CONF_widefont)->name) ||
strcmp(conf_get_fontspec(oldconf, CONF_wideboldfont)->name,
conf_get_fontspec(newconf, CONF_wideboldfont)->name) ||
strcmp(conf_get_str(oldconf, CONF_line_codepage),
conf_get_str(newconf, CONF_line_codepage)) ||
conf_get_int(oldconf, CONF_utf8_override) !=
conf_get_int(newconf, CONF_utf8_override) ||
conf_get_int(oldconf, CONF_vtmode) !=
conf_get_int(newconf, CONF_vtmode) ||
conf_get_int(oldconf, CONF_shadowbold) !=
conf_get_int(newconf, CONF_shadowbold) ||
conf_get_int(oldconf, CONF_shadowboldoffset) !=
conf_get_int(newconf, CONF_shadowboldoffset)) {
setup_fonts_ucs(inst);
need_size = 1;
} else
need_size = 0;
/*
* Resize the window.
*/
if (conf_get_int(oldconf, CONF_width) !=
conf_get_int(newconf, CONF_width) ||
conf_get_int(oldconf, CONF_height) !=
|
>
|
>
>
>
>
>
>
>
>
|
|
|
>
>
|
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
|
set_title(inst, conf_get_str(newconf, CONF_wintitle));
set_window_titles(inst);
/*
* Redo the whole tangled fonts and Unicode mess if
* necessary.
*/
need_size = FALSE;
if (strcmp(conf_get_fontspec(oldconf, CONF_font)->name,
conf_get_fontspec(newconf, CONF_font)->name) ||
strcmp(conf_get_fontspec(oldconf, CONF_boldfont)->name,
conf_get_fontspec(newconf, CONF_boldfont)->name) ||
strcmp(conf_get_fontspec(oldconf, CONF_widefont)->name,
conf_get_fontspec(newconf, CONF_widefont)->name) ||
strcmp(conf_get_fontspec(oldconf, CONF_wideboldfont)->name,
conf_get_fontspec(newconf, CONF_wideboldfont)->name) ||
strcmp(conf_get_str(oldconf, CONF_line_codepage),
conf_get_str(newconf, CONF_line_codepage)) ||
conf_get_int(oldconf, CONF_utf8_override) !=
conf_get_int(newconf, CONF_utf8_override) ||
conf_get_int(oldconf, CONF_vtmode) !=
conf_get_int(newconf, CONF_vtmode) ||
conf_get_int(oldconf, CONF_shadowbold) !=
conf_get_int(newconf, CONF_shadowbold) ||
conf_get_int(oldconf, CONF_shadowboldoffset) !=
conf_get_int(newconf, CONF_shadowboldoffset)) {
char *errmsg = setup_fonts_ucs(inst);
if (errmsg) {
char *msgboxtext =
dupprintf("Could not change fonts in terminal window: %s\n",
errmsg);
messagebox(inst->window, "Font setup error", msgboxtext,
string_width("Could not change fonts in terminal window:"),
"OK", 'o', +1, 1,
NULL);
sfree(errmsg);
} else {
need_size = TRUE;
}
}
/*
* Resize the window.
*/
if (conf_get_int(oldconf, CONF_width) !=
conf_get_int(newconf, CONF_width) ||
conf_get_int(oldconf, CONF_height) !=
|
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
|
inst->area = gtk_drawing_area_new();
#if GTK_CHECK_VERSION(2,0,0)
inst->imc = gtk_im_multicontext_new();
#endif
setup_fonts_ucs(inst);
init_cutbuffers();
inst->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
{
const char *winclass = conf_get_str(inst->conf, CONF_winclass);
if (*winclass)
gtk_window_set_wmclass(GTK_WINDOW(inst->window),
|
>
|
>
>
>
>
>
|
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
|
inst->area = gtk_drawing_area_new();
#if GTK_CHECK_VERSION(2,0,0)
inst->imc = gtk_im_multicontext_new();
#endif
{
char *errmsg = setup_fonts_ucs(inst);
if (errmsg) {
fprintf(stderr, "%s: %s\n", appname, errmsg);
exit(1);
}
}
init_cutbuffers();
inst->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
{
const char *winclass = conf_get_str(inst->conf, CONF_winclass);
if (*winclass)
gtk_window_set_wmclass(GTK_WINDOW(inst->window),
|