Esempio n. 1
0
STATIC int loadFields(LINEBUF *data, char *field)
{
   int numFields = 0, nc;

   for (
      field = nextField(data, field);
      field != NULL;
      field = nextField(data, field)
   ) {
      if (fieldData[0] == 0) {
         puts("/* Field name too large on header line */");
         numFields = -1;
         break;
      }
      if (numFields == NA) {
         numFields = -1;
         break;
      }
      nc = parseva(caps(fieldData));
      if (nc < 0 || nc >= NA) {
         badInput(fieldData);
         numFields = -1;
         break;
      } else
        fields[numFields++] = nc;
   }
   return numFields;
}
Esempio n. 2
0
STATIC int loadFrame(LINEBUF *data, int numFields)
{
   register int nc;
   char *field, *stopChar;

   nc = -1;

   for (field = getNextLine(data);
      field != NULL && data->isComment;
      field = getNextLine(data)
   ) flushLine(data, NULL);

   if (field != NULL) {
      nc = 0;
      for (
         field = nextField(data, field);
         field != NULL;
         field = nextField(data, field)
      ) {
         if (nc == numFields) {
            nc = 0;
            break;
         }
         A[fields[nc]] = strtod(fieldData, &stopChar);
         if (stopChar == fieldData ||
            (*stopChar != 0 && !isspace(*stopChar))) {
            nc = 0;
            break;
         }
         nc++;
      }
   }
   return nc;
}
Esempio n. 3
0
  /*!
   * \author Anders Fernström and Ingemar Axelsson
   * \date 2006-03-02 (update)
   *
   * \brief Creates the QTextEdit for the input part of the
   * inputcell
   *
   * 2005-10-27 AF, Large part of this function was changes due to
   * porting to QT4 (changes from Q3TextEdit to QTextEdit).
   * 2005-12-15 AF, Added more connections to the editor, mostly for
   * commandcompletion, but also for eval. invoking eval have moved
   * from the eventfilter on this cell to the reimplemented key event
   * handler in the editor
   * 2006-03-02 AF, Added call to createChapterCounter();
   */
  void InputCell::createInputCell()
  {
    input_ = new MyTextEdit( mainWidget() );
    mpModelicaTextHighlighter = new ModelicaTextHighlighter(input_->document());
    layout_->addWidget( input_, 1, 1 );

    // 2006-03-02 AF, Add a chapter counter
    createChapterCounter();

    //input_->setReadOnly( false );
    input_->setReadOnly( true );
    input_->setUndoRedoEnabled( true );
    //input_->setFrameStyle( QFrame::NoFrame );
    input_->setFrameShape( QFrame::Box );
    input_->setAutoFormatting( QTextEdit::AutoNone );

    input_->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    input_->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
//    input_->setContextMenuPolicy( Qt::NoContextMenu );

    QPalette palette;
    palette.setColor(input_->backgroundRole(), QColor(200,200,255));
    input_->setPalette(palette);

    // is this needed, don't know /AF
    input_->installEventFilter(this);


    connect( input_, SIGNAL( textChanged() ),
      this, SLOT( contentChanged() ));

      connect( input_, SIGNAL( clickOnCell() ),
      this, SLOT( clickEvent() ));
    connect( input_, SIGNAL( wheelMove(QWheelEvent*) ),
      this, SLOT( wheelEvent(QWheelEvent*) ));
    // 2005-12-15 AF, new connections
    connect( input_, SIGNAL( eval() ),
      this, SLOT( eval() ));
    connect( input_, SIGNAL( command() ),
      this, SLOT( command() ));
    connect( input_, SIGNAL( nextCommand() ),
      this, SLOT( nextCommand() ));
    connect( input_, SIGNAL( nextField() ),
      this, SLOT( nextField() ));
    //2005-12-29 AF
    connect( input_, SIGNAL( textChanged() ),
      this, SLOT( addToHighlighter() ));
    // 2006-01-17 AF, new...
    connect( input_, SIGNAL( currentCharFormatChanged(const QTextCharFormat &) ),
      this, SLOT( charFormatChanged(const QTextCharFormat &) ));
    // 2006-04-27 AF,
    connect( input_, SIGNAL( forwardAction(int) ),
      this, SIGNAL( forwardAction(int) ));

    contentChanged();
  }
Esempio n. 4
0
std::string getCommand (int argc, const char *argv[],
			const std::string prompt, std::string *pfx)

{ std::string field = "EOL" ;
  pendingVal = "" ;
  int pfxlen ;

  if (pfx != 0)
  { (*pfx) = "" ; }
/*
  Acquire the next field, and convert as outlined above if we're processing
  command line parameters.
*/
  while (field == "EOL")
  { pfxlen = 0 ;
    if (cmdField > 0)
    { if (cmdField < argc)
      { field = argv[cmdField++] ;
	if (field == "-")
	{ field = "stdin" ; }
	else
	if (field == "--")
	{ /* Prevent `--' from being eaten by next case. */ }
	else
	{ if (field[0] == '-')
	  { pfxlen = 1 ;
	    if (field[1] == '-')
	      pfxlen = 2 ;
	    if (pfx != 0)
	      (*pfx) = field.substr(0,pfxlen) ;
	    field = field.substr(pfxlen) ; } } }
      else
      { field = "" ; } }
    else
    { field = nextField(prompt.c_str()) ; }
    if (field == "stdin")
    { std::cout << "Switching to line mode" << std::endl ;
      cmdField = -1 ;
      field = nextField(prompt.c_str()) ; } }
/*
  Are we left with something of the form param=value? If so, separate the
  pieces, returning `param' and saving `value' for later use as per comments
  at the head of the file.
*/
  std::string::size_type found = field.find('=');
  if (found != std::string::npos)
  { pendingVal = field.substr(found+1) ;
    field = field.substr(0,found) ; }

  return (field) ; }
Esempio n. 5
0
    /*
     * \author Anders Fernstrom
     * \date 2005-12-12
     *
     * \brief Insert the next possible command into the text, that match
     * a command
     *
     * \param cursor The text cursor to the text where the command should
     * be inserted
     * \return TURE if a command is inserted
     */
    bool CommandCompletion::nextCommand( QTextCursor &cursor )
    {
        // check if cursor is okej
        if( !cursor.isNull() )
        {
            // check if currentList_ exists
            if( currentCommand_ >= 0 && currentList_ )
            {
                // if no more commands existes, restart
                if( currentCommand_ >= (currentList_->size()-1) )
                    currentCommand_ = -1;

                // reset currentField_
                currentField_ = -1;

                //next command
                currentCommand_++;
                cursor.setPosition( commandStartPos_ );
                cursor.setPosition( commandEndPos_, QTextCursor::KeepAnchor );
                cursor.insertText( currentList_->at( currentCommand_ ));
                commandEndPos_ = cursor.position();

                // select first field, if any
                nextField( cursor );

                return true;
            }
        }

        return false;
    }
Esempio n. 6
0
std::string getStringField (int argc, const char *argv[], int *valid)

{   std::string field ;

    if (pendingVal != "")
    {   field = pendingVal ;
        pendingVal = "" ;
    }
    else
    {   field = "EOL" ;
        if (cmdField > 0)
        {   if (cmdField < argc)
            {
                field = argv[cmdField++] ;
            }
        }
        else
        {
            field = nextField(0) ;
        }
    }

    if (valid != 0)
    {   if (field != "EOL")
        {
            *valid = 0 ;
        }
        else
        {
            *valid = 2 ;
        }
    }

    return (field) ;
}
Esempio n. 7
0
void WLogEntry::Impl::finish()
{
  while (field_ < (int)logger_.fields().size() - 1)
    nextField();

  finishField();
}
Esempio n. 8
0
double getDoubleField (int argc, const char *argv[], int *valid)

{ std::string field ;

  if (pendingVal != "")
  { field = pendingVal ;
    pendingVal = "" ; }
  else
  { field = "EOL" ;
    if (cmdField > 0)
    { if (cmdField < argc)
      { field = argv[cmdField++] ; } }
    else
    { field = nextField(0) ; } }
/*
  The only way to check for parse error here is to set the system variable
  errno to 0 and then see if it's nonzero after we try to convert the string
  to integer.
*/
  double value = 0.0 ;
  errno = 0 ;
  if (field != "EOL")
  { value = atof(field.c_str()) ; }

  if (valid != 0)
  { if (field != "EOL")
    { if (errno == 0)
      { *valid = 0 ; }
      else
      { *valid = 1 ; } }
    else
    { *valid = 2 ; } }

  return (value) ; }
Esempio n. 9
0
    /*
     * \author Anders Fernstrom
     * \date 2005-12-12
     * \date 2005-12-15 (update)
     *
     * \brief Insert a command into the text, if the text match a command
     *
     * 2005-12-15 AF, implemented function
     *
     * \param cursor The text cursor to the text where the command should
     * be inserted
     * \return TURE if a command is inserted
     */
    bool CommandCompletion::insertCommand( QTextCursor &cursor )
    {
        // check if cursor is okej
        if( !cursor.isNull() )
        {
            // first remove any old currentList_
            if( currentList_ )
            {
                delete currentList_;
                currentList_ = 0;
            }

            // reset currentCommand_ && currentField_
            currentCommand_ = -1;
            currentField_ = -1;

            // find current word in text
            cursor.movePosition( QTextCursor::StartOfWord, QTextCursor::KeepAnchor );
            QString command = cursor.selectedText();

            if( !command.isNull() && !command.isEmpty() )
            {
                // check if any comman match the current word in the text
                currentList_ = new QStringList();
                for( int i = 0; i < commandList_.size(); ++i )
                {
                    if( 0 == commandList_.at(i).indexOf( command, 0, Qt::CaseInsensitive ))
                        currentList_->append( commandList_.at(i) );
                }

                //cout << "Found commands (" << command.toStdString() << "):" << endl;
                //for( int i = 0; i < currentList_->size(); ++i )
                //    cout << " >" << currentList_->at(i).toStdString() << endl;

                // found one or more commands that match the word
                if( currentList_->size() > 0 )
                {
                    currentCommand_ = 0;

                    commandStartPos_ = cursor.position();
                    cursor.insertText( currentList_->at( currentCommand_ ));
                    commandEndPos_ = cursor.position();

                    // select first field, if any
                    nextField( cursor );

                    return true;
                }
                else
                {
                    delete currentList_;
                    currentList_ = 0;
                }
            }
        }

        return false;
    }
Esempio n. 10
0
void SCnEditorScene::selectNextField(SCnFieldItem *field)
{
    SCnFieldItem *next = nextField(field);
    if (next != 0)
    {
        unselectItems();
        next->setSelected(true);
        views().first()->centerOn(next);
    }
}
Esempio n. 11
0
/** Gets the next hyphen LingInfoEntry if exists
 This call "increments" the internal hyphen LingInfoEntry pointer.
 If there is no hyphen LingInfo anymore, an empty LingInfoEntry is returned
*/
LingInfoEntry DictionaryEntry::nextHyphenLingInfo() {
    if (m_startAddr == NULL) throw EmptyEntryException();
    if (m_hyphenLingInfo < m_endHyphenLingInfo) {
        unsigned char *hyphenLingInfo = m_hyphenLingInfo;
        nextField(m_hyphenLingInfo);
        return LingInfoEntry(m_key, m_stringStartAddr, m_lingPropertiesStartAddr, hyphenLingInfo);
    }
    else
        return LingInfoEntry();
}
Esempio n. 12
0
/** Gets the next ConcatenatedEntry if exists
 This call "increments" the internal ConcatenatedEntry pointer.
 If there is no Concatenated anymore, an empty ConcatenatedEntry is returned
*/
ConcatenatedEntry DictionaryEntry::nextConcatenated() {
    if (m_startAddr == NULL) throw EmptyEntryException();
    if (m_concatenated < m_endConcatenated) {
        unsigned char *concatenated = m_concatenated;
        nextField(m_concatenated);
        return ConcatenatedEntry(concatenated, m_stringStartAddr);
    }
    else
        return ConcatenatedEntry();
}
Esempio n. 13
0
// Gets the next SingleConcatenatedEntry if exists
// This call "increments" the internal SingleConcatenatedEntry pointer.
// If there is no SingleConcatenated anymore, an empty SingleConcatenatedEntry 
// is returned
SingleConcatenatedEntry ConcatenatedEntry::nextSingleConcatenated() {
    if (m_startAddr == NULL) throw EmptyEntryException();
    if (m_singleConcatenated < m_endAddr) {
        unsigned char *singleConcatenated = m_singleConcatenated;
        getEncodedNumber(m_singleConcatenated);        // Skip <component>
        nextField(m_singleConcatenated);                // Skip <dictionaryEntry>
        return SingleConcatenatedEntry(singleConcatenated, m_stringStartAddr);
    }
    else 
        return SingleConcatenatedEntry();
}
Esempio n. 14
0
    void CouchbaseRowBuilder::getDataResult(const RtlFieldInfo *field, size32_t &len, void * &result)
    {
        const char * value = nextField(field);

        if (!value || !*value)
        {
            NullFieldProcessor p(field);
            rtlStrToDataX(len, result, p.resultChars, p.stringResult);
            return;
        }
        rtlStrToDataX(len, result, strlen(value), value);   // This feels like it may not work to me - will preallocate rather larger than we want
    }
Esempio n. 15
0
    unsigned __int64 CouchbaseRowBuilder::getUnsignedResult(const RtlFieldInfo *field)
    {
        const char * value = nextField(field);
        if (!value || !*value)
        {
            NullFieldProcessor p(field);
            return p.uintResult;
        }

        unsigned __int64 myuint64;
        couchbaseembed::handleDeserializeOutcome(m_tokenDeserializer.deserialize(value, myuint64), "unsigned", value);
        return myuint64;
    }
Esempio n. 16
0
    bool CouchbaseRowBuilder::getBooleanResult(const RtlFieldInfo *field)
    {
        const char * value = nextField(field);

        if (!value && !*value)
        {
            NullFieldProcessor p(field);
            return p.boolResult;
        }

        bool mybool;
        couchbaseembed::handleDeserializeOutcome(m_tokenDeserializer.deserialize(value, mybool), "bool", value);
        return mybool;
    }
Esempio n. 17
0
    double CouchbaseRowBuilder::getRealResult(const RtlFieldInfo *field)
    {
        const char * value = nextField(field);

        if (!value || !*value)
        {
            NullFieldProcessor p(field);
            return p.doubleResult;
        }

        double mydouble;
        couchbaseembed::handleDeserializeOutcome(m_tokenDeserializer.deserialize(value, mydouble), "real", value);
        return mydouble;
    }
Esempio n. 18
0
    void CouchbaseRowBuilder::getUnicodeResult(const RtlFieldInfo *field, size32_t &chars, UChar * &result)
    {
        const char * value = nextField(field);

        if (!value || !*value)
        {
            NullFieldProcessor p(field);
            rtlUnicodeToUnicodeX(chars, result, p.resultChars, p.unicodeResult);
            return;
        }

        unsigned numchars = rtlUtf8Length(strlen(value), value);  // MORE - is it a good assumption that it is utf8 ? Depends how the database is configured I think
        rtlUtf8ToUnicodeX(chars, result, numchars, value);
        return;
    }
Esempio n. 19
0
    void CouchbaseRowBuilder::getDecimalResult(const RtlFieldInfo *field, Decimal &value)
    {
        const char * dvalue = nextField(field);
        if (!dvalue || !*dvalue)
        {
            NullFieldProcessor p(field);
            value.set(p.decimalResult);
            return;
        }

        size32_t chars;
        rtlDataAttr result;
        value.setString(strlen(dvalue), dvalue);
        if (field)
        {
            RtlDecimalTypeInfo *dtype = (RtlDecimalTypeInfo *) field->type;
            value.setPrecision(dtype->getDecimalDigits(), dtype->getDecimalPrecision());
        }
    }
Esempio n. 20
0
UBool
PreparsedUCD::getRangeForAlgNames(UChar32 &start, UChar32 &end, UErrorCode &errorCode) {
    if(U_FAILURE(errorCode)) { return FALSE; }
    if(lineType!=ALG_NAMES_RANGE_LINE) {
        errorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return FALSE;
    }
    firstField();
    const char *field=nextField();
    if(field==NULL) {
        // No range field after the type.
        fprintf(stderr,
                "error in preparsed UCD: missing algnamesrange range field "
                "(no second field) on line %ld\n",
                (long)lineNumber);
        errorCode=U_PARSE_ERROR;
        return FALSE;
    }
    return parseCodePointRange(field, start, end, errorCode);
}
Esempio n. 21
0
int runcmd(WJElement *doc, WJElement *current, char *line)
{
	WJECLIcmd		*command;
	char			*cmd	= line;
	char			*args	= NULL;
	int				i;

	// cmd = nextField(line, &args);

	/* Look for a command using the letter, which does NOT require a space */
	for (i = 0; (command = &WJECLIcmds[i]) && command->name; i++) {
		if (command->letter != '\0' && *cmd == command->letter) {
			args = skipspace(++cmd);
			break;
		}
	}

	/* Look for a full command */
	if (!command || !command->name) {
		cmd = nextField(line, &args);

		for (i = 0; (command = &WJECLIcmds[i]) && command->name; i++) {
			if (!stricmp(cmd, command->name)) {
				break;
			}
		}
	}

	if (!*current) {
		*current = *doc;
	}

	if (command && command->name) {
		return(command->cb(doc, current, args));
	} else {
		fprintf(stderr, "Unknown command: %s\n", cmd);
		return(3);
	}
}
Esempio n. 22
0
AREXPORT int ArNMEAParser::parse(const char *buf, int n)
{
  int result = 0;
  if (n < 0) 
  {
    return result|ParseError;
  }

  if (n == 0) 
  {
    return result|ParseFinished;
  }

#ifdef DEBUG_ARNMEAPARSER
  std::cerr << "\t[ArNMEAParser: given " << n << " bytes of data.]\n";
  std::cerr << "\t[ArNMEAParser: parsing chunk \"";
  ArNMEAParser_printBuf(stderr, buf, n);
  std::cerr << "\"]\n";
#endif


  for (int i = 0; i < n; i++)
  {
    // Check for message start
    if (buf[i] == '$')
    {
      beginMessage();
      continue;
    }

    // Otherwise, we must be in a sentece to do anything
    if (!inMessage)
      continue;

    // Reached the CRLF at the end?
    if (buf[i] == '\r') 
    {
      gotCR = true;
      continue;
    }
    if (buf[i] == '\n') 
    {
      if (gotCR) 
      {
        Message msg;
        msg.message = &currentMessage;
        msg.timeParseStarted = currentMessageStarted;
        HandlerMap::iterator h = myHandlers.find(currentMessage[0]);
        if (h != myHandlers.end()) 
        {
#ifdef DEBUG_ARNMEAPARSER
          fprintf(stderr, "\t[ArNMEAParser: Got complete message, calling handler for %s...]\n", currentMessage[0].c_str());
#endif
          h->second->invoke(msg);
          result |= ParseUpdated;
        }
        endMessage();
      }

      // a syntax error or no data, abort the message and start looking for the next one.
      if(currentField != "")
        ArLog::log(ArLog::Normal, "ArNMEAParser: Warning: NMEA parse error (currentField=\"%s\"), resetting parser.", currentField.c_str());
      endMessage();
      continue;
    }

    // Are we in the final checksum field?
    if (inChecksum)
    {
      checksumBuf[checksumBufOffset++] = buf[i];
      if (checksumBufOffset > 1)   // two bytes of checksum
      {
        int checksumRec = (int) strtol(checksumBuf, NULL, 16);
        if (checksumRec != currentChecksum) 
        {
          ArLog::log(ArLog::Normal, "%s: Warning: Skipping message with incorrect checksum.", myName);
          std::string nmeaText = "";
          for(MessageVector::const_iterator i = currentMessage.begin(); i != currentMessage.end(); ++i)
          {
            if(i != currentMessage.begin()) nmeaText += ",";
            nmeaText += *i;
          }
          ArLog::log(ArLog::Normal, "%s: Message provided checksum \"%s\" = 0x%x (%d). Calculated checksum is 0x%x (%d).  NMEA message ID was: \"%s\"", myName, checksumBuf, checksumRec, checksumRec, currentChecksum, currentChecksum, nmeaText.c_str());
          // abort the message and start looking for the next one.
          endMessage();
        }
      }
      continue;
    }


    // Got to the checksum?
    if (buf[i] == '*')
    {
      nextField();
      if (!ignoreChecksum)
        beginChecksum();
      continue;
    }

    // Every byte in a message between $ and * XORs to form the
    // checksum:
    currentChecksum ^= buf[i];

    // Time to start a new field?
    if (buf[i] == ',')
    {
      nextField();
      continue;
    }


    // Else, we must be in the middle of a field
    // TODO we could use strchr to look ahead in the buf 
    // for the end of the field (',' or '*') or end of the buf, and copy more
    // than one byte at a time.
    currentField += buf[i];
    if (currentField.size() > MaxFieldSize)
    {
      endMessage();
      continue;
    }
  }

  return result;
}
Esempio n. 23
0
 virtual double getRealResult(const RtlFieldInfo *field)
 {
     nextField(field);
     return sqlite3embed::getRealResult(field, val);
 }
Esempio n. 24
0
QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByteArray &cookieString)
{
    // According to http://wp.netscape.com/newsref/std/cookie_spec.html,<
    // the Set-Cookie response header is of the format:
    //
    //   Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
    //
    // where only the NAME=VALUE part is mandatory
    //
    // We do not support RFC 2965 Set-Cookie2-style cookies

    QList<QNetworkCookie> result;
    QDateTime now = QDateTime::currentDateTime().toUTC();

    int position = 0;
    const int length = cookieString.length();
    while (position < length) {
        QNetworkCookie cookie;

        // The first part is always the "NAME=VALUE" part
        QPair<QByteArray,QByteArray> field = nextField(cookieString, position, true);
        if (field.first.isEmpty() || field.second.isNull())
            // parsing error
            break;
        cookie.setName(field.first);
        cookie.setValue(field.second);

        position = nextNonWhitespace(cookieString, position);
        bool endOfCookie = false;
        while (!endOfCookie && position < length) {
            switch (cookieString.at(position++)) {
            case ',':
                // end of the cookie
                endOfCookie = true;
                break;

            case ';':
                // new field in the cookie
                field = nextField(cookieString, position, false);
                field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive

                if (field.first == "expires") {
                    position -= field.second.length();
                    int end;
                    for (end = position; end < length; ++end)
                        if (isValueSeparator(cookieString.at(end)))
                            break;

                    QByteArray dateString = cookieString.mid(position, end - position).trimmed();
                    position = end;
                    QDateTime dt = parseDateString(dateString.toLower());
                    if (!dt.isValid()) {
                        return result;
                    }
                    cookie.setExpirationDate(dt);
                } else if (field.first == "domain") {
                    QByteArray rawDomain = field.second;
                    QString maybeLeadingDot;
                    if (rawDomain.startsWith('.')) {
                        maybeLeadingDot = QLatin1Char('.');
                        rawDomain = rawDomain.mid(1);
                    }

                    QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain)));
                    if (normalizedDomain.isEmpty() && !rawDomain.isEmpty())
                        return result;
                    cookie.setDomain(maybeLeadingDot + normalizedDomain);
                } else if (field.first == "max-age") {
                    bool ok = false;
                    int secs = field.second.toInt(&ok);
                    if (!ok)
                        return result;
                    cookie.setExpirationDate(now.addSecs(secs));
                } else if (field.first == "path") {
                    QString path = QUrl::fromPercentEncoding(field.second);
                    cookie.setPath(path);
                } else if (field.first == "secure") {
                    cookie.setSecure(true);
                } else if (field.first == "httponly") {
                    cookie.setHttpOnly(true);
                } else if (field.first == "comment") {
                    //cookie.setComment(QString::fromUtf8(field.second));
                } else if (field.first == "version") {
                    if (field.second != "1") {
                        // oops, we don't know how to handle this cookie
                        return result;
                    }
                } else {
                    // got an unknown field in the cookie
                    // what do we do?
                }

                position = nextNonWhitespace(cookieString, position);
            }
        }

        if (!cookie.name().isEmpty())
            result += cookie;
    }

    return result;
}
Esempio n. 25
0
  /*!
   * \author Anders Fernström
   * \date 2005-12-15
   * \date 2006-01-30 (update)
   *
   * \brief Handles key event, check if command completion or eval,
   * otherwise send them to the textbrowser
   *
   * 2006-01-30 AF, added ignore to 'Alt+Enter'
   */
  void MyTextEdit::keyPressEvent(QKeyEvent *event )
  {

    // EVAL, key: SHIFT + RETURN || SHIFT + ENTER
    if( event->modifiers() == Qt::ShiftModifier &&

      (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) )
    {
      inCommand = false;

      event->accept();
      emit eval();
    }
    // COMMAND COMPLETION, key: SHIFT + TAB (= BACKTAB) || CTRL + SPACE
    else if( (event->modifiers() == Qt::ShiftModifier && event->key() == Qt::Key_Backtab ) ||
      (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_Space) )
    {

      event->accept();
      if( inCommand )
      {
        emit nextCommand();
      }
      else
      {
        inCommand = true;
        emit command();
      }
    }
    // COMMAND COMPLETION- NEXT FIELD, key: CTRL + TAB
    else if( event->modifiers() == Qt::ControlModifier &&
      event->key() == Qt::Key_Tab )
    {

      event->accept();
      inCommand = false;
      emit nextField();
    }
    // BACKSPACE, DELETE
    else if( event->key() == Qt::Key_Backspace ||
      event->key() == Qt::Key_Delete )
    {
      inCommand = false;

      QTextBrowser::keyPressEvent( event );
    }
    // ALT+ENTER (ignore)
    else if( event->modifiers() == Qt::AltModifier &&
      ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ))
    {
      inCommand = false;

      event->ignore();
    }
    // PAGE UP (ignore)
    else if( event->key() == Qt::Key_PageUp )
    {
      inCommand = false;

      event->ignore();
    }
    // PAGE DOWN (ignore)
    else if( event->key() == Qt::Key_PageDown )
    {
      inCommand = false;

      event->ignore();
    }
    // CTRL+C
    else if( event->modifiers() == Qt::ControlModifier &&
      event->key() == Qt::Key_C )
    {
      inCommand = false;

      event->ignore();
      emit forwardAction( 1 );
    }
    // CTRL+X
    else if( event->modifiers() == Qt::ControlModifier &&
      event->key() == Qt::Key_X )
    {
      inCommand = false;

      event->ignore();
      emit forwardAction( 2 );
    }
    // CTRL+V
    else if( event->modifiers() == Qt::ControlModifier &&
      event->key() == Qt::Key_V )
    {
      inCommand = false;

      event->ignore();
      emit forwardAction( 3 );
    }

    // TAB
    else if( event->key() == Qt::Key_Tab )
    {
      inCommand = false;

            textCursor().insertText( "  " );
    }
    else
    {
      inCommand = false;

      QTextBrowser::keyPressEvent( event );
    }
  }
Esempio n. 26
0
 virtual bool getBooleanResult(const RtlFieldInfo *field)
 {
     nextField(field);
     return sqlite3embed::getBooleanResult(field, val);
 }
Esempio n. 27
0
 virtual void getDataResult(const RtlFieldInfo *field, size32_t &len, void * &result)
 {
     nextField(field);
     sqlite3embed::getDataResult(field, val, len, result);
 }
Esempio n. 28
0
 virtual unsigned __int64 getUnsignedResult(const RtlFieldInfo *field)
 {
     nextField(field);
     return sqlite3embed::getUnsignedResult(field, val);
 }
Esempio n. 29
0
 virtual void getUnicodeResult(const RtlFieldInfo *field, size32_t &chars, UChar * &result)
 {
     nextField(field);
     sqlite3embed::getUnicodeResult(field, val, chars, result);
 }
Esempio n. 30
0
 virtual void getDecimalResult(const RtlFieldInfo *field, Decimal &value)
 {
     nextField(field);
     double ret = sqlite3embed::getRealResult(field, val);
     value.setReal(ret);
 }