OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [mac-xdep.c] - Diff between revs 105 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 105 Rev 1765
/* Top level support for Mac interface to GDB, the GNU debugger.
/* Top level support for Mac interface to GDB, the GNU debugger.
   Copyright 1994 Free Software Foundation, Inc.
   Copyright 1994 Free Software Foundation, Inc.
   Contributed by Cygnus Support.  Written by Stan Shebs.
   Contributed by Cygnus Support.  Written by Stan Shebs.
 
 
   This file is part of GDB.
   This file is part of GDB.
 
 
   This program is free software; you can redistribute it and/or modify
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   (at your option) any later version.
 
 
   This program is distributed in the hope that it will be useful,
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   GNU General Public License for more details.
 
 
   You should have received a copy of the GNU General Public License
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */
   Boston, MA 02111-1307, USA.  */
 
 
#include "defs.h"
#include "defs.h"
 
 
#include <readline/readline.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <readline/history.h>
 
 
#include <Types.h>
#include <Types.h>
#include <Resources.h>
#include <Resources.h>
#include <QuickDraw.h>
#include <QuickDraw.h>
#include <Fonts.h>
#include <Fonts.h>
#include <Events.h>
#include <Events.h>
#include <Windows.h>
#include <Windows.h>
#include <Menus.h>
#include <Menus.h>
#include <TextEdit.h>
#include <TextEdit.h>
#include <Dialogs.h>
#include <Dialogs.h>
#include <Desk.h>
#include <Desk.h>
#include <ToolUtils.h>
#include <ToolUtils.h>
#include <Memory.h>
#include <Memory.h>
#include <SegLoad.h>
#include <SegLoad.h>
#include <Files.h>
#include <Files.h>
#include <Folders.h>
#include <Folders.h>
#include <OSUtils.h>
#include <OSUtils.h>
#include <OSEvents.h>
#include <OSEvents.h>
#include <DiskInit.h>
#include <DiskInit.h>
#include <Packages.h>
#include <Packages.h>
#include <Traps.h>
#include <Traps.h>
#include <Lists.h>
#include <Lists.h>
#include <Gestalt.h>
#include <Gestalt.h>
#include <PPCToolbox.h>
#include <PPCToolbox.h>
#include <AppleEvents.h>
#include <AppleEvents.h>
#include <StandardFile.h>
#include <StandardFile.h>
#include <Sound.h>
#include <Sound.h>
 
 
#ifdef MPW
#ifdef MPW
#define QD(whatever) (qd.##whatever)
#define QD(whatever) (qd.##whatever)
#define QDPat(whatever) (&(qd.##whatever))
#define QDPat(whatever) (&(qd.##whatever))
#endif /* MPW */
#endif /* MPW */
 
 
#ifdef THINK_C
#ifdef THINK_C
#define QD(whatever) (whatever)
#define QD(whatever) (whatever)
#endif
#endif
 
 
#define p2c(pstr,cbuf)  \
#define p2c(pstr,cbuf)  \
  strncpy(cbuf, ((char *) (pstr) + 1), pstr[0]);  \
  strncpy(cbuf, ((char *) (pstr) + 1), pstr[0]);  \
  cbuf[pstr[0]] = '\0';
  cbuf[pstr[0]] = '\0';
 
 
#define pascalify(STR) \
#define pascalify(STR) \
  sprintf(tmpbuf, " %s", STR);  \
  sprintf(tmpbuf, " %s", STR);  \
  tmpbuf[0] = strlen(STR);
  tmpbuf[0] = strlen(STR);
 
 
#include "gdbcmd.h"
#include "gdbcmd.h"
#include "call-cmds.h"
#include "call-cmds.h"
#include "symtab.h"
#include "symtab.h"
#include "inferior.h"
#include "inferior.h"
#include "signals.h"
#include "signals.h"
#include "target.h"
#include "target.h"
#include "breakpoint.h"
#include "breakpoint.h"
#include "gdbtypes.h"
#include "gdbtypes.h"
#include "expression.h"
#include "expression.h"
#include "language.h"
#include "language.h"
 
 
#include "mac-defs.h"
#include "mac-defs.h"
 
 
int debug_openp = 0;
int debug_openp = 0;
 
 
/* This is true if we are running as a standalone application.  */
/* This is true if we are running as a standalone application.  */
 
 
int mac_app;
int mac_app;
 
 
/* This is true if we are using WaitNextEvent.  */
/* This is true if we are using WaitNextEvent.  */
 
 
int use_wne;
int use_wne;
 
 
/* This is true if we have Color Quickdraw.  */
/* This is true if we have Color Quickdraw.  */
 
 
int has_color_qd;
int has_color_qd;
 
 
/* This is true if we are using Color Quickdraw. */
/* This is true if we are using Color Quickdraw. */
 
 
int use_color_qd;
int use_color_qd;
 
 
int inbackground;
int inbackground;
 
 
Rect dragrect =
Rect dragrect =
{-32000, -32000, 32000, 32000};
{-32000, -32000, 32000, 32000};
Rect sizerect;
Rect sizerect;
 
 
int sbarwid = 15;
int sbarwid = 15;
 
 
/* Globals for the console window. */
/* Globals for the console window. */
 
 
WindowPtr console_window;
WindowPtr console_window;
 
 
ControlHandle console_v_scrollbar;
ControlHandle console_v_scrollbar;
 
 
Rect console_v_scroll_rect;
Rect console_v_scroll_rect;
 
 
TEHandle console_text;
TEHandle console_text;
 
 
Rect console_text_rect;
Rect console_text_rect;
 
 
/* This will go away eventually. */
/* This will go away eventually. */
gdb_has_a_terminal ()
gdb_has_a_terminal ()
{
{
  return 1;
  return 1;
}
}
 
 
mac_init ()
mac_init ()
{
{
  SysEnvRec se;
  SysEnvRec se;
  int eventloopdone = 0;
  int eventloopdone = 0;
  char *str;
  char *str;
  Boolean gotevent;
  Boolean gotevent;
  Point mouse;
  Point mouse;
  EventRecord event;
  EventRecord event;
  WindowPtr win;
  WindowPtr win;
  RgnHandle cursorRgn;
  RgnHandle cursorRgn;
  int i;
  int i;
  Handle menubar;
  Handle menubar;
  MenuHandle menu;
  MenuHandle menu;
  Handle siow_resource;
  Handle siow_resource;
 
 
  mac_app = 0;
  mac_app = 0;
 
 
  str = getenv ("DEBUG_GDB");
  str = getenv ("DEBUG_GDB");
  if (str != NULL && str[0] != '\0')
  if (str != NULL && str[0] != '\0')
    {
    {
      if (strcmp (str, "openp") == 0)
      if (strcmp (str, "openp") == 0)
        debug_openp = 1;
        debug_openp = 1;
    }
    }
 
 
  /* Don't do anything if we`re running under MPW. */
  /* Don't do anything if we`re running under MPW. */
  if (!StandAlone)
  if (!StandAlone)
    return;
    return;
 
 
  /* Don't do anything if we're using SIOW. */
  /* Don't do anything if we're using SIOW. */
  /* This test requires that the siow 0 resource, as defined in
  /* This test requires that the siow 0 resource, as defined in
     {RIncludes}siow.r, not be messed with.  If it is, then the
     {RIncludes}siow.r, not be messed with.  If it is, then the
     standard Mac setup below will step on SIOW's Mac setup and
     standard Mac setup below will step on SIOW's Mac setup and
     most likely crash the machine. */
     most likely crash the machine. */
  siow_resource = GetResource ('siow', 0);
  siow_resource = GetResource ('siow', 0);
  if (siow_resource != nil)
  if (siow_resource != nil)
    return;
    return;
 
 
  mac_app = 1;
  mac_app = 1;
 
 
  /* Do the standard Mac environment setup. */
  /* Do the standard Mac environment setup. */
  InitGraf (&QD (thePort));
  InitGraf (&QD (thePort));
  InitFonts ();
  InitFonts ();
  FlushEvents (everyEvent, 0);
  FlushEvents (everyEvent, 0);
  InitWindows ();
  InitWindows ();
  InitMenus ();
  InitMenus ();
  TEInit ();
  TEInit ();
  InitDialogs (NULL);
  InitDialogs (NULL);
  InitCursor ();
  InitCursor ();
 
 
  /* Color Quickdraw is different from Classic QD. */
  /* Color Quickdraw is different from Classic QD. */
  SysEnvirons (2, &se);
  SysEnvirons (2, &se);
  has_color_qd = se.hasColorQD;
  has_color_qd = se.hasColorQD;
  /* Use it if we got it. */
  /* Use it if we got it. */
  use_color_qd = has_color_qd;
  use_color_qd = has_color_qd;
 
 
  sizerect.top = 50;
  sizerect.top = 50;
  sizerect.left = 50;
  sizerect.left = 50;
  sizerect.bottom = 1000;
  sizerect.bottom = 1000;
  sizerect.right = 1000;
  sizerect.right = 1000;
#if 0
#if 0
  sizerect.bottom = screenBits.bounds.bottom - screenBits.bounds.top;
  sizerect.bottom = screenBits.bounds.bottom - screenBits.bounds.top;
  sizerect.right = screenBits.bounds.right - screenBits.bounds.left;
  sizerect.right = screenBits.bounds.right - screenBits.bounds.left;
#endif
#endif
 
 
  /* Set up the menus. */
  /* Set up the menus. */
  menubar = GetNewMBar (mbMain);
  menubar = GetNewMBar (mbMain);
  SetMenuBar (menubar);
  SetMenuBar (menubar);
  /* Add the DAs etc as usual. */
  /* Add the DAs etc as usual. */
  menu = GetMHandle (mApple);
  menu = GetMHandle (mApple);
  if (menu != nil)
  if (menu != nil)
    {
    {
      AddResMenu (menu, 'DRVR');
      AddResMenu (menu, 'DRVR');
    }
    }
  DrawMenuBar ();
  DrawMenuBar ();
 
 
  new_console_window ();
  new_console_window ();
}
}
 
 
new_console_window ()
new_console_window ()
{
{
  /* Create the main window we're going to play in. */
  /* Create the main window we're going to play in. */
  if (has_color_qd)
  if (has_color_qd)
    console_window = GetNewCWindow (wConsole, NULL, (WindowPtr) - 1L);
    console_window = GetNewCWindow (wConsole, NULL, (WindowPtr) - 1L);
  else
  else
    console_window = GetNewWindow (wConsole, NULL, (WindowPtr) - 1L);
    console_window = GetNewWindow (wConsole, NULL, (WindowPtr) - 1L);
 
 
  SetPort (console_window);
  SetPort (console_window);
  console_text_rect = console_window->portRect;
  console_text_rect = console_window->portRect;
  /* Leave 8 pixels of blank space, for aesthetic reasons and to
  /* Leave 8 pixels of blank space, for aesthetic reasons and to
     make it easier to select from the beginning of a line. */
     make it easier to select from the beginning of a line. */
  console_text_rect.left += 8;
  console_text_rect.left += 8;
  console_text_rect.bottom -= sbarwid - 1;
  console_text_rect.bottom -= sbarwid - 1;
  console_text_rect.right -= sbarwid - 1;
  console_text_rect.right -= sbarwid - 1;
  console_text = TENew (&console_text_rect, &console_text_rect);
  console_text = TENew (&console_text_rect, &console_text_rect);
  TESetSelect (0, 40000, console_text);
  TESetSelect (0, 40000, console_text);
  TEDelete (console_text);
  TEDelete (console_text);
  TEAutoView (1, console_text);
  TEAutoView (1, console_text);
 
 
  console_v_scroll_rect = console_window->portRect;
  console_v_scroll_rect = console_window->portRect;
  console_v_scroll_rect.bottom -= sbarwid - 1;
  console_v_scroll_rect.bottom -= sbarwid - 1;
  console_v_scroll_rect.left = console_v_scroll_rect.right - sbarwid;
  console_v_scroll_rect.left = console_v_scroll_rect.right - sbarwid;
  console_v_scrollbar =
  console_v_scrollbar =
    NewControl (console_window, &console_v_scroll_rect,
    NewControl (console_window, &console_v_scroll_rect,
                "\p", 1, 0, 0, 0, scrollBarProc, 0L);
                "\p", 1, 0, 0, 0, scrollBarProc, 0L);
 
 
  ShowWindow (console_window);
  ShowWindow (console_window);
  SelectWindow (console_window);
  SelectWindow (console_window);
}
}
 
 
mac_command_loop ()
mac_command_loop ()
{
{
  SysEnvRec se;
  SysEnvRec se;
  int eventloopdone = 0;
  int eventloopdone = 0;
  Boolean gotevent;
  Boolean gotevent;
  Point mouse;
  Point mouse;
  EventRecord event;
  EventRecord event;
  WindowPtr win;
  WindowPtr win;
  RgnHandle cursorRgn;
  RgnHandle cursorRgn;
  int i, tm;
  int i, tm;
  Handle menubar;
  Handle menubar;
  MenuHandle menu;
  MenuHandle menu;
 
 
  /* Figure out if the WaitNextEvent Trap is available.  */
  /* Figure out if the WaitNextEvent Trap is available.  */
  use_wne =
  use_wne =
    (NGetTrapAddress (0x60, ToolTrap) != NGetTrapAddress (0x9f, ToolTrap));
    (NGetTrapAddress (0x60, ToolTrap) != NGetTrapAddress (0x9f, ToolTrap));
  /* Pass WaitNextEvent an empty region the first time through.  */
  /* Pass WaitNextEvent an empty region the first time through.  */
  cursorRgn = NewRgn ();
  cursorRgn = NewRgn ();
  /* Go into the main event-handling loop.  */
  /* Go into the main event-handling loop.  */
  while (!eventloopdone)
  while (!eventloopdone)
    {
    {
      /* Use WaitNextEvent if it is available, otherwise GetNextEvent.  */
      /* Use WaitNextEvent if it is available, otherwise GetNextEvent.  */
      if (use_wne)
      if (use_wne)
        {
        {
          get_global_mouse (&mouse);
          get_global_mouse (&mouse);
          adjust_cursor (mouse, cursorRgn);
          adjust_cursor (mouse, cursorRgn);
          tm = GetCaretTime ();
          tm = GetCaretTime ();
          gotevent = WaitNextEvent (everyEvent, &event, tm, cursorRgn);
          gotevent = WaitNextEvent (everyEvent, &event, tm, cursorRgn);
        }
        }
      else
      else
        {
        {
          SystemTask ();
          SystemTask ();
          gotevent = GetNextEvent (everyEvent, &event);
          gotevent = GetNextEvent (everyEvent, &event);
        }
        }
      /* First decide if the event is for a dialog or is just any old event. */
      /* First decide if the event is for a dialog or is just any old event. */
      if (FrontWindow () != nil && IsDialogEvent (&event))
      if (FrontWindow () != nil && IsDialogEvent (&event))
        {
        {
          short itemhit;
          short itemhit;
          DialogPtr dialog;
          DialogPtr dialog;
 
 
          /* Handle all the modeless dialogs here. */
          /* Handle all the modeless dialogs here. */
          if (DialogSelect (&event, &dialog, &itemhit))
          if (DialogSelect (&event, &dialog, &itemhit))
            {
            {
            }
            }
        }
        }
      else if (gotevent)
      else if (gotevent)
        {
        {
          /* Make sure we have the right cursor before handling the event. */
          /* Make sure we have the right cursor before handling the event. */
          adjust_cursor (event.where, cursorRgn);
          adjust_cursor (event.where, cursorRgn);
          do_event (&event);
          do_event (&event);
        }
        }
      else
      else
        {
        {
          do_idle ();
          do_idle ();
        }
        }
    }
    }
}
}
 
 
/* Collect the global coordinates of the mouse pointer.  */
/* Collect the global coordinates of the mouse pointer.  */
 
 
get_global_mouse (mouse)
get_global_mouse (mouse)
     Point *mouse;
     Point *mouse;
{
{
  EventRecord evt;
  EventRecord evt;
 
 
  OSEventAvail (0, &evt);
  OSEventAvail (0, &evt);
  *mouse = evt.where;
  *mouse = evt.where;
}
}
 
 
/* Change the cursor's appearance to be appropriate for the given mouse
/* Change the cursor's appearance to be appropriate for the given mouse
   location.  */
   location.  */
 
 
adjust_cursor (mouse, region)
adjust_cursor (mouse, region)
     Point mouse;
     Point mouse;
     RgnHandle region;
     RgnHandle region;
{
{
}
}
 
 
/* Decipher an event, maybe do something with it.  */
/* Decipher an event, maybe do something with it.  */
 
 
do_event (evt)
do_event (evt)
     EventRecord *evt;
     EventRecord *evt;
{
{
  short part, err, rslt = 0;
  short part, err, rslt = 0;
  WindowPtr win;
  WindowPtr win;
  Boolean hit;
  Boolean hit;
  char key;
  char key;
  Point pnt;
  Point pnt;
 
 
  switch (evt->what)
  switch (evt->what)
    {
    {
    case mouseDown:
    case mouseDown:
      /* See if the click happened in a special part of the screen. */
      /* See if the click happened in a special part of the screen. */
      part = FindWindow (evt->where, &win);
      part = FindWindow (evt->where, &win);
      switch (part)
      switch (part)
        {
        {
        case inMenuBar:
        case inMenuBar:
          adjust_menus ();
          adjust_menus ();
          do_menu_command (MenuSelect (evt->where));
          do_menu_command (MenuSelect (evt->where));
          break;
          break;
        case inSysWindow:
        case inSysWindow:
          SystemClick (evt, win);
          SystemClick (evt, win);
          break;
          break;
        case inContent:
        case inContent:
          if (win != FrontWindow ())
          if (win != FrontWindow ())
            {
            {
              /* Bring the clicked-on window to the front. */
              /* Bring the clicked-on window to the front. */
              SelectWindow (win);
              SelectWindow (win);
              /* Fix the menu to match the new front window. */
              /* Fix the menu to match the new front window. */
              adjust_menus ();
              adjust_menus ();
              /* We always want to discard the event now, since clicks in a
              /* We always want to discard the event now, since clicks in a
                 windows are often irreversible actions. */
                 windows are often irreversible actions. */
            }
            }
          else
          else
            /* Mouse clicks in the front window do something useful. */
            /* Mouse clicks in the front window do something useful. */
            do_mouse_down (win, evt);
            do_mouse_down (win, evt);
          break;
          break;
        case inDrag:
        case inDrag:
          /* Standard drag behavior, no tricks necessary. */
          /* Standard drag behavior, no tricks necessary. */
          DragWindow (win, evt->where, &dragrect);
          DragWindow (win, evt->where, &dragrect);
          break;
          break;
        case inGrow:
        case inGrow:
          grow_window (win, evt->where);
          grow_window (win, evt->where);
          break;
          break;
        case inZoomIn:
        case inZoomIn:
        case inZoomOut:
        case inZoomOut:
          zoom_window (win, evt->where, part);
          zoom_window (win, evt->where, part);
          break;
          break;
        case inGoAway:
        case inGoAway:
          close_window (win);
          close_window (win);
          break;
          break;
        }
        }
      break;
      break;
    case keyDown:
    case keyDown:
    case autoKey:
    case autoKey:
      key = evt->message & charCodeMask;
      key = evt->message & charCodeMask;
      /* Check for menukey equivalents. */
      /* Check for menukey equivalents. */
      if (evt->modifiers & cmdKey)
      if (evt->modifiers & cmdKey)
        {
        {
          if (evt->what == keyDown)
          if (evt->what == keyDown)
            {
            {
              adjust_menus ();
              adjust_menus ();
              do_menu_command (MenuKey (key));
              do_menu_command (MenuKey (key));
            }
            }
        }
        }
      else
      else
        {
        {
          if (evt->what == keyDown)
          if (evt->what == keyDown)
            {
            {
              /* Random keypress, interpret it. */
              /* Random keypress, interpret it. */
              do_keyboard_command (key);
              do_keyboard_command (key);
            }
            }
        }
        }
      break;
      break;
    case activateEvt:
    case activateEvt:
      activate_window ((WindowPtr) evt->message, evt->modifiers & activeFlag);
      activate_window ((WindowPtr) evt->message, evt->modifiers & activeFlag);
      break;
      break;
    case updateEvt:
    case updateEvt:
      update_window ((WindowPtr) evt->message);
      update_window ((WindowPtr) evt->message);
      break;
      break;
    case diskEvt:
    case diskEvt:
      /* Call DIBadMount in response to a diskEvt, so that the user can format
      /* Call DIBadMount in response to a diskEvt, so that the user can format
         a floppy. (from DTS Sample) */
         a floppy. (from DTS Sample) */
      if (HiWord (evt->message) != noErr)
      if (HiWord (evt->message) != noErr)
        {
        {
          SetPt (&pnt, 50, 50);
          SetPt (&pnt, 50, 50);
          err = DIBadMount (pnt, evt->message);
          err = DIBadMount (pnt, evt->message);
        }
        }
      break;
      break;
    case app4Evt:
    case app4Evt:
      /* Grab only a single byte. */
      /* Grab only a single byte. */
      switch ((evt->message >> 24) & 0xFF)
      switch ((evt->message >> 24) & 0xFF)
        {
        {
        case 0xfa:
        case 0xfa:
          break;
          break;
        case 1:
        case 1:
          inbackground = !(evt->message & 1);
          inbackground = !(evt->message & 1);
          activate_window (FrontWindow (), !inbackground);
          activate_window (FrontWindow (), !inbackground);
          break;
          break;
        }
        }
      break;
      break;
    case kHighLevelEvent:
    case kHighLevelEvent:
      AEProcessAppleEvent (evt);
      AEProcessAppleEvent (evt);
      break;
      break;
    case nullEvent:
    case nullEvent:
      do_idle ();
      do_idle ();
      rslt = 1;
      rslt = 1;
      break;
      break;
    default:
    default:
      break;
      break;
    }
    }
  return rslt;
  return rslt;
}
}
 
 
/* Do any idle-time activities. */
/* Do any idle-time activities. */
 
 
do_idle ()
do_idle ()
{
{
  TEIdle (console_text);
  TEIdle (console_text);
}
}
 
 
grow_window (win, where)
grow_window (win, where)
     WindowPtr win;
     WindowPtr win;
     Point where;
     Point where;
{
{
  long winsize;
  long winsize;
  int h, v;
  int h, v;
  GrafPtr oldport;
  GrafPtr oldport;
 
 
  winsize = GrowWindow (win, where, &sizerect);
  winsize = GrowWindow (win, where, &sizerect);
  /* Only do anything if it actually changed size. */
  /* Only do anything if it actually changed size. */
  if (winsize != 0)
  if (winsize != 0)
    {
    {
      GetPort (&oldport);
      GetPort (&oldport);
      SetPort (win);
      SetPort (win);
      if (win == console_window)
      if (win == console_window)
        {
        {
          EraseRect (&win->portRect);
          EraseRect (&win->portRect);
          h = LoWord (winsize);
          h = LoWord (winsize);
          v = HiWord (winsize);
          v = HiWord (winsize);
          SizeWindow (win, h, v, 1);
          SizeWindow (win, h, v, 1);
          resize_console_window ();
          resize_console_window ();
        }
        }
      SetPort (oldport);
      SetPort (oldport);
    }
    }
}
}
 
 
zoom_window (win, where, part)
zoom_window (win, where, part)
     WindowPtr win;
     WindowPtr win;
     Point where;
     Point where;
     short part;
     short part;
{
{
  ZoomWindow (win, part, (win == FrontWindow ()));
  ZoomWindow (win, part, (win == FrontWindow ()));
  if (win == console_window)
  if (win == console_window)
    {
    {
      resize_console_window ();
      resize_console_window ();
    }
    }
}
}
 
 
resize_console_window ()
resize_console_window ()
{
{
  adjust_console_sizes ();
  adjust_console_sizes ();
  adjust_console_scrollbars ();
  adjust_console_scrollbars ();
  adjust_console_text ();
  adjust_console_text ();
  InvalRect (&console_window->portRect);
  InvalRect (&console_window->portRect);
}
}
 
 
close_window (win)
close_window (win)
     WindowPtr win;
     WindowPtr win;
{
{
}
}
 
 
pascal void
pascal void
v_scroll_proc (ControlHandle control, short part)
v_scroll_proc (ControlHandle control, short part)
{
{
  int oldval, amount = 0, newval;
  int oldval, amount = 0, newval;
  int pagesize = ((*console_text)->viewRect.bottom - (*console_text)->viewRect.top) / (*console_text)->lineHeight;
  int pagesize = ((*console_text)->viewRect.bottom - (*console_text)->viewRect.top) / (*console_text)->lineHeight;
  if (part)
  if (part)
    {
    {
      oldval = GetCtlValue (control);
      oldval = GetCtlValue (control);
      switch (part)
      switch (part)
        {
        {
        case inUpButton:
        case inUpButton:
          amount = 1;
          amount = 1;
          break;
          break;
        case inDownButton:
        case inDownButton:
          amount = -1;
          amount = -1;
          break;
          break;
        case inPageUp:
        case inPageUp:
          amount = pagesize;
          amount = pagesize;
          break;
          break;
        case inPageDown:
        case inPageDown:
          amount = -pagesize;
          amount = -pagesize;
          break;
          break;
        default:
        default:
          /* (should freak out) */
          /* (should freak out) */
          break;
          break;
        }
        }
      SetCtlValue (control, oldval - amount);
      SetCtlValue (control, oldval - amount);
      newval = GetCtlValue (control);
      newval = GetCtlValue (control);
      amount = oldval - newval;
      amount = oldval - newval;
      if (amount)
      if (amount)
        TEScroll (0, amount * (*console_text)->lineHeight, console_text);
        TEScroll (0, amount * (*console_text)->lineHeight, console_text);
    }
    }
}
}
 
 
do_mouse_down (WindowPtr win, EventRecord * event)
do_mouse_down (WindowPtr win, EventRecord * event)
{
{
  short part, value;
  short part, value;
  Point mouse;
  Point mouse;
  ControlHandle control;
  ControlHandle control;
 
 
  if (1 /*is_app_window(win) */ )
  if (1 /*is_app_window(win) */ )
    {
    {
      SetPort (win);
      SetPort (win);
      mouse = event->where;
      mouse = event->where;
      GlobalToLocal (&mouse);
      GlobalToLocal (&mouse);
      part = FindControl (mouse, win, &control);
      part = FindControl (mouse, win, &control);
      if (control == console_v_scrollbar)
      if (control == console_v_scrollbar)
        {
        {
          switch (part)
          switch (part)
            {
            {
            case inThumb:
            case inThumb:
              value = GetCtlValue (control);
              value = GetCtlValue (control);
              part = TrackControl (control, mouse, nil);
              part = TrackControl (control, mouse, nil);
              if (part)
              if (part)
                {
                {
                  value -= GetCtlValue (control);
                  value -= GetCtlValue (control);
                  if (value)
                  if (value)
                    TEScroll (0, value * (*console_text)->lineHeight,
                    TEScroll (0, value * (*console_text)->lineHeight,
                              console_text);
                              console_text);
                }
                }
              break;
              break;
            default:
            default:
#if 0                           /* don't deal with right now */
#if 0                           /* don't deal with right now */
#if 1                           /* universal headers */
#if 1                           /* universal headers */
              value = TrackControl (control, mouse, (ControlActionUPP) v_scroll_proc);
              value = TrackControl (control, mouse, (ControlActionUPP) v_scroll_proc);
#else
#else
              value = TrackControl (control, mouse, (ProcPtr) v_scroll_proc);
              value = TrackControl (control, mouse, (ProcPtr) v_scroll_proc);
#endif
#endif
#endif
#endif
              break;
              break;
            }
            }
        }
        }
      else
      else
        {
        {
          TEClick (mouse, 0, console_text);
          TEClick (mouse, 0, console_text);
        }
        }
    }
    }
}
}
 
 
scroll_text (hlines, vlines)
scroll_text (hlines, vlines)
     int hlines, vlines;
     int hlines, vlines;
{
{
}
}
 
 
activate_window (win, activate)
activate_window (win, activate)
     WindowPtr win;
     WindowPtr win;
     int activate;
     int activate;
{
{
  Rect grow_rect;
  Rect grow_rect;
 
 
  if (win == nil)
  if (win == nil)
    return;
    return;
  /* It's convenient to make the activated window also be the
  /* It's convenient to make the activated window also be the
     current GrafPort. */
     current GrafPort. */
  if (activate)
  if (activate)
    SetPort (win);
    SetPort (win);
  /* Activate the console window's scrollbar. */
  /* Activate the console window's scrollbar. */
  if (win == console_window)
  if (win == console_window)
    {
    {
      if (activate)
      if (activate)
        {
        {
          TEActivate (console_text);
          TEActivate (console_text);
          /* Cause the grow icon to be redrawn at the next update. */
          /* Cause the grow icon to be redrawn at the next update. */
          grow_rect = console_window->portRect;
          grow_rect = console_window->portRect;
          grow_rect.top = grow_rect.bottom - sbarwid;
          grow_rect.top = grow_rect.bottom - sbarwid;
          grow_rect.left = grow_rect.right - sbarwid;
          grow_rect.left = grow_rect.right - sbarwid;
          InvalRect (&grow_rect);
          InvalRect (&grow_rect);
        }
        }
      else
      else
        {
        {
          TEDeactivate (console_text);
          TEDeactivate (console_text);
          DrawGrowIcon (console_window);
          DrawGrowIcon (console_window);
        }
        }
      HiliteControl (console_v_scrollbar, (activate ? 0 : 255));
      HiliteControl (console_v_scrollbar, (activate ? 0 : 255));
    }
    }
}
}
 
 
update_window (win)
update_window (win)
     WindowPtr win;
     WindowPtr win;
{
{
  int controls = 1, growbox = 0;
  int controls = 1, growbox = 0;
  GrafPtr oldport;
  GrafPtr oldport;
 
 
  /* Set the updating window to be the current grafport. */
  /* Set the updating window to be the current grafport. */
  GetPort (&oldport);
  GetPort (&oldport);
  SetPort (win);
  SetPort (win);
/*  recalc_depths();  */
/*  recalc_depths();  */
  BeginUpdate (win);
  BeginUpdate (win);
  if (win == console_window)
  if (win == console_window)
    {
    {
      draw_console ();
      draw_console ();
      controls = 1;
      controls = 1;
      growbox = 1;
      growbox = 1;
    }
    }
  if (controls)
  if (controls)
    UpdateControls (win, win->visRgn);
    UpdateControls (win, win->visRgn);
  if (growbox)
  if (growbox)
    DrawGrowIcon (win);
    DrawGrowIcon (win);
  EndUpdate (win);
  EndUpdate (win);
  SetPort (oldport);
  SetPort (oldport);
}
}
 
 
adjust_menus ()
adjust_menus ()
{
{
}
}
 
 
do_menu_command (which)
do_menu_command (which)
     long which;
     long which;
{
{
  short menuid, menuitem;
  short menuid, menuitem;
  short itemHit;
  short itemHit;
  Str255 daname;
  Str255 daname;
  short daRefNum;
  short daRefNum;
  Boolean handledbyda;
  Boolean handledbyda;
  WindowPtr win;
  WindowPtr win;
  short ditem;
  short ditem;
  int i;
  int i;
  char cmdbuf[300];
  char cmdbuf[300];
 
 
  cmdbuf[0] = '\0';
  cmdbuf[0] = '\0';
  menuid = HiWord (which);
  menuid = HiWord (which);
  menuitem = LoWord (which);
  menuitem = LoWord (which);
  switch (menuid)
  switch (menuid)
    {
    {
    case mApple:
    case mApple:
      switch (menuitem)
      switch (menuitem)
        {
        {
        case miAbout:
        case miAbout:
          Alert (128, nil);
          Alert (128, nil);
          break;
          break;
#if 0
#if 0
        case miHelp:
        case miHelp:
          /* (should pop up help info) */
          /* (should pop up help info) */
          break;
          break;
#endif
#endif
        default:
        default:
          GetItem (GetMHandle (mApple), menuitem, daname);
          GetItem (GetMHandle (mApple), menuitem, daname);
          daRefNum = OpenDeskAcc (daname);
          daRefNum = OpenDeskAcc (daname);
        }
        }
      break;
      break;
    case mFile:
    case mFile:
      switch (menuitem)
      switch (menuitem)
        {
        {
        case miFileNew:
        case miFileNew:
          if (console_window == FrontWindow ())
          if (console_window == FrontWindow ())
            {
            {
              close_window (console_window);
              close_window (console_window);
            }
            }
          new_console_window ();
          new_console_window ();
          break;
          break;
        case miFileOpen:
        case miFileOpen:
          SysBeep (20);
          SysBeep (20);
          break;
          break;
        case miFileQuit:
        case miFileQuit:
          ExitToShell ();
          ExitToShell ();
          break;
          break;
        }
        }
      break;
      break;
    case mEdit:
    case mEdit:
      /* handledbyda = SystemEdit(menuitem-1); */
      /* handledbyda = SystemEdit(menuitem-1); */
      switch (menuitem)
      switch (menuitem)
        {
        {
        case miEditCut:
        case miEditCut:
          TECut (console_text);
          TECut (console_text);
          break;
          break;
        case miEditCopy:
        case miEditCopy:
          TECopy (console_text);
          TECopy (console_text);
          break;
          break;
        case miEditPaste:
        case miEditPaste:
          TEPaste (console_text);
          TEPaste (console_text);
          break;
          break;
        case miEditClear:
        case miEditClear:
          TEDelete (console_text);
          TEDelete (console_text);
          break;
          break;
        }
        }
      /* All of these operations need the same postprocessing. */
      /* All of these operations need the same postprocessing. */
      adjust_console_sizes ();
      adjust_console_sizes ();
      adjust_console_scrollbars ();
      adjust_console_scrollbars ();
      adjust_console_text ();
      adjust_console_text ();
      break;
      break;
    case mDebug:
    case mDebug:
      switch (menuitem)
      switch (menuitem)
        {
        {
        case miDebugTarget:
        case miDebugTarget:
          sprintf (cmdbuf, "target %s", "remote");
          sprintf (cmdbuf, "target %s", "remote");
          break;
          break;
        case miDebugRun:
        case miDebugRun:
          sprintf (cmdbuf, "run");
          sprintf (cmdbuf, "run");
          break;
          break;
        case miDebugContinue:
        case miDebugContinue:
          sprintf (cmdbuf, "continue");
          sprintf (cmdbuf, "continue");
          break;
          break;
        case miDebugStep:
        case miDebugStep:
          sprintf (cmdbuf, "step");
          sprintf (cmdbuf, "step");
          break;
          break;
        case miDebugNext:
        case miDebugNext:
          sprintf (cmdbuf, "next");
          sprintf (cmdbuf, "next");
          break;
          break;
        }
        }
      break;
      break;
    }
    }
  HiliteMenu (0);
  HiliteMenu (0);
  /* Execute a command if one had been given.  Do here because a command
  /* Execute a command if one had been given.  Do here because a command
     may longjmp before we get a chance to unhilite the menu. */
     may longjmp before we get a chance to unhilite the menu. */
  if (strlen (cmdbuf) > 0)
  if (strlen (cmdbuf) > 0)
    execute_command (cmdbuf, 0);
    execute_command (cmdbuf, 0);
}
}
 
 
char commandbuf[1000];
char commandbuf[1000];
 
 
do_keyboard_command (key)
do_keyboard_command (key)
     int key;
     int key;
{
{
  int startpos, endpos, i, len;
  int startpos, endpos, i, len;
  char *last_newline;
  char *last_newline;
  char buf[10], *text_str, *command, *cmd_start;
  char buf[10], *text_str, *command, *cmd_start;
  CharsHandle text;
  CharsHandle text;
 
 
  if (key == '\015' || key == '\003')
  if (key == '\015' || key == '\003')
    {
    {
      text = TEGetText (console_text);
      text = TEGetText (console_text);
      HLock ((Handle) text);
      HLock ((Handle) text);
      text_str = *text;
      text_str = *text;
      startpos = (*console_text)->selStart;
      startpos = (*console_text)->selStart;
      endpos = (*console_text)->selEnd;
      endpos = (*console_text)->selEnd;
      if (startpos != endpos)
      if (startpos != endpos)
        {
        {
          len = endpos - startpos;
          len = endpos - startpos;
          cmd_start = text_str + startpos;
          cmd_start = text_str + startpos;
        }
        }
      else
      else
        {
        {
          for (i = startpos - 1; i >= 0; --i)
          for (i = startpos - 1; i >= 0; --i)
            if (text_str[i] == '\015')
            if (text_str[i] == '\015')
              break;
              break;
          last_newline = text_str + i;
          last_newline = text_str + i;
          len = (text_str + startpos) - 1 - last_newline;
          len = (text_str + startpos) - 1 - last_newline;
          cmd_start = last_newline + 1;
          cmd_start = last_newline + 1;
        }
        }
      if (len > 1000)
      if (len > 1000)
        len = 999;
        len = 999;
      if (len < 0)
      if (len < 0)
        len = 0;
        len = 0;
      strncpy (commandbuf + 1, cmd_start, len);
      strncpy (commandbuf + 1, cmd_start, len);
      commandbuf[1 + len] = 0;
      commandbuf[1 + len] = 0;
      command = commandbuf + 1;
      command = commandbuf + 1;
      HUnlock ((Handle) text);
      HUnlock ((Handle) text);
      commandbuf[0] = strlen (command);
      commandbuf[0] = strlen (command);
 
 
      /* Insert a newline and recalculate before doing any command. */
      /* Insert a newline and recalculate before doing any command. */
      key = '\015';
      key = '\015';
      TEKey (key, console_text);
      TEKey (key, console_text);
      TEInsert (buf, 1, console_text);
      TEInsert (buf, 1, console_text);
      adjust_console_sizes ();
      adjust_console_sizes ();
      adjust_console_scrollbars ();
      adjust_console_scrollbars ();
      adjust_console_text ();
      adjust_console_text ();
 
 
      if (strlen (command) > 0)
      if (strlen (command) > 0)
        {
        {
          execute_command (command, 0);
          execute_command (command, 0);
          bpstat_do_actions (&stop_bpstat);
          bpstat_do_actions (&stop_bpstat);
        }
        }
    }
    }
  else
  else
    {
    {
      /* A self-inserting character.  This includes delete.  */
      /* A self-inserting character.  This includes delete.  */
      TEKey (key, console_text);
      TEKey (key, console_text);
    }
    }
}
}
 
 
/* Draw all graphical stuff in the console window.  */
/* Draw all graphical stuff in the console window.  */
 
 
draw_console ()
draw_console ()
{
{
  SetPort (console_window);
  SetPort (console_window);
  TEUpdate (&(console_window->portRect), console_text);
  TEUpdate (&(console_window->portRect), console_text);
}
}
 
 
/* Cause an update of a given window's entire contents.  */
/* Cause an update of a given window's entire contents.  */
 
 
force_update (win)
force_update (win)
     WindowPtr win;
     WindowPtr win;
{
{
  GrafPtr oldport;
  GrafPtr oldport;
 
 
  if (win == nil)
  if (win == nil)
    return;
    return;
  GetPort (&oldport);
  GetPort (&oldport);
  SetPort (win);
  SetPort (win);
  EraseRect (&win->portRect);
  EraseRect (&win->portRect);
  InvalRect (&win->portRect);
  InvalRect (&win->portRect);
  SetPort (oldport);
  SetPort (oldport);
}
}
 
 
adjust_console_sizes ()
adjust_console_sizes ()
{
{
  Rect tmprect;
  Rect tmprect;
 
 
  tmprect = console_window->portRect;
  tmprect = console_window->portRect;
  /* Move and size the scrollbar. */
  /* Move and size the scrollbar. */
  MoveControl (console_v_scrollbar, tmprect.right - sbarwid, 0);
  MoveControl (console_v_scrollbar, tmprect.right - sbarwid, 0);
  SizeControl (console_v_scrollbar, sbarwid + 1, tmprect.bottom - sbarwid + 1);
  SizeControl (console_v_scrollbar, sbarwid + 1, tmprect.bottom - sbarwid + 1);
  /* Move and size the text. */
  /* Move and size the text. */
  tmprect.left += 7;
  tmprect.left += 7;
  tmprect.right -= sbarwid;
  tmprect.right -= sbarwid;
  tmprect.bottom -= sbarwid;
  tmprect.bottom -= sbarwid;
  InsetRect (&tmprect, 1, 1);
  InsetRect (&tmprect, 1, 1);
  (*console_text)->destRect = tmprect;
  (*console_text)->destRect = tmprect;
  /* Fiddle bottom of viewrect to be even multiple of text lines. */
  /* Fiddle bottom of viewrect to be even multiple of text lines. */
  tmprect.bottom = tmprect.top
  tmprect.bottom = tmprect.top
    + ((tmprect.bottom - tmprect.top) / (*console_text)->lineHeight)
    + ((tmprect.bottom - tmprect.top) / (*console_text)->lineHeight)
    * (*console_text)->lineHeight;
    * (*console_text)->lineHeight;
  (*console_text)->viewRect = tmprect;
  (*console_text)->viewRect = tmprect;
}
}
 
 
adjust_console_scrollbars ()
adjust_console_scrollbars ()
{
{
  int lines, newmax, value;
  int lines, newmax, value;
 
 
  (*console_v_scrollbar)->contrlVis = 0;
  (*console_v_scrollbar)->contrlVis = 0;
  lines = (*console_text)->nLines;
  lines = (*console_text)->nLines;
  newmax = lines - (((*console_text)->viewRect.bottom
  newmax = lines - (((*console_text)->viewRect.bottom
                     - (*console_text)->viewRect.top)
                     - (*console_text)->viewRect.top)
                    / (*console_text)->lineHeight);
                    / (*console_text)->lineHeight);
  if (newmax < 0)
  if (newmax < 0)
    newmax = 0;
    newmax = 0;
  SetCtlMax (console_v_scrollbar, newmax);
  SetCtlMax (console_v_scrollbar, newmax);
  value = ((*console_text)->viewRect.top - (*console_text)->destRect.top)
  value = ((*console_text)->viewRect.top - (*console_text)->destRect.top)
    / (*console_text)->lineHeight;
    / (*console_text)->lineHeight;
  SetCtlValue (console_v_scrollbar, value);
  SetCtlValue (console_v_scrollbar, value);
  (*console_v_scrollbar)->contrlVis = 0xff;
  (*console_v_scrollbar)->contrlVis = 0xff;
  ShowControl (console_v_scrollbar);
  ShowControl (console_v_scrollbar);
}
}
 
 
/* Scroll the TE record so that it is consistent with the scrollbar(s). */
/* Scroll the TE record so that it is consistent with the scrollbar(s). */
 
 
adjust_console_text ()
adjust_console_text ()
{
{
  TEScroll (((*console_text)->viewRect.left
  TEScroll (((*console_text)->viewRect.left
             - (*console_text)->destRect.left)
             - (*console_text)->destRect.left)
            - 0 /* get h scroll value */ ,
            - 0 /* get h scroll value */ ,
            ((((*console_text)->viewRect.top - (*console_text)->destRect.top)
            ((((*console_text)->viewRect.top - (*console_text)->destRect.top)
              / (*console_text)->lineHeight)
              / (*console_text)->lineHeight)
             - GetCtlValue (console_v_scrollbar))
             - GetCtlValue (console_v_scrollbar))
            * (*console_text)->lineHeight,
            * (*console_text)->lineHeight,
            console_text);
            console_text);
}
}
 
 
/* Readline substitute. */
/* Readline substitute. */
 
 
char *
char *
readline (char *prrompt)
readline (char *prrompt)
{
{
  return gdb_readline (prrompt);
  return gdb_readline (prrompt);
}
}
 
 
char *rl_completer_word_break_characters;
char *rl_completer_word_break_characters;
 
 
char *rl_completer_quote_characters;
char *rl_completer_quote_characters;
 
 
int (*rl_completion_entry_function) ();
int (*rl_completion_entry_function) ();
 
 
int rl_point;
int rl_point;
 
 
char *rl_line_buffer;
char *rl_line_buffer;
 
 
char *rl_readline_name;
char *rl_readline_name;
 
 
/* History substitute. */
/* History substitute. */
 
 
void
void
add_history (char *buf)
add_history (char *buf)
{
{
}
}
 
 
void
void
stifle_history (int n)
stifle_history (int n)
{
{
}
}
 
 
int
int
unstifle_history ()
unstifle_history ()
{
{
}
}
 
 
int
int
read_history (char *name)
read_history (char *name)
{
{
}
}
 
 
int
int
write_history (char *name)
write_history (char *name)
{
{
}
}
 
 
int
int
history_expand (char *x, char **y)
history_expand (char *x, char **y)
{
{
}
}
 
 
extern HIST_ENTRY *
extern HIST_ENTRY *
history_get (int xxx)
history_get (int xxx)
{
{
  return NULL;
  return NULL;
}
}
 
 
int history_base;
int history_base;
 
 
char *
char *
filename_completion_function (char *text, char *name)
filename_completion_function (char *text, char *name)
{
{
  return "?";
  return "?";
}
}
 
 
char *
char *
tilde_expand (char *str)
tilde_expand (char *str)
{
{
  return strsave (str);
  return strsave (str);
}
}
 
 
/* Modified versions of standard I/O. */
/* Modified versions of standard I/O. */
 
 
#undef fprintf
#undef fprintf
 
 
int
int
hacked_fprintf (FILE * fp, const char *fmt,...)
hacked_fprintf (FILE * fp, const char *fmt,...)
{
{
  int ret;
  int ret;
  va_list ap;
  va_list ap;
 
 
  va_start (ap, fmt);
  va_start (ap, fmt);
  if (mac_app && (fp == stdout || fp == stderr))
  if (mac_app && (fp == stdout || fp == stderr))
    {
    {
      char buf[1000];
      char buf[1000];
 
 
      ret = vsprintf (buf, fmt, ap);
      ret = vsprintf (buf, fmt, ap);
      TEInsert (buf, strlen (buf), console_text);
      TEInsert (buf, strlen (buf), console_text);
    }
    }
  else
  else
    ret = vfprintf (fp, fmt, ap);
    ret = vfprintf (fp, fmt, ap);
  va_end (ap);
  va_end (ap);
  return ret;
  return ret;
}
}
 
 
#undef printf
#undef printf
 
 
int
int
hacked_printf (const char *fmt,...)
hacked_printf (const char *fmt,...)
{
{
  int ret;
  int ret;
  va_list ap;
  va_list ap;
 
 
  va_start (ap, fmt);
  va_start (ap, fmt);
  ret = hacked_vfprintf (stdout, fmt, ap);
  ret = hacked_vfprintf (stdout, fmt, ap);
  va_end (ap);
  va_end (ap);
  return ret;
  return ret;
}
}
 
 
#undef vfprintf
#undef vfprintf
 
 
int
int
hacked_vfprintf (FILE * fp, const char *format, va_list args)
hacked_vfprintf (FILE * fp, const char *format, va_list args)
{
{
  if (mac_app && (fp == stdout || fp == stderr))
  if (mac_app && (fp == stdout || fp == stderr))
    {
    {
      char buf[1000];
      char buf[1000];
      int ret;
      int ret;
 
 
      ret = vsprintf (buf, format, args);
      ret = vsprintf (buf, format, args);
      TEInsert (buf, strlen (buf), console_text);
      TEInsert (buf, strlen (buf), console_text);
      if (strchr (buf, '\n'))
      if (strchr (buf, '\n'))
        {
        {
          adjust_console_sizes ();
          adjust_console_sizes ();
          adjust_console_scrollbars ();
          adjust_console_scrollbars ();
          adjust_console_text ();
          adjust_console_text ();
        }
        }
      return ret;
      return ret;
    }
    }
  else
  else
    return vfprintf (fp, format, args);
    return vfprintf (fp, format, args);
}
}
 
 
#undef fputs
#undef fputs
 
 
hacked_fputs (const char *s, FILE * fp)
hacked_fputs (const char *s, FILE * fp)
{
{
  if (mac_app && (fp == stdout || fp == stderr))
  if (mac_app && (fp == stdout || fp == stderr))
    {
    {
      TEInsert (s, strlen (s), console_text);
      TEInsert (s, strlen (s), console_text);
      if (strchr (s, '\n'))
      if (strchr (s, '\n'))
        {
        {
          adjust_console_sizes ();
          adjust_console_sizes ();
          adjust_console_scrollbars ();
          adjust_console_scrollbars ();
          adjust_console_text ();
          adjust_console_text ();
        }
        }
      return 0;
      return 0;
    }
    }
  else
  else
    return fputs (s, fp);
    return fputs (s, fp);
}
}
 
 
#undef fputc
#undef fputc
 
 
hacked_fputc (const char c, FILE * fp)
hacked_fputc (const char c, FILE * fp)
{
{
  if (mac_app && (fp == stdout || fp == stderr))
  if (mac_app && (fp == stdout || fp == stderr))
    {
    {
      char buf[1];
      char buf[1];
 
 
      buf[0] = c;
      buf[0] = c;
      TEInsert (buf, 1, console_text);
      TEInsert (buf, 1, console_text);
      if (c == '\n')
      if (c == '\n')
        {
        {
          adjust_console_sizes ();
          adjust_console_sizes ();
          adjust_console_scrollbars ();
          adjust_console_scrollbars ();
          adjust_console_text ();
          adjust_console_text ();
        }
        }
      return c;
      return c;
    }
    }
  else
  else
    return fputc (c, fp);
    return fputc (c, fp);
}
}
 
 
#undef putc
#undef putc
 
 
hacked_putc (const char c, FILE * fp)
hacked_putc (const char c, FILE * fp)
{
{
  if (mac_app && (fp == stdout || fp == stderr))
  if (mac_app && (fp == stdout || fp == stderr))
    {
    {
      char buf[1];
      char buf[1];
 
 
      buf[0] = c;
      buf[0] = c;
      TEInsert (buf, 1, console_text);
      TEInsert (buf, 1, console_text);
      if (c == '\n')
      if (c == '\n')
        {
        {
          adjust_console_sizes ();
          adjust_console_sizes ();
          adjust_console_scrollbars ();
          adjust_console_scrollbars ();
          adjust_console_text ();
          adjust_console_text ();
        }
        }
      return c;
      return c;
    }
    }
  else
  else
    return fputc (c, fp);
    return fputc (c, fp);
}
}
 
 
#undef fflush
#undef fflush
 
 
hacked_fflush (FILE * fp)
hacked_fflush (FILE * fp)
{
{
  if (mac_app && (fp == stdout || fp == stderr))
  if (mac_app && (fp == stdout || fp == stderr))
    {
    {
      adjust_console_sizes ();
      adjust_console_sizes ();
      adjust_console_scrollbars ();
      adjust_console_scrollbars ();
      adjust_console_text ();
      adjust_console_text ();
      return 0;
      return 0;
    }
    }
  return fflush (fp);
  return fflush (fp);
}
}
 
 
#undef fgetc
#undef fgetc
 
 
hacked_fgetc (FILE * fp)
hacked_fgetc (FILE * fp)
{
{
  if (mac_app && (fp == stdin))
  if (mac_app && (fp == stdin))
    {
    {
      /* Catch any attempts to use this.  */
      /* Catch any attempts to use this.  */
      DebugStr ("\pShould not be reading from stdin!");
      DebugStr ("\pShould not be reading from stdin!");
      return '\n';
      return '\n';
    }
    }
  return fgetc (fp);
  return fgetc (fp);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.