Esempio n. 1
0
int macgetch(void)
{
    WindowPtr whichWindow;
    EventRecord theEvent;
    char c;                     /* one-byte buffer for read() to use */

    do {
        SystemTask();
        if (!GetNextEvent(everyEvent, &theEvent))
            theEvent.what = nullEvent;
        else {
            switch (theEvent.what) {
            case keyDown:
                c = theEvent.message & charCodeMask;
                break;
            case mouseDown:
                if (FindWindow(theEvent.where, &whichWindow) ==
                    inSysWindow)
                    SystemClick(&theEvent, whichWindow);
                break;
            case updateEvt:
                break;
            }
        }
    } while (theEvent.what != keyDown);

    printf("*");
    fflush(stdout);

    return (int)c;
}
Esempio n. 2
0
/*
 * FindCharOnCurrentLine - look for c char on a line ('f','F','t','T' cmds)
 */
vi_rc FindCharOnCurrentLine( bool fwdflag, int mod, int *col, int cnt )
{
    int         i, c, j;
    char        lst[2];

    c = CurrentPos.column - 1;
    *col = -1;
    LastEvent = GetNextEvent( FALSE );
    if( LastEvent == VI_KEY( ESC ) ) {
        return( ERR_NO_ERR );
    }
    lst[0] = (char)LastEvent;
    lst[1] = 0;
    i = 0;
    for( j = 0; j < cnt; j++ ) {
        i = -1;
        if( fwdflag ) {
            if( c < CurrentLine->len - 1 ) {
                i = findFirstCharInListForward( CurrentLine, lst, c + 1 );
            }
        } else {
            if( c > 0 ) {
                i = findFirstCharInListBackwards( CurrentLine, lst, c - 1 );
            }
        }
        if( i < 0 ) {
            Error( GetErrorMsg( ERR_CHAR_NOT_FOUND ), LastEvent );
            return( DO_NOT_CLEAR_MESSAGE_WINDOW );
        }
        c = i;
    }
    *col = 1 + i + mod;
    return( ERR_NO_ERR );

} /* FindCharOnCurrentLine */
void MIDISequencer::ScanEventsAtThisTime()
{
    // save the current iterator state
    MIDIMultiTrackIteratorState istate ( state.iterator.GetState() );
    int prev_measure = state.cur_measure;
    int prev_beat = state.cur_beat;
    // process all messages up to and including this time only
    MIDIClockTime orig_clock = state.cur_clock;
    double orig_time_ms = state.cur_time_ms;
    MIDIClockTime t = 0;
    int trk;
    MIDITimedBigMessage ev;

    while (
        GetNextEventTime ( &t )
        && t == orig_clock
        && GetNextEvent ( &trk, &ev )
    )
    {
        ;
    }

    // restore the iterator state
    state.iterator.SetState ( istate );
    // and current time
    state.cur_clock = orig_clock;
    state.cur_time_ms = float ( orig_time_ms );
    state.cur_measure = prev_measure;
    state.cur_beat = prev_beat;
}
Esempio n. 4
0
int YamlHelper::GetScalar(std::string& scalar)
{
	int res = 1;
	bool bDone = false;

	while (!bDone)
	{
		GetNextEvent();

		switch(m_newEvent.type)
		{
		case YAML_SCALAR_EVENT:
			scalar = m_scalarName = (const char*)m_newEvent.data.scalar.value;
			res = 1;
			bDone = true;
			break;
		case YAML_SEQUENCE_END_EVENT:
			res = 0;
			bDone = true;
			break;
		case YAML_MAPPING_END_EVENT:
			res = 0;
			bDone = true;
			break;
		case YAML_STREAM_END_EVENT:
			res = 0;
			bDone = true;
			break;
		}
	}

	return res;
}
Esempio n. 5
0
static change_resp ChangePrompt( void )
{
#ifdef __WIN__
    int     i;

    i = MyMessageBox( Root, "Change this occurence?", "Replace Text",
                      MB_ICONQUESTION | MB_YESNOCANCEL );
    if( i == IDNO ) {
        return( CHANGE_NO );
    } else if( i == IDCANCEL ) {
        return( CHANGE_CANCEL );
    } else {
        return( CHANGE_OK );
    }
#else
    vi_key      key = 0;

    Message1( "Change? (y)es/(n)o/(a)ll/(q)uit" );
    for( ;; ) {
        key = GetNextEvent( false );
        if( key == VI_KEY( y ) ) {
            return( CHANGE_OK );
        } else if( key == VI_KEY( n ) ) {
            return( CHANGE_NO );
        } else if( key == VI_KEY( a ) ) {
            return( CHANGE_ALL );
        } else if( key == VI_KEY( q ) ) {
            return( CHANGE_CANCEL );
        }
    }
#endif
}
Esempio n. 6
0
static
void *exec(void *arg)
{
  ws_state_list *p = (ws_state_list *) arg;
  EventRecord event;

  create_window(p);

  init_norm_xform();
  init_colors();
  create_patterns();

  p->run = 1;
  while (p->run)
    {
      pthread_mutex_lock(&p->mutex);
      while (EventAvail(everyEvent, &event))
	{
	  GetNextEvent(everyEvent, &event);
	  if (event.what == kHighLevelEvent)
	    AEProcessAppleEvent(&event);
	}
      pthread_mutex_unlock(&p->mutex);
      usleep(10000);
    }
  DisposeWindow(p->win);

  pthread_exit(0);

  return 0;
}
/*! State Machine function */
void emberAfPluginSimpleCommissioningInitiatorStateMachineEventHandler(void) {
  emberEventControlSetInactive(StateMachineEvent);
  // That might happened that ZigBee state machine changed current network
  // So, it is important to switch to the proper network before commissioning
  // state machine might start
  EmberStatus status = emberAfPushNetworkIndex(dev_comm_session.network_index);
  if (status != EMBER_SUCCESS) {
    // TODO: Handle unavailability of switching network
  }
  emberAfDebugPrintln("DEBUG: State Machine");
  // Get state previously set by some handler
  CommissioningState_t cur_state = GetNextState();
  CommissioningEvent_t cur_event = GetNextEvent();
  for (size_t i = 0; i < TRANSIT_TABLE_SIZE(); ++i) {
    if ((cur_state == sm_transition_table[i].state ||
         SC_EZ_UNKNOWN == sm_transition_table[i].state) &&
        ((cur_event == sm_transition_table[i].event) ||
         SC_EZEV_UNKNOWN == sm_transition_table[i].event)) {
      // call handler which set the next_state on return and
      // next_event inside itself
      SetNextState((sm_transition_table[i].handler)());
      break;
    }
  }

  // Don't forget to pop Network Index
  status = emberAfPopNetworkIndex();
  // sanity check that network switched back properly
  EMBER_TEST_ASSERT(status == EMBER_SUCCESS);
}
Esempio n. 8
0
Word ResolveHost(const char *name, cvtRecPtr cvt)
{
dnrBuffer dnr;
char *pstr;
Word port;
EventRecord event;

	cvt->cvtIPAddress = 0;
	cvt->cvtPort = 0;

	if (!name || !*name) return false;

	pstr = __c2pstrMalloc(name);
	if (!pstr) return false;

	port = TCPIPMangleDomainName(0xf800, pstr);

	// check if name is a dotted decimal or a host...

	if (TCPIPValidateIPString(pstr))
	{
		TCPIPConvertIPToHex(cvt, pstr);
		cvt->cvtPort = port;
		free (pstr);
		return true;
	}
	else
	{
		TCPIPDNRNameToIP(pstr, &dnr);
		if (_toolErr)
		{
			free(pstr);
			return false;
		}
		while (dnr.DNRStatus == DNRPending)
		{
			TCPIPPoll();
			GetNextEvent(keyDownMask | autoKeyMask, &event);
			if ((event.what == keyDownEvt)
				&& (event.modifiers & appleKey)
				&& ((Word)event.message == '.'))
			{
				TCPIPCancelDNR(&dnr);
				break;
			}
		}
		if (dnr.DNRStatus == DNROK)
		{
			cvt->cvtIPAddress = dnr.DNRIPAddress;
			cvt->cvtPort = port;
			free(pstr);
			return true;
		}
	}

	free(pstr);

	return false;
}
Esempio n. 9
0
static bool fileComplete( input_buffer *input, vi_key first_event )
{
    bool        exit, done;
    vi_rc       rc;
    vi_key      event;
    int         old_len;

    exit = false;
    if( input->curr_pos != strlen( input->buffer ) ) {
        MyBeep();
    } else {
        saveStr( input );
        old_len = strlen( input->buffer ) - 1;
        rc = StartFileComplete( input->buffer, old_len,
                                 input->buffer_length, first_event );
        if( rc > ERR_NO_ERR ) {
            MyBeep();
        } else {
            if( rc != FILE_COMPLETE ) {
                done = false;
                do {
                    endColumn( input );
                    displayLine( input );
                    event = GetNextEvent( true );
                    switch( event ) {
                    case VI_KEY( FAKEMOUSE ):
                    case VI_KEY( MOUSEEVENT ):
                    case VI_KEY( TAB ):
                    case VI_KEY( SHIFT_TAB ):
                    case VI_KEY( UP ):
                    case VI_KEY( DOWN ):
                    case VI_KEY( LEFT ):
                    case VI_KEY( RIGHT ):
                    case VI_KEY( PAGEDOWN ):
                    case VI_KEY( PAGEUP ):
                    case VI_KEY( ALT_END ):
                        rc = ContinueFileComplete( input->buffer, old_len,
                                                    input->buffer_length, event );
                        if( rc != ERR_NO_ERR ) {
                            FinishFileComplete();
                            if( rc == FILE_COMPLETE_ENTER ) {
                                exit = true;
                            }
                            done = true;
                        }
                        old_len = strlen( input->buffer );
                        break;
                    default:
                        KeyAdd( event );
                        PauseFileComplete();
                        done = true;
                    }
                } while( !done );
            }
        }
    }
    return( exit );

} /* fileComplete */
Esempio n. 10
0
void Mapper4::RenderingEnabledChanged( bool enabled )
{
	mRenderingEnabled = enabled;
	// report new next event
	const int newEvent = GetNextEvent( g_nesMainboard->GetSynchroniser()->GetCpuMTC() );
	if ( newEvent >= 0 )
		g_nesMainboard->GetSynchroniser()->NewNextEvent( newEvent );
}
Esempio n. 11
0
void MCScreenDC::expose()
{
	SetGWorld(GetWindowPort(getinvisiblewin()), GetMainDevice());

	EventRecord event;
	while (GetNextEvent(updateMask, &event))
		doredraw(event);
}
Esempio n. 12
0
File: ugView.c Progetto: rolk/ug
static void ProcessEvent ()
{
  EventRecord myEvent;
  WindowPtr whichWindow;

  /* do system tasks */
  SystemTask();

  /* get event */
  if (GetNextEvent(everyEvent,&myEvent))
  {
    switch (myEvent.what)
    {
    case mouseDown :
      switch (FindWindow(myEvent.where,&whichWindow))
      {
      case inSysWindow :
        SystemClick(&myEvent,whichWindow);
        break;
      case inMenuBar :
        DoCommand(MenuSelect(myEvent.where));
        break;
      case inDrag :
        DragWindow(whichWindow,myEvent.where,&dragRect);
        break;
      case inContent :
        if (whichWindow!=FrontWindow())
          SelectWindow(whichWindow);
        else
        {
          /*DoContentClick(whichWindow,&myEvent);*/
        }
        break;
      case inGrow :
        /*DoGrowWindow(whichWindow,&myEvent);*/
        break;
      case inGoAway :
        /*DoGoAway(whichWindow,&myEvent);*/
        break;
      }
      break;                           /* mouseDown */

    case keyDown :
    case autoKey :
      DoKey(&myEvent);
      break;

    case activateEvt :
      /*DoActivate(&myEvent);*/
      break;

    case updateEvt :
      whichWindow = (WindowPtr) myEvent.message;
      /*DoUpdate(whichWindow,&myEvent);*/
      break;
    }
  }
} /* ProcessEvent */
Esempio n. 13
0
/*
    CommandPeriod()
    
    
*/
Boolean CommandPeriod(void)
{
	EventRecord event;

	if(EventAvail(keyDownMask|autoKeyMask,&event) && IsCommandPeriod(&event)){
		GetNextEvent(keyDownMask|autoKeyMask,&event);	// consume the event.
		return 1;
	}else return 0;	
}
Esempio n. 14
0
void Mapper4::SpriteScreenEnabledUpdate( bool spriteAddress, bool screenAddress )
{
	mSpriteAddress = spriteAddress;
	mScreenAddress = screenAddress;
	// report new next event
	const int newEvent = GetNextEvent( g_nesMainboard->GetSynchroniser()->GetCpuMTC() );
	if ( newEvent >= 0 )
		g_nesMainboard->GetSynchroniser()->NewNextEvent( newEvent );
}
bool MIDISequencer::GoToTimeMs ( float time_ms )
{
    // temporarily disable the gui notifier
    bool notifier_mode = false;

    if ( state.notifier )
    {
        notifier_mode = state.notifier->GetEnable();
        state.notifier->SetEnable ( false );
    }

    if ( time_ms < state.cur_time_ms || time_ms == 0.0 )
    {
        // start from zero if desired time is before where we are
        for ( int i = 0; i < state.num_tracks; ++i )
        {
            state.track_state[i]->GoToZero();
        }

        state.iterator.GoToTime ( 0 );
        state.cur_time_ms = 0.0;
        state.cur_clock = 0;
//  state.next_beat_time = state.multitrack->GetClksPerBeat();
        state.next_beat_time =
            state.multitrack->GetClksPerBeat()
            * 4 / ( state.track_state[0]->timesig_denominator );
        state.cur_beat = 0;
        state.cur_measure = 0;
    }

    float t = 0;
    int trk;
    MIDITimedBigMessage ev;

    while (
        GetNextEventTimeMs ( &t )
        && t < time_ms
        && GetNextEvent ( &trk, &ev )
    )
    {
        ;
    }

    // examine all the events at this specific time
    // and update the track states to reflect this time
// ScanEventsAtThisTime();

    // re-enable the gui notifier if it was enabled previously
    if ( state.notifier )
    {
        state.notifier->SetEnable ( notifier_mode );
        // cause a full gui refresh now
        state.notifier->Notify ( this, MIDISequencerGUIEvent::GROUP_ALL );
    }

    return true;
}
// ---------------------------------------------------------------------------
// CCsConversationCacheHelper::HandleProcessConversationL()
// Process Conversation and update cache
// ---------------------------------------------------------------------------
//
void CCsConversationCacheHelper::HandleProcessConversationL()
{
    iConversationEvent = GetNextEvent();
    // check to see if all the events are consumed
    // then mark cache as caching done..
    if (!iConversationEvent)
    {
        iConversationCache->CachingCompletedL();
        return;
    }

    CCsConversationEntry* conEntry =
            iConversationEvent->ClientConversation()->GetConversationEntry();

    //handle add, modify events
    if (iConversationEvent->Event() != KConversationEventDelete)
    {
        TUint8 SpecialId = NeedsSpecialProcessing(conEntry);

        if (SpecialId)
        {
            // this is for draft(unlnown)/BT/IR processing            
            iState = ECsSpecialConversation;
        }
        // check only if contact is a valid address
        else if (conEntry->Contact())
        {
            iCurrentConversationIndex
                    = iConversationCache->FindConversation(* (conEntry->Contact()));
            if (iCurrentConversationIndex != KErrNotFound)
            {
                iState = ECsConversationFoundInCache;
            }
            else
            {
                iState = ECsResolveConversation;
            }
        }
        else
        {
            // this is when contact number is NULL
            // delete the entry from temp list
            DeleteEvent(*iConversationEvent);
            iState = ECsProcessConversation;
        }
    }
    else
    {
        //handle delete event
        DeleteConversationEntryL(conEntry);
        DeleteEvent(*iConversationEvent);
        iState = ECsProcessConversation;
    }
    //move to other state
    IssueRequest();
}
Esempio n. 17
0
static Nlm_Char Nlm_ReadCharFromTerm (void)

{
  Nlm_Char     ch;
/*#ifdef OS_MAC*/
#ifdef WIN_MAC 
  EventRecord  event;
#endif
#ifdef WIN_MSWIN
  MSG          msg;
  HWND         hwnd;
#endif

  ch = '\0';
/*#ifdef OS_MAC*/
#ifdef WIN_MAC
  while (ch == '\0') {
    if (GetNextEvent (keyDownMask + autoKeyMask, &event)) {
      ch = (Nlm_Char) (event.message % 256);
    }
  }
  Nlm_DrawACharacter (ch);
  if (ch == '\3') {
    ch = '\0';
  }
#endif
#ifdef WIN_MSWIN
  hwnd = GetFocus ();
  if (hwnd != NULL) {
    hwnd = GetParent (hwnd);
    if (hwnd != NULL) {
      SetFocus (hwnd);
    }
  }
  while (ch == '\0') {
    while (PeekMessage (&msg, NULL, WM_KEYDOWN, WM_KEYUP, PM_NOREMOVE)) {
      if (GetMessage (&msg, NULL, WM_KEYDOWN, WM_KEYUP)) {
        TranslateMessage (&msg);
        DispatchMessage (&msg);
      }
    }
    while (PeekMessage (&msg, NULL, WM_CHAR, WM_CHAR, PM_NOREMOVE)) {
      if (GetMessage (&msg, NULL, WM_CHAR, WM_CHAR)) {
        ch = (Nlm_Char) msg.wParam;
      }
    }
    if (ch == '\r') {
      ch = '\n';
    }
  }
  Nlm_DrawACharacter (ch);
#endif
#ifdef WIN_MOTIF
#endif
  return ch;
}
Esempio n. 18
0
void YamlHelper::GetMapStartEvent(void)
{
	GetNextEvent();

	if (m_newEvent.type != YAML_MAPPING_START_EVENT)
	{
		//printf("Unexpected yaml event (%d)\n", m_newEvent.type);
		throw std::string("Unexpected yaml event");
	}
}
Esempio n. 19
0
int raw_kbhit(void)
{
	EventRecord event;

	// Allow SIOUX response for the mouse, drag, zoom, or resize.
	if (GetNextEvent(mDownMask|mUpMask,&event))
		SIOUXHandleOneEvent(&event);

	/* Check for keystroke. */
	return EventAvail(keyDownMask, &event);
}
Esempio n. 20
0
void DoAbout()
{
DialogPtr ad;
EventRecord	e;

	ad=GetNewDialog(kAboutDlogID, nil, (DialogPtr)-1);
	DrawDialog(ad);
		
	while(!GetNextEvent(keyDownMask+mDownMask,&e)) ;
	DisposeDialog(ad);
}
Esempio n. 21
0
/*
 * doRunKeyMap - execute a key map a specified number of times
 */
static vi_rc doRunKeyMap( key_map *scr, long total )
{
    int         max;
    vi_rc       rc = ERR_NO_ERR;
    undo_stack  *cstack;

    if( EditFlags.InputKeyMapMode ) {
        return( ERR_INPUT_KEYMAP_RUNNING );
    }
    cstack = UndoStack;
    StartUndoGroup( cstack );
    while( total > 0 ) {
        /*
         * set up key map to run
         */
        CurrentKeyMap = scr->data;
        if( scr->no_input_window ) {
            EditFlags.NoInputWindow = TRUE;
        }
        // max = strlen( CurrentKeyMap );
        for( max = 0; CurrentKeyMap[max] != 0; max++ );

        EditFlags.KeyMapInProgress = TRUE;
        EditFlags.KeyMapMode = TRUE;
        LastError = ERR_NO_ERR;

        /*
         * run until done
         */
        for( CurrentKeyMapCount = 0; CurrentKeyMapCount < max; ) {
            LastEvent = GetNextEvent( FALSE );
            rc = DoLastEvent();
            if( rc > ERR_NO_ERR || LastError != ERR_NO_ERR ) {
                break;
            }
            DoneLastEvent( rc, TRUE );
        }

        EditFlags.KeyMapMode = FALSE;
        EditFlags.NoInputWindow = FALSE;
        EditFlags.KeyMapInProgress = FALSE;
        if( rc > ERR_NO_ERR || LastError != ERR_NO_ERR ) {
            break;
        }
        total--;
    }

    TryEndUndoGroup( cstack );
    EditFlags.Dotable = FALSE;
    return( rc );

} /* doRunKeyMap */
Esempio n. 22
0
/* Return -1 if no char available, otherwise return char.
 * Return 3 if user hits the interrupt key (usually ^C, hence 3)
 *
 * Bug: This version does not set unbuffered mode on stdout,
 * so be sure to fflush(stdout) early and often...
 */
int raw_getc(void)
{
	int c;
	EventRecord event;

	// Allow SIOUX response for the mouse, drag, zoom, or resize.
	if (GetNextEvent(mDownMask|mUpMask,&event))
		SIOUXHandleOneEvent(&event);

	/* Check for keystroke. */
	if (GetNextEvent(keyDownMask,&event)) {
		/* Get ASCII value of keystroke. */
		c=event.message&charCodeMask;
		if (c=='.' && (event.modifiers&cmdKey)) {
			return 3;
			//exit(1);
		}

		return c;
	}

	return -1;  /* No character avail */
}
Esempio n. 23
0
static PyObject *Evt_GetNextEvent(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    Boolean _rv;
    EventMask eventMask;
    EventRecord theEvent;
#ifndef GetNextEvent
    PyMac_PRECHECK(GetNextEvent);
#endif
    if (!PyArg_ParseTuple(_args, "H",
                          &eventMask))
        return NULL;
    _rv = GetNextEvent(eventMask,
                       &theEvent);
    _res = Py_BuildValue("bO&",
                         _rv,
                         PyMac_BuildEventRecord, &theEvent);
    return _res;
}
Esempio n. 24
0
/*
 * MovePosition - move to a screen position
 */
vi_rc MovePosition( void )
{
    linenum     lne, lines;
    vi_key      key;
    vi_rc       rc;

    if( RepeatDigits == 0 ) {
        lne = CurrentPos.line;
    } else {
        lne = GetRepeatCount();
        if( IsPastLastLine( lne ) ) {
            return( ERR_INVALID_REDRAW );
        }
    }
    lines = WindowAuxInfo( CurrentWindow, WIND_INFO_TEXT_LINES );
    key = GetNextEvent( false );
    switch( key ) {
    case '.':
        LeftTopPos.line = lne - lines / 2;
        break;
    case VI_KEY( ENTER ):
        LeftTopPos.line = lne;
        break;
    case '-':
        LeftTopPos.line = lne - lines + 1;
        break;
    default:
        return( ERR_INVALID_REDRAW );
    }
    if( LeftTopPos.line < 1 ) {
        LeftTopPos.line = 1;
    }
    SetCurrentLineNumber( lne );
    rc = CGimmeLinePtr( CurrentPos.line, &CurrentFcb, &CurrentLine );
    CurrentPos.column = 1;
    DCInvalidateAllLines();
    DCDisplayAllLines();
    if( rc == ERR_NO_ERR ) {
        rc = GoToColumnOnCurrentLine( FindStartOfCurrentLine() );
    }
    return( rc );

} /* MovePosition */
Esempio n. 25
0
/*
 * StartSaveExit - prepare to do save & exit of file
 */
vi_rc StartSaveExit( void )
{
    vi_key  key;
    vi_key  levent;

    /*
     * get the next key
     */
    levent = LastEvent;
    key = GetNextEvent( FALSE );
    if( key != levent ) {
        if( key == VI_KEY( ESC ) ) {
            return( ERR_NO_ERR );
        }
        return( InvalidKey() );
    }
    return( SaveAndExit( NULL ) );

} /* StartSaveExit */
Esempio n. 26
0
static void postSpawn( long rc )
{
    restorePrompt();
    VarAddGlobalLong( "Sysrc", rc );
    UpdateCurrentDirectory();

#ifndef __WIN__
    ResetColors();
    // if( (EditFlags.PauseOnSpawnErr && rc != 0 ) ||
    //          !EditFlags.SourceScriptActive ) {
    if( EditFlags.PauseOnSpawnErr && rc != 0 ) {
        MyPrintf( "[%s]\n", MSG_PRESSANYKEY );
        GetNextEvent( false );
    }
    ResetSpawnScreen();
    if( !EditFlags.LineDisplay ) {
        ReDisplayScreen();
    }
#endif
    EditFlags.ClockActive = clockActive;
}
Esempio n. 27
0
/*
 * DoSavebufNumber - get a savebuf number
 */
vi_rc DoSavebufNumber( void )
{
    vi_key      key;
    char        buff[2];
    vi_rc       rc;

    /*
     * get savebuf to use
     */
    key = GetNextEvent( false );
    if( key == VI_KEY( ESC ) ) {
        return( ERR_NO_ERR );
    }
    buff[0] = (char)key;
    buff[1] = '\0';
    rc = SetSavebufNumber( buff );
    if( rc == ERR_NO_ERR ) {
        rc = GOT_A_SAVEBUF;
    }
    return( rc );

} /* DoSavebufNumber */
double MIDISequencer::GetMusicDurationInSeconds()
{
    double event_time = 0.; // in milliseconds

    MIDITimedBigMessage ev;
    int ev_track;

    GoToZero();

    while ( GetNextEvent( &ev_track, &ev ) )
    {
        // std::cout << "MIDISequencer::GetMusicDurationInSeconds: " << EventAsText( ev ) << std::endl;

        // skip these events
        if ( ev.IsEndOfTrack() || ev.IsBeatMarker() )
            continue;

        // end of music is the time of last not end of track midi event!
        event_time = GetCurrentTimeInMs();
    }

    return ( 0.001 * event_time );
}
Esempio n. 29
0
static void doHistorySearch( input_buffer *input )
{
    int             curr;
    char            *str;
    vi_key          event;

    curr = input->h->curr;
    str = alloca( strlen( input->buffer ) + 1 );
    strcpy( str, input->buffer );
    event = VI_KEY( CTRL_TAB );
    while( curr != -1 ) {
        if( event == VI_KEY( ALT_TAB ) || event == VI_KEY( CTRL_TAB ) ) {
            saveStr( input );
            curr = searchHistory( input, str, curr );
            displayLine( input );
            event = GetNextEvent( true );
            continue;
        }
        KeyAdd( event );
        return;
    }

} /* doHistorySearch */
Esempio n. 30
0
BOOL CDockContext::Track()
{
	// don't handle if capture already set
	if (::GetCapture() != NULL)
		return FALSE;

	// set capture to the window which received this message
	m_pBar->SetCapture();
	ASSERT(m_pBar == CWnd::GetCapture());

#ifndef _MAC
	// get messages until capture lost or cancelled/accepted
	while (CWnd::GetCapture() == m_pBar)
	{
		MSG msg;
		if (!::GetMessage(&msg, NULL, 0, 0))
		{
			AfxPostQuitMessage(msg.wParam);
			break;
		}

		switch (msg.message)
		{
		case WM_LBUTTONUP:
			if (m_bDragging)
				EndDrag();
			else
				EndResize();
			return TRUE;
		case WM_MOUSEMOVE:
			if (m_bDragging)
				Move(msg.pt);
			else
				Stretch(msg.pt);
			break;
		case WM_KEYUP:
			if (m_bDragging)
				OnKey((int)msg.wParam, FALSE);
			break;
		case WM_KEYDOWN:
			if (m_bDragging)
				OnKey((int)msg.wParam, TRUE);
			if (msg.wParam == VK_ESCAPE)
			{
				CancelLoop();
				return FALSE;
			}
			break;
		case WM_RBUTTONDOWN:
			CancelLoop();
			return FALSE;

		// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}
#else
	Point   ptCur = {0};

	// get messages until capture lost or cancelled/accepted
	while (CWnd::GetCapture() == m_pBar)
	{
		EventRecord     er;

		if (OSEventAvail(everyEvent, &er))
		{
			GetNextEvent(everyEvent, &er);
			switch (er.what)
			{
			case mouseUp:
				if (m_bDragging)
					EndDrag();
				else
					EndResize();
				return TRUE;

			case keyDown:
			case keyUp:
			case autoKey:
			case app2Evt:
			{
				MSG     msg;

				if (WrapEvent(&er, &msg, PM_REMOVE))
				{
					if (m_bDragging)
						OnKey((int)msg.wParam, msg.message == WM_KEYDOWN);
					if (msg.message == WM_KEYUP && msg.wParam == VK_ESCAPE)
					{
						CancelLoop();
						return FALSE;
					}
				}
				break;
			}

			default:
				break;
			}
		}
		else
		{
			if (!EqualPt(er.where, ptCur))
			{
				POINT pt = {er.where.h, er.where.v};
				if (m_bDragging)
					Move(pt);
				else
					Stretch(pt);
			}
		}
	}
#endif
	CancelLoop();

	return FALSE;
}