Mercurial > hg > xemacs-beta
comparison src/objects-msw.c @ 867:804517e16990
[xemacs-hg @ 2002-06-05 09:54:39 by ben]
Textual renaming: text/char names
abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization.
[a] distinguish between "charptr" when it refers to operations on
the pointer itself and when it refers to operations on text; and
[b] use consistent naming for everything referring to internal
format, i.e.
Itext == text in internal format
Ibyte == a byte in such text
Ichar == a char as represented in internal character format
thus e.g.
set_charptr_emchar -> set_itext_ichar
The pre and post tags on either side of this change are:
pre-internal-format-textual-renaming
post-internal-format-textual-renaming
See the Internals Manual for details of exactly how this was done,
how to handle the change in your workspace, etc.
author | ben |
---|---|
date | Wed, 05 Jun 2002 09:58:45 +0000 |
parents | e7ee5f8bde58 |
children | 79c6ff3eef26 |
comparison
equal
deleted
inserted
replaced
866:613552a02607 | 867:804517e16990 |
---|---|
913 /************************************************************************/ | 913 /************************************************************************/ |
914 /* helpers */ | 914 /* helpers */ |
915 /************************************************************************/ | 915 /************************************************************************/ |
916 | 916 |
917 static int | 917 static int |
918 hexval (Intbyte c) | 918 hexval (Ibyte c) |
919 { | 919 { |
920 /* assumes ASCII and isxdigit (c) */ | 920 /* assumes ASCII and isxdigit (c) */ |
921 if (c >= 'a') | 921 if (c >= 'a') |
922 return c - 'a' + 10; | 922 return c - 'a' + 10; |
923 else if (c >= 'A') | 923 else if (c >= 'A') |
925 else | 925 else |
926 return c - '0'; | 926 return c - '0'; |
927 } | 927 } |
928 | 928 |
929 COLORREF | 929 COLORREF |
930 mswindows_string_to_color (const Intbyte *name) | 930 mswindows_string_to_color (const Ibyte *name) |
931 { | 931 { |
932 int i; | 932 int i; |
933 | 933 |
934 if (*name == '#') | 934 if (*name == '#') |
935 { | 935 { |
966 } | 966 } |
967 else if (!qxestrncmp_c (name, "rgb:", 4)) | 967 else if (!qxestrncmp_c (name, "rgb:", 4)) |
968 { | 968 { |
969 unsigned int r, g, b; | 969 unsigned int r, g, b; |
970 | 970 |
971 if (sscanf ((CIntbyte *) name, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) | 971 if (sscanf ((CIbyte *) name, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) |
972 { | 972 { |
973 int len = qxestrlen (name); | 973 int len = qxestrlen (name); |
974 if (len == 18) | 974 if (len == 18) |
975 { | 975 { |
976 r /= 257; | 976 r /= 257; |
988 else | 988 else |
989 return (COLORREF) -1; | 989 return (COLORREF) -1; |
990 } | 990 } |
991 else if (*name) /* Can't be an empty string */ | 991 else if (*name) /* Can't be an empty string */ |
992 { | 992 { |
993 Intbyte *nospaces = (Intbyte *) ALLOCA (qxestrlen (name) + 1); | 993 Ibyte *nospaces = (Ibyte *) ALLOCA (qxestrlen (name) + 1); |
994 Intbyte *c = nospaces; | 994 Ibyte *c = nospaces; |
995 while (*name) | 995 while (*name) |
996 if (*name != ' ') | 996 if (*name != ' ') |
997 *c++ = *name++; | 997 *c++ = *name++; |
998 else | 998 else |
999 name++; | 999 name++; |
1030 * | 1030 * |
1031 * The patterns 'match' iff for each field that is not blank in either pattern, | 1031 * The patterns 'match' iff for each field that is not blank in either pattern, |
1032 * the corresponding field in the other pattern is either identical or blank. | 1032 * the corresponding field in the other pattern is either identical or blank. |
1033 */ | 1033 */ |
1034 static int | 1034 static int |
1035 match_font (Intbyte *pattern1, Intbyte *pattern2, | 1035 match_font (Ibyte *pattern1, Ibyte *pattern2, |
1036 Intbyte *fontname) | 1036 Ibyte *fontname) |
1037 { | 1037 { |
1038 Intbyte *c1 = pattern1, *c2 = pattern2, *e1 = 0, *e2 = 0; | 1038 Ibyte *c1 = pattern1, *c2 = pattern2, *e1 = 0, *e2 = 0; |
1039 int i; | 1039 int i; |
1040 | 1040 |
1041 if (fontname) | 1041 if (fontname) |
1042 fontname[0] = '\0'; | 1042 fontname[0] = '\0'; |
1043 | 1043 |
1091 | 1091 |
1092 static int CALLBACK | 1092 static int CALLBACK |
1093 font_enum_callback_2 (ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme, | 1093 font_enum_callback_2 (ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme, |
1094 int FontType, struct font_enum_t *font_enum) | 1094 int FontType, struct font_enum_t *font_enum) |
1095 { | 1095 { |
1096 Intbyte fontname[MSW_FONTSIZE * 2 * MAX_EMCHAR_LEN]; /* should be enough :)*/ | 1096 Ibyte fontname[MSW_FONTSIZE * 2 * MAX_ICHAR_LEN]; /* should be enough :)*/ |
1097 Lisp_Object fontname_lispstr; | 1097 Lisp_Object fontname_lispstr; |
1098 int i; | 1098 int i; |
1099 Intbyte *facename; | 1099 Ibyte *facename; |
1100 | 1100 |
1101 /* | 1101 /* |
1102 * The enumerated font weights are not to be trusted because: | 1102 * The enumerated font weights are not to be trusted because: |
1103 * a) lpelfe->elfStyle is only filled in for TrueType fonts. | 1103 * a) lpelfe->elfStyle is only filled in for TrueType fonts. |
1104 * b) Not all Bold and Italic styles of all fonts (including some Vector, | 1104 * b) Not all Bold and Italic styles of all fonts (including some Vector, |
1108 * disallow Bold And Italic weights for these fonts, so we just leave | 1108 * disallow Bold And Italic weights for these fonts, so we just leave |
1109 * weights unspecified. This means that we have to weed out duplicates of | 1109 * weights unspecified. This means that we have to weed out duplicates of |
1110 * those fonts that do get enumerated with different weights. | 1110 * those fonts that do get enumerated with different weights. |
1111 */ | 1111 */ |
1112 TSTR_TO_C_STRING (lpelfe->elfLogFont.lfFaceName, facename); | 1112 TSTR_TO_C_STRING (lpelfe->elfLogFont.lfFaceName, facename); |
1113 if (charptr_emchar (facename) == '@') | 1113 if (itext_ichar (facename) == '@') |
1114 /* This is a font for writing vertically. We ignore it. */ | 1114 /* This is a font for writing vertically. We ignore it. */ |
1115 return 1; | 1115 return 1; |
1116 | 1116 |
1117 if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) | 1117 if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) |
1118 /* Scalable, so leave pointsize blank */ | 1118 /* Scalable, so leave pointsize blank */ |
1319 | 1319 |
1320 static void | 1320 static void |
1321 mswindows_finalize_font_instance (Lisp_Font_Instance *f); | 1321 mswindows_finalize_font_instance (Lisp_Font_Instance *f); |
1322 | 1322 |
1323 static HFONT | 1323 static HFONT |
1324 create_hfont_from_font_spec (const Intbyte *namestr, | 1324 create_hfont_from_font_spec (const Ibyte *namestr, |
1325 HDC hdc, | 1325 HDC hdc, |
1326 Lisp_Object name_for_errors, | 1326 Lisp_Object name_for_errors, |
1327 Lisp_Object device_font_list, | 1327 Lisp_Object device_font_list, |
1328 Error_Behavior errb) | 1328 Error_Behavior errb) |
1329 { | 1329 { |
1330 LOGFONTW logfont; | 1330 LOGFONTW logfont; |
1331 int fields, i; | 1331 int fields, i; |
1332 int pt; | 1332 int pt; |
1333 Intbyte fontname[LF_FACESIZE], weight[LF_FACESIZE], *style, points[8]; | 1333 Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], *style, points[8]; |
1334 Intbyte effects[LF_FACESIZE], charset[LF_FACESIZE]; | 1334 Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; |
1335 Intbyte *c; | 1335 Ibyte *c; |
1336 HFONT hfont; | 1336 HFONT hfont; |
1337 | 1337 |
1338 /* | 1338 /* |
1339 * mswindows fonts look like: | 1339 * mswindows fonts look like: |
1340 * fontname[:[weight ][style][:pointsize[:effects]]][:charset] | 1340 * fontname[:[weight ][style][:pointsize[:effects]]][:charset] |
1346 * Courier New | 1346 * Courier New |
1347 * maximal: | 1347 * maximal: |
1348 * Courier New:Bold Italic:10:underline strikeout:western | 1348 * Courier New:Bold Italic:10:underline strikeout:western |
1349 */ | 1349 */ |
1350 | 1350 |
1351 fields = sscanf ((CIntbyte *) namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s", | 1351 fields = sscanf ((CIbyte *) namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s", |
1352 fontname, weight, points, effects, charset); | 1352 fontname, weight, points, effects, charset); |
1353 | 1353 |
1354 /* This function is implemented in a fairly ad-hoc manner. | 1354 /* This function is implemented in a fairly ad-hoc manner. |
1355 * The general idea is to validate and canonicalize each of the above fields | 1355 * The general idea is to validate and canonicalize each of the above fields |
1356 * at the same time as we build up the win32 LOGFONT structure. This enables | 1356 * at the same time as we build up the win32 LOGFONT structure. This enables |
1449 /* Effects */ | 1449 /* Effects */ |
1450 logfont.lfUnderline = FALSE; | 1450 logfont.lfUnderline = FALSE; |
1451 logfont.lfStrikeOut = FALSE; | 1451 logfont.lfStrikeOut = FALSE; |
1452 if (fields >= 4 && effects[0] != '\0') | 1452 if (fields >= 4 && effects[0] != '\0') |
1453 { | 1453 { |
1454 Intbyte *effects2; | 1454 Ibyte *effects2; |
1455 | 1455 |
1456 /* Maybe split effects into effects and effects2 */ | 1456 /* Maybe split effects into effects and effects2 */ |
1457 if ((c = qxestrchr (effects, ' '))) | 1457 if ((c = qxestrchr (effects, ' '))) |
1458 { | 1458 { |
1459 *c = '\0'; | 1459 *c = '\0'; |
1550 for the default face. */ | 1550 for the default face. */ |
1551 | 1551 |
1552 if (!NILP (device_font_list)) | 1552 if (!NILP (device_font_list)) |
1553 { | 1553 { |
1554 Lisp_Object fonttail; | 1554 Lisp_Object fonttail; |
1555 Intbyte truename[MSW_FONTSIZE]; | 1555 Ibyte truename[MSW_FONTSIZE]; |
1556 | 1556 |
1557 qxesprintf (truename, "%s:%s:%d:%s:%s", fontname, weight, pt, effects, | 1557 qxesprintf (truename, "%s:%s:%d:%s:%s", fontname, weight, pt, effects, |
1558 charset); | 1558 charset); |
1559 LIST_LOOP (fonttail, device_font_list) | 1559 LIST_LOOP (fonttail, device_font_list) |
1560 { | 1560 { |
1590 Lisp_Object device_font_list, HDC hdc, | 1590 Lisp_Object device_font_list, HDC hdc, |
1591 Error_Behavior errb) | 1591 Error_Behavior errb) |
1592 { | 1592 { |
1593 HFONT hfont, hfont2; | 1593 HFONT hfont, hfont2; |
1594 TEXTMETRICW metrics; | 1594 TEXTMETRICW metrics; |
1595 Intbyte *namestr = XSTRING_DATA (name); | 1595 Ibyte *namestr = XSTRING_DATA (name); |
1596 | 1596 |
1597 hfont = create_hfont_from_font_spec (namestr, hdc, name, device_font_list, | 1597 hfont = create_hfont_from_font_spec (namestr, hdc, name, device_font_list, |
1598 errb); | 1598 errb); |
1599 f->data = xnew_and_zero (struct mswindows_font_instance_data); | 1599 f->data = xnew_and_zero (struct mswindows_font_instance_data); |
1600 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f,0,0) = hfont; | 1600 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f,0,0) = hfont; |
1696 else | 1696 else |
1697 abort (); | 1697 abort (); |
1698 | 1698 |
1699 LIST_LOOP (fonttail, font_list) | 1699 LIST_LOOP (fonttail, font_list) |
1700 { | 1700 { |
1701 Intbyte fontname[MSW_FONTSIZE]; | 1701 Ibyte fontname[MSW_FONTSIZE]; |
1702 | 1702 |
1703 if (match_font (XSTRING_DATA (XCAR (fonttail)), XSTRING_DATA (pattern), | 1703 if (match_font (XSTRING_DATA (XCAR (fonttail)), XSTRING_DATA (pattern), |
1704 fontname)) | 1704 fontname)) |
1705 result = Fcons (build_intstring (fontname), result); | 1705 result = Fcons (build_intstring (fontname), result); |
1706 } | 1706 } |
1726 | 1726 |
1727 #### does not canonicalize given fields! needs to be merged | 1727 #### does not canonicalize given fields! needs to be merged |
1728 with initialize_font_instance(). */ | 1728 with initialize_font_instance(). */ |
1729 | 1729 |
1730 int nsep = 0; | 1730 int nsep = 0; |
1731 Intbyte *ptr = (Intbyte *) XSTRING_DATA (f->name); | 1731 Ibyte *ptr = (Ibyte *) XSTRING_DATA (f->name); |
1732 Intbyte *name = (Intbyte *) ALLOCA (XSTRING_LENGTH (f->name) + 19); | 1732 Ibyte *name = (Ibyte *) ALLOCA (XSTRING_LENGTH (f->name) + 19); |
1733 | 1733 |
1734 qxestrcpy (name, ptr); | 1734 qxestrcpy (name, ptr); |
1735 | 1735 |
1736 while ((ptr = qxestrchr (ptr, ':')) != 0) | 1736 while ((ptr = qxestrchr (ptr, ':')) != 0) |
1737 { | 1737 { |
1760 } | 1760 } |
1761 | 1761 |
1762 #ifdef MULE | 1762 #ifdef MULE |
1763 | 1763 |
1764 static int | 1764 static int |
1765 mswindows_font_spec_matches_charset_stage_1 (const Intbyte *font_charset, | 1765 mswindows_font_spec_matches_charset_stage_1 (const Ibyte *font_charset, |
1766 Lisp_Object charset) | 1766 Lisp_Object charset) |
1767 { | 1767 { |
1768 int i, ms_charset = 0; | 1768 int i, ms_charset = 0; |
1769 CHARSETINFO info; | 1769 CHARSETINFO info; |
1770 int font_code_page; | 1770 int font_code_page; |
1798 return font_code_page == XINT (charset_code_page); | 1798 return font_code_page == XINT (charset_code_page); |
1799 } | 1799 } |
1800 | 1800 |
1801 static int | 1801 static int |
1802 mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset, | 1802 mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset, |
1803 const Intbyte *nonreloc, | 1803 const Ibyte *nonreloc, |
1804 Lisp_Object reloc, | 1804 Lisp_Object reloc, |
1805 Bytecount offset, Bytecount length) | 1805 Bytecount offset, Bytecount length) |
1806 { | 1806 { |
1807 const Intbyte *the_nonreloc = nonreloc; | 1807 const Ibyte *the_nonreloc = nonreloc; |
1808 int i; | 1808 int i; |
1809 const Intbyte *c; | 1809 const Ibyte *c; |
1810 Bytecount the_length = length; | 1810 Bytecount the_length = length; |
1811 | 1811 |
1812 /* The idea is that, when trying to find a suitable font for a character, | 1812 /* The idea is that, when trying to find a suitable font for a character, |
1813 we first see if the character comes from one of the known charsets | 1813 we first see if the character comes from one of the known charsets |
1814 listed above; if so, we try to find a font which is declared as being of | 1814 listed above; if so, we try to find a font which is declared as being of |
1829 the_nonreloc += offset; | 1829 the_nonreloc += offset; |
1830 | 1830 |
1831 c = the_nonreloc; | 1831 c = the_nonreloc; |
1832 for (i = 0; i < 4; i++) | 1832 for (i = 0; i < 4; i++) |
1833 { | 1833 { |
1834 Intbyte *newc = (Intbyte *) memchr (c, ':', the_length); | 1834 Ibyte *newc = (Ibyte *) memchr (c, ':', the_length); |
1835 if (!newc) | 1835 if (!newc) |
1836 break; | 1836 break; |
1837 newc++; | 1837 newc++; |
1838 the_length -= (newc - c); | 1838 the_length -= (newc - c); |
1839 c = newc; | 1839 c = newc; |
1908 dim = XCHARSET_DIMENSION (charset); | 1908 dim = XCHARSET_DIMENSION (charset); |
1909 | 1909 |
1910 if (dim == 1) | 1910 if (dim == 1) |
1911 { | 1911 { |
1912 for (i = lowlim; i <= highlim; i++) | 1912 for (i = lowlim; i <= highlim; i++) |
1913 if ((cp = emchar_to_unicode (make_emchar (charset, i, 0))) >= 0) | 1913 if ((cp = ichar_to_unicode (make_ichar (charset, i, 0))) >= 0) |
1914 break; | 1914 break; |
1915 } | 1915 } |
1916 else | 1916 else |
1917 { | 1917 { |
1918 for (i = lowlim; i <= highlim; i++) | 1918 for (i = lowlim; i <= highlim; i++) |
1919 for (j = lowlim; j <= highlim; j++) | 1919 for (j = lowlim; j <= highlim; j++) |
1920 if ((cp = emchar_to_unicode (make_emchar (charset, i, j))) >= 0) | 1920 if ((cp = ichar_to_unicode (make_ichar (charset, i, j))) >= 0) |
1921 break; | 1921 break; |
1922 } | 1922 } |
1923 | 1923 |
1924 if (cp < 0) | 1924 if (cp < 0) |
1925 return 0; | 1925 return 0; |