Пример #1
0
Entity::~Entity()
{
	//printf("Entity dtor %d\n", _guid);
	deleteSprite();
	deleteLine();
	deleteSpritebatch();
}
Пример #2
0
//delete all lines that should be removed
void Board::deletePossibleLines(){
	for(int j = 0; j < BOARD_HEIGHT; j++){
		int i;
		for(i = 0; i < BOARD_WIDTH; i++){
			if(mBoard[i][j] != POS_FILLED) break;
		}
		if(i == BOARD_WIDTH) deleteLine(j);
	}
}
Пример #3
0
int parseCommand(token *tok, char **s)
{
	int line;
	int r;

	if (matchNumber(tok, s))
	{
		line = tok->n;
		if (!matchWhiteSpace(tok, s)) // delete line
			return deleteLine(line);
		else	// add line
		{
			matchString(tok, s);
			return insertLine(line, tok->s);
		}
	}

	if (matchSize(tok, s))
	{
		puts(itos(programGetSize()));
		return 1;
	}

	if (matchFree(tok, s))
	{
		puts(itos(programGetFree()));
		return 1;
	}

  if (matchClear(tok, s))
	{
		programInit();
		return 1;
	}

	if (matchBye(tok, s))
	{
		exit(0);
	}

	if (parseRun(tok, s))
		return 1;
	else if (errorGet() != ERROR_OK) return 0;

	if (parseList(tok, s))
		return 1;
	else if (errorGet() != ERROR_OK) return 0;

	programSetMode(progModeImmediate);
	r = parseLine(tok, s);
	programSetMode(progModeStored);

	return r;
}
Пример #4
0
void DatenPunkt::mousePressEvent(QGraphicsSceneMouseEvent *event)//Lienie erstellen, wenn an bestimmte stellen geklickt wird, oder löschen
{
    if(event->pos().x()>this->textItem->boundingRect().width() && event->button() == Qt::LeftButton){//Linie muss erstellt werden
        emit drawLine(this);


    }
    if(event->pos().x()>this->textItem->boundingRect().width() && event->button() == Qt::RightButton){//Linie muss erstellt werden
        deleteLine();

    }
}
Пример #5
0
void Board::DeletePossibleLines()
{
	for (int i = 0; i < BOARD_HEIGHT; i++)
	{
		int j = 0;
		while (j < BOARD_WIDTH)
		{
			if (mBoard[i][j] != 1) 
				break;
			j++;
		}

		if (j == BOARD_WIDTH ) 
			deleteLine(i);
	}
}
Пример #6
0
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setUpEditor();

    //adds new tab button
    QToolButton *newTabButton = new QToolButton(this);
    ui->tabWidget->setCornerWidget(newTabButton);
    newTabButton->setAutoRaise(true);
    newTabButton->setText("+");

    //connect signals
    QObject::connect(newTabButton, SIGNAL(clicked()), this, SLOT(makeNewTab()));
    QObject::connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(deleteTab(int)));

    //create keyboard shortcuts
    QShortcut *shortcut = new QShortcut(QKeySequence("ctrl+w"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(deleteCurrentTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+t"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(makeNewTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+s"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionSave_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+shift+s"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionSave_As_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+o"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionOpen_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+q"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_actionQuit_triggered()));

    shortcut = new QShortcut(QKeySequence("ctrl+tab"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(switchToNextTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+shift+tab"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(switchToPrevTab()));

    shortcut = new QShortcut(QKeySequence("ctrl+d"), ui->tabWidget);
    QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(deleteLine()));
}
Пример #7
0
//Public method for deleting lines.
//Works out which lines are full and tells the delete line method.
void GameBoard::deleteLines()
{
	for (int i = 0; i < BOARD_HEIGHT; i++)
	{
		int j = 0;
		//printf("Current value of j:\n%d\n\n\n", j);
		while (j < BOARD_WIDTH)
		{
			if (board[i][j] != positionFilled) break;	
			//printf("Got to here.\n\n\n");
				j++;
		}
			if (j == BOARD_WIDTH)
			{
				deleteLine(j);
			}
		
	}
}
Пример #8
0
void clearLines()
{
    int x, y;
    bool lineFull;
    for(y=0; y<16; y++) {
        lineFull = true; //assume the line is full
        for(x=0; x<10; x++) {
            int color = grid[x][y];
            if(color == 0) {
                lineFull = false;
                break;
            }
        }

        if(lineFull) {
            deleteLine(y);
            incScore();
        }
    }
}
Пример #9
0
	bool INIFile::deleteSection(const String& section_name)
	{
		if (!section_index_.has(section_name))
		{
			return false;
		}

		if (section_name == HEADER)
		{
			while (+getSectionFirstLine(HEADER))
			{
				deleteLine(getSectionFirstLine(HEADER));
			}
			
			return true;
		}

		sections_.erase(section_index_[section_name]);
		section_index_.remove(section_name);
		return true;
	}
Пример #10
0
void CodeEditor::keyPressEvent(QKeyEvent *e)
{
    if ((codeCompleter) && codeCompleter->popup()->isVisible() && (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Backtab || e->key() == Qt::Key_Escape|| e->key() == Qt::Key_Return || e->key() == Qt::Key_Tab))
    {
        e->ignore();
        return;
    }
    else if (e->key() == Qt::Key_Tab)
    {
        QTextCursor cur = textCursor();
        cur.beginEditBlock();
        cur.insertText("\t");
        cur.endEditBlock();
        setTextCursor(cur);
        e->ignore();
        return;
    }
    else if (e->key() == Qt::Key_D && (e->modifiers() & Qt::ControlModifier)){
        deleteLine();
    } else if (e->key() == Qt::Key_Up && (e->modifiers() & Qt::AltModifier)){
        copyLineUp();
    }else if (e->key() == Qt::Key_Up && (e->modifiers() & Qt::ControlModifier)) {
        moveLineUp();
    } else if (e->key() == Qt::Key_Down && (e->modifiers() & Qt::AltModifier)){
        copyLineDown();
    }else if (e->key() == Qt::Key_Down && (e->modifiers() & Qt::ControlModifier)){
        moveLineDown();
    }else if (e->key() == Qt::Key_Space &&(e->modifiers() & Qt::ControlModifier)){
        popupSuggestions();

    }else if (e->key() == Qt::Key_3 && (e->modifiers() & Qt::ControlModifier)){
        toggleComments();
    }else if(e->key() == Qt::Key_Period){
         popupSuggestions();
         QTextEdit::keyPressEvent(e);
    }else
        QTextEdit::keyPressEvent(e);


}
Пример #11
0
/*!
 * \en 	Handler line current change signal. \_en
 * \ru	Обработчик сигнала изменения строки. Генерирует сигналы
 * deleteLine и saveLine. \_ru
 */
void
wDBTable::lineUpdate( QSql::Op mode)
{
QSqlRecord *rec = sqlCursor()->editBuffer();//currentRecord();
	switch(mode)
	{
		case QSql::Update:
	//	rec =  currentRecord();
		break;
		case QSql::Insert:
		break;
		case QSql::Delete:
		//printf("emit del line\n");
		emit(deleteLine(rec));
		return;
		default:
		break;
	}
	//if(!rec) return;
	//printf(" emit saveLine\n");
	emit(saveLine(rec));
}
Пример #12
0
void QgsGrassEdit::keyPress( QKeyEvent *e )
{
  QgsDebugMsg( "entered." );
  // This does not work:
  //keyPressEvent(e);

  // TODO: this is not optimal
  switch ( e->key() )
  {
    case Qt::Key_F1: newPoint(); break;
    case Qt::Key_F2: newLine(); break;
    case Qt::Key_F3: newBoundary(); break;
    case Qt::Key_F4: newCentroid(); break;
    case Qt::Key_F5: moveVertex(); break;
    case Qt::Key_F6: addVertex(); break;
    case Qt::Key_F7: deleteVertex(); break;
    case Qt::Key_F9: moveLine(); break;
    case Qt::Key_F10: splitLine(); break;
    case Qt::Key_F11: deleteLine(); break;
    default: break;
  }
}
Пример #13
0
void editfile( struct options *options, list_ref list ){
   char stdinline[1024];
   char *operand = NULL;
   int stdincount = 0;
   int lineCount = 0;
   char *linepos = NULL;
   for(;;){
      if(!options->s_opt_silent)
		 printf("%s: ", progname); 
	  linepos = fgets( stdinline, sizeof stdinline, stdin );
      if( linepos == NULL ) break;
	  if(options->e_opt_echo && !options->s_opt_silent)
	     printf("%s",stdinline);
      linepos = strchr( stdinline, '\n' );
      if( linepos == NULL || stdinline[0] == '\0' ){
         badline( stdincount, stdinline );
      }else{
         *linepos = '\0';
		 operand=stdinline+1;
         switch( stdinline[0] ){
            case '$':
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	lastLine(list, options);
            	break;
            case '*':
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	printAll(list, options); 
            	break;
            case '.': 
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	printCurr(list, options);
            	break;
            case '0':
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	firstLine(list, options);
            	break;
            case '<': 
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	prevLine(list, options);
            	break;
            case '>': 
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	nextLine(list, options);
            	break;
            case '@': 
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	debugdump_list( list );
            	break;
            case 'a': 
            	insertAfter(list, operand, options);
            	break;
            case 'd': 
            	if(stdinline[1] != '\0') {
					badline(stdincount, stdinline);
					break;
				}
            	deleteLine(list, options);
            	break;
            case 'i': 
            	insertBefore(list, operand, options); 
            	break;
            case 'r':
				lineCount = readFile(list, operand, options); 
            	if(lineCount>=0 && !options->s_opt_silent)
					printf("%s: %d lines read.\n", progname, lineCount);
				break;
            case 'w': 
            	lineCount = writeFile(list, operand, options); 
            	if(lineCount>=0 && !options->s_opt_silent)
					printf("%s: %d lines written to %s\n", progname, lineCount, operand);
				break;
            default :
            	badline( stdincount, stdinline );
         };
      };
      ++stdincount;
   };
   if(!options->s_opt_silent)
	  printf("\n");
}
Пример #14
0
void Entity::addLine(Line* line)
{
	deleteLine();
	_line = new Line();
	*_line = *line;
}
Пример #15
0
void Entity::addLine(const std::string& filename)
{
	deleteLine();
	_line = new Line(filename);
}
Пример #16
0
void BattleMode()
{
	system("cls");
	srand(time(NULL));
	DrawPad(TRUE);
	AttackOfPlayer0=0;
	AttackOfPlayer1=0;
	TempClub club0(rand()%19+1,0,0);
	TempClub club1(rand()%19+1,1,1);
	int a=rand()%19+1;
	int b=rand()%19+1;
	int flag0=0,flag1=0;
	NextClubRefresh(a);
	NextClubRefresh(b,1);
	ScoreFresh(1);
	continue_choosed=3;
	AttackFresh(0);
	AttackFresh(1);
GamePlay:
	while(TRUE)
	{
		for(int n=1;n<=(fps/100);++n)
		{
			Sleep(50);
			if(KEYDOWN(VK_A))								{club0.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_LEFT) )							{club1.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_D))								{club0.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_RIGHT))							{club1.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_W))								{club0.Rotation();Sleep(50);}
			if(KEYDOWN(VK_UP))								{club1.Rotation();Sleep(50);}
			if(KEYDOWN(VK_DOWN) || KEYDOWN(VK_S))			{n+=8;}
			if(KEYDOWN(VK_SPACE) && AttackOfPlayer0>0 )		{AttackOfPlayer0--;AttackFresh(0);SetCursor(2,15);cout<<"Attack";Sleep(50);goto AAttackB;}
			if(KEYDOWN(VK_NUMPAD0) && AttackOfPlayer1>0 )	{AttackOfPlayer1--;AttackFresh(1);SetCursor(55,15);cout<<"Attack";Sleep(50);goto BAttackA;}
		}
		if(club0.isMoveable()==0)							{club0.refresh(a,1);if((continue_choosed==0)||(continue_choosed==1)){break;}a=rand()%19+1;NextClubRefresh(a,0);}
		if(club1.isMoveable()==0)							{club1.refresh(b,1);if((continue_choosed==0)||(continue_choosed==1)){break;}b=rand()%19+1;NextClubRefresh(b,1);}
		if(isFull(0)==1)									{AttackOfPlayer0 +=deleteLine(0);AttackFresh(0);AttackFresh(1);ScoreFresh(0);}
		if(isFull(1)==1)									{AttackOfPlayer1 +=deleteLine(1);AttackFresh(1);AttackFresh(1);ScoreFresh(1);}
		club0.MoveDown();
		club1.MoveDown();
	}
	goto END;

AAttackB:
	flag0=0,flag1=0;
	while(TRUE)
	{
		for(int n=1;n<=(fps/100);++n)
		{
			Sleep(50);
			if(KEYDOWN(VK_A))								{club0.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_LEFT) )							{club1.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_D))								{club0.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_RIGHT))							{club1.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_W))								{club0.Rotation();Sleep(50);}
			if(KEYDOWN(VK_UP))								{club1.Rotation();Sleep(50);}
			if(KEYDOWN(VK_DOWN) || KEYDOWN(VK_S))			{n+=8;}
			if(KEYDOWN(VK_SPACE))							{SetCursor(2,15);cout<<"      ";AttackOfPlayer0++;AttackFresh(0);Sleep(50);goto GamePlay;}
		}
		if(club0.isMoveable()==0&&flag0==0)					{flag0=1;for(int n=0;n<=3;++n)for(int m=0;m<=3;++m)playground[club0.X+n][club0.Y+m]=(club0.ClubType[n][m] || playground[club0.X+n][club0.Y+m]);}
		if(club1.isMoveable()==0&&flag1==0)					{flag1=1;for(int n=0;n<=3;++n)for(int m=0;m<=3;++m)playground[club1.X+n][club1.Y+m]=(club1.ClubType[n][m] || playground[club1.X+n+50][club1.Y+m]);}
		if(isFull(0)==1)									{AttackOfPlayer0+=deleteLine(0);AttackFresh(0);ScoreFresh(1);}
		if(isFull(1)==1)									{AttackOfPlayer1+=deleteLine(1);AttackFresh(1);ScoreFresh(1);}
		club0.MoveDown();
		club1.MoveDown();
		if(club0.isMoveable()==0&&club1.isMoveable()==0)break;
	}
	club1.fresh(rand()%19+1);
	while(TRUE)
	{
		for(int n=1;n<=(fps/100);++n)
		{
			Sleep(50);
			if(KEYDOWN(VK_A) )								{club1.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_D))								{club1.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_W))								{club1.Rotation();Sleep(50);}
			if(KEYDOWN(VK_S))								{n+=8;}
		}	
		club1.MoveDown();
	if(club1.isMoveable()==0)								{for(int n=0;n<=3;++n)for(int m=0;m<=3;++m)playground[club1.X+n][club1.Y+m]=(club1.ClubType[n][m] || playground[club1.X+n][club1.Y+m]);break;}
	}
	if(isFull(1)==1)										{deleteLine(1);}
	club0.fresh(a);
	a=rand()%19+1;
	NextClubRefresh(a,0);
	club1.fresh(b);
	b=rand()%19+1;
	NextClubRefresh(b,1);
	SetCursor(2,15);cout<<"      ";
	goto GamePlay;

BAttackA:
	flag0=0,flag1=0;
	while(TRUE)
	{
		for(int n=1;n<=(fps/100);++n)
		{
			Sleep(50);
			if(KEYDOWN(VK_A))								{club0.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_LEFT) )							{club1.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_D))								{club0.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_RIGHT))							{club1.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_W))								{club0.Rotation();Sleep(50);}
			if(KEYDOWN(VK_UP))								{club1.Rotation();Sleep(50);}
			if(KEYDOWN(VK_DOWN) || KEYDOWN(VK_S))			{n+=8;}
			if(KEYDOWN(VK_NUMPAD0))							{SetCursor(55,15);cout<<"      ";AttackOfPlayer1++;AttackFresh(1);Sleep(50);goto GamePlay;}
		}
		if(club0.isMoveable()==0&&flag0==0)					{flag0=1;for(int n=0;n<=3;++n)for(int m=0;m<=3;++m)playground[club0.X+n][club0.Y+m]=(club0.ClubType[n][m] || playground[club0.X+n][club0.Y+m]);}
		if(club1.isMoveable()==0&&flag1==0)					{flag1=1;for(int n=0;n<=3;++n)for(int m=0;m<=3;++m)playground[club1.X+n][club1.Y+m]=(club1.ClubType[n][m] || playground[club1.X+n+50][club1.Y+m]);}
		if(isFull(0)==1)									{AttackOfPlayer0+=deleteLine(0);AttackFresh(0);ScoreFresh(1);}
		if(isFull(1)==1)									{AttackOfPlayer1+=deleteLine(1);AttackFresh(1);ScoreFresh(1);}
		club0.MoveDown();
		club1.MoveDown();
		if(club0.isMoveable()==0&&club1.isMoveable()==0)break;
	}
	club0.fresh(rand()%19+1);
	while(TRUE)
	{
		for(int n=1;n<=(fps/100);++n)
		{
			Sleep(50);
			if(KEYDOWN(VK_LEFT) )								{club0.MoveLeft();Sleep(50);}
			if(KEYDOWN(VK_RIGHT))								{club0.MoveRight();Sleep(50);}
			if(KEYDOWN(VK_UP))									{club0.Rotation();Sleep(50);}
			if(KEYDOWN(VK_DOWN))								{n+=8;}
		}	
		club0.MoveDown();
	if(club0.isMoveable()==0)								{for(int n=0;n<=3;++n)for(int m=0;m<=3;++m)playground[club0.X+n][club0.Y+m]=(club0.ClubType[n][m] || playground[club0.X+n][club0.Y+m]);break;}
	}
	if(isFull(1)==1)										{deleteLine(1);}
	club0.fresh(a);
	a=rand()%19+1;
	NextClubRefresh(a,0);
	club1.fresh(b);
	b=rand()%19+1;
	NextClubRefresh(b,1);
	SetCursor(55,15);cout<<"      ";
	goto GamePlay;
	
END:;
}
Пример #17
0
void
H19::processCharacter(char ch)
{
    // mask off the high bit just in case, the real H19 would not have it set.
    ch &= 0x7f;

    if (mode_m == Normal)
    {
        switch (ch)
        {
            case ascii::NUL:
            case ascii::SOH:
            case ascii::STX:
            case ascii::ETX:
            case ascii::EOT:
            case ascii::ENQ:
            case ascii::ACK:
            case ascii::VT:
            case ascii::FF:
            case ascii::SO:
            case ascii::SI:
            case ascii::DLE:
            case ascii::DC1:
            case ascii::DC2:
            case ascii::DC3:
            case ascii::DC4:
            case ascii::NAK:
            case ascii::SYN:
            case ascii::ETB:
            case ascii::EM:
            case ascii::SUB:
            case ascii::FS:
            case ascii::GS:
            case ascii::RS:
            case ascii::US:
            case ascii::DEL:
                // From manual, these characters are not processed by the terminal
                break;

            case ascii::BEL: // Rings the bell.
                /// \todo - implement ringing bell.
                consoleLog("<BEL>");
                break;

            case ascii::BS: // Backspace
                consoleLog("<BS>");
                processBS();
                break;

            case ascii::HT: // Horizontal Tab
                consoleLog("<TAB>");
                processTAB();
                break;

            case ascii::LF: // Line Feed
                processLF();

                if (autoCR_m)
                {
                    processCR();
                }

                consoleLog("\n");
                break;

            case ascii::CR: // Carriage Return
                processCR();

                if (autoLF_m)
                {
                    processLF();
                }

                break;

            case ascii::CAN: // Cancel.
                break;

            case ascii::ESC: // Escape
                mode_m = Escape;
                consoleLog("<ESC>");
                break;

            default:
                // if Printable character display it.
#if CONSOLE_LOG
                fprintf(console_out, "%c", ch);
#endif
                displayCharacter(ch);
                break;
        }
    }
    else if (mode_m == Escape)
    {
        // Assume we go back to Normal, so only the few that don't need to set the mode.
        mode_m = Normal;

        switch (ch)
        {
            case ascii::CAN: // CAN - Cancel
                // return to Normal mode, already set.
                break;

            case ascii::ESC: // Escape
                // From the ROM listing, stay in this mode.
                mode_m = Escape;
                break;

            // Cursor Functions

            case 'H': // Cursor Home
                posX_m    = posY_m = 0;
                updated_m = true;
                break;

            case 'C': // Cursor Forward
                cursorForward();
                break;

            case 'D':        // Cursor Backward
                processBS(); // same processing as cursor backward
                break;

            case 'B': // Cursor Down
                cursorDown();
                break;

            case 'A': // Cursor Up
                cursorUp();
                break;

            case 'I': // Reverse Index
                reverseIndex();
                break;

            case 'n': // Cursor Position Report
                cursorPositionReport();
                break;

            case 'j': // Save cursor position
                saveCursorPosition();
                break;

            case 'k': // Restore cursor position
                restoreCursorPosition();
                break;

            case 'Y': // Direct Cursor Addressing
                mode_m = DCA_1;
                break;

            // Erase and Editing

            case 'E': // Clear Display
                clearDisplay();
                break;

            case 'b': // Erase Beginning of Display
                eraseBOD();
                break;

            case 'J': // Erase to End of Page
                eraseEOP();
                break;

            case 'l': // Erase entire Line
                eraseEL();
                break;

            case 'o': // Erase Beginning Of Line
                eraseBOL();
                break;

            case 'K': // Erase To End Of Line
                eraseEOL();
                break;

            case 'L': // Insert Line
                insertLine();
                break;

            case 'M': // Delete Line
                deleteLine();
                break;

            case 'N': // Delete Character
                deleteChar();
                break;

            case '@': // Enter Insert Character Mode
                insertMode_m = true;
                break;

            case 'O': // Exit Insert Character Mode
                insertMode_m = false;
                break;

            // Configuration

            case 'z': // Reset To Power-Up Configuration
                reset();
                break;

            case 'r': // Modify the Baud Rate
                /// \todo - determine if we should support this.
                debugss(ssH19, ERROR, "Error Unimplemented Modify Baud\n");
                break;

            case 'x': // Set Mode
                mode_m = SetMode;
                break;

            case 'y': // Reset Mode
                mode_m = ResetMode;
                break;

            case '<': // Enter ANSI Mode
                /// \todo - implement ANSI mode.
                // ROM - just sets the mode
                debugss(ssH19, ERROR, "Error Entering ANSI mode - unsupported\n");
                break;

            // Modes of operation

            case '[': // Enter Hold Screen Mode
                holdScreen_m = true;
                break;

            case '\\': // Exit Hold Screen Mode
                holdScreen_m = false;
                break;

            case 'p': // Enter Reverse Video Mode
                reverseVideo_m = true;
                break;

            case 'q': // Exit Reverse Video Mode
                reverseVideo_m = false;
                break;

            case 'F': // Enter Graphics Mode
                graphicMode_m = true;
                break;

            case 'G': // Exit Graphics Mode
                graphicMode_m = false;
                break;

            case 't': // Enter Keypad Shifted Mode
                keypadShifted_m = true;
                break;

            case 'u': // Exit Keypad Shifted Mode
                // ROM - just sets the mode
                keypadShifted_m = false;
                break;

            case '=': // Enter Alternate Keypad Mode
                // ROM - just sets the mode
                keypadShifted_m = true;
                break;

            case '>': // Exit Alternate Keypad Mode
                // ROM - just sets the mode
                keypadShifted_m = false;
                break;

            // Additional Functions

            case '}': // Keyboard Disable
                /// \todo - determine whether to do this.
                keyboardEnabled_m = false;
                break;

            case '{': // Keyboard Enable
                keyboardEnabled_m = true;
                break;

            case 'v': // Wrap Around at End Of Line
                wrapEOL_m = true;
                break;

            case 'w': // Discard At End Of Line
                wrapEOL_m = false;
                break;

            case 'Z': // Identify as VT52 (Data: ESC / K)
                debugss(ssH19, ERROR, "Identify request\n");
                sendData(ascii::ESC);
                sendData('/');
                sendData('K');
                break;

            case ']': // Transmit 25th Line
                transmitLine25();
                break;

            case '#': // Transmit Page
                transmitPage();
                break;

            default:
                debugss(ssH19, WARNING, "Unhandled ESC: %d\n", ch);
                /// \todo - verify this is how the H19 ROM does it.
                break;
        }
    }
    else if (mode_m == SetMode)
    {
        mode_m = Normal;

        switch (ch)
        {
            case '1': // Enable 25th line
                // From the ROM, it erases line 25 on the enable, but here we erase on the disable.
                line25_m = true;
                break;

            case '2': // No key click
                keyClick_m = true;
                break;

            case '3': // Hold screen mode
                holdScreen_m = true;
                break;

            case '4': // Block Cursor
                cursorBlock_m = true;
                updated_m     = true;
                break;

            case '5': // Cursor Off
                cursorOff_m = true;
                updated_m   = true;
                break;

            case '6': // Keypad Shifted
                keypadShifted_m = true;
                break;

            case '7': // Alternate Keypad mode
                altKeypadMode_m = true;
                break;

            case '8': // Auto LF
                autoLF_m = true;
                break;

            case '9': // Auto CR
                autoCR_m = true;
                break;

            default:
                /// \todo Need to process ch as if none of this happened...
                debugss(ssH19, WARNING, "Invalid set Mode: %c\n", ch);
                break;
        }
    }
    else if (mode_m == ResetMode)
    {
        mode_m = Normal;

        switch (ch)
        {
            case '1': // Disable 25th line
                eraseLine(rowsMain_c);
                line25_m  = false;
                updated_m = true;
                break;

            case '2': // key click
                keyClick_m = false;
                break;

            case '3': // Hold screen mode
                holdScreen_m = false;
                break;

            case '4': // Block Cursor
                cursorBlock_m = false;
                updated_m     = true;
                break;

            case '5': // Cursor On
                cursorOff_m = false;
                updated_m   = true;
                break;

            case '6': // Keypad Unshifted
                keypadShifted_m = false;
                break;

            case '7': // Exit Alternate Keypad mode
                altKeypadMode_m = false;
                break;

            case '8': // No Auto LF
                autoLF_m = false;
                break;

            case '9': // No Auto CR
                autoCR_m = false;
                break;

            default:
                /// \todo Need to process ch as if none of this happened...
                debugss(ssH19, WARNING, "Invalid reset Mode: %c\n", ch);
                break;
        }
    }
    else if (mode_m == DCA_1)
    {
        // From actual H19, once the line is specified, the cursor
        // immediately moves to that line, so no need to save the
        // position and wait for the entire command.
        /// \todo verify that this is the same on newer H19s.
        if (ch == ascii::CAN)
        {
            // cancel
            mode_m = Normal;
        }
        else
        {
            // \todo handle error conditions

            int pos = ch - 31;

            // verify valid Position
            if (((pos > 0) && (pos < (signed) rows_c)) || ((pos == (signed) rows_c) && (line25_m)))
            {
                posY_m = pos - 1;
            }
            else
            {
                /// \todo check to see how a real h19 handles this.
                debugss(ssH19, INFO, "DCA invalid Y: %d\n", pos);
            }

            mode_m = DCA_2;
        }
    }
    else if (mode_m == DCA_2)
    {
        if (ch == ascii::CAN)
        {
            // cancel
            mode_m = Normal;
        }
        else
        {
            int pos = ch - 31;

            if ((pos > 0) && (pos < 81))
            {
                posX_m = pos - 1;
            }
            else
            {
                posX_m = (cols_c - 1);
            }

            updated_m = true;
            mode_m    = Normal;
        }
    }
}
Пример #18
0
void LiteEditor::createActions()
{
    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor");

    m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this);
    actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo);

    m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this);
    actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y");

    m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this);
    actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut);

    m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this);
    actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy);

    m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this);
    actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste);

    m_selectAllAct = new QAction(tr("Select All"),this);
    actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll);

    m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this);
#ifndef QT_NO_PRINTER
    m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this);
    m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this);
    m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this);
#endif
    m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this);
    actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+[");

    m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this);
    actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]");


    m_selectBlockAct = new QAction(tr("Select Block"),this);
    actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U");

    m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this);
    actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E");

    m_foldAct = new QAction(tr("Fold"),this);   
    actionContext->regAction(m_foldAct,"Fold","Ctrl+<");

    m_unfoldAct = new QAction(tr("Unfold"),this);
    actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>");

    m_foldAllAct = new QAction(tr("Fold All"),this);
    actionContext->regAction(m_foldAllAct,"FoldAll","");

    m_unfoldAllAct = new QAction(tr("Unfold All"),this);
    actionContext->regAction(m_unfoldAllAct,"UnfoldAll","");

    connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold()));
    connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold()));
    connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll()));
    connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll()));

    m_gotoLineAct = new QAction(tr("Go To Line"),this);
    actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L");

    m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this);
    m_lockAct->setEnabled(false);

    m_duplicateAct = new QAction(tr("Duplicate"),this);
    actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+Shift+D");
    connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate()));

    m_deleteLineAct = new QAction(tr("Delete Line"),this);
    actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K");
    connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine()));

    m_copyLineAct = new QAction(tr("Copy Line"),this);
    actionContext->regAction(m_copyLineAct,"CopyLine","Ctrl+Ins");
    connect(m_copyLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(copyLine()));

    m_cutLineAct = new QAction(tr("Cut Line"),this);
    actionContext->regAction(m_cutLineAct,"CutLine","Shift+Del");
    connect(m_cutLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(cutLine()));

    m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this);
    actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return");
    connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore()));

    m_insertLineAfterAct = new QAction(tr("Insert Line After"),this);
    actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return");
    connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter()));

    m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++");

    m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-");

    m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0");

    m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this);
    actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace","");

    m_wordWrapAct = new QAction(tr("Word Wrap (MimeType)"),this);
    m_wordWrapAct->setCheckable(true);
    actionContext->regAction(m_wordWrapAct,"WordWrap","");

    m_codeCompleteAct = new QAction(tr("Code Complete"),this);
#ifdef Q_OS_MAC
    actionContext->regAction(m_codeCompleteAct,"CodeComplete","Meta+Space");
#else
    actionContext->regAction(m_codeCompleteAct,"CodeComplete","Ctrl+Space");
#endif

    m_commentAct = new QAction(tr("Toggle Comment"),this);
    actionContext->regAction(m_commentAct,"Comment","Ctrl+/");

    m_blockCommentAct = new QAction(tr("Toggle Block Commnet"),this);
    actionContext->regAction(m_blockCommentAct,"BlockComment","Ctrl+Shift+/");

    m_autoIndentAct = new QAction(tr("Auto-indent Selection"),this);
    actionContext->regAction(m_autoIndentAct,"AutoIndent","Ctrl+I");
    m_autoIndentAct->setVisible(false);

    m_tabToSpacesAct = new QAction(tr("Tab To Spaces (MimeType)"),this);
    actionContext->regAction(m_tabToSpacesAct,"TabToSpaces","");
    m_tabToSpacesAct->setCheckable(true);

    m_lineEndingWindowAct = new QAction(tr("Line End Windows (\\r\\n)"),this);
    actionContext->regAction(m_lineEndingWindowAct,"LineEndingWindow","");
    m_lineEndingWindowAct->setCheckable(true);

    m_lineEndingUnixAct = new QAction(tr("Line End Unix (\\n)"),this);
    actionContext->regAction(m_lineEndingUnixAct,"LineEndingUnix","");
    m_lineEndingUnixAct->setCheckable(true);

    m_visualizeWhitespaceAct = new QAction(tr("Visualize Whitespace (Global)"),this);
    actionContext->regAction(m_visualizeWhitespaceAct,"VisualizeWhitespace","");
    m_visualizeWhitespaceAct->setCheckable(true);

    m_commentAct->setVisible(false);
    m_blockCommentAct->setVisible(false);

    m_moveLineUpAction = new QAction(tr("Move Line Up"),this);
    actionContext->regAction(m_moveLineUpAction,"MoveLineUp","Ctrl+Shift+Up");

    m_moveLineDownAction = new QAction(tr("Move Line Down"),this);
    actionContext->regAction(m_moveLineDownAction,"MoveLineDown","Ctrl+Shift+Down");

    m_copyLineUpAction = new QAction(tr("Copy Line Up"),this);
    actionContext->regAction(m_copyLineUpAction,"CopyLineUp","Ctrl+Alt+Up");

    m_copyLineDownAction = new QAction(tr("Copy Line Down"),this);
    actionContext->regAction(m_copyLineDownAction,"CopyLineDown","Ctrl+Alt+Down");

    m_joinLinesAction = new QAction(tr("Join Lines"),this);
    actionContext->regAction(m_joinLinesAction,"JoinLines","Ctrl+J");

    connect(m_codeCompleteAct,SIGNAL(triggered()),m_editorWidget,SLOT(codeCompleter()));
//    m_widget->addAction(m_foldAct);
//    m_widget->addAction(m_unfoldAct);
//    m_widget->addAction(m_gotoLineAct);

//    m_widget->addAction(m_gotoPrevBlockAct);
//    m_widget->addAction(m_gotoNextBlockAct);
//    m_widget->addAction(m_selectBlockAct);
//    m_widget->addAction(m_gotoMatchBraceAct);

    connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool)));

    connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo()));
    connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo()));
    connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut()));
    connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy()));
    connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste()));
    connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll()));
    connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock()));

    connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml()));
#ifndef QT_NO_PRINTER
    connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf()));
    connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint()));
    connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview()));
#endif
    connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock()));
    connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock()));
    connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace()));
    connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine()));
    connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace()));
    connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool)));
    connect(m_commentAct,SIGNAL(triggered()),this,SLOT(comment()));
    connect(m_blockCommentAct,SIGNAL(triggered()),this,SLOT(blockComment()));
    connect(m_autoIndentAct,SIGNAL(triggered()),this,SLOT(autoIndent()));
    connect(m_tabToSpacesAct,SIGNAL(toggled(bool)),this,SLOT(tabToSpacesToggled(bool)));
    connect(m_visualizeWhitespaceAct,SIGNAL(toggled(bool)),this,SLOT(toggledVisualizeWhitespace(bool)));
    connect(m_moveLineUpAction,SIGNAL(triggered()),m_editorWidget,SLOT(moveLineUp()));
    connect(m_moveLineDownAction,SIGNAL(triggered()),m_editorWidget,SLOT(moveLineDown()));
    connect(m_copyLineUpAction,SIGNAL(triggered()),m_editorWidget,SLOT(copyLineUp()));
    connect(m_copyLineDownAction,SIGNAL(triggered()),m_editorWidget,SLOT(copyLineDown()));
    connect(m_joinLinesAction,SIGNAL(triggered()),m_editorWidget,SLOT(joinLines()));
    //connect(m_lineEndingWindowAct,SIGNAL(triggered()),this,SLOT(lineEndingWindow()));
    //connect(m_lineEndingUnixAct,SIGNAL(triggered()),this,SLOT(lineEndingUnixAct()));
    QActionGroup *group = new QActionGroup(this);
    group->addAction(m_lineEndingWindowAct);
    group->addAction(m_lineEndingUnixAct);
    connect(group,SIGNAL(triggered(QAction*)),this,SLOT(triggeredLineEnding(QAction*)));

#ifdef Q_OS_WIN
    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged()));
    clipbordDataChanged();
#endif
}
Пример #19
0
static int insertLine(int line, char *text)
{
	char *lineStr;
	int lineLen = 0;
	int i;
	char *insertPoint = NULL;
	char *end = NULL;
	char *newEnd = NULL;
	char *prog = NULL;

	prog = programGetProgram();
	if (!prog)
	{
		errorSet(ERROR_OUT_OF_MEMORY);
		return 0;
	}

	deleteLine(line);
	errorSet(ERROR_OK);

	lineStr = itos(line);

	lineLen = strlen(text) + strlen(lineStr) + 2; // add 1 for space and 1 for NL

		// Find insertion point

	insertPoint = programFindNextLineNumber(line);
	if (!insertPoint)
	{
		errorSet(ERROR_OUT_OF_MEMORY);
		return 0;
	}

		// Find end of current program

	end = prog + strlen(prog) - 1;

		// Calculate proposed end of edited program

	newEnd = end + lineLen;
	if ((newEnd - prog) > PROGRAM_SIZEOF_DATA_SPACE)
	{
		errorSet(ERROR_OUT_OF_MEMORY);
		return 0;
	}

		// Shuffle rest of program down, must be backwards

	for (; end >= insertPoint; --end, --newEnd)
		*newEnd = *end;

		// Copy in this line

	for (i = 0; i < strlen(lineStr); i++)
		insertPoint[i] = lineStr[i];

	insertPoint[i] = ' ';

	insertPoint += i + 1;

	for (i = 0; i < strlen(text); i++)
		insertPoint[i] = text[i];

	insertPoint[i] = '\n';

	return 1;
}
Пример #20
0
void LiteEditor::createActions()
{
    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor");

    m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this);
    actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo);

    m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this);
    actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y");

    m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this);
    actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut);

    m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this);
    actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy);

    m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this);
    actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste);

    m_selectAllAct = new QAction(tr("Select All"),this);
    actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll);

    m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this);
#ifndef QT_NO_PRINTER
    m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this);
    m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this);
    m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this);
#endif
    m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this);
    actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+[");

    m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this);
    actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]");


    m_selectBlockAct = new QAction(tr("Select Block"),this);
    actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U");

    m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this);
    actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E");

    m_foldAct = new QAction(tr("Fold"),this);   
    actionContext->regAction(m_foldAct,"Fold","Ctrl+<");

    m_unfoldAct = new QAction(tr("Unfold"),this);
    actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>");

    m_foldAllAct = new QAction(tr("Fold All"),this);
    actionContext->regAction(m_foldAllAct,"FoldAll","");

    m_unfoldAllAct = new QAction(tr("Unfold All"),this);
    actionContext->regAction(m_unfoldAllAct,"UnfoldAll","");

    connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold()));
    connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold()));
    connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll()));
    connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll()));

    m_gotoLineAct = new QAction(tr("Go To Line"),this);
    actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L");

    m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this);
    m_lockAct->setEnabled(false);

    m_duplicateAct = new QAction(tr("Duplicate"),this);
    actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+D");

    connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate()));

    m_deleteLineAct = new QAction(tr("Delete Line"),this);
    actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K");

    connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine()));

    m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this);
    actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return");
    connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore()));

    m_insertLineAfterAct = new QAction(tr("Insert Line After"),this);
    actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return");
    connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter()));

    m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++;Ctrl+=");

    m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-");

    m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0");

    m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this);
    actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace","");

    m_wordWrapAct = new QAction(tr("Word Wrap"),this);
    m_wordWrapAct->setCheckable(true);
    actionContext->regAction(m_wordWrapAct,"WordWrap","");

//    m_widget->addAction(m_foldAct);
//    m_widget->addAction(m_unfoldAct);
//    m_widget->addAction(m_gotoLineAct);

//    m_widget->addAction(m_gotoPrevBlockAct);
//    m_widget->addAction(m_gotoNextBlockAct);
//    m_widget->addAction(m_selectBlockAct);
//    m_widget->addAction(m_gotoMatchBraceAct);

    connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool)));
    connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool)));

    connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo()));
    connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo()));
    connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut()));
    connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy()));
    connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste()));
    connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll()));
    connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock()));

    connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml()));
#ifndef QT_NO_PRINTER
    connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf()));
    connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint()));
    connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview()));
#endif
    connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock()));
    connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock()));
    connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace()));
    connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine()));
    connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace()));
    connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool)));

    QClipboard *clipboard = QApplication::clipboard();
    connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged()));
    clipbordDataChanged();
}
Пример #21
0
void Editor::handleInsertModeInput(int c)
{
    std::lock_guard<std::recursive_mutex> lock(_mutex);
    switch(c)
    {
        case 27:
            // Escape/Alt key
            _mode = NORMAL;
            break;
        case 127:
        case KEY_BACKSPACE:
            // The Backspace
            if(_x == 0 && _y > 0)
            {
                _x = _pBuff->lines[_y-1].length();
                // Bring line down
                _pBuff->lines[_y-1] += _pBuff->lines[_y];
                // Delete the line
                deleteLine();
                moveUp();
            }
            else if(_x > 0)
            {
                _pBuff->lines[_y].erase(--_x, 1);
            }
            break;
        case KEY_DC:
            // The Delete key
            if(_x == _pBuff->lines[_y].length() && _y != _pBuff->lines.size()-1)
            {
                // Bring line down
                _pBuff->lines[_y] += _pBuff->lines[_y+1];
                // Delete the line
                deleteLine(_y+1);
            }
            else
            {
                _pBuff->lines[_y].erase(_x, 1);
            }
            break;
        case KEY_LEFT:
            moveLeft();
            break;
        case KEY_RIGHT:
            moveRight();
            break;
        case KEY_UP:
            moveUp();
            break;
        case KEY_DOWN:
            moveDown();
            break;
        case KEY_ENTER:
        case 10:
            // Bring rest of line down
            if(_x < _pBuff->lines[_y+_lowerbound].length()-1)
            {
                // Put rest of line on new line
                _pBuff->insertLine(_pBuff->lines[_y+_lowerbound].substr(_x, _pBuff->lines[_y+_lowerbound].length()-_x), _y+1);
                // Remove that part of the line
                _pBuff->lines[_y+_lowerbound].erase(_x, _pBuff->lines[_y+_lowerbound].length()-_x);
            }
            else
                _pBuff->insertLine("", _y+_lowerbound+1);
            moveDown();
            break;
        case KEY_BTAB:
        case KEY_CTAB:
        case KEY_STAB:
        case KEY_CATAB:
        case 9:
            // The tab
            _pBuff->lines[_y+_lowerbound].insert(_x, 4, ' ');
            _x+=4;
            break;
        default:
            _pBuff->lines[_y+_lowerbound].insert(_x, 1, char(c));
            _x++;
            break;
    }

}
Пример #22
0
void Board::clearPossibleLines()
{
    for ( int i = 0; i < rows; i++ )
        if ( lineIsFull( i ) )
            deleteLine( i );
}
Пример #23
0
void QgsGrassEdit::init()
{
  if ( !( mProvider->isGrassEditable() ) )
  {
    QMessageBox::warning( 0, tr( "Warning" ),
                          tr( "You are not owner of the mapset, cannot open the vector for editing." ) );
    return;
  }

  if ( !( mProvider->startEdit() ) )
  {
    QMessageBox::warning( 0, tr( "Warning" ), tr( "Cannot open vector for update." ) );
    return;
  }

  mRubberBandLine = new QgsRubberBand( mCanvas );
  mRubberBandIcon = new QgsVertexMarker( mCanvas );
  mRubberBandLine->setZValue( 20 );
  mRubberBandIcon->setZValue( 20 );

  connect( mCanvas, SIGNAL( keyPressed( QKeyEvent * ) ), this, SLOT( keyPress( QKeyEvent * ) ) );


  mToolBar = addToolBar( tr( "Edit tools" ) );

  mNewPointAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_point.png" ), tr( "New point" ), this );
  mNewPointAction->setShortcut( QKeySequence( Qt::Key_F1 ) );
  mToolBar->addAction( mNewPointAction );
  connect( mNewPointAction, SIGNAL( triggered() ), this, SLOT( newPoint() ) );

  mNewLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_line.png" ), tr( "New line" ), this );
  mNewLineAction->setShortcut( QKeySequence( Qt::Key_F2 ) );
  mToolBar->addAction( mNewLineAction );
  connect( mNewLineAction, SIGNAL( triggered() ), this, SLOT( newLine() ) );

  mNewBoundaryAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_boundary.png" ), tr( "New boundary" ), this );
  mNewBoundaryAction->setShortcut( QKeySequence( Qt::Key_F3 ) );
  mToolBar->addAction( mNewBoundaryAction );
  connect( mNewBoundaryAction, SIGNAL( triggered() ), this, SLOT( newBoundary() ) );

  mNewCentroidAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_new_centroid.png" ), tr( "New centroid" ), this );
  mNewCentroidAction->setShortcut( QKeySequence( Qt::Key_F4 ) );
  mToolBar->addAction( mNewCentroidAction );
  connect( mNewCentroidAction, SIGNAL( triggered() ), this, SLOT( newCentroid() ) );

  mMoveVertexAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_move_vertex.png" ), tr( "Move vertex" ), this );
  mMoveVertexAction->setShortcut( QKeySequence( Qt::Key_F5 ) );
  mToolBar->addAction( mMoveVertexAction );
  connect( mMoveVertexAction, SIGNAL( triggered() ), this, SLOT( moveVertex() ) );

  mAddVertexAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_add_vertex.png" ), tr( "Add vertex" ), this );
  mAddVertexAction->setShortcut( QKeySequence( Qt::Key_F6 ) );
  mToolBar->addAction( mAddVertexAction );
  connect( mAddVertexAction, SIGNAL( triggered() ), this, SLOT( addVertex() ) );

  mDeleteVertexAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_delete_vertex.png" ), tr( "Delete vertex" ), this );
  mDeleteVertexAction->setShortcut( QKeySequence( Qt::Key_F7 ) );
  mToolBar->addAction( mDeleteVertexAction );
  connect( mDeleteVertexAction, SIGNAL( triggered() ), this, SLOT( deleteVertex() ) );

  mMoveLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_move_line.png" ), tr( "Move element" ), this );
  mMoveLineAction->setShortcut( QKeySequence( Qt::Key_F9 ) );
  mToolBar->addAction( mMoveLineAction );
  connect( mMoveLineAction, SIGNAL( triggered() ), this, SLOT( moveLine() ) );

  mSplitLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_split_line.png" ), tr( "Split line" ), this );
  mSplitLineAction->setShortcut( QKeySequence( Qt::Key_F10 ) );
  mToolBar->addAction( mSplitLineAction );
  connect( mSplitLineAction, SIGNAL( triggered() ), this, SLOT( splitLine() ) );

  mDeleteLineAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_delete_line.png" ), tr( "Delete element" ), this );
  mDeleteLineAction->setShortcut( QKeySequence( Qt::Key_F11 ) );
  mToolBar->addAction( mDeleteLineAction );
  connect( mDeleteLineAction, SIGNAL( triggered() ), this, SLOT( deleteLine() ) );

  mEditAttributesAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_edit_attributes.png" ), tr( "Edit attributes" ), this );
  mToolBar->addAction( mEditAttributesAction );
  connect( mEditAttributesAction, SIGNAL( triggered() ), this, SLOT( editAttributes() ) );

  mCloseEditAction = new QAction(
    QgsGrassPlugin::getThemeIcon( "grass_close_edit.png" ), tr( "Close" ), this );
  mToolBar->addAction( mCloseEditAction );
  connect( mCloseEditAction, SIGNAL( triggered() ), this, SLOT( closeEdit() ) );

  mNewPointAction->setCheckable( true );
  mNewLineAction->setCheckable( true );
  mNewBoundaryAction->setCheckable( true );
  mNewCentroidAction->setCheckable( true );
  mMoveVertexAction->setCheckable( true );
  mAddVertexAction->setCheckable( true );
  mDeleteVertexAction->setCheckable( true );
  mMoveLineAction->setCheckable( true );
  mSplitLineAction->setCheckable( true );
  mDeleteLineAction->setCheckable( true );
  mEditAttributesAction->setCheckable( true );

  QActionGroup *ag = new QActionGroup( this );
  ag->addAction( mNewPointAction );
  ag->addAction( mNewLineAction );
  ag->addAction( mNewBoundaryAction );
  ag->addAction( mNewCentroidAction );
  ag->addAction( mMoveVertexAction );
  ag->addAction( mAddVertexAction );
  ag->addAction( mDeleteVertexAction );
  ag->addAction( mMoveLineAction );
  ag->addAction( mSplitLineAction );
  ag->addAction( mDeleteLineAction );
  ag->addAction( mEditAttributesAction );

  mEditPoints = Vect_new_line_struct();
  mPoints = Vect_new_line_struct();
  mCats = Vect_new_cats_struct();

  // Set lines symbology from map
  int nlines = mProvider->numLines();
  mLineSymb.resize( nlines + 1000 );
  for ( int line = 1; line <= nlines; line++ )
  {
    mLineSymb[line] = lineSymbFromMap( line );
  }

  // Set nodes symbology from map
  int nnodes = mProvider->numNodes();
  mNodeSymb.resize( nnodes + 1000 );
  for ( int node = 1; node <= nnodes; node++ )
  {
    mNodeSymb[node] = nodeSymbFromMap( node );
  }

  // Set default colors
  mSymb.resize( SYMB_COUNT );
  mSymb[SYMB_BACKGROUND].setColor( QColor( 255, 255, 255 ) );       // white
  mSymb[SYMB_HIGHLIGHT].setColor( QColor( 255, 255,   0 ) );        // yellow
  mSymb[SYMB_DYNAMIC].setColor( QColor( 125, 125, 125 ) );          // grey
  mSymb[SYMB_POINT].setColor( QColor( 0,   0,   0 ) );              // black
  mSymb[SYMB_LINE].setColor( QColor( 0,   0,   0 ) );               // black
  mSymb[SYMB_BOUNDARY_0].setColor( QColor( 255,   0,   0 ) );       // red
  mSymb[SYMB_BOUNDARY_1].setColor( QColor( 255, 125,   0 ) );       // orange
  mSymb[SYMB_BOUNDARY_2].setColor( QColor( 0, 255,   0 ) );         // green
  mSymb[SYMB_CENTROID_IN].setColor( QColor( 0, 255,   0 ) );        // green
  mSymb[SYMB_CENTROID_OUT].setColor( QColor( 255,   0,   0 ) );     // red
  mSymb[SYMB_CENTROID_DUPL].setColor( QColor( 255,   0, 255 ) );    // magenta
  mSymb[SYMB_NODE_1].setColor( QColor( 255,   0,   0 ) );           // red
  mSymb[SYMB_NODE_2].setColor( QColor( 0, 255,   0 ) );             // green

  // Set mSymbDisplay
  mSymbDisplay.resize( SYMB_COUNT );
  mSymbDisplay[SYMB_BACKGROUND] = true;
  mSymbDisplay[SYMB_HIGHLIGHT] = true;
  mSymbDisplay[SYMB_DYNAMIC] = true;
  mSymbDisplay[SYMB_POINT] = true;
  mSymbDisplay[SYMB_LINE] = true;
  mSymbDisplay[SYMB_BOUNDARY_0] = true;
  mSymbDisplay[SYMB_BOUNDARY_1] = true;
  mSymbDisplay[SYMB_BOUNDARY_2] = true;
  mSymbDisplay[SYMB_CENTROID_IN] = true;
  mSymbDisplay[SYMB_CENTROID_OUT] = true;
  mSymbDisplay[SYMB_CENTROID_DUPL] = true;
  mSymbDisplay[SYMB_NODE_1] = true;
  mSymbDisplay[SYMB_NODE_2] = true;

  // Set symbology names
  mSymbName.resize( SYMB_COUNT );
  mSymbName[SYMB_BACKGROUND]    = tr( "Background" );
  mSymbName[SYMB_HIGHLIGHT]     = tr( "Highlight" );
  mSymbName[SYMB_DYNAMIC]       = tr( "Dynamic" );
  mSymbName[SYMB_POINT]         = tr( "Point" );
  mSymbName[SYMB_LINE]          = tr( "Line" );
  mSymbName[SYMB_BOUNDARY_0]    = tr( "Boundary (no area)" );
  mSymbName[SYMB_BOUNDARY_1]    = tr( "Boundary (1 area)" );
  mSymbName[SYMB_BOUNDARY_2]    = tr( "Boundary (2 areas)" );
  mSymbName[SYMB_CENTROID_IN]   = tr( "Centroid (in area)" );
  mSymbName[SYMB_CENTROID_OUT]  = tr( "Centroid (outside area)" );
  mSymbName[SYMB_CENTROID_DUPL] = tr( "Centroid (duplicate in area)" );
  mSymbName[SYMB_NODE_1]        = tr( "Node (1 line)" );
  mSymbName[SYMB_NODE_2]        = tr( "Node (2 lines)" );

  // Restore symbology
  QString spath = "/GRASS/edit/symb/";
  QSettings settings;

  mLineWidth = settings.value(
                 spath + "lineWidth", 1 ).toInt();
  mSize = settings.value(
            spath + "markerSize", 9 ).toInt();
  mLineWidthSpinBox->setValue( mLineWidth );
  mMarkerSizeSpinBox->setValue( mSize );

  for ( int i = 0; i < SYMB_COUNT; i++ )
  {
    bool ok = settings.contains(
                spath + "display/" + QString::number( i ) );
    bool displ = settings.value(
                   spath + "display/" + QString::number( i ),
                   true ).toBool();
    if ( ok )
    {
      mSymbDisplay[i] = displ;
    }

    ok = settings.contains(
           spath + "color/" + QString::number( i ) );
    QString colorName = settings.value(
                          spath + "color/" + QString::number( i ),
                          "" ).toString();
    if ( ok )
    {
      QColor color( colorName );
      mSymb[i].setColor( color );
      // Use the 'dynamic' color for mRubberBand
      if ( i == SYMB_DYNAMIC )
      {
        mRubberBandLine->setColor( QColor( colorName ) );
      }
    }
    mSymb[i].setWidth( mLineWidth );
  }

  // Set Symbology in dialog
  symbologyList->setColumnWidth( 0, 40 );
  symbologyList->setColumnWidth( 1, 50 );
  symbologyList->setColumnWidth( 2, 200 );

  for ( int i = 0; i < SYMB_COUNT; i++ )
  {
    if ( i == SYMB_NODE_0 )
      continue;

    QPixmap pm( 40, 15 );
    pm.fill( mSymb[i].color() );
    QString index;
    index.sprintf( "%d", i );

    QTreeWidgetItem *item = new QTreeWidgetItem( symbologyList );
    if ( !( i == SYMB_BACKGROUND || i == SYMB_HIGHLIGHT || i == SYMB_DYNAMIC ) )
    {
      item->setCheckState( 0, mSymbDisplay[i] ? Qt::Checked : Qt::Unchecked );
    }
    item->setIcon( 1, pm );
    item->setText( 2, mSymbName[i] );
    item->setText( 3, index );
  }

  connect( symbologyList, SIGNAL( itemPressed( QTreeWidgetItem *, int ) ),
           this, SLOT( changeSymbology( QTreeWidgetItem *, int ) ) );

  // Init table tab
  mAttributeTable->setItemDelegate( new QgsGrassEditAttributeTableItemDelegate( this ) );
  mAttributeTable->verticalHeader()->hide();

  int ndblinks = mProvider->numDbLinks();

  if ( ndblinks > 0 )
  {
    for ( int i = 0; i < ndblinks; i++ )
    {
      int f = mProvider->dbLinkField( i );

      QString str;
      str.sprintf( "%d", f );
      mTableField->addItem( str );
      mFieldBox->addItem( str );
      if ( i == 0 )
      {
        setAttributeTable( f );
      }
    }
    mTableField->setCurrentIndex( 0 );
    mFieldBox->setCurrentIndex( 0 );
  }
  else
  {
    mTableField->addItem( "1" );
    setAttributeTable( 1 );

    mFieldBox->addItem( "1" );
  }

  connect( mAttributeTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( columnTypeChanged( int, int ) ) );

  // Set variables
  mSelectedLine = 0;
  mAttributes = 0;

  // Read max cats
  for ( int i = 0; i < mProvider->cidxGetNumFields(); i++ )
  {
    int field = mProvider->cidxGetFieldNumber( i );
    if ( field > 0 )
    {
      int cat = mProvider->cidxGetMaxCat( i );
      MaxCat mc;
      mc.field = field;
      mc.maxCat = cat;
      mMaxCats.push_back( mc );
    }
  }

  connect( mCanvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( postRender( QPainter * ) ) );

  mCanvasEdit = new QgsGrassEditLayer( mCanvas );

  mPixmap = &mCanvasEdit->pixmap();

  // Init GUI values
  mCatModeBox->addItem( tr( "Next not used" ), CAT_MODE_NEXT );
  mCatModeBox->addItem( tr( "Manual entry" ), CAT_MODE_MANUAL );
  mCatModeBox->addItem( tr( "No category" ), CAT_MODE_NOCAT );
  catModeChanged( );

  // TODO: how to get keyboard events from canvas (shortcuts)

  restorePosition();

  mValid = true;
  mInited = true;
}