1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

Created new data types Filename' and FontSpec', intended to be

opaque to all platform-independent modules and only handled within
per-platform code. `Filename' is there because the Mac has a magic
way to store filenames (though currently this checkin doesn't
support it!); `FontSpec' is there so that all the auxiliary stuff
such as font height and charset and so on which is needed under
Windows but not Unix can be kept where it belongs, and so that I can
have a hope in hell of dealing with a font chooser in the forthcoming
cross-platform config box code, and best of all it gets the horrid
font height wart out of settings.c and into the Windows code where
it should be.
The Mac part of this checkin is a bunch of random guesses which will
probably not quite compile, but which look roughly right to me.
Sorry if I screwed it up, Ben :-)

[originally from svn r2765]
This commit is contained in:
Simon Tatham
2003-02-01 12:54:40 +00:00
parent ccf35b8a26
commit f26b7aa0d3
30 changed files with 612 additions and 271 deletions

View File

@ -1,4 +1,4 @@
/* $Id: mac.c,v 1.37 2003/01/25 15:15:40 ben Exp $ */
/* $Id: mac.c,v 1.38 2003/02/01 12:54:40 simon Exp $ */
/*
* Copyright (c) 1999 Ben Harris
* All rights reserved.
@ -741,8 +741,9 @@ void old_keyfile_warning(void)
}
char *platform_default_s(char const *name)
FontSpec platform_default_font(char const *name)
{
FontSpec ret;
long smfs;
Str255 pname;
static char cname[256];
@ -754,12 +755,33 @@ char *platform_default_s(char const *name)
if (smfs != 0) {
GetFontName(HiWord(smfs), pname);
if (pname[0] == 0)
return "Monaco";
p2cstrcpy(cname, pname);
return cname;
} else
return "Monaco";
strcpy(ret.name, "Monaco");
ret.height = LoWord(smfs);
p2cstrcpy(ret.name, pname);
} else {
strcpy(ret.name, "Monaco");
ret.height = 9;
}
ret.isbold = 0;
} else {
ret.name[0] = '\0';
}
return ret;
}
Filename platform_default_filename(const char *name)
{
Filename ret;
if (!strcmp(name, "LogFileName"))
strcpy(ret.path, "putty.log");
else
*ret.path = '\0';
return ret;
}
char *platform_default_s(char const *name)
{
return NULL;
}
@ -767,16 +789,6 @@ int platform_default_i(char const *name, int def)
{
long smfs;
if (!strcmp(name, "FontHeight")) {
smfs = GetScriptVariable(smSystemScript, smScriptMonoFondSize);
if (smfs == 0)
smfs = GetScriptVariable(smRoman, smScriptMonoFondSize);
if (smfs != 0)
return LoWord(smfs);
else
return 9;
}
/* Non-raw cut and paste of line-drawing chars works badly on the
* current Unix stub implementation of the Unicode functions.
* So I'm going to temporarily set the default to raw mode so
@ -793,6 +805,29 @@ void platform_get_x11_auth(char *display, int *proto,
/* SGT: I have no idea whether Mac X servers need anything here. */
}
Filename filename_from_str(char *str)
{
Filename ret;
strncpy(ret.path, str, sizeof(ret.path));
ret.path[sizeof(ret.path)-1] = '\0';
return ret;
}
char *filename_to_str(Filename fn)
{
return fn.path;
}
int filename_equal(Filename f1, Filename f2)
{
return !strcmp(f1.path, f2.path);
}
int filename_is_null(Filename fn)
{
return !*fn.path;
}
/*
* Local Variables:
* c-file-style: "simon"