Exemplo n.º 1
0
void Screen::Tabulate(int n)
{
  // note that TAB is a format effector (does not write ' ');
  if (n == 0) n = 1;
  while((n > 0) && (cuX < columns-1))
  {
    cursorRight(1); while((cuX < columns-1) && !tabstops[cuX]) cursorRight(1);
    n--;
  }
}
Exemplo n.º 2
0
void QLineEdit::mouseMoveEvent( QMouseEvent *e )
{
    int margin = frame() ? 4 : 2;

    if ( e->pos().x() < margin || e->pos().x() > width() - margin ) {
	scrollingLeft = ( e->pos().x() < margin );
	if ( !dragScrolling ) {
	    dragScrolling = TRUE;
	    if ( scrollingLeft )
		newMark( offset, FALSE );
	    else
		newMark( lastCharVisible(), FALSE );
	    d->dragTimer.start( scrollTime );
	} else {
	    if ( scrollingLeft ) {
		int steps = -(e->pos().x() + margin) / 15 + 2;
		cursorLeft( TRUE, steps );
	    } else {
		int steps = (e->pos().x() - width() +  margin) / 15 + 2;
		cursorRight( TRUE, steps );
	    }
	}
    } else {
	dragScrolling = FALSE;
	int mousePos = offset + xPosToCursorPos( &tbuf[(int)offset],
						 fontMetrics(),
						 e->pos().x() - margin,
						 width() - margin - margin );
	int m1 = markDrag;
	newMark( mousePos, FALSE );
	repaintArea( m1, mousePos );
    }
}
Exemplo n.º 3
0
void MainWindow::loadCursors()
{
   cursorList << Qt::ArrowCursor;
   
   QPixmap cursorCrossPic;
   cursorCrossPic.load((cursorDir+QString("cursorCross.bmp")), "BMP", Qt::MonoOnly);
   cursorCrossPic.setMask(QBitmap(cursorCrossPic));
   QCursor cursorCross(cursorCrossPic, 15,15);
   cursorList << cursorCross;

   QPixmap cursorDownPic;
   cursorDownPic.load((cursorDir+QString("cursorDown.bmp")), "BMP", Qt::MonoOnly);
   cursorDownPic.setMask(QBitmap(cursorDownPic));
   QCursor cursorDown(cursorDownPic, 15,31);
   cursorList << cursorDown;

   QPixmap cursorLeftPic;
   cursorLeftPic.load((cursorDir+QString("cursorLeft.bmp")), "BMP", Qt::MonoOnly);
   cursorLeftPic.setMask(QBitmap(cursorLeftPic));
   QCursor cursorLeft(cursorLeftPic, 0,15);
   cursorList << cursorLeft;

   QPixmap cursorRightPic;
   cursorRightPic.load((cursorDir+QString("cursorRight.bmp")), "BMP", Qt::MonoOnly);
   cursorRightPic.setMask(QBitmap(cursorRightPic));
   QCursor cursorRight(cursorRightPic, 31,15);
   cursorList << cursorRight;
   
   cursorList+=cursorList;
   roundNum = 1;
}
Exemplo n.º 4
0
void twinkle::findLimbusContour(cv::Mat mat, Point* pupil)
{
    Point cursorUp(*pupil);
    Point cursorDown(cursorUp.x, cursorUp.y+1);
    Point cursorLeft(cursorUp);
    Point cursorRight(cursorUp.x+1, cursorUp.y);

    std::vector<Point> limbusContourLR, limbusContourUD;

    bool debug = true;
    Mat debMatLR(mat.rows, mat.cols, CV_8U);
    Mat debMatUD(mat.rows, mat.cols, CV_8U);

    mat.copyTo(debMatLR);
    mat.copyTo(debMatUD);

    if(debug)
    {
        namedWindow("Limbus contour LR", CV_WINDOW_NORMAL);
        namedWindow("Limbus contour UD", CV_WINDOW_NORMAL);
    }

    mat.at<uchar>(cursorUp) = 0;

    std::cout<<"limbusContourLR.size() = "<<limbusContourLR.size()<<std::endl;
    moveCursor(cursorUp, mat, &limbusContourLR, debug, debMatLR, UP_DIR);
    std::cout<<"After moveUp limbusContourLR.size() = "<<limbusContourLR.size()<<std::endl;
    moveCursor(cursorDown, mat, &limbusContourLR, debug, debMatLR, DOWN_DIR);
    std::cout<<"After moveDown limbusContourLR.size() = "<<limbusContourLR.size()<<std::endl;

    moveCursor(cursorLeft, mat, &limbusContourUD, debug, debMatUD, LEFT_DIR);
    std::cout<<"After moveLeft limbusContourUD.size() = "<<limbusContourUD.size()<<std::endl;
    moveCursor(cursorRight, mat, &limbusContourUD, debug, debMatUD, RIGHT_DIR);
    std::cout<<"After moveRight limbusContourUD.size() = "<<limbusContourUD.size()<<std::endl;
}
Exemplo n.º 5
0
void QLineEdit::dragScrollSlot()
{
    if ( !hasFocus() || !dragScrolling )
	d->dragTimer.stop();
    else if ( scrollingLeft )
	cursorLeft( TRUE );
    else
	cursorRight( TRUE );
}
Exemplo n.º 6
0
bool ClientConsole::onKeyPress (int32_t key, int16_t modifier)
{
	switch (key) {
	case SDLK_TAB:
		if (modifier & KMOD_SHIFT) {
			toggleConsole();
			return true;
		}
	}

	if (!_active)
		return false;

	switch (key) {
	case SDLK_ESCAPE:
		toggleConsole();
		break;
	case SDLK_RETURN:
		executeCommandLine();
		break;
	case SDLK_BACKSPACE:
		cursorDelete();
		break;
	case SDLK_DELETE:
		cursorDelete(false);
		break;
	case SDLK_INSERT:
		_overwrite ^= true;
		break;
	case SDLK_LEFT:
		cursorLeft();
		break;
	case SDLK_RIGHT:
		cursorRight();
		break;
	case SDLK_UP:
		cursorUp();
		break;
	case SDLK_DOWN:
		cursorDown();
		break;
	case SDLK_TAB:
		autoComplete();
		break;
	default:
		return false;
	}

	return true;
}
Exemplo n.º 7
0
void KEdit::replace_slot()
{

    if(!replace_dialog)
        return;

    if(!can_replace)
    {
        KNotifyClient::beep();
        return;
    }

    int line, col, length;

    QString string = replace_dialog->getReplaceText();
    length = string.length();

    this->cut();

    getCursorPosition(&line, &col);

    insertAt(string, line, col);
    setModified(true);
    can_replace = false;

    if(replace_dialog->get_direction())
    {
        // Backward
        setCursorPosition(line, col + length);
        for(int k = 0; k < length; k++)
        {
            cursorLeft(true);
        }
    }
    else
    {
        // Forward
        setCursorPosition(line, col);
        for(int k = 0; k < length; k++)
        {
            cursorRight(true);
        }
    }
}
Exemplo n.º 8
0
    void TextField::processKeyEvent(KeyEvent* event)
    {
        int keycode = event->getKeycode();
        int modifiers = event->getModifiers();

        // Toggle IME ON/OFF
        if (keycode == '\\' && modifiers == KeyEvent::VKEY_CTRL) {
            _imeManager->processEvent(event);
            return;
        }

        if (isImeOn()) {
            _imeManager->processEvent(event);
            return;
        }

        switch(keycode) {
        case  KeyEvent::VKEY_BACKSPACE:
            backspace();
            break;
        case KeyEvent::VKEY_LEFT:
            if (cursorLeft()) {
                repaint();
            }
            break;
        case KeyEvent::VKEY_RIGHT:
            if (cursorRight()) {
                repaint();
            }
            break;
            // case KeyEvent::VKEY_ENTER:
            //     if (getParent()) {
            //         getParent()->processEvent(&this->textEvent);
            //     }
            //     break;
        default:
            ASSERT(keycode < 128);
            insertCharacter(keycode);
            repaint();
            break;
        }
    }
Exemplo n.º 9
0
bool Weather::keyPressEvent(QKeyEvent *event)
{
    if (GetFocusWidget() && GetFocusWidget()->keyPressEvent(event))
        return true;

    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("Weather", event, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "LEFT")
            cursorLeft();
        else if (action == "RIGHT")
            cursorRight();
        else if (action == "PAUSE")
            holdPage();
        else if (action == "MENU")
            setupPage();
        else if (action == "UPDATE")
        {
            m_srcMan->doUpdate();
        }
        else if (action == "ESCAPE")
        {
            m_nextpage_Timer->stop();
            hideScreen();
            Close();
        }
        else
            handled = false;
    }

    if (!handled && MythScreenType::keyPressEvent(event))
        handled = true;

    return handled;
}
Exemplo n.º 10
0
void QLineEdit::cursorLeft( bool mark, int steps )
{
    if ( steps < 0 ) {
	cursorRight( mark, -steps );
	return;
    }
    if ( cursorPos > 0 || (!mark && hasMarkedText()) ) {
	cursorPos -= steps;
	if ( cursorPos < 0 )
	    cursorPos = 0;
	cursorOn = FALSE;
	blinkSlot();
	int minP = QMIN( minMark(), cursorPos );
	int maxP = QMAX( maxMark(), cursorPos );
	if ( mark )
	    newMark( cursorPos );
	else
	    markAnchor = markDrag = cursorPos;
	d->pmDirty = TRUE;
	repaintArea( minP, maxP );
    }
}
//==============================================================================
bool CodeEditorComponent::keyPressed (const KeyPress& key)
{
    const bool moveInWholeWordSteps = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown();
    const bool shiftDown = key.getModifiers().isShiftDown();

    if (key.isKeyCode (KeyPress::leftKey))
    {
        cursorLeft (moveInWholeWordSteps, shiftDown);
    }
    else if (key.isKeyCode (KeyPress::rightKey))
    {
        cursorRight (moveInWholeWordSteps, shiftDown);
    }
    else if (key.isKeyCode (KeyPress::upKey))
    {
        if (key.getModifiers().isCtrlDown() && ! shiftDown)
            scrollDown();
#if JUCE_MAC
        else if (key.getModifiers().isCommandDown())
            goToStartOfDocument (shiftDown);
#endif
        else
            cursorUp (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::downKey))
    {
        if (key.getModifiers().isCtrlDown() && ! shiftDown)
            scrollUp();
#if JUCE_MAC
        else if (key.getModifiers().isCommandDown())
            goToEndOfDocument (shiftDown);
#endif
        else
            cursorDown (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::pageDownKey))
    {
        pageDown (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::pageUpKey))
    {
        pageUp (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::homeKey))
    {
        if (moveInWholeWordSteps)
            goToStartOfDocument (shiftDown);
        else
            goToStartOfLine (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::endKey))
    {
        if (moveInWholeWordSteps)
            goToEndOfDocument (shiftDown);
        else
            goToEndOfLine (shiftDown);
    }
    else if (key.isKeyCode (KeyPress::backspaceKey))
    {
        backspace (moveInWholeWordSteps);
    }
    else if (key.isKeyCode (KeyPress::deleteKey))
    {
        deleteForward (moveInWholeWordSteps);
    }
    else if (key == KeyPress (T('c'), ModifierKeys::commandModifier, 0))
    {
        copy();
    }
    else if (key == KeyPress (T('x'), ModifierKeys::commandModifier, 0))
    {
        copyThenCut();
    }
    else if (key == KeyPress (T('v'), ModifierKeys::commandModifier, 0))
    {
        paste();
    }
    else if (key == KeyPress (T('z'), ModifierKeys::commandModifier, 0))
    {
        undo();
    }
    else if (key == KeyPress (T('y'), ModifierKeys::commandModifier, 0)
              || key == KeyPress (T('z'), ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0))
    {
        redo();
    }
    else if (key == KeyPress (T('a'), ModifierKeys::commandModifier, 0))
    {
        selectAll();
    }
    else if (key == KeyPress::tabKey || key.getTextCharacter() == '\t')
    {
        insertTabAtCaret();
    }
    else if (key == KeyPress::returnKey)
    {
        newTransaction();
        insertTextAtCaret (document.getNewLineCharacters());
    }
    else if (key.isKeyCode (KeyPress::escapeKey))
    {
        newTransaction();
    }
    else if (key.getTextCharacter() >= ' ')
    {
        insertTextAtCaret (String::charToString (key.getTextCharacter()));
    }
    else
    {
        return false;
    }

    return true;
}
Exemplo n.º 12
0
void QLineEdit::keyPressEvent( QKeyEvent *e )
{
    if ( e->key() == Key_Enter || e->key() == Key_Return ) {
	QValidator * v = validator();
	if ( !v || v->validate( tbuf, cursorPos ) == QValidator::Acceptable ) {
	    emit returnPressed();
	} else if ( v ) {
	    v->fixup( tbuf );
	    if ( v->validate( tbuf, cursorPos ) == QValidator::Acceptable )
		emit returnPressed();
	}
	// ### 2.0 must fix this
	e->ignore();
	return;
    }
    if ( e->ascii() >= 32 &&
	 e->key() != Key_Delete &&
	 e->key() != Key_Backspace ) {
	QString t( 2 );
	t[0] = e->ascii();
	t[1] = '\0';
	insert( t );
	return;
    }
    int unknown = 0;
    if ( e->state() & ControlButton ) {
	switch ( e->key() ) {
	case Key_A:
	case Key_Left:
	    home( e->state() & ShiftButton );
	    break;
	case Key_B:
	    cursorLeft( e->state() & ShiftButton );
	    break;
	case Key_C:
	    if ( hasMarkedText() && echoMode() == Normal )
		copyText();
	    break;
	case Key_D:
	    del();
	    break;
	case Key_E:
	case Key_Right:
	    end( e->state() & ShiftButton );
	    break;
	case Key_F:
	    cursorRight( e->state() & ShiftButton );
	    break;
	case Key_H:
	    backspace();
	    break;
	case Key_K:
	    if ( cursorPos < (int)tbuf.length() ) {
		QString t( tbuf );
		t.detach(); // ### 2.0
		t.truncate( cursorPos );
		validateAndSet( t, cursorPos, cursorPos, cursorPos );
	    }
	    break;
	case Key_V:
	    insert( QApplication::clipboard()->text() );
	case Key_X:
	    if ( hasMarkedText() && echoMode() == Normal ) {
		copyText();
		del();
	    }
	    break;
	default:
	    unknown++;
	}
    } else {
	switch ( e->key() ) {
	case Key_Left:
	    cursorLeft( e->state() & ShiftButton );
	    break;
	case Key_Right:
	    cursorRight( e->state() & ShiftButton );
	    break;
	case Key_Backspace:
	    backspace();
	    break;
	case Key_Home:
	    home( e->state() & ShiftButton );
	    break;
	case Key_End:
	    end( e->state() & ShiftButton );
	    break;
	case Key_Delete:
	    del();
	    break;
	default:
	    unknown++;
	}
    }

    if ( unknown ) {				// unknown key
	e->ignore();
	return;
    }
}
Exemplo n.º 13
0
/* antlarr: KDE 4: make it const QString & */
int KEdit::doReplace(QString s_pattern, bool case_sensitive,
	   bool wildcard, bool forward, int line, int col, bool replace_all){


  (void) wildcard; // reserved for possible extension to regex

  int line_counter, length;
  int pos = -1;

  QString string;
  QString stringnew;
  QString replacement;

  replacement = replace_dialog->getReplaceText();
  line_counter = line;
  replace_all_col = col;

  if(forward){

    int num_lines = numLines();

    while (line_counter < num_lines){

      string = textLine(line_counter);

      if (replace_all){
	pos = string.find(s_pattern, replace_all_col, case_sensitive);
      }
      else{
	pos = string.find(s_pattern, line_counter == line ? col : 0, case_sensitive);
      }

      if (pos == -1 ){
	line_counter++;
	replace_all_col = 0;
	replace_all_line = line_counter;
      }

      if( pos != -1){

	length = s_pattern.length();

	if(replace_all){ // automatic

          stringnew = string.copy();
          do 
          {  
	    stringnew.replace(pos,length,replacement);

	    replace_all_col = pos + replacement.length();
	    replace_all_line = line_counter;

            pos = stringnew.find(s_pattern, replace_all_col, case_sensitive);
          }
          while( pos != -1); 

	  removeLine(line_counter);
	  insertLine(stringnew,line_counter);

	  setModified(true);
	}
	else{ // interactive

	  setCursorPosition( line_counter , pos, false );

	  for(int l = 0 ; l < length; l++){
	    cursorRight(true);
	  }

	  setCursorPosition( line_counter , pos + length, true );
	  pattern = s_pattern;
	  last_replace = FORWARD;
	  can_replace = true;

	  return 1;

	}

      }
    }
  }
  else{ // searching backwards

    while(line_counter >= 0){

      string = textLine(line_counter);

      int line_length = string.length();

      if( replace_all ){
        if (replace_all_col < 0)
          pos = -1;
        else
          pos = string.findRev(s_pattern, replace_all_col , case_sensitive);
      }
      else{
        if ((line == line_counter) && (col < 0))
          pos = -1;
        else
          pos = string.findRev(s_pattern,
			   line == line_counter ? col : line_length , case_sensitive);
      }

      if (pos == -1 ){
	line_counter--;

        replace_all_col = 0;
	if(line_counter >= 0){
	  string = textLine(line_counter);
	  replace_all_col = string.length();

	}
	replace_all_line = line_counter;
      }


      if (pos != -1){
	length = s_pattern.length();

	if(replace_all){ // automatic

	  stringnew = string.copy();
	  stringnew.replace(pos,length,replacement);

	  removeLine(line_counter);
	  insertLine(stringnew,line_counter);

	  replace_all_col = pos-length;
	  replace_all_line = line_counter;
	  if (replace_all_col < 0)
	  {
             line_counter--;

             if(line_counter >= 0){
                string = textLine(line_counter);
                replace_all_col = string.length();
             }
             replace_all_line = line_counter;
	  }

	  setModified(true);
	}
	else{ // interactive

	  //	  printf("line_counter %d pos %d col %d\n",line_counter, pos,col);
	  if( ! (line == line_counter && pos > col ) ){

	    setCursorPosition(line_counter, pos + length ,false );

	    for(int l = 0 ; l < length; l++){
	      cursorLeft(true);
	    }

	    setCursorPosition(line_counter, pos ,true );
	    pattern = s_pattern;

	    last_replace = BACKWARD;
	    can_replace = true;

	    return 1;
	  }
	}
      }
    }
  }

  return 0;

}
Exemplo n.º 14
0
/* antlarr: KDE 4: make it const QString & */
int KEdit::doSearch(QString s_pattern, bool case_sensitive,
		    bool wildcard, bool forward, int line, int col){

  (void) wildcard; // reserved for possible extension to regex


  int i, length;
  int pos = -1;

  if(forward){

    QString string;

    for(i = line; i < numLines(); i++) {

      string = textLine(i);

      pos = string.find(s_pattern, i == line ? col : 0, case_sensitive);

      if( pos != -1){

	length = s_pattern.length();

	setCursorPosition(i,pos,false);

	for(int l = 0 ; l < length; l++){
	  cursorRight(true);
	}

	setCursorPosition( i , pos + length, true );
	pattern = s_pattern;
	last_search = FORWARD;

	return 1;
      }
    }
  }
  else{ // searching backwards

    QString string;

    for(i = line; i >= 0; i--) {

      string = textLine(i);
      int line_length = string.length();

      pos = string.findRev(s_pattern, line == i ? col : line_length , case_sensitive);

      if (pos != -1){

	length = s_pattern.length();

	if( ! (line == i && pos > col ) ){

	  setCursorPosition(i ,pos ,false );

	  for(int l = 0 ; l < length; l++){
	    cursorRight(true);
	  }

	  setCursorPosition(i ,pos + length ,true );
	  pattern = s_pattern;
	  last_search = BACKWARD;
	  return 1;

	}
      }

    }
  }

  return 0;

}