Ejemplo n.º 1
0
void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev)
{
  if ( ev->button() != Qt::LeftButton) return;

  QPoint tL  = contentsRect().topLeft();
  int    tLx = tL.x();
  int    tLy = tL.y();
  QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);

  // pass on double click as two clicks.
  if (!mouse_marks && !(ev->modifiers() & Qt::ShiftModifier))
  {
    emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
    emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release
    emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button
    return;
  }


  emit clearSelectionSignal();
  QPoint bgnSel = pos;
  QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h);
  int i = loc(bgnSel.x(),bgnSel.y());
  iPntSel = bgnSel;

  word_selection_mode = TRUE;

  // find word boundaries...
  int selClass = charClass(image[i].c);
  {
    // set the start...
     int x = bgnSel.x();
     while ( x > 0 && charClass(image[i-1].c) == selClass )
     { i--; x--; }
     bgnSel.setX(x);
     emit beginSelectionSignal( bgnSel.x(), bgnSel.y() );

     // set the end...
     i = loc( endSel.x(), endSel.y() );
     x = endSel.x();
     while( x < columns-1 && charClass(image[i+1].c) == selClass )
     { i++; x++ ; }
     endSel.setX(x);
     actSel = 2; // within selection
     emit extendSelectionSignal( endSel.x(), endSel.y() );
     emit endSelectionSignal(preserve_line_breaks);
     preserve_line_breaks = TRUE;
   }
}
Ejemplo n.º 2
0
// expandArg writes NULL-terminated expansions of `arg', a NULL-terminated
// string, to stdout.  If arg does not begin with `@' or does not refer to a
// file, it is written as is.  Otherwise the contents of the file are
// recursively expanded.  On unexpected EOF in malformed response files an
// incomplete final argument is written, even if it is empty, to parse like GCC.
void expandArg(String *arg) {
    FILE *f;
    if (arg->data[0] != '@' || !(f = fopen(&arg->data[1], "r"))) {
        fwrite(arg->data, 1, arg->len, stdout);
        return;
    }

    resize(arg, 0);
    State cur = outside;
    int c;
    do {
        c = fgetc(f);
        State next = transitions[cur][charClass(c)];
        if ((cur == unq && next == outside) || (cur != outside && c == EOF)) {
            append(arg, "", 1);
            expandArg(arg);
            resize(arg, 0);
        } else if (cur == unq_esc || cur == sq_esc || cur == dq_esc ||
                   (cur == outside ? next == unq : cur == next)) {
            char s = c;
            append(arg, &s, 1);
        }
        cur = next;
    } while (c != EOF);

    fclose(f);
}
Ejemplo n.º 3
0
inline bool isGraphical(uint32_t c)
{
    return (charClass(c) & (CharClass::Letter |
                            CharClass::Mark |
                            CharClass::Number |
                            CharClass::Punctuation |
                            CharClass::Symbol)) != 0;
}
Ejemplo n.º 4
0
inline bool isVisible(uint32_t c)
{
    return (charClass(c) & (CharClass::Letter |
                            CharClass::Mark |
                            CharClass::Number |
                            CharClass::Punctuation |
                            CharClass::Symbol |
                            CharClass::Separator)) != 0;
}
Ejemplo n.º 5
0
void RxCompile::simple()
	{
	if (match("."))
		emit(&any);
	else if (match("\\d"))
		emit(new CharClass(digit));
	else if (match("\\D"))
		emit(new CharClass(notDigit));
	else if (match("\\w"))
		emit(new CharClass(word));
	else if (match("\\W"))
		emit(new CharClass(notWord));
	else if (match("\\s"))
		emit(new CharClass(space));
	else if (match("\\S"))
		emit(new CharClass(notSpace));
	else if (matchBackref())
		{
		int i = src[si - 1] - '0';
		emit(new Backref(i, ignoringCase));
		}
	else if (match("["))
		{
		charClass();
		mustMatch(']');
		}
	else if (match("("))
		{
		int i = ++leftCount;
		emit(new Left(i));
		regexp();					// recurse
		emit(new Right(i));
		mustMatch(')');
		}
	else
		{
		if (si + 1 < sn)
			match("\\");
		emitChars(src + si, 1);
		++si;
		}
	}
Ejemplo n.º 6
0
void TEWidget::mouseMoveEvent(QMouseEvent* ev)
{
  // for auto-hiding the cursor, we need mouseTracking
  if (ev->modifiers() == Qt::NoButton ) return;

  if (actSel == 0) return;

 // don't extend selection while pasting
  if (ev->modifiers() & Qt::MidButton) return;

  //if ( !contentsRect().contains(ev->pos()) ) return;
  QPoint tL  = contentsRect().topLeft();
  int    tLx = tL.x();
  int    tLy = tL.y();
  int    scroll = scrollbar->value();

  // we're in the process of moving the mouse with the left button pressed
  // the mouse cursor will remain caught within the bounds of the text in
  // this widget.

  // Adjust position within text area bounds. See FIXME above.
  QPoint pos = ev->pos();
  if ( pos.x() < tLx+blX )                  pos.setX( tLx+blX );
  if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w );
  if ( pos.y() < tLy+bY )                   pos.setY( tLy+bY );
  if ( pos.y() > tLy+bY+lines*font_h-1 )    pos.setY( tLy+bY+lines*font_h-1 );
  // check if we produce a mouse move event by this
  if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos));

  if ( pos.y() == tLy+bY+lines*font_h-1 )
  {
    scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward
  }
  if ( pos.y() == tLy+bY )
  {
    scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback
  }

  QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h);
  QPoint ohere;
  bool swapping = FALSE;

  if ( word_selection_mode )
  {
    // Extend to word boundaries
    int i;
    int selClass;

    bool left_not_right = ( here.y() < iPntSel.y() ||
     here.y() == iPntSel.y() && here.x() < iPntSel.x() );
    bool old_left_not_right = ( pntSel.y() < iPntSel.y() ||
     pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() );
    swapping = left_not_right != old_left_not_right;

    // Find left (left_not_right ? from here : from start)
    QPoint left = left_not_right ? here : iPntSel;
    i = loc(left.x(),left.y());
    selClass = charClass(image[i].c);
    while ( left.x() > 0 && charClass(image[i-1].c) == selClass )
    { i--; left.rx()--; }

    // Find left (left_not_right ? from start : from here)
    QPoint right = left_not_right ? iPntSel : here;
    i = loc(right.x(),right.y());
    selClass = charClass(image[i].c);
    while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass )
    { i++; right.rx()++; }

    // Pick which is start (ohere) and which is extension (here)
    if ( left_not_right )
    {
      here = left; ohere = right;
    }
    else
    {
      here = right; ohere = left;
    }
  }

  if (here == pntSel && scroll == scrollbar->value()) return; // not moved

  if ( word_selection_mode ) {
    if ( actSel < 2 || swapping ) {
      emit beginSelectionSignal( ohere.x(), ohere.y() );
    }
  } else if ( actSel < 2 ) {
    emit beginSelectionSignal( pntSel.x(), pntSel.y() );
  }

  actSel = 2; // within selection
  pntSel = here;
  emit extendSelectionSignal( here.x(), here.y() );
}
Ejemplo n.º 7
0
inline bool isAlphaNumeric(uint32_t c)
{
    return (charClass(c) & (CharClass::Letter | CharClass::Number)) != 0;
}
Ejemplo n.º 8
0
inline bool isSymbol(uint32_t c)
{
    return (charClass(c) & CharClass::Symbol) != 0;
}
Ejemplo n.º 9
0
inline bool isSurrogate(uint32_t c)
{
    return (charClass(c) & CharClass::Surrogate) != 0;
}
Ejemplo n.º 10
0
inline bool isWhitespace(uint32_t c)
{
    return c == '\t' || c == ' ' || isNewline(c) ||
           (c > 128 && (charClass(c) & CharClass::Separator) != 0);
}
Ejemplo n.º 11
0
inline bool isPunctuation(uint32_t c)
{
    return (charClass(c) & CharClass::Punctuation) != 0;
}
Ejemplo n.º 12
0
inline bool isNumber(uint32_t c)
{
    return (charClass(c) & CharClass::Number) != 0;
}
Ejemplo n.º 13
0
inline bool isLetter(uint32_t c)
{
    return (charClass(c) & CharClass::Letter) != 0;
}
Ejemplo n.º 14
0
inline bool isFormat(uint32_t c)
{
    return (charClass(c) & CharClass::Format) != 0;
}
Ejemplo n.º 15
0
inline bool isControl(uint32_t c)
{
    return (charClass(c) & CharClass::Control) != 0;
}
Ejemplo n.º 16
0
inline bool isSeparator(uint32_t c)
{
    return (charClass(c) & CharClass::Separator) != 0;
}
Ejemplo n.º 17
0
void NFABuilder::dot(const ParseNode&) {
  charClass(ParseNode(ParseNode::CHAR_CLASS, 0, 0x10FFFF));
}