예제 #1
0
void Vid_Init(int mode)
{
   OldScreenData.cb=ScreenData.cb=sizeof(ScreenData);
   VioGetMode(&OldScreenData,hvio);
   memcpy(&ScreenData,&OldScreenData,sizeof(ScreenData));
   switch (mode)
      {
      case TEXT_25:
         ScreenData.row=25;
         ScreenData.vres=400;
         break;
      case TEXT_30:
         ScreenData.row=30;
         ScreenData.vres=480;
         break;
      }
VioSetMode(&ScreenData,hvio);
VioGetMode(&ScreenData,hvio);
CELL_SIZE=ScreenData.buf_length / (ScreenData.row * ScreenData.col);
VioGetCurType(&Save,hvio);
mAcurs=&Ins[1];
Ins[0].yStart=0;
Ins[0].cEnd=ScreenData.vres/ScreenData.row;
Ins[0].cx=1;
Ins[1].yStart=ScreenData.vres/ScreenData.row-2;
Ins[1].cEnd=ScreenData.vres/ScreenData.row;
Ins[1].cx=1;
VioSetCurType(&Ins[1],hvio);
}
예제 #2
0
void Vid_Reset()
{
  StopTimeService();
  StopKeyBarService();
  VioSetMode(&OldScreenData,hvio);
  VioSetCurType(&Save,hvio);
}
예제 #3
0
파일: aaos2.c 프로젝트: JohnChu/Snoopy
void breakfunc(int signo) {
  BYTE bCell[2];
  
  bCell[0] = 0x20;
  bCell[1] = ( WM_BLACK << 4 ) + WM_PALEGRAY;
  
  VioScrollDn(TOP_ROW,LEFT_COL,0xFFFF,0xFFFF,0xFFFF,bCell,(HVIO) 0);
  VioSetMode(&oldMode, (HVIO) 0);
  VioSetCurPos(0, 0, (HVIO)0);
  VioSetCurType(&oldCurInfo, (HVIO)0);

  switch(signo) {
  case SIGINT:
    fprintf(stderr, "Interrupt (Ctrl-C)\n"); break;
  case SIGQUIT:
    fprintf(stderr, "Quit\n"); break;
  case SIGILL:
    fprintf(stderr, "Illegal instruction\n"); break;
  case SIGFPE:
    fprintf(stderr, "Floating point\n"); break;
  case SIGKILL:
    fprintf(stderr, "Kill process\n"); break;
  case SIGBUS:
    fprintf(stderr, "Bus error\n"); break;
  case SIGSEGV:
    fprintf(stderr, "Segmentation fault\n"); break;
  case SIGTERM:
    fprintf(stderr, "Termination, process killed\n"); break;
  case SIGBREAK:
    fprintf(stderr, "Break (Ctrl-Break)\n"); break;
  }
  exit(99);
}
void main(void)
{
   VIOCURSORINFO  CursorData;

   SHORT   start;
   SHORT   end;
   short   chr;

   VioGetCurType(&CursorData, (HVIO)0);
   start = CursorData.yStart;
   end = CursorData.cEnd;

   while(chr != 27)
   {
      chr = getch();
      if(chr == 'q') start--;
      if(chr == 'a') start++;
      if(chr == 'w') end--;
      if(chr == 's') end++;
      CursorData.yStart = start;
      CursorData.cEnd = end;
      VioSetCurType(&CursorData, (HVIO)0);
      if(chr == 13)
          cprintf("start: %d\n\r  end: %d\n\r", start, end);
   }
}
예제 #5
0
static void DrawCursor(int Show) {
  VIOCURSORINFO vci;

  VioGetCurType(&vci, 0);

  if (Show == 1) vci.attr = 1;
  else vci.attr = (SHORT)-1;
  VioSetCurType(&vci, 0);
}
예제 #6
0
static void vm_setcursorsize(char start, char end)
{
    VIOCURSORINFO vi;
    vi.yStart = start;
    vi.cEnd = end;
    vi.cx = 0;
    vi.attr = 0;
    VioSetCurType(&vi, 0);
}
void ShowCursor (BOOL hide) {

  VIOCURSORINFO viocurs;

  memset(&viocurs,0,sizeof(viocurs));
  VioGetCurType(&viocurs,0);
  viocurs.attr = (hide) ? -1 : 0;
  VioSetCurType(&viocurs,0);
}
예제 #8
0
int SLang_init_tty(int abort_char, int dum2, int dum3)
{
  VIOCURSORINFO cursorInfo, OldcursorInfo;

  (void) dum2; (void) dum3;
   if (abort_char == -1) abort_char = 3;   /* ^C */
   SLang_Abort_Char = abort_char;
   SLKeyBoard_Quit = 0;

  /*  set ^C off */
  signal (SIGINT, SIG_IGN);
  signal (SIGBREAK, SIG_IGN);

  /* set up the keyboard */

  initialKbdInfo.cb = sizeof(initialKbdInfo);
  KbdGetStatus(&initialKbdInfo, 0);
  set_kbd();

  /* open a semaphore */
  CreateSem();

  /* start a separate thread to read the keyboard */
#if defined(__BORLANDC__)
  SLos2_threadID = _beginthread (thread_code, 8096, NULL);
#else
  SLos2_threadID = _beginthread (thread_code, NULL,  8096, NULL);
#endif

   if ((int)SLos2_threadID == -1)
     {
	SLang_exit_error ("init_tty: Error starting keyboard thread.");
     }

  VioGetCurType (&OldcursorInfo, 0);
  cursorInfo.yStart = 1;
  cursorInfo.cEnd = 15;
  cursorInfo.cx = 1;
  cursorInfo.attr = 1;
  if (VioSetCurType (&cursorInfo, 0))
    VioSetCurType (&OldcursorInfo, 0);   /* reset to previous value */

  return 0;
}
예제 #9
0
int MLE_edit(PMLE pmle)
{
int K_TYPE;
int K_CODE;
int rc,i;
USHORT x,y;
   if (mAcurs !=&Ins[pmle->ins])
      {
      mAcurs =&Ins[pmle->ins];
      VioSetCurType(&Ins[pmle->ins],hvio);
      }


   rc=1;
   while (rc)
      {
      x=pmle->cursor % pmle->width;         // положение курсора
      y=pmle->cursor / pmle->width;         // в окне
      VioSetCurPos(pmle->luy+y,pmle->lux+x,hvio);

      Kbd_Wait();
      K_TYPE = Kbd_GetType();
      K_CODE = Kbd_GetCode();

      if (K_TYPE==KBD_ASCII)
         {
         if (EDO_allow((EDO *)pmle,K_CODE)!=FLG_YES && EDO_deny((EDO *)pmle,K_CODE)==FLG_YES)
            {
            DosBeep(500,50);
            continue;
            }
         else
            {
            K_CODE=EDO_filtr((EDO *)pmle,K_CODE);
            if (!K_CODE)
               {
               DosBeep(500,50);
               continue;
               }
            rc=MLE_edit_ascii(K_CODE,pmle);
            }
         }
      else
         if (K_CODE !=ESC)
            rc=MLE_edit_control(K_CODE,pmle);
         else
            rc=0;

      if (rc == 1)
         MLE_reload(pmle);
      else if (rc==-1)
         DosBeep(400,50);
      }
   return K_CODE;
}
예제 #10
0
파일: os2pm.c 프로젝트: OS2World/LIB-libfly
void set_cursor (int flag)
{
    static int cursor_attrib = 0;
    
    VioGetCurType (pci, hvps);
    
    if (flag == 0)
    {
        if (pci->attr == 0xFFFF) return;
        cursor_attrib = pci->attr;
        pci->attr = 0xFFFF;
        VioSetCurType (pci, hvps);
    }
    else
    {
        if (pci->attr != 0xFFFF) return;
        pci->attr = cursor_attrib;
        VioSetCurType (pci, hvps);
    }
}
예제 #11
0
static void hb_gt_os2_SetCursorSize( char start, char end, int visible )
{
   VIOCURSORINFO vi;

   HB_TRACE( HB_TR_DEBUG, ( "hb_gt_os2_SetCursorSize(%d, %d, %d)", ( int ) start, ( int ) end, visible ) );

   vi.yStart = start;
   vi.cEnd = end;
   vi.cx = 0;
   vi.attr = ( visible ? 0 : -1 );
   VioSetCurType( &vi, 0 );
}
예제 #12
0
파일: aaos2.c 프로젝트: JohnChu/Snoopy
static void os2vio_uninit(aa_context * c)
{
  BYTE bCell[2];
  
  bCell[0] = 0x20;
  bCell[1] = ( WM_BLACK << 4 ) + WM_PALEGRAY;
  
  VioScrollDn(TOP_ROW,LEFT_COL,0xFFFF,0xFFFF,0xFFFF,bCell,(HVIO) 0);
  VioSetMode(&oldMode, (HVIO) 0);
  VioSetCurPos(0, 0, (HVIO)0);
  VioSetCurType(&oldCurInfo, (HVIO)0);
}
예제 #13
0
void vm_setcursorstyle(int style)
{
    VIOCURSORINFO vi;

    switch (style)
    {
    case CURSORHALF:
        vi.yStart = -50;
        vi.cEnd = -100;
        vi.cx = 0;
        vi.attr = 0;
        VioSetCurType(&vi, 0);
        break;
    case CURSORFULL:
        vi.yStart = 0;
        vi.cEnd = -100;
        vi.cx = 0;
        vi.attr = 0;
        VioSetCurType(&vi, 0);
        break;
    case CURSORNORM:
        vi.yStart = -90;
        vi.cEnd = -100;
        vi.cx = 0;
        vi.attr = 0;
        VioSetCurType(&vi, 0);
        break;
    case CURSORHIDE:
        vi.yStart = -90;
        vi.cEnd = -100;
        vi.cx = 0;
        vi.attr = -1;
        VioSetCurType(&vi, 0);
        break;
    default:
        break;
    }
}
예제 #14
0
static void vm_setcursorsize(char start, char end)
{
    if (_osmode == DOS_MODE)
    {
        vi_init();
        v_ctype(start, end);
    }
    else
    {
        VIOCURSORINFO vi;
        vi.yStart = start;
        vi.cEnd = end;
        vi.cx = 0;
        vi.attr = 0;
        VioSetCurType(&vi, 0);
    }
}
예제 #15
0
void UIAPI uioffcursor( void )
/*****************************/
{
    VIOCURSORINFO vioCursor;

    if( UIData->cursor_on ) {
        /* set cursor size */
            VioGetCurType( &vioCursor, 0 );

           vioCursor.attr   = (USHORT)-1;        //invisible

           VioSetCurType(&vioCursor,0);

        UIData->cursor_on = false;
    }
    UIData->cursor_type = C_OFF;
}
예제 #16
0
void UIAPI uioncursor( void )
/****************************/
{
    CHAR                CharCellPair[2];
    VIOCURSORINFO       vioCursor;


    VioGetCurType( &vioCursor, 0 );
    if( UIData->cursor_type == C_INSERT ) {
        vioCursor.yStart = vioCursor.cEnd / 2;
    } else {
        vioCursor.yStart = (vioCursor.cEnd * 7) / 8;
    }
    vioCursor.cx = 1;
    vioCursor.attr = 1;

    VioSetCurType(&vioCursor, 0);


    /* set cursor position */

    VioSetCurPos( UIData->cursor_row, UIData->cursor_col, 0);

    if( UIData->cursor_attr != -2 ) {
    /* get current character and attribute */

        VioGetCurPos( &r, &c, 0 );
        length = sizeof(CharCellPair);
        VioReadCellStr(&CharCellPair[0],
                       &length,
                       UIData->cursor_row,
                       UIData->cursor_col,
                       0);

        /* write out the character and the new attribute */
        CharCellPair[1] = UIData->cursor_attr;
        VioWrtNCell((PBYTE)&CharCellPair[0],
                    24,
                    UIData->cursor_row,
                    UIData->cursor_col,
                    0);

    }
    UIData->cursor_on = true;
}
예제 #17
0
/* change the shape of the cursor */
static void 
cursorshape (ELVCURSOR shape)
{
  static ELVCURSOR prev_shape;  /* current shape */
  VIOCURSORINFO ci;

  if (shape != prev_shape)
    {
      /* Default width (1 column): */
      ci.cx = 0;
      ci.attr = 0;

      switch (shape)
        {
        case CURSOR_INSERT:
          ci.yStart = -80;
          ci.cEnd = -100;
          break;

        case CURSOR_REPLACE:
          ci.yStart = -0;
          ci.cEnd = -100;
          break;

        case CURSOR_COMMAND:
          ci.yStart = -10;
          ci.cEnd = -90;
          break;

        case CURSOR_QUOTE:
          ci.yStart = -20;
          ci.cEnd = -80;
          break;

        default:
          /* Hide the cursor. */
          ci.attr = -1;
          break;
        }
      VioSetCurType (&ci, 0L);
      prev_shape = shape;
    }
}
예제 #18
0
파일: os2pm.c 프로젝트: OS2World/LIB-libfly
void change_displayed_size (int r, int c)
{
    int rc;
    
    grab_video ();
    
    video_init (r, c);
    
    VioAssociate (0, hvps);
    VioDestroyPS (hvps);
    
    rc = VioCreatePS (&hvps, r, c, 0, 1, 0);
    rc = VioAssociate (hdc, hvps);
    rc = VioSetDeviceCellSize (cyChar, cxChar, hvps);
    VioSetCurType (pci, hvps);
    
    vio_rows = r;
    vio_cols = c;
    
    release_video ();
}
예제 #19
0
void vm_setcursorstyle(int style)
{
    if (_osmode == DOS_MODE)
    {
        if (vm_iscolorcard())
        {
            switch (style)
            {
            case CURSORHALF:
                vm_setcursorsize(4, 7);
                break;
            case CURSORFULL:
                vm_setcursorsize(0, 7);
                break;
            case CURSORNORM:
                vm_setcursorsize(7, 8);
                break;
            case CURSORHIDE:
                v_hidecursor();
                break;
            default:
                break;
            }
        }
        else
        {
            switch (style)
            {
            case CURSORHALF:
                vm_setcursorsize(8, 13);
                break;
            case CURSORFULL:
                vm_setcursorsize(0, 13);
                break;
            case CURSORNORM:
                vm_setcursorsize(11, 13);
                break;
            case CURSORHIDE:
                vm_setcursorsize(32, 32);
                break;
            default:
                break;
            }
        }
    }
    else
    {
        VIOCURSORINFO vi;

        switch (style)
        {
        case CURSORHALF:
            vi.yStart = -50;
            vi.cEnd = -100;
            vi.cx = 0;
            vi.attr = 0;
            VioSetCurType(&vi, 0);
            break;
        case CURSORFULL:
            vi.yStart = 0;
            vi.cEnd = -100;
            vi.cx = 0;
            vi.attr = 0;
            VioSetCurType(&vi, 0);
            break;
        case CURSORNORM:
            vi.yStart = -90;
            vi.cEnd = -100;
            vi.cx = 0;
            vi.attr = 0;
            VioSetCurType(&vi, 0);
            break;
        case CURSORHIDE:
            vi.yStart = -90;
            vi.cEnd = -100;
            vi.cx = 0;
            vi.attr = -1;
            VioSetCurType(&vi, 0);
            break;
        default:
            break;
        }
    }
}
uint  ExcepDialogFunction( DIALOGSHELL *shell, DIALOGCHOICE *ptr,
                           EVENT *nEvent, void *ParamBlock )
{
  uint   fldcol;
  uchar  *pExcepMap;                    /* Pointer to exception map.         */
  int    SelectIndex;                   /* Index into exception map array.   */

  SelectIndex = shell->CurrentField + ptr->SkipRows - 1;
  pExcepMap = LocalExcepMap + SelectIndex;
  for( ;; )
  {
    switch( nEvent->Value )
    {
      case INIT_DIALOG:
      {
        /*********************************************************************/
        /* This message is sent before displaying elements in display area.  */
        /* It is to initialise the locals in the dialog function.            */
        /*  - Make a copy of the global exception map.                       */
        /*  - Set the field cursor and variables to the first field.         */
        /*  - Set the length of the field highlite bar in normal and hilite  */
        /*    arrays (used in the call to putrc).                            */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        memcpy( LocalExcepMap, ExceptionMap, MAXEXCEPTIONS );
        fldcol = shell->col + 2;
        VioSetCurPos( (short)(shell->row + shell->SkipLines +
                       shell->CurrentField - 1), (short)fldcol, 0 );
        fld = ExpField;

        hilite[1] = normal[1] = (UCHAR)VATTLENGTH - 4;
        return( 0 );
      }

      case ENTER:
      {
        /*********************************************************************/
        /* This message is sent if the user clicks on the ENTER button or    */
        /* presses the ENTER key.                                            */
        /*  - Copy the local excetion map to the global exception map.       */
        /*  - Return non zero value to denote the end of dialog processing.  */
        /*********************************************************************/
        ptr->SkipRows = 0;
        memcpy( ExceptionMap, LocalExcepMap, MAXEXCEPTIONS );
        return( ENTER );
      }

      case F1:
      {
        uchar  *HelpMsg;

        HelpMsg = GetHelpMsg( HELP_DLG_EXCEPTIONS, NULL,0 );
        CuaShowHelpBox( HelpMsg );
        return( 0 );
      }

      case ESC:
      case F10:
      {
        /*********************************************************************/
        /* This message is sent if the user clicks on the CANCEL button or   */
        /* presses the ESC/F10 keys.                                         */
        /*  - Return non zero value to denote the end of dialog processing.  */
        /*********************************************************************/
        ptr->SkipRows = 0;
        return( nEvent->Value );
      }

      case MOUSEPICK:
      {
        /*********************************************************************/
        /* This message is sent if the clicks in the dialog display area.    */
        /*  - Determine on which field the user clicked.                     */
        /*  - Set the cursor on that field.                                  */
        /*  - If the field turns out to be notify field,                     */
        /*     - Set the event value as SPACEBAR (simulate) and stay in the  */
        /*       outer for loop to process SPACEBAR.                         */
        /*    Else                                                           */
        /*     - Return zero to denote continue dialog processing.           */
        /*********************************************************************/
        if( ((uint)nEvent->Col >= (shell->col + 2 + VATTLENGTH)) &&
            ((uint)nEvent->Col < (shell->col+ 2 + VATTLENGTH + NOTIFYMSGWIDTH)))
        {
           fldcol = shell->col+ 2 + VATTLENGTH;
           fld = NotifyField;
        }
        else
        {
           fldcol = shell->col+2;
           fld = ExpField;
        }

        VioSetCurPos( (short)(shell->row + shell->SkipLines +
                       shell->CurrentField - 1), (short)fldcol, 0 );

        if( fld == NotifyField )
        {
          nEvent->Value = SPACEBAR;
          continue;
        }

        return( 0 );
      }

      case key_R:
      case key_r:
      {
        /*********************************************************************/
        /* This message is sent if the user clicks in the RESET button or    */
        /* presses 'R' / 'r' keys.                                           */
        /*  - Reset the current exception notification to default.           */
        /*  - Display the new notification value in the field.               */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        *pExcepMap = DefExcepMap[ SelectIndex ];
        putrc( shell->row + shell->SkipLines + shell->CurrentField - 1,
               shell->col + 2 + VATTLENGTH, ExcepSel[*pExcepMap] );
        return( 0 );
      }

      case key_D:
      case key_d:
      {
        /*********************************************************************/
        /* This message is sent if the user clicks in the DEFAULT button or  */
        /* presses 'D' / 'd' keys.                                           */
        /*  - Copy the default exception map to the local exception map.     */
        /*  - Redisplay the display area of the dialog.                      */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        memcpy( LocalExcepMap, DefExcepMap, MAXEXCEPTIONS );
        DisplayExcepChoice( shell, ptr );
        return( 0 );
      }

      case key_S:
      case key_s:
      {
        /*********************************************************************/
        /* This message is sent if the user clicks on the SAVE button or     */
        /* presses the 'S' / 's' keys.                                       */
        /*  - Find the fully qualified file name for the .pro                */
        /*  - Call function to save the exceptions.                          */
        /*  - If not successfull in saving exceptions, display the error box */
        /*    with appropriate error message.                                */
        /*  - If successfull display a timmed message and copy the local     */
        /*    exception map to the default exception map.                    */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        uchar  StatusMsg[100];
        uchar  fn[MAXFNAMELEN];
        int    rc;

        findpro( "SD386.PRO", fn, MAXFNAMELEN );
        rc = SaveExceptions( fn );
        if( rc )
        {
          if( rc == FILENOTFOUND )
            sprintf( StatusMsg, "Unable to find \"SD386.PRO\" in DPATH" );
          else
            sprintf( StatusMsg, "Unable to save to profile \"%s\"", fn );
        }
        else
        {
          sprintf( StatusMsg, "Saving Exceptions to profile \"%s\"", fn );
          memcpy( ExceptionMap, LocalExcepMap, MAXEXCEPTIONS );
        }
        SayMsgBox2( StatusMsg, 1200UL );
        VioSetCurType( &NormalCursor, 0 );
        return( 0 );
      }

      case RIGHT:
      case TAB:
      {
        /*********************************************************************/
        /* This message is sent if the user presses TAB or right arrow  key.*/
        /*  - Depending on the current field determine to which field we have*/
        /*    to move to the right or loop around.                           */
        /*  - Set the field variables.                                       */
        /*  - Set the cursor position.                                       */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        switch( fld )
        {
          case ExpField:
          {
            fldcol = shell->col + 2 + VATTLENGTH;
            fld    = NotifyField;
            break;
          }

          case NotifyField:
          {
            fldcol = shell->col + 2;
            fld    = ExpField;
            break;
          }
        }
        VioSetCurPos( (short)(shell->row + shell->SkipLines +
                       shell->CurrentField - 1), (short)fldcol, 0 );
        return( 0 );
      }

      case LEFT:
      case S_TAB:
      {
        /*********************************************************************/
        /* This message is sent if the user presses SHIFT TAB or left arrow  */
        /*  key.                                                            */
        /*  - Depending on the current field determine to which field we have*/
        /*    to move to the left or loop around.                            */
        /*  - Set the field variables.                                       */
        /*  - Set the cursor position.                                       */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        switch( fld )
        {
          case ExpField:
          {
            fldcol = shell->col + 2 + VATTLENGTH;
            fld    = NotifyField;
            break;
          }

          case NotifyField:
          {
            fldcol = shell->col + 2;
            fld    = ExpField;
            break;
          }
        }
        VioSetCurPos( (short)(shell->row + shell->SkipLines +
                       shell->CurrentField - 1), (short)fldcol, 0 );
        return( 0 );
      }

      case SPACEBAR:
      {
        /*********************************************************************/
        /* This message is sent if the user presses the SPACEBAR.            */
        /*  - Toggle the notification value of the current field.            */
        /*  - Display the new notification value in the field.               */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        pExcepMap = LocalExcepMap + SelectIndex;
        *pExcepMap = (uchar)(*pExcepMap + 1);
        if( *pExcepMap > 1 )
          *pExcepMap  = 0;

        ClearField[1] = NOTIFICATION;
        putrc( shell->row + shell->SkipLines + shell->CurrentField - 1,
               shell->col + 2 + VATTLENGTH, ClearField );
        putrc( shell->row + shell->SkipLines + shell->CurrentField - 1,
               shell->col + 2 + VATTLENGTH, ExcepSel[*pExcepMap] );
        return( 0 );
      }

      case UP:
      case DOWN:
      case SCROLLUP:
      case SCROLLDOWN:
      case SCROLLBAR:
      {
        /*********************************************************************/
        /* These messages are sent if the user presses up  or down  arrow  */
        /* keys or the user clicks on the  or  in the scrollbar.           */
        /*  - Set the field variables.                                       */
        /*  - Set the cursor position.                                       */
        /*  - Return zero to denote continue dialog processing.              */
        /*********************************************************************/
        switch( fld )
        {
          case ExpField:
          {
            fldcol = shell->col + 2;
            break;
          }

          case NotifyField:
          {
            fldcol = shell->col + 2 + VATTLENGTH;
            break;
          }
        }

        VioSetCurPos( (short)(shell->row + shell->SkipLines +
                       shell->CurrentField - 1), (short)fldcol, 0 );
        return( 0 );
      }

      default:
        /*********************************************************************/
        /* Any other message.                                                */
        /* - Return zero to denote continue dialog processing.               */
        /*********************************************************************/
        return( 0 );
    }
  }
}
uint GetString( uint FieldRow, uint FieldCol, uint length, uint displen,
                uint *cursor, uchar *pInbuf, uint InFlags, POPUPSHELL *pShell)
{
  /***************************************************************************/
  /* Diagram to explain local variables.                                     */
  /*                                                                         */
  /*  0  ...     10        ...                   40       ...          200   */
  /*                                                                         */
  /*             +-------------------------------+                           */
  /*  +----------|                               |---------------------+     */
  /*  |          |  Portion of the string shown  |                     |     */
  /*  |          |  in the screen.               |                     |     */
  /*  +----------|                               |---------------------+     */
  /*             +-------------------------------+                           */
  /*             |<---- Display Length --------->|                           */
  /*                                                                         */
  /*  |<------------ length (length of the entire buffer) ------------>|     */
  /*                                                                         */
  /*   In the above example:                                                 */
  /*                                                                         */
  /*   length            ===>  200                                           */
  /*   DisplayLength     ===>  30                                            */
  /*   DisplayOffset     ===>  10                                            */
  /*                                                                         */
  /***************************************************************************/
  uint        key;
  int         n, i;
  ushort      rc;
  int         voff;
  uint        IsInsertMode = 0, scratch, BufLen;
  uint        DisplayOffset;
  uint        CursorRow, CursorCol;
  int         FirstKeyEntry = TRUE;                                     /*910*/
  uint        flags = InFlags;                                          /*910*/
  int         state = MOU_STATE_UP; /* assume this! */                  /*910*/
  int         NextState = 0;                                            /*910*/
  BUTTON     *pButtonDown = NULL;                                       /*910*/

  /***************************************************************************/
  /*                                                                         */
  /* flags  - Flags which indicate type of the field.                        */
  /*          (AUTOEXIT / HEXONLY / BINONLY)                                 */
  /***************************************************************************/
  if(pShell)
   flags = pShell->Flags;                                               /*910*/

  /***************************************************************************/
  /* - Set keyboard flush buffer flag to indiacte not to flush the keyboard  */
  /*   buffer while we are in getstring.                                     */
  /* - Initialise the local variables.                                       */
  /***************************************************************************/
  SetFlushBufferFlag( NOFLUSHNOW );                                     /*820*/
  FieldDisplayLength = displen;
  DisplayOffset = 0;
  CursorRow = FieldRow;

  CursorCol = ( *cursor > displen ) ? FieldCol : FieldCol + *cursor;

#ifdef MSH
  if(iview) {
    CursorRow+=RowStart;
    FieldRow+=RowStart;
    CursorCol+=ColStart;
    FieldCol+=ColStart;
  }
#endif

  /***************************************************************************/
  /* Allocate memory for the local buffer.                                   */
  /***************************************************************************/
  Buffer = (uchar *)Talloc( (length+1) * sizeof( uchar ) );
  memset( Buffer, '\0', length+1 );
  if(!iview) {
  /***************************************************************************/
  /* Adjust display length if the length specified by the caller goes out of */
  /* the screen.                                                             */
  /***************************************************************************/
  if( FieldCol + FieldDisplayLength > VideoCols )
    FieldDisplayLength = VideoCols - FieldCol;

  /***************************************************************************/
  /* Check to see if the field would over lap some other window, if so adjust*/
  /* the display length accordingly.                                         */
  /***************************************************************************/
  if( FieldDisplayLength + FieldCol > BoundPtr[FieldRow] )
    FieldDisplayLength = BoundPtr[FieldRow] - FieldCol;
  }
  else
  {
#ifdef MSH
      if( FieldDisplayLength + FieldCol - ColStart> VideoWidth )
        FieldDisplayLength = VideoWidth - FieldCol + ColStart;
#endif

  }/* End if*/
  /***************************************************************************/
  /* RightScrollOffset is the amount of scrolling to be done when the user   */
  /* goes out of the display length. It is 2/3 rds of the display length.    */
  /***************************************************************************/
  RightScrollOffset  = (FieldDisplayLength * 2)/3;
  LeftScrollOffset   = FieldDisplayLength - RightScrollOffset;

  FieldBase = (uchar *)Sel2Flat( HiFlat(VideoPtr) ) +
              ( voff = 2*(FieldRow*VideoCols + FieldCol) );
  FieldType = flags;

  /***************************************************************************/
  /* Depending on the type of the string copy the initial string to the local*/
  /* buffer. Display the string.                                             */
  /***************************************************************************/
  if( (FieldType & HEXONLY) || (FieldType & BINONLY) )
  {
    for( i = 0; i < length; i++ )
      Buffer[i] = FieldBase[i*2];
  }
  else
    strcpy( Buffer, pInbuf );

  DisplayField( DisplayOffset );
  VioShowBuf( (ushort)voff,(ushort) (2*FieldDisplayLength), 0 );

  VioSetCurType( &NormalCursor, 0 );

  for(;;)
  {
    VioSetCurPos( (ushort)CursorRow, (ushort)CursorCol, 0 );

    Event = GetEvent( SEM_INDEFINITE_WAIT );

    switch( Event->Type )
    {
      case TYPE_MOUSE_EVENT:                                            /*910*/
      {                                                                 /*910*/
       /******************************************************************910*/
       /* Test for mouse event between the string brackets.               910*/
       /******************************************************************910*/
       if( ( Event->Row == (ushort)FieldRow ) &&                        /*910*/
           ( Event->Col >= (ushort)FieldCol ) &&                        /*910*/
           ( Event->Col <= ((ushort)FieldCol+(ushort)FieldDisplayLength-1))
         )                                                              /*910*/
       {                                                                /*910*/
        /*****************************************************************910*/
        /* - If it's a button down event then set the cursor at the       910*/
        /*   end of the string or on the character that was clicked on.   910*/
        /*****************************************************************910*/
        if( Event->Value == EVENT_BUTTON_1_DOWN)                        /*910*/
        {                                                               /*910*/
          BufLen = strlen( Buffer );                                    /*910*/
          if( (DisplayOffset + (Event->Col - FieldCol)) > BufLen )      /*910*/
          {                                                             /*910*/
            keybeep();                                                  /*910*/
            CursorCol = FieldCol + (BufLen - DisplayOffset);            /*910*/
          }                                                             /*910*/
          else                                                          /*910*/
            CursorCol = (uint)Event->Col;                               /*910*/
        }                                                               /*910*/
        /*****************************************************************910*/
        /* - Ignore events between the brackets that are not button       910*/
        /*   down events.                                                 910*/
        /* - Any mouse event between []s turns off the erasure of a       910*/
        /*   cursor sensitive prompt.                                     910*/
        /*****************************************************************910*/
        FieldType &= ~CLEAR1ST;                                         /*910*/
        continue;                                                       /*910*/
       }                                                                /*910*/
                                                                        /*910*/
       /**********************************************************************/
       /* - handle strings that are not in the context of a popup.           */
       /**********************************************************************/
       if(pShell == NULL )                                              /*910*/
       {                                                                /*910*/
        NextState = GetMouseState( Event );                             /*910*/
        if( (state == MOU_STATE_UP) &&                                  /*910*/
            (NextState == MOU_STATE_DOWN)                               /*910*/
          )                                                             /*910*/
        {                                                               /*910*/
         key = LEFTMOUSECLICK;                                          /*910*/
         break;                                                         /*910*/
        }                                                               /*910*/
                                                                        /*910*/
        state = NextState;                                              /*910*/
        continue;                                                       /*910*/
       }                                                                /*910*/
       /******************************************************************910*/
       /* - Now, handle mouse events outside the []s within the context   910*/
       /*   of a popup.                                                   910*/
       /*                                                                 910*/
       /* - Button events are valid on the release event.                 910*/
       /*                                                                 910*/
       /* - Transitions from up to down "outside" the <>s and []s         910*/
       /*   are returned to the caller as a LEFTMOUSECLICK.               910*/
       /*                                                                 910*/
       /*  ------------------------                                       910*/
       /* |                        |                                      910*/
       /* |                       -----------                             910*/
       /* |         <------------|           |<----------------           910*/
       /* |        |              -----------                  |          910*/
       /* |      ----                                        ----         910*/
       /* |     |    |---                                ---|    |---     910*/
       /* |     | UP |   | BU,BUM                BD,BDM |   | DN |   |    910*/
       /* |     |    |<--                                -->|    |<--     910*/
       /* |      ----                                        ----         910*/
       /* |        |                                           |          910*/
       /* |        |                                           |          910*/
       /* |        |              -----------                  |          910*/
       /* |         ------------>|           |---------------->           910*/
       /* |                       -----------                             910*/
       /* |                               |                               910*/
       /* |                               |                               910*/
       /* | BU  - Button up event.        |                               910*/
       /* | BUM - Button up move event.    -(1) If BD or BDM event        910*/
       /* | BD  - Button down event.            occurs in a button(<>s),  910*/
       /* | BDM - Button down move event.       then set pButtonDown      910*/
       /* |                                     to point to the BUTTON    910*/
       /* |                                     structure. This is        910*/
       /* |                                     effectively a "pending"   910*/
       /*  ----(1) If BU or BUM event           button event. If the      910*/
       /*          && if the event occurs       up event occurs within    910*/
       /*          in the same button as        the same <>s, then we've  910*/
       /*          a "pending" button           got ourselves a valid     910*/
       /*          then we have a button        button event.             910*/
       /*          event.                                                 910*/
       /*                                   (2) If BD or BDM do not       910*/
       /*                                       occur within a button,    910*/
       /*                                       then set pButtonDown=NULL 910*/
       /*                                       and go back to the        910*/
       /*                                       caller with a             910*/
       /*                                       LEFTMOUSECLICK.           910*/
       /*                                                                 910*/
       /******************************************************************910*/
       NextState = GetMouseState( Event );                              /*910*/
       if( (state == MOU_STATE_DOWN) &&                                 /*910*/
           (NextState == MOU_STATE_UP) &&                               /*910*/
           (pButtonDown != NULL) &&                                     /*910*/
           (pButtonDown == GetButtonPtr(pShell,Event))                  /*910*/
         )                                                              /*910*/
       {                                                                /*910*/
        key = pButtonDown->Key;                                         /*910*/
        break;                                                          /*910*/
       }                                                                /*910*/
                                                                        /*910*/
       if( (state == MOU_STATE_UP) &&                                   /*910*/
           (NextState == MOU_STATE_DOWN)                                /*910*/
         )                                                              /*910*/
       {                                                                /*910*/
        pButtonDown = GetButtonPtr( pShell,Event);                      /*910*/
        if( pButtonDown == NULL )                                       /*910*/
        {                                                               /*910*/
         key = LEFTMOUSECLICK;                                          /*910*/
         break;                                                         /*910*/
        }                                                               /*910*/
       }                                                                /*910*/
                                                                        /*910*/
       state = NextState;                                               /*910*/
       continue;                                                        /*910*/
      }

      case TYPE_KBD_EVENT:
      {
        key = Event->Value;
        break;
      }
    }

    if( (FieldType & CLEAR1ST) && (FirstKeyEntry == TRUE) )             /*910*/
     FirstKeyEntry = FALSE;                                             /*910*/

    switch( key )
    {
      case F1:
      case ESC:
      case ENTER:
      case UP:
      case DOWN:
      case A_ENTER:
      case MOUSECLICK:
      /***********************************************************************/
      /* - these keys are specific to the watchpoint dialog.              910*/
      /***********************************************************************/
      case TYNEXT:                      /* watchpoint type button.        910*/
      case SPNEXT:                      /* watchpoint scope button.       910*/
      case SZNEXT:                      /* watchpoint size button.        910*/
      case STNEXT:                      /* watchpoint status button.      910*/
      {
        /*********************************************************************/
        /* All the above keys cannot be proccessed by getstring, so return   */
        /* the key to the caller.                                            */
        /*********************************************************************/
        rc = RCBREAK;
        break;
      }

      case C_HOME:
      {
        /*********************************************************************/
        /* Control-Home takes you to the start of the string.                */
        /*********************************************************************/
        DisplayOffset = 0;
        CursorCol = FieldCol;
        rc = RCREDRAW;
        break;
      }

      case C_END:
      {
        /*********************************************************************/
        /* Control-End takes you to the end of the string (to the last char  */
        /* the user has types in).                                           */
        /*********************************************************************/
        BufLen = strlen( Buffer );
        if( BufLen > FieldDisplayLength )
        {
          DisplayOffset = BufLen - FieldDisplayLength;
          CursorCol = FieldCol + FieldDisplayLength - 1;
        }
        else
        {
          DisplayOffset = 0;
          CursorCol = FieldCol + BufLen;
        }
        rc = RCREDRAW;
        break;
      }

      case TAB:
      case S_TAB:
      {
        /*********************************************************************/
        /* If the user has keyed in a tab  and the field type is AUTOEXIT,   */
        /* return to the caller.                                             */
        /*********************************************************************/
        if( FieldType & AUTOEXIT )
          rc = RCBREAK;
        else
        {
          keybeep();
          rc = 0;
        }
        break;
      }

      case LEFT:
      {
        /*********************************************************************/
        /* The user has pressed the left arrow key.                          */
        /*  - If the cursor is not in the starting column move the cursor    */
        /*    one column to the left.                                        */
        /*********************************************************************/
        if( CursorCol > FieldCol )
        {
          CursorCol--;
          rc = 0;
        }
        else
        {
          /*******************************************************************/
          /* If the cursor is in the starting column, a non zero value in the*/
          /* display offset would indicate we have some characters to the    */
          /* left to be displayed (see diagram above). If you have enough    */
          /* characters to scroll to LeftScrollOffset amount, do so. If not  */
          /* scroll to the start of the string.                              */
          /*******************************************************************/
          if( DisplayOffset )
          {
            if( (int)(DisplayOffset - LeftScrollOffset) >= 0 )
            {
              DisplayOffset -= LeftScrollOffset;
              CursorCol += (LeftScrollOffset - 1);
            }
            else
            {
              CursorCol += DisplayOffset;
              DisplayOffset = 0;
            }
            rc = RCREDRAW;
          }
          else
          {
            if( FieldType & AUTOEXIT )
              rc = RCBREAK;
            else
            {
               keybeep();
               rc = 0;
            }
          }
        }
        break;
      }

      case RIGHT:
      {
        /*********************************************************************/
        /* The user has pressed the right arrow key.                         */
        /*  - If the cursor is not in the ending column of display and not   */
        /*    end of the string, move the cursor one column to the right.    */
        /*********************************************************************/
        BufLen = strlen( Buffer );
        if( CursorCol < ( FieldCol + FieldDisplayLength - 1 ) )
        {
          if( (DisplayOffset + (CursorCol - FieldCol)) < BufLen )
          {
            CursorCol++;
            rc = 0;
          }
          else
          {
            keybeep();
            rc = 0;
          }
        }
        else
        {
          /*******************************************************************/
          /* If the cursor is at the ending column of display, check to see  */
          /* if we are within the buffer length. If we have enough space to  */
          /* scroll by RightScrollOffset amount do so, if not scroll till the*/
          /* end of the string.                                              */
          /*******************************************************************/
          if( DisplayOffset + FieldDisplayLength < BufLen )
          {
            DisplayOffset += (FieldDisplayLength - RightScrollOffset);
            if( (DisplayOffset + (CursorCol - FieldCol)) > BufLen )
              CursorCol = FieldCol + (BufLen - DisplayOffset);
            else
              CursorCol = FieldCol + RightScrollOffset;
            rc = RCREDRAW;
          }
          else
          {
            /*****************************************************************/
            /* If we reached the ending column and the end of the buffer, if */
            /* the field type is AUTOEXIT return to the caller.              */
            /*****************************************************************/
            if( FieldType & AUTOEXIT )
              rc = RCBREAK;
            else
            {
              keybeep();
              rc = 0;
            }
          }
        }
        break;
      }

      case HOME:
      {
        /*********************************************************************/
        /* Home takes to the starting column of the string.                  */
        /*********************************************************************/
        CursorCol = FieldCol;
        break;
      }

      case END:
      {
        /*********************************************************************/
        /* End takes you to the ending column of the string. If the string   */
        /* is not long enough till the ending column of the display, End     */
        /* takes you to the end of the string.                               */
        /*********************************************************************/
        CursorCol = FieldCol + FieldDisplayLength - 1;
        scratch = DisplayOffset + ( CursorCol - FieldCol );
        BufLen = strlen( Buffer );
        if( scratch > BufLen )
          CursorCol = FieldCol + (BufLen - DisplayOffset);
        break;
      }

      case INS:
      {
        /*********************************************************************/
        /* Insert key is pressed. This toggles the InsertMode flag. If the   */
        /* current length of the string is less than the buffer length,      */
        /* InsertMode could be allowed. Set the cusror type accordingly.     */
        /*********************************************************************/
        if( IsInsertMode )
        {
          IsInsertMode = 0;
          VioSetCurType( &NormalCursor, 0 );
        }
        else
        {
          if( length != strlen( Buffer ) )
          {
            IsInsertMode = 1 - IsInsertMode;
            IsInsertMode ? VioSetCurType( &InsertCursor, 0 ) :
                           VioSetCurType( &NormalCursor, 0 );
          }
          else                           /* Display proper error message...   */
            keybeep();
        }
        break;
      }

      case DEL:
      {
        /*********************************************************************/
        /* Delete the current character. The rest of the string is shifted   */
        /* left.                                                             */
        /*********************************************************************/
        scratch = DisplayOffset + ( CursorCol - FieldCol );
        ( scratch < strlen( Buffer ) ) ? ShiftLeft( scratch ) :
                                       keybeep();
        rc = RCREDRAW;
        break;
      }

      case BACKSPACE:
      {
        /*********************************************************************/
        /* The previous character to the cursor is deleted. By default the   */
        /* string is shifted left by one character. But if the cursor is on  */
        /* the starting column then the string is shifted by LeftScrollOffset*/
        /* amount.                                                           */
        /*********************************************************************/
        scratch = DisplayOffset + (CursorCol - FieldCol);
        if( scratch )
        {
          ShiftLeft( scratch - 1 );
          CursorCol--;
          if( CursorCol < FieldCol )
          {
            if( (int)(DisplayOffset - LeftScrollOffset) >= 0 )
            {
              DisplayOffset -= LeftScrollOffset;
              CursorCol += LeftScrollOffset;
            }
            else
            {
              CursorCol += (DisplayOffset + 1);
              DisplayOffset = 0;
            }
          }
        }
        else
          keybeep();
        rc = RCREDRAW;
        break;
      }

      default:
      {
        /*********************************************************************/
        /* Any other character key is pressed. Verify the validity of the    */
        /* character depending on the type of the string (HEX/BIN).          */
        /*********************************************************************/
        key &= 0xFF;
        if( key != 0x15 )
        if( (key < 0x20) || (key > 0x7E) )
        {
          rc = RCBREAK;
          break;
        }

        if( FieldType & HEXONLY )
        {
          if( (key < '0') || (key > '9') )
          {
            key &= 0xDF;
            if( (key < 'A') || (key > 'F') )
            {
              keybeep();
              rc = 0;
              break;
            }
          }
        }

        if( FieldType & BINONLY )
        {
          if( (key != '0') && (key != '1') )
          {
            keybeep();
            rc = 0;
            break;
          }
        }


        if( FieldType & CLEAR1ST )                                      /*910*/
        {                                                               /*910*/
         memset(Buffer,'\0',strlen(Buffer) );                           /*910*/
         *cursor = 0;                                                   /*910*/
         CursorCol = (*cursor > displen)?FieldCol : FieldCol + *cursor; /*910*/
        }                                                               /*910*/

        /*********************************************************************/
        /* Scratch gives you the exact number of characters so far typed in  */
        /* by the user. Accept the last character only if scratch is less    */
        /* than the total length of the string.                              */
        /*********************************************************************/
        scratch = DisplayOffset + ( CursorCol - FieldCol );
        if( scratch < length )
        {
          if( IsInsertMode )
          {
            if( (strlen( Buffer ) + 1) > length )
            {
              keybeep();
              rc = 0;
              break;      /* reject */
            }
            else
               ShiftRight( scratch );
          }

          Buffer[scratch] = ( uchar )key;

          /*******************************************************************/
          /* Adjust the cursor position accordingly so that it stays ahead   */
          /* of the last character.                                          */
          /*******************************************************************/
          if( CursorCol >= (FieldCol + FieldDisplayLength) )
          {
            DisplayOffset += (FieldDisplayLength - RightScrollOffset - 1);
            CursorCol = FieldCol + RightScrollOffset + 2;
          }
          else
            CursorCol++;

          /*******************************************************************/
          /* It the type of the field is AUTOEXIT return to the caller once  */
          /* the buffer is full.                                             */
          /*******************************************************************/
          BufLen = strlen( Buffer );
          if( (BufLen == length) &&
              (FieldType & AUTOEXIT) &&
              ((CursorCol - FieldCol) == FieldDisplayLength) )
            rc = RCREDRAW + RCBREAK + RCDATAXT;
          else
            rc = RCREDRAW;
          break;
        }
        else
        {
          keybeep();
          rc = 0;
          break;
        }
      }
    }

    /*************************************************************************/
    /* - Turn off the clear field flag after any event.                      */
    /*************************************************************************/
    FieldType &= ~CLEAR1ST;                                             /*910*/

   if( rc & RCREDRAW )
   {
     DisplayField( DisplayOffset );
     VioShowBuf( (ushort)voff, (ushort)( 2 * FieldDisplayLength ), 0 );
   }
   if( rc & RCBREAK )
     break;
  }                                     /* end of for loop to handle keystrks*/
    VioSetCurType( &HiddenCursor, 0 );

    /*************************************************************************/
    /* - Copy the local buffer to the caller supplied buffer.                */
    /* - Free the local buffer.                                              */
    /* - Reset the keyboard buffer flush flag.                               */
    /*************************************************************************/
    for( n = 0; n < strlen( Buffer ); n++ )
        *pInbuf++ = Buffer[n];

    *pInbuf = 0;
    *cursor = CursorCol;
    Tfree( Buffer );
    ResetFlushBufferFlag();                                             /*820*/
    return( (rc & RCDATAXT) ? DATAKEY : key );
}
예제 #22
0
파일: wrap.c 프로젝트: ErisBlastar/osfree
USHORT __pascal VIOSETCURTYPE(const PVIOCURSORINFO CursorInfo, const HVIO Handle)
{
  return VioSetCurType(CursorInfo, Handle);
}
예제 #23
0
파일: aaos2.c 프로젝트: JohnChu/Snoopy
static int os2vio_init(__AA_CONST struct aa_hardware_params *p,__AA_CONST  void *none, struct aa_hardware_params *dest, void *params)
{
  static struct aa_hardware_params def=
  {NULL,
   AA_DIM_MASK | AA_REVERSE_MASK | AA_NORMAL_MASK | AA_BOLD_MASK | AA_EXTENDED,
   0, 0,
   0, 0,
   80, 32,
   0, 0};
  BYTE bCell[2];
  VIOCURSORINFO hidecur;
#ifdef __EMX__
  int idx;
  struct sigaction   sa;
#endif  
  *dest=def;
  
  /* check size or prompt for it */
  if(p->width)
    width = p->width;
  else {
    char c[255];
    width = def.recwidth;
    if(p->recwidth)
      width = p->recwidth;
    printf("Width?[%i]", width);
    gets(c);
    sscanf(c, "%i", &width);
  }
  if (p->height)
    height = p->height;
  else {
    char c[256];
    height = def.recheight;
    if (p->recheight)
      height = p->recheight;
    printf("Height?[%i]", height);
    gets(c);
    sscanf(c, "%i", &height);
  }
  if (p->maxwidth && width > p->maxwidth)
    width = p->maxwidth;
  if (p->minwidth && width < p->minwidth)
    width = p->minwidth;
  if (p->maxheight && height > p->maxheight)
    height = p->maxheight;
  if (p->minheight && height < p->minheight)
    height = p->minheight;

  /* set font for modes that we know the size for, default vga16 */
  switch(height) {
  case 50:
    p->font = &aa_font8; break;
  case 43:
    p->font = &aa_font9; break;
  case 28:
    p->font = &aa_font14; break;
  }

  RowStr = (BYTE *)malloc(2 * width * sizeof(BYTE));
  if(RowStr==NULL) return 0;

  oldMode.cb=sizeof(VIOMODEINFO);
  VioGetMode((PVIOMODEINFO) &oldMode,(HVIO) 0);
  VioGetCurType(&oldCurInfo, (HVIO)0);
  memcpy((void *) &vio_mode, (const void *) &oldMode, sizeof(VIOMODEINFO));
  /* VIO, 80x50 */
  vio_mode.fbType = 1;
  vio_mode.color = 4;
  vio_mode.col = width;
  vio_mode.row = height;
  if(width>=132)
    vio_mode.hres = 1056;
  else
    vio_mode.hres = 720;
  vio_mode.vres = 400;
  vio_mode.fmt_ID = 0;
  vio_mode.attrib = 1;

  if (VioSetMode(&vio_mode, (HVIO) 0)) return 0;

#ifdef __EMX__
  /* under EMX, catch the signals to clean up proberly */

  sa.sa_handler = breakfunc;
  sa.sa_flags   = 0;
  sigemptyset(&sa.sa_mask);
  for (idx=SIGHUP;idx<=SIGTERM;idx++)  sigaction(idx,&sa,NULL);
#endif
  
  hidecur.attr = -1;
  VioSetCurType(&hidecur, (HVIO)0);
  
  bCell[0] = 0x20;
  bCell[1] = ( WM_BLACK << 4 ) + WM_PALEGRAY;
  
  VioScrollDn(TOP_ROW,LEFT_COL,0xFFFF,0xFFFF,0xFFFF,bCell,(HVIO) 0);

#ifdef 0
  printf("minwidth=%d\nminheight=%d\n", p->minwidth, p->minheight);
  printf("maxwidth=%d\nmaxheight=%d\n", p->maxwidth, p->maxheight);
  printf("recwidth=%d\nrecheight=%d\n", p->recwidth, p->recheight);
  printf("mmwidth=%d\nmmheight=%d\n", p->mmwidth, p->mmheight);
  printf("width=%d\nheight=%d\n", p->width, p->height);
  if(p->font!=NULL) {
    printf("fontheight=%d\n", p->font->height);
    printf("fontname=%s\n", p->font->name);
    printf("fontname(short)=%s\n", p->font->shortname);
  }
  getchar();
#endif

  return 1;
}
예제 #24
0
int MLE_edit_control(UCHAR code, PMLE pmle)
{
int x,y;
int rc;
int i,j,d;
   d=0;
   x=pmle->cursor % pmle->width;         // положение курсора
   y=pmle->cursor / pmle->width;         // в окне
   switch(code)
      {
      case INS:
         pmle->ins=1-pmle->ins;
         VioSetCurType(&Ins[pmle->ins],hvio);
         mAcurs =&Ins[pmle->ins];
         rc=2; // no reload
         break;
      case BS:
         if (!pmle->cursor)
            return -1;
         else
            strcpy(pmle->buf + pmle->cursor - 1,pmle->buf + pmle->cursor);
         d=1;
      case CULT:
         if (pmle->cursor)
            {
            pmle->cursor--;
            rc=2;
            }
         else
            rc=-1;
         break;
      case CURT:
         if (pmle->cursor < strlen(pmle->buf) && pmle->cursor < pmle->blen-1)
            {
            pmle->cursor++;
            rc=2;
            }
         else
            rc=-1;
         break;
      case CUUP:
         if (y)
            {
            pmle->cursor-=pmle->width;
            rc=2;
            }
         break;
      case CUDN:
         if (y < pmle->height - 1)
            {
            pmle->cursor+=pmle->width;
            rc=2;
            if (pmle->cursor >= strlen(pmle->buf))
               {
               pmle->cursor-=pmle->width;
               rc=-1;
               }
            }
         break;
      case CTRLCULT:
         if (pmle->cursor)
            pmle->cursor--;
         while (pmle->cursor && pmle->buf[pmle->cursor - 1] == 0x20)
               pmle->cursor--;
         while (pmle->cursor && pmle->buf[pmle->cursor-1] > 0x20)
               pmle->cursor--;
         rc=2;
         break;
      case CTRLCURT:
         i=strlen(pmle->buf);
         i=min(i,pmle->blen-1);
         while (pmle->cursor < i && pmle->buf[pmle->cursor] == 0x20)
               pmle->cursor++;
         while (pmle->cursor < i && pmle->buf[pmle->cursor] > 0x20)
            pmle->cursor++;
         while (pmle->cursor < i && pmle->buf[pmle->cursor] == 0x20)
            pmle->cursor++;
         rc=2;
         break;
      case ALTD:
         i=y*(pmle->width);
//         i=pmle->cursor-x;
         j=i+pmle->width;
         if (j < strlen(pmle->buf))
            strcpy(pmle->buf + i,pmle->buf + j);
         else
            pmle->buf[i]=0;
         pmle->cursor=i;
         d=1;
         break;
      case ALTK:
         i=y*(pmle->width);
         j=pmle->cursor-x+pmle->width;
         if (j < strlen(pmle->buf))
            strcpy(pmle->buf + pmle->cursor,pmle->buf + j);
         else
            pmle->buf[pmle->cursor]=0;
         d=1;
         break;
      case CTRLBS:
         i=pmle->cursor;
         rc=1;
         while (pmle->cursor && pmle->buf[--pmle->cursor] == 0x20);
         while (pmle->cursor && pmle->buf[--pmle->cursor] > 0x20);
         if (pmle->cursor)
             pmle->cursor++;
         if (pmle->cursor !=i)
            strcpy(pmle->buf + pmle->cursor,pmle->buf + i);
         break;
      case HOME:
         pmle->cursor=pmle->cursor - (pmle->cursor % pmle->width);
         rc=2;
         break;
      case END:
         j=max(pmle->cursor - x + pmle->width -1,0);
         i=strlen(pmle->buf);
         pmle->cursor =min (i, j);
         if (pmle->cursor == pmle->blen)
            pmle->cursor--;
         rc=2;
         break;
      case DEL:
         if (pmle->cursor < strlen(pmle->buf))
            {
            strcpy(pmle->buf + pmle->cursor,pmle->buf + pmle->cursor +1);
            d=1;
            }
         else
            rc=-1;
         break;
      case  CR: //was: CTRLCR:
         rc=0;
         break;
      default:
         return EDO_runCCKey((EDO *)pmle, code);

      }

   if (d)
      {
      rc=1;
      i=strlen(pmle->buf);
      while (i<pmle->blen)
         pmle->buf[i++]=0;
      }
   return rc;

}
예제 #25
0
파일: os2pm.c 프로젝트: OS2World/LIB-libfly
MRESULT EXPENTRY FlyWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
    SIZEL        sizl;
    int          rc, key, mou_r, mou_c, mou_ev, new_vio_rows, new_vio_cols;
    int          deltaX, deltaY, pix_rows, pix_cols, new_x0, new_y0;
    static int   mou_c1=-1, mou_r1=-1;
    struct _item *L;
    HWND         hwndMenu;
    SWP          swp;
    QMSG         *qmsg;
    USHORT       vk, fl;
    
    switch (msg)
    {
    case WM_CREATE:
        hdc = WinOpenWindowDC (hwnd);
        sizl.cx = sizl.cy = 0;
        grab_video ();
        hps = GpiCreatePS (hab, hdc, &sizl, PU_PELS | GPIF_DEFAULT |
                           GPIT_MICRO | GPIA_ASSOC);
        rc = VioCreatePS (&hvps, 80, 25, 0, 1, 0);
        VioGetDeviceCellSize (&cyChar, &cxChar, hvps);
        set_cursor (0);
        VioSetCurType (pci, hvps);
        release_video ();
        DosPostEventSem (hev_VideoReady);
        return 0;
        
    case WM_MOUSEMOVE:          mou_ev = MOUEV_MOVE; goto MOUSE;
    
    case WM_BUTTON1CLICK:       mou_ev = MOUEV_B1SC; goto MOUSE;
    case WM_BUTTON1DBLCLK:      mou_ev = MOUEV_B1DC; goto MOUSE;
    case WM_BUTTON1MOTIONSTART: mou_ev = MOUEV_B1MS; goto MOUSE;
    case WM_BUTTON1MOTIONEND:   mou_ev = MOUEV_B1ME; goto MOUSE;
    case WM_BUTTON1DOWN:        mou_ev = MOUEV_B1DN; goto MOUSE;
    case WM_BUTTON1UP:          mou_ev = MOUEV_B1UP; goto MOUSE;
    
    case WM_BUTTON2CLICK:       mou_ev = MOUEV_B2SC; goto MOUSE;
    case WM_BUTTON2DBLCLK:      mou_ev = MOUEV_B2DC; goto MOUSE;
    case WM_BUTTON2MOTIONSTART: mou_ev = MOUEV_B2MS; goto MOUSE;
    case WM_BUTTON2MOTIONEND:   mou_ev = MOUEV_B2ME; goto MOUSE;
    case WM_BUTTON2DOWN:        mou_ev = MOUEV_B2DN; goto MOUSE;
    case WM_BUTTON2UP:          mou_ev = MOUEV_B2UP; goto MOUSE;
    
    case WM_BUTTON3DBLCLK:      mou_ev = MOUEV_B3DC; goto MOUSE;
    case WM_BUTTON3CLICK:       mou_ev = MOUEV_B3SC; goto MOUSE;
    case WM_BUTTON3MOTIONSTART: mou_ev = MOUEV_B3MS; goto MOUSE;
    case WM_BUTTON3MOTIONEND:   mou_ev = MOUEV_B3ME; goto MOUSE;
    case WM_BUTTON3DOWN:        mou_ev = MOUEV_B3DN; goto MOUSE;
    case WM_BUTTON3UP:          mou_ev = MOUEV_B3UP; goto MOUSE;
    
    MOUSE:
        if (fl_opt.mouse_active != TRUE) break;
        mou_r = vio_rows - 1 - (SHORT2FROMMP (mp1)/cyChar);
        mou_c = SHORT1FROMMP (mp1)/cxChar;
        if (mou_r < 0 || mou_c < 0) break;
        // prevent MOUEV_MOVE message with same coordinates
        if (mou_ev == MOUEV_MOVE && mou_r == mou_r1 && mou_c == mou_c1) break;
        mou_r1 = mou_r, mou_c1 = mou_c;
        que_put (FMSG_BASE_MOUSE + FMSG_BASE_MOUSE_EVTYPE*mou_ev +
                 FMSG_BASE_MOUSE_X*mou_c + FMSG_BASE_MOUSE_Y*mou_r);
        break;
        
    case WM_PAINT:
        WinBeginPaint (hwnd, hps, NULL);
        grab_video ();
        VioShowBuf (0, 2 * vio_rows * vio_cols, hvps);
        release_video ();
        WinEndPaint (hps);
        return 0;

    case WM_CHAR:
        if (SHORT1FROMMP (mp1) & KC_KEYUP) return 0;
        if (SHORT2FROMMP (mp2) == VK_SHIFT ||
            SHORT2FROMMP (mp2) == VK_CTRL ||
            SHORT2FROMMP (mp2) == VK_ALT) return 0;
        key = pmkey2asvkey (SHORT2FROMMP(mp2), CHAR4FROMMP(mp1), SHORT1FROMMP(mp2),
                            CHAR3FROMMP(mp1), SHORT1FROMMP(mp1));
        if (key != -1) que_put (key);
        return 0;

    case WM_TRANSLATEACCEL:
        qmsg = (QMSG *)mp1;
        vk = SHORT2FROMMP (qmsg->mp2);
        fl = SHORT1FROMMP (qmsg->mp1) & (KC_ALT | KC_SHIFT | KC_CTRL | KC_KEYUP);
        if (vk == VK_MENU || vk == VK_F1) return FALSE;
        //if ((fl & KC_ALT) && vk >= VK_F1 && vk <= VK_F24) return FALSE;
        break;
        
    case WM_CLOSE:
        que_put (FMSG_BASE_SYSTEM +
                 FMSG_BASE_SYSTEM_TYPE*SYSTEM_QUIT);
        return 0;
        
    case WM_SIZE:
        if (cxChar != 0 && cyChar != 0)
        {
            pix_rows = SHORT2FROMMP (mp2);
            pix_cols = SHORT1FROMMP (mp2);
            new_vio_rows = pix_rows / cyChar;
            new_vio_cols = pix_cols / cxChar;
            if (new_vio_rows != vio_rows || new_vio_cols != vio_cols)
            {
                grab_video ();
                VioAssociate (0, hvps);
                VioDestroyPS (hvps);
                rc = VioCreatePS (&hvps, new_vio_rows, new_vio_cols, 0, 1, 0);
                VioSetDeviceCellSize (cyChar, cxChar, hvps);
                VioGetDeviceCellSize (&cyChar, &cxChar, hvps);
                rc = VioAssociate (hdc, hvps);
                VioSetCurType (pci, hvps);
                release_video ();
                que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_RESIZE +
                         FMSG_BASE_SYSTEM_INT2*new_vio_rows + FMSG_BASE_SYSTEM_INT1*new_vio_cols);
            }
            deltaX = new_vio_cols*cxChar - pix_cols;
            deltaY = new_vio_rows*cyChar - pix_rows;
            //if (deltaX != 0 || deltaY != 0)
            if (abs(deltaX) > MAX_DELTA || abs(deltaY) > MAX_DELTA)
            {
                WinPostMsg (hwndFrame, WM_FLY_RESIZE,
                            MPFROM2SHORT (SHORTBASE+deltaX, SHORTBASE+deltaY), NULL);
            }
        }
        WinDefAVioWindowProc (hwnd, msg, (ULONG)mp1, (ULONG)mp2);
        return 0;

    case WM_COMMAND:
        que_put (FMSG_BASE_MENU + LOUSHORT (mp1));
        break;

    case WM_FLY_LOADMENU:
        L = PVOIDFROMMP (mp1);
        // obtain handle for window menu
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        fill_submenu (hwndMenu, L);
        fly_active_menu = L;
        break;

    case WM_FLY_UNLOADMENU:
        L = PVOIDFROMMP (mp1);
        // obtain handle for window menu
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        empty_submenu (hwndMenu, L);
        fly_active_menu = NULL;
        break;
        
    case WM_FLY_RESIZE:
        deltaX = SHORT1FROMMP (mp1) - SHORTBASE;
        deltaY = SHORT2FROMMP (mp1) - SHORTBASE;
        rc = WinQueryWindowPos (hwndFrame, &swp);
        rc = WinSetWindowPos (hwndFrame, 0, swp.x, swp.y-deltaY, swp.cx+deltaX, swp.cy+deltaY, SWP_SIZE|SWP_MOVE);
        break;
        
    case WM_FLY_MOVE_CANVAS:
        new_x0 = SHORT1FROMMP (mp1) - SHORTBASE;
        new_y0 = SHORT2FROMMP (mp1) - SHORTBASE;
        rc = WinQueryWindowPos (hwndFrame, &swp);
        WinSetWindowPos (hwndFrame, 0, new_x0, new_y0-swp.cy, 0, 0, SWP_MOVE);
        //DosPostEventSem (hev_VideoReady);
        break;
        
    case WM_FLY_MENU_CHSTATUS:
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        WinEnableMenuItem (hwndMenu, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1));
        item_status_change++;
        break;
        
    case WM_FLY_MENU_CHSTATE:
        hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU);
        WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (SHORT1FROMMP(mp1), TRUE),
                    MPFROM2SHORT (MIA_CHECKED, SHORT2FROMMP(mp1) ? MIA_CHECKED : 0));
        break;
        
    case WM_DESTROY:
        grab_video ();
        VioAssociate (0, hvps);
        VioDestroyPS (hvps);
        GpiDestroyPS (hps);
        release_video ();
        que_put (FMSG_BASE_SYSTEM +
                 FMSG_BASE_SYSTEM_TYPE*SYSTEM_DIE);
        return 0;
    }
    
    return WinDefWindowProc (hwnd, msg, mp1, mp2);
}