]> code.delx.au - gnu-emacs/blobdiff - mac/src/macterm.c
*** empty log message ***
[gnu-emacs] / mac / src / macterm.c
index 2b7ea0f0a61b7f108cd50cd753595ca5c29c696e..d84eea705739cc08bfc3b9798a311a53fa86c262 100644 (file)
@@ -90,6 +90,7 @@ Boston, MA 02111-1307, USA.  */
 #include "intervals.h"
 #include "process.h"
 #include "atimer.h"
+#include "keymap.h"
 #include "coding.h"
 
 #ifdef HAVE_UNISTD_H
@@ -540,7 +541,7 @@ XDrawLine (display, w, gc, x1, y1, x2, y2)
 
 /* Mac version of XClearArea.  */
 
-static void
+void
 XClearArea (display, w, x, y, width, height, exposures)
      Display *display;
      WindowPtr w;
@@ -836,6 +837,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
 }
 
 
+#if 0
 /* Convert a pair of local coordinates to global (screen) coordinates.
    Assume graphic port has been properly set.  */
 static void
@@ -851,7 +853,7 @@ local_to_global_coord (short *h, short *v)
   *h = p.h;
   *v = p.v;
 }
-
+#endif
 
 /* Mac replacement for XCopyArea: used only for scrolling.  */
 
@@ -867,11 +869,14 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
   Rect src_r, dest_r;
 
   SetPort (w);
+#if 0
   mac_set_colors (gc);
+#endif
 
   SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
   SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
 
+#if 0
   /* Need to use global coordinates and screenBits since src and dest
      areas overlap in general.  */
   local_to_global_coord (&src_r.left, &src_r.top);
@@ -880,6 +885,15 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
   local_to_global_coord (&dest_r.right, &dest_r.bottom);
 
   CopyBits (&qd.screenBits, &qd.screenBits, &src_r, &dest_r, srcCopy, 0);
+#else
+  /* In Color QuickDraw, set ForeColor and BackColor as follows to avoid
+     color mapping in CopyBits.  Otherwise, it will be slow.  */
+  ForeColor (blackColor);
+  BackColor (whiteColor);
+  CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
+  
+  mac_set_colors (gc);
+#endif
 }
 
 
@@ -6796,13 +6810,13 @@ note_mode_line_highlight (w, x, mode_line_p)
          /* Change the mouse pointer according to what is under X/Y.  */
          map = Fget_text_property (make_number (glyph->charpos),
                                    Qlocal_map, glyph->object);
-         if (!NILP (Fkeymapp (map)))
+         if (KEYMAPP (map))
            cursor = f->output_data.mac->nontext_cursor;
          else
            {
              map = Fget_text_property (make_number (glyph->charpos),
                                        Qkeymap, glyph->object);
-             if (!NILP (Fkeymapp (map)))
+             if (KEYMAPP (map))
                cursor = f->output_data.mac->nontext_cursor;
            }
        }
@@ -7532,7 +7546,7 @@ void
 clear_mouse_face (dpyinfo)
      struct mac_display_info *dpyinfo;
 {
-  if (tip_frame)
+  if (!NILP (tip_frame))
     return;
   
   if (! NILP (dpyinfo->mouse_face_window))
@@ -9272,7 +9286,7 @@ xim_open_dpy (dpyinfo, resource_name)
 #ifdef HAVE_X11R6
       destroy.callback = xim_destroy_callback;
       destroy.client_data = (XPointer)dpyinfo;
-      /* This isn't prptotyped in OSF 5.0.  */
+      /* This isn't prototyped in OSF 5.0.  */
       XSetIMValues (xim, XNDestroyCallback, &destroy, NULL);
 #endif
     }
@@ -10274,6 +10288,15 @@ mac_to_x_fontname (char *name, int size, Style style, short scriptcode)
       case smJapanese:
         strcpy(cs, "jisx0208.1983-sjis");
         break;
+      case -smJapanese:
+       /* Each Apple Japanese font is entered into the font table
+          twice: once as a jisx0208.1983-sjis font and once as a
+          jisx0201.1976-0 font.  The latter can be used to display
+          the ascii charset and katakana-jisx0201 charset.  A
+          negative script code signals that the name of this latter
+          font is being built.  */
+       strcpy(cs, "jisx0201.1976-0");
+       break;
       case smKorean:
         strcpy(cs, "ksc5601.1989-0");
         break;        
@@ -10317,6 +10340,7 @@ x_font_name_to_mac_font_name (char *xf, char *mf)
 
   if (strcmp (cs, "big5-0") == 0 || strcmp (cs, "gb2312.1980-0") == 0
       || strcmp (cs, "jisx0208.1983-sjis") == 0
+      || strcmp (cs, "jisx0201.1976-0") == 0
       || strcmp (cs, "ksc5601.1989-0") == 0 || strcmp (cs, "mac-roman") == 0)
     strcpy(mf, family);
   else
@@ -10380,7 +10404,11 @@ init_font_name_table ()
                       font_name_table = (char **)
                        xmalloc (font_name_table_size * sizeof (char *));
                     }
-                  else if (font_name_count >= font_name_table_size)
+                  else if (font_name_count >= font_name_table_size ||
+                          /* fonts in Japanese scripts require two
+                             entries.  */
+                          scriptcode == smJapanese &&
+                          font_name_count + 1 >= font_name_table_size)
                     {
                       font_name_table_size += 16;
                       font_name_table = (char **)
@@ -10392,6 +10420,16 @@ init_font_name_table ()
                                         assc_entry->fontSize,
                                         assc_entry->fontStyle,
                                         scriptcode);
+                 /* Both jisx0208.1983-sjis and jisx0201.1976-0 parts
+                    are contained in Apple Japanese (SJIS) font.  */
+                 if (smJapanese == scriptcode)
+                   {
+                     font_name_table[font_name_count++]
+                       = mac_to_x_fontname (name,
+                                            assc_entry->fontSize,
+                                            assc_entry->fontStyle,
+                                            -smJapanese);
+                   }
                 }
             }
 
@@ -10647,6 +10685,20 @@ XLoadQueryFont (Display *dpy, char *fontname)
   font->mac_fontface = fontface;
   font->mac_scriptcode = FontToScript (fontnum);
 
+  /* Apple Japanese (SJIS) font is listed as both
+     "*-jisx0208.1983-sjis" (Japanese script) and "*-jisx0201.1976-0"
+     (Roman script) in init_font_name_table().  The latter should be
+     treated as a one-byte font.  */
+  {
+    char cs[32];
+
+    if (sscanf (name, 
+               "-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]--%*[^-]-%*[^-]-%*[^-]-%*[^-]-%*c-%*[^-]-%31s",
+               cs) == 1
+       && 0 == strcmp (cs, "jisx0201.1976-0"))  
+      font->mac_scriptcode = smRoman;
+  }
+  
   is_two_byte_font = font->mac_scriptcode == smJapanese ||
                      font->mac_scriptcode == smTradChinese ||
                      font->mac_scriptcode == smSimpChinese ||
@@ -11101,6 +11153,7 @@ static long app_sleep_time = WNE_SLEEP_AT_RESUME;
 
 #define ARGV_STRING_LIST_ID 129
 #define ABOUT_ALERT_ID 128
+#define RAM_TOO_LARGE_ALERT_ID 129
 
 Boolean        terminate_flag = false;
 
@@ -11177,6 +11230,22 @@ do_init_managers (void)
 }
 
 
+static void
+do_check_ram_size (void)
+{
+  SInt32 physical_ram_size, logical_ram_size;
+  
+  if (Gestalt (gestaltPhysicalRAMSize, &physical_ram_size) != noErr
+      || Gestalt (gestaltLogicalRAMSize, &logical_ram_size) != noErr
+      || physical_ram_size > 256 * 1024 * 1024
+      || logical_ram_size > 256 * 1024 * 1024)
+    {
+      StopAlert (RAM_TOO_LARGE_ALERT_ID, NULL);
+      exit (1);
+    }
+}
+
+
 static void
 do_window_update (WindowPtr win)
 {
@@ -11243,6 +11312,8 @@ do_app_resume ()
   mac_output *mwp = (mac_output *) GetWRefCon (FrontWindow ());
   struct frame *f = mwp->mFP;
 
+  SetCursor (&qd.arrow);
+
   if (f)
     {
       x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
@@ -11295,7 +11366,7 @@ do_os_event (EventRecord *erp)
        do_app_suspend ();
       break;
                                
-    case mouseMovedMessage:
+    case mouseMovedMessage:    /* never reached */
       do_mouse_moved (erp->where);
       break;
     }
@@ -11558,7 +11629,7 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
 
          if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID,
                                      fs.name) &&
-             mac_to_unix_pathname (path_name, unix_path_name, 255))
+             mac_to_posix_pathname (path_name, unix_path_name, 255))
             drag_and_drop_file_list = Fcons (build_string (unix_path_name),
                                             drag_and_drop_file_list);
         }
@@ -11644,6 +11715,8 @@ main (void)
        
   do_get_menus ();
        
+  do_check_ram_size ();
+
   init_emacs_passwd_dir ();
 
   init_environ ();
@@ -11763,7 +11836,7 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
   if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
     event_mask -= highLevelEventMask;
 
-  if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL))
+  while (WaitNextEvent (event_mask, &er, 0L, NULL) && numchars > 0)
     switch (er.what)
       {
       case mouseDown:
@@ -11796,6 +11869,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
               mouse_tracking_in_progress = mouse_tracking_none;
               tracked_scroll_bar = NULL;
               count++;
+             bufp++;
+             numchars--;
               break;
             }
 
@@ -11811,6 +11886,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                 bufp->kind = menu_bar_activate_event;
                 XSETFRAME (bufp->frame_or_window, f);
                 count++;
+               bufp++;
+               numchars--;
               }
              break;
 
@@ -11875,6 +11952,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                    }
                                                                
                  count++;
+                 bufp++;
+                 numchars--;
                }
              break;
 
@@ -11889,6 +11968,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
                  XSETFRAME (bufp->frame_or_window,
                             ((mac_output *) GetWRefCon (window_ptr))->mFP);
                  count++;
+                 bufp++;
+                 numchars--;
                }
              break;
 
@@ -12025,6 +12106,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
        bufp->timestamp = er.when * (1000 / 60);  /* ticks to milliseconds */
 
        count++;
+       bufp++;
+       numchars--;
        break;
 
       case kHighLevelEvent:
@@ -12066,6 +12149,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
               InvalRect (&(wp->portRect));
             
             count++;
+           bufp++;
+           numchars--;
           }
         
       default: