/[emacs]/emacs/src/xterm.c
ViewVC logotype

Diff of /emacs/src/xterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.804 by jhd, Thu Jul 31 16:10:53 2003 UTC revision 1.804.2.1 by handa, Mon Sep 8 12:48:17 2003 UTC
# Line 68  Boston, MA 02111-1307, USA.  */ Line 68  Boston, MA 02111-1307, USA.  */
68  /* #include <sys/param.h>  */  /* #include <sys/param.h>  */
69    
70  #include "charset.h"  #include "charset.h"
71    #include "character.h"
72  #include "coding.h"  #include "coding.h"
73  #include "ccl.h"  #include "ccl.h"
74  #include "frame.h"  #include "frame.h"
# Line 765  XTreset_terminal_modes () Line 766  XTreset_terminal_modes ()
766    
767  /* Function prototypes of this page.  */  /* Function prototypes of this page.  */
768    
769  static int x_encode_char P_ ((int, XChar2b *, struct font_info *, int *));  static int x_encode_char P_ ((int, XChar2b *, struct font_info *,
770                                  struct charset *, int *));
771    
772    
773  /* Get metrics of character CHAR2B in FONT.  Value is null if CHAR2B  /* Get metrics of character CHAR2B in FONT.  Value is null if CHAR2B
# Line 844  x_per_char_metric (font, char2b, font_ty Line 846  x_per_char_metric (font, char2b, font_ty
846     the two-byte form of C.  Encoding is returned in *CHAR2B.  */     the two-byte form of C.  Encoding is returned in *CHAR2B.  */
847    
848  static int  static int
849  x_encode_char (c, char2b, font_info, two_byte_p)  x_encode_char (c, char2b, font_info, charset, two_byte_p)
850       int c;       int c;
851       XChar2b *char2b;       XChar2b *char2b;
852       struct font_info *font_info;       struct font_info *font_info;
853         struct charset *charset;
854       int *two_byte_p;       int *two_byte_p;
855  {  {
   int charset = CHAR_CHARSET (c);  
856    XFontStruct *font = font_info->font;    XFontStruct *font = font_info->font;
857    
858    /* FONT_INFO may define a scheme by which to encode byte1 and byte2.    /* FONT_INFO may define a scheme by which to encode byte1 and byte2.
# Line 863  x_encode_char (c, char2b, font_info, two Line 865  x_encode_char (c, char2b, font_info, two
865    
866        if (CHARSET_DIMENSION (charset) == 1)        if (CHARSET_DIMENSION (charset) == 1)
867          {          {
868            ccl->reg[0] = charset;            ccl->reg[0] = CHARSET_ID (charset);
869            ccl->reg[1] = char2b->byte2;            ccl->reg[1] = char2b->byte2;
870            ccl->reg[2] = -1;            ccl->reg[2] = -1;
871          }          }
872        else        else
873          {          {
874            ccl->reg[0] = charset;            ccl->reg[0] = CHARSET_ID (charset);
875            ccl->reg[1] = char2b->byte1;            ccl->reg[1] = char2b->byte1;
876            ccl->reg[2] = char2b->byte2;            ccl->reg[2] = char2b->byte2;
877          }          }
878    
879        ccl_driver (ccl, NULL, NULL, 0, 0, NULL);        ccl_driver (ccl, NULL, NULL, 0, 0, Qnil);
880    
881        /* We assume that MSBs are appropriately set/reset by CCL        /* We assume that MSBs are appropriately set/reset by CCL
882           program.  */           program.  */
883        if (font->max_byte1 == 0) /* 1-byte font */        if (font->max_byte1 == 0) /* 1-byte font */
884          char2b->byte1 = 0, char2b->byte2 = ccl->reg[1];          STORE_XCHAR2B (char2b, 0, ccl->reg[1]);
885        else        else
886          char2b->byte1 = ccl->reg[1], char2b->byte2 = ccl->reg[2];          STORE_XCHAR2B (char2b, ccl->reg[1], ccl->reg[2]);
887      }      }
888    else if (font_info->encoding[charset])    else if (font_info->encoding_type)
889      {      {
890        /* Fixed encoding scheme.  See fontset.h for the meaning of the        /* Fixed encoding scheme.  See fontset.h for the meaning of the
891           encoding numbers.  */           encoding numbers.  */
892        int enc = font_info->encoding[charset];        unsigned char enc = font_info->encoding_type;
893    
894        if ((enc == 1 || enc == 2)        if ((enc == 1 || enc == 2)
895            && CHARSET_DIMENSION (charset) == 2)            && CHARSET_DIMENSION (charset) == 2)
# Line 6440  handle_one_xevent (dpyinfo, eventp, bufp Line 6442  handle_one_xevent (dpyinfo, eventp, bufp
6442                    /* The input is converted to events, thus we can't                    /* The input is converted to events, thus we can't
6443                       handle composition.  Anyway, there's no XIM that                       handle composition.  Anyway, there's no XIM that
6444                       gives us composition information.  */                       gives us composition information.  */
6445                    coding.composing = COMPOSITION_DISABLED;                    coding.common_flags &= ~CODING_ANNOTATION_MASK;
6446    
6447                    for (i = 0; i < nbytes; i++)                    for (i = 0; i < nbytes; i++)
6448                      {                      {
# Line 6452  handle_one_xevent (dpyinfo, eventp, bufp Line 6454  handle_one_xevent (dpyinfo, eventp, bufp
6454    
6455                    {                    {
6456                      /* Decode the input data.  */                      /* Decode the input data.  */
6457                      int require;                      coding.destination = (unsigned char *) malloc (nbytes);
6458                      unsigned char *p;                      if (! coding.destination)
6459                          break;
6460                      require = decoding_buffer_size (&coding, nbytes);                      coding.dst_bytes = nbytes;
6461                      p = (unsigned char *) alloca (require);                      coding.mode |= CODING_MODE_LAST_BLOCK;
6462                      coding.mode |= CODING_MODE_LAST_BLOCK;                      decode_coding_c_string (&coding, copy_bufptr,
6463                      /* We explicitly disable composition                                              nbytes, Qnil);
6464                         handling because key data should                      nbytes = coding.produced;
6465                         not contain any composition                      nchars = coding.produced_char;
6466                         sequence.  */                      if (copy_bufsiz < nbytes)
6467                      coding.composing = COMPOSITION_DISABLED;                        {
6468                      decode_coding (&coding, copy_bufptr, p,                          copy_bufsiz = nbytes;
6469                                     nbytes, require);                          copy_bufptr = (char *) alloca (nbytes);
6470                      nbytes = coding.produced;                        }
6471                      nchars = coding.produced_char;                      bcopy (coding.destination, copy_bufptr, nbytes);
6472                      copy_bufptr = p;                      free (coding.destination);
6473                    }                    }
6474    
6475                    /* Convert the input data to a sequence of                    /* Convert the input data to a sequence of
# Line 6480  handle_one_xevent (dpyinfo, eventp, bufp Line 6482  handle_one_xevent (dpyinfo, eventp, bufp
6482                          c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,                          c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
6483                                                      nbytes - i, len);                                                      nbytes - i, len);
6484    
6485                        bufp->kind = (SINGLE_BYTE_CHAR_P (c)                        bufp->kind = (ASCII_CHAR_P (c)
6486                                      ? ASCII_KEYSTROKE_EVENT                                      ? ASCII_KEYSTROKE_EVENT
6487                                      : MULTIBYTE_CHAR_KEYSTROKE_EVENT);                                      : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
6488                        bufp->code = c;                        bufp->code = c;
# Line 7876  x_new_font (f, fontname) Line 7878  x_new_font (f, fontname)
7878       register char *fontname;       register char *fontname;
7879  {  {
7880    struct font_info *fontp    struct font_info *fontp
7881      = FS_LOAD_FONT (f, 0, fontname, -1);      = FS_LOAD_FONT (f, fontname);
7882    
7883    if (!fontp)    if (!fontp)
7884      return Qnil;      return Qnil;
7885    
7886      if (FRAME_FONT (f) == (XFontStruct *) (fontp->font))
7887        /* This font is already set in frame F.  There's nothing more to
7888           do.  */
7889        return build_string (fontp->full_name);
7890    
7891    FRAME_FONT (f) = (XFontStruct *) (fontp->font);    FRAME_FONT (f) = (XFontStruct *) (fontp->font);
7892    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;    FRAME_BASELINE_OFFSET (f) = fontp->baseline_offset;
7893    FRAME_FONTSET (f) = -1;    FRAME_FONTSET (f) = -1;
# Line 7923  x_new_font (f, fontname) Line 7930  x_new_font (f, fontname)
7930    return build_string (fontp->full_name);    return build_string (fontp->full_name);
7931  }  }
7932    
7933  /* Give frame F the fontset named FONTSETNAME as its default font, and  /* Give frame F the fontset named FONTSETNAME as its default fontset,
7934     return the full name of that fontset.  FONTSETNAME may be a wildcard     and return the full name of that fontset.  FONTSETNAME may be a
7935     pattern; in that case, we choose some fontset that fits the pattern.     wildcard pattern; in that case, we choose some fontset that fits
7936     The return value shows which fontset we chose.  */     the pattern.  FONTSETNAME may be a font name for ASCII characters;
7937       in that case, we create a fontset from that font name.
7938    
7939       The return value shows which fontset we chose.
7940       If FONTSETNAME specifies the default fontset, return Qt.
7941       If an ASCII font in the specified fontset can't be loaded, return
7942       Qnil.  */
7943    
7944  Lisp_Object  Lisp_Object
7945  x_new_fontset (f, fontsetname)  x_new_fontset (f, fontsetname)
7946       struct frame *f;       struct frame *f;
7947       char *fontsetname;       Lisp_Object fontsetname;
7948  {  {
7949    int fontset = fs_query_fontset (build_string (fontsetname), 0);    int fontset = fs_query_fontset (fontsetname, 0);
7950    Lisp_Object result;    Lisp_Object result;
7951    
7952    if (fontset < 0)    if (fontset > 0 && f->output_data.x->fontset == fontset)
     return Qnil;  
   
   if (FRAME_FONTSET (f) == fontset)  
7953      /* This fontset is already set in frame F.  There's nothing more      /* This fontset is already set in frame F.  There's nothing more
7954         to do.  */         to do.  */
7955      return fontset_name (fontset);      return fontset_name (fontset);
7956      else if (fontset == 0)
7957        /* The default fontset can't be the default font.   */
7958        return Qt;
7959    
7960    result = x_new_font (f, (SDATA (fontset_ascii (fontset))));    if (fontset > 0)
7961        result = x_new_font (f, (SDATA (fontset_ascii (fontset))));
7962      else
7963        result = x_new_font (f, SDATA (fontsetname));
7964    
7965    if (!STRINGP (result))    if (!STRINGP (result))
7966      /* Can't load ASCII font.  */      /* Can't load ASCII font.  */
7967      return Qnil;      return Qnil;
7968    
7969      if (fontset < 0)
7970        fontset = new_fontset_from_font_name (result);
7971    
7972    /* Since x_new_font doesn't update any fontset information, do it now.  */    /* Since x_new_font doesn't update any fontset information, do it now.  */
7973    FRAME_FONTSET (f) = fontset;    FRAME_FONTSET (f) = fontset;
7974    
# Line 7959  x_new_fontset (f, fontsetname) Line 7978  x_new_fontset (f, fontsetname)
7978      xic_set_xfontset (f, SDATA (fontset_ascii (fontset)));      xic_set_xfontset (f, SDATA (fontset_ascii (fontset)));
7979  #endif  #endif
7980    
7981    return build_string (fontsetname);    return fontset_name (fontset);
7982  }  }
7983    
7984    
# Line 9868  x_load_font (f, fontname, size) Line 9887  x_load_font (f, fontname, size)
9887      BLOCK_INPUT;      BLOCK_INPUT;
9888      fontp->font = font;      fontp->font = font;
9889      fontp->font_idx = i;      fontp->font_idx = i;
9890        fontp->charset = -1;        /* fs_load_font sets it.  */
9891      fontp->name = (char *) xmalloc (strlen (fontname) + 1);      fontp->name = (char *) xmalloc (strlen (fontname) + 1);
9892      bcopy (fontname, fontp->name, strlen (fontname) + 1);      bcopy (fontname, fontp->name, strlen (fontname) + 1);
9893    
# Line 9942  x_load_font (f, fontname, size) Line 9962  x_load_font (f, fontname, size)
9962         the font code-points (0:0x20..0x7F, 1:0xA0..0xFF), or         the font code-points (0:0x20..0x7F, 1:0xA0..0xFF), or
9963         (0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF,         (0:0x2020..0x7F7F, 1:0xA0A0..0xFFFF, 3:0x20A0..0x7FFF,
9964         2:0xA020..0xFF7F).  For the moment, we don't know which charset         2:0xA020..0xFF7F).  For the moment, we don't know which charset
9965         uses this font.  So, we set information in fontp->encoding[1]         uses this font.  So, we set information in fontp->encoding_type
9966         which is never used by any charset.  If mapping can't be         which is never used by any charset.  If mapping can't be
9967         decided, set FONT_ENCODING_NOT_DECIDED.  */         decided, set FONT_ENCODING_NOT_DECIDED.  */
9968      fontp->encoding[1]      fontp->encoding_type
9969        = (font->max_byte1 == 0        = (font->max_byte1 == 0
9970           /* 1-byte font */           /* 1-byte font */
9971           ? (font->min_char_or_byte2 < 0x80           ? (font->min_char_or_byte2 < 0x80
# Line 10045  x_find_ccl_program (fontp) Line 10065  x_find_ccl_program (fontp)
10065  }  }
10066    
10067    
10068    /* Return a char-table whose elements are t if the font FONT_INFO
10069       contains a glyph for the corresponding character, and nil if not.
10070    
10071       Fixme: For the moment, this function works only for fonts whose
10072       glyph encoding is the same as Unicode (e.g. ISO10646-1 fonts).  */
10073    
10074    Lisp_Object
10075    x_get_font_repertory (f, font_info)
10076         FRAME_PTR f;
10077         struct font_info *font_info;
10078    {
10079      XFontStruct *font = (XFontStruct *) font_info->font;
10080      Lisp_Object table;
10081      int min_byte1, max_byte1, min_byte2, max_byte2;
10082    
10083      table = Fmake_char_table (Qnil, Qnil);
10084    
10085      min_byte1 = font->min_byte1;
10086      max_byte1 = font->max_byte1;
10087      min_byte2 = font->min_char_or_byte2;
10088      max_byte2 = font->max_char_or_byte2;
10089      if (min_byte1 == 0 && max_byte1 == 0)
10090        {
10091          if (! font->per_char || font->all_chars_exist == True)
10092            char_table_set_range (table, min_byte2, max_byte2, Qt);
10093          else
10094            {
10095              XCharStruct *pcm = font->per_char;
10096              int from = -1;
10097              int i;
10098    
10099              for (i = min_byte2; i <= max_byte2; i++, pcm++)
10100                {
10101                  if (pcm->width == 0 && pcm->rbearing == pcm->lbearing)
10102                    {
10103                      if (from >= 0)
10104                        {
10105                          char_table_set_range (table, from, i - 1, Qt);
10106                          from = -1;
10107                        }
10108                    }
10109                  else if (from < 0)
10110                    from = i;
10111                }
10112              if (from >= 0)
10113                char_table_set_range (table, from, i - 1, Qt);
10114            }
10115        }
10116      else
10117        {
10118          if (! font->per_char || font->all_chars_exist == True)
10119            {
10120              int i;
10121    
10122              for (i = min_byte1; i <= max_byte1; i++)
10123                char_table_set_range (table,
10124                                      (i << 8) | min_byte2, (i << 8) | max_byte2,
10125                                      Qt);
10126            }
10127          else
10128            {
10129              XCharStruct *pcm = font->per_char;
10130              int i;
10131    
10132              for (i = min_byte1; i <= max_byte1; i++)
10133                {
10134                  int from = -1;
10135                  int j;
10136    
10137                  for (j = min_byte2; j <= max_byte2; j++, pcm++)
10138                    {
10139                      if (pcm->width == 0 && pcm->rbearing == pcm->lbearing)
10140                        {
10141                          if (from >= 0)
10142                            {
10143                              char_table_set_range (table, (i << 8) | from,
10144                                                    (i << 8) | (j - 1), Qt);
10145                              from = -1;
10146                            }
10147                        }
10148                      else if (from < 0)
10149                        from = j;
10150                    }
10151                  if (from >= 0)
10152                    char_table_set_range (table, (i << 8) | from,
10153                                          (i << 8) | (j - 1), Qt);
10154                }
10155            }
10156        }
10157    
10158      return table;
10159    }
10160    
10161  /***********************************************************************  /***********************************************************************
10162                              Initialization                              Initialization
# Line 10801  syms_of_xterm () Line 10913  syms_of_xterm ()
10913    staticpro (&Qvendor_specific_keysyms);    staticpro (&Qvendor_specific_keysyms);
10914    Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");    Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
10915    
   staticpro (&Qutf_8);  
   Qutf_8 = intern ("utf-8");  
10916    staticpro (&Qlatin_1);    staticpro (&Qlatin_1);
10917    Qlatin_1 = intern ("latin-1");    Qlatin_1 = intern ("latin-1");
10918    

Legend:
Removed from v.1.804  
changed lines
  Added in v.1.804.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26