示例#1
0
bool GUI_TextField::HandleEvent(const char *action)
{
    if (!strcmp(action, "accept")) {
        GUI_Page *page = GetPage();
        if (page) {
            page->UpdateFocusWidget(1);
            page->DecRef();
        }
        return true;
    } else
    if (!strcmp(action, "prev")) {
        SetCursorPos(GetCursorPos() - 1);
        InputDigit(-1);
        return true;
    } else
    if (!strcmp(action, "next")) {
        SetCursorPos(GetCursorPos() + 1);
        InputDigit(-1);
        return true;
    } else
    if ((GetFlags() & WIDGET_FOCUSED &&
         (!strcmp(action, "stop") ||
          !strcmp(action, "cancel"))) ||
        !strcmp(action, "clear") ||
        !strcmp(action, "backspace")) {
        Backspace();
        InputDigit(-1);
        return true;
    } else
    if (!strcmp(action, "delete")) {
        DeleteCurrChar();
        InputDigit(-1);
        return true;
    } else
    if (!strcmp(action, "home") ||
        !strcmp(action, "first")) {
        SetCursorPos(0);
        InputDigit(-1);
        return true;
    } else
    if (!strcmp(action, "end") ||
        !strcmp(action, "last")) {
        SetCursorPos(GetTextLength());
        InputDigit(-1);
        return true;
    } else
    if (!strncmp(action, "key", 3) &&
        strlen(action) == 4) {
        SendChar(action[3], true);
        InputDigit(-1);
        return true;
    } else
    if (!strncmp(action, "number", 6) &&
        strlen(action) == 7 &&
        isdigit(action[6])) {
        InputDigit(atoi(action + 6));
        return true;
    }
    return GUI_Widget::HandleEvent(action);
}
示例#2
0
bool GUI_TextField::HandleKeyEvent(const SDL_Event * event)
{
    if (IsFocused()) {
        int key = event->key.keysym.sym;
        int ch = event->key.keysym.unicode;
        switch (key) {
        case SDLK_RIGHT:
            SetCursorPos(cursorpos + 1);
            return 1;
        case SDLK_LEFT:
            SetCursorPos(cursorpos - 1);
            return 1;
        case SDLK_DELETE:
            DeleteCurrChar();
            return 1;
        case SDLK_BACKSPACE:
            Backspace();
            return 1;
        case SDLK_HOME:
            SetCursorPos(0);
            return 1;
        case SDLK_END:
            SetCursorPos(strlen(buffer));
            return 1;
        case SDLK_RETURN:
            break;
        }
        if (ch >= 32 && ch <= 126) {
            SendChar(ch, true);
            return 1;
        }
    }
    return GUI_Widget::HandleKeyEvent(event);
}
void CGUIDialogKeyboardGeneric::OnClickButton(int iButtonControl)
{
  if (iButtonControl == CTL_BUTTON_BACKSPACE)
  {
    Backspace();
  }
  else
    Character(GetCharacter(iButtonControl));
}
static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key)
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);
    unsigned int c;

    if (!inputbox->editing)
    {
        if (key == KEY_ABUTTON)
        {
            StartEditing(inputbox);
            return 1;
        }

        // Backspace or delete erases the contents of the box.

        if ((key == KEY_DEL || key == KEY_BACKSPACE)
         && inputbox->widget.widget_class == &txt_inputbox_class)
        {
            free(*((char **)inputbox->value));
            *((char **) inputbox->value) = strdup("");
        }

        return 0;
    }

    if (key == KEY_ABUTTON)
    {
        FinishEditing(inputbox);
    }

    if (key == KEY_BBUTTON)
    {
        inputbox->editing = 0;
    }

    if (key == KEY_BACKSPACE)
    {
        Backspace(inputbox);
    }

    c = TXT_KEY_TO_UNICODE(key);

    // Add character to the buffer, but only if it's a printable character
    // that we can represent on the screen.
    if (isprint(c)
     || (c >= 128 && TXT_CanDrawCharacter(c)))
    {
        AddCharacter(inputbox, c);
    }

    return 1;
}
示例#5
0
static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key)
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);
    unsigned int c;

    if (!inputbox->editing)
    {
        if (key == KEY_ENTER)
        {
            StartEditing(inputbox);
            return 1;
        }

        // Backspace or delete erases the contents of the box.

        if ((key == KEY_DEL || key == KEY_BACKSPACE)
         && inputbox->widget.widget_class == &txt_inputbox_class)
        {
            free(*((char **)inputbox->value));
            *((char **) inputbox->value) = strdup("");
        }

        return 0;
    }

    if (key == KEY_ENTER)
    {
        FinishEditing(inputbox);
    }

    if (key == KEY_ESCAPE)
    {
        inputbox->editing = 0;
    }

    if (key == KEY_BACKSPACE)
    {
        Backspace(inputbox);
    }

    c = TXT_KEY_TO_UNICODE(key);

    if (c >= 128 || isprint(c))
    {
        // Add character to the buffer

        AddCharacter(inputbox, c);
    }

    return 1;
}
static int TXT_InputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key)
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);

    if (!inputbox->editing)
    {
        if (key == KEY_ENTER)
        {
            SetBufferFromValue(inputbox);
            inputbox->editing = 1;
            return 1;
        }

        return 0;
    }

    if (key == KEY_ENTER)
    {
        free(*((char **)inputbox->value));
        *((char **) inputbox->value) = strdup(inputbox->buffer);

        TXT_EmitSignal(&inputbox->widget, "changed");

        inputbox->editing = 0;
    }

    if (key == KEY_ESCAPE)
    {
        inputbox->editing = 0;
    }

    if (isprint(key))
    {
        // Add character to the buffer

        AddCharacter(inputbox, key);
    }

    if (key == KEY_BACKSPACE)
    {
        Backspace(inputbox);
    }
    
    return 1;
}
static int TXT_IntInputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key)
{
    TXT_CAST_ARG(txt_inputbox_t, inputbox);

    if (!inputbox->editing)
    {
        if (key == KEY_ENTER)
        {
            strcpy(inputbox->buffer, "");
            inputbox->editing = 1;
            return 1;
        }

        return 0;
    }

    if (key == KEY_ENTER)
    {
        *((int *) inputbox->value) = atoi(inputbox->buffer);

        inputbox->editing = 0;
    }

    if (key == KEY_ESCAPE)
    {
        inputbox->editing = 0;
    }

    if (isdigit(key))
    {
        // Add character to the buffer

        AddCharacter(inputbox, key);
    }

    if (key == KEY_BACKSPACE)
    {
        Backspace(inputbox);
    }
    
    return 1;
}
示例#8
0
int MyInputPanel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: characterGenerated((*reinterpret_cast< QChar(*)>(_a[1]))); break;
        case 1: BackSpaceSignal(); break;
        case 2: EnterSignal(); break;
        case 3: saveFocusWidget((*reinterpret_cast< QWidget*(*)>(_a[1])),(*reinterpret_cast< QWidget*(*)>(_a[2]))); break;
        case 4: buttonClicked((*reinterpret_cast< QWidget*(*)>(_a[1]))); break;
        case 5: Backspace(); break;
        case 6: Enter(); break;
        default: ;
        }
        _id -= 7;
    }
    return _id;
}
void CGUIDialogKeyboardGeneric::OnRemoteNumberClick(int key)
{
  unsigned int now = CTimeUtils::GetFrameTime();

  if (m_lastRemoteClickTime)
  { // a remote key has been pressed
    if (key != m_lastRemoteKeyClicked || m_lastRemoteClickTime + REMOTE_SMS_DELAY < now)
    { // a different key was clicked than last time, or we have timed out
      m_lastRemoteKeyClicked = key;
      m_indexInSeries = 0;
      // reset our shift and symbol states, and update our label to ensure the search filter is sent
      ResetShiftAndSymbols();
      UpdateLabel();
    }
    else
    { // same key as last time within the appropriate time period
      m_indexInSeries++;
      Backspace();
    }
  }
  else
  { // key is pressed for the first time
    m_lastRemoteKeyClicked = key;
    m_indexInSeries = 0;
  }

  int arrayIndex = key - REMOTE_0;
  m_indexInSeries = m_indexInSeries % strlen(s_charsSeries[arrayIndex]);
  m_lastRemoteClickTime = now;

  // Select the character that will be pressed
  const char* characterPressed = s_charsSeries[arrayIndex];
  characterPressed += m_indexInSeries;

  // use caps where appropriate
  char ch = *characterPressed;
  bool caps = (m_keyType == CAPS && !m_bShift) || (m_keyType == LOWER && m_bShift);
  if (!caps && *characterPressed >= 'A' && *characterPressed <= 'Z')
    ch += 32;
  Character(ch);
}
void CGUIDialogKeyboardGeneric::OnClickButton(int iButtonControl)
{
    if (iButtonControl == CTL_BUTTON_BACKSPACE)
    {
        Backspace();
    }
    else if (iButtonControl == CTL_BUTTON_SPACE)
    {
        Character(" ");
    }
    else
    {
        const CGUIControl* pButton = GetControl(iButtonControl);
        if (pButton)
        {
            Character(pButton->GetDescription());
            // reset the shift keys
            if (m_bShift) OnShift();
        }
    }
}
示例#11
0
bool CGenericSerialConsole::ProcessChar ( const uint8_t c )
{
  // When the user inserts characters at the command's beginning,
  // a number of bytes are sent to the terminal, depending on the command length.

  bool isCmdReady = false;

  switch ( c )
  {
  case 0x1B: // Escape
    m_state = stEscapeReceived;
    break;

    // When you press the ENTER key, most terminal emulators send either a single LF or the (CR, LF) sequence.
  case 0x0A: // LF, \n
  case 0x0D: // Enter pressed (CR, \r)
    isCmdReady = true;
    break;

  case 0x02: // ^B (left arrow)
    LeftArrow();
    break;

  case 0x06: // ^F (right arrow)
    RightArrow();
    break;

  case 0x08: // Backspace (^H).
  case 0x7F: // For me, that's the backspace key.
    Backspace();
    break;

  default:
    InsertChar( c );
    break;
  }

  return isCmdReady;
}
void TextTerminal::PutChar(TextBuffer* textbuf, char c)
{
	if ( ansimode )
		return PutAnsiEscaped(textbuf, c);

	if ( mbsinit(&ps) )
	{
		switch ( c )
		{
		case '\n': Newline(textbuf); return;
		case '\r': column = 0; return;
		case '\b': Backspace(textbuf); return;
		case '\t': Tab(textbuf); return;
		case '\e': AnsiReset(); return;
		case 127: return;
		default: break;
		}
	}

	wchar_t wc;
	size_t result = mbrtowc(&wc, &c, 1, &ps);
	if ( result == (size_t) -2 )
		return;
	if ( result == (size_t) -1 )
	{
		memset(&ps, 0, sizeof(ps));
		wc = L'�';
	}
	if ( result == (size_t) 0 )
		wc = L' ';

	if ( textbuf->Width() <= column )
		Newline(textbuf);
	TextPos pos(column++, line);
	TextChar tc(wc, vgacolor, ATTR_CHAR | next_attr);
	textbuf->SetChar(pos, tc);
	next_attr = 0;
}
示例#13
0
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled(true);
  if (action.GetID() == ACTION_BACKSPACE)
  {
    Backspace();
  }
  else if (action.GetID() == ACTION_ENTER)
  {
    OnOK();
  }
  else if (action.GetID() == ACTION_CURSOR_LEFT)
  {
    MoveCursor( -1);
  }
  else if (action.GetID() == ACTION_CURSOR_RIGHT)
  {
    MoveCursor(1);
  }
  else if (action.GetID() == ACTION_SHIFT)
  {
    OnShift();
  }
  else if (action.GetID() == ACTION_SYMBOLS)
  {
    OnSymbols();
  }
  else if (action.GetID() >= KEY_ASCII)
  { // send action to the edit control
    CGUIControl *edit = GetControl(CTL_EDIT);
    if (edit)
      edit->OnAction(action);
  }
  else // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  return handled;
}
示例#14
0
static void DelChar(int xc, int yc)
{
	if (yc == YC_CAMPAIGNTITLE) {
		switch (xc) {
		case XC_CAMPAIGNTITLE:
			Backspace(campaign.title);
			break;
		case XC_AUTHOR:
			Backspace(campaign.author);
			break;
		case XC_CAMPAIGNDESC:
			Backspace(campaign.description);
			break;
		}
	}

	if (!currentMission)
		return;

	switch (yc) {
	case YC_MISSIONTITLE:
		if (xc == XC_MUSICFILE)
			Backspace(currentMission->song);
		else
			Backspace(currentMission->title);
		break;

	case YC_MISSIONDESC:
		Backspace(currentMission->description);
		break;

	default:
		if (yc - YC_OBJECTIVES < currentMission->objectiveCount)
			Backspace(currentMission->
				  objectives[yc -
					     YC_OBJECTIVES].description);
		break;
	}
}
示例#15
0
/*****************************************************************************
 * FUNCTION: IperfConsoleProcess
 *
 * RETURNS: None
 *
 * PARAMS:  None
 *
 * NOTES:   State machine called from main loop of app.  Handles serial input.
 *
 *****************************************************************************/
void IperfConsoleProcess(void)
{
    //uint8_t *pStart = &(cmdline[0]);
    int8_t  c;
    static int8_t escape_sequence[kMaxInputEscapeSequence];
    static int8_t esc_seq_index;

    // if this state machine has been disabled
    if (g_ConsoleContext.bStateMachineLoop == false)
    {
        return;
    }


    // if a command was entered that is application=specific
    if (g_ConsoleContext.appConsoleMsgRx == true)
    {
        return;  // wait until app done before processing further characters
    }

    // if no character(s) received
    if (SYS_CONSOLE_DATA_RDY() == 0)
    {
        return;
    }

    // get the character
    c = (int8_t) SYS_CONSOLE_GETC();

    // if this is the very first character received by this state machine
    if (g_ConsoleContext.firstChar == false)
    {
        Output_Monitor_Hdr();
        g_ConsoleContext.firstChar = true;
    }

    switch( GET_RX_STATE() )
    {
        //------------------------------------------
        case kSTWaitForChar:
        //------------------------------------------
            // if a 'normal' printable character
            if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
            }
            // else if Delete key
            else if (c == kDelete)
            {
                Delete();
            }
            // else if Backspace key
            else if (c == (int8_t)kBackspace)
            {
                Backspace();
            }
            // else if Enter key
            else if (c == kEnter)
            {
                Enter();
            }
            // else if Escape key
            else if (c == kEscape)
            {
                /* zero out escape buffer, init with ESC */
                memset(escape_sequence, 0x00, sizeof(escape_sequence));
                escape_sequence[0] = kEscape;
                esc_seq_index = 1;
                SET_RX_STATE(kSTWaitForEscSeqSecondChar);
            }
            // else if Ctrl C
            else if (c == kCtrl_C)
            {
               OutputCommandPrompt();
            }
            else {
                // Enter();
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqSecondChar:
        //------------------------------------------
            /* if an arrow key, home, or end key (which is all that this state machine handles) */
            if (c == 0x5b)
            {
               escape_sequence[1] = c;
               SET_RX_STATE(kSTWaitForEscSeqThirdChar);
            }
            // else if user pressed escape followed by any printable character
            else if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
                SET_RX_STATE(kSTWaitForChar);
            }
            // start this command line over
            else // anything else
            {
                OutputCommandPrompt();
                SET_RX_STATE(kSTWaitForChar);
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqThirdChar:
        //------------------------------------------
            escape_sequence[2] = c;
            
            if ((c == 0x31) || (c == 0x34))   // home or end key
            {
                SET_RX_STATE(kSTWaitForEscSeqFourthChar);
            }
            else
            {    
                ProcessEscapeSequence(escape_sequence);
                SET_RX_STATE(kSTWaitForChar);
            }    
            break;
            
        //------------------------------------------            
        case kSTWaitForEscSeqFourthChar:
        //------------------------------------------
            ProcessEscapeSequence(escape_sequence);
            SET_RX_STATE(kSTWaitForChar);
            break;
            


    } // end switch
}
示例#16
0
bool CGUIDialogKeyboard::OnAction(const CAction &action)
{
  // check if we're doing a search, and if so, interrupt the search timer.
  DWORD now = timeGetTime();
  if (m_lastSearchUpdate || m_lastSearchUpdate + SEARCH_DELAY >= now)
    m_lastSearchUpdate = now;

  if (action.wID == ACTION_BACKSPACE
#ifdef __APPLE__
     || action.wID == ACTION_PARENT_DIR
#endif
     )
  {
    Backspace();
    return true;
  }
  else if (action.wID == ACTION_ENTER)
  {
    OnOK();
    return true;
  }
  else if (action.wID == ACTION_CURSOR_LEFT)
  {
    MoveCursor( -1);
    return true;
  }
  else if (action.wID == ACTION_CURSOR_RIGHT)
  {
    if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' '))
    { // add a space
      Character(L' ');
    }
    else
      MoveCursor(1);
    return true;
  }
  else if (action.wID == ACTION_SHIFT)
  {
    OnShift();
    return true;
  }
  else if (action.wID == ACTION_SYMBOLS)
  {
    OnSymbols();
    return true;
  }
  else if (action.wID >= REMOTE_0 && action.wID <= REMOTE_9)
  {
    OnRemoteNumberClick(action.wID);
    return true;
  }
  else if (action.wID >= (WORD)KEY_VKEY && action.wID < (WORD)KEY_ASCII)
  { // input from the keyboard (vkey, not ascii)
    BYTE b = action.wID & 0xFF;
    if (b == 0x25) MoveCursor( -1);     // left
    else if (b == 0x27) MoveCursor(1);  // right
    else if (b == 0x0D) OnOK();         // enter
    else if (b == 0x08) Backspace();    // backspace
    else if (b == 0x1B) Close();        // escape
    else if (b == 0x20) Character(b);   // space
    return true;
  }
  else if (action.wID >= KEY_ASCII)
  { // input from the keyboard
    //char ch = action.wID & 0xFF;
    switch (action.unicode)
    {
    case 13:  // enter
    case 10:  // enter
      OnOK();
      break;
    case 8:   // backspace
      Backspace();
      break;
    case 27:  // escape
      Close();
      break;
    default:  //use character input
      Character(action.unicode);
      break;
    }
    return true;
  }
  return CGUIDialog::OnAction(action);
}
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled(true);
  if (action.GetID() == ACTION_BACKSPACE)
  {
    Backspace();
  }
  else if (action.GetID() == ACTION_ENTER)
  {
    OnOK();
  }
  else if (action.GetID() == ACTION_CURSOR_LEFT)
  {
    MoveCursor( -1);
  }
  else if (action.GetID() == ACTION_CURSOR_RIGHT)
  {
    if (m_strEditing.empty() && (unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' '))
    { // add a space
      Character(L' ');
    }
    else
      MoveCursor(1);
  }
  else if (action.GetID() == ACTION_SHIFT)
  {
    OnShift();
  }
  else if (action.GetID() == ACTION_SYMBOLS)
  {
    OnSymbols();
  }
  else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
  {
    OnRemoteNumberClick(action.GetID());
  }
  else if (action.GetID() == ACTION_PASTE)
  {
    OnPasteClipboard();
  }
  else if ( (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII) ||
  			(action.GetButtonCode() >= KEY_VKEY && action.GetButtonCode() < KEY_ASCII) )
  { // input from the keyboard (vkey, not ascii)
    if (!m_strEditing.empty())
      return handled;
    uint8_t b = action.GetButtonCode() ? action.GetButtonCode() & 0xFF : action.GetID() & 0xFF;
    
    switch (b)
    {
	case XBMCVK_HOME:
    	SetCursorPos(0);
    	break;
    case XBMCVK_END:
	    SetCursorPos(m_strEdit.size());
    	break;
    case XBMCVK_LEFT:
    	MoveCursor( -1);
    	break;
    case XBMCVK_RIGHT:
    	MoveCursor(1);
    	break;
    case XBMCVK_RETURN:
    case XBMCVK_NUMPADENTER:
    	OnOK();
    	break;
    case XBMCVK_DELETE:
		if (GetCursorPos() < (int)m_strEdit.size())
		{
			MoveCursor(1);
			Backspace();
		}
    	break;
    case XBMCVK_BACK:
    	Backspace();
    	break;
    case XBMCVK_ESCAPE:
    	Close();
    	break;
    case XBMCVK_LSHIFT:
    case XBMCVK_RSHIFT:
		OnShift();
		break;
	case XBMCVK_CAPSLOCK:
		OnCapsLock();
		break;
	}	
  }
  else if (action.GetID() >= KEY_ASCII)
  { // input from the keyboard
    //char ch = action.GetID() & 0xFF;
    int ch = action.GetUnicode();
    
    if( m_keyType == LOWER && m_bShift )
    {
		if (ch >= 'a' && ch <= 'z')
    		ch -= 32;
    		
    	OnShift();	
	}	
	else if( m_keyType == CAPS && !m_bShift )
	{
		if (ch >= 'a' && ch <= 'z')
    		ch -= 32;
    }
    else if( m_keyType == CAPS && m_bShift )
    	OnShift();
   		
    // Ignore non-printing characters
    if ( !((0 <= ch && ch < 0x8) || (0xE <= ch && ch < 0x1B) || (0x1C <= ch && ch < 0x20)) )
    {
      switch (ch)
      {
      case 0x8: // backspace
        Backspace();
        break;
      case 0x9: // Tab (do nothing)
      case 0xB: // Non-printing character, ignore
      case 0xC: // Non-printing character, ignore
        break;
      case 0xA: // enter
      case 0xD: // enter
        OnOK();
        break;
      case 0x1B: // escape
        Close();
        break;
      case 0x7F: // Delete
        if (GetCursorPos() < (int)m_strEdit.size())
        {
          MoveCursor(1);
          Backspace();
        }
        break;
      default:  //use character input
        // When we support text input method, we only accept text by gui text message.
        if (!g_Windowing.IsTextInputEnabled())
	        Character(ch);
	        //Character(action.GetUnicode());
        break;
      }
    }
  }
  else // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  if (handled && m_pCharCallback)
  { // we did _something_, so make sure our search message filter is reset
    m_pCharCallback(this, GetText());
  }
  return handled;
}
示例#18
0
bool CGUIDialogKeyboardGeneric::OnAction(const CAction &action)
{
  bool handled(true);
  if (action.GetID() == ACTION_BACKSPACE)
  {
    Backspace();
  }
  else if (action.GetID() == ACTION_ENTER)
  {
    OnOK();
  }
  else if (action.GetID() == ACTION_CURSOR_LEFT)
  {
    MoveCursor( -1);
  }
  else if (action.GetID() == ACTION_CURSOR_RIGHT)
  {
    if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' '))
    { // add a space
      Character(L' ');
    }
    else
      MoveCursor(1);
  }
  else if (action.GetID() == ACTION_SHIFT)
  {
    OnShift();
  }
  else if (action.GetID() == ACTION_SYMBOLS)
  {
    OnSymbols();
  }
  else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
  {
    OnRemoteNumberClick(action.GetID());
  }
  else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
  { // input from the keyboard (vkey, not ascii)
    uint8_t b = action.GetID() & 0xFF;
    if (b == XBMCVK_HOME)
    {
      MoveCursor(-GetCursorPos());
    }
    else if (b == XBMCVK_END)
    {
      MoveCursor(m_strEdit.GetLength() - GetCursorPos());
    }
    else if (b == XBMCVK_LEFT)
    {
      MoveCursor( -1);
    }
    else if (b == XBMCVK_RIGHT)
    {
      MoveCursor(1);
    }
    else if (b == XBMCVK_RETURN || b == XBMCVK_NUMPADENTER)
    {
      OnOK();
    }
    else if (b == XBMCVK_DELETE)
    {
      if (GetCursorPos() < m_strEdit.GetLength())
      {
        MoveCursor(1);
        Backspace();
      }
    }
    else if (b == XBMCVK_BACK) Backspace();
    else if (b == XBMCVK_ESCAPE) Close();
  }
  else if (action.GetID() >= KEY_ASCII)
  { // input from the keyboard
    //char ch = action.GetID() & 0xFF;
    switch (action.GetUnicode())
    {
    case 13:  // enter
    case 10:  // enter
      OnOK();
      break;
    case 8:   // backspace
      Backspace();
      break;
    case 27:  // escape
      Close();
      break;
    default:  //use character input
      Character(action.GetUnicode());
      break;
    }
  }
  else // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  if (handled && m_pCharCallback)
  { // we did _something_, so make sure our search message filter is reset
    m_pCharCallback(this, GetText());
  }
  return handled;
}
示例#19
0
/*****************************************************************************
 * FUNCTION: WFConsoleProcess
 *
 * RETURNS: None
 *
 * PARAMS:  None
 *
 * NOTES:   State machine called from main loop of app.  Handles serial input.
 *
 *****************************************************************************/
void WFConsoleProcess(void)
{
    //UINT8 *pStart = &(cmdline[0]);
    UINT16  rc;
    INT8  c;
    static INT8 escape_sequence[kWFMaxInputEscapeSequence];
    static INT8 esc_seq_index;

    // if this state machine has been disabled
    if (g_ConsoleContext.bStateMachineLoop == FALSE)
    {
        return;
    }


    // if a command was entered that is application=specific
    if (g_ConsoleContext.appConsoleMsgRx == TRUE)
    {
        return;  // wait until app done before processing further characters
    }

    // if no character(s) received
    if ( (rc = DataRdyUART() ) == 0u )
    {
        return;
    }

    // get the character
    c = (INT8) ReadUART();

    // if this is the very first character received by this state machine
    if (g_ConsoleContext.firstChar == FALSE)
    {
        Output_Monitor_Hdr();
        g_ConsoleContext.firstChar = TRUE;
    }

    switch( GET_RX_STATE() )
    {
        //------------------------------------------
        case kSTWaitForChar:
        //------------------------------------------
            // if a 'normal' printable character
            if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
            }
            // else if Delete key
            else if (c == kWFDelete)
            {
                Delete();
            }
            // else if Backspace key
            else if (c == (INT8)kWFBackspace)
            {
                Backspace();
            }
            // else if Enter key
            else if (c == kWFEnter)
            {
                Enter();
            }
            // else if Escape key
            else if (c == kWFEscape)
            {
                /* zero out escape buffer, init with ESC */
                memset(escape_sequence, 0x00, sizeof(escape_sequence));
                escape_sequence[0] = kWFEscape;
                esc_seq_index = 1;
                SET_RX_STATE(kSTWaitForEscSeqSecondChar);
            }
            // else if Ctrl C
            else if (c == kWFCtrl_C)
            {
               OutputCommandPrompt();
            }
            else {
                // Enter();
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqSecondChar:
        //------------------------------------------
            /* if an arrow key, home, or end key (which is all that this state machine handles) */
            if (c == 0x5b)
            {
               escape_sequence[1] = c;
               SET_RX_STATE(kSTWaitForEscSeqThirdChar);
            }
            // else if user pressed escape followed by any printable character
            else if (isPrintableCharacter(c))
            {
                InsertCharacter(c);
                SET_RX_STATE(kSTWaitForChar);
            }
            // start this command line over
            else // anything else
            {
                OutputCommandPrompt();
                SET_RX_STATE(kSTWaitForChar);
            }
            break;

        //------------------------------------------
        case kSTWaitForEscSeqThirdChar:
        //------------------------------------------
            escape_sequence[2] = c;
            ProcessEscapeSequence(escape_sequence);
            SET_RX_STATE(kSTWaitForChar);
            break;


    } // end switch
}
示例#20
0
static void VKBBackspace(TXT_UNCAST_ARG(widget), void *userdata)
{
    Backspace(vkb_inputbox);
    VKBUpdateLabel();
}
示例#21
0
bool CGUIDialogKeyboard::OnAction(const CAction &action)
{
  bool handled(true);
  if (action.GetID() == ACTION_BACKSPACE)
  {
    Backspace();
  }
  else if (action.GetID() == ACTION_ENTER)
  {
    OnOK();
  }
  else if (action.GetID() == ACTION_CURSOR_LEFT)
  {
    MoveCursor( -1);
  }
  else if (action.GetID() == ACTION_CURSOR_RIGHT)
  {
    if ((unsigned int) GetCursorPos() == m_strEdit.size() && (m_strEdit.size() == 0 || m_strEdit[m_strEdit.size() - 1] != ' '))
    { // add a space
      Character(L' ');
    }
    else
      MoveCursor(1);
  }
  else if (action.GetID() == ACTION_SHIFT)
  {
    OnShift();
  }
  else if (action.GetID() == ACTION_SYMBOLS)
  {
    OnSymbols();
  }
  else if (action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9)
  {
    OnRemoteNumberClick(action.GetID());
  }
  else if (action.GetID() >= KEY_VKEY && action.GetID() < KEY_ASCII)
  { // input from the keyboard (vkey, not ascii)
    uint8_t b = action.GetID() & 0xFF;
    if (b == 0x88) // home
    {
      MoveCursor(-GetCursorPos());
    }
    else if (b == 0x89) // end
    {
      MoveCursor(m_strEdit.GetLength() - GetCursorPos());
    }
    else if (b == 0x82) // left
    {
      MoveCursor( -1);
    }
    else if (b == 0x83) // right
    {
      MoveCursor(1);
    }
    else if (b == 0x0D || b == 0x65) // enter
    {
      OnOK();
    }
    else if (b == 0x87) // delete
    {
      if (GetCursorPos() < m_strEdit.GetLength())
      {
        MoveCursor(1);
        Backspace();
      }
    }
    else if (b == 0x08) Backspace();    // backspace
    else if (b == 0x1B) Close();        // escape
  }
  else if (action.GetID() >= KEY_ASCII)
  { // input from the keyboard
    //char ch = action.GetID() & 0xFF;
    switch (action.GetUnicode())
    {
    case 13:  // enter
    case 10:  // enter
      OnOK();
      break;
    case 8:   // backspace
      Backspace();
      break;
    case 27:  // escape
      Close();
      break;
    default:  //use character input
      Character(action.GetUnicode());
      break;
    }
  }
  else // unhandled by us - let's see if the baseclass wants it
    handled = CGUIDialog::OnAction(action);

  if (handled && m_filtering == FILTERING_SEARCH)
  { // we did _something_, so make sure our search message filter is reset
    SendSearchMessage();
  }
  return handled;
}
示例#22
0
static int TXT_SpinControlKeyPress(TXT_UNCAST_ARG(spincontrol), int key)
{
    TXT_CAST_ARG(txt_spincontrol_t, spincontrol);

    // Enter to enter edit mode

    if (spincontrol->editing)
    {
        if (key == KEY_ENTER)
        {
            switch (spincontrol->type)
            {
                case TXT_SPINCONTROL_INT:
                    spincontrol->value->i = atoi(spincontrol->buffer);
                    break;

                case TXT_SPINCONTROL_FLOAT:
                    spincontrol->value->f = (float) atof(spincontrol->buffer);
                    break;
            }

            spincontrol->editing = 0;
            EnforceLimits(spincontrol);
            return 1;
        }

        if (key == KEY_ESCAPE)
        {
            // Abort without saving value
            spincontrol->editing = 0;
            return 1;
        }

        if (isdigit(key) || key == '-' || key == '.')
        {
            AddCharacter(spincontrol, key);
            return 1;
        }

        if (key == KEY_BACKSPACE)
        {
            Backspace(spincontrol);
            return 1;
        }
    }
    else
    {
        // Non-editing mode

        if (key == KEY_ENTER)
        {
            spincontrol->editing = 1;
            strcpy(spincontrol->buffer, "");
            return 1;
        }
        if (key == KEY_LEFTARROW)
        {
            switch (spincontrol->type)
            {
                case TXT_SPINCONTROL_INT:
                    spincontrol->value->i -= spincontrol->step.i;
                    break;

                case TXT_SPINCONTROL_FLOAT:
                    spincontrol->value->f -= spincontrol->step.f;
                    break;
            }

            EnforceLimits(spincontrol);

            return 1;
        }
        
        if (key == KEY_RIGHTARROW)
        {
            switch (spincontrol->type)
            {
                case TXT_SPINCONTROL_INT:
                    spincontrol->value->i += spincontrol->step.i;
                    break;

                case TXT_SPINCONTROL_FLOAT:
                    spincontrol->value->f += spincontrol->step.f;
                    break;
            }

            EnforceLimits(spincontrol);

            return 1;
        }
    }

    return 0;
}
示例#23
0
FX_BOOL CPWL_EditCtrl::OnChar(uint16_t nChar, uint32_t nFlag) {
  if (m_bMouseDown)
    return TRUE;

  CPWL_Wnd::OnChar(nChar, nFlag);

  // FILTER
  switch (nChar) {
    case 0x0A:
    case 0x1B:
      return FALSE;
    default:
      break;
  }

  FX_BOOL bCtrl = IsCTRLpressed(nFlag);
  FX_BOOL bAlt = IsALTpressed(nFlag);
  FX_BOOL bShift = IsSHIFTpressed(nFlag);

  uint16_t word = nChar;

  if (bCtrl && !bAlt) {
    switch (nChar) {
      case 'C' - 'A' + 1:
        CopyText();
        return TRUE;
      case 'V' - 'A' + 1:
        PasteText();
        return TRUE;
      case 'X' - 'A' + 1:
        CutText();
        return TRUE;
      case 'A' - 'A' + 1:
        SelectAll();
        return TRUE;
      case 'Z' - 'A' + 1:
        if (bShift)
          Redo();
        else
          Undo();
        return TRUE;
      default:
        if (nChar < 32)
          return FALSE;
    }
  }

  if (IsReadOnly())
    return TRUE;

  if (m_pEdit->IsSelected() && word == FWL_VKEY_Back)
    word = FWL_VKEY_Unknown;

  Clear();

  switch (word) {
    case FWL_VKEY_Back:
      Backspace();
      break;
    case FWL_VKEY_Return:
      InsertReturn();
      break;
    case FWL_VKEY_Unknown:
      break;
    default:
      InsertWord(word, GetCharSet());
      break;
  }

  return TRUE;
}
示例#24
0
bool LineEdit::Key(dword key, int count) {
	NextUndo();
	switch(key) {
	case K_CTRL_UP:
		ScrollUp();
		return true;
	case K_CTRL_DOWN:
		ScrollDown();
		return true;
	case K_INSERT:
		OverWriteMode(!IsOverWriteMode());
		break;
	}
	bool sel = key & K_SHIFT;
	switch(key & ~K_SHIFT) {
	case K_CTRL_LEFT:
		{
			PlaceCaret(GetPrevWord(cursor), sel);
			break;
		}
	case K_CTRL_RIGHT:
		{
			PlaceCaret(GetNextWord(cursor), sel);
			break;
		}
	case K_LEFT:
		MoveLeft(sel);
		break;
	case K_RIGHT:
		MoveRight(sel);
		break;
	case K_HOME:
		MoveHome(sel);
		break;
	case K_END:
		MoveEnd(sel);
		break;
	case K_UP:
		MoveUp(sel);
		break;
	case K_DOWN:
		MoveDown(sel);
		break;
	case K_PAGEUP:
		MovePageUp(sel);
		break;
	case K_PAGEDOWN:
		MovePageDown(sel);
		break;
	case K_CTRL_PAGEUP:
	case K_CTRL_HOME:
		MoveTextBegin(sel);
		break;
	case K_CTRL_PAGEDOWN:
	case K_CTRL_END:
		MoveTextEnd(sel);
		break;
	case K_CTRL_C:
	case K_CTRL_INSERT:
		Copy();
		break;
	case K_CTRL_A:
		SelectAll();
		break;
	default:
		if(IsReadOnly())
			return MenuBar::Scan(WhenBar, key);
		switch(key) {
		case K_DELETE:
			DeleteChar();
			break;
		case K_BACKSPACE:
		case K_SHIFT|K_BACKSPACE:
			Backspace();
			break;
	   	case K_SHIFT_TAB:
			AlignChar();
			break;
		case K_CTRL_Y:
		case K_CTRL_L:
			if(cutline) {
				CutLine();
				break;
			}
		default:
			if(InsertChar(key, count, true))
				return true;
			return MenuBar::Scan(WhenBar, key);
		}
		return true;
	}
	Sync();
	return true;
}